summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-16 11:23:38 +0100
committerTyge Løvset <[email protected]>2022-12-16 11:23:38 +0100
commitd13478b120d2d8ee3fb1bd0e78d1f13bce2f264a (patch)
treee2f1212f622a8432f3efab60b9c33364042fab51 /src
parent2360cf289d1e1221ee259c0bc54543efbc398d86 (diff)
downloadSTC-modified-d13478b120d2d8ee3fb1bd0e78d1f13bce2f264a.tar.gz
STC-modified-d13478b120d2d8ee3fb1bd0e78d1f13bce2f264a.zip
Rewrote cregex _nextc() to use for-loop instead of goto.
Diffstat (limited to 'src')
-rw-r--r--src/cregex.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/cregex.c b/src/cregex.c
index dfd27714..8bac0e07 100644
--- a/src/cregex.c
+++ b/src/cregex.c
@@ -577,25 +577,26 @@ _nextc(_Parser *par, _Rune *rp)
*rp = 0;
return 1;
}
-start:
- ret = par->litmode;
- par->exprp += chartorune(rp, par->exprp);
-
- if (*rp == '\\') {
- if (par->litmode && *par->exprp != 'E')
- return 1; /* litmode */
+ for (;;) {
+ ret = par->litmode;
par->exprp += chartorune(rp, par->exprp);
- switch (*rp) {
- case 'Q':
- par->litmode = true;
- goto start;
- case 'E':
- if (!par->litmode) break;
- par->litmode = false;
- goto start;
+ if (*rp == '\\') {
+ if (par->litmode) {
+ if (*par->exprp != 'E')
+ break;
+ par->litmode = false;
+ par->exprp += 1;
+ continue;
+ }
+ par->exprp += chartorune(rp, par->exprp);
+ if (*rp == 'Q') {
+ par->litmode = true;
+ continue;
+ }
+ ret = 1;
}
- ret = 1;
+ break;
}
if (*rp == 0)
par->lexdone = true;
@@ -1126,7 +1127,7 @@ static int
_regexec(const _Reprog *progp, /* program to run */
const char *bol, /* string to run machine on */
unsigned ms, /* number of elements at mp */
- _Resub mp[], /* subexpression elements */
+ _Resub mp[], /* subexpression elements */
int mflags)
{
_Reljunk j;
@@ -1134,7 +1135,7 @@ _regexec(const _Reprog *progp, /* program to run */
int rv;
/*
- * use user-specified starting/ending location if specified
+ * use user-specified starting/ending location if specified
*/
j.starts = bol;
j.eol = NULL;