Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0513de

Browse files
committed
getbinaryname is now part of dl_loadmod.
1 parent b7e5160 commit e0513de

1 file changed

Lines changed: 2 additions & 63 deletions

File tree

Python/import.c

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4646
#ifdef USE_DL
4747
#include "dl.h"
4848

49-
static char *getbinaryname();
49+
extern char *argv0;
5050
#endif
5151

5252
/* Magic word to reject pre-0.9.4 .pyc files */
@@ -194,7 +194,7 @@ get_module(m, name, m_ret)
194194
dl_funcptr p;
195195
D(fprintf(stderr, "Found %s\n", namebuf));
196196
sprintf(funcname, "init%s", name);
197-
p = dl_loadmod(getbinaryname(), namebuf, funcname);
197+
p = dl_loadmod(argv0, namebuf, funcname);
198198
if (p == NULL) {
199199
D(fprintf(stderr, "dl_loadmod failed\n"));
200200
}
@@ -404,64 +404,3 @@ init_builtin(name)
404404
}
405405
return 0;
406406
}
407-
408-
#ifdef USE_DL
409-
410-
/* A function to find a filename for the currently executing binary.
411-
Because this is not directly available, we have to search for argv[0]
412-
along $PATH. But note that if argv[0] contains a slash anywhere,
413-
sh(1) doesn't search $PATH -- so neither do we! */
414-
415-
/* XXX This should be moved to a more system-specific file */
416-
417-
#include <sys/types.h>
418-
#include <sys/stat.h> /* For stat */
419-
420-
extern char *getenv();
421-
422-
extern char *argv0; /* In config.c */
423-
424-
/* Default path from sh(1) in Irix 4.0.1 */
425-
#define DEF_PATH ":/usr/sbin:/usr/bsd:/bin:/usr/bin:/usr/bin/X11"
426-
427-
static char *
428-
getbinaryname()
429-
{
430-
char *p, *q;
431-
char *path;
432-
static char buf[258];
433-
int i;
434-
struct stat st;
435-
436-
if (strchr(argv0, '/') != NULL) {
437-
D(fprintf(stderr, "binary includes slash: %s\n", argv0));
438-
return argv0;
439-
}
440-
path = getenv("PATH");
441-
if (path == NULL)
442-
path = DEF_PATH;
443-
p = q = path;
444-
for (;;) {
445-
while (*q && *q != ':')
446-
q++;
447-
i = q-p;
448-
strncpy(buf, p, i);
449-
if (q > p && q[-1] != '/')
450-
buf[i++] = '/';
451-
strcpy(buf+i, argv0);
452-
if (stat(buf, &st) >= 0) {
453-
if (S_ISREG(st.st_mode) &&
454-
(st.st_mode & 0111)) {
455-
D(fprintf(stderr, "found binary: %s\n", buf));
456-
return buf;
457-
}
458-
}
459-
if (!*q)
460-
break;
461-
p = ++q;
462-
}
463-
D(fprintf(stderr, "can't find binary: %s\n", argv0));
464-
return argv0;
465-
}
466-
467-
#endif

0 commit comments

Comments
 (0)