]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Modules/getpath.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Modules / getpath.c
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Modules/getpath.c b/AppPkg/Applications/Python/Python-2.7.2/Modules/getpath.c
deleted file mode 100644 (file)
index 24fedd9..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-/* Return the initial module search path. */\r
-\r
-#include "Python.h"\r
-#include "osdefs.h"\r
-\r
-#include <sys/types.h>\r
-#include <string.h>\r
-\r
-#ifdef __APPLE__\r
-#include <mach-o/dyld.h>\r
-#endif\r
-\r
-/* Search in some common locations for the associated Python libraries.\r
- *\r
- * Two directories must be found, the platform independent directory\r
- * (prefix), containing the common .py and .pyc files, and the platform\r
- * dependent directory (exec_prefix), containing the shared library\r
- * modules.  Note that prefix and exec_prefix can be the same directory,\r
- * but for some installations, they are different.\r
- *\r
- * Py_GetPath() carries out separate searches for prefix and exec_prefix.\r
- * Each search tries a number of different locations until a ``landmark''\r
- * file or directory is found.  If no prefix or exec_prefix is found, a\r
- * warning message is issued and the preprocessor defined PREFIX and\r
- * EXEC_PREFIX are used (even though they will not work); python carries on\r
- * as best as is possible, but most imports will fail.\r
- *\r
- * Before any searches are done, the location of the executable is\r
- * determined.  If argv[0] has one or more slashes in it, it is used\r
- * unchanged.  Otherwise, it must have been invoked from the shell's path,\r
- * so we search $PATH for the named executable and use that.  If the\r
- * executable was not found on $PATH (or there was no $PATH environment\r
- * variable), the original argv[0] string is used.\r
- *\r
- * Next, the executable location is examined to see if it is a symbolic\r
- * link.  If so, the link is chased (correctly interpreting a relative\r
- * pathname if one is found) and the directory of the link target is used.\r
- *\r
- * Finally, argv0_path is set to the directory containing the executable\r
- * (i.e. the last component is stripped).\r
- *\r
- * With argv0_path in hand, we perform a number of steps.  The same steps\r
- * are performed for prefix and for exec_prefix, but with a different\r
- * landmark.\r
- *\r
- * Step 1. Are we running python out of the build directory?  This is\r
- * checked by looking for a different kind of landmark relative to\r
- * argv0_path.  For prefix, the landmark's path is derived from the VPATH\r
- * preprocessor variable (taking into account that its value is almost, but\r
- * not quite, what we need).  For exec_prefix, the landmark is\r
- * Modules/Setup.  If the landmark is found, we're done.\r
- *\r
- * For the remaining steps, the prefix landmark will always be\r
- * lib/python$VERSION/os.py and the exec_prefix will always be\r
- * lib/python$VERSION/lib-dynload, where $VERSION is Python's version\r
- * number as supplied by the Makefile.  Note that this means that no more\r
- * build directory checking is performed; if the first step did not find\r
- * the landmarks, the assumption is that python is running from an\r
- * installed setup.\r
- *\r
- * Step 2. See if the $PYTHONHOME environment variable points to the\r
- * installed location of the Python libraries.  If $PYTHONHOME is set, then\r
- * it points to prefix and exec_prefix.  $PYTHONHOME can be a single\r
- * directory, which is used for both, or the prefix and exec_prefix\r
- * directories separated by a colon.\r
- *\r
- * Step 3. Try to find prefix and exec_prefix relative to argv0_path,\r
- * backtracking up the path until it is exhausted.  This is the most common\r
- * step to succeed.  Note that if prefix and exec_prefix are different,\r
- * exec_prefix is more likely to be found; however if exec_prefix is a\r
- * subdirectory of prefix, both will be found.\r
- *\r
- * Step 4. Search the directories pointed to by the preprocessor variables\r
- * PREFIX and EXEC_PREFIX.  These are supplied by the Makefile but can be\r
- * passed in as options to the configure script.\r
- *\r
- * That's it!\r
- *\r
- * Well, almost.  Once we have determined prefix and exec_prefix, the\r
- * preprocessor variable PYTHONPATH is used to construct a path.  Each\r
- * relative path on PYTHONPATH is prefixed with prefix.  Then the directory\r
- * containing the shared library modules is appended.  The environment\r
- * variable $PYTHONPATH is inserted in front of it all.  Finally, the\r
- * prefix and exec_prefix globals are tweaked so they reflect the values\r
- * expected by other code, by stripping the "lib/python$VERSION/..." stuff\r
- * off.  If either points to the build directory, the globals are reset to\r
- * the corresponding preprocessor variables (so sys.prefix will reflect the\r
- * installation location, even though sys.path points into the build\r
- * directory).  This seems to make more sense given that currently the only\r
- * known use of sys.prefix and sys.exec_prefix is for the ILU installation\r
- * process to find the installed Python tree.\r
- */\r
-\r
-#ifdef __cplusplus\r
- extern "C" {\r
-#endif\r
-\r
-\r
-#ifndef VERSION\r
-#define VERSION "2.1"\r
-#endif\r
-\r
-#ifndef VPATH\r
-#define VPATH "."\r
-#endif\r
-\r
-#ifndef PREFIX\r
-#  ifdef __VMS\r
-#    define PREFIX ""\r
-#  else\r
-#    define PREFIX "/usr/local"\r
-#  endif\r
-#endif\r
-\r
-#ifndef EXEC_PREFIX\r
-#define EXEC_PREFIX PREFIX\r
-#endif\r
-\r
-#ifndef PYTHONPATH\r
-#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \\r
-              EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"\r
-#endif\r
-\r
-#ifndef LANDMARK\r
-#define LANDMARK "os.py"\r
-#endif\r
-\r
-static char prefix[MAXPATHLEN+1];\r
-static char exec_prefix[MAXPATHLEN+1];\r
-static char progpath[MAXPATHLEN+1];\r
-static char *module_search_path = NULL;\r
-static char lib_python[] = "lib/python" VERSION;\r
-\r
-static void\r
-reduce(char *dir)\r
-{\r
-    size_t i = strlen(dir);\r
-    while (i > 0 && dir[i] != SEP)\r
-        --i;\r
-    dir[i] = '\0';\r
-}\r
-\r
-\r
-static int\r
-isfile(char *filename)          /* Is file, not directory */\r
-{\r
-    struct stat buf;\r
-    if (stat(filename, &buf) != 0)\r
-        return 0;\r
-    if (!S_ISREG(buf.st_mode))\r
-        return 0;\r
-    return 1;\r
-}\r
-\r
-\r
-static int\r
-ismodule(char *filename)        /* Is module -- check for .pyc/.pyo too */\r
-{\r
-    if (isfile(filename))\r
-        return 1;\r
-\r
-    /* Check for the compiled version of prefix. */\r
-    if (strlen(filename) < MAXPATHLEN) {\r
-        strcat(filename, Py_OptimizeFlag ? "o" : "c");\r
-        if (isfile(filename))\r
-            return 1;\r
-    }\r
-    return 0;\r
-}\r
-\r
-\r
-static int\r
-isxfile(char *filename)         /* Is executable file */\r
-{\r
-    struct stat buf;\r
-    if (stat(filename, &buf) != 0)\r
-        return 0;\r
-    if (!S_ISREG(buf.st_mode))\r
-        return 0;\r
-    if ((buf.st_mode & 0111) == 0)\r
-        return 0;\r
-    return 1;\r
-}\r
-\r
-\r
-static int\r
-isdir(char *filename)                   /* Is directory */\r
-{\r
-    struct stat buf;\r
-    if (stat(filename, &buf) != 0)\r
-        return 0;\r
-    if (!S_ISDIR(buf.st_mode))\r
-        return 0;\r
-    return 1;\r
-}\r
-\r
-\r
-/* Add a path component, by appending stuff to buffer.\r
-   buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a\r
-   NUL-terminated string with no more than MAXPATHLEN characters (not counting\r
-   the trailing NUL).  It's a fatal error if it contains a string longer than\r
-   that (callers must be careful!).  If these requirements are met, it's\r
-   guaranteed that buffer will still be a NUL-terminated string with no more\r
-   than MAXPATHLEN characters at exit.  If stuff is too long, only as much of\r
-   stuff as fits will be appended.\r
-*/\r
-static void\r
-joinpath(char *buffer, char *stuff)\r
-{\r
-    size_t n, k;\r
-    if (stuff[0] == SEP)\r
-        n = 0;\r
-    else {\r
-        n = strlen(buffer);\r
-        if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)\r
-            buffer[n++] = SEP;\r
-    }\r
-    if (n > MAXPATHLEN)\r
-        Py_FatalError("buffer overflow in getpath.c's joinpath()");\r
-    k = strlen(stuff);\r
-    if (n + k > MAXPATHLEN)\r
-        k = MAXPATHLEN - n;\r
-    strncpy(buffer+n, stuff, k);\r
-    buffer[n+k] = '\0';\r
-}\r
-\r
-/* copy_absolute requires that path be allocated at least\r
-   MAXPATHLEN + 1 bytes and that p be no more than MAXPATHLEN bytes. */\r
-static void\r
-copy_absolute(char *path, char *p)\r
-{\r
-    if (p[0] == SEP)\r
-        strcpy(path, p);\r
-    else {\r
-        if (!getcwd(path, MAXPATHLEN)) {\r
-            /* unable to get the current directory */\r
-            strcpy(path, p);\r
-            return;\r
-        }\r
-        if (p[0] == '.' && p[1] == SEP)\r
-            p += 2;\r
-        joinpath(path, p);\r
-    }\r
-}\r
-\r
-/* absolutize() requires that path be allocated at least MAXPATHLEN+1 bytes. */\r
-static void\r
-absolutize(char *path)\r
-{\r
-    char buffer[MAXPATHLEN + 1];\r
-\r
-    if (path[0] == SEP)\r
-        return;\r
-    copy_absolute(buffer, path);\r
-    strcpy(path, buffer);\r
-}\r
-\r
-/* search_for_prefix requires that argv0_path be no more than MAXPATHLEN\r
-   bytes long.\r
-*/\r
-static int\r
-search_for_prefix(char *argv0_path, char *home)\r
-{\r
-    size_t n;\r
-    char *vpath;\r
-\r
-    /* If PYTHONHOME is set, we believe it unconditionally */\r
-    if (home) {\r
-        char *delim;\r
-        strncpy(prefix, home, MAXPATHLEN);\r
-        delim = strchr(prefix, DELIM);\r
-        if (delim)\r
-            *delim = '\0';\r
-        joinpath(prefix, lib_python);\r
-        joinpath(prefix, LANDMARK);\r
-        return 1;\r
-    }\r
-\r
-    /* Check to see if argv[0] is in the build directory */\r
-    strcpy(prefix, argv0_path);\r
-    joinpath(prefix, "Modules/Setup");\r
-    if (isfile(prefix)) {\r
-        /* Check VPATH to see if argv0_path is in the build directory. */\r
-        vpath = VPATH;\r
-        strcpy(prefix, argv0_path);\r
-        joinpath(prefix, vpath);\r
-        joinpath(prefix, "Lib");\r
-        joinpath(prefix, LANDMARK);\r
-        if (ismodule(prefix))\r
-            return -1;\r
-    }\r
-\r
-    /* Search from argv0_path, until root is found */\r
-    copy_absolute(prefix, argv0_path);\r
-    do {\r
-        n = strlen(prefix);\r
-        joinpath(prefix, lib_python);\r
-        joinpath(prefix, LANDMARK);\r
-        if (ismodule(prefix))\r
-            return 1;\r
-        prefix[n] = '\0';\r
-        reduce(prefix);\r
-    } while (prefix[0]);\r
-\r
-    /* Look at configure's PREFIX */\r
-    strncpy(prefix, PREFIX, MAXPATHLEN);\r
-    joinpath(prefix, lib_python);\r
-    joinpath(prefix, LANDMARK);\r
-    if (ismodule(prefix))\r
-        return 1;\r
-\r
-    /* Fail */\r
-    return 0;\r
-}\r
-\r
-\r
-/* search_for_exec_prefix requires that argv0_path be no more than\r
-   MAXPATHLEN bytes long.\r
-*/\r
-static int\r
-search_for_exec_prefix(char *argv0_path, char *home)\r
-{\r
-    size_t n;\r
-\r
-    /* If PYTHONHOME is set, we believe it unconditionally */\r
-    if (home) {\r
-        char *delim;\r
-        delim = strchr(home, DELIM);\r
-        if (delim)\r
-            strncpy(exec_prefix, delim+1, MAXPATHLEN);\r
-        else\r
-            strncpy(exec_prefix, home, MAXPATHLEN);\r
-        joinpath(exec_prefix, lib_python);\r
-        joinpath(exec_prefix, "lib-dynload");\r
-        return 1;\r
-    }\r
-\r
-    /* Check to see if argv[0] is in the build directory */\r
-    strcpy(exec_prefix, argv0_path);\r
-    joinpath(exec_prefix, "Modules/Setup");\r
-    if (isfile(exec_prefix)) {\r
-        reduce(exec_prefix);\r
-        return -1;\r
-    }\r
-\r
-    /* Search from argv0_path, until root is found */\r
-    copy_absolute(exec_prefix, argv0_path);\r
-    do {\r
-        n = strlen(exec_prefix);\r
-        joinpath(exec_prefix, lib_python);\r
-        joinpath(exec_prefix, "lib-dynload");\r
-        if (isdir(exec_prefix))\r
-            return 1;\r
-        exec_prefix[n] = '\0';\r
-        reduce(exec_prefix);\r
-    } while (exec_prefix[0]);\r
-\r
-    /* Look at configure's EXEC_PREFIX */\r
-    strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN);\r
-    joinpath(exec_prefix, lib_python);\r
-    joinpath(exec_prefix, "lib-dynload");\r
-    if (isdir(exec_prefix))\r
-        return 1;\r
-\r
-    /* Fail */\r
-    return 0;\r
-}\r
-\r
-\r
-static void\r
-calculate_path(void)\r
-{\r
-    extern char *Py_GetProgramName(void);\r
-\r
-    static char delimiter[2] = {DELIM, '\0'};\r
-    static char separator[2] = {SEP, '\0'};\r
-    char *pythonpath = PYTHONPATH;\r
-    char *rtpypath = Py_GETENV("PYTHONPATH");\r
-    char *home = Py_GetPythonHome();\r
-    char *path = getenv("PATH");\r
-    char *prog = Py_GetProgramName();\r
-    char argv0_path[MAXPATHLEN+1];\r
-    char zip_path[MAXPATHLEN+1];\r
-    int pfound, efound; /* 1 if found; -1 if found build directory */\r
-    char *buf;\r
-    size_t bufsz;\r
-    size_t prefixsz;\r
-    char *defpath = pythonpath;\r
-#ifdef WITH_NEXT_FRAMEWORK\r
-    NSModule pythonModule;\r
-#endif\r
-#ifdef __APPLE__\r
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4\r
-    uint32_t nsexeclength = MAXPATHLEN;\r
-#else\r
-    unsigned long nsexeclength = MAXPATHLEN;\r
-#endif\r
-#endif\r
-\r
-        /* If there is no slash in the argv0 path, then we have to\r
-         * assume python is on the user's $PATH, since there's no\r
-         * other way to find a directory to start the search from.  If\r
-         * $PATH isn't exported, you lose.\r
-         */\r
-        if (strchr(prog, SEP))\r
-                strncpy(progpath, prog, MAXPATHLEN);\r
-#ifdef __APPLE__\r
-     /* On Mac OS X, if a script uses an interpreter of the form\r
-      * "#!/opt/python2.3/bin/python", the kernel only passes "python"\r
-      * as argv[0], which falls through to the $PATH search below.\r
-      * If /opt/python2.3/bin isn't in your path, or is near the end,\r
-      * this algorithm may incorrectly find /usr/bin/python. To work\r
-      * around this, we can use _NSGetExecutablePath to get a better\r
-      * hint of what the intended interpreter was, although this\r
-      * will fail if a relative path was used. but in that case,\r
-      * absolutize() should help us out below\r
-      */\r
-     else if(0 == _NSGetExecutablePath(progpath, &nsexeclength) && progpath[0] == SEP)\r
-       ;\r
-#endif /* __APPLE__ */\r
-        else if (path) {\r
-                while (1) {\r
-                        char *delim = strchr(path, DELIM);\r
-\r
-                        if (delim) {\r
-                                size_t len = delim - path;\r
-                                if (len > MAXPATHLEN)\r
-                                        len = MAXPATHLEN;\r
-                                strncpy(progpath, path, len);\r
-                                *(progpath + len) = '\0';\r
-                        }\r
-                        else\r
-                                strncpy(progpath, path, MAXPATHLEN);\r
-\r
-                        joinpath(progpath, prog);\r
-                        if (isxfile(progpath))\r
-                                break;\r
-\r
-                        if (!delim) {\r
-                                progpath[0] = '\0';\r
-                                break;\r
-                        }\r
-                        path = delim + 1;\r
-                }\r
-        }\r
-        else\r
-                progpath[0] = '\0';\r
-        if (progpath[0] != SEP && progpath[0] != '\0')\r
-                absolutize(progpath);\r
-        strncpy(argv0_path, progpath, MAXPATHLEN);\r
-        argv0_path[MAXPATHLEN] = '\0';\r
-\r
-#ifdef WITH_NEXT_FRAMEWORK\r
-        /* On Mac OS X we have a special case if we're running from a framework.\r
-        ** This is because the python home should be set relative to the library,\r
-        ** which is in the framework, not relative to the executable, which may\r
-        ** be outside of the framework. Except when we're in the build directory...\r
-        */\r
-    pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));\r
-    /* Use dylib functions to find out where the framework was loaded from */\r
-    buf = (char *)NSLibraryNameForModule(pythonModule);\r
-    if (buf != NULL) {\r
-        /* We're in a framework. */\r
-        /* See if we might be in the build directory. The framework in the\r
-        ** build directory is incomplete, it only has the .dylib and a few\r
-        ** needed symlinks, it doesn't have the Lib directories and such.\r
-        ** If we're running with the framework from the build directory we must\r
-        ** be running the interpreter in the build directory, so we use the\r
-        ** build-directory-specific logic to find Lib and such.\r
-        */\r
-        strncpy(argv0_path, buf, MAXPATHLEN);\r
-        reduce(argv0_path);\r
-        joinpath(argv0_path, lib_python);\r
-        joinpath(argv0_path, LANDMARK);\r
-        if (!ismodule(argv0_path)) {\r
-                /* We are in the build directory so use the name of the\r
-                   executable - we know that the absolute path is passed */\r
-                strncpy(argv0_path, progpath, MAXPATHLEN);\r
-        }\r
-        else {\r
-                /* Use the location of the library as the progpath */\r
-                strncpy(argv0_path, buf, MAXPATHLEN);\r
-        }\r
-    }\r
-#endif\r
-\r
-#if HAVE_READLINK\r
-    {\r
-        char tmpbuffer[MAXPATHLEN+1];\r
-        int linklen = readlink(progpath, tmpbuffer, MAXPATHLEN);\r
-        while (linklen != -1) {\r
-            /* It's not null terminated! */\r
-            tmpbuffer[linklen] = '\0';\r
-            if (tmpbuffer[0] == SEP)\r
-                /* tmpbuffer should never be longer than MAXPATHLEN,\r
-                   but extra check does not hurt */\r
-                strncpy(argv0_path, tmpbuffer, MAXPATHLEN);\r
-            else {\r
-                /* Interpret relative to progpath */\r
-                reduce(argv0_path);\r
-                joinpath(argv0_path, tmpbuffer);\r
-            }\r
-            linklen = readlink(argv0_path, tmpbuffer, MAXPATHLEN);\r
-        }\r
-    }\r
-#endif /* HAVE_READLINK */\r
-\r
-    reduce(argv0_path);\r
-    /* At this point, argv0_path is guaranteed to be less than\r
-       MAXPATHLEN bytes long.\r
-    */\r
-\r
-    if (!(pfound = search_for_prefix(argv0_path, home))) {\r
-        if (!Py_FrozenFlag)\r
-            fprintf(stderr,\r
-                "Could not find platform independent libraries <prefix>\n");\r
-        strncpy(prefix, PREFIX, MAXPATHLEN);\r
-        joinpath(prefix, lib_python);\r
-    }\r
-    else\r
-        reduce(prefix);\r
-\r
-    strncpy(zip_path, prefix, MAXPATHLEN);\r
-    zip_path[MAXPATHLEN] = '\0';\r
-    if (pfound > 0) { /* Use the reduced prefix returned by Py_GetPrefix() */\r
-        reduce(zip_path);\r
-        reduce(zip_path);\r
-    }\r
-    else\r
-        strncpy(zip_path, PREFIX, MAXPATHLEN);\r
-    joinpath(zip_path, "lib/python00.zip");\r
-    bufsz = strlen(zip_path);   /* Replace "00" with version */\r
-    zip_path[bufsz - 6] = VERSION[0];\r
-    zip_path[bufsz - 5] = VERSION[2];\r
-\r
-    if (!(efound = search_for_exec_prefix(argv0_path, home))) {\r
-        if (!Py_FrozenFlag)\r
-            fprintf(stderr,\r
-                "Could not find platform dependent libraries <exec_prefix>\n");\r
-        strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN);\r
-        joinpath(exec_prefix, "lib/lib-dynload");\r
-    }\r
-    /* If we found EXEC_PREFIX do *not* reduce it!  (Yet.) */\r
-\r
-    if ((!pfound || !efound) && !Py_FrozenFlag)\r
-        fprintf(stderr,\r
-                "Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n");\r
-\r
-    /* Calculate size of return buffer.\r
-     */\r
-    bufsz = 0;\r
-\r
-    if (rtpypath)\r
-        bufsz += strlen(rtpypath) + 1;\r
-\r
-    prefixsz = strlen(prefix) + 1;\r
-\r
-    while (1) {\r
-        char *delim = strchr(defpath, DELIM);\r
-\r
-        if (defpath[0] != SEP)\r
-            /* Paths are relative to prefix */\r
-            bufsz += prefixsz;\r
-\r
-        if (delim)\r
-            bufsz += delim - defpath + 1;\r
-        else {\r
-            bufsz += strlen(defpath) + 1;\r
-            break;\r
-        }\r
-        defpath = delim + 1;\r
-    }\r
-\r
-    bufsz += strlen(zip_path) + 1;\r
-    bufsz += strlen(exec_prefix) + 1;\r
-\r
-    /* This is the only malloc call in this file */\r
-    buf = (char *)PyMem_Malloc(bufsz);\r
-\r
-    if (buf == NULL) {\r
-        /* We can't exit, so print a warning and limp along */\r
-        fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");\r
-        fprintf(stderr, "Using default static PYTHONPATH.\n");\r
-        module_search_path = PYTHONPATH;\r
-    }\r
-    else {\r
-        /* Run-time value of $PYTHONPATH goes first */\r
-        if (rtpypath) {\r
-            strcpy(buf, rtpypath);\r
-            strcat(buf, delimiter);\r
-        }\r
-        else\r
-            buf[0] = '\0';\r
-\r
-        /* Next is the default zip path */\r
-        strcat(buf, zip_path);\r
-        strcat(buf, delimiter);\r
-\r
-        /* Next goes merge of compile-time $PYTHONPATH with\r
-         * dynamically located prefix.\r
-         */\r
-        defpath = pythonpath;\r
-        while (1) {\r
-            char *delim = strchr(defpath, DELIM);\r
-\r
-            if (defpath[0] != SEP) {\r
-                strcat(buf, prefix);\r
-                strcat(buf, separator);\r
-            }\r
-\r
-            if (delim) {\r
-                size_t len = delim - defpath + 1;\r
-                size_t end = strlen(buf) + len;\r
-                strncat(buf, defpath, len);\r
-                *(buf + end) = '\0';\r
-            }\r
-            else {\r
-                strcat(buf, defpath);\r
-                break;\r
-            }\r
-            defpath = delim + 1;\r
-        }\r
-        strcat(buf, delimiter);\r
-\r
-        /* Finally, on goes the directory for dynamic-load modules */\r
-        strcat(buf, exec_prefix);\r
-\r
-        /* And publish the results */\r
-        module_search_path = buf;\r
-    }\r
-\r
-    /* Reduce prefix and exec_prefix to their essence,\r
-     * e.g. /usr/local/lib/python1.5 is reduced to /usr/local.\r
-     * If we're loading relative to the build directory,\r
-     * return the compiled-in defaults instead.\r
-     */\r
-    if (pfound > 0) {\r
-        reduce(prefix);\r
-        reduce(prefix);\r
-        /* The prefix is the root directory, but reduce() chopped\r
-         * off the "/". */\r
-        if (!prefix[0])\r
-                strcpy(prefix, separator);\r
-    }\r
-    else\r
-        strncpy(prefix, PREFIX, MAXPATHLEN);\r
-\r
-    if (efound > 0) {\r
-        reduce(exec_prefix);\r
-        reduce(exec_prefix);\r
-        reduce(exec_prefix);\r
-        if (!exec_prefix[0])\r
-                strcpy(exec_prefix, separator);\r
-    }\r
-    else\r
-        strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN);\r
-}\r
-\r
-\r
-/* External interface */\r
-\r
-char *\r
-Py_GetPath(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return module_search_path;\r
-}\r
-\r
-char *\r
-Py_GetPrefix(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return prefix;\r
-}\r
-\r
-char *\r
-Py_GetExecPrefix(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return exec_prefix;\r
-}\r
-\r
-char *\r
-Py_GetProgramFullPath(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return progpath;\r
-}\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r