From ba1170ac0504fbe7cf96a9d6515477ed8de1b29d Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Mon, 28 Apr 2025 11:37:18 -0400 Subject: toml-c c99 compliance --- compressor.c | 10 +++++----- toml.c | 4 ++-- toml.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compressor.c b/compressor.c index b317c25..1de978a 100644 --- a/compressor.c +++ b/compressor.c @@ -123,18 +123,18 @@ load_compressor(const char *path, Compressor *comp) { return 1; } - strncpy(comp->brand, brand.u.s, nelem(comp->brand)-1); - strncpy(comp->series, series.u.s, nelem(comp->series)-1); - strncpy(comp->model, model.u.s, nelem(comp->model)-1); + strncpy(comp->brand, brand.u.s.s, nelem(comp->brand)-1); + strncpy(comp->series, series.u.s.s, nelem(comp->series)-1); + strncpy(comp->model, model.u.s.s, nelem(comp->model)-1); (void) cwk_path_change_extension(path, "jpg", comp->imgfile, sizeof(comp->imgfile)); - if (load_point(tbl, "origin", flowunit.u.s, &comp->origin) != 0) { + if (load_point(tbl, "origin", flowunit.u.s.s, &comp->origin) != 0) { weprintf("%s: failed to load 'origin'", path); toml_free(tbl); return 1; } - if (load_point(tbl, "ref", flowunit.u.s, &comp->ref) != 0) { + if (load_point(tbl, "ref", flowunit.u.s.s, &comp->ref) != 0) { weprintf("%s: failed to load 'ref'", path); toml_free(tbl); return 1; diff --git a/toml.c b/toml.c index 7f3ac61..c5c61d6 100644 --- a/toml.c +++ b/toml.c @@ -1913,7 +1913,7 @@ int toml_value_string(toml_unparsed_t src, char** ret, int* len) { toml_value_t toml_array_string(const toml_array_t* arr, int idx) { toml_value_t ret; memset(&ret, 0, sizeof(ret)); - ret.ok = (toml_value_string(toml_array_unparsed(arr, idx), &ret.u.s, &ret.u.sl) == 0); + ret.ok = (toml_value_string(toml_array_unparsed(arr, idx), &ret.u.s.s, &ret.u.s.len) == 0); return ret; } @@ -1950,7 +1950,7 @@ toml_value_t toml_table_string(const toml_table_t* tbl, const char* key) { memset(&ret, 0, sizeof(ret)); toml_unparsed_t raw = toml_table_unparsed(tbl, key); if (raw) - ret.ok = (toml_value_string(raw, &ret.u.s, &ret.u.sl) == 0); + ret.ok = (toml_value_string(raw, &ret.u.s.s, &ret.u.s.len) == 0); return ret; } diff --git a/toml.h b/toml.h index 9ed36ae..3833fc8 100644 --- a/toml.h +++ b/toml.h @@ -90,8 +90,8 @@ struct toml_value_t { union { struct { char* s; // string value; must be freed after use. - int sl; // string length, excluding NULL. - }; + int len; // string length, excluding NULL. + } s; toml_timestamp_t ts; // datetime bool b; // bool int64_t i; // int -- cgit v1.2.3