X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=dict%2Fdicttest.c;h=849111e54e5ad740c35e073d4afd44c46616df3d;hb=3e97ca3e99068d83691ad6d43d53dd9f1f316889;hp=5d97bb28ced4aa867eafec8c021932c0f6e3fcd1;hpb=d07818ca27f4e0efc9683148cb5d9891d34b9495;p=idzebra-moved-to-github.git diff --git a/dict/dicttest.c b/dict/dicttest.c index 5d97bb2..849111e 100644 --- a/dict/dicttest.c +++ b/dict/dicttest.c @@ -4,7 +4,15 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dicttest.c,v $ - * Revision 1.18 1996-02-01 20:39:52 adam + * Revision 1.20 1996-03-20 09:35:16 adam + * Function dict_lookup_grep got extra parameter, init_pos, which marks + * from which position in pattern approximate pattern matching should occur. + * + * Revision 1.19 1996/02/02 13:43:50 adam + * The public functions simply use char instead of Dict_char to represent + * search strings. Dict_char is used internally only. + * + * Revision 1.18 1996/02/01 20:39:52 adam * Bug fix: insert didn't work on 8-bit characters due to unsigned char * compares in dict_strcmp (strcmp) and signed Dict_char. Dict_char is * unsigned now. @@ -79,7 +87,7 @@ static Dict dict; static int look_hits; -static int grep_handle (Dict_char *name, const char *info, void *client) +static int grep_handle (char *name, const char *info, void *client) { look_hits++; printf ("%s\n", name); @@ -93,6 +101,7 @@ int main (int argc, char **argv) const char *base = NULL; int do_delete = 0; int range = -1; + int srange = 0; int rw = 0; int infosize = 4; int cache = 10; @@ -109,11 +118,12 @@ int main (int argc, char **argv) if (argc < 2) { fprintf (stderr, "usage:\n " - " %s [-d] [-r n] [-u] [-g pat] [-s n] [-v n] [-i f] [-w]" - " [-c n] base file\n\n", + " %s [-d] [-r n] [-p n] [-u] [-g pat] [-s n] [-v n] [-i f]" + " [-w] [-c n] base file\n\n", prog); fprintf (stderr, " -d delete instead of insert\n"); fprintf (stderr, " -r n set regular match range\n"); + fprintf (stderr, " -p n set regular match start range\n"); fprintf (stderr, " -u report if keys change during insert\n"); fprintf (stderr, " -g p try pattern n (see -r)\n"); fprintf (stderr, " -s n set info size to n (instead of 4)\n"); @@ -123,7 +133,7 @@ int main (int argc, char **argv) fprintf (stderr, " -c n cache size (number of pages)\n"); exit (1); } - while ((ret = options ("dr:ug:s:v:i:wc:", argv, argc, &arg)) != -2) + while ((ret = options ("dr:p:ug:s:v:i:wc:", argv, argc, &arg)) != -2) { if (ret == 0) { @@ -147,6 +157,10 @@ int main (int argc, char **argv) { range = atoi (arg); } + else if (ret == 'p') + { + srange = atoi (arg); + } else if (ret == 'u') { unique = 1; @@ -264,7 +278,7 @@ int main (int argc, char **argv) { look_hits = 0; dict_lookup_grep (dict, ipf_ptr, range, NULL, - &max_pos, grep_handle); + &max_pos, srange, grep_handle); if (look_hits) no_of_hits++; else @@ -284,7 +298,7 @@ int main (int argc, char **argv) range = 0; logf (LOG_LOG, "Grepping '%s'", grep_pattern); dict_lookup_grep (dict, grep_pattern, range, NULL, &max_pos, - grep_handle); + srange, grep_handle); } if (rw) {