X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=e9eeea12347198e94a020f4d375da3bb14adddf8;hb=d8e960f5f1060148a5fffa7a767c72391662fbdc;hp=0e0a18322cfb937dac783a125818e1b0ad8103b6;hpb=0e898c0c6183c6dd9701286f6a4ac9b734c9bdbb;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 0e0a183..e9eeea1 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.186 2005-05-03 09:11:34 adam Exp $ +/* $Id: zrpn.c,v 1.190 2005-05-09 13:24:09 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -522,7 +522,7 @@ static int term_104(ZebraMaps zebra_maps, int reg_type, const char **src, char *dst, int space_split, char *dst_term) { - const char *s0, *s1; + const char *s0; const char **map; int i = 0; int j = 0; @@ -570,17 +570,33 @@ static int term_104(ZebraMaps zebra_maps, int reg_type, } else { - s1 = s0; - map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0); + const char *s1 = s0; + int q_map_match = 0; + map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0), + &q_map_match); if (space_split && **map == *CHR_SPACE) break; - while (s1 < s0) - { - if (strchr(REGEX_CHARS, *s1)) - dst[i++] = '\\'; - dst_term[j++] = *s1; - dst[i++] = *s1++; - } + + /* add non-space char */ + memcpy(dst_term+j, s1, s0 - s1); + j += (s0 - s1); + if (!q_map_match) + { + while (s1 < s0) + { + if (strchr(REGEX_CHARS, *s1)) + dst[i++] = '\\'; + dst[i++] = *s1++; + } + } + else + { + char tmpbuf[80]; + esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0])); + + strcpy(dst + i, map[0]); + i += strlen(map[0]); + } } } dst[i] = '\0'; @@ -594,7 +610,7 @@ 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 *s0; const char **map; int i = 0; int j = 0; @@ -617,17 +633,33 @@ static int term_105(ZebraMaps zebra_maps, int reg_type, } else { - s1 = s0; - map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0); + const char *s1 = s0; + int q_map_match = 0; + map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0), + &q_map_match); if (space_split && **map == *CHR_SPACE) break; - while (s1 < s0) - { - if (strchr(REGEX_CHARS, *s1)) - dst[i++] = '\\'; - dst_term[j++] = *s1; - dst[i++] = *s1++; - } + + /* add non-space char */ + memcpy(dst_term+j, s1, s0 - s1); + j += (s0 - s1); + if (!q_map_match) + { + while (s1 < s0) + { + if (strchr(REGEX_CHARS, *s1)) + dst[i++] = '\\'; + dst[i++] = *s1++; + } + } + else + { + char tmpbuf[80]; + esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0])); + + strcpy(dst + i, map[0]); + i += strlen(map[0]); + } } } if (right_truncate) @@ -1237,6 +1269,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, return ZEBRA_OK; } strcat(term_dict, ")"); + break; case 104: /* process # and ! in term */ term_dict[j++] = '('; if (!term_104(zh->reg->zebra_maps, reg_type, @@ -1974,11 +2007,8 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int i; int sort_relation_value; AttrType sort_relation_type; - int use_value; - AttrType use_type; Z_SortKeySpec *sks; Z_SortKey *sk; - Z_AttributeElement *ae; int oid[OID_SIZE]; oident oe; char termz[20]; @@ -1986,9 +2016,6 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, attr_init(&sort_relation_type, zapt, 7); sort_relation_value = attr_find(&sort_relation_type, &attributeSet); - attr_init(&use_type, zapt, 1); - use_value = attr_find(&use_type, &attributeSet); - if (!sort_sequence->specs) { sort_sequence->num_specs = 10; @@ -2024,21 +2051,7 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, nmem_malloc(stream, sizeof(*sk->u.sortAttributes)); sk->u.sortAttributes->id = oid; - sk->u.sortAttributes->list = (Z_AttributeList *) - nmem_malloc(stream, sizeof(*sk->u.sortAttributes->list)); - sk->u.sortAttributes->list->num_attributes = 1; - sk->u.sortAttributes->list->attributes = (Z_AttributeElement **) - nmem_malloc(stream, sizeof(*sk->u.sortAttributes->list->attributes)); - ae = *sk->u.sortAttributes->list->attributes = (Z_AttributeElement *) - nmem_malloc(stream, sizeof(**sk->u.sortAttributes->list->attributes)); - ae->attributeSet = 0; - ae->attributeType = (int *) - nmem_malloc(stream, sizeof(*ae->attributeType)); - *ae->attributeType = 1; - ae->which = Z_AttributeValue_numeric; - ae->value.numeric = (int *) - nmem_malloc(stream, sizeof(*ae->value.numeric)); - *ae->value.numeric = use_value; + sk->u.sortAttributes->list = zapt->attributes; sks->sortRelation = (int *) nmem_malloc(stream, sizeof(*sks->sortRelation)); @@ -2408,15 +2421,16 @@ ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, for (i = 0; idec)(kc); - return ZEBRA_OK; + return res; } ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,