Ignore:
Timestamp:
May 21, 2007, 2:27:53 AM (18 years ago)
Author:
bird
Message:

In progress...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/essentials/dev-lang/python/Modules/getpath.c

    r3225 r3364  
    136136{
    137137    size_t i = strlen(dir);
    138     while (i > 0 && dir[i] != SEP)
     138    while (i > 0 && !IS_SEP(dir[i]))
    139139        --i;
    140140    dir[i] = '\0';
     
    209209{
    210210    size_t n, k;
    211     if (stuff[0] == SEP)
     211    if (IS_ABSPATH(stuff))
    212212        n = 0;
    213213    else {
    214214        n = strlen(buffer);
    215         if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)
     215        if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN)
    216216            buffer[n++] = SEP;
    217217    }
     
    230230copy_absolute(char *path, char *p)
    231231{
    232     if (p[0] == SEP)
     232    if (IS_ABSPATH(p)) {
    233233        strcpy(path, p);
     234#ifdef ALTSEP
     235        p = path;
     236        while ((p = strchr(p, ALTSEP)))
     237            *p++ = SEP;
     238#endif
     239    }
    234240    else {
    235241        getcwd(path, MAXPATHLEN);
    236         if (p[0] == '.' && p[1] == SEP)
     242        if (p[0] == '.' && IS_SEP(p[1]))
    237243            p += 2;
    238244        joinpath(path, p);
     
    246252    char buffer[MAXPATHLEN + 1];
    247253
    248     if (path[0] == SEP)
     254    if (IS_ABSPATH(path)) {
     255#ifdef ALTSEP
     256        while ((path = strchr(path, ALTSEP)))
     257            *path++ = SEP;
     258#endif
    249259        return;
     260    }
    250261    copy_absolute(buffer, path);
    251262    strcpy(path, buffer);
     
    399410         * $PATH isn't exported, you lose.
    400411         */
    401         if (strchr(prog, SEP))
     412        if (HAS_ANYSEP(prog))
    402413                strncpy(progpath, prog, MAXPATHLEN);
    403414#ifdef __APPLE__
     
    442453        else
    443454                progpath[0] = '\0';
    444         if (progpath[0] != SEP)
     455#ifndef ALTSEP
     456        if (!IS_ABSPATH(progpath))
     457#endif
    445458                absolutize(progpath);
    446459        strncpy(argv0_path, progpath, MAXPATHLEN);
     
    488501            /* It's not null terminated! */
    489502            tmpbuffer[linklen] = '\0';
    490             if (tmpbuffer[0] == SEP)
     503            if (IS_ABSPATH(tmpbuffer))
    491504                /* tmpbuffer should never be longer than MAXPATHLEN,
    492505                   but extra check does not hurt */
     
    553566
    554567    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))
    558571            /* Paths are relative to prefix */
    559572            bufsz += prefixsz;
     
    598611        defpath = pythonpath;
    599612        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)) {
    603616                strcat(buf, prefix);
    604617                strcat(buf, separator);
     
    606619
    607620            if (delim) {
    608                 size_t len = delim - defpath + 1;
     621                size_t len = delim - defpath;
    609622                size_t end = strlen(buf) + len;
    610623                strncat(buf, defpath, len);
    611                 *(buf + end) = '\0';
     624                *(buf + end) = DELIM;   /* bird: correct the DELIM char. */
     625                *(buf + end + 1) = '\0';
    612626            }
    613627            else {
Note: See TracChangeset for help on using the changeset viewer.