summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-08-03 05:59:14 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-08-03 05:59:14 +0000
commita982e48ca367805b9bac3abd0a40f84bfe8a9603 (patch)
treeab56ed2c51416917d26ac0e84670f0f5eae7b460 /src
parent846cb63700c15feb56235bd1bd833e5927ae5463 (diff)
downloadcoreutils-a982e48ca367805b9bac3abd0a40f84bfe8a9603.tar.xz
(cut_fields): Use to_uchar rather than a cast.
(cut_file, main): Use bool for booleans.
Diffstat (limited to 'src')
-rw-r--r--src/cut.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/cut.c b/src/cut.c
index 4cb80fe13..23aed8a32 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -604,7 +604,7 @@ cut_fields (FILE *stream)
/* If the first field extends to the end of line (it is not
delimited) and we are printing all non-delimited lines,
print this one. */
- if ((unsigned char) field_1_buffer[n_bytes - 1] != delim)
+ if (to_uchar (field_1_buffer[n_bytes - 1]) != delim)
{
if (suppress_non_delimited)
{
@@ -688,9 +688,9 @@ cut_stream (FILE *stream)
}
/* Process file FILE to standard output.
- Return 0 if successful, 1 if not. */
+ Return true if successful. */
-static int
+static bool
cut_file (char *file)
{
FILE *stream;
@@ -706,7 +706,7 @@ cut_file (char *file)
if (stream == NULL)
{
error (0, errno, "%s", file);
- return 1;
+ return false;
}
}
@@ -715,22 +715,23 @@ cut_file (char *file)
if (ferror (stream))
{
error (0, errno, "%s", file);
- return 1;
+ return false;
}
if (STREQ (file, "-"))
clearerr (stream); /* Also clear EOF. */
else if (fclose (stream) == EOF)
{
error (0, errno, "%s", file);
- return 1;
+ return false;
}
- return 0;
+ return true;
}
int
main (int argc, char **argv)
{
- int optc, exit_status = 0;
+ int optc;
+ bool ok;
bool delim_specified = false;
char *spec_list_string IF_LINT(= NULL);
@@ -850,10 +851,10 @@ main (int argc, char **argv)
}
if (optind == argc)
- exit_status |= cut_file ("-");
+ ok = cut_file ("-");
else
- for (; optind < argc; optind++)
- exit_status |= cut_file (argv[optind]);
+ for (ok = true; optind < argc; optind++)
+ ok &= cut_file (argv[optind]);
if (range_start_ht)
hash_free (range_start_ht);
@@ -861,8 +862,8 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
{
error (0, errno, "-");
- exit_status = 1;
+ ok = false;
}
- exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}