From: Jim Meyering Date: Wed, 21 Apr 1999 03:18:23 +0000 (+0000) Subject: : Include this, not xstrtoul.h. X-Git-Tag: SH-UTILS-1_16g~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf6eaeb03b16e0369b88a694efc459c69f7e66af;p=platform%2Fupstream%2Fcoreutils.git : Include this, not xstrtoul.h. : Include. Use uintmax_t in place of unsigned long. Use human_readable to convert to strings for printing. --- diff --git a/src/factor.c b/src/factor.c index 5fa5f73..1ea7cec 100644 --- a/src/factor.c +++ b/src/factor.c @@ -28,8 +28,9 @@ #include "system.h" #include "long-options.h" #include "error.h" -#include "xstrtoul.h" +#include "human.h" #include "readtokens.h" +#include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "factor" @@ -76,9 +77,9 @@ Print factors of each NUMBER; read standard input with no arguments.\n\ /* FIXME: comment */ static int -factor (long unsigned int n0, int max_n_factors, long unsigned int *factors) +factor (uintmax_t n0, int max_n_factors, uintmax_t *factors) { - register unsigned long n = n0, d, q; + register uintmax_t n = n0, d, q; int n_factors = 0; if (n < 1) @@ -128,20 +129,21 @@ factor (long unsigned int n0, int max_n_factors, long unsigned int *factors) static int print_factors (const char *s) { - unsigned long int factors[MAX_N_FACTORS]; - unsigned long n; + uintmax_t factors[MAX_N_FACTORS]; + uintmax_t n; int n_factors; int i; + char buf[LONGEST_HUMAN_READABLE + 1]; - if (xstrtoul (s, NULL, 10, &n, "") != LONGINT_OK) + if (xstrtoumax (s, NULL, 10, &n, "") != LONGINT_OK) { error (0, 0, _("`%s' is not a valid positive integer"), s); return 1; } n_factors = factor (n, MAX_N_FACTORS, factors); - printf ("%lu:", n); + printf ("%s:", human_readable (n, buf, 1, 1)); for (i = 0; i < n_factors; i++) - printf (" %lu", factors[i]); + printf (" %s", human_readable (factors[i], buf, 1, 1)); putchar ('\n'); return 0; }