summaryrefslogtreecommitdiff
path: root/src/grep.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-11-05 15:01:57 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2019-11-05 15:02:23 -0800
commit50312b72f570609abb85fc0add7554be0ac8721e (patch)
tree86f500ce833e5ed155bf6d5b97ac6e5bf9571a91 /src/grep.c
parentbacb70670e9ebcc0072ff50ab4888aca56ae0108 (diff)
downloadgrep-50312b72f570609abb85fc0add7554be0ac8721e.tar.gz
grep: simplify previous patch
* src/grep.c (main): Use an int rather than an enum for a local var, which is overkill here.
Diffstat (limited to 'src/grep.c')
-rw-r--r--src/grep.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/grep.c b/src/grep.c
index 142bc2ff..7f3ada1f 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2432,13 +2432,9 @@ main (int argc, char **argv)
exit_failure = EXIT_TROUBLE;
initialize_main (&argc, &argv);
- /* Command-line options for filename output. */
- enum
- {
- NO_FILENAME = -1, /* --no-filename (-h) */
- FILENAME_DEFAULT, /* Neither option is specified. */
- WITH_FILENAME, /* --with-filename (-H) */
- } filename_option = FILENAME_DEFAULT;
+ /* Which command-line options have been specified for filename output.
+ -1 for -h, 1 for -H, 0 for neither. */
+ int filename_option = 0;
eolbyte = '\n';
filename_mask = ~0;
@@ -2521,7 +2517,7 @@ main (int argc, char **argv)
break;
case 'H':
- filename_option = WITH_FILENAME;
+ filename_option = 1;
break;
case 'I':
@@ -2613,7 +2609,7 @@ main (int argc, char **argv)
break;
case 'h':
- filename_option = NO_FILENAME;
+ filename_option = -1;
break;
case 'i':
@@ -2904,11 +2900,9 @@ main (int argc, char **argv)
== out_invert);
int num_operands = argc - optind;
- out_file = (filename_option < FILENAME_DEFAULT
- ? 0
- : filename_option == FILENAME_DEFAULT && num_operands <= 1
+ out_file = (filename_option == 0 && num_operands <= 1
? - (directories == RECURSE_DIRECTORIES)
- : 1);
+ : 0 <= filename_option);
if (binary)
xset_binary_mode (STDOUT_FILENO, O_BINARY);