oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: b2bab82b4baa99b974ff28f91cd7f671340fd2da
parent: 3fb210fe87f1837fbcad4cfc5628d5e0e7f1071e
author: Tim Sedlmeyer <tim@sedlmeyer.org>
date:   Fri, 28 Sep 2018 15:28:05 -0400
Avoid conflict on systems which have gmatch in libgen, ie Solaris
Mc_test.c4++--
Medit.c2+-
Meval.c10+++++-----
Mexec.c2+-
Mmisc.c2+-
Msh.h2+-
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/c_test.c b/c_test.c
@@ -291,11 +291,11 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
 	 */
 	case TO_STEQL: /* = */
 		if (te->flags & TEF_DBRACKET)
-			return gmatch(opnd1, opnd2, false);
+			return gmatch_(opnd1, opnd2, false);
 		return strcmp(opnd1, opnd2) == 0;
 	case TO_STNEQ: /* != */
 		if (te->flags & TEF_DBRACKET)
-			return !gmatch(opnd1, opnd2, false);
+			return !gmatch_(opnd1, opnd2, false);
 		return strcmp(opnd1, opnd2) != 0;
 	case TO_STLT: /* < */
 		return strcmp(opnd1, opnd2) < 0;
diff --git a/edit.c b/edit.c
@@ -805,7 +805,7 @@ glob_table(const char *pat, XPtrV *wp, struct table *tp)
 	struct tbl *te;
 
 	for (ktwalk(&ts, tp); (te = ktnext(&ts)); ) {
-		if (gmatch(te->name, pat, false))
+		if (gmatch_(te->name, pat, false))
 			XPput(*wp, str_save(te->name, ATEMP));
 	}
 }
diff --git a/eval.c b/eval.c
@@ -910,7 +910,7 @@ trimsub(char *str, char *pat, int how)
 	case '#':		/* shortest at beginning */
 		for (p = str; p <= end; p++) {
 			c = *p; *p = '\0';
-			if (gmatch(str, pat, false)) {
+			if (gmatch_(str, pat, false)) {
 				*p = c;
 				return p;
 			}
@@ -920,7 +920,7 @@ trimsub(char *str, char *pat, int how)
 	case '#'|0x80:	/* longest match at beginning */
 		for (p = end; p >= str; p--) {
 			c = *p; *p = '\0';
-			if (gmatch(str, pat, false)) {
+			if (gmatch_(str, pat, false)) {
 				*p = c;
 				return p;
 			}
@@ -929,13 +929,13 @@ trimsub(char *str, char *pat, int how)
 		break;
 	case '%':		/* shortest match at end */
 		for (p = end; p >= str; p--) {
-			if (gmatch(p, pat, false))
+			if (gmatch_(p, pat, false))
 				return str_nsave(str, p - str, ATEMP);
 		}
 		break;
 	case '%'|0x80:	/* longest match at end */
 		for (p = str; p <= end; p++) {
-			if (gmatch(p, pat, false))
+			if (gmatch_(p, pat, false))
 				return str_nsave(str, p - str, ATEMP);
 		}
 		break;
@@ -1089,7 +1089,7 @@ globit(XString *xs,	/* dest string */
 			    (name[1] == 0 || (name[1] == '.' && name[2] == 0)))
 				continue; /* always ignore . and .. */
 			if ((*name == '.' && *sp != '.') ||
-			    !gmatch(name, sp, true))
+			    !gmatch_(name, sp, true))
 				continue;
 
 			len = strlen(d->d_name) + 1;
diff --git a/exec.c b/exec.c
@@ -348,7 +348,7 @@ execute(struct op *volatile t,
 		for (t = t->left; t != NULL && t->type == TPAT; t = t->right) {
 			for (ap = t->vars; *ap; ap++) {
 				if ((s = evalstr(*ap, DOTILDE|DOPAT)) &&
-				    gmatch(cp, s, false))
+				    gmatch_(cp, s, false))
 					goto Found;
 			}
 		}
diff --git a/misc.c b/misc.c
@@ -483,7 +483,7 @@ bi_getn(const char *as, int *ai)
  */
 
 int
-gmatch(const char *s, const char *p, int isfile)
+gmatch_(const char *s, const char *p, int isfile)
 {
 	const char *se, *pe;
 
diff --git a/sh.h b/sh.h
@@ -537,7 +537,7 @@ void	change_flag(enum sh_flag, int, int);
 int	parse_args(char **, int, int *);
 int	getn(const char *, int *);
 int	bi_getn(const char *, int *);
-int	gmatch(const char *, const char *, int);
+int	gmatch_(const char *, const char *, int);
 int	has_globbing(const char *, const char *);
 const unsigned char *pat_scan(const unsigned char *, const unsigned char *,
     int);