Changeset 3364 for trunk/essentials/dev-lang/python/Modules/getpath.c
- Timestamp:
- May 21, 2007, 2:27:53 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note:
See TracChangeset
for help on using the changeset viewer.