From c28f94c70573ba0971b0455470f77e95e582079a Mon Sep 17 00:00:00 2001 From: Antti-Juhani Kaijanaho Date: Sat, 28 Jan 2006 21:12:39 +0100 Subject: Import 1.101 --- debian/changelog | 13 +++++++++++++ fieldtrie.h | 3 +++ grep-dctrl.c | 23 ++++++++++++++--------- paragraph.c | 4 ++++ rc.c | 1 + 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index c0f19d1..0d8f9aa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +grep-dctrl (1.101) unstable; urgency=low + + * fieldtrie.h (fieldtrie_count): New function. + * paragraph.c (para_parse_next): Clear the fields too. + Closes: #205373, #205376, #205295. + * grep-dctrl.c (main): If no predicate is given, bail out. + Closes: #205511. + * grep-dctrl.c (dump_args): Use C99 %zi and not %i to print out size_t + (size mismatch on 64-bit archs). + * rc.c: #include "util.h" + + -- Antti-Juhani Kaijanaho Fri, 15 Aug 2003 21:37:30 +0300 + grep-dctrl (1.100) unstable; urgency=low * A (nearly) full rewrite (bumped minor version number to match) diff --git a/fieldtrie.h b/fieldtrie.h index 7ae7d8c..93bf88c 100644 --- a/fieldtrie.h +++ b/fieldtrie.h @@ -49,4 +49,7 @@ size_t fieldtrie_lookup(fieldtrie_t *, char const *, size_t n); void fieldtrie_clear(fieldtrie_t *); +static inline +size_t fieldtrie_count(fieldtrie_t * ft) { return ft->nextfree; } + #endif /* FIELDTRIE_H */ diff --git a/grep-dctrl.c b/grep-dctrl.c index e2b7e53..ae5a4ea 100644 --- a/grep-dctrl.c +++ b/grep-dctrl.c @@ -413,17 +413,17 @@ static void dump_args(struct arguments * args) size_t i; assert(args->state == STATE_FINISHED); assert(args->top == 0); - printf("num_atoms = %i\n", args->p.num_atoms); + printf("num_atoms = %zi\n", args->p.num_atoms); for (i = 0; i < args->p.num_atoms; i++) { - printf("atoms[%i].field_name = %s\n", i, args->p.atoms[i].field_name); - printf("atoms[%i].mode = %i\n", i, args->p.atoms[i].mode); - printf("atoms[%i].ignore_case = %i\n", i, args->p.atoms[i].ignore_case); - printf("atoms[%i].pat = %s\n", i, args->p.atoms[i].pat); + printf("atoms[%zi].field_name = %s\n", i, args->p.atoms[i].field_name); + printf("atoms[%zi].mode = %i\n", i, args->p.atoms[i].mode); + printf("atoms[%zi].ignore_case = %i\n", i, args->p.atoms[i].ignore_case); + printf("atoms[%zi].pat = %s\n", i, args->p.atoms[i].pat); } - printf("proglen = %i\n", args->p.proglen); + printf("proglen = %zi\n", args->p.proglen); for (i = 0; i < args->p.proglen; i++) { int op = args->p.program[i]; - printf("program[%i] = ", i); + printf("program[%zi] = ", i); switch (op) { case I_NOP: puts("NOP"); break; case I_NEG: puts("NEG"); break; @@ -433,9 +433,9 @@ static void dump_args(struct arguments * args) printf("PUSH(%i)\n", op - I_PUSH(0)); } } - printf("num_fnames = %i\n", args->num_fnames); + printf("num_fnames = %zi\n", args->num_fnames); for (i = 0; i < args->num_fnames; i++) { - printf("fname[%i] = %s\n", i, args->fname[i]); + printf("fname[%zi] = %s\n", i, args->fname[i]); } } @@ -453,6 +453,11 @@ int main (int argc, char * argv[]) banner(true); if (debug_optparse) { dump_args(&args); return 0; } + + if (args.p.num_atoms == 0) { + message(L_FATAL, "a predicate is required", 0); + exit(EXIT_FAILURE); + } if (args.short_descr && !args.description_selected) { if (args.num_show_fields >= MAX_FIELDS) { diff --git a/paragraph.c b/paragraph.c index a6d1145..a777bcc 100644 --- a/paragraph.c +++ b/paragraph.c @@ -33,6 +33,10 @@ void para_parse_next(para_t * para) { debug_message("para_parse_next", 0); para->start = para->end; + for (size_t i = 0; i < fieldtrie_count(para->trie); i++) { + para->fields[i].start = 0; + para->fields[i].end = 0; + } fsaf_invalidate(para->fp, para->start); register enum { START, FIELD_NAME, BODY, BODY_NEWLINE, BODY_SKIPBLANKS, END } state = START; diff --git a/rc.c b/rc.c index 4d5f308..1e973e1 100644 --- a/rc.c +++ b/rc.c @@ -38,6 +38,7 @@ #include "msg.h" #include "rc.h" #include "strutil.h" +#include "util.h" const char * find_ifile_by_exename(const char * exename, const char * rcfname) -- cgit v1.2.3