File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121#define prefix_stricmp strcasecmp
2222#endif
2323
24- static inline int ends_with_case_insensitive (const char * s , const char * suffix ) {
25- if (!s || !suffix )
26- return 0 ;
27- size_t ls = strlen (s ), lf = strlen (suffix );
28- return lf <= ls && prefix_stricmp (s + (ls - lf ), suffix ) == 0 ;
29- }
30-
3124static inline char * prefix_fullpath_dup (const char * path ) {
3225 if (!path || path [0 ] == '\0' ) {
3326 return NULL ;
Original file line number Diff line number Diff line change @@ -129,8 +129,13 @@ static const char *platform_dynlib_suffix(void) {
129129}
130130
131131static int has_dynlib_suffix (const char * path ) {
132- return ends_with_case_insensitive (path , ".dll" ) || ends_with_case_insensitive (path , ".so" ) ||
133- ends_with_case_insensitive (path , ".dylib" );
132+ if (!path ) {
133+ return 0 ;
134+ }
135+ size_t plen = strlen (path );
136+ return (plen >= 4 && prefix_stricmp (path + plen - 4 , ".dll" ) == 0 ) ||
137+ (plen >= 3 && prefix_stricmp (path + plen - 3 , ".so" ) == 0 ) ||
138+ (plen >= 6 && prefix_stricmp (path + plen - 6 , ".dylib" ) == 0 );
134139}
135140
136141static char * path_join2 (const char * a , const char * b ) {
Original file line number Diff line number Diff line change @@ -19,8 +19,10 @@ static int is_extension_arg(const char *arg) {
1919 if (!arg ) {
2020 return 0 ;
2121 }
22- return ends_with_case_insensitive (arg , ".dll" ) || ends_with_case_insensitive (arg , ".so" ) ||
23- ends_with_case_insensitive (arg , ".dylib" );
22+ size_t alen = strlen (arg );
23+ return (alen >= 4 && prefix_stricmp (arg + alen - 4 , ".dll" ) == 0 ) ||
24+ (alen >= 3 && prefix_stricmp (arg + alen - 3 , ".so" ) == 0 ) ||
25+ (alen >= 6 && prefix_stricmp (arg + alen - 6 , ".dylib" ) == 0 );
2426}
2527
2628static char * path_dirname_dup (const char * path ) {
You can’t perform that action at this time.
0 commit comments