Require YAZ 2.1.46 or later
[pazpar2-moved-to-github.git] / src / pazpar2.c
index 2222679..5dda86d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pazpar2.c,v 1.32 2007-01-15 16:56:51 quinn Exp $ */
+/* $Id: pazpar2.c,v 1.36 2007-01-16 05:29:48 quinn Exp $ */
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -319,7 +319,10 @@ char *normalize_mergekey(char *buf, int skiparticle)
             p++;
     }
     if (buf != pout)
-        *pout = '\0';
+        do {
+            *(pout--) = '\0';
+        }
+        while (pout > buf && *pout == ' ');
 
     return buf;
 }
@@ -569,7 +572,12 @@ static struct record *ingest_record(struct client *cl, Z_External *rec)
             newm->next = 0;
             if (md->type == Metadata_type_generic)
             {
+                char *p;
                 newm->data.text = nmem_strdup(se->nmem, value);
+                for (p = newm->data.text + strlen(newm->data.text) - 1;
+                        p > newm->data.text && strchr(" ,/.", *p); p--)
+                    *p = '\0';
+
             }
             else if (md->type == Metadata_type_year)
             {
@@ -590,7 +598,7 @@ static struct record *ingest_record(struct client *cl, Z_External *rec)
             {
                 struct record_metadata *mnode;
                 for (mnode = *wheretoput; mnode; mnode = mnode->next)
-                    if (!strcmp(mnode->data.text, mnode->data.text))
+                    if (!strcmp(mnode->data.text, newm->data.text))
                         break;
                 if (!mnode)
                 {
@@ -638,12 +646,6 @@ static struct record *ingest_record(struct client *cl, Z_External *rec)
                         (*wheretoput)->data.number.min = first;
                     if (last > (*wheretoput)->data.number.max)
                         (*wheretoput)->data.number.max = last;
-                    if (sk)
-                    {
-                        union data_types *sdata = cluster->sortkeys[md->sortkey_offset];
-                        sdata->number.min = first;
-                        sdata->number.max = last;
-                    }
                 }
 #ifdef GAGA
                 if (sk)