remove broken \b
This commit is contained in:
28
pike.c
28
pike.c
@@ -97,7 +97,6 @@ enum /* rinst.opcode */
|
|||||||
ASSERT,
|
ASSERT,
|
||||||
BOL,
|
BOL,
|
||||||
EOL,
|
EOL,
|
||||||
WBND,
|
|
||||||
// Instructions which take relative offset as arg
|
// Instructions which take relative offset as arg
|
||||||
JMP,
|
JMP,
|
||||||
SPLIT,
|
SPLIT,
|
||||||
@@ -151,12 +150,11 @@ void re_fatal(char *msg)
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int re_classmatch(const int *pc, const char *sp)
|
int re_classmatch(const int *pc, int c)
|
||||||
{
|
{
|
||||||
// pc points to "classnot" byte after opcode
|
// pc points to "classnot" byte after opcode
|
||||||
int is_positive = *pc++;
|
int is_positive = *pc++;
|
||||||
int cnt = *pc++, c;
|
int cnt = *pc++;
|
||||||
uc_code(c, sp)
|
|
||||||
while (cnt--) {
|
while (cnt--) {
|
||||||
if (c >= *pc && c <= pc[1]) return is_positive;
|
if (c >= *pc && c <= pc[1]) return is_positive;
|
||||||
pc += 2;
|
pc += 2;
|
||||||
@@ -214,8 +212,6 @@ void re_dumpcode(rcode *prog)
|
|||||||
printf("assert bol\n");
|
printf("assert bol\n");
|
||||||
else if (code[pc] == EOL)
|
else if (code[pc] == EOL)
|
||||||
printf("assert eol\n");
|
printf("assert eol\n");
|
||||||
else if (code[pc] == WBND)
|
|
||||||
printf("assert WBND\n");
|
|
||||||
pc++;
|
pc++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -235,13 +231,6 @@ static int _compilecode(const char **re_loc, rcode *prog, int sizecode)
|
|||||||
case '\\':
|
case '\\':
|
||||||
re++;
|
re++;
|
||||||
if (!*re) goto syntax_error; // Trailing backslash
|
if (!*re) goto syntax_error; // Trailing backslash
|
||||||
if (*re == 'b') {
|
|
||||||
EMIT(PC++, ASSERT);
|
|
||||||
EMIT(PC++, WBND);
|
|
||||||
prog->len++;
|
|
||||||
term = PC;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
term = PC;
|
term = PC;
|
||||||
EMIT(PC++, CHAR);
|
EMIT(PC++, CHAR);
|
||||||
@@ -544,8 +533,6 @@ if (csub->ref > 1) { \
|
|||||||
goto rec_check##nn; \
|
goto rec_check##nn; \
|
||||||
if(*pc == EOL && *_sp) \
|
if(*pc == EOL && *_sp) \
|
||||||
goto rec_check##nn; \
|
goto rec_check##nn; \
|
||||||
if(*pc == WBND && isword(sp)) \
|
|
||||||
goto rec_check##nn; \
|
|
||||||
pc++; goto rec##nn; \
|
pc++; goto rec##nn; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@@ -583,7 +570,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
nsub->sub[0] = sp;
|
nsub->sub[0] = sp;
|
||||||
goto jmp_start;
|
goto jmp_start;
|
||||||
for(; clist->n; sp += l) {
|
for(; clist->n; sp += l) {
|
||||||
gen++; uc_len(l, sp)
|
gen++; uc_len(l, sp) uc_code(c, sp)
|
||||||
for(i=0; i<clist->n; i++) {
|
for(i=0; i<clist->n; i++) {
|
||||||
npc = clist->t[i].pc;
|
npc = clist->t[i].pc;
|
||||||
nsub = clist->t[i].sub;
|
nsub = clist->t[i].sub;
|
||||||
@@ -591,26 +578,25 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
// it's fail (we don't schedule current thread for continuation)
|
// it's fail (we don't schedule current thread for continuation)
|
||||||
if (inst_is_consumer(*npc) && !*sp) {
|
if (inst_is_consumer(*npc) && !*sp) {
|
||||||
if (i >= clist->n-1)
|
if (i >= clist->n-1)
|
||||||
goto BreakFor;
|
goto break_for;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch(*npc++) {
|
switch(*npc++) {
|
||||||
case CHAR:
|
case CHAR:
|
||||||
uc_code(c, sp)
|
|
||||||
if(c != *npc++)
|
if(c != *npc++)
|
||||||
break;
|
break;
|
||||||
case ANY:
|
case ANY:
|
||||||
addthread:
|
addthread:
|
||||||
addthread(2, nlist, npc, nsub, continue)
|
addthread(2, nlist, npc, nsub, continue)
|
||||||
case CLASS:
|
case CLASS:
|
||||||
if (!re_classmatch(npc, sp))
|
if (!re_classmatch(npc, c))
|
||||||
break;
|
break;
|
||||||
npc += *(npc+1) * 2 + 2;
|
npc += *(npc+1) * 2 + 2;
|
||||||
goto addthread;
|
goto addthread;
|
||||||
case MATCH:
|
case MATCH:
|
||||||
matched = nsub;
|
matched = nsub;
|
||||||
subidx = 0;
|
subidx = 0;
|
||||||
goto BreakFor;
|
goto break_for;
|
||||||
}
|
}
|
||||||
nsub->ref--;
|
nsub->ref--;
|
||||||
}
|
}
|
||||||
@@ -625,7 +611,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
addthread(1, clist, prog->insts, nsub, break)
|
addthread(1, clist, prog->insts, nsub, break)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BreakFor:
|
break_for:
|
||||||
swaplist()
|
swaplist()
|
||||||
}
|
}
|
||||||
if(matched) {
|
if(matched) {
|
||||||
|
|||||||
9
test.sh
9
test.sh
@@ -56,9 +56,6 @@ abc$|c
|
|||||||
^abc+d
|
^abc+d
|
||||||
^(abc|kj)
|
^(abc|kj)
|
||||||
^(abc|kj)
|
^(abc|kj)
|
||||||
\\\\babc
|
|
||||||
ab\\\\bd
|
|
||||||
\\\\b(as|js)
|
|
||||||
([^qwe]*rty)|(asd[^fgh]*)
|
([^qwe]*rty)|(asd[^fgh]*)
|
||||||
([^qwe]*rty+)|(asd[^fgh]*)
|
([^qwe]*rty+)|(asd[^fgh]*)
|
||||||
"
|
"
|
||||||
@@ -118,9 +115,6 @@ abccdb
|
|||||||
abccdb
|
abccdb
|
||||||
kj
|
kj
|
||||||
jhdfh kj hhd
|
jhdfh kj hhd
|
||||||
abc
|
|
||||||
ab d
|
|
||||||
js hashasd
|
|
||||||
qweasd qqqq fff
|
qweasd qqqq fff
|
||||||
qwehh sjsjsj rtyyyyyyyyyj sdj
|
qwehh sjsjsj rtyyyyyyyyyj sdj
|
||||||
"
|
"
|
||||||
@@ -180,9 +174,6 @@ expect="\
|
|||||||
(0,5)
|
(0,5)
|
||||||
(0,2)(0,2)
|
(0,2)(0,2)
|
||||||
-nomatch-
|
-nomatch-
|
||||||
(7,10)
|
|
||||||
-nomatch-
|
|
||||||
(5,7)(5,7)
|
|
||||||
(3,16)(?,?)(3,16)
|
(3,16)(?,?)(3,16)
|
||||||
(3,25)(3,25)(?,?)
|
(3,25)(3,25)(?,?)
|
||||||
(0,0)
|
(0,0)
|
||||||
|
|||||||
Reference in New Issue
Block a user