mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
* 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.
This commit is contained in:
parent
d05eb8b0fc
commit
e22e6442b7
4 changed files with 98 additions and 21 deletions
|
|
@ -141,7 +141,7 @@ donecalls()
|
||||||
|
|
||||||
#ifdef MSDOS
|
#ifdef MSDOS
|
||||||
/* In MS-DOS, the delimiter is a semicolon */
|
/* In MS-DOS, the delimiter is a semicolon */
|
||||||
#define PYTHONPATH ".;C\\python\\lib"
|
#define PYTHONPATH ".;..\\lib;\\python\\lib"
|
||||||
#endif /* MSDOS */
|
#endif /* MSDOS */
|
||||||
|
|
||||||
#ifndef PYTHONPATH
|
#ifndef PYTHONPATH
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#ifdef MSDOS
|
#ifdef MSDOS
|
||||||
#define NO_LSTAT
|
#define NO_LSTAT
|
||||||
#define NO_UNAME
|
#define NO_UNAME
|
||||||
|
#include <dos.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __sgi
|
#ifdef __sgi
|
||||||
|
|
@ -79,17 +80,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#else /* _SEQUENT_ */
|
#else /* _SEQUENT_ */
|
||||||
/* XXX Aren't these always declared in unistd.h? */
|
/* 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 mkdir PROTO((const char *, mode_t));
|
||||||
extern int chdir PROTO((const char *));
|
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 link PROTO((const char *, const char *));
|
||||||
extern int rename 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 stat PROTO((const char *, struct stat *));
|
||||||
extern int unlink PROTO((const char *));
|
extern int unlink PROTO((const char *));
|
||||||
extern int pclose PROTO((FILE *));
|
extern int pclose PROTO((FILE *));
|
||||||
|
#endif
|
||||||
#endif /* _SEQUENT_ */
|
#endif /* _SEQUENT_ */
|
||||||
#ifdef NO_LSTAT
|
#ifdef NO_LSTAT
|
||||||
#define lstat stat
|
#define lstat stat
|
||||||
|
|
@ -279,7 +282,7 @@ posix_listdir(self, args)
|
||||||
char *name;
|
char *name;
|
||||||
object *d, *v;
|
object *d, *v;
|
||||||
|
|
||||||
#ifdef MSDOS
|
#ifdef TURBO_C
|
||||||
struct ffblk ep;
|
struct ffblk ep;
|
||||||
int rv;
|
int rv;
|
||||||
if (!getstrarg(args, &name))
|
if (!getstrarg(args, &name))
|
||||||
|
|
@ -304,7 +307,54 @@ posix_listdir(self, args)
|
||||||
}
|
}
|
||||||
DECREF(v);
|
DECREF(v);
|
||||||
} while ((rv = findnext(&ep)) == 0);
|
} 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;
|
DIR *dirp;
|
||||||
struct direct *ep;
|
struct direct *ep;
|
||||||
if (!getstrarg(args, &name))
|
if (!getstrarg(args, &name))
|
||||||
|
|
@ -336,7 +386,7 @@ posix_listdir(self, args)
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
END_SAVE
|
END_SAVE
|
||||||
#endif /* !MSDOS */
|
#endif /* unix */
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
@ -1205,11 +1255,11 @@ getmtime(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MSDOS
|
#ifdef TURBO_C
|
||||||
|
|
||||||
/* A small "compatibility library" for TurboC under MS-DOS */
|
/* A small "compatibility library" for TurboC under MS-DOS */
|
||||||
|
|
||||||
#include <sir.h>
|
//#include <sir.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <dos.h>
|
#include <dos.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
@ -1247,4 +1297,4 @@ utime(path, times)
|
||||||
close(fh); /* close the temp handle */
|
close(fh); /* close the temp handle */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MSDOS */
|
#endif /* TURBO_C */
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
/* XXX This file assumes that the <ctype.h> is*() functions
|
||||||
|
XXX are defined for all 8-bit characters! */
|
||||||
|
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
|
|
@ -365,8 +367,6 @@ static struct methodlist strop_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Initialization function for the module (*must* be called initstrop) */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
initstrop()
|
initstrop()
|
||||||
{
|
{
|
||||||
|
|
@ -375,12 +375,42 @@ initstrop()
|
||||||
int c, n;
|
int c, n;
|
||||||
m = initmodule("strop", strop_methods);
|
m = initmodule("strop", strop_methods);
|
||||||
d = getmoduledict(m);
|
d = getmoduledict(m);
|
||||||
|
|
||||||
|
/* Create 'whitespace' object */
|
||||||
n = 0;
|
n = 0;
|
||||||
for (c = 1; c < 256; c++) {
|
for (c = 1; c < 256; c++) {
|
||||||
if (isspace(c))
|
if (isspace(c))
|
||||||
buf[n++] = c;
|
buf[n++] = c;
|
||||||
}
|
}
|
||||||
|
if (s) {
|
||||||
s = newsizedstringobject(buf, n);
|
s = newsizedstringobject(buf, n);
|
||||||
dictinsert(d, "whitespace", s);
|
dictinsert(d, "whitespace", s);
|
||||||
DECREF(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);
|
||||||
|
if (s) {
|
||||||
|
dictinsert(d, "uppercase", s);
|
||||||
|
DECREF(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err_occurred())
|
||||||
|
fatal("can't initialize module strop");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ extern long sys_milli();
|
||||||
#define DO_MILLI
|
#define DO_MILLI
|
||||||
#endif /* BSD_TIME */
|
#endif /* BSD_TIME */
|
||||||
|
|
||||||
#ifdef TURBO_C
|
#ifdef MSDOS
|
||||||
#define DO_MILLI
|
#define DO_MILLI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -469,7 +469,7 @@ floatsleep(secs)
|
||||||
#endif /* unix */
|
#endif /* unix */
|
||||||
|
|
||||||
|
|
||||||
#ifdef TURBO_C
|
#ifdef MSDOS
|
||||||
|
|
||||||
#ifndef CLOCKS_PER_SEC
|
#ifndef CLOCKS_PER_SEC
|
||||||
#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
|
#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? */
|
return ticks * CLOCKS_PER_SEC;/* XXX shouldn't this be different? */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TURBO_C */
|
|
||||||
|
|
||||||
#ifdef MSDOS
|
|
||||||
|
|
||||||
floatsleep(secs)
|
floatsleep(secs)
|
||||||
double secs;
|
double secs;
|
||||||
{
|
{
|
||||||
|
|
@ -502,4 +498,5 @@ floatsleep(secs)
|
||||||
while( (clock()-t)/CLOCKS_PER_SEC<secs )
|
while( (clock()-t)/CLOCKS_PER_SEC<secs )
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MSDOS */
|
#endif /* MSDOS */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue