Skip to content

Commit

Permalink
Emit strncmp() for FSM_IO_STR, similar to memcmp().
Browse files Browse the repository at this point in the history
  • Loading branch information
katef committed Jun 5, 2023
1 parent 886c60a commit f932511
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libfsm/print/vmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,19 @@ fsm_print_cfrag(FILE *f, const struct ir *ir, const struct fsm_options *opt,
fprintf(f, "\t");
fprintf(f, "p += %zu;\n", n);

op = tail;
} else if (n > 1 && opt->io == FSM_IO_STR) {
fprintf(f, "if (0 != strncmp(p, \"");
escputbuf(f, opt, c_escputc_str, buf, n);
fprintf(f, "\", %zu)) ", n);
if (-1 == print_end(f, NULL, opt, end_bits, ir)) {
return -1;
}
fprintf(f, "\n");

fprintf(f, "\t");
fprintf(f, "p += %zu;\n", n);

op = tail;
} else {
print_fetch(f, opt);
Expand Down

0 comments on commit f932511

Please sign in to comment.