Bug fix: Leading and trailing white space weren't removed in scan tokens.
[idzebra-moved-to-github.git] / isam / isam.c
index d2edbbe..380ccec 100644 (file)
@@ -4,7 +4,16 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: isam.c,v $
- * Revision 1.19  1996-02-10 12:20:56  quinn
+ * Revision 1.22  1996-10-29 13:56:53  adam
+ * Include of zebrautl.h instead of alexutil.h.
+ *
+ * Revision 1.21  1996/03/29 14:11:47  quinn
+ * Change to is_merge
+ *
+ * Revision 1.20  1996/03/19  13:14:57  quinn
+ * Moved an xfree()
+ *
+ * Revision 1.19  1996/02/10  12:20:56  quinn
  * *** empty log message ***
  *
  * Revision 1.18  1996/02/06  10:19:56  quinn
@@ -67,7 +76,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <alexutil.h>
+#include <zebrautl.h>
 #include <bfile.h>
 #include <isam.h>
 #include <common.h>
@@ -360,7 +369,6 @@ int is_close(ISAM is)
            bf_close(is->types[i].bf);
        }
     }
-    xfree(is);
     if (is->writeflag)
     {
        logf(LOG_LOG, "ISAM statistics:");
@@ -383,6 +391,7 @@ int is_close(ISAM is)
        logf(LOG_LOG, "block_jumps                 %d", statistics.block_jumps);
        logf(LOG_LOG, "tab_deletes                 %d", statistics.tab_deletes);
     }
+    xfree(is);
     return 0;
 }
 
@@ -473,9 +482,8 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data)
                        continue;
                    }
                    /* else check if next key can fit in this position */
-                   is_m_peek_record(&tab, keybuf);
-                   res = (*is->cmp)(data + 1, keybuf);
-                   if (res < 0)
+                   if (is_m_peek_record(&tab, keybuf) &&
+                       (*is->cmp)(data + 1, keybuf) < 0)
                    {
                        logf (LOG_DEBUG, "XXReplacing record.");
                        is_m_replace_record(&tab, data + 1);