From owner-p4-projects@FreeBSD.ORG Tue Jun 17 16:55:30 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 56D891065677; Tue, 17 Jun 2008 16:55:30 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 184131065673 for ; Tue, 17 Jun 2008 16:55:30 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 00A708FC1B for ; Tue, 17 Jun 2008 16:55:30 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m5HGtTjo076256 for ; Tue, 17 Jun 2008 16:55:29 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5HGtTOD076254 for perforce@freebsd.org; Tue, 17 Jun 2008 16:55:29 GMT (envelope-from gabor@freebsd.org) Date: Tue, 17 Jun 2008 16:55:29 GMT Message-Id: <200806171655.m5HGtTOD076254@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 143654 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jun 2008 16:55:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=143654 Change 143654 by gabor@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); }