now actually do comparisons for sorting ASCIIbetically
This commit is contained in:
		
							
								
								
									
										6
									
								
								edit.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								edit.c
									
									
									
									
									
								
							| @@ -28,7 +28,7 @@ | |||||||
|  |  | ||||||
| #ifndef MKSH_NO_CMDLINE_EDITING | #ifndef MKSH_NO_CMDLINE_EDITING | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.323 2017/04/21 19:50:06 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.324 2017/04/21 20:06:03 tg Exp $"); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * in later versions we might use libtermcap for this, but since external |  * in later versions we might use libtermcap for this, but since external | ||||||
| @@ -468,7 +468,7 @@ path_order_cmp(const void *aa, const void *bb) | |||||||
| 	const struct path_order_info *b = (const struct path_order_info *)bb; | 	const struct path_order_info *b = (const struct path_order_info *)bb; | ||||||
| 	int t; | 	int t; | ||||||
|  |  | ||||||
| 	if ((t = strcmp(a->word + a->base, b->word + b->base))) | 	if ((t = ascstrcmp(a->word + a->base, b->word + b->base))) | ||||||
| 		return (t); | 		return (t); | ||||||
| 	if (a->path_order > b->path_order) | 	if (a->path_order > b->path_order) | ||||||
| 		return (1); | 		return (1); | ||||||
| @@ -536,7 +536,7 @@ x_command_glob(int flags, char *toglob, char ***wordsp) | |||||||
| 		char **words = (char **)XPptrv(w); | 		char **words = (char **)XPptrv(w); | ||||||
| 		size_t i, j; | 		size_t i, j; | ||||||
|  |  | ||||||
| 		qsort(words, nwords, sizeof(void *), xstrcmp); | 		qsort(words, nwords, sizeof(void *), ascpstrcmp); | ||||||
| 		for (i = j = 0; i < nwords - 1; i++) { | 		for (i = j = 0; i < nwords - 1; i++) { | ||||||
| 			if (strcmp(words[i], words[i + 1])) | 			if (strcmp(words[i], words[i + 1])) | ||||||
| 				words[j++] = words[i]; | 				words[j++] = words[i]; | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								eval.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								eval.c
									
									
									
									
									
								
							| @@ -23,7 +23,7 @@ | |||||||
|  |  | ||||||
| #include "sh.h" | #include "sh.h" | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.201 2017/04/06 01:59:54 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.202 2017/04/21 20:06:04 tg Exp $"); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * string expansion |  * string expansion | ||||||
| @@ -1555,7 +1555,7 @@ glob(char *cp, XPtrV *wp, bool markdirs) | |||||||
| 		XPput(*wp, debunk(cp, cp, strlen(cp) + 1)); | 		XPput(*wp, debunk(cp, cp, strlen(cp) + 1)); | ||||||
| 	else | 	else | ||||||
| 		qsort(XPptrv(*wp) + oldsize, XPsize(*wp) - oldsize, | 		qsort(XPptrv(*wp) + oldsize, XPsize(*wp) - oldsize, | ||||||
| 		    sizeof(void *), xstrcmp); | 		    sizeof(void *), ascpstrcmp); | ||||||
| } | } | ||||||
|  |  | ||||||
| #define GF_NONE		0 | #define GF_NONE		0 | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								main.c
									
									
									
									
									
								
							| @@ -34,7 +34,7 @@ | |||||||
| #include <locale.h> | #include <locale.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.332 2017/04/12 16:01:45 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/main.c,v 1.333 2017/04/21 20:06:04 tg Exp $"); | ||||||
|  |  | ||||||
| extern char **environ; | extern char **environ; | ||||||
|  |  | ||||||
| @@ -1887,7 +1887,7 @@ tnamecmp(const void *p1, const void *p2) | |||||||
| 	const struct tbl *a = *((const struct tbl * const *)p1); | 	const struct tbl *a = *((const struct tbl * const *)p1); | ||||||
| 	const struct tbl *b = *((const struct tbl * const *)p2); | 	const struct tbl *b = *((const struct tbl * const *)p2); | ||||||
|  |  | ||||||
| 	return (strcmp(a->name, b->name)); | 	return (ascstrcmp(a->name, b->name)); | ||||||
| } | } | ||||||
|  |  | ||||||
| struct tbl ** | struct tbl ** | ||||||
|   | |||||||
							
								
								
									
										24
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								misc.c
									
									
									
									
									
								
							| @@ -30,7 +30,7 @@ | |||||||
