Skip to content

Commit

Permalink
Fix a bug in the CDATA interpreter's bitset checking.
Browse files Browse the repository at this point in the history
Because of the for loop init condition, this was checking bits
`1 << 1..64` in every word -- it was unintentionally ignoring
the least significant bit. It should check `1 << 0..64`.
  • Loading branch information
silentbicycle committed Jan 17, 2025
1 parent c5342a8 commit 8cd564b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libfsm/print/cdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ generate_interpreter(FILE *f, const struct cdata_config *config, const struct fs
fprintf(f, "\tfor (size_t w_i = 0; w_i < %zu; w_i++) {\n", eager_output_words);
fprintf(f, "\t\tconst uint64_t w = uncommitted_eager_output_buf[w_i];\n");
fprintf(f, "\t\tif (w == 0) { continue; }\n");
fprintf(f, "\t\tfor (size_t bit = 1; bit < 64; bit++) {\n");
fprintf(f, "\t\tfor (size_t bit = 0; bit < 64; bit++) {\n");
fprintf(f, "\t\t\tif (w & ((uint64_t)1 << bit)) {\n");
fprintf(f, "\t\t\t\tconst uint64_t id = %s_dfa_data.eager_output_ids[64*w_i + bit];\n", prefix);
fprintf(f, "\t\t\t\teager_output_buf[id/64] |= ((uint64_t)1 << (id & 63));\n");
Expand Down

0 comments on commit 8cd564b

Please sign in to comment.