From owner-p4-projects@FreeBSD.ORG Fri Jun 20 11:49:38 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E7345106566C; Fri, 20 Jun 2008 11:49:37 +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 A9AB01065676 for ; Fri, 20 Jun 2008 11:49:37 +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 9A6A78FC1E for ; Fri, 20 Jun 2008 11:49:37 +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 m5KBnbXv092147 for ; Fri, 20 Jun 2008 11:49:37 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5KBnb63092145 for perforce@freebsd.org; Fri, 20 Jun 2008 11:49:37 GMT (envelope-from gabor@freebsd.org) Date: Fri, 20 Jun 2008 11:49:37 GMT Message-Id: <200806201149.m5KBnb63092145@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 143816 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: Fri, 20 Jun 2008 11:49:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=143816 Change 143816 by gabor@gabor_server on 2008/06/20 11:48:57 - Don't grep directories as standard files when -R is given Reported by: Michael Plass Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/util.c#29 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#29 (text+ko) ==== @@ -66,7 +66,6 @@ FTS *fts; FTSENT *p; int c, fts_flags; - struct stat *finfo = 0; c = fts_flags = 0; @@ -91,19 +90,26 @@ case FTS_DP: break; default: - if (Dflag) { + if (Dflag || Rflag) { + struct stat *finfo; + if (!(finfo = malloc(sizeof(struct stat)))) err(2, NULL); if (stat(p->fts_path, finfo) == -1) err(2, NULL); - if (S_ISBLK(finfo->st_mode) || + + if (Dflag && (S_ISBLK(finfo->st_mode) || S_ISCHR(finfo->st_mode) || S_ISFIFO(finfo->st_mode) || - S_ISSOCK(finfo->st_mode)) { + S_ISSOCK(finfo->st_mode))) { free(finfo); break; - } else + } + if (Rflag && S_ISDIR(finfo->st_mode)) { free(finfo); + break; + } + free(finfo); } c += procfile(p->fts_path); break;