From owner-p4-projects@FreeBSD.ORG Fri Jun 20 18:33:37 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 771131065674; Fri, 20 Jun 2008 18:33: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 378CE1065671 for ; Fri, 20 Jun 2008 18:33: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 3719B8FC19 for ; Fri, 20 Jun 2008 18:33: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 m5KIXa3F062707 for ; Fri, 20 Jun 2008 18:33:36 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5KIXaqH062705 for perforce@freebsd.org; Fri, 20 Jun 2008 18:33:36 GMT (envelope-from gabor@freebsd.org) Date: Fri, 20 Jun 2008 18:33:36 GMT Message-Id: <200806201833.m5KIXaqH062705@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 143830 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 18:33:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=143830 Change 143830 by gabor@gabor_server on 2008/06/20 18:32:37 - GNU compatibility: return 2 for unbalanced parentheses if -E is specified Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#30 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#30 (text+ko) ==== @@ -188,6 +188,7 @@ add_pattern(char *pat, size_t len) { char *ptr, *st; + int lbr, rbr; /* Workaround for our libc-regex library to match GNU behaviour. Our library rejects '|' with empty subexpressions. Just cut out @@ -237,6 +238,25 @@ strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr)); st = ptr; } + if (Eflag) { + st = pat; + lbr = 0; + while ((ptr = strstr(st, "(")) != NULL) { + if (strstr(st, "\\(") != (ptr - 1)) + lbr++; + st = &(ptr[1]); + } + st = pat; + rbr = 0; + while ((ptr = strstr(st, ")")) != NULL) { + if (strstr(st, "\\)") != (ptr - 1)) + rbr++; + st = &(ptr[1]); + } + if (lbr != rbr) { + errx(2, "parentheses not balanced"); + } + } // printf("PAT %s\n", pat);