--- grep.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/grep.c b/grep.c index 269ec92..29110b8 100644 --- a/grep.c +++ b/grep.c _AT_@ -8,8 +8,6 @@ #include "text.h" #include "util.h" -enum { Match = 0, NoMatch = 1, Error = 2 }; - static void addpattern(const char *); static bool grep(FILE *, const char *); _AT_@ -27,7 +25,7 @@ static struct plist { static void usage(void) { - enprintf(Error, "usage: %s [-Ecilnqv] [-e pattern] pattern [files...]\n", argv0); + eprintf("usage: %s [-Ecilnqv] [-e pattern] pattern [files...]\n", argv0); } int _AT_@ -78,7 +76,7 @@ main(int argc, char *argv[]) char buf[BUFSIZ]; regerror(n, &pnode->preg, buf, sizeof buf); - enprintf(Error, "invalid pattern: %s\n", buf); + eprintf("invalid pattern: %s\n", buf); } } many = (argc > 1); _AT_@ -87,7 +85,7 @@ main(int argc, char *argv[]) } else { for(i = 0; i < argc; i++) { if(!(fp = fopen(argv[i], "r"))) - enprintf(Error, "fopen %s:", argv[i]); + eprintf("fopen %s:", argv[i]); if(grep(fp, argv[i])) match = true; fclose(fp); _AT_@ -101,7 +99,7 @@ main(int argc, char *argv[]) free(pnode); pnode = tmp; } - return match ? Match : NoMatch; + return match ? EXIT_SUCCESS : EXIT_FAILURE; } void _AT_@ -142,7 +140,7 @@ grep(FILE *fp, const char *str) puts(str); goto end; case 'q': - exit(Match); + exit(EXIT_SUCCESS); default: if(many) printf("%s:", str); _AT_@ -158,7 +156,7 @@ grep(FILE *fp, const char *str) printf("%ld\n", c); end: if(ferror(fp)) - enprintf(Error, "%s: read error:", str); + eprintf("%s: read error:", str); free(buf); return match; } -- 1.8.3.2 --Multipart=_Sun__11_May_2014_23_20_26_+0200_YSoI.6f/IFMOWHmz--Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Sun May 11 2014 - 23:36:03 CEST