Date: Wed, 9 Jul 2008 15:05:29 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 144946 for review Message-ID: <200807091505.m69F5Thu081877@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144946 Change 144946 by gabor@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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807091505.m69F5Thu081877>