? 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;