summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2003-04-22 03:21:42 (GMT)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2003-04-22 03:21:42 (GMT)
commit0c83348d5c110a6ca706219019e97d5cefe2fddb (patch)
treebd4be5331c889044de6470147d476e90b2373171 /PC
parent699cbb767628888901d1a3c1f0ce20dd3ce1e4f9 (diff)
downloadcpython-0c83348d5c110a6ca706219019e97d5cefe2fddb.zip
cpython-0c83348d5c110a6ca706219019e97d5cefe2fddb.tar.gz
cpython-0c83348d5c110a6ca706219019e97d5cefe2fddb.tar.bz2
minor cleanups and whitespace normalisation
Diffstat (limited to 'PC')
-rw-r--r--PC/os2emx/dlfcn.c75
-rw-r--r--PC/os2emx/dlfcn.h17
-rw-r--r--PC/os2emx/dllentry.c33
-rw-r--r--PC/os2emx/getpathp.c38
4 files changed, 82 insertions, 81 deletions
diff --git a/PC/os2emx/dlfcn.c b/PC/os2emx/dlfcn.c
index acf0197..c9307da 100644
--- a/PC/os2emx/dlfcn.c
+++ b/PC/os2emx/dlfcn.c
@@ -29,10 +29,9 @@ PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
-/*
- This library implements dlopen() - functions for OS/2 using
- DosLoadModule() and company.
-*/
+/* This library implements dlopen() - Unix-like dynamic linking
+ * emulation functions for OS/2 using DosLoadModule() and company.
+ */
#define INCL_DOS
#define INCL_DOSERRORS
@@ -46,8 +45,6 @@ PERFORMANCE OF THIS SOFTWARE.
#include <string.h>
#include <malloc.h>
-/*-------------------------------------- Unix-like dynamic linking emulation -*/
-
typedef struct _track_rec {
char *name;
HMODULE handle;
@@ -55,8 +52,8 @@ typedef struct _track_rec {
struct _track_rec *next;
} tDLLchain, *DLLchain;
-static DLLchain dlload = NULL; /* A simple chained list of DLL names */
-static char dlerr [256]; /* last error text string */
+static DLLchain dlload = NULL; /* A simple chained list of DLL names */
+static char dlerr [256]; /* last error text string */
static void *last_id;
static DLLchain find_id(void *id)
@@ -65,13 +62,13 @@ static DLLchain find_id(void *id)
for (tmp = dlload; tmp; tmp = tmp->next)
if (id == tmp->id)
- return (tmp);
+ return tmp;
- return (NULL);
+ return NULL;
}
/* load a dynamic-link library and return handle */
-void *dlopen (char *filename, int flags)
+void *dlopen(char *filename, int flags)
{
HMODULE hm;
DLLchain tmp;
@@ -85,10 +82,10 @@ void *dlopen (char *filename, int flags)
if (!tmp)
{
- tmp = (DLLchain)malloc (sizeof (tDLLchain));
+ tmp = (DLLchain) malloc(sizeof(tDLLchain));
if (!tmp)
goto nomem;
- tmp->name = strdup (filename);
+ tmp->name = strdup(filename);
tmp->next = dlload;
set_chain = 1;
}
@@ -97,14 +94,15 @@ void *dlopen (char *filename, int flags)
{
case NO_ERROR:
tmp->handle = hm;
- if (set_chain) {
- do {
+ if (set_chain)
+ {
+ do
last_id++;
- } while ((last_id == 0) || (find_id(last_id)));
+ while ((last_id == 0) || (find_id(last_id)));
tmp->id = last_id;
dlload = tmp;
}
- return (tmp->id);
+ return tmp->id;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errtxt = "module `%s' not found";
@@ -145,34 +143,35 @@ nomem:
errtxt = "cause `%s', error code = %d";
break;
}
- snprintf (dlerr, sizeof (dlerr), errtxt, &err, rc);
- if (tmp) {
+ snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc);
+ if (tmp)
+ {
if (tmp->name)
free(tmp->name);
- free (tmp);
+ free(tmp);
}
- return (0);
+ return 0;
}
/* return a pointer to the `symbol' in DLL */
-void *dlsym (void *handle, char *symbol)
+void *dlsym(void *handle, char *symbol)
{
int rc = 0;
PFN addr;
char *errtxt;
int symord = 0;
- DLLchain tmp = find_id (handle);
+ DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
if (*symbol == '#')
- symord = atoi (symbol + 1);
+ symord = atoi(symbol + 1);
switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
{
case NO_ERROR:
- return ((void *)addr);
+ return (void *)addr;
case ERROR_INVALID_HANDLE:
inv_handle:
errtxt = "invalid module handle";
@@ -185,40 +184,40 @@ inv_handle:
errtxt = "symbol `%s', error code = %d";
break;
}
- snprintf (dlerr, sizeof (dlerr), errtxt, symbol, rc);
- return (NULL);
+ snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc);
+ return NULL;
}
/* free dynamicaly-linked library */
-int dlclose (void *handle)
+int dlclose(void *handle)
{
int rc;
- DLLchain tmp = find_id (handle);
+ DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
- switch (rc = DosFreeModule (tmp->handle))
+ switch (rc = DosFreeModule(tmp->handle))
{
case NO_ERROR:
- free (tmp->name);
+ free(tmp->name);
dlload = tmp->next;
- free (tmp);
- return (0);
+ free(tmp);
+ return 0;
case ERROR_INVALID_HANDLE:
inv_handle:
strcpy(dlerr, "invalid module handle");
- return (-1);
+ return -1;
case ERROR_INVALID_ACCESS:
- strcpy (dlerr, "access denied");
- return (-1);
+ strcpy(dlerr, "access denied");
+ return -1;
default:
- return (-1);
+ return -1;
}
}
/* return a string describing last occured dl error */
char *dlerror()
{
- return (dlerr);
+ return dlerr;
}
diff --git a/PC/os2emx/dlfcn.h b/PC/os2emx/dlfcn.h
index 214ddac..c429834 100644
--- a/PC/os2emx/dlfcn.h
+++ b/PC/os2emx/dlfcn.h
@@ -29,21 +29,22 @@ PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
-/*
- This library implements dlopen() - functions for OS/2 using
- DosLoadModule() and company.
-*/
+/* This library implements dlopen() - Unix-like dynamic linking
+ * emulation 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);
+void *dlopen(char *filename, int flags);
+
/* return a pointer to the `symbol' in DLL */
-void *dlsym (void *handle, char *symbol);
+void *dlsym(void *handle, char *symbol);
+
/* free dynamicaly-linked library */
-int dlclose (void *handle);
+int dlclose(void *handle);
+
/* return a string describing last occured dl error */
char *dlerror(void);
diff --git a/PC/os2emx/dllentry.c b/PC/os2emx/dllentry.c
index ea8d366..dbf9c98 100644
--- a/PC/os2emx/dllentry.c
+++ b/PC/os2emx/dllentry.c
@@ -1,40 +1,39 @@
/*
- This is the entry point for Python DLL(s).
- It also provides an getenv() function that works from within DLLs.
-*/
+ * This is the entry point for the Python 2.3 core DLL.
+ */
#define NULL 0
-/* Make references to imported symbols to pull them from static library */
-#define REF(s) extern void s (); void *____ref_##s = &s;
+#define REF(s) extern void s(); void *____ref_##s = &s;
-REF (Py_Main);
+/* 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);
+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)
+unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag)
{
switch (flag)
{
case 0:
- if (_CRT_init ())
+ if (_CRT_init())
return 0;
- __ctordtorInit ();
+ __ctordtorInit();
/* Ignore fatal signals */
- signal (SIGSEGV, SIG_IGN);
- signal (SIGFPE, SIG_IGN);
+ signal(SIGSEGV, SIG_IGN);
+ signal(SIGFPE, SIG_IGN);
return 1;
case 1:
- __ctordtorTerm ();
- _CRT_term ();
+ __ctordtorTerm();
+ _CRT_term();
return 1;
default:
diff --git a/PC/os2emx/getpathp.c b/PC/os2emx/getpathp.c
index ab31c65..4a4c893 100644
--- a/PC/os2emx/getpathp.c
+++ b/PC/os2emx/getpathp.c
@@ -94,9 +94,9 @@ is_sep(char ch) /* determine if "ch" is a separator character */
#endif
}
-/* assumes 'dir' null terminated in bounds. Never writes
- beyond existing terminator.
-*/
+/* assumes 'dir' null terminated in bounds.
+ * Never writes beyond existing terminator.
+ */
static void
reduce(char *dir)
{
@@ -113,11 +113,12 @@ exists(char *filename)
return stat(filename, &buf) == 0;
}
-/* Assumes 'filename' MAXPATHLEN+1 bytes long -
- may extend 'filename' by one character.
-*/
+/* Is module (check for .pyc/.pyo too)
+ * Assumes 'filename' MAXPATHLEN+1 bytes long -
+ * may extend 'filename' by one character.
+ */
static int
-ismodule(char *filename) /* Is module -- check for .pyc/.pyo too */
+ismodule(char *filename)
{
if (exists(filename))
return 1;
@@ -151,9 +152,9 @@ join(char *buffer, char *stuff)
}
/* 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.
-*/
+ * 'prefix' is null terminated in bounds. join() ensures
+ * 'landmark' can not overflow prefix if too long.
+ */
static int
gotlandmark(char *landmark)
{
@@ -167,7 +168,8 @@ gotlandmark(char *landmark)
}
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
- assumption provided by only caller, calculate_path() */
+ * assumption provided by only caller, calculate_path()
+ */
static int
search_for_prefix(char *argv0_path, char *landmark)
{
@@ -283,13 +285,13 @@ calculate_path(void)
}
/* 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.
- */
+ * (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 */
if (pythonhome != NULL) {