diff options
author | Guido van Rossum <guido@python.org> | 1993-07-09 10:51:31 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-07-09 10:51:31 (GMT) |
commit | e22e6442b748f5f4703cb6f221e1e10b320d0295 (patch) | |
tree | b464f80ce6b88f81a4b79cd3270f7990ee14ef4e /Modules | |
parent | d05eb8b0fc24c518abcd582e875393886f37689b (diff) | |
download | cpython-e22e6442b748f5f4703cb6f221e1e10b320d0295.zip cpython-e22e6442b748f5f4703cb6f221e1e10b320d0295.tar.gz cpython-e22e6442b748f5f4703cb6f221e1e10b320d0295.tar.bz2 |
* config.c: different default PYTHONPATH for MS-DOS
* timemodule.c: change #ifdef TURBO_C into #ifdef MSDOS
* posixmodule.c: MSDOS changes by Marcel van der Peijl (Digicash)
* stropmodule.c: use C isspace(c) to test for whitespace; add
whitespace, lowercase and uppercase variables to the module.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/config.c.in | 2 | ||||
-rw-r--r-- | Modules/posixmodule.c | 70 | ||||
-rw-r--r-- | Modules/stropmodule.c | 38 | ||||
-rw-r--r-- | Modules/timemodule.c | 9 |
4 files changed, 98 insertions, 21 deletions
diff --git a/Modules/config.c.in b/Modules/config.c.in index fe48023..692827e 100644 --- a/Modules/config.c.in +++ b/Modules/config.c.in @@ -141,7 +141,7 @@ donecalls() #ifdef MSDOS /* In MS-DOS, the delimiter is a semicolon */ -#define PYTHONPATH ".;C\\python\\lib" +#define PYTHONPATH ".;..\\lib;\\python\\lib" #endif /* MSDOS */ #ifndef PYTHONPATH diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 88861c6..e29be40 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -32,6 +32,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifdef MSDOS #define NO_LSTAT #define NO_UNAME +#include <dos.h> #endif #ifdef __sgi @@ -79,17 +80,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <unistd.h> #else /* _SEQUENT_ */ /* XXX Aren't these always declared in unistd.h? */ -extern char *strerror PROTO((int)); -extern int chmod PROTO((const char *, mode_t)); -extern char *getcwd PROTO((char *, int)); /* XXX or size_t? */ extern int mkdir PROTO((const char *, mode_t)); extern int chdir PROTO((const char *)); +extern int rmdir PROTO((const char *)); +extern int chmod PROTO((const char *, mode_t)); +extern char *getcwd PROTO((char *, int)); /* XXX or size_t? */ +#if 0 +extern char *strerror PROTO((int)); extern int link PROTO((const char *, const char *)); extern int rename PROTO((const char *, const char *)); -extern int rmdir PROTO((const char *)); extern int stat PROTO((const char *, struct stat *)); extern int unlink PROTO((const char *)); extern int pclose PROTO((FILE *)); +#endif #endif /* _SEQUENT_ */ #ifdef NO_LSTAT #define lstat stat @@ -279,7 +282,7 @@ posix_listdir(self, args) char *name; object *d, *v; -#ifdef MSDOS +#ifdef TURBO_C struct ffblk ep; int rv; if (!getstrarg(args, &name)) @@ -304,7 +307,54 @@ posix_listdir(self, args) } DECREF(v); } while ((rv = findnext(&ep)) == 0); -#else /* !MSDOS */ +#endif /* TURBO_C */ +#ifdef MSDOS + struct find_t ep; + int rv; + char _name[100]; + int attrib; + int num= 0; + + if (!getstrarg(args, &name)) + return NULL; + strcpy( _name, name ); + +again: + if ((d = newlistobject(0)) == NULL) + return NULL; + + if( _name[strlen( _name )-1]=='/' ) + strcat( _name, "*.*" ); + + if (_dos_findfirst(_name, _A_NORMAL|_A_SUBDIR, &ep) == -1) + return posix_error(); + attrib= ep.attrib; + do { + v = newstringobject(ep.name); + if (v == NULL) { + DECREF(d); + d = NULL; + break; + } + if (addlistitem(d, v) != 0) { + DECREF(v); + DECREF(d); + d = NULL; + break; + } + num++; + DECREF(v); + } while ((rv = _dos_findnext(&ep)) == 0); + + if( attrib&_A_SUBDIR && num==1 ) + { + DECREF( d ); + strcat( _name, "/*.*" ); + goto again; + } + +#endif /* MSDOS */ +#ifdef unix DIR *dirp; struct direct *ep; if (!getstrarg(args, &name)) @@ -336,7 +386,7 @@ posix_listdir(self, args) } closedir(dirp); END_SAVE -#endif /* !MSDOS */ +#endif /* unix */ return d; } @@ -1205,11 +1255,11 @@ getmtime(path) } -#ifdef MSDOS +#ifdef TURBO_C /* A small "compatibility library" for TurboC under MS-DOS */ -#include <sir.h> +//#include <sir.h> #include <io.h> #include <dos.h> #include <fcntl.h> @@ -1247,4 +1297,4 @@ utime(path, times) close(fh); /* close the temp handle */ } -#endif /* MSDOS */ +#endif /* TURBO_C */ diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 6fc2719..4a10b7c 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -28,6 +28,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "modsupport.h" #include <ctype.h> +/* XXX This file assumes that the <ctype.h> is*() functions + XXX are defined for all 8-bit characters! */ static object * @@ -365,8 +367,6 @@ static struct methodlist strop_methods[] = { }; -/* Initialization function for the module (*must* be called initstrop) */ - void initstrop() { @@ -375,12 +375,42 @@ initstrop() int c, n; m = initmodule("strop", strop_methods); d = getmoduledict(m); + + /* Create 'whitespace' object */ n = 0; for (c = 1; c < 256; c++) { if (isspace(c)) buf[n++] = c; } + if (s) { + s = newsizedstringobject(buf, n); + dictinsert(d, "whitespace", s); + DECREF(s); + } + /* Create 'lowercase' object */ + n = 0; + for (c = 1; c < 256; c++) { + if (islower(c)) + buf[n++] = c; + } + s = newsizedstringobject(buf, n); + if (s) { + dictinsert(d, "lowercase", s); + DECREF(s); + } + + /* Create 'uppercase' object */ + n = 0; + for (c = 1; c < 256; c++) { + if (isupper(c)) + buf[n++] = c; + } s = newsizedstringobject(buf, n); - dictinsert(d, "whitespace", s); - DECREF(s); + if (s) { + dictinsert(d, "uppercase", s); + DECREF(s); + } + + if (err_occurred()) + fatal("can't initialize module strop"); } diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 68c5ac7..5bf1340 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -174,7 +174,7 @@ extern long sys_milli(); #define DO_MILLI #endif /* BSD_TIME */ -#ifdef TURBO_C +#ifdef MSDOS #define DO_MILLI #endif @@ -469,7 +469,7 @@ floatsleep(secs) #endif /* unix */ -#ifdef TURBO_C +#ifdef MSDOS #ifndef CLOCKS_PER_SEC #define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */ @@ -491,10 +491,6 @@ millitimer() return ticks * CLOCKS_PER_SEC;/* XXX shouldn't this be different? */ } -#endif /* TURBO_C */ - -#ifdef MSDOS - floatsleep(secs) double secs; { @@ -502,4 +498,5 @@ floatsleep(secs) while( (clock()-t)/CLOCKS_PER_SEC<secs ) ; } + #endif /* MSDOS */ |