diff options
Diffstat (limited to 'src/set-fields.c')
| -rw-r--r-- | src/set-fields.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/set-fields.c b/src/set-fields.c index 0cf1ef247..6102282ea 100644 --- a/src/set-fields.c +++ b/src/set-fields.c @@ -27,10 +27,10 @@ struct field_range_pair *frp; /* Number of finite ranges specified by the user. */ -size_t n_frp; +idx_t n_frp; /* Number of `struct field_range_pair's allocated. */ -static size_t n_frp_allocated; +static idx_t n_frp_allocated; #define FATAL_ERROR(Message) \ do \ @@ -47,7 +47,7 @@ static void add_range_pair (uintmax_t lo, uintmax_t hi) { if (n_frp == n_frp_allocated) - frp = X2NREALLOC (frp, &n_frp_allocated); + frp = xpalloc (frp, &n_frp_allocated, 1, -1, sizeof *frp); frp[n_frp].lo = lo; frp[n_frp].hi = hi; ++n_frp; @@ -70,7 +70,7 @@ static void complement_rp (void) { struct field_range_pair *c = frp; - size_t n = n_frp; + idx_t n = n_frp; frp = nullptr; n_frp = 0; @@ -79,7 +79,7 @@ complement_rp (void) if (c[0].lo > 1) add_range_pair (1, c[0].lo - 1); - for (size_t i = 1; i < n; ++i) + for (idx_t i = 1; i < n; ++i) { if (c[i - 1].hi + 1 == c[i].lo) continue; @@ -250,9 +250,8 @@ set_fields (char const *fieldstr, unsigned int options) { /* In case the user specified -c$(echo 2^64|bc),22, complain only about the first number. */ - /* Determine the length of the offending number. */ - size_t len = strspn (num_start, "0123456789"); - char *bad_num = ximemdup0 (num_start, len); + char *bad_num = ximemdup0 (num_start, + strspn (num_start, "0123456789")); error (0, 0, (options & SETFLD_ERRMSG_USE_POS) ?_("byte/character offset %s is too large") :_("field number %s is too large"), @@ -281,9 +280,9 @@ set_fields (char const *fieldstr, unsigned int options) qsort (frp, n_frp, sizeof (frp[0]), compare_ranges); /* Merge range pairs (e.g. `2-5,3-4' becomes `2-5'). */ - for (size_t i = 0; i < n_frp; ++i) + for (idx_t i = 0; i < n_frp; ++i) { - for (size_t j = i + 1; j < n_frp; ++j) + for (idx_t j = i + 1; j < n_frp; ++j) { if (frp[j].lo <= frp[i].hi) { |
