Cosmetic
[idzebra-moved-to-github.git] / index / zrpn.c
index a9882c6..472e7bd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zrpn.c,v 1.172 2005-04-13 08:52:01 adam Exp $
+/* $Id: zrpn.c,v 1.174 2005-04-14 09:03:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -180,7 +180,7 @@ struct grep_info {
 #ifdef TERM_COUNT        
     int *term_no;        
 #endif        
-    ISAMC_P *isam_p_buf;
+    ISAM_P *isam_p_buf;
     int isam_p_size;        
     int isam_p_indx;
     ZebraHandle zh;
@@ -215,13 +215,13 @@ static void add_isam_p(const char *name, const char *info,
     }
     if (p->isam_p_indx == p->isam_p_size)
     {
-        ISAMC_P *new_isam_p_buf;
+        ISAM_P *new_isam_p_buf;
 #ifdef TERM_COUNT        
         int *new_term_no;        
 #endif
         p->isam_p_size = 2*p->isam_p_size + 100;
-        new_isam_p_buf = (ISAMC_P *) xmalloc(sizeof(*new_isam_p_buf) *
-                                             p->isam_p_size);
+        new_isam_p_buf = (ISAM_P *) xmalloc(sizeof(*new_isam_p_buf) *
+                                           p->isam_p_size);
         if (p->isam_p_buf)
         {
             memcpy(new_isam_p_buf, p->isam_p_buf,
@@ -1095,7 +1095,7 @@ static int string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                                      use_string)))
             {
                 yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
-                      curAttributeSet, use_value, r);
+                       curAttributeSet, use_value, r);
                 if (r == -1)
                 {
                     /* set was found, but value wasn't defined */
@@ -1702,8 +1702,11 @@ static int numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                       curAttributeSet, use_value, r);
                 if (r == -1)
                 {
-                    errString = nmem_strdup_i(stream, use_value);
                     errCode = 114;
+                    if (use_string)
+                        errString = nmem_strdup(stream, use_string);
+                    else
+                        errString = nmem_strdup_i (stream, use_value);
                 }
                 else
                     errCode = 121;
@@ -2406,7 +2409,7 @@ RSET rpn_search(ZebraHandle zh, NMEM nmem, NMEM rset_nmem,
 
 struct scan_info_entry {
     char *term;
-    ISAMC_P isam_p;
+    ISAM_P isam_p;
 };
 
 struct scan_info {
@@ -2430,8 +2433,8 @@ static int scan_handle (char *name, const char *info, int pos, void *client)
     scan_info->list[idx].term = (char *)
         odr_malloc(scan_info->odr, strlen(name + len_prefix)+1);
     strcpy(scan_info->list[idx].term, name + len_prefix);
-    assert (*info == sizeof(ISAMC_P));
-    memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAMC_P));
+    assert (*info == sizeof(ISAM_P));
+    memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAM_P));
     return 0;
 }
 
@@ -2524,6 +2527,7 @@ void rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     NMEM rset_nmem = NULL; 
 
     *list = 0;
+    *is_partial = 0;
 
     if (attributeset == VAL_NONE)
         attributeset = VAL_BIB1;
@@ -2605,10 +2609,15 @@ void rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                        attributeset, use_value);
                if (r == -1)
                {
-                   char val_str[32];
-                   sprintf (val_str, "%d", use_value);
                    errCode = 114;
-                   errString = odr_strdup (stream, val_str);
+                    if (use_string)
+                        errString = odr_strdup(stream, use_string);
+                    else
+                   {
+                       char val_str[32];
+                       sprintf (val_str, "%d", use_value);
+                        errString = odr_strdup(stream, val_str);
+                   }
                }   
                else
                    errCode = 121;
@@ -2631,6 +2640,7 @@ void rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         zh->errCode = errCode;
         zh->errString = errString;
         *num_entries = 0;
+       return;
     }
     if (ord_no == 0)
     {