PERFORCE change 144946 for review
Gabor Kovesdan
gabor at FreeBSD.org
Wed Jul 9 15:05:29 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144946
Change 144946 by gabor at gabor_server on 2008/07/09 15:05:16
- Fix --exclude and --include with proper basename() calls
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#64 edit
.. //depot/projects/soc2008/gabor_textproc/grep/util.c#57 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#64 (text+ko) ====
@@ -43,6 +43,7 @@
#include <err.h>
#include <errno.h>
#include <getopt.h>
+#include <libgen.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
@@ -260,6 +261,7 @@
--len;
epattern[epatterns] = grep_malloc(len + 1);
memcpy(epattern[epatterns], pat, len);
+ epattern[epatterns][len] = '\0';
++epatterns;
}
@@ -511,14 +513,14 @@
usage();
inclflag = 1;
exclflag = 0;
- add_epattern(optarg, strlen(optarg));
+ add_epattern(basename(optarg), strlen(basename(optarg)));
break;
case R_EXCLUDE_OPT:
if (dirbehave != DIR_RECURSE)
usage();
inclflag = 0;
exclflag = 1;
- add_epattern(optarg, strlen(optarg));
+ add_epattern(basename(optarg), strlen(basename(optarg)));
break;
case HELP_OPT:
default:
==== //depot/projects/soc2008/gabor_textproc/grep/util.c#57 (text+ko) ====
@@ -43,6 +43,7 @@
#include <errno.h>
#include <fnmatch.h>
#include <fts.h>
+#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -97,14 +98,14 @@
if (exclflag) {
ok = 1;
for (i = 0; i < epatterns; ++i)
- if (fnmatch(epattern[i], p->fts_path, 0) == 0) {
+ if (fnmatch(epattern[i], basename(p->fts_path), 0) == 0) {
ok = 0;
break;
}
} else if (inclflag) {
ok = 0;
for (i = 0; i < epatterns; i++)
- if (fnmatch(epattern[i], p->fts_path, 0) == 0) {
+ if (fnmatch(epattern[i], basename(p->fts_path), 0) == 0) {
ok = 1;
break;
}
More information about the p4-projects
mailing list