Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/regex/regcomp.c
Show First 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | case '$': | ||||
p->g->neol++; | p->g->neol++; | ||||
break; | break; | ||||
case '|': | case '|': | ||||
SETERROR(REG_EMPTY); | SETERROR(REG_EMPTY); | ||||
break; | break; | ||||
case '*': | case '*': | ||||
case '+': | case '+': | ||||
case '?': | case '?': | ||||
case '{': | |||||
SETERROR(REG_BADRPT); | SETERROR(REG_BADRPT); | ||||
break; | break; | ||||
case '.': | case '.': | ||||
if (p->g->cflags®_NEWLINE) | if (p->g->cflags®_NEWLINE) | ||||
nonnewline(p); | nonnewline(p); | ||||
else | else | ||||
EMIT(OANY, 0); | EMIT(OANY, 0); | ||||
break; | break; | ||||
Show All 10 Lines | case '\\': | ||||
case '>': | case '>': | ||||
EMIT(OEOW, 0); | EMIT(OEOW, 0); | ||||
break; | break; | ||||
default: | default: | ||||
ordinary(p, wc); | ordinary(p, wc); | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
case '{': /* okay as ordinary except if digit follows */ | |||||
(void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT); | |||||
/* FALLTHROUGH */ | |||||
default: | default: | ||||
if (p->error != 0) | if (p->error != 0) | ||||
return (false); | return (false); | ||||
p->next--; | p->next--; | ||||
wc = WGETNEXT(); | wc = WGETNEXT(); | ||||
ordinary(p, wc); | ordinary(p, wc); | ||||
break; | break; | ||||
} | } | ||||
if (!MORE()) | if (!MORE()) | ||||
return (false); | return (false); | ||||
c = PEEK(); | c = PEEK(); | ||||
/* we call { a repetition if followed by a digit */ | /* we call { a repetition if followed by a digit */ | ||||
if (!( c == '*' || c == '+' || c == '?' || | if (!( c == '*' || c == '+' || c == '?' || c == '{')) | ||||
(c == '{' && MORE2() && isdigit((uch)PEEK2())) )) | |||||
return (false); /* no repetition, we're done */ | return (false); /* no repetition, we're done */ | ||||
else if (c == '{') | |||||
(void)REQUIRE(MORE2() && \ | |||||
(isdigit((uch)PEEK2()) || PEEK2() == ','), REG_BADRPT); | |||||
NEXT(); | NEXT(); | ||||
(void)REQUIRE(!wascaret, REG_BADRPT); | (void)REQUIRE(!wascaret, REG_BADRPT); | ||||
switch (c) { | switch (c) { | ||||
case '*': /* implemented as +? */ | case '*': /* implemented as +? */ | ||||
/* this case does not require the (y|) trick, noKLUDGE */ | /* this case does not require the (y|) trick, noKLUDGE */ | ||||
INSERT(OPLUS_, pos); | INSERT(OPLUS_, pos); | ||||
ASTERN(O_PLUS, pos); | ASTERN(O_PLUS, pos); | ||||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | case BACKSL|'(': | ||||
if (subno < NPAREN) { | if (subno < NPAREN) { | ||||
p->pend[subno] = HERE(); | p->pend[subno] = HERE(); | ||||
assert(p->pend[subno] != 0); | assert(p->pend[subno] != 0); | ||||
} | } | ||||
EMIT(ORPAREN, subno); | EMIT(ORPAREN, subno); | ||||
(void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN); | (void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN); | ||||
break; | break; | ||||
case BACKSL|')': /* should not get here -- must be user */ | case BACKSL|')': /* should not get here -- must be user */ | ||||
case BACKSL|'}': | |||||
SETERROR(REG_EPAREN); | SETERROR(REG_EPAREN); | ||||
break; | break; | ||||
case BACKSL|'1': | case BACKSL|'1': | ||||
case BACKSL|'2': | case BACKSL|'2': | ||||
case BACKSL|'3': | case BACKSL|'3': | ||||
case BACKSL|'4': | case BACKSL|'4': | ||||
case BACKSL|'5': | case BACKSL|'5': | ||||
case BACKSL|'6': | case BACKSL|'6': | ||||
▲ Show 20 Lines • Show All 1,191 Lines • Show Last 20 Lines |