@@ -1772,26 +1772,9 @@ dln_find_1(fname, path, exe_flag)
1772
1772
}
1773
1773
memcpy (bp , fname , i + 1 );
1774
1774
1775
- #ifndef __MACOS__
1776
- if (stat (fbuf , & st ) == 0 ) {
1777
- if (exe_flag == 0 ) return fbuf ;
1778
- /* looking for executable */
1779
- if (!S_ISDIR (st .st_mode ) && eaccess (fbuf , X_OK ) == 0 )
1780
- return fbuf ;
1781
- }
1782
- #else
1783
- if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name (fbuf )) {
1784
- if (exe_flag == 0 ) return mac_fullpath ;
1785
- /* looking for executable */
1786
- if (stat (mac_fullpath , & st ) == 0 ) {
1787
- if (!S_ISDIR (st .st_mode ) && eaccess (mac_fullpath , X_OK ) == 0 )
1788
- return mac_fullpath ;
1789
- }
1790
- }
1791
- #endif
1792
1775
#if defined(DOSISH )
1793
1776
if (exe_flag ) {
1794
- static const char * extension [] = {
1777
+ static const char extension [][ 5 ] = {
1795
1778
#if defined(MSDOS )
1796
1779
".com" , ".exe" , ".bat" ,
1797
1780
#if defined(DJGPP )
@@ -1804,11 +1787,10 @@ dln_find_1(fname, path, exe_flag)
1804
1787
".r" , ".R" , ".x" , ".X" , ".bat" , ".BAT" ,
1805
1788
/* __human68k__ */
1806
1789
#endif
1807
- (char * ) NULL
1808
1790
};
1809
1791
int j ;
1810
1792
1811
- for (j = 0 ; extension [ j ] ; j ++ ) {
1793
+ for (j = 0 ; j < sizeof ( extension ) / sizeof ( extension [ 0 ]) ; j ++ ) {
1812
1794
if (fspace < strlen (extension [j ])) {
1813
1795
fprintf (stderr , "openpath: pathname too long (ignored)\n" );
1814
1796
fprintf (stderr , "\tDirectory \"%.*s\"\n" , (int ) (bp - fbuf ), fbuf );
@@ -1825,9 +1807,28 @@ dln_find_1(fname, path, exe_flag)
1825
1807
1826
1808
#endif
1827
1809
}
1810
+ goto next ;
1828
1811
}
1829
1812
#endif /* MSDOS or _WIN32 or __human68k__ or __EMX__ */
1830
1813
1814
+ #ifndef __MACOS__
1815
+ if (stat (fbuf , & st ) == 0 ) {
1816
+ if (exe_flag == 0 ) return fbuf ;
1817
+ /* looking for executable */
1818
+ if (!S_ISDIR (st .st_mode ) && eaccess (fbuf , X_OK ) == 0 )
1819
+ return fbuf ;
1820
+ }
1821
+ #else
1822
+ if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name (fbuf )) {
1823
+ if (exe_flag == 0 ) return mac_fullpath ;
1824
+ /* looking for executable */
1825
+ if (stat (mac_fullpath , & st ) == 0 ) {
1826
+ if (!S_ISDIR (st .st_mode ) && eaccess (mac_fullpath , X_OK ) == 0 )
1827
+ return mac_fullpath ;
1828
+ }
1829
+ }
1830
+ #endif
1831
+
1831
1832
next :
1832
1833
/* if not, and no other alternatives, life is bleak */
1833
1834
if (* ep == '\0' ) {
0 commit comments