-/* $Id: zrpn.c,v 1.187 2005-05-03 13:57:44 adam Exp $
+/* $Id: zrpn.c,v 1.190 2005-05-09 13:24:09 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
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;
}
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';
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;
}
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)
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];
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;
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));
for (i = 0; i<num_result_sets; i++)
rset_delete(result_sets[i]);
*result_set = 0;
- return res;
}
- assert(num_result_sets == 1);
- assert(result_sets);
- assert(*result_sets);
- *result_set = *result_sets;
-
+ else
+ {
+ assert(num_result_sets == 1);
+ assert(result_sets);
+ assert(*result_sets);
+ *result_set = *result_sets;
+ }
(*kc->dec)(kc);
- return ZEBRA_OK;
+ return res;
}
ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,