PERFORCE change 143654 for review
Gabor Kovesdan
gabor at FreeBSD.org
Tue Jun 17 16:55:30 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143654
Change 143654 by gabor at gabor_server on 2008/06/17 16:54:31
- GNU compatibility: - should represent stdin as a command line
argument
- GNU compatibility: return the proper status codes in all cases
regarding the -q flag, the matched texts and the inexisting files
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#21 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.h#16 edit
.. //depot/projects/soc2008/gabor_textproc/grep/util.c#27 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#21 (text+ko) ====
@@ -113,6 +113,7 @@
int first = 1; /* flag whether we are processing the first match */
int prev; /* flag whether or not the previous line matched */
int tail; /* lines left to print */
+int notfound; /* file not found */
struct patfile {
const char *pf_file;
@@ -550,5 +551,15 @@
}
c+= procfile(*argv);
}
- exit(!c);
+ if (c) {
+ if (notfound && qflag)
+ exit(0);
+ else if (notfound)
+ exit (2);
+ else
+ exit (0);
+ } else if (notfound)
+ exit(2);
+ else
+ exit(1);
}
==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#16 (text+ko) ====
@@ -68,7 +68,7 @@
extern char *color, *label;
extern int binbehave;
-extern int first, prev, matchall, patterns, tail;
+extern int first, prev, matchall, patterns, tail, notfound;
extern char **pattern;
extern struct fastgrep *fg_pattern;
extern regex_t *r_pattern;
==== //depot/projects/soc2008/gabor_textproc/grep/util.c#27 (text+ko) ====
@@ -125,7 +125,7 @@
if (mflag && (mcount <= 0))
return (0);
- if (fn == NULL) {
+ if (fn == NULL || (strcmp(fn, "-") == 0)) {
if (label != NULL)
fn = label;
else
@@ -138,7 +138,7 @@
if (!sflag)
warn("%s", fn);
if (errno == ENOENT)
- exit (2);
+ notfound++;
return (0);
}
More information about the p4-projects
mailing list