Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly reset the goto table for a state. #200

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions b.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extern int u8_nextlen(const char *s);

static int get_gototab(fa*, int, int);
static int set_gototab(fa*, int, int, int);
static void reset_gototab(fa*, int);
extern int u8_rune(int *, const uschar *);

static int *
Expand Down Expand Up @@ -268,8 +269,7 @@ int makeinit(fa *f, bool anchor)
}
if ((f->posns[2])[1] == f->accept)
f->out[2] = 1;
for (i = 0; i < NCHARS; i++)
set_gototab(f, 2, 0, 0); /* f->gototab[2][i] = 0; */
reset_gototab(f, 2);
f->curstat = cgoto(f, 2, HAT);
if (anchor) {
*f->posns[2] = k-1; /* leave out position 0 */
Expand Down Expand Up @@ -607,6 +607,11 @@ static int get_gototab(fa *f, int state, int ch) /* hide gototab inplementation
return 0;
}

static void reset_gototab(fa *f, int state) /* hide gototab inplementation */
{
memset(f->gototab[state], 0, f->gototab_len * sizeof(**f->gototab));
}

static int set_gototab(fa *f, int state, int ch, int val) /* hide gototab inplementation */
{
int i;
Expand Down Expand Up @@ -1486,8 +1491,6 @@ int cgoto(fa *f, int s, int c)
/* add tmpset to current set of states */
++(f->curstat);
resize_state(f, f->curstat);
for (i = 0; i < NCHARS; i++)
set_gototab(f, f->curstat, 0, 0);
xfree(f->posns[f->curstat]);
p = intalloc(setcnt + 1, __func__);

Expand Down