Hi,

At Thu, 24 Apr 2008 02:32:05 +0900,
Luis Lavena wrote in [ruby-core:16517]:
> Basically, this ticket [1] exposes a problem that annoys and add
> cross-platform inoperativeness to Ruby. It start with the assumption
> that an extensionless file have priority over a true windows
> executable (.exe, com, bat, cmd) and try to use it instead when issue
> system or any way that calls back into the OS.

Do you consider files sans extensions shouldn't be returned?


Index: dln.c =================================================================== --- dln.c (revision 16174) +++ dln.c (working copy) @@ -1695,24 +1695,7 @@ dln_find_1(const char *fname, const char 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 const extension[][5] = { #if defined(MSDOS) ".com", ".exe", ".bat", @@ -1748,7 +1731,26 @@ dln_find_1(const char *fname, const char #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 */
-- Nobu Nakada