RPM: store libs in %{_libdir}
[idzebra-moved-to-github.git] / index / rpnscan.c
index fa12bbd..f638f83 100644 (file)
@@ -1,8 +1,5 @@
-/* $Id: rpnscan.c,v 1.24 2007-12-13 11:09:20 adam Exp $
-   Copyright (C) 1995-2007
-   Index Data ApS
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+   Copyright (C) 1994-2011 Index Data
 
 Zebra is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -20,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 */
 
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <stdio.h>
 #include <assert.h>
 #ifdef WIN32
@@ -149,11 +149,6 @@ static int scan_handle2(char *name, const char *info, int pos, void *client)
     len_prefix = strlen(scan_info->prefix);
     if (memcmp(name, scan_info->prefix, len_prefix))
         return 1;
-
-    /* skip special terms such as first-in-field specials */
-    if (name[len_prefix] < CHR_BASE_CHAR)
-        return 1;
-
     wrbuf_rewind(scan_info->term);
     wrbuf_puts(scan_info->term, name+len_prefix);
 
@@ -187,29 +182,32 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
     {
         if (ar[i].isam_p && strcmp(wrbuf_cstr(ar[i].term), term) == 0)
         {
-            struct ord_list *ol = ord_list_create(nmem);
-            RSET rset_t;
-
-            ol = ord_list_append(nmem, ol, ar[i].ord);
-
-            assert(ol);
-            rset_t = rset_trunc(
+            if (strcmp(term, FIRST_IN_FIELD_STR))
+            {
+                struct ord_list *ol = ord_list_create(nmem);
+                RSET rset_t;
+                
+                ol = ord_list_append(nmem, ol, ar[i].ord);
+                
+                assert(ol);
+                rset_t = rset_trunc(
                     zh, &ar[i].isam_p, 1,
                     wrbuf_buf(ar[i].term), wrbuf_len(ar[i].term),
                     NULL, 1, zapt->term->which, nmem, 
                     kc, kc->scope, ol, index_type, 
                     0 /* hits_limit_value */,
                     0 /* term_ref_id_str */);
-            if (!rset)
-                rset = rset_t;
-            else
-            {
-                RSET rsets[2];
-                
-                rsets[0] = rset;
-                rsets[1] = rset_t;
-                rset = rset_create_or(nmem, kc, kc->scope, 0 /* termid */,
-                                      2, rsets);
+                if (!rset)
+                    rset = rset_t;
+                else
+                {
+                    RSET rsets[2];
+                    
+                    rsets[0] = rset;
+                    rsets[1] = rset_t;
+                    rset = rset_create_or(nmem, kc, kc->scope, 0 /* termid */,
+                                          2, rsets);
+                }
             }
             ar[i].isam_p = 0;
         }
@@ -250,6 +248,10 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
                     {
                         glist[pos].display_term = odr_strdup(stream, w->term);
                     }
+                    else
+                    {
+                        yaz_log(YLOG_WARN, "zebra_snippets_lookup failed for pos=%d", pos);
+                    }
                 }
                 zebra_snippets_destroy(rec_snippets);
             }
@@ -260,6 +262,12 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
                 glist[pos].term = glist[pos].display_term;
             }
 
+            if (!glist[pos].term)
+            {
+                yaz_log(YLOG_WARN, "Could not generate scan term for pos=%d",
+                        pos);
+                glist[pos].term = "None";
+            }
             glist[pos].occurrences = count;
             zebra_snippets_destroy(hit_snippets);
         }
@@ -368,7 +376,6 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem,
     {
         /* did not get all terms; adjust the real position and reduce
            number of entries */
-        yaz_log(YLOG_LOG, "before terms dif=%d", dif);
         glist = glist + dif;
         *num_entries -= dif;
         *position -= dif;
@@ -575,6 +582,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab