Ignore:
Timestamp:
Sep 3, 2010, 5:33:06 PM (15 years ago)
Author:
Yuri Dario
Message:

python: merged offline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/trunk/Modules/getpath.c

    r2 r10  
    117117#endif
    118118
     119#ifndef __EMX__
    119120#ifndef PYTHONPATH
    120121#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
    121122              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"
    122137#endif
    123138
     
    136151{
    137152    size_t i = strlen(dir);
    138     while (i > 0 && dir[i] != SEP)
     153    while (i > 0 && !IS_SEP(dir[i]))
    139154        --i;
    140155    dir[i] = '\0';
     
    209224{
    210225    size_t n, k;
    211     if (stuff[0] == SEP)
     226    if (IS_ABSPATH(stuff))
    212227        n = 0;
    213228    else {
    214229        n = strlen(buffer);
    215         if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)
     230        if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN)
    216231            buffer[n++] = SEP;
    217232    }
     
    230245copy_absolute(char *path, char *p)
    231246{
    232     if (p[0] == SEP)
     247    if (IS_ABSPATH(p)) {
    233248        strcpy(path, p);
     249#ifdef ALTSEP
     250        p = path;
     251        while ((p = strchr(p, ALTSEP)))
     252            *p++ = SEP;
     253#endif
     254    }
    234255    else {
    235256        getcwd(path, MAXPATHLEN);
    236         if (p[0] == '.' && p[1] == SEP)
     257        if (p[0] == '.' && IS_SEP(p[1]))
    237258            p += 2;
    238259        joinpath(path, p);
     
    246267    char buffer[MAXPATHLEN + 1];
    247268
    248     if (path[0] == SEP)
     269    if (IS_ABSPATH(path)) {
     270#ifdef ALTSEP
     271        while ((path = strchr(path, ALTSEP)))
     272            *path++ = SEP;
     273#endif
    249274        return;
     275    }
    250276    copy_absolute(buffer, path);
    251277    strcpy(path, buffer);
     
    399425         * $PATH isn't exported, you lose.
    400426         */
    401         if (strchr(prog, SEP))
     427        if (HAS_ANYSEP(prog))
    402428                strncpy(progpath, prog, MAXPATHLEN);
    403429#ifdef __APPLE__
     
    442468        else
    443469                progpath[0] = '\0';
    444         if (progpath[0] != SEP)
     470#ifndef ALTSEP
     471        if (!IS_ABSPATH(progpath))
     472#endif
    445473                absolutize(progpath);
    446474        strncpy(argv0_path, progpath, MAXPATHLEN);
     
    488516            /* It's not null terminated! */
    489517            tmpbuffer[linklen] = '\0';
    490             if (tmpbuffer[0] == SEP)
     518            if (IS_ABSPATH(tmpbuffer))
    491519                /* tmpbuffer should never be longer than MAXPATHLEN,
    492520                   but extra check does not hurt */
     
    553581
    554582    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))
    558586            /* Paths are relative to prefix */
    559587            bufsz += prefixsz;
     
    598626        defpath = pythonpath;
    599627        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)) {
    603631                strcat(buf, prefix);
    604632                strcat(buf, separator);
     
    606634
    607635            if (delim) {
    608                 size_t len = delim - defpath + 1;
     636                size_t len = delim - defpath;
    609637                size_t end = strlen(buf) + len;
    610638                strncat(buf, defpath, len);
    611                 *(buf + end) = '\0';
     639                *(buf + end) = DELIM;   /* bird: correct the DELIM char. */
     640                *(buf + end + 1) = '\0';
    612641            }
    613642            else {
Note: See TracChangeset for help on using the changeset viewer.