summaryrefslogtreecommitdiffstats
path: root/dln.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-24 05:15:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-24 05:15:13 +0000
commit46bf5f3463ddab66dc82d6d1a0fd53a855783edf (patch)
tree2027065dba3ad774980ec5812573007a2bb66c49 /dln.c
parentfc802b81b25ef072ee7ed4c57387c329e0932080 (diff)
downloadruby-46bf5f3463ddab66dc82d6d1a0fd53a855783edf.tar.gz
ruby-46bf5f3463ddab66dc82d6d1a0fd53a855783edf.tar.xz
ruby-46bf5f3463ddab66dc82d6d1a0fd53a855783edf.zip
* dln.c (dln_find_1): prior files with extensions to files sans
extensions. [ruby-core:16517] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/dln.c b/dln.c
index f3d6bf936..33b912d38 100644
--- a/dln.c
+++ b/dln.c
@@ -1694,26 +1694,9 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
}
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)
@@ -1726,11 +1709,10 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
".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);
@@ -1747,9 +1729,28 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
#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') {