X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fcharmap.c;h=60bc25401ad4f358814bc358b9ae64b1485ea5a6;hb=de4ada45ce039553f8322e620cc047d8cf4a065e;hp=3f5abdf97c074e6aa6b6b03445a01827b7382806;hpb=cb1317543281a64aeb8b389d5cdfffa5bb2cde90;p=idzebra-moved-to-github.git diff --git a/util/charmap.c b/util/charmap.c index 3f5abdf..60bc254 100644 --- a/util/charmap.c +++ b/util/charmap.c @@ -4,7 +4,22 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: charmap.c,v $ - * Revision 1.6 1996-06-04 13:28:00 quinn + * Revision 1.11 1997-09-05 09:52:32 adam + * Extra argument added to function chr_read_maptab (tab path). + * + * Revision 1.10 1997/07/01 13:01:08 adam + * Bug fix in routine find_entry: didn't take into account the len arg. + * + * Revision 1.9 1996/10/29 13:48:14 adam + * Updated to use zebrautl.h instead of alexutil.h. + * + * Revision 1.8 1996/10/18 12:39:23 adam + * Uses LOG_DEBUG instead of LOG_WARN for "Character map overlap". + * + * Revision 1.7 1996/06/06 12:08:56 quinn + * Fixed bug. + * + * Revision 1.6 1996/06/04 13:28:00 quinn * More work on charmapping * * Revision 1.5 1996/06/04 08:32:15 quinn @@ -34,7 +49,7 @@ #include #include -#include +#include #include #include #include @@ -46,8 +61,6 @@ const char *CHR_UNKNOWN = "\001"; const char *CHR_SPACE = "\002"; const char *CHR_BASE = "\003"; -extern char *data1_tabpath; - /* * Character map trie node. */ @@ -85,7 +98,7 @@ static chr_t_entry *set_map_string(chr_t_entry *root, char *from, int len, (char*) root->target == CHR_UNKNOWN) root->target = (unsigned char *) xstrdup(to); else if ((char*) to != CHR_SPACE) - logf(LOG_WARN, "Character map overlap"); + logf(LOG_DEBUG, "Character map overlap"); } else { @@ -136,7 +149,7 @@ static chr_t_entry *find_entry(chr_t_entry *t, char **from, int len) { chr_t_entry *res; - if (t->children && t->children[(unsigned char) **from]) + if (len && t->children && t->children[(unsigned char) **from]) { char *pos = *from; @@ -147,8 +160,8 @@ static chr_t_entry *find_entry(chr_t_entry *t, char **from, int len) /* no match */ *from = pos; } - /* no children match. use ourselves */ - return t; + /* no children match. use ourselves, if we have a target */ + return t->target ? t : 0; } char **chr_map_input(chr_t_entry *t, char **from, int len) @@ -335,14 +348,14 @@ static int scan_string(char *s, void (*fun)(char *c, void *data, int num), return 0; } -chrmaptab *chr_read_maptab(char *name) +chrmaptab *chr_read_maptab(const char *tabpath, const char *name) { FILE *f; char line[512], *argv[50]; chrmaptab *res = xmalloc(sizeof(*res)); int argc, num = (int) *CHR_BASE, i; - if (!(f = yaz_path_fopen(data1_tabpath, name, "r"))) + if (!(f = yaz_path_fopen(tabpath, name, "r"))) { logf(LOG_WARN|LOG_ERRNO, "%s", name); return 0;