X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=index%2Fzrpn.c;h=e87cf464d07f2051bb55b24711e85e6969cc9e1e;hb=43506dd0ff92373604bb7288e2dcc943b2c1d524;hp=249e7e9655de70776608988611d732a79219aa8d;hpb=01ddc55fd5a59535e229c09440cfdadccadf3555;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 249e7e9..e87cf46 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,16 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.95 1999-09-07 07:19:21 adam + * Revision 1.98 1999-11-30 13:48:04 adam + * Improved installation. Updated for inclusion of YAZ header files. + * + * Revision 1.97 1999/10/14 14:33:50 adam + * Added truncation 5=106. + * + * Revision 1.96 1999/09/23 10:05:05 adam + * Implemented structure=105 searching. + * + * Revision 1.95 1999/09/07 07:19:21 adam * Work on character mapping. Implemented replace rules. * * Revision 1.94 1999/07/20 13:59:18 adam @@ -442,7 +451,7 @@ struct grep_info { #ifdef TERM_COUNT int *term_no; #endif - ISAM_P *isam_p_buf; + ISAMS_P *isam_p_buf; int isam_p_size; int isam_p_indx; ZebraHandle zh; @@ -469,12 +478,12 @@ static void add_isam_p (const char *name, const char *info, { if (p->isam_p_indx == p->isam_p_size) { - ISAM_P *new_isam_p_buf; + ISAMS_P *new_isam_p_buf; #ifdef TERM_COUNT int *new_term_no; #endif p->isam_p_size = 2*p->isam_p_size + 100; - new_isam_p_buf = (ISAM_P *) xmalloc (sizeof(*new_isam_p_buf) * + new_isam_p_buf = (ISAMS_P *) xmalloc (sizeof(*new_isam_p_buf) * p->isam_p_size); if (p->isam_p_buf) { @@ -714,6 +723,58 @@ static int term_104 (ZebraMaps zebra_maps, int reg_type, return i; } +/* term_105/106: handle term, where trunc=Process # and ! and right trunc */ +static int term_105 (ZebraMaps zebra_maps, int reg_type, + const char **src, char *dst, int space_split, + char *dst_term, int right_truncate) +{ + const char *s0, *s1; + const char **map; + int i = 0; + int j = 0; + + if (!term_pre (zebra_maps, reg_type, src, "*!", "*!")) + return 0; + s0 = *src; + while (*s0) + { + if (*s0 == '*') + { + dst[i++] = '.'; + dst[i++] = '+'; + dst_term[j++] = *s0++; + } + else if (*s0 == '!') + { + dst[i++] = '.'; + dst_term[j++] = *s0++; + } + { + s1 = s0; + map = zebra_maps_input (zebra_maps, reg_type, &s0, strlen(s0)); + if (space_split && **map == *CHR_SPACE) + break; + while (s1 < s0) + { + if (!isalnum (*s1)) + dst[i++] = '\\'; + dst_term[j++] = *s1; + dst[i++] = *s1++; + } + } + } + if (right_truncate) + { + dst[i++] = '.'; + dst[i++] = '*'; + } + dst[i] = '\0'; + + dst_term[j++] = '\0'; + *src = s0; + return i; +} + /* gen_regular_rel - generate regular expression from relation * val: border value (inclusive) @@ -1198,6 +1259,28 @@ static int string_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (r) logf (LOG_WARN, "dict_lookup_grep err, trunc=#/!: %d", r); break; + case 105: /* process * and ! in term */ + term_dict[j++] = '('; + if (!term_105 (zh->zebra_maps, reg_type, + &termp, term_dict + j, space_split, term_dst, 1)) + return 0; + strcat (term_dict, ")"); + r = dict_lookup_grep (zh->dict, term_dict, 0, grep_info, + &max_pos, 0, grep_handle); + if (r) + logf (LOG_WARN, "dict_lookup_grep err, trunc=*/!: %d", r); + break; + case 106: /* process * and ! in term */ + term_dict[j++] = '('; + if (!term_105 (zh->zebra_maps, reg_type, + &termp, term_dict + j, space_split, term_dst, 0)) + return 0; + strcat (term_dict, ")"); + r = dict_lookup_grep (zh->dict, term_dict, 0, grep_info, + &max_pos, 0, grep_handle); + if (r) + logf (LOG_WARN, "dict_lookup_grep err, trunc=*/!: %d", r); + break; } } *term_sub = termp; @@ -1494,6 +1577,9 @@ char *normalize_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, case 104: ex_list = "!#"; break; + case 105: + ex_list = "!*"; + break; } if (ex_list) wrbuf = zebra_replace(zh->zebra_maps, reg_id, ex_list, @@ -2271,7 +2357,7 @@ RSET rpn_search (ZebraHandle zh, NMEM nmem, struct scan_info_entry { char *term; - ISAM_P isam_p; + ISAMS_P isam_p; }; struct scan_info { @@ -2295,8 +2381,8 @@ static int scan_handle (char *name, const char *info, int pos, void *client) scan_info->list[idx].term = (char *) odr_malloc (scan_info->odr, strlen(name + len_prefix)+1); strcpy (scan_info->list[idx].term, name + len_prefix); - assert (*info == sizeof(ISAM_P)); - memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAM_P)); + assert (*info == sizeof(ISAMS_P)); + memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAMS_P)); return 0; }