Skip to content

Commit

Permalink
WIP comment dst
Browse files Browse the repository at this point in the history
  • Loading branch information
silentbicycle committed Oct 8, 2024
1 parent 9528d01 commit 80c79c0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libfsm/print/cdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,14 @@ generate_data(FILE *f, const struct cdata_config *config,
fprintf(f, "\t\t\t\t.labels = { 0x%lx, 0x%lx, 0x%lx, 0x%lx },\n",
si->labels[0], si->labels[1], si->labels[2], si->labels[3]);

size_t dst_count = 0;
if (comments) {
fprintf(f, "\t\t\t\t// ");
for (size_t i = 0; i < 256; i++) {
if (si->label_group_starts[i/64] & ((uint64_t)1 << (i & 63))) {
char c = (char)i;
fprintf(f, "%c", isprint(c) ? c : '.');
dst_count++;
}
}
fprintf(f, "\n");
Expand All @@ -320,6 +322,13 @@ generate_data(FILE *f, const struct cdata_config *config,
if (si->default_dst == STATE_OFFSET_NONE) {
fprintf(f, "\t\t\t\t.default_dst = %zu /* NONE */,\n", state_NONE);
} else {
if (comments) {
fprintf(f, "\t\t\t\t//");
for (size_t i = 0; i < dst_count; i++) {
fprintf(f, " %u,", config->dst_buf.buf[si->default_dst + i]);
}
fprintf(f, "\n");
}
fprintf(f, "\t\t\t\t.default_dst = %zu,\n", si->default_dst);
}

Expand Down

0 comments on commit 80c79c0

Please sign in to comment.