From: Adam Dickmeiss Date: Thu, 9 Nov 1995 15:24:02 +0000 (+0000) Subject: Allow charsets [..] in record match. X-Git-Tag: IRTCL.1.4~188 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=1d407b82044d8495be5821c3734cd17cb4c2514e;p=ir-tcl-moved-to-github.git Allow charsets [..] in record match. --- diff --git a/marc.c b/marc.c index d98ecd5..cc26636 100644 --- a/marc.c +++ b/marc.c @@ -5,7 +5,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: marc.c,v $ - * Revision 1.6 1995-08-28 12:21:22 adam + * Revision 1.7 1995-11-09 15:24:02 adam + * Allow charsets [..] in record match. + * + * Revision 1.6 1995/08/28 12:21:22 adam * Removed lines and list as synonyms of list in MARC extractron. * Configure searches also for tk4.0 / tcl7.4. * @@ -60,18 +63,39 @@ static int atoi_n (const char *buf, int len) static int marc_compare (const char *f, const char *p) { + int ch; + if (*p == '*') return 0; if (!f) return -*p; - for (; *f && *p; f++, p++) - { - if (*p == '?') - continue; - if (*p != *f) - break; - } - return *f - *p; + for (; (ch = *p) && *f; f++, p++) + switch (*p) + { + case '*': + return 0; + case '?': + ch = *f; + break; + case '[': + while (1) + if (!*++p) + break; + else if (*p == ']') + { + p++; + break; + } + else if (*p == *f) + ch = *p; + if (ch != *p) + return *f - ch; + break; + default: + if (ch != *f) + return *f - ch; + } + return *f - ch; } char *ir_tcl_fread_marc (FILE *inf, size_t *size)