summaryrefslogtreecommitdiff
path: root/grep-dctrl.c
diff options
context:
space:
mode:
authorAntti-Juhani Kaijanaho <ajk@debian.org>2006-04-02 22:03:18 +0100
committerAntti-Juhani Kaijanaho <ajk@debian.org>2006-04-02 22:03:18 +0100
commit5be85a5f0482e3b23970c895f5f1b8c304c7cbe7 (patch)
tree73dd2ff07c9f381473ec72c177379622cda8f793 /grep-dctrl.c
parenta682d6a6368ae5779d4109b5e6d9b36b60005947 (diff)
downloaddctrl-tools-5be85a5f0482e3b23970c895f5f1b8c304c7cbe7.tar.gz
grep-dctrl.{c,1.cp}: Add the option '--pattern'
Closes: #359318 (Unable to specify a pattern that begins with '-') Reported by James Vega <jamessan@debian.org>
Diffstat (limited to 'grep-dctrl.c')
-rw-r--r--grep-dctrl.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/grep-dctrl.c b/grep-dctrl.c
index cc3661f..ba836f9 100644
--- a/grep-dctrl.c
+++ b/grep-dctrl.c
@@ -57,7 +57,8 @@ enum {
OPT_GT,
OPT_GE,
OPT_MMAP,
- OPT_IGN_ERRS
+ OPT_IGN_ERRS,
+ OPT_PATTERN
};
#undef BANNER
@@ -134,6 +135,7 @@ static struct argp_option options[] = {
{ "silent", OPT_SILENT, 0, 0, N_("Do no output to stdout.") },
{ "mmap", OPT_MMAP, 0, 0, N_("Attempt mmapping input files") },
{ "ignore-parse-errors", OPT_IGN_ERRS, 0, 0, N_("Ignore parse errors") },
+ { "pattern", OPT_PATTERN, N_("PATTERN"), 0, N_("Specify the pattern to search for") },
{ 0 }
};
@@ -500,6 +502,19 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
debug_message("parse_opt: ignore-parse-errors", 0);
args->ignore_errors = 1;
break;
+ case OPT_PATTERN:
+ debug_message("parse_opt: pattern", 0);
+ atom = ENTER_ATOM;
+ if (atom->pat != 0) {
+ message(L_FATAL, _("Multiple patterns for the same "
+ "atom are not allowed"), 0);
+ fail();
+ }
+ atom->patlen = strlen(arg);
+ atom->pat = malloc(atom->patlen+1);
+ if (atom->pat == 0) fatal_enomem(0);
+ strcpy((char*)atom->pat, arg);
+ break;
case ARGP_KEY_ARG:
debug_message("parse_opt: argument", 0);
redo: