From: David Mansfield <lkml@dm.cobite.com>
To: Andrea Arcangeli <andrea@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] cvsps support for parsing BK->CVS kernel tree logs
Date: Wed, 19 Mar 2003 17:21:12 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.44.0303191715390.19298-200000@admin> (raw)
In-Reply-To: <20030319213738.GR30541@dualathlon.random>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1356 bytes --]
On Wed, 19 Mar 2003, Andrea Arcangeli wrote:
> I'm downloading the new version now... ;) thanks
>
> > The file is actualy a substring match. If the -f argument matches as a
>
> so it doesn't sound a regex. Being able to specify more than 1 -f would
> be very useful. Either that or regex would do it fine too with
> '^net/core', so as far as I can write stuff like -f
> '^net/core|^net/ipv4' I'm fine.
>
> I also think using match by default in the regex is cleaner. So I can
> write -f 'net/core|net/ipv4' w/o bothering about the ^ because it become
> implicit. And I can still use '.*net/core.*' if I want a substring
> regex. I think substring search will be not common.
>
> But really, any kind of way you implement the 'multiple file' thing is
> fine as far as I can specify more than 1 file ;).
>
Attached is a patch (on top of previous which is on top of 2.0b5) changes
the -f to regex match. The regex is of course slightly slower than
'strstr' but I agree the advantage is worth it.
It differs slightly in syntax (c library regex just works this way):
cvsps -f '^net/core\|^net/ipv4'
^
You must escape the | symbol to separate the regex.
Try it out!
David
--
/==============================\
| David Mansfield |
| lkml@dm.cobite.com |
\==============================/
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2661 bytes --]
? p1
Index: cvsps.c
===================================================================
RCS file: /sulu/cvs_master/cvsps/cvsps.c,v
retrieving revision 4.71
diff -b -u -r4.71 cvsps.c
--- cvsps.c 19 Mar 2003 22:11:09 -0000 4.71
+++ cvsps.c 19 Mar 2003 22:15:26 -0000
@@ -78,7 +78,8 @@
static const char * restrict_author;
static int have_restrict_log;
static regex_t restrict_log;
-static const char * restrict_file;
+static int have_restrict_file;
+static regex_t restrict_file;
static time_t restrict_date_start;
static time_t restrict_date_end;
static const char * restrict_branch;
@@ -108,7 +109,10 @@
static int compare_patch_sets(const void *, const void *);
static int compare_patch_sets_bytime(const void *, const void *);
static int is_revision_metadata(const char *);
+static int patch_set_member_regex(PatchSet * ps, regex_t * reg);
+#if 0
static int patch_set_contains_member(PatchSet *, const char *);
+#endif
static int patch_set_affects_branch(PatchSet *, const char *);
static void do_cvs_diff(PatchSet *);
static PatchSet * create_patch_set();
@@ -574,10 +578,20 @@
if (strcmp(argv[i], "-f") == 0)
{
+ int err;
+
if (++i >= argc)
usage("argument to -f missing", "");
- restrict_file = argv[i++];
+ if ((err = regcomp(&restrict_file, argv[i++], REG_NOSUB)) != 0)
+ {
+ char errbuf[256];
+ regerror(err, &restrict_file, errbuf, 256);
+ usage("bad regex to -f", errbuf);
+ }
+
+ have_restrict_file = 1;
+
continue;
}
@@ -1080,7 +1094,7 @@
if (have_restrict_log && regexec(&restrict_log, ps->descr, 0, NULL, 0) != 0)
return;
- if (restrict_file && !patch_set_contains_member(ps, restrict_file))
+ if (have_restrict_file && !patch_set_member_regex(ps, &restrict_file))
return;
if (restrict_branch && !patch_set_affects_branch(ps, restrict_branch))
@@ -1327,6 +1341,7 @@
return 0;
}
+#if 0
static int patch_set_contains_member(PatchSet * ps, const char * file)
{
struct list_head * next = ps->members.next;
@@ -1336,6 +1351,24 @@
PatchSetMember * psm = list_entry(next, PatchSetMember, link);
if (strstr(psm->file->filename, file))
+ return 1;
+
+ next = next->next;
+ }
+
+ return 0;
+}
+#endif
+
+static int patch_set_member_regex(PatchSet * ps, regex_t * reg)
+{
+ struct list_head * next = ps->members.next;
+
+ while (next != &ps->members)
+ {
+ PatchSetMember * psm = list_entry(next, PatchSetMember, link);
+
+ if (regexec(&restrict_file, psm->file->filename, 0, NULL, 0) == 0)
return 1;
next = next->next;
next prev parent reply other threads:[~2003-03-19 22:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-18 17:41 David Mansfield
2003-03-19 20:11 ` Andrea Arcangeli
2003-03-19 21:19 ` David Mansfield
2003-03-19 21:37 ` Andrea Arcangeli
2003-03-19 22:21 ` David Mansfield [this message]
2003-03-19 22:40 ` Andrea Arcangeli
2003-03-19 22:36 ` Andrea Arcangeli
2003-03-20 0:19 ` David Mansfield
2003-03-20 1:00 ` Andrea Arcangeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.44.0303191715390.19298-200000@admin \
--to=lkml@dm.cobite.com \
--cc=andrea@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®