From f9325111c05ef0760e5a1ebd5224a7f3724fbefe Mon Sep 17 00:00:00 2001 From: Kate F Date: Fri, 2 Jun 2023 14:54:28 -0700 Subject: [PATCH] Emit strncmp() for `FSM_IO_STR`, similar to memcmp(). --- src/libfsm/print/vmc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libfsm/print/vmc.c b/src/libfsm/print/vmc.c index 783eb5dfd..b92d68f6d 100644 --- a/src/libfsm/print/vmc.c +++ b/src/libfsm/print/vmc.c @@ -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);