X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=db339e5569884a884b86ffc6293a1f98c4216a27;hb=ff83da9583191588c5816189b55966a6bb057d71;hp=135f68bbf64a5cec391e0c81c22c955e30aea8fd;hpb=be0203ee07adfeda7821a2c44ba6dd31a532b792;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 135f68b..db339e5 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.204 2005-08-22 09:04:18 adam Exp $ +/* $Id: zrpn.c,v 1.206 2005-11-02 11:43:26 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -82,7 +82,7 @@ static void rpn_char_map_prepare(struct zebra_register *reg, int reg_type, } static int attr_find_ex(AttrType *src, oid_value *attributeSetP, - const char **string_value) + const char **string_value) { int num_attributes; @@ -235,13 +235,13 @@ static void add_isam_p(const char *name, const char *info, const char *db; int set, use; char term_tmp[IT_MAX_WORD]; - int su_code = 0; - int len = key_SU_decode (&su_code, (const unsigned char *) name); + int ord = 0; + int len = key_SU_decode (&ord, (const unsigned char *) name); zebra_term_untrans (p->zh, p->reg_type, term_tmp, name+len+1); - yaz_log(log_level_rpn, "grep: %d %c %s", su_code, name[len], term_tmp); + yaz_log(log_level_rpn, "grep: %d %c %s", ord, name[len], term_tmp); zebraExplain_lookup_ord (p->zh->reg->zei, - su_code, &db, &set, &use); + ord, 0 /* index_type */, &db, &set, &use); yaz_log(log_level_rpn, "grep: set=%d use=%d db=%s", set, use, db); resultSetAddTerm(p->zh, p->termset, name[len], db, @@ -993,19 +993,28 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, static ZEBRA_RES term_limits_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, zint *hits_limit_value, - const char **term_ref_id_str) + const char **term_ref_id_str, + NMEM nmem) { AttrType term_ref_id_attr; AttrType hits_limit_attr; + int term_ref_id_int; attr_init(&hits_limit_attr, zapt, 9); *hits_limit_value = attr_find(&hits_limit_attr, NULL); attr_init(&term_ref_id_attr, zapt, 10); - attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str); + term_ref_id_int = attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str); + if (term_ref_id_int != -1) + { + char *res = nmem_malloc(nmem, 20); + sprintf(res, "%d", term_ref_id_int); + *term_ref_id_str = res; + } /* no limit given ? */ if (*hits_limit_value == -1) + { if (*term_ref_id_str) { /* use global if term_ref is present */ @@ -1016,6 +1025,7 @@ static ZEBRA_RES term_limits_APT(ZebraHandle zh, /* no counting if term_ref is not present */ *hits_limit_value = 0; } + } else if (*hits_limit_value == 0) { /* 0 is the same as global limit */ @@ -1046,7 +1056,8 @@ static ZEBRA_RES term_trunc(ZebraHandle zh, const char *term_ref_id_str = 0; *rset = 0; - term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str); + term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, + stream); grep_info->isam_p_indx = 0; res = string_term(zh, zapt, term_sub, attributeSet, stream, grep_info, reg_type, complete_flag, num_bases, basenames, @@ -1931,7 +1942,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, zint hits_limit_value; const char *term_ref_id_str = 0; - term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str); + term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, stream); yaz_log(log_level_rpn, "APT_numeric t='%s'", termz); if (grep_info_prepare(zh, zapt, &grep_info, reg_type) == ZEBRA_FAIL)