From a1a5922fc65c5b8d5b02ff17d8b27841e2503f4d Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 17 Mar 2011 21:59:30 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20make=20misc.c(gmatch.c):pat=5Fscan(?= =?UTF-8?q?)=20static=20and=20fix=20int=20=E2=86=92=20bool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- misc.c | 18 ++++++++++-------- sh.h | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/misc.c b/misc.c index b078d4e..b5297af 100644 --- a/misc.c +++ b/misc.c @@ -29,11 +29,13 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.154 2011/03/13 01:20:21 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.155 2011/03/17 21:59:28 tg Exp $"); /* type bits for unsigned char */ unsigned char chtypes[UCHAR_MAX + 1]; +static const unsigned char *pat_scan(const unsigned char *, + const unsigned char *, bool); static int do_gmatch(const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *); static const unsigned char *cclass(const unsigned char *, int); @@ -649,7 +651,7 @@ do_gmatch(const unsigned char *s, const unsigned char *se, case 0x80|'+': /* matches zero or more times */ case 0x80|'*': - if (!(prest = pat_scan(p, pe, 0))) + if (!(prest = pat_scan(p, pe, false))) return (0); s--; /* take care of zero matches */ @@ -657,7 +659,7 @@ do_gmatch(const unsigned char *s, const unsigned char *se, do_gmatch(s, se, prest, pe)) return (1); for (psub = p; ; psub = pnext) { - pnext = pat_scan(psub, pe, 1); + pnext = pat_scan(psub, pe, true); for (srest = s; srest <= se; srest++) { if (do_gmatch(s, srest, psub, pnext - 2) && (do_gmatch(srest, se, prest, pe) || @@ -676,7 +678,7 @@ do_gmatch(const unsigned char *s, const unsigned char *se, case 0x80|'@': /* simile for @ */ case 0x80|' ': - if (!(prest = pat_scan(p, pe, 0))) + if (!(prest = pat_scan(p, pe, false))) return (0); s--; /* Take care of zero matches */ @@ -684,7 +686,7 @@ do_gmatch(const unsigned char *s, const unsigned char *se, do_gmatch(s, se, prest, pe)) return (1); for (psub = p; ; psub = pnext) { - pnext = pat_scan(psub, pe, 1); + pnext = pat_scan(psub, pe, true); srest = prest == pe ? se : s; for (; srest <= se; srest++) { if (do_gmatch(s, srest, psub, pnext - 2) && @@ -698,14 +700,14 @@ do_gmatch(const unsigned char *s, const unsigned char *se, /* matches none of the patterns */ case 0x80|'!': - if (!(prest = pat_scan(p, pe, 0))) + if (!(prest = pat_scan(p, pe, false))) return (0); s--; for (srest = s; srest <= se; srest++) { int matched = 0; for (psub = p; ; psub = pnext) { - pnext = pat_scan(psub, pe, 1); + pnext = pat_scan(psub, pe, true); if (do_gmatch(s, srest, psub, pnext - 2)) { matched = 1; @@ -777,7 +779,7 @@ cclass(const unsigned char *p, int sub) /* Look for next ) or | (if match_sep) in *(foo|bar) pattern */ const unsigned char * -pat_scan(const unsigned char *p, const unsigned char *pe, int match_sep) +pat_scan(const unsigned char *p, const unsigned char *pe, bool match_sep) { int nest = 0; diff --git a/sh.h b/sh.h index ce632c5..a6b8750 100644 --- a/sh.h +++ b/sh.h @@ -154,7 +154,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.447 2011/03/17 21:58:38 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.448 2011/03/17 21:59:30 tg Exp $"); #endif #define MKSH_VERSION "R39 2011/03/16" @@ -1691,7 +1691,6 @@ int getn(const char *, int *); int bi_getn(const char *, int *); int gmatchx(const char *, const char *, bool); int has_globbing(const char *, const char *); -const unsigned char *pat_scan(const unsigned char *, const unsigned char *, int); int xstrcmp(const void *, const void *); void ksh_getopt_reset(Getopt *, int); int ksh_getopt(const char **, Getopt *, const char *);