summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-26 18:15:22 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-26 18:15:22 (GMT)
commite0513dee58578e308bad7f6ad7b5b124f7a18c7b (patch)
tree104ecfc7e6d41fac6500be879da37fe4d23a2bc3 /Python/import.c
parentb7e51608386ee91840f00d1caa032ab0f14fbd36 (diff)
downloadcpython-e0513dee58578e308bad7f6ad7b5b124f7a18c7b.zip
cpython-e0513dee58578e308bad7f6ad7b5b124f7a18c7b.tar.gz
cpython-e0513dee58578e308bad7f6ad7b5b124f7a18c7b.tar.bz2
getbinaryname is now part of dl_loadmod.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c65
1 files changed, 2 insertions, 63 deletions
diff --git a/Python/import.c b/Python/import.c
index 4ee72a9..899621f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -46,7 +46,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef USE_DL
#include "dl.h"
-static char *getbinaryname();
+extern char *argv0;
#endif
/* Magic word to reject pre-0.9.4 .pyc files */
@@ -194,7 +194,7 @@ get_module(m, name, m_ret)
dl_funcptr p;
D(fprintf(stderr, "Found %s\n", namebuf));
sprintf(funcname, "init%s", name);
- p = dl_loadmod(getbinaryname(), namebuf, funcname);
+ p = dl_loadmod(argv0, namebuf, funcname);
if (p == NULL) {
D(fprintf(stderr, "dl_loadmod failed\n"));
}
@@ -404,64 +404,3 @@ init_builtin(name)
}
return 0;
}
-
-#ifdef USE_DL
-
-/* A function to find a filename for the currently executing binary.
- Because this is not directly available, we have to search for argv[0]
- along $PATH. But note that if argv[0] contains a slash anywhere,
- sh(1) doesn't search $PATH -- so neither do we! */
-
-/* XXX This should be moved to a more system-specific file */
-
-#include <sys/types.h>
-#include <sys/stat.h> /* For stat */
-
-extern char *getenv();
-
-extern char *argv0; /* In config.c */
-
-/* Default path from sh(1) in Irix 4.0.1 */
-#define DEF_PATH ":/usr/sbin:/usr/bsd:/bin:/usr/bin:/usr/bin/X11"
-
-static char *
-getbinaryname()
-{
- char *p, *q;
- char *path;
- static char buf[258];
- int i;
- struct stat st;
-
- if (strchr(argv0, '/') != NULL) {
- D(fprintf(stderr, "binary includes slash: %s\n", argv0));
- return argv0;
- }
- path = getenv("PATH");
- if (path == NULL)
- path = DEF_PATH;
- p = q = path;
- for (;;) {
- while (*q && *q != ':')
- q++;
- i = q-p;
- strncpy(buf, p, i);
- if (q > p && q[-1] != '/')
- buf[i++] = '/';
- strcpy(buf+i, argv0);
- if (stat(buf, &st) >= 0) {
- if (S_ISREG(st.st_mode) &&
- (st.st_mode & 0111)) {
- D(fprintf(stderr, "found binary: %s\n", buf));
- return buf;
- }
- }
- if (!*q)
- break;
- p = ++q;
- }
- D(fprintf(stderr, "can't find binary: %s\n", argv0));
- return argv0;
-}
-
-#endif