diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-25 06:51:21 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-25 06:51:21 +0000 |
commit | 74efef0be85061c3c9e24ee0cfdf5f83c2af9a22 (patch) | |
tree | 2db7641808ab4f14daf322ee4eae9786b372dc35 /dln.c | |
parent | 23de09d6bb2005efe55b08e90875ff6a6c6f8976 (diff) | |
download | ruby-74efef0be85061c3c9e24ee0cfdf5f83c2af9a22.tar.gz |
Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r-- | dln.c | 41 |
1 files changed, 21 insertions, 20 deletions
@@ -1781,26 +1781,9 @@ dln_find_1(fname, path, exe_flag) } memcpy(bp, fname, i + 1); -#ifndef __MACOS__ - if (stat(fbuf, &st) == 0) { - if (exe_flag == 0) return fbuf; - /* looking for executable */ - if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0) - return fbuf; - } -#else - if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) { - if (exe_flag == 0) return mac_fullpath; - /* looking for executable */ - if (stat(mac_fullpath, &st) == 0) { - if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0) - return mac_fullpath; - } - } -#endif #if defined(DOSISH) if (exe_flag) { - static const char *const extension[] = { + static const char extension[][5] = { #if defined(MSDOS) ".com", ".exe", ".bat", #if defined(DJGPP) @@ -1813,11 +1796,10 @@ dln_find_1(fname, path, exe_flag) ".r", ".R", ".x", ".X", ".bat", ".BAT", /* __human68k__ */ #endif - (char *) NULL }; int j; - for (j = 0; extension[j]; j++) { + for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) { if (fspace < strlen(extension[j])) { fprintf(stderr, "openpath: pathname too long (ignored)\n"); fprintf(stderr, "\tDirectory \"%.*s\"\n", (int) (bp - fbuf), fbuf); @@ -1834,9 +1816,28 @@ dln_find_1(fname, path, exe_flag) #endif } + goto next; } #endif /* MSDOS or _WIN32 or __human68k__ or __EMX__ */ +#ifndef __MACOS__ + if (stat(fbuf, &st) == 0) { + if (exe_flag == 0) return fbuf; + /* looking for executable */ + if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0) + return fbuf; + } +#else + if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) { + if (exe_flag == 0) return mac_fullpath; + /* looking for executable */ + if (stat(mac_fullpath, &st) == 0) { + if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0) + return mac_fullpath; + } + } +#endif + next: /* if not, and no other alternatives, life is bleak */ if (*ep == '\0') { |