regex(3): Resolve issues with higher WARNS levels
libc is set for WARNS=2, but the incoming libregex will use WARNS=6. Sprinkle some casts and (void)bc's to alleviate the warnings that come along with the higher WARNS level. These 'bc' parameters could be outright removed, but as of right now they will be used in some parts of libregex land. Silence the warnings instead rather than flip-flopping.
This commit is contained in:
parent
f10d0bd4d4
commit
e0d9650001
@ -398,7 +398,7 @@ dissect(struct match *m,
|
||||
es += OPND(m->g->strip[es]);
|
||||
break;
|
||||
case OCH_:
|
||||
while (OP(m->g->strip[es]) != O_CH)
|
||||
while (OP(m->g->strip[es]) != (sop)O_CH)
|
||||
es += OPND(m->g->strip[es]);
|
||||
break;
|
||||
}
|
||||
@ -512,7 +512,7 @@ dissect(struct match *m,
|
||||
assert(OP(m->g->strip[esub]) == OOR2);
|
||||
ssub = esub + 1;
|
||||
esub += OPND(m->g->strip[esub]);
|
||||
if (OP(m->g->strip[esub]) == OOR2)
|
||||
if (OP(m->g->strip[esub]) == (sop)OOR2)
|
||||
esub--;
|
||||
else
|
||||
assert(OP(m->g->strip[esub]) == O_CH);
|
||||
@ -647,7 +647,7 @@ backref(struct match *m,
|
||||
do {
|
||||
assert(OP(s) == OOR2);
|
||||
ss += OPND(s);
|
||||
} while (OP(s = m->g->strip[ss]) != O_CH);
|
||||
} while (OP(s = m->g->strip[ss]) != (sop)O_CH);
|
||||
/* note that the ss++ gets us past the O_CH */
|
||||
break;
|
||||
default: /* have to make a choice */
|
||||
@ -680,7 +680,7 @@ backref(struct match *m,
|
||||
ssp = m->offp + m->pmatch[i].rm_so;
|
||||
if (memcmp(sp, ssp, len) != 0)
|
||||
return(NULL);
|
||||
while (m->g->strip[ss] != SOP(O_BACK, i))
|
||||
while (m->g->strip[ss] != (sop)SOP(O_BACK, i))
|
||||
ss++;
|
||||
return(backref(m, sp+len, stop, ss+1, stopst, lev, rec));
|
||||
case OQUEST_: /* to null or not */
|
||||
@ -712,13 +712,13 @@ backref(struct match *m,
|
||||
if (dp != NULL)
|
||||
return(dp);
|
||||
/* that one missed, try next one */
|
||||
if (OP(m->g->strip[esub]) == O_CH)
|
||||
if (OP(m->g->strip[esub]) == (sop)O_CH)
|
||||
return(NULL); /* there is none */
|
||||
esub++;
|
||||
assert(OP(m->g->strip[esub]) == OOR2);
|
||||
assert(OP(m->g->strip[esub]) == (sop)OOR2);
|
||||
ssub = esub + 1;
|
||||
esub += OPND(m->g->strip[esub]);
|
||||
if (OP(m->g->strip[esub]) == OOR2)
|
||||
if (OP(m->g->strip[esub]) == (sop)OOR2)
|
||||
esub--;
|
||||
else
|
||||
assert(OP(m->g->strip[esub]) == O_CH);
|
||||
@ -847,7 +847,7 @@ walk(struct match *m, const char *start, const char *stop, sopno startst,
|
||||
else
|
||||
matchp = p;
|
||||
}
|
||||
if (EQ(st, empty) || p == stop || clen > stop - p)
|
||||
if (EQ(st, empty) || p == stop || clen > (size_t)(stop - p))
|
||||
break; /* NOTE BREAK OUT */
|
||||
|
||||
/* no, we must deal with this character */
|
||||
@ -969,22 +969,22 @@ step(struct re_guts *g,
|
||||
break;
|
||||
case OCH_: /* mark the first two branches */
|
||||
FWD(aft, aft, 1);
|
||||
assert(OP(g->strip[pc+OPND(s)]) == OOR2);
|
||||
assert(OP(g->strip[pc+OPND(s)]) == (sop)OOR2);
|
||||
FWD(aft, aft, OPND(s));
|
||||
break;
|
||||
case OOR1: /* done a branch, find the O_CH */
|
||||
if (ISSTATEIN(aft, here)) {
|
||||
for (look = 1;
|
||||
OP(s = g->strip[pc+look]) != O_CH;
|
||||
look += OPND(s))
|
||||
assert(OP(s) == OOR2);
|
||||
OP(s = g->strip[pc+look]) != (sop)O_CH;
|
||||
look += OPND(s))
|
||||
assert(OP(s) == (sop)OOR2);
|
||||
FWD(aft, aft, look + 1);
|
||||
}
|
||||
break;
|
||||
case OOR2: /* propagate OCH_'s marking */
|
||||
FWD(aft, aft, 1);
|
||||
if (OP(g->strip[pc+OPND(s)]) != O_CH) {
|
||||
assert(OP(g->strip[pc+OPND(s)]) == OOR2);
|
||||
if (OP(g->strip[pc+OPND(s)]) != (sop)O_CH) {
|
||||
assert(OP(g->strip[pc+OPND(s)]) == (sop)OOR2);
|
||||
FWD(aft, aft, OPND(s));
|
||||
}
|
||||
break;
|
||||
|
@ -364,6 +364,7 @@ p_ere_exp(struct parse *p, struct branchc *bc)
|
||||
sopno subno;
|
||||
int wascaret = 0;
|
||||
|
||||
(void)bc;
|
||||
assert(MORE()); /* caller should have ensured this */
|
||||
c = GETNEXT();
|
||||
|
||||
@ -534,6 +535,7 @@ p_branch_eat_delim(struct parse *p, struct branchc *bc)
|
||||
{
|
||||
int nskip;
|
||||
|
||||
(void)bc;
|
||||
nskip = 0;
|
||||
while (EAT('|'))
|
||||
++nskip;
|
||||
@ -587,6 +589,7 @@ static bool
|
||||
p_branch_empty(struct parse *p, struct branchc *bc)
|
||||
{
|
||||
|
||||
(void)bc;
|
||||
SETERROR(REG_EMPTY);
|
||||
return (false);
|
||||
}
|
||||
@ -1617,12 +1620,12 @@ findmust(struct parse *p, struct re_guts *g)
|
||||
scan += OPND(s);
|
||||
s = *scan;
|
||||
/* assert() interferes w debug printouts */
|
||||
if (OP(s) != O_QUEST && OP(s) != O_CH &&
|
||||
OP(s) != OOR2) {
|
||||
if (OP(s) != (sop)O_QUEST &&
|
||||
OP(s) != (sop)O_CH && OP(s) != (sop)OOR2) {
|
||||
g->iflags |= BAD;
|
||||
return;
|
||||
}
|
||||
} while (OP(s) != O_QUEST && OP(s) != O_CH);
|
||||
} while (OP(s) != (sop)O_QUEST && OP(s) != (sop)O_CH);
|
||||
/* FALLTHROUGH */
|
||||
case OBOW: /* things that break a sequence */
|
||||
case OEOW:
|
||||
@ -1631,7 +1634,7 @@ findmust(struct parse *p, struct re_guts *g)
|
||||
case O_QUEST:
|
||||
case O_CH:
|
||||
case OEND:
|
||||
if (newlen > g->mlen) { /* ends one */
|
||||
if (newlen > (sopno)g->mlen) { /* ends one */
|
||||
start = newstart;
|
||||
g->mlen = newlen;
|
||||
if (offset > -1) {
|
||||
@ -1646,7 +1649,7 @@ findmust(struct parse *p, struct re_guts *g)
|
||||
newlen = 0;
|
||||
break;
|
||||
case OANY:
|
||||
if (newlen > g->mlen) { /* ends one */
|
||||
if (newlen > (sopno)g->mlen) { /* ends one */
|
||||
start = newstart;
|
||||
g->mlen = newlen;
|
||||
if (offset > -1) {
|
||||
@ -1664,7 +1667,7 @@ findmust(struct parse *p, struct re_guts *g)
|
||||
break;
|
||||
case OANYOF: /* may or may not invalidate offset */
|
||||
/* First, everything as OANY */
|
||||
if (newlen > g->mlen) { /* ends one */
|
||||
if (newlen > (sopno)g->mlen) { /* ends one */
|
||||
start = newstart;
|
||||
g->mlen = newlen;
|
||||
if (offset > -1) {
|
||||
@ -1687,7 +1690,7 @@ findmust(struct parse *p, struct re_guts *g)
|
||||
* save the last known good offset, in case the
|
||||
* must sequence doesn't occur later.
|
||||
*/
|
||||
if (newlen > g->mlen) { /* ends one */
|
||||
if (newlen > (sopno)g->mlen) { /* ends one */
|
||||
start = newstart;
|
||||
g->mlen = newlen;
|
||||
if (offset > -1)
|
||||
@ -1748,7 +1751,7 @@ altoffset(sop *scan, int offset)
|
||||
largest = 0;
|
||||
try = 0;
|
||||
s = *scan++;
|
||||
while (OP(s) != O_QUEST && OP(s) != O_CH) {
|
||||
while (OP(s) != (sop)O_QUEST && OP(s) != (sop)O_CH) {
|
||||
switch (OP(s)) {
|
||||
case OOR1:
|
||||
if (try > largest)
|
||||
@ -1764,10 +1767,10 @@ altoffset(sop *scan, int offset)
|
||||
do {
|
||||
scan += OPND(s);
|
||||
s = *scan;
|
||||
if (OP(s) != O_QUEST && OP(s) != O_CH &&
|
||||
OP(s) != OOR2)
|
||||
if (OP(s) != (sop)O_QUEST &&
|
||||
OP(s) != (sop)O_CH && OP(s) != (sop)OOR2)
|
||||
return -1;
|
||||
} while (OP(s) != O_QUEST && OP(s) != O_CH);
|
||||
} while (OP(s) != (sop)O_QUEST && OP(s) != (sop)O_CH);
|
||||
/* We must skip to the next position, or we'll
|
||||
* leave altoffset() too early.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user