diff options
author | Jim Meyering <jim@meyering.net> | 1994-12-31 15:28:51 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-12-31 15:28:51 +0000 |
commit | 14842c9a59f38ed2a47a271b8b3c5818e72f5055 (patch) | |
tree | a8d4c5c93e9814cefad2d4ab1c104b147b376771 /src | |
parent | 652d4c6cd636bb09f2cf5282c1ea8d35136fd229 (diff) | |
download | coreutils-14842c9a59f38ed2a47a271b8b3c5818e72f5055.tar.xz |
Use readtoken.
Diffstat (limited to 'src')
-rw-r--r-- | src/factor.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/factor.c b/src/factor.c index f11c388f3..21495c00d 100644 --- a/src/factor.c +++ b/src/factor.c @@ -25,6 +25,10 @@ #include "version.h" #include "long-options.h" #include "error.h" +#include "readtokens.h" + +/* FIXME */ +#define DELIM "\n\t " /* The name this program was run with. */ char *program_name; @@ -101,22 +105,29 @@ print_factors (n) n_factors = factor (n, 64, factors); for (i=0; i<n_factors; i++) - printf ("\t%lu\n", factors[i]); + printf (" %lu\n", factors[i]); + putchar ('\n'); } static void do_stdin () { - char buf[1000]; + token_buffer tokenbuffer; + + init_tokenbuffer (&tokenbuffer); for (;;) { - /* FIXME: Use getline. */ - if (fgets (buf, sizeof buf, stdin) == 0) - exit (0); + long int token_length; + + token_length = readtoken (stdin, DELIM, sizeof (DELIM) - 1, + &tokenbuffer); + if (token_length < 0) + break; /* FIXME: Use strtoul. */ - print_factors ((unsigned long) atoi (buf)); + print_factors ((unsigned long) atoi (tokenbuffer.buffer)); } + free (tokenbuffer.buffer); } void |