]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* config.c: different default PYTHONPATH for MS-DOS
authorGuido van Rossum <guido@python.org>
Fri, 9 Jul 1993 10:51:31 +0000 (10:51 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 9 Jul 1993 10:51:31 +0000 (10:51 +0000)
* 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.

Modules/config.c.in
Modules/posixmodule.c
Modules/stropmodule.c
Modules/timemodule.c

index fe48023d3f2b2171977ab02d9ebe9f28154c9f06..692827e1e18564267f12e247f2b766b8dd631b6c 100644 (file)
@@ -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
index 88861c66e09a5a3a59ac6799149d14f22f2caccd..e29be404cd9243d00ee9e29bfc3a05e20a1e0fb3 100644 (file)
@@ -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 */
index 6fc2719c6939de1c63e1289349a3eb7c23f305d5..4a10b7cf4048c97c9b8a624d15d89046a22824f3 100644 (file)
@@ -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");
 }
index 68c5ac7b9c94526124ded1b0499f9af0847f70f8..5bf1340caf3492ca74ffbb81f223053a84ba462f 100644 (file)
@@ -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 */