[Python-checkins] python/dist/src/PC/os2emx dlfcn.c,1.1,1.2 dlfcn.h,1.1,1.2 dllentry.c,1.3,1.4 getpathp.c,1.2,1.3
aimacintyre@users.sourceforge.net
aimacintyre@users.sourceforge.net
Mon, 21 Apr 2003 20:21:46 -0700
Update of /cvsroot/python/python/dist/src/PC/os2emx
In directory sc8-pr-cvs1:/tmp/cvs-serv7070
Modified Files:
dlfcn.c dlfcn.h dllentry.c getpathp.c
Log Message:
minor cleanups and whitespace normalisation
Index: dlfcn.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/os2emx/dlfcn.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dlfcn.c 17 Feb 2002 05:23:30 -0000 1.1
--- dlfcn.c 22 Apr 2003 03:21:42 -0000 1.2
***************
*** 30,37 ****
******************************************************************/
! /*
! This library implements dlopen() - functions for OS/2 using
! DosLoadModule() and company.
! */
#define INCL_DOS
--- 30,36 ----
******************************************************************/
! /* This library implements dlopen() - Unix-like dynamic linking
! * emulation functions for OS/2 using DosLoadModule() and company.
! */
#define INCL_DOS
***************
*** 47,52 ****
#include <malloc.h>
- /*-------------------------------------- Unix-like dynamic linking emulation -*/
-
typedef struct _track_rec {
char *name;
--- 46,49 ----
***************
*** 56,61 ****
} tDLLchain, *DLLchain;
! static DLLchain dlload = NULL; /* A simple chained list of DLL names */
! static char dlerr [256]; /* last error text string */
static void *last_id;
--- 53,58 ----
} tDLLchain, *DLLchain;
! static DLLchain dlload = NULL; /* A simple chained list of DLL names */
! static char dlerr [256]; /* last error text string */
static void *last_id;
***************
*** 66,76 ****
for (tmp = dlload; tmp; tmp = tmp->next)
if (id == tmp->id)
! return (tmp);
! return (NULL);
}
/* load a dynamic-link library and return handle */
! void *dlopen (char *filename, int flags)
{
HMODULE hm;
--- 63,73 ----
for (tmp = dlload; tmp; tmp = tmp->next)
if (id == tmp->id)
! return tmp;
! return NULL;
}
/* load a dynamic-link library and return handle */
! void *dlopen(char *filename, int flags)
{
HMODULE hm;
***************
*** 86,93 ****
if (!tmp)
{
! tmp = (DLLchain)malloc (sizeof (tDLLchain));
if (!tmp)
goto nomem;
! tmp->name = strdup (filename);
tmp->next = dlload;
set_chain = 1;
--- 83,90 ----
if (!tmp)
{
! tmp = (DLLchain) malloc(sizeof(tDLLchain));
if (!tmp)
goto nomem;
! tmp->name = strdup(filename);
tmp->next = dlload;
set_chain = 1;
***************
*** 98,109 ****
case NO_ERROR:
tmp->handle = hm;
! if (set_chain) {
! do {
last_id++;
! } while ((last_id == 0) || (find_id(last_id)));
tmp->id = last_id;
dlload = tmp;
}
! return (tmp->id);
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
--- 95,107 ----
case NO_ERROR:
tmp->handle = hm;
! if (set_chain)
! {
! do
last_id++;
! while ((last_id == 0) || (find_id(last_id)));
tmp->id = last_id;
dlload = tmp;
}
! return tmp->id;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
***************
*** 146,160 ****
break;
}
! snprintf (dlerr, sizeof (dlerr), errtxt, &err, rc);
! if (tmp) {
if (tmp->name)
free(tmp->name);
! free (tmp);
}
! return (0);
}
/* return a pointer to the `symbol' in DLL */
! void *dlsym (void *handle, char *symbol)
{
int rc = 0;
--- 144,159 ----
break;
}
! snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc);
! if (tmp)
! {
if (tmp->name)
free(tmp->name);
! free(tmp);
}
! return 0;
}
/* return a pointer to the `symbol' in DLL */
! void *dlsym(void *handle, char *symbol)
{
int rc = 0;
***************
*** 162,166 ****
char *errtxt;
int symord = 0;
! DLLchain tmp = find_id (handle);
if (!tmp)
--- 161,165 ----
char *errtxt;
int symord = 0;
! DLLchain tmp = find_id(handle);
if (!tmp)
***************
*** 168,177 ****
if (*symbol == '#')
! symord = atoi (symbol + 1);
switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
{
case NO_ERROR:
! return ((void *)addr);
case ERROR_INVALID_HANDLE:
inv_handle:
--- 167,176 ----
if (*symbol == '#')
! symord = atoi(symbol + 1);
switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
{
case NO_ERROR:
! return (void *)addr;
case ERROR_INVALID_HANDLE:
inv_handle:
***************
*** 186,218 ****
break;
}
! snprintf (dlerr, sizeof (dlerr), errtxt, symbol, rc);
! return (NULL);
}
/* free dynamicaly-linked library */
! int dlclose (void *handle)
{
int rc;
! DLLchain tmp = find_id (handle);
if (!tmp)
goto inv_handle;
! switch (rc = DosFreeModule (tmp->handle))
{
case NO_ERROR:
! free (tmp->name);
dlload = tmp->next;
! free (tmp);
! return (0);
case ERROR_INVALID_HANDLE:
inv_handle:
strcpy(dlerr, "invalid module handle");
! return (-1);
case ERROR_INVALID_ACCESS:
! strcpy (dlerr, "access denied");
! return (-1);
default:
! return (-1);
}
}
--- 185,217 ----
break;
}
! snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc);
! return NULL;
}
/* free dynamicaly-linked library */
! int dlclose(void *handle)
{
int rc;
! DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
! switch (rc = DosFreeModule(tmp->handle))
{
case NO_ERROR:
! free(tmp->name);
dlload = tmp->next;
! free(tmp);
! return 0;
case ERROR_INVALID_HANDLE:
inv_handle:
strcpy(dlerr, "invalid module handle");
! return -1;
case ERROR_INVALID_ACCESS:
! strcpy(dlerr, "access denied");
! return -1;
default:
! return -1;
}
}
***************
*** 221,224 ****
char *dlerror()
{
! return (dlerr);
}
--- 220,223 ----
char *dlerror()
{
! return dlerr;
}
Index: dlfcn.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/os2emx/dlfcn.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dlfcn.h 17 Feb 2002 05:23:30 -0000 1.1
--- dlfcn.h 22 Apr 2003 03:21:42 -0000 1.2
***************
*** 30,48 ****
******************************************************************/
! /*
! This library implements dlopen() - functions for OS/2 using
! DosLoadModule() and company.
! */
#ifndef _DLFCN_H
#define _DLFCN_H
- /*-------------------------------------- Unix-like dynamic linking emulation -*/
/* load a dynamic-link library and return handle */
! void *dlopen (char *filename, int flags);
/* return a pointer to the `symbol' in DLL */
! void *dlsym (void *handle, char *symbol);
/* free dynamicaly-linked library */
! int dlclose (void *handle);
/* return a string describing last occured dl error */
char *dlerror(void);
--- 30,49 ----
******************************************************************/
! /* This library implements dlopen() - Unix-like dynamic linking
! * emulation functions for OS/2 using DosLoadModule() and company.
! */
#ifndef _DLFCN_H
#define _DLFCN_H
/* load a dynamic-link library and return handle */
! void *dlopen(char *filename, int flags);
!
/* return a pointer to the `symbol' in DLL */
! void *dlsym(void *handle, char *symbol);
!
/* free dynamicaly-linked library */
! int dlclose(void *handle);
!
/* return a string describing last occured dl error */
char *dlerror(void);
Index: dllentry.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/os2emx/dllentry.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dllentry.c 31 Dec 2002 11:23:50 -0000 1.3
--- dllentry.c 22 Apr 2003 03:21:42 -0000 1.4
***************
*** 1,39 ****
/*
! This is the entry point for Python DLL(s).
! It also provides an getenv() function that works from within DLLs.
! */
#define NULL 0
! /* Make references to imported symbols to pull them from static library */
! #define REF(s) extern void s (); void *____ref_##s = &s;
! REF (Py_Main);
#include <signal.h>
! extern int _CRT_init (void);
! extern void _CRT_term (void);
! extern void __ctordtorInit (void);
! extern void __ctordtorTerm (void);
! unsigned long _DLL_InitTerm (unsigned long mod_handle, unsigned long flag)
{
switch (flag)
{
case 0:
! if (_CRT_init ())
return 0;
! __ctordtorInit ();
/* Ignore fatal signals */
! signal (SIGSEGV, SIG_IGN);
! signal (SIGFPE, SIG_IGN);
return 1;
case 1:
! __ctordtorTerm ();
! _CRT_term ();
return 1;
--- 1,38 ----
/*
! * This is the entry point for the Python 2.3 core DLL.
! */
#define NULL 0
! #define REF(s) extern void s(); void *____ref_##s = &s;
! /* Make references to imported symbols to pull them from static library */
! REF(Py_Main);
#include <signal.h>
! extern int _CRT_init(void);
! extern void _CRT_term(void);
! extern void __ctordtorInit(void);
! extern void __ctordtorTerm(void);
! unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag)
{
switch (flag)
{
case 0:
! if (_CRT_init())
return 0;
! __ctordtorInit();
/* Ignore fatal signals */
! signal(SIGSEGV, SIG_IGN);
! signal(SIGFPE, SIG_IGN);
return 1;
case 1:
! __ctordtorTerm();
! _CRT_term();
return 1;
Index: getpathp.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/os2emx/getpathp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** getpathp.c 2 Jan 2003 12:41:58 -0000 1.2
--- getpathp.c 22 Apr 2003 03:21:42 -0000 1.3
***************
*** 95,101 ****
}
! /* assumes 'dir' null terminated in bounds. Never writes
! beyond existing terminator.
! */
static void
reduce(char *dir)
--- 95,101 ----
}
! /* assumes 'dir' null terminated in bounds.
! * Never writes beyond existing terminator.
! */
static void
reduce(char *dir)
***************
*** 114,122 ****
}
! /* Assumes 'filename' MAXPATHLEN+1 bytes long -
! may extend 'filename' by one character.
! */
static int
! ismodule(char *filename) /* Is module -- check for .pyc/.pyo too */
{
if (exists(filename))
--- 114,123 ----
}
! /* Is module (check for .pyc/.pyo too)
! * Assumes 'filename' MAXPATHLEN+1 bytes long -
! * may extend 'filename' by one character.
! */
static int
! ismodule(char *filename)
{
if (exists(filename))
***************
*** 152,158 ****
/* gotlandmark only called by search_for_prefix, which ensures
! 'prefix' is null terminated in bounds. join() ensures
! 'landmark' can not overflow prefix if too long.
! */
static int
gotlandmark(char *landmark)
--- 153,159 ----
/* gotlandmark only called by search_for_prefix, which ensures
! * 'prefix' is null terminated in bounds. join() ensures
! * 'landmark' can not overflow prefix if too long.
! */
static int
gotlandmark(char *landmark)
***************
*** 168,172 ****
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
! assumption provided by only caller, calculate_path() */
static int
search_for_prefix(char *argv0_path, char *landmark)
--- 169,174 ----
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
! * assumption provided by only caller, calculate_path()
! */
static int
search_for_prefix(char *argv0_path, char *landmark)
***************
*** 284,294 ****
/* We need to construct a path from the following parts.
! (1) the PYTHONPATH environment variable, if set;
! (2) the zip archive file path;
! (3) the PYTHONPATH config macro, with the leading "."
! of each component replaced with pythonhome, if set;
! (4) the directory containing the executable (argv0_path).
! The length calculation calculates #3 first.
! */
/* Calculate size of return buffer */
--- 286,296 ----
/* We need to construct a path from the following parts.
! * (1) the PYTHONPATH environment variable, if set;
! * (2) the zip archive file path;
! * (3) the PYTHONPATH config macro, with the leading "."
! * of each component replaced with pythonhome, if set;
! * (4) the directory containing the executable (argv0_path).
! * The length calculation calculates #3 first.
! */
/* Calculate size of return buffer */