summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-03-17 15:30:00 +0000
committerJim Meyering <jim@meyering.net>2005-03-17 15:30:00 +0000
commitb90c3e46097a222eaeac27941b11968d6933fe47 (patch)
treeb80d066034413189d3e9d35d027f135d21718029
parent183cba6524a35824f9518f445d2e0ee8a4cea1fc (diff)
downloadcoreutils-b90c3e46097a222eaeac27941b11968d6933fe47.tar.xz
(parse_tab_stops, main): Use DECIMAL_DIGIT_ACCUMULATE macro in
place of nearly-equivalent code.
-rw-r--r--src/expand.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/expand.c b/src/expand.c
index 5ea16c07e..4f57c6071 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -172,8 +172,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);
@@ -182,7 +181,6 @@ parse_tab_stops (char const *stops)
ok = false;
stops = num_start + len - 1;
}
- tabval = new_t;
}
}
else
@@ -421,10 +419,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;