summaryrefslogtreecommitdiff
path: root/src/cut.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-03-17 14:35:42 +0000
committerJim Meyering <jim@meyering.net>2005-03-17 14:35:42 +0000
commit183cba6524a35824f9518f445d2e0ee8a4cea1fc (patch)
tree6e15d8d0f234c31492ef931867ecf3b0670f6d1b /src/cut.c
parenta26f414348925cfe9732ed044afa30a09768068d (diff)
downloadcoreutils-183cba6524a35824f9518f445d2e0ee8a4cea1fc.tar.xz
(set_fields): Use DECIMAL_DIGIT_ACCUMULATE macro in
place of nearly-equivalent code.
Diffstat (limited to 'src/cut.c')
-rw-r--r--src/cut.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/cut.c b/src/cut.c
index f88bba04e..f74093055 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -447,7 +447,6 @@ set_fields (const char *fieldstr)
}
else if (ISDIGIT (*fieldstr))
{
- size_t new_v;
/* Record beginning of digit string, in case we have to
complain about it. */
static char const *num_start;
@@ -456,10 +455,9 @@ set_fields (const char *fieldstr)
in_digits = true;
/* Detect overflow. */
- new_v = 10 * value + *fieldstr - '0';
- if (SIZE_MAX / 10 < value || new_v < value * 10)
+ if (DECIMAL_DIGIT_ACCUMULATE (value, *fieldstr - '0', SIZE_MAX))
{
- /* In case the user specified -c4294967296-22,
+ /* In case the user specified -c4294967296,22,
complain only about the first number. */
/* Determine the length of the offending number. */
size_t len = strspn (num_start, "0123456789");
@@ -473,7 +471,6 @@ set_fields (const char *fieldstr)
free (bad_num);
exit (EXIT_FAILURE);
}
- value = new_v;
fieldstr++;
}