summaryrefslogtreecommitdiff
path: root/src/unexpand.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-03-17 15:32:53 +0000
committerJim Meyering <jim@meyering.net>2005-03-17 15:32:53 +0000
commitf864f6df1cf7f15cf05cd335e011849c9ae6dde4 (patch)
treef33e0df46f19e9aa21e1fe202eed12d0b113c81a /src/unexpand.c
parent3bf5718c30d937bce9b383ff4ebe2eb2a6209a08 (diff)
downloadcoreutils-f864f6df1cf7f15cf05cd335e011849c9ae6dde4.tar.xz
(parse_tab_stops, main): Use DECIMAL_DIGIT_ACCUMULATE macro in
place of nearly-equivalent code.
Diffstat (limited to 'src/unexpand.c')
-rw-r--r--src/unexpand.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/unexpand.c b/src/unexpand.c
index 60a3f1d61..935f98600 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -193,8 +193,7 @@ parse_tab_stops (char const *stops)
}
{
/* Detect overflow. */
- uintmax_t new_t = 10 * tabval + *stops - '0';
- if (UINTMAX_MAX / 10 < tabval || new_t < tabval * 10)
+ if (DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0', UINTMAX_MAX))
{
size_t len = strspn (num_start, "0123456789");
char *bad_num = xstrndup (num_start, len);
@@ -203,7 +202,6 @@ parse_tab_stops (char const *stops)
ok = false;
stops = num_start + len - 1;
}
- tabval = new_t;
}
}
else
@@ -519,10 +517,8 @@ main (int argc, char **argv)
have_tabval = true;
}
{
- uintmax_t new_t = tabval * 10 + c - '0';
- if (UINTMAX_MAX / 10 < tabval || new_t < tabval * 10)
+ if (DECIMAL_DIGIT_ACCUMULATE (tabval, c - '0', UINTMAX_MAX))
error (EXIT_FAILURE, 0, _("tab stop value is too large"));
- tabval = new_t;
}
obsolete_tablist = true;
break;