- Timestamp:
- May 21, 2007, 2:27:53 AM (18 years ago)
- Location:
- trunk/essentials/dev-lang/python
- Files:
-
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/essentials/dev-lang/python/Include/osdefs.h
r3225 r3364 20 20 #define MAXPATHLEN 256 21 21 #endif 22 #define DRVSEP ':' /* (bird) */ 22 23 #define DELIM ';' 23 24 #endif … … 34 35 #ifndef SEP 35 36 #define SEP '/' 37 #endif 38 39 /* Test if `ch' is a filename separator (bird) */ 40 #ifdef ALTSEP 41 #define IS_SEP(ch) ((ch) == SEP || (ch) == ALTSEP) 42 #else 43 #define IS_SEP(ch) ((ch) == SEP) 44 #endif 45 46 /* Test if `path' has a drive letter or not. (bird) */ 47 #ifdef DRVSEP 48 #define HAS_DRV(path) (*(path) && (path)[1] == DRVSEP) 49 #else 50 #define HAS_DRV(path) 0 51 #endif 52 53 /* Test if `path' is absolute or not. (bird) */ 54 #ifdef DRVSEP 55 #define IS_ABSPATH(path) (IS_SEP((path)[0]) || HAS_DRV(path)) 56 #else 57 #define IS_ABSPATH(path) (IS_SEP((path)[0])) 58 #endif 59 60 /* Test if `path' contains any of the path separators including drive letter. (bird) */ 61 #ifdef ALTSEP 62 #define HAS_ANYSEP(path) ( strchr((path), SEP) || strchr((path), ALTSEP) || HAS_DRV(path) ) 63 #else 64 #define HAS_ANYSEP(path) ( strchr((path), SEP) || HAS_DRV(path) ) 36 65 #endif 37 66 -
trunk/essentials/dev-lang/python/Lib/tempfile.py
r3225 r3364 437 437 return _TemporaryFileWrapper(file, name) 438 438 439 if _os.name != 'posix' or _os.sys.platform == 'cygwin' :439 if _os.name != 'posix' or _os.sys.platform == 'cygwin' ot _os.sys.platform == 'os2emx': 440 440 # On non-POSIX and Cygwin systems, assume that we cannot unlink a file 441 441 # while it is open. -
trunk/essentials/dev-lang/python/Makefile.pre.in
r3225 r3364 484 484 485 485 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES) 486 ifndef BOOTSTRAPPING_PYTHON 486 487 $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL) 488 endif 487 489 488 490 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES) 491 ifndef BOOTSTRAPPING_PYTHON 489 492 $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL) 493 endif 490 494 491 495 Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H) -
trunk/essentials/dev-lang/python/Modules/getpath.c
r3225 r3364 136 136 { 137 137 size_t i = strlen(dir); 138 while (i > 0 && dir[i] != SEP)138 while (i > 0 && !IS_SEP(dir[i])) 139 139 --i; 140 140 dir[i] = '\0'; … … 209 209 { 210 210 size_t n, k; 211 if ( stuff[0] == SEP)211 if (IS_ABSPATH(stuff)) 212 212 n = 0; 213 213 else { 214 214 n = strlen(buffer); 215 if (n > 0 && buffer[n-1] != SEP&& n < MAXPATHLEN)215 if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN) 216 216 buffer[n++] = SEP; 217 217 } … … 230 230 copy_absolute(char *path, char *p) 231 231 { 232 if ( p[0] == SEP)232 if (IS_ABSPATH(p)) { 233 233 strcpy(path, p); 234 #ifdef ALTSEP 235 p = path; 236 while ((p = strchr(p, ALTSEP))) 237 *p++ = SEP; 238 #endif 239 } 234 240 else { 235 241 getcwd(path, MAXPATHLEN); 236 if (p[0] == '.' && p[1] == SEP)242 if (p[0] == '.' && IS_SEP(p[1])) 237 243 p += 2; 238 244 joinpath(path, p); … … 246 252 char buffer[MAXPATHLEN + 1]; 247 253 248 if (path[0] == SEP) 254 if (IS_ABSPATH(path)) { 255 #ifdef ALTSEP 256 while ((path = strchr(path, ALTSEP))) 257 *path++ = SEP; 258 #endif 249 259 return; 260 } 250 261 copy_absolute(buffer, path); 251 262 strcpy(path, buffer); … … 399 410 * $PATH isn't exported, you lose. 400 411 */ 401 if ( strchr(prog, SEP))412 if (HAS_ANYSEP(prog)) 402 413 strncpy(progpath, prog, MAXPATHLEN); 403 414 #ifdef __APPLE__ … … 442 453 else 443 454 progpath[0] = '\0'; 444 if (progpath[0] != SEP) 455 #ifndef ALTSEP 456 if (!IS_ABSPATH(progpath)) 457 #endif 445 458 absolutize(progpath); 446 459 strncpy(argv0_path, progpath, MAXPATHLEN); … … 488 501 /* It's not null terminated! */ 489 502 tmpbuffer[linklen] = '\0'; 490 if ( tmpbuffer[0] == SEP)503 if (IS_ABSPATH(tmpbuffer)) 491 504 /* tmpbuffer should never be longer than MAXPATHLEN, 492 505 but extra check does not hurt */ … … 553 566 554 567 while (1) { 555 char *delim = strchr(defpath, DELIM);556 557 if ( defpath[0] != SEP)568 char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */ 569 570 if (!IS_ABSPATH(defpath)) 558 571 /* Paths are relative to prefix */ 559 572 bufsz += prefixsz; … … 598 611 defpath = pythonpath; 599 612 while (1) { 600 char *delim = strchr(defpath, DELIM);601 602 if ( defpath[0] != SEP) {613 char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */ 614 615 if (!IS_ABSPATH(defpath)) { 603 616 strcat(buf, prefix); 604 617 strcat(buf, separator); … … 606 619 607 620 if (delim) { 608 size_t len = delim - defpath + 1;621 size_t len = delim - defpath; 609 622 size_t end = strlen(buf) + len; 610 623 strncat(buf, defpath, len); 611 *(buf + end) = '\0'; 624 *(buf + end) = DELIM; /* bird: correct the DELIM char. */ 625 *(buf + end + 1) = '\0'; 612 626 } 613 627 else { -
trunk/essentials/dev-lang/python/Modules/posixmodule.c
r3225 r3364 132 132 #define fsync _commit 133 133 #else 134 #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)134 #if (defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)) || defined(__VMS) 135 135 /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */ 136 136 #else /* all other compilers */ -
trunk/essentials/dev-lang/python/Objects/exceptions.c
r3225 r3364 1052 1052 return "???"; 1053 1053 while (*cp != '\0') { 1054 if ( *cp == SEP)1054 if (IS_SEP(*cp)) 1055 1055 result = cp + 1; 1056 1056 ++cp; -
trunk/essentials/dev-lang/python/PC/os2emx/Setup.os2emx
r3343 r3364 110 110 # setup.py script in the root of the Python source tree. 111 111 112 posix posixmodule.c #posix (UNIX) system calls112 os2 posixmodule.c # os2 / posix (UNIX) system calls 113 113 errno errnomodule.c # posix (UNIX) errno values 114 114 pwd pwdmodule.c # this is needed to find out the user's home dir -
trunk/essentials/dev-lang/python/Python/dynload_shlib.c
r3225 r3364 21 21 #else 22 22 #if defined(PYOS_OS2) && defined(PYCC_GCC) 23 #ifdef __KLIBC__ 24 #error "kLIBC has dlfcn.h and shouldn't get here!" 25 #endif 23 26 #include "dlfcn.h" 24 27 #endif 25 28 #endif 26 29 27 #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__) 30 #if ((defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)) \ 31 || (defined(__OS2__) && defined(__KLIBC__)) 28 32 #define LEAD_UNDERSCORE "_" 29 33 #else … … 37 41 {"module.dll", "rb", C_EXTENSION}, 38 42 #else 39 #if defined(PYOS_OS2) && defined(PYCC_GCC)43 #if (defined(PYOS_OS2) && defined(PYCC_GCC)) || (defined(__OS2__) && defined(__KLIBC__)) 40 44 {".pyd", "rb", C_EXTENSION}, 41 45 {".dll", "rb", C_EXTENSION}, … … 82 86 } 83 87 84 PyOS_snprintf(funcname, sizeof(funcname), 88 PyOS_snprintf(funcname, sizeof(funcname), 85 89 LEAD_UNDERSCORE "init%.200s", shortname); 86 90 … … 114 118 115 119 if (Py_VerboseFlag) 116 PySys_WriteStderr("dlopen(\"%s\", %x);\n", pathname, 120 PySys_WriteStderr("dlopen(\"%s\", %x);\n", pathname, 117 121 dlopenflags); 118 122 … … 123 127 /* As C module use only one name space this is probably not a */ 124 128 /* important limitation */ 125 PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s", 129 PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s", 126 130 shortname); 127 131 pathname = pathbuf; -
trunk/essentials/dev-lang/python/Python/import.c
r3225 r3364 1475 1475 #include <dirent.h> 1476 1476 1477 #elif defined(__KLIBC__) 1478 #include <stdlib.h> 1479 1477 1480 #elif defined(PYOS_OS2) 1478 1481 #define INCL_DOS … … 1594 1597 1595 1598 /* OS/2 */ 1599 #elif defined(__KLIBC__) 1600 char canon[MAXPATHLEN+1]; 1601 size_t canonlen; 1602 char *p, *p2; 1603 1604 if (Py_GETENV("PYTHONCASEOK") != NULL) 1605 return 1; 1606 1607 /* This resolves case differences and return and native OS/2 1608 path. Unfortunately, it'll also resolve symbolic links 1609 while of course will screw up a bit... */ 1610 if (!_realrealpath(buf, canon, sizeof(canon))) 1611 return 0; 1612 canonlen = strlen(canon); 1613 if (canonlen < namelen) 1614 return 0; 1615 p = strrchr(canon, SEP); 1616 p2 = strrchr(p ? p : canon, ALTSEP); 1617 if (p2) 1618 p = p2; 1619 1620 return strncmp(p ? p + 1 : canon, name, namelen) == 0; 1621 1596 1622 #elif defined(PYOS_OS2) 1597 1623 HDIR hdir = 1; -
trunk/essentials/dev-lang/python/Python/sysmodule.c
r3225 r3364 1319 1319 /* It's a symlink */ 1320 1320 link[nr] = '\0'; 1321 if ( link[0] == SEP)1321 if (IS_ABSPATH(link)) 1322 1322 argv0 = link; /* Link to absolute path */ 1323 else if ( strchr(link, SEP) == NULL)1323 else if (!HAS_ANYSEP(link)) 1324 1324 ; /* Link without path */ 1325 1325 else { 1326 1326 /* Must join(dirname(argv0), link) */ 1327 1327 char *q = strrchr(argv0, SEP); 1328 #ifdef ALTSEP 1329 char *q2 = strrchr(q ? q : argv0, ALTSEP); 1330 if (q2) 1331 q = q2; 1332 #endif 1333 #ifdef DRVSEP 1334 if (!q && HAS_DRV(argv0)) 1335 q = strchr(argv0, DRVSEP); 1336 #endif 1337 1328 1338 if (q == NULL) 1329 1339 argv0 = link; /* argv0 without path */ … … 1331 1341 /* Must make a copy */ 1332 1342 strcpy(argv0copy, argv0); 1333 q = strrchr(argv0copy, SEP);1343 q = &argv0copy[q - argv0]; 1334 1344 strcpy(q+1, link); 1335 1345 argv0 = argv0copy; … … 1369 1379 #endif 1370 1380 p = strrchr(argv0, SEP); 1381 #ifdef ALTSEP 1382 { 1383 char *p2 = strrchr(p ? p : argv0, ALTSEP); 1384 if (p2 != NULL) 1385 p = p2; 1386 } 1387 #endif 1388 #ifdef DRVSEP 1389 if (p == NULL && HAS_DRV(argv0)) 1390 p = strchr(argv0, DRVSEP); 1391 #endif 1371 1392 } 1372 1393 if (p != NULL) { -
trunk/essentials/dev-lang/python/Python/traceback.c
r3225 r3364 140 140 PyObject *path; 141 141 char *tail = strrchr(filename, SEP); 142 #ifdef ALTSEP 143 char *tail2 = strrchr(filename, ALTSEP); 144 if (!tail || tail2 > tail) 145 tail = tail2; 146 #endif 147 #ifdef DRVSEP 148 if (!tail && HAS_DRV(filename)) 149 tail = strchr(filename, DRVSEP); 150 #endif 142 151 if (tail == NULL) 143 152 tail = filename; … … 164 173 if (strlen(namebuf) != len) 165 174 continue; /* v contains '\0' */ 166 if (len > 0 && namebuf[len-1] != SEP)175 if (len > 0 && IS_SEP(namebuf[len-1])) 167 176 namebuf[len++] = SEP; 168 177 strcpy(namebuf+len, tail); -
trunk/essentials/dev-lang/python/configure.in
r3225 r3364 184 184 atheos*) MACHDEP="atheos";; 185 185 irix646) MACHDEP="irix6";; 186 os2*|emx*) MACHDEP="emx";; 187 186 188 '') MACHDEP="unknown";; 187 189 esac … … 487 489 gcc) CC="$CC -D_HAVE_BSDI";; 488 490 esac;; 491 os2*|emx*) 492 CC="$CC -DPYCC_OS2=1 -DPYCC_GCC=1" 493 ;; 489 494 esac 490 495 … … 519 524 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On 520 525 # systems without shared libraries, LDLIBRARY is the same as LIBRARY 521 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,522 # DLLLIBRARY is the shared (i.e., DLL) library.523 # 526 # (defined in the Makefiles). On Cygwin and OS/2 LDLIBRARY is the import 527 # library, DLLLIBRARY is the shared (i.e., DLL) library. 528 # 524 529 # RUNSHARED is used to run shared python without installed libraries 525 530 # … … 665 670 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} 666 671 ;; 672 os2*|emx*) 673 LDLIBRARY='python$(VERSION)_dll.a' 674 BLDLIBRARY='-L. -lpython$(VERSION)' 675 RUNSHARED=BEGINLIBPATH="`pwd`;$BEGINLIBPATH" 676 CONDENSED_VERSION=`echo "$(VERSION)" | tr -d .,"` 677 DLLLIBRARY='python$(CONDENSED_VERSION).dll' 678 ;; 667 679 esac 668 680 else # shared is disabled … … 706 718 BeOS*) LN="ln -s";; 707 719 CYGWIN*) LN="ln -s";; 720 os2*|emx*) LN="ln -s";; 708 721 atheos*) LN="ln -s";; 709 722 *) LN=ln;; … … 1396 1409 AC_SUBST(LINKFORSHARED) 1397 1410 # SO is the extension of shared libraries `(including the dot!) 1398 # -- usually .so, .sl on HP-UX, .dll on Cygwin 1411 # -- usually .so, .sl on HP-UX, .dll on Cygwin and OS/2 1399 1412 AC_MSG_CHECKING(SO) 1400 1413 if test -z "$SO" … … 1408 1421 ;; 1409 1422 CYGWIN*) SO=.dll;; 1423 os2*|emx*) SO=.dll;; 1410 1424 *) SO=.so;; 1411 1425 esac … … 3402 3416 if test ! -f Modules/Setup 3403 3417 then 3404 cp $srcdir/Modules/Setup.dist Modules/Setup 3418 if test "$MACHDEP" = "emx"; then 3419 cp $srcdir/PC/os2emx/Modules/Setup.os2emx Modules/Setup 3420 else 3421 cp $srcdir/Modules/Setup.dist Modules/Setup 3422 if 3405 3423 fi 3406 3424
Note:
See TracChangeset
for help on using the changeset viewer.