diff --git a/ext/ereg/regex/cclass.h b/ext/ereg/regex/cclass.h index 6227f810b72..df41694b040 100644 --- a/ext/ereg/regex/cclass.h +++ b/ext/ereg/regex/cclass.h @@ -1,8 +1,8 @@ /* character-class table */ static struct cclass { - char *name; - char *chars; - char *multis; + unsigned char *name; + unsigned char *chars; + unsigned char *multis; } cclasses[] = { {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""}, {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", diff --git a/ext/ereg/regex/debug.c b/ext/ereg/regex/debug.c index c0feaeb1694..3db93ef293a 100644 --- a/ext/ereg/regex/debug.c +++ b/ext/ereg/regex/debug.c @@ -124,9 +124,9 @@ FILE *d; break; case OCHAR: if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL) - fprintf(d, "\\%c", (char)opnd); + fprintf(d, "\\%c", (unsigned char)opnd); else - fprintf(d, "%s", regchar((char)opnd)); + fprintf(d, "%s", regchar((unsigned char)opnd)); break; case OBOL: fprintf(d, "^"); @@ -228,11 +228,11 @@ FILE *d; - regchar - make a character printable == static char *regchar(int ch); */ -static char * /* -> representation */ +static unsigned char * /* -> representation */ regchar(ch) int ch; { - static char buf[10]; + static unsigned char buf[10]; if (isprint(ch) || ch == ' ') sprintf(buf, "%c", ch); diff --git a/ext/ereg/regex/engine.c b/ext/ereg/regex/engine.c index 0b88dcf1ed8..c4bdc8079f0 100644 --- a/ext/ereg/regex/engine.c +++ b/ext/ereg/regex/engine.c @@ -33,11 +33,11 @@ struct match { struct re_guts *g; int eflags; regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ - char *offp; /* offsets work from here */ - char *beginp; /* start of string -- virtual NUL precedes */ - char *endp; /* end of string -- virtual NUL here */ - char *coldp; /* can be no match starting before here */ - char **lastpos; /* [nplus+1] */ + unsigned char *offp; /* offsets work from here */ + unsigned char *beginp; /* start of string -- virtual NUL precedes */ + unsigned char *endp; /* end of string -- virtual NUL here */ + unsigned char *coldp; /* can be no match starting before here */ + unsigned char **lastpos; /* [nplus+1] */ STATEVARS; states st; /* current states */ states fresh; /* states for a fresh start */ @@ -65,20 +65,20 @@ struct match { static int /* 0 success, REG_NOMATCH failure */ matcher(g, string, nmatch, pmatch, eflags) register struct re_guts *g; -char *string; +unsigned char *string; size_t nmatch; regmatch_t pmatch[]; int eflags; { - register char *endp; + register unsigned char *endp; register size_t i; struct match mv; register struct match *m = &mv; - register char *dp; + register unsigned char *dp; const register sopno gf = g->firststate+1; /* +1 for OEND */ const register sopno gl = g->laststate; - char *start; - char *stop; + unsigned char *start; + unsigned char *stop; /* simplify the situation where possible */ if (g->cflags®_NOSUB) @@ -156,10 +156,10 @@ int eflags; dp = dissect(m, m->coldp, endp, gf, gl); } else { if (g->nplus > 0 && m->lastpos == NULL) - m->lastpos = (char **)malloc((g->nplus+1) * - sizeof(char *)); + m->lastpos = (unsigned char **)malloc((g->nplus+1) * + sizeof(unsigned char *)); if (g->nplus > 0 && m->lastpos == NULL) { - free(m->pmatch); + free((char *)m->pmatch); STATETEARDOWN(m); return(REG_ESPACE); } @@ -225,30 +225,30 @@ int eflags; /* - dissect - figure out what matched what, no back references - == static char *dissect(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst); + == static unsigned char *dissect(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst); */ -static char * /* == stop (success) always */ +static unsigned char * /* == stop (success) always */ dissect(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { register int i; register sopno ss; /* start sop of current subRE */ register sopno es; /* end sop of current subRE */ - register char *sp; /* start of string matched by it */ - register char *stp; /* string matched by it cannot pass here */ - register char *rest; /* start of rest of string */ - register char *tail; /* string unmatched by rest of RE */ + register unsigned char *sp; /* start of string matched by it */ + register unsigned char *stp; /* string matched by it cannot pass here */ + register unsigned char *rest; /* start of rest of string */ + register unsigned char *tail; /* string unmatched by rest of RE */ register sopno ssub; /* start sop of subsubRE */ register sopno esub; /* end sop of subsubRE */ - register char *ssp; /* start of string matched by subsubRE */ - register char *sep; /* end of string matched by subsubRE */ - register char *oldssp; /* previous ssp */ - register char *dp; + register unsigned char *ssp; /* start of string matched by subsubRE */ + register unsigned char *sep; /* end of string matched by subsubRE */ + register unsigned char *oldssp; /* previous ssp */ + register unsigned char *dp; AT("diss", start, stop, startst, stopst); sp = start; @@ -413,25 +413,25 @@ sopno stopst; /* - backref - figure out what matched what, figuring in back references - == static char *backref(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst, sopno lev); + == static unsigned char *backref(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst, sopno lev); */ -static char * /* == stop (success) or NULL (failure) */ +static unsigned char * /* == stop (success) or NULL (failure) */ backref(m, start, stop, startst, stopst, lev) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; sopno lev; /* PLUS nesting level */ { register int i; register sopno ss; /* start sop of current subRE */ - register char *sp; /* start of string matched by it */ + register unsigned char *sp; /* start of string matched by it */ register sopno ssub; /* start sop of subsubRE */ register sopno esub; /* end sop of subsubRE */ - register char *ssp; /* start of string matched by subsubRE */ - register char *dp; + register unsigned char *ssp; /* start of string matched by subsubRE */ + register unsigned char *dp; register size_t len; register int hard; register sop s; @@ -446,7 +446,7 @@ sopno lev; /* PLUS nesting level */ for (ss = startst; !hard && ss < stopst; ss++) switch (OP(s = m->g->strip[ss])) { case OCHAR: - if (sp == stop || *sp++ != (char)OPND(s)) + if (sp == stop || *sp++ != (unsigned char)OPND(s)) return(NULL); break; case OANY: @@ -613,31 +613,31 @@ sopno lev; /* PLUS nesting level */ /* "can't happen" */ assert(nope); /* NOTREACHED */ - return((char *)NULL); /* dummy */ + return((unsigned char *)NULL); /* dummy */ } /* - fast - step through the string at top speed - == static char *fast(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst); + == static unsigned char *fast(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst); */ -static char * /* where tentative match ended, or NULL */ +static unsigned char * /* where tentative match ended, or NULL */ fast(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { register states st = m->st; register states fresh = m->fresh; register states tmp = m->tmp; - register char *p = start; + register unsigned char *p = start; register int c = (start == m->beginp) ? OUT : *(start-1); register int lastc; /* previous c */ register int flagch; register int i; - register char *coldp; /* last p after which no match was underway */ + register unsigned char *coldp; /* last p after which no match was underway */ CLEAR(st); SET1(st, startst); @@ -709,26 +709,26 @@ sopno stopst; /* - slow - step through the string more deliberately - == static char *slow(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst); + == static unsigned char *slow(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst); */ -static char * /* where it ended */ +static unsigned char * /* where it ended */ slow(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { register states st = m->st; register states empty = m->empty; register states tmp = m->tmp; - register char *p = start; + register unsigned char *p = start; register int c = (start == m->beginp) ? OUT : *(start-1); register int lastc; /* previous c */ register int flagch; register int i; - register char *matchp; /* last p at which a match ended */ + register unsigned char *matchp; /* last p at which a match ended */ AT("slow", start, stop, startst, stopst); CLEAR(st); @@ -805,8 +805,8 @@ sopno stopst; == #define BOW (BOL+4) == #define EOW (BOL+5) == #define CODEMAX (BOL+5) // highest code used - == #define NONCHAR(c) ((c) > CHAR_MAX) - == #define NNONCHAR (CODEMAX-CHAR_MAX) + == #define NONCHAR(c) ((c) > UCHAR_MAX) + == #define NNONCHAR (CODEMAX-UCHAR_MAX) */ static states step(g, start, stop, bef, ch, aft) @@ -832,8 +832,8 @@ register states aft; /* states already known reachable after */ break; case OCHAR: /* only characters can match */ - assert(!NONCHAR(ch) || ch != (char)OPND(s)); - if (ch == (char)OPND(s)) + assert(!NONCHAR(ch) || ch != (unsigned char)OPND(s)); + if (ch == (unsigned char)OPND(s)) FWD(aft, bef, 1); break; case OBOL: @@ -926,14 +926,14 @@ register states aft; /* states already known reachable after */ /* - print - print a set of states == #ifdef REDEBUG - == static void print(struct match *m, char *caption, states st, \ + == static void print(struct match *m, unsigned char *caption, states st, \ == int ch, FILE *d); == #endif */ static void print(m, caption, st, ch, d) struct match *m; -char *caption; +unsigned char *caption; states st; int ch; FILE *d; @@ -959,16 +959,16 @@ FILE *d; /* - at - print current situation == #ifdef REDEBUG - == static void at(struct match *m, char *title, char *start, char *stop, \ + == static void at(struct match *m, unsigned char *title, unsigned char *start, unsigned char *stop, \ == sopno startst, sopno stopst); == #endif */ static void at(m, title, start, stop, startst, stopst) struct match *m; -char *title; -char *start; -char *stop; +unsigned char *title; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { @@ -985,7 +985,7 @@ sopno stopst; /* - pchar - make a character printable == #ifdef REDEBUG - == static char *pchar(int ch); + == static unsigned char *pchar(int ch); == #endif * * Is this identical to regchar() over in debug.c? Well, yes. But a @@ -993,11 +993,11 @@ sopno stopst; * a matching debug.o, and this is convenient. It all disappears in * the non-debug compilation anyway, so it doesn't matter much. */ -static char * /* -> representation */ +static unsigned char * /* -> representation */ pchar(ch) int ch; { - static char pbuf[10]; + static unsigned char pbuf[10]; if (isprint(ch) || ch == ' ') sprintf(pbuf, "%c", ch); diff --git a/ext/ereg/regex/engine.ih b/ext/ereg/regex/engine.ih index cc98334e752..9a301838bcd 100644 --- a/ext/ereg/regex/engine.ih +++ b/ext/ereg/regex/engine.ih @@ -4,11 +4,11 @@ extern "C" { #endif /* === engine.c === */ -static int matcher(register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags); -static char *dissect(register struct match *m, char *start, char *stop, sopno startst, sopno stopst); -static char *backref(register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev); -static char *fast(register struct match *m, char *start, char *stop, sopno startst, sopno stopst); -static char *slow(register struct match *m, char *start, char *stop, sopno startst, sopno stopst); +static int matcher(register struct re_guts *g, unsigned char *string, size_t nmatch, regmatch_t pmatch[], int eflags); +static unsigned char *dissect(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); +static unsigned char *backref(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst, sopno lev); +static unsigned char *fast(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); +static unsigned char *slow(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); static states step(register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft); #define BOL (OUT+1) #define EOL (BOL+1) @@ -17,16 +17,16 @@ static states step(register struct re_guts *g, sopno start, sopno stop, register #define BOW (BOL+4) #define EOW (BOL+5) #define CODEMAX (BOL+5) /* highest code used */ -#define NONCHAR(c) ((c) > CHAR_MAX) -#define NNONCHAR (CODEMAX-CHAR_MAX) +#define NONCHAR(c) ((c) > UCHAR_MAX) +#define NNONCHAR (CODEMAX-UCHAR_MAX) #ifdef REDEBUG -static void print(struct match *m, char *caption, states st, int ch, FILE *d); +static void print(struct match *m, unsigned char *caption, states st, int ch, FILE *d); #endif #ifdef REDEBUG -static void at(struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst); +static void at(struct match *m, unsigned char *title, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); #endif #ifdef REDEBUG -static char *pchar(int ch); +static unsigned char *pchar(int ch); #endif #ifdef __cplusplus diff --git a/ext/ereg/regex/regcomp.c b/ext/ereg/regex/regcomp.c index 0b939461bd7..ec034d4c4ce 100644 --- a/ext/ereg/regex/regcomp.c +++ b/ext/ereg/regex/regcomp.c @@ -19,8 +19,8 @@ * other clumsinesses */ struct parse { - char *next; /* next character in RE */ - char *end; /* end of string (-> NUL normally) */ + unsigned char *next; /* next character in RE */ + unsigned char *end; /* end of string (-> NUL normally) */ int error; /* has an error been seen? */ sop *strip; /* malloced strip */ sopno ssize; /* malloced strip size (allocated) */ @@ -34,7 +34,7 @@ struct parse { #include "regcomp.ih" -static char nuls[10]; /* place to point scanner in event of error */ +static unsigned char nuls[10]; /* place to point scanner in event of error */ /* * macros for use with parse structure @@ -127,7 +127,7 @@ int cflags; /* set things up */ p->g = g; - p->next = (char *)pattern; /* convenience; we do not modify it */ + p->next = (unsigned char *)pattern; /* convenience; we do not modify it */ p->end = p->next + len; p->error = 0; p->ncsalloc = 0; @@ -147,7 +147,7 @@ int cflags; g->mlen = 0; g->nsub = 0; g->ncategories = 1; /* category 0 is "everything else" */ - g->categories = &g->catspace[-(CHAR_MIN)]; + g->categories = &g->catspace[0]; (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); g->backrefs = 0; @@ -193,7 +193,7 @@ p_ere(p, stop) register struct parse *p; int stop; /* character this ERE should end at */ { - register char c; + register unsigned char c; register sopno prevback = 0; register sopno prevfwd = 0; register sopno conc; @@ -238,7 +238,7 @@ static void p_ere_exp(p) register struct parse *p; { - register char c; + register unsigned char c; register sopno pos; register int count; register int count2; @@ -518,7 +518,7 @@ int starordinary; /* is a leading * an ordinary character? */ REQUIRE(starordinary, REG_BADRPT); /* FALLTHROUGH */ default: - ordinary(p, (char)c); /* takes off BACKSL, if any */ + ordinary(p, (unsigned char)c); /* takes off BACKSL, if any */ break; } @@ -657,8 +657,8 @@ p_b_term(p, cs) register struct parse *p; register cset *cs; { - register char c; - register char start, finish; + register unsigned char c; + register unsigned char start, finish; register int i; /* classify what we've got */ @@ -723,11 +723,11 @@ p_b_cclass(p, cs) register struct parse *p; register cset *cs; { - register char *sp = p->next; + register unsigned char *sp = p->next; register struct cclass *cp; register size_t len; - register char *u; - register char c; + register unsigned char *u; + register unsigned char c; while (MORE() && isalpha(PEEK())) NEXT(); @@ -759,7 +759,7 @@ p_b_eclass(p, cs) register struct parse *p; register cset *cs; { - register char c; + register unsigned char c; c = p_b_coll_elem(p, '='); CHadd(cs, c); @@ -769,11 +769,11 @@ register cset *cs; - p_b_symbol - parse a character or [..]ed multicharacter collating symbol == static char p_b_symbol(register struct parse *p); */ -static char /* value of symbol */ +static unsigned char /* value of symbol */ p_b_symbol(p) register struct parse *p; { - register char value; + register unsigned char value; REQUIRE(MORE(), REG_EBRACK); if (!EATTWO('[', '.')) @@ -789,12 +789,12 @@ register struct parse *p; - p_b_coll_elem - parse a collating-element name and look it up == static char p_b_coll_elem(register struct parse *p, int endc); */ -static char /* value of collating element */ +static unsigned char /* value of collating element */ p_b_coll_elem(p, endc) register struct parse *p; int endc; /* name ended by endc,']' */ { - register char *sp = p->next; + register unsigned char *sp = p->next; register struct cname *cp; register int len; @@ -818,7 +818,7 @@ int endc; /* name ended by endc,']' */ - othercase - return the case counterpart of an alphabetic == static char othercase(int ch); */ -static char /* if no counterpart, return ch */ +static unsigned char /* if no counterpart, return ch */ othercase(ch) int ch; { @@ -842,9 +842,9 @@ bothcases(p, ch) register struct parse *p; int ch; { - register char *oldnext = p->next; - register char *oldend = p->end; - char bracket[3]; + register unsigned char *oldnext = p->next; + register unsigned char *oldend = p->end; + unsigned char bracket[3]; assert(othercase(ch) != ch); /* p_bracket() would recurse */ p->next = bracket; @@ -888,9 +888,9 @@ static void nonnewline(p) register struct parse *p; { - register char *oldnext = p->next; - register char *oldend = p->end; - char bracket[4]; + register unsigned char *oldnext = p->next; + register unsigned char *oldend = p->end; + unsigned char bracket[4]; p->next = bracket; p->end = bracket+3; @@ -1015,19 +1015,19 @@ register struct parse *p; if (p->g->sets == NULL) p->g->sets = (cset *)malloc(nc * sizeof(cset)); else - p->g->sets = (cset *)realloc((char *)p->g->sets, + p->g->sets = (cset *)realloc((unsigned char *)p->g->sets, nc * sizeof(cset)); if (p->g->setbits == NULL) p->g->setbits = (uch *)malloc(nbytes); else { - p->g->setbits = (uch *)realloc((char *)p->g->setbits, + p->g->setbits = (uch *)realloc((unsigned char *)p->g->setbits, nbytes); /* xxx this isn't right if setbits is now NULL */ for (i = 0; i < no; i++) p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); } if (p->g->sets != NULL && p->g->setbits != NULL) - (void) memset((char *)p->g->setbits + (nbytes - css), + (void) memset((unsigned char *)p->g->setbits + (nbytes - css), 0, css); else { no = 0; @@ -1120,7 +1120,7 @@ register cset *cs; for (i = 0; i < css; i++) if (CHIN(cs, i)) - return((char)i); + return((unsigned char)i); assert(never); return(0); /* arbitrary */ } @@ -1153,7 +1153,7 @@ static void mcadd(p, cs, cp) register struct parse *p; register cset *cs; -register char *cp; +register unsigned char *cp; { register size_t oldend = cs->smultis; @@ -1174,14 +1174,14 @@ register char *cp; #if 0 /* - mcsub - subtract a collating element from a cset - == static void mcsub(register cset *cs, register char *cp); + == static void mcsub(register cset *cs, register unsigned char *cp); */ static void mcsub(cs, cp) -register cset *cs; -register char *cp; +register unsigned cset *cs; +register unsigned char *cp; { - register char *fp = mcfind(cs, cp); + register unsigned char *fp = mcfind(cs, cp); register size_t len = strlen(fp); assert(fp != NULL); @@ -1201,12 +1201,12 @@ register char *cp; /* - mcin - is a collating element in a cset? - == static int mcin(register cset *cs, register char *cp); + == static int mcin(register cset *cs, register unsigned char *cp); */ static int mcin(cs, cp) register cset *cs; -register char *cp; +register unsigned char *cp; { return(mcfind(cs, cp) != NULL); } @@ -1214,14 +1214,14 @@ register char *cp; /* - mcfind - find a collating element in a cset - == static char *mcfind(register cset *cs, register char *cp); + == static unsigned char *mcfind(register cset *cs, register unsigned char *cp); */ -static char * +static unsigned char * mcfind(cs, cp) register cset *cs; -register char *cp; +register unsigned char *cp; { - register char *p; + register unsigned char *p; if (cs->multis == NULL) return(NULL); @@ -1322,11 +1322,11 @@ register struct re_guts *g; if (p->error != 0) return; - for (c = CHAR_MIN; c <= CHAR_MAX; c++) + for (c = 0; c <= UCHAR_MAX; c++) if (cats[c] == 0 && isinsets(g, c)) { cat = g->ncategories++; cats[c] = cat; - for (c2 = c+1; c2 <= CHAR_MAX; c2++) + for (c2 = c+1; c2 <= UCHAR_MAX; c2++) if (cats[c2] == 0 && samesets(g, c, c2)) cats[c2] = cat; } @@ -1477,7 +1477,7 @@ register struct parse *p; register struct re_guts *g; { g->nstates = p->slen; - g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); + g->strip = (sop *)realloc((unsigned char *)p->strip, p->slen * sizeof(sop)); if (g->strip == NULL) { SETERROR(REG_ESPACE); g->strip = p->strip; @@ -1504,7 +1504,7 @@ register struct re_guts *g; register sop *newstart = NULL; register sopno newlen; register sop s; - register char *cp; + register unsigned char *cp; register sopno i; /* avoid making error situations worse */ @@ -1565,7 +1565,7 @@ register struct re_guts *g; while (OP(s = *scan++) != OCHAR) continue; assert(cp < g->must + g->mlen); - *cp++ = (char)OPND(s); + *cp++ = (unsigned char)OPND(s); } assert(cp == g->must + g->mlen); *cp++ = '\0'; /* just on general principles */ diff --git a/ext/ereg/regex/regcomp.ih b/ext/ereg/regex/regcomp.ih index 6efafebf602..c93d32e51d3 100644 --- a/ext/ereg/regex/regcomp.ih +++ b/ext/ereg/regex/regcomp.ih @@ -14,9 +14,9 @@ static void p_bracket(register struct parse *p); static void p_b_term(register struct parse *p, register cset *cs); static void p_b_cclass(register struct parse *p, register cset *cs); static void p_b_eclass(register struct parse *p, register cset *cs); -static char p_b_symbol(register struct parse *p); -static char p_b_coll_elem(register struct parse *p, int endc); -static char othercase(int ch); +static unsigned char p_b_symbol(register struct parse *p); +static unsigned char p_b_coll_elem(register struct parse *p, int endc); +static unsigned char othercase(int ch); static void bothcases(register struct parse *p, int ch); static void ordinary(register struct parse *p, register int ch); static void nonnewline(register struct parse *p); @@ -27,11 +27,11 @@ static void freeset(register struct parse *p, register cset *cs); static int freezeset(register struct parse *p, register cset *cs); static int firstch(register struct parse *p, register cset *cs); static int nch(register struct parse *p, register cset *cs); -static void mcadd(register struct parse *p, register cset *cs, register char *cp); +static void mcadd(register struct parse *p, register cset *cs, register unsigned char *cp); #if 0 -static void mcsub(register cset *cs, register char *cp); -static int mcin(register cset *cs, register char *cp); -static char *mcfind(register cset *cs, register char *cp); +static void mcsub(register cset *cs, register unsigned char *cp); +static int mcin(register cset *cs, register unsigned char *cp); +static unsigned char *mcfind(register cset *cs, register unsigned char *cp); #endif static void mcinvert(register struct parse *p, register cset *cs); static void mccase(register struct parse *p, register cset *cs); diff --git a/ext/ereg/regex/regex2.h b/ext/ereg/regex/regex2.h index 7cd39a59ae5..4996f96ecd3 100644 --- a/ext/ereg/regex/regex2.h +++ b/ext/ereg/regex/regex2.h @@ -10,7 +10,7 @@ = typedef struct { = int re_magic; = size_t re_nsub; // number of parenthesized subexpressions - = const char *re_endp; // end pointer for REG_PEND + = const unsigned char *re_endp; // end pointer for REG_PEND = struct re_guts *re_g; // none of your business :-) = } regex_t; = typedef struct { @@ -90,7 +90,7 @@ typedef struct { uch mask; /* bit within array */ uch hash; /* hash code */ size_t smultis; - char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ + unsigned char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ } cset; /* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ #define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) @@ -125,8 +125,8 @@ struct re_guts { int nbol; /* number of ^ used */ int neol; /* number of $ used */ int ncategories; /* how many character categories */ - cat_t *categories; /* ->catspace[-CHAR_MIN] */ - char *must; /* match must contain this string */ + cat_t *categories; /* ->catspace[-UCHAR_MIN] */ + unsigned char *must; /* match must contain this string */ int mlen; /* length of must */ size_t nsub; /* copy of re_nsub */ int backrefs; /* does it use back references? */ @@ -136,5 +136,5 @@ struct re_guts { }; /* misc utilities */ -#define OUT (CHAR_MAX+1) /* a non-character value */ +#define OUT (UCHAR_MAX+1) /* a non-character value */ #define ISWORD(c) (isalnum(c) || (c) == '_') diff --git a/ext/ereg/regex/regexec.c b/ext/ereg/regex/regexec.c index 7888d02368c..c8cb8fdf564 100644 --- a/ext/ereg/regex/regexec.c +++ b/ext/ereg/regex/regexec.c @@ -67,14 +67,14 @@ static int nope = 0; /* for use in asserts; shuts lint up */ #undef SNAMES /* macros for manipulating states, large version */ -#define states char * +#define states unsigned char * #define CLEAR(v) memset(v, 0, m->g->nstates) #define SET0(v, n) ((v)[n] = 0) #define SET1(v, n) ((v)[n] = 1) #define ISSET(v, n) ((v)[n]) #define ASSIGN(d, s) memcpy(d, s, m->g->nstates) #define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) -#define STATEVARS int vn; char *space +#define STATEVARS int vn; unsigned char *space #define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ if ((m)->space == NULL) return(REG_ESPACE); \ (m)->vn = 0; } @@ -132,7 +132,7 @@ int eflags; eflags = GOODFLAGS(eflags); if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) - return(smatcher(g, (char *)string, nmatch, pmatch, eflags)); + return(smatcher(g, (unsigned char *)string, nmatch, pmatch, eflags)); else - return(lmatcher(g, (char *)string, nmatch, pmatch, eflags)); + return(lmatcher(g, (unsigned char *)string, nmatch, pmatch, eflags)); } diff --git a/regex/cclass.h b/regex/cclass.h index 6227f810b72..df41694b040 100644 --- a/regex/cclass.h +++ b/regex/cclass.h @@ -1,8 +1,8 @@ /* character-class table */ static struct cclass { - char *name; - char *chars; - char *multis; + unsigned char *name; + unsigned char *chars; + unsigned char *multis; } cclasses[] = { {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""}, {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", diff --git a/regex/debug.c b/regex/debug.c index c0feaeb1694..3db93ef293a 100644 --- a/regex/debug.c +++ b/regex/debug.c @@ -124,9 +124,9 @@ FILE *d; break; case OCHAR: if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL) - fprintf(d, "\\%c", (char)opnd); + fprintf(d, "\\%c", (unsigned char)opnd); else - fprintf(d, "%s", regchar((char)opnd)); + fprintf(d, "%s", regchar((unsigned char)opnd)); break; case OBOL: fprintf(d, "^"); @@ -228,11 +228,11 @@ FILE *d; - regchar - make a character printable == static char *regchar(int ch); */ -static char * /* -> representation */ +static unsigned char * /* -> representation */ regchar(ch) int ch; { - static char buf[10]; + static unsigned char buf[10]; if (isprint(ch) || ch == ' ') sprintf(buf, "%c", ch); diff --git a/regex/engine.c b/regex/engine.c index 0b88dcf1ed8..c4bdc8079f0 100644 --- a/regex/engine.c +++ b/regex/engine.c @@ -33,11 +33,11 @@ struct match { struct re_guts *g; int eflags; regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ - char *offp; /* offsets work from here */ - char *beginp; /* start of string -- virtual NUL precedes */ - char *endp; /* end of string -- virtual NUL here */ - char *coldp; /* can be no match starting before here */ - char **lastpos; /* [nplus+1] */ + unsigned char *offp; /* offsets work from here */ + unsigned char *beginp; /* start of string -- virtual NUL precedes */ + unsigned char *endp; /* end of string -- virtual NUL here */ + unsigned char *coldp; /* can be no match starting before here */ + unsigned char **lastpos; /* [nplus+1] */ STATEVARS; states st; /* current states */ states fresh; /* states for a fresh start */ @@ -65,20 +65,20 @@ struct match { static int /* 0 success, REG_NOMATCH failure */ matcher(g, string, nmatch, pmatch, eflags) register struct re_guts *g; -char *string; +unsigned char *string; size_t nmatch; regmatch_t pmatch[]; int eflags; { - register char *endp; + register unsigned char *endp; register size_t i; struct match mv; register struct match *m = &mv; - register char *dp; + register unsigned char *dp; const register sopno gf = g->firststate+1; /* +1 for OEND */ const register sopno gl = g->laststate; - char *start; - char *stop; + unsigned char *start; + unsigned char *stop; /* simplify the situation where possible */ if (g->cflags®_NOSUB) @@ -156,10 +156,10 @@ int eflags; dp = dissect(m, m->coldp, endp, gf, gl); } else { if (g->nplus > 0 && m->lastpos == NULL) - m->lastpos = (char **)malloc((g->nplus+1) * - sizeof(char *)); + m->lastpos = (unsigned char **)malloc((g->nplus+1) * + sizeof(unsigned char *)); if (g->nplus > 0 && m->lastpos == NULL) { - free(m->pmatch); + free((char *)m->pmatch); STATETEARDOWN(m); return(REG_ESPACE); } @@ -225,30 +225,30 @@ int eflags; /* - dissect - figure out what matched what, no back references - == static char *dissect(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst); + == static unsigned char *dissect(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst); */ -static char * /* == stop (success) always */ +static unsigned char * /* == stop (success) always */ dissect(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { register int i; register sopno ss; /* start sop of current subRE */ register sopno es; /* end sop of current subRE */ - register char *sp; /* start of string matched by it */ - register char *stp; /* string matched by it cannot pass here */ - register char *rest; /* start of rest of string */ - register char *tail; /* string unmatched by rest of RE */ + register unsigned char *sp; /* start of string matched by it */ + register unsigned char *stp; /* string matched by it cannot pass here */ + register unsigned char *rest; /* start of rest of string */ + register unsigned char *tail; /* string unmatched by rest of RE */ register sopno ssub; /* start sop of subsubRE */ register sopno esub; /* end sop of subsubRE */ - register char *ssp; /* start of string matched by subsubRE */ - register char *sep; /* end of string matched by subsubRE */ - register char *oldssp; /* previous ssp */ - register char *dp; + register unsigned char *ssp; /* start of string matched by subsubRE */ + register unsigned char *sep; /* end of string matched by subsubRE */ + register unsigned char *oldssp; /* previous ssp */ + register unsigned char *dp; AT("diss", start, stop, startst, stopst); sp = start; @@ -413,25 +413,25 @@ sopno stopst; /* - backref - figure out what matched what, figuring in back references - == static char *backref(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst, sopno lev); + == static unsigned char *backref(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst, sopno lev); */ -static char * /* == stop (success) or NULL (failure) */ +static unsigned char * /* == stop (success) or NULL (failure) */ backref(m, start, stop, startst, stopst, lev) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; sopno lev; /* PLUS nesting level */ { register int i; register sopno ss; /* start sop of current subRE */ - register char *sp; /* start of string matched by it */ + register unsigned char *sp; /* start of string matched by it */ register sopno ssub; /* start sop of subsubRE */ register sopno esub; /* end sop of subsubRE */ - register char *ssp; /* start of string matched by subsubRE */ - register char *dp; + register unsigned char *ssp; /* start of string matched by subsubRE */ + register unsigned char *dp; register size_t len; register int hard; register sop s; @@ -446,7 +446,7 @@ sopno lev; /* PLUS nesting level */ for (ss = startst; !hard && ss < stopst; ss++) switch (OP(s = m->g->strip[ss])) { case OCHAR: - if (sp == stop || *sp++ != (char)OPND(s)) + if (sp == stop || *sp++ != (unsigned char)OPND(s)) return(NULL); break; case OANY: @@ -613,31 +613,31 @@ sopno lev; /* PLUS nesting level */ /* "can't happen" */ assert(nope); /* NOTREACHED */ - return((char *)NULL); /* dummy */ + return((unsigned char *)NULL); /* dummy */ } /* - fast - step through the string at top speed - == static char *fast(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst); + == static unsigned char *fast(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst); */ -static char * /* where tentative match ended, or NULL */ +static unsigned char * /* where tentative match ended, or NULL */ fast(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { register states st = m->st; register states fresh = m->fresh; register states tmp = m->tmp; - register char *p = start; + register unsigned char *p = start; register int c = (start == m->beginp) ? OUT : *(start-1); register int lastc; /* previous c */ register int flagch; register int i; - register char *coldp; /* last p after which no match was underway */ + register unsigned char *coldp; /* last p after which no match was underway */ CLEAR(st); SET1(st, startst); @@ -709,26 +709,26 @@ sopno stopst; /* - slow - step through the string more deliberately - == static char *slow(register struct match *m, char *start, \ - == char *stop, sopno startst, sopno stopst); + == static unsigned char *slow(register struct match *m, unsigned char *start, \ + == unsigned char *stop, sopno startst, sopno stopst); */ -static char * /* where it ended */ +static unsigned char * /* where it ended */ slow(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { register states st = m->st; register states empty = m->empty; register states tmp = m->tmp; - register char *p = start; + register unsigned char *p = start; register int c = (start == m->beginp) ? OUT : *(start-1); register int lastc; /* previous c */ register int flagch; register int i; - register char *matchp; /* last p at which a match ended */ + register unsigned char *matchp; /* last p at which a match ended */ AT("slow", start, stop, startst, stopst); CLEAR(st); @@ -805,8 +805,8 @@ sopno stopst; == #define BOW (BOL+4) == #define EOW (BOL+5) == #define CODEMAX (BOL+5) // highest code used - == #define NONCHAR(c) ((c) > CHAR_MAX) - == #define NNONCHAR (CODEMAX-CHAR_MAX) + == #define NONCHAR(c) ((c) > UCHAR_MAX) + == #define NNONCHAR (CODEMAX-UCHAR_MAX) */ static states step(g, start, stop, bef, ch, aft) @@ -832,8 +832,8 @@ register states aft; /* states already known reachable after */ break; case OCHAR: /* only characters can match */ - assert(!NONCHAR(ch) || ch != (char)OPND(s)); - if (ch == (char)OPND(s)) + assert(!NONCHAR(ch) || ch != (unsigned char)OPND(s)); + if (ch == (unsigned char)OPND(s)) FWD(aft, bef, 1); break; case OBOL: @@ -926,14 +926,14 @@ register states aft; /* states already known reachable after */ /* - print - print a set of states == #ifdef REDEBUG - == static void print(struct match *m, char *caption, states st, \ + == static void print(struct match *m, unsigned char *caption, states st, \ == int ch, FILE *d); == #endif */ static void print(m, caption, st, ch, d) struct match *m; -char *caption; +unsigned char *caption; states st; int ch; FILE *d; @@ -959,16 +959,16 @@ FILE *d; /* - at - print current situation == #ifdef REDEBUG - == static void at(struct match *m, char *title, char *start, char *stop, \ + == static void at(struct match *m, unsigned char *title, unsigned char *start, unsigned char *stop, \ == sopno startst, sopno stopst); == #endif */ static void at(m, title, start, stop, startst, stopst) struct match *m; -char *title; -char *start; -char *stop; +unsigned char *title; +unsigned char *start; +unsigned char *stop; sopno startst; sopno stopst; { @@ -985,7 +985,7 @@ sopno stopst; /* - pchar - make a character printable == #ifdef REDEBUG - == static char *pchar(int ch); + == static unsigned char *pchar(int ch); == #endif * * Is this identical to regchar() over in debug.c? Well, yes. But a @@ -993,11 +993,11 @@ sopno stopst; * a matching debug.o, and this is convenient. It all disappears in * the non-debug compilation anyway, so it doesn't matter much. */ -static char * /* -> representation */ +static unsigned char * /* -> representation */ pchar(ch) int ch; { - static char pbuf[10]; + static unsigned char pbuf[10]; if (isprint(ch) || ch == ' ') sprintf(pbuf, "%c", ch); diff --git a/regex/engine.ih b/regex/engine.ih index cc98334e752..9a301838bcd 100644 --- a/regex/engine.ih +++ b/regex/engine.ih @@ -4,11 +4,11 @@ extern "C" { #endif /* === engine.c === */ -static int matcher(register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags); -static char *dissect(register struct match *m, char *start, char *stop, sopno startst, sopno stopst); -static char *backref(register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev); -static char *fast(register struct match *m, char *start, char *stop, sopno startst, sopno stopst); -static char *slow(register struct match *m, char *start, char *stop, sopno startst, sopno stopst); +static int matcher(register struct re_guts *g, unsigned char *string, size_t nmatch, regmatch_t pmatch[], int eflags); +static unsigned char *dissect(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); +static unsigned char *backref(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst, sopno lev); +static unsigned char *fast(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); +static unsigned char *slow(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); static states step(register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft); #define BOL (OUT+1) #define EOL (BOL+1) @@ -17,16 +17,16 @@ static states step(register struct re_guts *g, sopno start, sopno stop, register #define BOW (BOL+4) #define EOW (BOL+5) #define CODEMAX (BOL+5) /* highest code used */ -#define NONCHAR(c) ((c) > CHAR_MAX) -#define NNONCHAR (CODEMAX-CHAR_MAX) +#define NONCHAR(c) ((c) > UCHAR_MAX) +#define NNONCHAR (CODEMAX-UCHAR_MAX) #ifdef REDEBUG -static void print(struct match *m, char *caption, states st, int ch, FILE *d); +static void print(struct match *m, unsigned char *caption, states st, int ch, FILE *d); #endif #ifdef REDEBUG -static void at(struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst); +static void at(struct match *m, unsigned char *title, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); #endif #ifdef REDEBUG -static char *pchar(int ch); +static unsigned char *pchar(int ch); #endif #ifdef __cplusplus diff --git a/regex/regcomp.c b/regex/regcomp.c index 0b939461bd7..ec034d4c4ce 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -19,8 +19,8 @@ * other clumsinesses */ struct parse { - char *next; /* next character in RE */ - char *end; /* end of string (-> NUL normally) */ + unsigned char *next; /* next character in RE */ + unsigned char *end; /* end of string (-> NUL normally) */ int error; /* has an error been seen? */ sop *strip; /* malloced strip */ sopno ssize; /* malloced strip size (allocated) */ @@ -34,7 +34,7 @@ struct parse { #include "regcomp.ih" -static char nuls[10]; /* place to point scanner in event of error */ +static unsigned char nuls[10]; /* place to point scanner in event of error */ /* * macros for use with parse structure @@ -127,7 +127,7 @@ int cflags; /* set things up */ p->g = g; - p->next = (char *)pattern; /* convenience; we do not modify it */ + p->next = (unsigned char *)pattern; /* convenience; we do not modify it */ p->end = p->next + len; p->error = 0; p->ncsalloc = 0; @@ -147,7 +147,7 @@ int cflags; g->mlen = 0; g->nsub = 0; g->ncategories = 1; /* category 0 is "everything else" */ - g->categories = &g->catspace[-(CHAR_MIN)]; + g->categories = &g->catspace[0]; (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); g->backrefs = 0; @@ -193,7 +193,7 @@ p_ere(p, stop) register struct parse *p; int stop; /* character this ERE should end at */ { - register char c; + register unsigned char c; register sopno prevback = 0; register sopno prevfwd = 0; register sopno conc; @@ -238,7 +238,7 @@ static void p_ere_exp(p) register struct parse *p; { - register char c; + register unsigned char c; register sopno pos; register int count; register int count2; @@ -518,7 +518,7 @@ int starordinary; /* is a leading * an ordinary character? */ REQUIRE(starordinary, REG_BADRPT); /* FALLTHROUGH */ default: - ordinary(p, (char)c); /* takes off BACKSL, if any */ + ordinary(p, (unsigned char)c); /* takes off BACKSL, if any */ break; } @@ -657,8 +657,8 @@ p_b_term(p, cs) register struct parse *p; register cset *cs; { - register char c; - register char start, finish; + register unsigned char c; + register unsigned char start, finish; register int i; /* classify what we've got */ @@ -723,11 +723,11 @@ p_b_cclass(p, cs) register struct parse *p; register cset *cs; { - register char *sp = p->next; + register unsigned char *sp = p->next; register struct cclass *cp; register size_t len; - register char *u; - register char c; + register unsigned char *u; + register unsigned char c; while (MORE() && isalpha(PEEK())) NEXT(); @@ -759,7 +759,7 @@ p_b_eclass(p, cs) register struct parse *p; register cset *cs; { - register char c; + register unsigned char c; c = p_b_coll_elem(p, '='); CHadd(cs, c); @@ -769,11 +769,11 @@ register cset *cs; - p_b_symbol - parse a character or [..]ed multicharacter collating symbol == static char p_b_symbol(register struct parse *p); */ -static char /* value of symbol */ +static unsigned char /* value of symbol */ p_b_symbol(p) register struct parse *p; { - register char value; + register unsigned char value; REQUIRE(MORE(), REG_EBRACK); if (!EATTWO('[', '.')) @@ -789,12 +789,12 @@ register struct parse *p; - p_b_coll_elem - parse a collating-element name and look it up == static char p_b_coll_elem(register struct parse *p, int endc); */ -static char /* value of collating element */ +static unsigned char /* value of collating element */ p_b_coll_elem(p, endc) register struct parse *p; int endc; /* name ended by endc,']' */ { - register char *sp = p->next; + register unsigned char *sp = p->next; register struct cname *cp; register int len; @@ -818,7 +818,7 @@ int endc; /* name ended by endc,']' */ - othercase - return the case counterpart of an alphabetic == static char othercase(int ch); */ -static char /* if no counterpart, return ch */ +static unsigned char /* if no counterpart, return ch */ othercase(ch) int ch; { @@ -842,9 +842,9 @@ bothcases(p, ch) register struct parse *p; int ch; { - register char *oldnext = p->next; - register char *oldend = p->end; - char bracket[3]; + register unsigned char *oldnext = p->next; + register unsigned char *oldend = p->end; + unsigned char bracket[3]; assert(othercase(ch) != ch); /* p_bracket() would recurse */ p->next = bracket; @@ -888,9 +888,9 @@ static void nonnewline(p) register struct parse *p; { - register char *oldnext = p->next; - register char *oldend = p->end; - char bracket[4]; + register unsigned char *oldnext = p->next; + register unsigned char *oldend = p->end; + unsigned char bracket[4]; p->next = bracket; p->end = bracket+3; @@ -1015,19 +1015,19 @@ register struct parse *p; if (p->g->sets == NULL) p->g->sets = (cset *)malloc(nc * sizeof(cset)); else - p->g->sets = (cset *)realloc((char *)p->g->sets, + p->g->sets = (cset *)realloc((unsigned char *)p->g->sets, nc * sizeof(cset)); if (p->g->setbits == NULL) p->g->setbits = (uch *)malloc(nbytes); else { - p->g->setbits = (uch *)realloc((char *)p->g->setbits, + p->g->setbits = (uch *)realloc((unsigned char *)p->g->setbits, nbytes); /* xxx this isn't right if setbits is now NULL */ for (i = 0; i < no; i++) p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); } if (p->g->sets != NULL && p->g->setbits != NULL) - (void) memset((char *)p->g->setbits + (nbytes - css), + (void) memset((unsigned char *)p->g->setbits + (nbytes - css), 0, css); else { no = 0; @@ -1120,7 +1120,7 @@ register cset *cs; for (i = 0; i < css; i++) if (CHIN(cs, i)) - return((char)i); + return((unsigned char)i); assert(never); return(0); /* arbitrary */ } @@ -1153,7 +1153,7 @@ static void mcadd(p, cs, cp) register struct parse *p; register cset *cs; -register char *cp; +register unsigned char *cp; { register size_t oldend = cs->smultis; @@ -1174,14 +1174,14 @@ register char *cp; #if 0 /* - mcsub - subtract a collating element from a cset - == static void mcsub(register cset *cs, register char *cp); + == static void mcsub(register cset *cs, register unsigned char *cp); */ static void mcsub(cs, cp) -register cset *cs; -register char *cp; +register unsigned cset *cs; +register unsigned char *cp; { - register char *fp = mcfind(cs, cp); + register unsigned char *fp = mcfind(cs, cp); register size_t len = strlen(fp); assert(fp != NULL); @@ -1201,12 +1201,12 @@ register char *cp; /* - mcin - is a collating element in a cset? - == static int mcin(register cset *cs, register char *cp); + == static int mcin(register cset *cs, register unsigned char *cp); */ static int mcin(cs, cp) register cset *cs; -register char *cp; +register unsigned char *cp; { return(mcfind(cs, cp) != NULL); } @@ -1214,14 +1214,14 @@ register char *cp; /* - mcfind - find a collating element in a cset - == static char *mcfind(register cset *cs, register char *cp); + == static unsigned char *mcfind(register cset *cs, register unsigned char *cp); */ -static char * +static unsigned char * mcfind(cs, cp) register cset *cs; -register char *cp; +register unsigned char *cp; { - register char *p; + register unsigned char *p; if (cs->multis == NULL) return(NULL); @@ -1322,11 +1322,11 @@ register struct re_guts *g; if (p->error != 0) return; - for (c = CHAR_MIN; c <= CHAR_MAX; c++) + for (c = 0; c <= UCHAR_MAX; c++) if (cats[c] == 0 && isinsets(g, c)) { cat = g->ncategories++; cats[c] = cat; - for (c2 = c+1; c2 <= CHAR_MAX; c2++) + for (c2 = c+1; c2 <= UCHAR_MAX; c2++) if (cats[c2] == 0 && samesets(g, c, c2)) cats[c2] = cat; } @@ -1477,7 +1477,7 @@ register struct parse *p; register struct re_guts *g; { g->nstates = p->slen; - g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); + g->strip = (sop *)realloc((unsigned char *)p->strip, p->slen * sizeof(sop)); if (g->strip == NULL) { SETERROR(REG_ESPACE); g->strip = p->strip; @@ -1504,7 +1504,7 @@ register struct re_guts *g; register sop *newstart = NULL; register sopno newlen; register sop s; - register char *cp; + register unsigned char *cp; register sopno i; /* avoid making error situations worse */ @@ -1565,7 +1565,7 @@ register struct re_guts *g; while (OP(s = *scan++) != OCHAR) continue; assert(cp < g->must + g->mlen); - *cp++ = (char)OPND(s); + *cp++ = (unsigned char)OPND(s); } assert(cp == g->must + g->mlen); *cp++ = '\0'; /* just on general principles */ diff --git a/regex/regcomp.ih b/regex/regcomp.ih index 6efafebf602..c93d32e51d3 100644 --- a/regex/regcomp.ih +++ b/regex/regcomp.ih @@ -14,9 +14,9 @@ static void p_bracket(register struct parse *p); static void p_b_term(register struct parse *p, register cset *cs); static void p_b_cclass(register struct parse *p, register cset *cs); static void p_b_eclass(register struct parse *p, register cset *cs); -static char p_b_symbol(register struct parse *p); -static char p_b_coll_elem(register struct parse *p, int endc); -static char othercase(int ch); +static unsigned char p_b_symbol(register struct parse *p); +static unsigned char p_b_coll_elem(register struct parse *p, int endc); +static unsigned char othercase(int ch); static void bothcases(register struct parse *p, int ch); static void ordinary(register struct parse *p, register int ch); static void nonnewline(register struct parse *p); @@ -27,11 +27,11 @@ static void freeset(register struct parse *p, register cset *cs); static int freezeset(register struct parse *p, register cset *cs); static int firstch(register struct parse *p, register cset *cs); static int nch(register struct parse *p, register cset *cs); -static void mcadd(register struct parse *p, register cset *cs, register char *cp); +static void mcadd(register struct parse *p, register cset *cs, register unsigned char *cp); #if 0 -static void mcsub(register cset *cs, register char *cp); -static int mcin(register cset *cs, register char *cp); -static char *mcfind(register cset *cs, register char *cp); +static void mcsub(register cset *cs, register unsigned char *cp); +static int mcin(register cset *cs, register unsigned char *cp); +static unsigned char *mcfind(register cset *cs, register unsigned char *cp); #endif static void mcinvert(register struct parse *p, register cset *cs); static void mccase(register struct parse *p, register cset *cs); diff --git a/regex/regex2.h b/regex/regex2.h index 7cd39a59ae5..4996f96ecd3 100644 --- a/regex/regex2.h +++ b/regex/regex2.h @@ -10,7 +10,7 @@ = typedef struct { = int re_magic; = size_t re_nsub; // number of parenthesized subexpressions - = const char *re_endp; // end pointer for REG_PEND + = const unsigned char *re_endp; // end pointer for REG_PEND = struct re_guts *re_g; // none of your business :-) = } regex_t; = typedef struct { @@ -90,7 +90,7 @@ typedef struct { uch mask; /* bit within array */ uch hash; /* hash code */ size_t smultis; - char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ + unsigned char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ } cset; /* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ #define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) @@ -125,8 +125,8 @@ struct re_guts { int nbol; /* number of ^ used */ int neol; /* number of $ used */ int ncategories; /* how many character categories */ - cat_t *categories; /* ->catspace[-CHAR_MIN] */ - char *must; /* match must contain this string */ + cat_t *categories; /* ->catspace[-UCHAR_MIN] */ + unsigned char *must; /* match must contain this string */ int mlen; /* length of must */ size_t nsub; /* copy of re_nsub */ int backrefs; /* does it use back references? */ @@ -136,5 +136,5 @@ struct re_guts { }; /* misc utilities */ -#define OUT (CHAR_MAX+1) /* a non-character value */ +#define OUT (UCHAR_MAX+1) /* a non-character value */ #define ISWORD(c) (isalnum(c) || (c) == '_') diff --git a/regex/regexec.c b/regex/regexec.c index 7888d02368c..c8cb8fdf564 100644 --- a/regex/regexec.c +++ b/regex/regexec.c @@ -67,14 +67,14 @@ static int nope = 0; /* for use in asserts; shuts lint up */ #undef SNAMES /* macros for manipulating states, large version */ -#define states char * +#define states unsigned char * #define CLEAR(v) memset(v, 0, m->g->nstates) #define SET0(v, n) ((v)[n] = 0) #define SET1(v, n) ((v)[n] = 1) #define ISSET(v, n) ((v)[n]) #define ASSIGN(d, s) memcpy(d, s, m->g->nstates) #define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) -#define STATEVARS int vn; char *space +#define STATEVARS int vn; unsigned char *space #define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ if ((m)->space == NULL) return(REG_ESPACE); \ (m)->vn = 0; } @@ -132,7 +132,7 @@ int eflags; eflags = GOODFLAGS(eflags); if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) - return(smatcher(g, (char *)string, nmatch, pmatch, eflags)); + return(smatcher(g, (unsigned char *)string, nmatch, pmatch, eflags)); else - return(lmatcher(g, (char *)string, nmatch, pmatch, eflags)); + return(lmatcher(g, (unsigned char *)string, nmatch, pmatch, eflags)); }