Fixed bug with numerical relations.
[idzebra-moved-to-github.git] / index / zrpn.c
index 5a1b42a..a97e265 100644 (file)
@@ -1,10 +1,20 @@
 /*
- * Copyright (C) 1995-1998, Index Data I/S 
+ * Copyright (C) 1995-1998, Index Data
  * All rights reserved.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zrpn.c,v $
- * Revision 1.81  1998-06-24 12:16:14  adam
+ * Revision 1.84  1998-09-18 12:41:00  adam
+ * Fixed bug with numerical relations.
+ *
+ * Revision 1.83  1998/09/02 13:53:19  adam
+ * Extra parameter decode added to search routines to implement
+ * persistent queries.
+ *
+ * Revision 1.82  1998/06/26 11:16:40  quinn
+ * Added support (un-optimised) for left and left/right truncation
+ *
+ * Revision 1.81  1998/06/24 12:16:14  adam
  * Support for relations on text operands. Open range support in
  * DFA module (i.e. [-j], [g-]).
  *
@@ -644,7 +654,7 @@ static void gen_regular_rel (char *dst, int val, int islt)
         }
         else
         {
-            strcpy (dst, "((-");
+            strcpy (dst, "(-(");
             islt = 0;
         }
         val = -val;
@@ -1006,8 +1016,24 @@ static int string_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt,
            dict_lookup_grep (zh->dict, term_dict, 0, grep_info,
                              &max_pos, 0, grep_handle);
            break;
-       case 2:          /* left truncation */
+       case 2:          /* keft truncation */
+           term_dict[j++] = '('; term_dict[j++] = '.'; term_dict[j++] = '*';
+           if (!term_100 (zh->zebra_maps, reg_type,
+                          &termp, term_dict + j, space_split, term_dst))
+               return 0;
+           strcat (term_dict, ")");
+           dict_lookup_grep (zh->dict, term_dict, 0, grep_info,
+                             &max_pos, 0, grep_handle);
+           break;
        case 3:          /* left&right truncation */
+           term_dict[j++] = '('; term_dict[j++] = '.'; term_dict[j++] = '*';
+           if (!term_100 (zh->zebra_maps, reg_type,
+                          &termp, term_dict + j, space_split, term_dst))
+               return 0;
+           strcat (term_dict, ".*)");
+           dict_lookup_grep (zh->dict, term_dict, 0, grep_info,
+                             &max_pos, 0, grep_handle);
+           break;
            zh->errCode = 120;
            return -1;
        case 101:        /* process # in term */
@@ -1994,7 +2020,7 @@ static RSET rpn_search_structure (ZebraHandle zh, Z_RPNStructure *zs,
     return r;
 }
 
-void rpn_search (ZebraHandle zh, ODR stream,
+void rpn_search (ZebraHandle zh, ODR stream, ODR decode,
                 Z_RPNQuery *rpn, int num_bases, char **basenames, 
                 const char *setname)
 {