diff --git a/README b/README index e3712c0..80faac2 100644 --- a/README +++ b/README @@ -43,6 +43,9 @@ or class is a space we want to match not assert at. But the code for it was too dirty and I scrapped it. Syntax for word assertions are like posix C library, not the pcre "\b" which can be used both in front or back of the word, because there is no distinction, it makes the implementation potentially even uglier. +* Assert flags like REG_ICASE,REG_NOTEOL,REG_NOTBOL and lookahead inside +negated bracket are implemented here (also shows use case in real world project): +https://github.com/kyx0r/neatvi/blob/pikevm/regex.c NOTES ===== diff --git a/pike.c b/pike.c index 50b1c6e..f232721 100644 --- a/pike.c +++ b/pike.c @@ -472,7 +472,7 @@ goto next##nn; \ pc += 2 + pc[1]; \ goto rec##nn; \ case SPLIT: \ - if(plist[pc - insts] == gen) \ + if (plist[pc - insts] == gen) \ deccheck(nn) \ plist[pc - insts] = gen; \ sub->ref++; \ @@ -480,7 +480,7 @@ goto next##nn; \ pcs[i] = pc + pc[-1]; \ fastrec(nn, list, listidx) \ case RSPLIT: \ - if(plist[pc - insts] == gen) \ + if (plist[pc - insts] == gen) \ deccheck(nn) \ plist[pc - insts] = gen; \ sub->ref++; \ @@ -490,10 +490,10 @@ goto next##nn; \ fastrec(nn, list, listidx) \ case SAVE: \ if (sub->ref > 1) { \ + sub->ref--; \ newsub() \ for (j = 0; j < nsubp; j++) \ s1->sub[j] = sub->sub[j]; \ - sub->ref--; \ sub = s1; \ sub->ref = 1; \ } \ @@ -537,15 +537,15 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) rthread *clist = _clist, *nlist = _nlist, *tmp; gen = prog->gen; goto jmp_start; - for(;; sp = _sp) { + for (;; sp = _sp) { gen++; uc_len(i, sp) uc_code(c, sp) _sp = sp+i; - for(i = 0; i < clistidx; i++) { + for (i = 0; i < clistidx; i++) { npc = clist[i].pc; nsub = clist[i].sub; switch(*npc++) { case CHAR: - if(c != *npc++) + if (c != *npc++) break; case ANY: addthread: @@ -584,8 +584,8 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) } else if (!clistidx) break; } - if(matched) { - for(i = 0; i < nsubp; i++) + if (matched) { + for (i = 0; i < nsubp; i++) subp[i] = matched->sub[i]; _return(1) } @@ -620,17 +620,17 @@ int main(int argc, char *argv[]) printf("Done in %f seconds\n", elapsed_time); if (!sz) { printf("-nomatch-\n"); continue; } - for(int k=sub_els; k>0; k--) - if(sub[k-1]) + for (int k=sub_els; k>0; k--) + if (sub[k-1]) break; - for(int l=0; l