* dcrt0.cc: New global variable `ignore_case_with_glob'.
(dll_crt0_1): Disable case-insensitive globbing before calling `main'. * environ.cc (glob_init): New static function to set or clear `ignore_case_with_glob'. (known): Changed "glob" entry to call `glob_init'. * glob.c (match): Use case-insensitive globbing if needed.
This commit is contained in:
		| @@ -1,3 +1,12 @@ | |||||||
|  | Fri Nov 10 13:48:44 2000 Bradley A. Town <townba@pobox.com> | ||||||
|  |  | ||||||
|  | 	* dcrt0.cc: New global variable `ignore_case_with_glob'. | ||||||
|  | 	(dll_crt0_1): Disable case-insensitive globbing before calling `main'. | ||||||
|  | 	* environ.cc (glob_init): New static function to set or clear | ||||||
|  | 	`ignore_case_with_glob'. | ||||||
|  | 	(known): Changed "glob" entry to call `glob_init'. | ||||||
|  | 	* glob.c (match): Use case-insensitive globbing if needed. | ||||||
|  |  | ||||||
| Thu Nov  9 14:30:00 2000  Corinna Vinschen <corinna@vinschen.de> | Thu Nov  9 14:30:00 2000  Corinna Vinschen <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* dir.cc (readdir): Avoid reading from the beginning when | 	* dir.cc (readdir): Avoid reading from the beginning when | ||||||
|   | |||||||
| @@ -106,6 +106,7 @@ extern "C" | |||||||
|    /* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf, |    /* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf, | ||||||
|    /* impure_ptr */ &reent_data, |    /* impure_ptr */ &reent_data, | ||||||
|   }; |   }; | ||||||
|  |   BOOL ignore_case_with_glob = FALSE; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| char *old_title = NULL; | char *old_title = NULL; | ||||||
| @@ -835,6 +836,9 @@ dll_crt0_1 () | |||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |   /* Disable case-insensitive globbing */ | ||||||
|  |   ignore_case_with_glob = FALSE; | ||||||
|  |  | ||||||
|   /* Flush signals and ensure that signal thread is up and running. Can't |   /* Flush signals and ensure that signal thread is up and running. Can't | ||||||
|      do this for noncygwin case since the signal thread is blocked due to |      do this for noncygwin case since the signal thread is blocked due to | ||||||
|      LoadLibrary serialization. */ |      LoadLibrary serialization. */ | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ details. */ | |||||||
| #include "perprocess.h" | #include "perprocess.h" | ||||||
|  |  | ||||||
| extern BOOL allow_glob; | extern BOOL allow_glob; | ||||||
|  | extern BOOL ignore_case_with_glob; | ||||||
| extern BOOL allow_ntea; | extern BOOL allow_ntea; | ||||||
| extern BOOL strip_title_path; | extern BOOL strip_title_path; | ||||||
| extern DWORD chunksize; | extern DWORD chunksize; | ||||||
| @@ -380,6 +381,31 @@ enum settings | |||||||
|     set_process_state, |     set_process_state, | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  | /* When BUF is: | ||||||
|  |  * null or empty: disables globbing | ||||||
|  |  * "ignorecase": enables case-insensitive globbing | ||||||
|  |  * anything else: enables case-sensitive globbing | ||||||
|  |  */ | ||||||
|  | static void | ||||||
|  | glob_init (const char *buf) | ||||||
|  | { | ||||||
|  |   if (!buf || !*buf) | ||||||
|  |     { | ||||||
|  |       allow_glob = FALSE; | ||||||
|  |       ignore_case_with_glob = FALSE; | ||||||
|  |     } | ||||||
|  |   else if (strncasematch (buf, "ignorecase", 10)) | ||||||
|  |     { | ||||||
|  |       allow_glob = TRUE; | ||||||
|  |       ignore_case_with_glob = TRUE; | ||||||
|  |     } | ||||||
|  |   else | ||||||
|  |     { | ||||||
|  |       allow_glob = TRUE; | ||||||
|  |       ignore_case_with_glob = FALSE; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| /* The structure below is used to set up an array which is used to | /* The structure below is used to set up an array which is used to | ||||||
|  * parse the CYGWIN environment variable or, if enabled, options from |  * parse the CYGWIN environment variable or, if enabled, options from | ||||||
|  * the registry. |  * the registry. | ||||||
| @@ -409,7 +435,7 @@ struct parse_thing | |||||||
|   {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}}, |   {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}}, | ||||||
|   {"export", {&export_settings}, justset, NULL, {{FALSE}, {TRUE}}}, |   {"export", {&export_settings}, justset, NULL, {{FALSE}, {TRUE}}}, | ||||||
|   {"forkchunk", {x: &chunksize}, justset, NULL, {{8192}, {0}}}, |   {"forkchunk", {x: &chunksize}, justset, NULL, {{8192}, {0}}}, | ||||||
|   {"glob", {&allow_glob}, justset, NULL, {{FALSE}, {TRUE}}}, |   {"glob", {func: &glob_init}, isfunc, NULL, {{0}, {s: "normal"}}}, | ||||||
|   {"ntea", {&allow_ntea}, justset, NULL, {{FALSE}, {TRUE}}}, |   {"ntea", {&allow_ntea}, justset, NULL, {{FALSE}, {TRUE}}}, | ||||||
|   {"ntsec", {&allow_ntsec}, justset, NULL, {{FALSE}, {TRUE}}}, |   {"ntsec", {&allow_ntsec}, justset, NULL, {{FALSE}, {TRUE}}}, | ||||||
|   {"reset_com", {&reset_com}, justset, NULL, {{FALSE}, {TRUE}}}, |   {"reset_com", {&reset_com}, justset, NULL, {{FALSE}, {TRUE}}}, | ||||||
|   | |||||||
| @@ -72,6 +72,7 @@ | |||||||
| #include <sys/param.h> | #include <sys/param.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
|  |  | ||||||
|  | #include <ctype.h> | ||||||
| #include <dirent.h> | #include <dirent.h> | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <glob.h> | #include <glob.h> | ||||||
| @@ -81,6 +82,7 @@ | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  | #include <windows.h> | ||||||
|  |  | ||||||
| #ifdef __weak_alias | #ifdef __weak_alias | ||||||
| #ifdef __LIBC12_SOURCE__ | #ifdef __LIBC12_SOURCE__ | ||||||
| @@ -174,6 +176,8 @@ static void	 qprintf __P((const char *, Char *)); | |||||||
| #undef MAXPATHLEN | #undef MAXPATHLEN | ||||||
| #define MAXPATHLEN 16384 | #define MAXPATHLEN 16384 | ||||||
|  |  | ||||||
|  | extern BOOL ignore_case_with_glob; | ||||||
|  |  | ||||||
| int | int | ||||||
| glob(pattern, flags, errfunc, pglob) | glob(pattern, flags, errfunc, pglob) | ||||||
| 	const char *pattern; | 	const char *pattern; | ||||||
| @@ -727,19 +731,41 @@ match(name, pat, patend) | |||||||
| 				return(0); | 				return(0); | ||||||
| 			if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) | 			if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) | ||||||
| 				++pat; | 				++pat; | ||||||
| 			while (((c = *pat++) & M_MASK) != M_END) | 			if (ignore_case_with_glob) | ||||||
| 				if ((*pat & M_MASK) == M_RNG) { | 			  { | ||||||
| 					if (c <= k && k <= pat[1]) | 			    while (((c = *pat++) & M_MASK) != M_END) | ||||||
| 						ok = 1; | 			      if ((*pat & M_MASK) == M_RNG) { | ||||||
| 					pat += 2; | 				if (tolower(c) <= tolower(k) && tolower(k) <= tolower(pat[1])) | ||||||
| 				} else if (c == k) | 				  ok = 1; | ||||||
| 					ok = 1; | 				pat += 2; | ||||||
|  | 			      } else if (tolower(c) == tolower(k)) | ||||||
|  | 				ok = 1; | ||||||
|  | 			  } | ||||||
|  | 			else | ||||||
|  | 			  { | ||||||
|  | 			    while (((c = *pat++) & M_MASK) != M_END) | ||||||
|  | 			      if ((*pat & M_MASK) == M_RNG) { | ||||||
|  | 				if (c <= k && k <= pat[1]) | ||||||
|  | 				  ok = 1; | ||||||
|  | 				pat += 2; | ||||||
|  | 			      } else if (c == k) | ||||||
|  | 				ok = 1; | ||||||
|  | 			  } | ||||||
| 			if (ok == negate_range) | 			if (ok == negate_range) | ||||||
| 				return(0); | 				return(0); | ||||||
| 			break; | 			break; | ||||||
| 		default: | 		default: | ||||||
| 			if (*name++ != c) | 			if (ignore_case_with_glob) | ||||||
| 				return(0); | 			  { | ||||||
|  | 			    if (tolower(*name) != tolower(c)) | ||||||
|  | 			      return(0); | ||||||
|  | 			    ++name; | ||||||
|  | 			  } | ||||||
|  | 			else | ||||||
|  | 			  { | ||||||
|  | 			    if (*name++ != c) | ||||||
|  | 			      return(0); | ||||||
|  | 			  } | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user