Changeset 10 for python/trunk/Modules/getpath.c
- Timestamp:
- Sep 3, 2010, 5:33:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk/Modules/getpath.c
r2 r10 117 117 #endif 118 118 119 #ifndef __EMX__ 119 120 #ifndef PYTHONPATH 120 121 #define PYTHONPATH PREFIX "/lib/python" VERSION ":" \ 121 122 EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" 123 #endif 124 #else 125 //#define PYTHONPATH "./Lib;./Lib/plat-" PLATFORM \ 126 // ";./Lib/lib-dynload;./Lib/site-packages" 127 // force unixroot 128 #define PYTHONPATH PREFIX "/lib/python" VERSION ";" \ 129 EXEC_PREFIX "/lib/python" VERSION "/lib-" PLATFORM ";" \ 130 EXEC_PREFIX "/lib/python" VERSION "/site-packages" ";" \ 131 EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" ";" \ 132 /* now local (for building) */ \ 133 "./lib" ";" \ 134 "./lib/plat-" PLATFORM ";" \ 135 "./lib/site-packages" ";" \ 136 "./lib/lib-dynload" 122 137 #endif 123 138 … … 136 151 { 137 152 size_t i = strlen(dir); 138 while (i > 0 && dir[i] != SEP)153 while (i > 0 && !IS_SEP(dir[i])) 139 154 --i; 140 155 dir[i] = '\0'; … … 209 224 { 210 225 size_t n, k; 211 if ( stuff[0] == SEP)226 if (IS_ABSPATH(stuff)) 212 227 n = 0; 213 228 else { 214 229 n = strlen(buffer); 215 if (n > 0 && buffer[n-1] != SEP&& n < MAXPATHLEN)230 if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN) 216 231 buffer[n++] = SEP; 217 232 } … … 230 245 copy_absolute(char *path, char *p) 231 246 { 232 if ( p[0] == SEP)247 if (IS_ABSPATH(p)) { 233 248 strcpy(path, p); 249 #ifdef ALTSEP 250 p = path; 251 while ((p = strchr(p, ALTSEP))) 252 *p++ = SEP; 253 #endif 254 } 234 255 else { 235 256 getcwd(path, MAXPATHLEN); 236 if (p[0] == '.' && p[1] == SEP)257 if (p[0] == '.' && IS_SEP(p[1])) 237 258 p += 2; 238 259 joinpath(path, p); … … 246 267 char buffer[MAXPATHLEN + 1]; 247 268 248 if (path[0] == SEP) 269 if (IS_ABSPATH(path)) { 270 #ifdef ALTSEP 271 while ((path = strchr(path, ALTSEP))) 272 *path++ = SEP; 273 #endif 249 274 return; 275 } 250 276 copy_absolute(buffer, path); 251 277 strcpy(path, buffer); … … 399 425 * $PATH isn't exported, you lose. 400 426 */ 401 if ( strchr(prog, SEP))427 if (HAS_ANYSEP(prog)) 402 428 strncpy(progpath, prog, MAXPATHLEN); 403 429 #ifdef __APPLE__ … … 442 468 else 443 469 progpath[0] = '\0'; 444 if (progpath[0] != SEP) 470 #ifndef ALTSEP 471 if (!IS_ABSPATH(progpath)) 472 #endif 445 473 absolutize(progpath); 446 474 strncpy(argv0_path, progpath, MAXPATHLEN); … … 488 516 /* It's not null terminated! */ 489 517 tmpbuffer[linklen] = '\0'; 490 if ( tmpbuffer[0] == SEP)518 if (IS_ABSPATH(tmpbuffer)) 491 519 /* tmpbuffer should never be longer than MAXPATHLEN, 492 520 but extra check does not hurt */ … … 553 581 554 582 while (1) { 555 char *delim = strchr(defpath, DELIM);556 557 if ( defpath[0] != SEP)583 char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */ 584 585 if (!IS_ABSPATH(defpath)) 558 586 /* Paths are relative to prefix */ 559 587 bufsz += prefixsz; … … 598 626 defpath = pythonpath; 599 627 while (1) { 600 char *delim = strchr(defpath, DELIM);601 602 if ( defpath[0] != SEP) {628 char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */ 629 630 if (!IS_ABSPATH(defpath)) { 603 631 strcat(buf, prefix); 604 632 strcat(buf, separator); … … 606 634 607 635 if (delim) { 608 size_t len = delim - defpath + 1;636 size_t len = delim - defpath; 609 637 size_t end = strlen(buf) + len; 610 638 strncat(buf, defpath, len); 611 *(buf + end) = '\0'; 639 *(buf + end) = DELIM; /* bird: correct the DELIM char. */ 640 *(buf + end + 1) = '\0'; 612 641 } 613 642 else {
Note:
See TracChangeset
for help on using the changeset viewer.