| #include <grp.h> | #include <grp.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.257 2017/04/21 19:50:08 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.258 2017/04/21 20:06:05 tg Exp $"); | ||||||
|  |  | ||||||
| #define KSH_CHVT_FLAG | #define KSH_CHVT_FLAG | ||||||
| #ifdef MKSH_SMALL | #ifdef MKSH_SMALL | ||||||
| @@ -512,7 +512,7 @@ parse_args(const char **argv, | |||||||
| 		for (i = go.optind; argv[i]; i++) | 		for (i = go.optind; argv[i]; i++) | ||||||
| 			; | 			; | ||||||
| 		qsort(&argv[go.optind], i - go.optind, sizeof(void *), | 		qsort(&argv[go.optind], i - go.optind, sizeof(void *), | ||||||
| 		    xstrcmp); | 		    ascpstrcmp); | ||||||
| 	} | 	} | ||||||
| 	if (arrayset) | 	if (arrayset) | ||||||
| 		go.optind += set_array(array, tobool(arrayset > 0), | 		go.optind += set_array(array, tobool(arrayset > 0), | ||||||
| @@ -661,7 +661,7 @@ gmatchx(const char *s, const char *p, bool isfile) | |||||||
| 	pe = p + strlen(p); | 	pe = p + strlen(p); | ||||||
| 	/* | 	/* | ||||||
| 	 * isfile is false iff no syntax check has been done on | 	 * isfile is false iff no syntax check has been done on | ||||||
| 	 * the pattern. If check fails, just to a strcmp(). | 	 * the pattern. If check fails, just do a strcmp(). | ||||||
| 	 */ | 	 */ | ||||||
| 	if (!isfile && !has_globbing(p, pe)) { | 	if (!isfile && !has_globbing(p, pe)) { | ||||||
| 		size_t len = pe - p + 1; | 		size_t len = pe - p + 1; | ||||||
| @@ -957,9 +957,23 @@ pat_scan(const unsigned char *p, const unsigned char *pe, bool match_sep) | |||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| xstrcmp(const void *p1, const void *p2) | ascstrcmp(const void *s1, const void *s2) | ||||||
| { | { | ||||||
| 	return (strcmp(*(const char * const *)p1, *(const char * const *)p2)); | 	const uint8_t *cp1 = s1, *cp2 = s2; | ||||||
|  |  | ||||||
|  | 	while (*cp1 == *cp2) { | ||||||
|  | 		if (*cp1++ == '\0') | ||||||
|  | 			return (0); | ||||||
|  | 		++cp2; | ||||||
|  | 	} | ||||||
|  | 	return (asc(*cp1) - asc(*cp2)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int | ||||||
|  | ascpstrcmp(const void *pstr1, const void *pstr2) | ||||||
|  | { | ||||||
|  | 	return (ascstrcmp(*(const char * const *)pstr1, | ||||||
|  | 	    *(const char * const *)pstr2)); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Initialise a Getopt structure */ | /* Initialise a Getopt structure */ | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								sh.h
									
									
									
									
									
								
							| @@ -175,7 +175,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef EXTERN | #ifdef EXTERN | ||||||
| __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.812 2017/04/21 19:50:09 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.813 2017/04/21 20:06:06 tg Exp $"); | ||||||
| #endif | #endif | ||||||
| #define MKSH_VERSION "R55 2017/04/20" | #define MKSH_VERSION "R55 2017/04/20" | ||||||
|  |  | ||||||
| @@ -2289,7 +2289,8 @@ int parse_args(const char **, int, bool *); | |||||||
| int getn(const char *, int *); | int getn(const char *, int *); | ||||||
| int gmatchx(const char *, const char *, bool); | int gmatchx(const char *, const char *, bool); | ||||||
| int has_globbing(const char *, const char *) MKSH_A_PURE; | int has_globbing(const char *, const char *) MKSH_A_PURE; | ||||||
| int xstrcmp(const void *, const void *) MKSH_A_PURE; | int ascstrcmp(const void *, const void *) MKSH_A_PURE; | ||||||
|  | int ascpstrcmp(const void *, const void *) MKSH_A_PURE; | ||||||
| void ksh_getopt_reset(Getopt *, int); | void ksh_getopt_reset(Getopt *, int); | ||||||
| int ksh_getopt(const char **, Getopt *, const char *); | int ksh_getopt(const char **, Getopt *, const char *); | ||||||
| void print_value_quoted(struct shf *, const char *); | void print_value_quoted(struct shf *, const char *); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user