* -X and -I options implementation
@ 2008-06-06 13:45 Serj Kalichev
2008-06-11 15:46 ` Tim Waugh
0 siblings, 1 reply; 2+ messages in thread
From: Serj Kalichev @ 2008-06-06 13:45 UTC (permalink / raw)
To: patchutils-list
[-- Attachment #1: Type: text/plain, Size: 3023 bytes --]
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 <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <limits.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#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) {
[-- Attachment #2: patchutils-0.2.31-XI.patch --]
[-- Type: text/x-diff, Size: 2706 bytes --]
--- 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 <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <limits.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#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) {
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: -X and -I options implementation
2008-06-06 13:45 -X and -I options implementation Serj Kalichev
@ 2008-06-11 15:46 ` Tim Waugh
0 siblings, 0 replies; 2+ messages in thread
From: Tim Waugh @ 2008-06-11 15:46 UTC (permalink / raw)
To: Serj Kalichev; +Cc: patchutils-list
[-- Attachment #1: Type: text/plain, Size: 200 bytes --]
On Fri, 2008-06-06 at 17:29 +0400, Serj Kalichev wrote:
> Hello
> Consider this patch that implements -X and -I options for filterdiff
> utility.
Thanks. I've applied this now.
Tim.
*/
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-11 15:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-06 13:45 -X and -I options implementation Serj Kalichev
2008-06-11 15:46 ` Tim Waugh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).