Revert
[idzebra-moved-to-github.git] / util / zebramap.c
index dfec14c..170ccc0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebramap.c,v 1.56 2007-01-22 18:15:04 adam Exp $
+/* $Id: zebramap.c,v 1.59 2007-10-29 16:57:54 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -77,7 +77,7 @@ void zebra_maps_close(ZebraMaps zms)
            chrmaptab_destroy(zm->maptab);
        zm = zm->next;
     }
-    wrbuf_free(zms->wrbuf_1, 1);
+    wrbuf_destroy(zms->wrbuf_1);
     nmem_destroy(zms->nmem);
     xfree(zms);
 }
@@ -427,7 +427,7 @@ int zebra_maps_sort(ZebraMaps zms, Z_SortAttributes *sortAttributes,
 }
 
 int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
-                   unsigned *reg_id, char **search_type, char *rank_type,
+                   const char **index_type, char **search_type, char *rank_type,
                    int *complete_flag, int *sort_flag)
 {
     AttrType completeness;
@@ -438,6 +438,7 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
     AttrType use;
     int completeness_value;
     int structure_value;
+    const char *structure_str = 0;
     int relation_value;
     int sort_relation_value;
     int weight_value;
@@ -451,7 +452,7 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
     attr_init_APT(&use, zapt, 1);
 
     completeness_value = attr_find(&completeness, NULL);
-    structure_value = attr_find(&structure, NULL);
+    structure_value = attr_find_ex(&structure, NULL, &structure_str);
     relation_value = attr_find(&relation, NULL);
     sort_relation_value = attr_find(&sort_relation, NULL);
     weight_value = attr_find(&weight, NULL);
@@ -461,7 +462,7 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
        *complete_flag = 1;
     else
        *complete_flag = 0;
-    *reg_id = 0;
+    *index_type = 0;
 
     *sort_flag =(sort_relation_value > 0) ? 1 : 0;
     *search_type = "phrase";
@@ -473,9 +474,9 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
         sprintf(rank_type, "rank,w=%d,u=%d", weight_value, use_value);
     }
     if (*complete_flag)
-       *reg_id = 'p';
+       *index_type = "p";
     else
-       *reg_id = 'w';
+       *index_type = "w";
     switch (structure_value)
     {
     case 6:   /* word list */
@@ -495,28 +496,34 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
        break;
     case 107: /* local-number */
        *search_type = "local";
-       *reg_id = 0;
+       *index_type = 0;
        break;
     case 109: /* numeric string */
-       *reg_id = 'n';
+       *index_type = "n";
        *search_type = "numeric";
         break;
     case 104: /* urx */
-       *reg_id = 'u';
+       *index_type = "u";
        *search_type = "phrase";
        break;
     case 3:   /* key */
-        *reg_id = '0';
+        *index_type = "0";
         *search_type = "phrase";
         break;
     case 4:  /* year */
-        *reg_id = 'y';
+        *index_type = "y";
         *search_type = "phrase";
         break;
     case 5:  /* date */
-        *reg_id = 'd';
+        *index_type = "d";
         *search_type = "phrase";
         break;
+    case -2:
+        if (structure_str && *structure_str)
+            *index_type = structure_str;
+        else
+            return -1;
+        break;
     default:
        return -1;
     }