From owner-p4-projects@FreeBSD.ORG Tue Jun 17 18:54:46 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 320F1106567E; Tue, 17 Jun 2008 18:54:46 +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 E6797106567A for ; Tue, 17 Jun 2008 18:54:45 +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 CE04A8FC20 for ; Tue, 17 Jun 2008 18:54:45 +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 m5HIsjoJ088752 for ; Tue, 17 Jun 2008 18:54:45 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5HIsjMo088750 for perforce@freebsd.org; Tue, 17 Jun 2008 18:54:45 GMT (envelope-from gabor@freebsd.org) Date: Tue, 17 Jun 2008 18:54:45 GMT Message-Id: <200806171854.m5HIsjMo088750@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 143658 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 18:54:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=143658 Change 143658 by gabor@gabor_server on 2008/06/17 18:54:12 - GNU compatibility: Add workaround to allow '|' with empty subexpressions. This is done by cutting off those parts, e.g. "(|a|b||c|)" will be "(a|b|c)" Reported by: dougb Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#22 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#22 (text+ko) ==== @@ -187,6 +187,18 @@ static void add_pattern(char *pat, size_t len) { + char *ptr; + +/* Workaround for our libc-regex library to match GNU behaviour. + Our library rejects '|' with empty subexpressions. Just cut out + those parts, e.g. "(|a|b||c|)" will be "(a|b|c)" */ + while ((ptr = strstr(pat, "|)")) != NULL) + strlcpy(ptr, &(ptr[1]), strlen(pat) - strlen(ptr)); + while ((ptr = strstr(pat, "(|")) != NULL) + strlcpy(&(ptr[1]), &(ptr[2]), strlen(pat) - strlen(ptr) - 1); + while ((ptr = strstr(pat, "||")) != NULL) + strlcpy(&(ptr[1]), &(ptr[2]), strlen(pat) - strlen(ptr) - 1); + if (!xflag && (len == 0 || matchall)) { matchall = 1; return;