From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10221 invoked by alias); 6 Jun 2008 13:45:07 -0000 Received: (qmail 10210 invoked by uid 22791); 6 Jun 2008 13:45:05 -0000 X-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,SPF_PASS X-Spam-Check-By: sourceware.org Received: from gv-out-0910.google.com (HELO gv-out-0910.google.com) (216.239.58.185) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 06 Jun 2008 13:44:46 +0000 Received: by gv-out-0910.google.com with SMTP id n8so341254gve.39 for ; Fri, 06 Jun 2008 06:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=oVt2klmBf/KuxpiuEwOkaaLgKeBOaU0ErEjf9UWyW6U=; b=YlQU0zTiWQGKcrlgoevNCtuy1rouFOfOZYzqL/KCkVLhK9giAAisHBnouj9j2YakHv 1V8MHFpjy7jpBLXkOdPDlIZiQMJfp1Bo1vyyjCrQewl9PAo73W5XIzaDrCgc0V7tROFq sOErttZZg5j9+WIb2GtBxi/F86D7UHCNIT3BE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=hkcRB4HMwosgs4Wlds+9BVMlo4MGlLSXWZWaY386p+y91bdzt963P3XWpWNU4iMIPu nkJ9jgS/eXKF2qjPkOO8cYdwn7JLsuOBLZ4WchnH85+D2fvcO1OoszLjtbBfkfPcVCff 1YsxfGSzpmvh8dVusA6nsLXy0z7NUl+6x5W4g= Received: by 10.78.163.8 with SMTP id l8mr76951hue.62.1212759882796; Fri, 06 Jun 2008 06:44:42 -0700 (PDT) Received: from ?127.0.0.1? ( [194.154.66.219]) by mx.google.com with ESMTPS id 36sm5166050hub.59.2008.06.06.06.44.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 06 Jun 2008 06:44:40 -0700 (PDT) Message-ID: <48493BA7.1030502@gmail.com> Date: Fri, 06 Jun 2008 13:45:00 -0000 From: Serj Kalichev User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: patchutils-list@sourceware.org Subject: -X and -I options implementation Content-Type: multipart/mixed; boundary="------------050708060009020106080902" X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact patchutils-list-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: patchutils-list-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00000.txt.bz2 This is a multi-part message in MIME format. --------------050708060009020106080902 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 3023 Hello Consider this patch that implements -X and -I options for filterdiff utility. --- orig/patchutils-0.2.31/doc/filterdiff.1 2005-06-13 21:41:07.000000000 +0400 +++ work/patchutils-0.2.31/doc/filterdiff.1 2008-06-06 15:48:48.000000000 +0400 @@ -61,10 +61,18 @@ You can use both unified and context for Include only files matching \fIPATTERN\fR\&. All other lines in the input are suppressed\&. .TP +\fB\-I\fR \fIFILE\fR +Include only files that match any \fIPATTERN\fR in \fIFILE\fR\&. All other lines in the input are suppressed\&. + +.TP \fB\-x\fR \fIPATTERN\fR Exclude files matching \fIPATTERN\fR\&. All other lines in the input are displayed\&. .TP +\fB\-X\fR \fIFILE\fR +Exclude files that match any \fIPATTERN\fR in \fIFILE\fR\&. All other lines in the input are displayed\&. + +.TP \fB\-p\fR \fIn\fR When matching, ignore the first \fIn\fR components of the pathname\&. --- orig/patchutils-0.2.31/src/filterdiff.c 2004-11-29 18:14:50.000000000 +0300 +++ work/patchutils-0.2.31/src/filterdiff.c 2008-06-06 15:54:35.000000000 +0400 @@ -1012,7 +1012,9 @@ static int filterdiff (FILE *f, const ch const char * syntax_str = "Options:\n" " -x PAT exclude files matching PAT\n" +" -X FILE exclude files that match any pattern in FILE\n" " -i PAT include only files matching PAT\n" +" -I FILE include only files that match any pattern in FILE\n" " --hunks=H, -# H\n" " include only hunks in range H\n" " --lines=L include only hunks with (original) lines in range L\n" @@ -1309,9 +1311,15 @@ int main (int argc, char *argv[]) case 'x': patlist_add (&pat_exclude, optarg); break; + case 'X': + patlist_add_file (&pat_exclude, optarg); + break; case 'i': patlist_add (&pat_include, optarg); break; + case 'I': + patlist_add_file (&pat_include, optarg); + break; case 'z': unzip = 1; break; --- orig/patchutils-0.2.31/src/util.c 2004-06-07 18:07:46.000000000 +0400 +++ work/patchutils-0.2.31/src/util.c 2008-06-06 15:59:25.000000000 +0400 @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ @@ -109,6 +110,28 @@ void patlist_add(struct patlist **dst, c *dst = item; } +void patlist_add_file(struct patlist **dst, const char *fn) +{ + FILE *fd; + char buf[PATH_MAX]; + size_t len; + + fd = fopen (fn, "r"); + if (NULL == fd) + return; + + while (fgets (buf, sizeof(buf), fd)) { + len = strlen(buf); + if (len <= 1) /* only '\n' presents */ + continue; + /* Remove '\n' from pattern */ + if ('\n' == buf[len - 1]) + buf[len - 1] = '\0'; + patlist_add (dst, buf); + } + fclose (fd); +} + int patlist_match(struct patlist *list, const char *s) { while (list) { --------------050708060009020106080902 Content-Type: text/x-diff; name="patchutils-0.2.31-XI.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patchutils-0.2.31-XI.patch" Content-length: 2706 --- orig/patchutils-0.2.31/doc/filterdiff.1 2005-06-13 21:41:07.000000000 +0400 +++ work/patchutils-0.2.31/doc/filterdiff.1 2008-06-06 15:48:48.000000000 +0400 @@ -61,10 +61,18 @@ You can use both unified and context for Include only files matching \fIPATTERN\fR\&. All other lines in the input are suppressed\&. .TP +\fB\-I\fR \fIFILE\fR +Include only files that match any \fIPATTERN\fR in \fIFILE\fR\&. All other lines in the input are suppressed\&. + +.TP \fB\-x\fR \fIPATTERN\fR Exclude files matching \fIPATTERN\fR\&. All other lines in the input are displayed\&. .TP +\fB\-X\fR \fIFILE\fR +Exclude files that match any \fIPATTERN\fR in \fIFILE\fR\&. All other lines in the input are displayed\&. + +.TP \fB\-p\fR \fIn\fR When matching, ignore the first \fIn\fR components of the pathname\&. --- orig/patchutils-0.2.31/src/filterdiff.c 2004-11-29 18:14:50.000000000 +0300 +++ work/patchutils-0.2.31/src/filterdiff.c 2008-06-06 15:54:35.000000000 +0400 @@ -1012,7 +1012,9 @@ static int filterdiff (FILE *f, const ch const char * syntax_str = "Options:\n" " -x PAT exclude files matching PAT\n" +" -X FILE exclude files that match any pattern in FILE\n" " -i PAT include only files matching PAT\n" +" -I FILE include only files that match any pattern in FILE\n" " --hunks=H, -# H\n" " include only hunks in range H\n" " --lines=L include only hunks with (original) lines in range L\n" @@ -1309,9 +1311,15 @@ int main (int argc, char *argv[]) case 'x': patlist_add (&pat_exclude, optarg); break; + case 'X': + patlist_add_file (&pat_exclude, optarg); + break; case 'i': patlist_add (&pat_include, optarg); break; + case 'I': + patlist_add_file (&pat_include, optarg); + break; case 'z': unzip = 1; break; --- orig/patchutils-0.2.31/src/util.c 2004-06-07 18:07:46.000000000 +0400 +++ work/patchutils-0.2.31/src/util.c 2008-06-06 15:59:25.000000000 +0400 @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ @@ -109,6 +110,28 @@ void patlist_add(struct patlist **dst, c *dst = item; } +void patlist_add_file(struct patlist **dst, const char *fn) +{ + FILE *fd; + char buf[PATH_MAX]; + size_t len; + + fd = fopen (fn, "r"); + if (NULL == fd) + return; + + while (fgets (buf, sizeof(buf), fd)) { + len = strlen(buf); + if (len <= 1) /* only '\n' presents */ + continue; + /* Remove '\n' from pattern */ + if ('\n' == buf[len - 1]) + buf[len - 1] = '\0'; + patlist_add (dst, buf); + } + fclose (fd); +} + int patlist_match(struct patlist *list, const char *s) { while (list) { --------------050708060009020106080902--