summaryrefslogtreecommitdiff
path: root/src/factor.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-09-14 17:25:16 +0000
committerJim Meyering <jim@meyering.net>2003-09-14 17:25:16 +0000
commitb97f8bb5ce2977d9b54904dc4bbc69de7ca3cb2d (patch)
tree4ae0426ef16f4c58ee7f2f32a56021589dab8a74 /src/factor.c
parent589f2ab6ba4291bf55dea42296c691437df8b58c (diff)
downloadcoreutils-b97f8bb5ce2977d9b54904dc4bbc69de7ca3cb2d.tar.xz
(print_factors): Give a separate diagnostic
for numbers that are too large, but otherwise valid.
Diffstat (limited to 'src/factor.c')
-rw-r--r--src/factor.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/factor.c b/src/factor.c
index c364781a1..f27c1c08d 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -1,5 +1,5 @@
/* factor -- print prime factors of n.
- Copyright (C) 86, 1995-2002 Free Software Foundation, Inc.
+ Copyright (C) 86, 1995-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -147,10 +147,14 @@ print_factors (const char *s)
int n_factors;
int i;
char buf[INT_BUFSIZE_BOUND (uintmax_t)];
+ strtol_error err;
- if (xstrtoumax (s, NULL, 10, &n, "") != LONGINT_OK)
+ if ((err = xstrtoumax (s, NULL, 10, &n, "")) != LONGINT_OK)
{
- error (0, 0, _("`%s' is not a valid positive integer"), s);
+ if (err == LONGINT_OVERFLOW)
+ error (0, 0, _("`%s' is too large"), s);
+ else
+ error (0, 0, _("`%s' is not a valid positive integer"), s);
return 1;
}
n_factors = factor (n, MAX_N_FACTORS, factors);