mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.3.1014
Problem: New regexp state dump is hard to read. Solution: Make the state dump more pretty. (Taro Muraoka)
This commit is contained in:
parent
d6c11cb3e0
commit
152e7890c1
@ -183,7 +183,8 @@ static int nfa_reg __ARGS((int paren));
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static void nfa_set_code __ARGS((int c));
|
static void nfa_set_code __ARGS((int c));
|
||||||
static void nfa_postfix_dump __ARGS((char_u *expr, int retval));
|
static void nfa_postfix_dump __ARGS((char_u *expr, int retval));
|
||||||
static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state, int ident));
|
static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state));
|
||||||
|
static void nfa_print_state2 __ARGS((FILE *debugf, nfa_state_T *state, garray_T *indent));
|
||||||
static void nfa_dump __ARGS((nfa_regprog_T *prog));
|
static void nfa_dump __ARGS((nfa_regprog_T *prog));
|
||||||
#endif
|
#endif
|
||||||
static int *re2post __ARGS((void));
|
static int *re2post __ARGS((void));
|
||||||
@ -1811,19 +1812,45 @@ nfa_postfix_dump(expr, retval)
|
|||||||
* Print the NFA starting with a root node "state".
|
* Print the NFA starting with a root node "state".
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
nfa_print_state(debugf, state, ident)
|
nfa_print_state(debugf, state)
|
||||||
FILE *debugf;
|
FILE *debugf;
|
||||||
nfa_state_T *state;
|
nfa_state_T *state;
|
||||||
int ident;
|
|
||||||
{
|
{
|
||||||
int i;
|
garray_T indent;
|
||||||
|
|
||||||
|
ga_init2(&indent, 1, 64);
|
||||||
|
ga_append(&indent, '\0');
|
||||||
|
nfa_print_state2(debugf, state, &indent);
|
||||||
|
ga_clear(&indent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nfa_print_state2(debugf, state, indent)
|
||||||
|
FILE *debugf;
|
||||||
|
nfa_state_T *state;
|
||||||
|
garray_T *indent;
|
||||||
|
{
|
||||||
|
char_u *p;
|
||||||
|
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(debugf, "(%2d)", abs(state->id));
|
fprintf(debugf, "(%2d)", abs(state->id));
|
||||||
for (i = 0; i < ident; i++)
|
|
||||||
fprintf(debugf, "%c", ' ');
|
/* Output indent */
|
||||||
|
p = (char_u *)indent->ga_data;
|
||||||
|
if (indent->ga_len >= 3)
|
||||||
|
{
|
||||||
|
int last = indent->ga_len - 3;
|
||||||
|
char_u save[2];
|
||||||
|
|
||||||
|
STRNCPY(save, &p[last], 2);
|
||||||
|
STRNCPY(&p[last], "+-", 2);
|
||||||
|
fprintf(debugf, " %s", p);
|
||||||
|
STRNCPY(&p[last], save, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf(debugf, " %s", p);
|
||||||
|
|
||||||
nfa_set_code(state->c);
|
nfa_set_code(state->c);
|
||||||
fprintf(debugf, "%s%s (%d) (id=%d)\n",
|
fprintf(debugf, "%s%s (%d) (id=%d)\n",
|
||||||
@ -1832,8 +1859,27 @@ nfa_print_state(debugf, state, ident)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
state->id = abs(state->id) * -1;
|
state->id = abs(state->id) * -1;
|
||||||
nfa_print_state(debugf, state->out, ident + 4);
|
|
||||||
nfa_print_state(debugf, state->out1, ident + 4);
|
/* grow indent for state->out */
|
||||||
|
indent->ga_len -= 1;
|
||||||
|
if (state->out1)
|
||||||
|
ga_concat(indent, "| ");
|
||||||
|
else
|
||||||
|
ga_concat(indent, " ");
|
||||||
|
ga_append(indent, '\0');
|
||||||
|
|
||||||
|
nfa_print_state2(debugf, state->out, indent);
|
||||||
|
|
||||||
|
/* replace last part of indent for state->out1 */
|
||||||
|
indent->ga_len -= 3;
|
||||||
|
ga_concat(indent, " ");
|
||||||
|
ga_append(indent, '\0');
|
||||||
|
|
||||||
|
nfa_print_state2(debugf, state->out1, indent);
|
||||||
|
|
||||||
|
/* shrink indent */
|
||||||
|
indent->ga_len -= 3;
|
||||||
|
ga_append(indent, '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1847,7 +1893,7 @@ nfa_dump(prog)
|
|||||||
|
|
||||||
if (debugf != NULL)
|
if (debugf != NULL)
|
||||||
{
|
{
|
||||||
nfa_print_state(debugf, prog->start, 0);
|
nfa_print_state(debugf, prog->start);
|
||||||
fclose(debugf);
|
fclose(debugf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3505,7 +3551,7 @@ nfa_regtry(start, col)
|
|||||||
#endif
|
#endif
|
||||||
fprintf(f, "\tInput text is \"%s\" \n", reginput);
|
fprintf(f, "\tInput text is \"%s\" \n", reginput);
|
||||||
fprintf(f, " =======================================================\n\n\n\n\n\n\n");
|
fprintf(f, " =======================================================\n\n\n\n\n\n\n");
|
||||||
nfa_print_state(f, start, 0);
|
nfa_print_state(f, start);
|
||||||
fprintf(f, "\n\n");
|
fprintf(f, "\n\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1014,
|
||||||
/**/
|
/**/
|
||||||
1013,
|
1013,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user