diff --git a/examples/sixdraw.c b/examples/sixdraw.c index 12a9891..5fecf54 100644 --- a/examples/sixdraw.c +++ b/examples/sixdraw.c @@ -279,7 +279,7 @@ sixdraw_prepare(struct sixdraw_ctx *ctx) bool has_sixel = false; bool has_dec_locator = false; union ctlseqs_value *result = ctx->result; - for (size_t i = 1; i <= result[0].num; ++i) { + for (size_t i = 1; i <= result[0].len; ++i) { if (result[i].num == 4) { has_sixel = true; } else if (result[i].num == 29) { diff --git a/src/ctlseqs.c b/src/ctlseqs.c index cbfc47c..5046497 100644 --- a/src/ctlseqs.c +++ b/src/ctlseqs.c @@ -74,7 +74,7 @@ break; \ } \ } \ - buf_val[0].num = cnt; \ + buf_val[0].len = cnt; \ buf_val[1].str = seq; \ *buf += 2; \ return seq + cnt @@ -250,7 +250,8 @@ ctlseqs_state_transition(enum ctlseqs_state state, char ch) CTLSEQS_HOT static char const * ctlseqs_fetch_value(char const *seq, int type, union ctlseqs_value **buf) { - unsigned long cnt, num; + size_t cnt; + unsigned long num; char *endptr = NULL; union ctlseqs_value *buf_val = *buf; switch (type) { @@ -269,7 +270,7 @@ ctlseqs_fetch_value(char const *seq, int type, union ctlseqs_value **buf) } seq = endptr + 1; } - buf_val[0].num = cnt; + buf_val[0].len = cnt; *buf += cnt + 1; return endptr; case ctlseqs_ph_str: @@ -365,7 +366,7 @@ ctlseqs_do_match(struct ctlseqs_matcher const *matcher, struct ctlseqs_match_arg } } if (retval < 0 || args->save_seq) { - args->result[0].num = idx; + args->result[0].len = idx; args->result[1].str = seq; } args->result_idx = idx; diff --git a/src/ctlseqs.h b/src/ctlseqs.h index 0976f18..d8f0d6c 100644 --- a/src/ctlseqs.h +++ b/src/ctlseqs.h @@ -388,6 +388,7 @@ struct ctlseqs_reader_options { union ctlseqs_value { char const *str; + size_t len; unsigned long num; }; diff --git a/tests/tcsgrep.c b/tests/tcsgrep.c index ed8b1a9..519dac2 100644 --- a/tests/tcsgrep.c +++ b/tests/tcsgrep.c @@ -87,7 +87,7 @@ parse_int(char const *str, int *dest) static void print_generic_seq(char const *header, union ctlseqs_value *result, bool newline) { - size_t length = result[0].num; + size_t length = result[0].len; char const *seq = result[1].str; printf("%s %zu", header, length); for (size_t idx = 0; idx < length; ++idx) { @@ -124,10 +124,10 @@ print_matching_seq(struct tcsgrep_sequence *seq, union ctlseqs_value *result, bo printf(" %lu", result[idx].num); break; case 0x10: // CTLSEQS_PH_STR - printf(" %.*s", (int)result[idx].num, result[idx + 1].str); + printf(" %.*s", (int)result[idx].len, result[idx + 1].str); break; case 0x0f: // CTLSEQS_PH_NUMS - for (size_t i = 1; i <= result[idx].num; ++i) { + for (size_t i = 1; i <= result[idx].len; ++i) { printf(" %lu", result[idx + i].num); } break; @@ -421,7 +421,7 @@ main(int argc, char **argv) case CTLSEQS_NOMEM: print_generic_seq("NOMEM", result, true); if (ctx.purge_long_seqs) { - ctlseqs_purge(reader, result[0].num); + ctlseqs_purge(reader, result[0].len); break; } else { status = 1;