Code calls xfree() instead of free().
[idzebra-moved-to-github.git] / recctrl / regxread.c
index 0626721..17ce5d9 100644 (file)
@@ -4,7 +4,20 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: regxread.c,v $
- * Revision 1.6  1997-02-24 10:41:51  adam
+ * Revision 1.10  1997-10-31 12:36:12  adam
+ * Minor change that avoids compiler warning.
+ *
+ * Revision 1.9  1997/09/29 09:02:49  adam
+ * Fixed small bug (introduced by previous commit).
+ *
+ * Revision 1.8  1997/09/17 12:19:22  adam
+ * Zebra version corresponds to YAZ version 1.4.
+ * Changed Zebra server so that it doesn't depend on global common_resource.
+ *
+ * Revision 1.7  1997/07/15 16:33:07  adam
+ * Check for zero length in execData.
+ *
+ * Revision 1.6  1997/02/24 10:41:51  adam
  * Cleanup of code and commented out the "end element-end-record" code.
  *
  * Revision 1.5  1997/02/19 16:22:33  adam
@@ -162,6 +175,7 @@ struct lexSpec {
     struct lexTrans trans;
     int lineNo;
     NMEM m;
+    data1_handle dh;
     void *f_win_fh;
     void (*f_win_ef)(void *, off_t);
 
@@ -501,7 +515,8 @@ int readFileSpec (struct lexSpec *spec)
     lineBuf = xmalloc (1+lineSize);
     logf (LOG_LOG, "reading regx filter %s.flt", spec->name);
     sprintf (lineBuf, "%s.flt", spec->name);
-    if (!(spec_inf = yaz_path_fopen (data1_get_tabpath(), lineBuf, "r")))
+    if (!(spec_inf = yaz_path_fopen (data1_get_tabpath(spec->dh),
+                                    lineBuf, "r")))
     {
         logf (LOG_ERRNO|LOG_WARN, "cannot read spec file %s", spec->name);
         xfree (lineBuf);
@@ -580,6 +595,9 @@ static void execData (struct lexSpec *spec,
                       const char *ebuf, int elen, int formatted_text)
 {
     struct data1_node *res, *parent;
+
+    if (elen == 0) /* shouldn't happen, but it does! */
+       return ;
 #if REGX_DEBUG
     if (elen > 40)
         logf (LOG_DEBUG, "execData %.15s ... %.*s", ebuf, 15, ebuf + elen-15);
@@ -612,7 +630,7 @@ static void execData (struct lexSpec *spec,
     }
     else
     {
-        res = data1_mk_node (spec->m);
+        res = data1_mk_node (spec->dh, spec->m);
         res->parent = parent;
         res->which = DATA1N_data;
         res->u.data.what = DATA1I_text;
@@ -652,7 +670,7 @@ static void tagBegin (struct lexSpec *spec,
 {
     struct data1_node *parent = d1_stack[*d1_level -1];
     data1_element *elem = NULL;
-    data1_node *partag = get_parent_tag(parent);
+    data1_node *partag = get_parent_tag(spec->dh, parent);
     data1_node *res;
     data1_element *e = NULL;
     int localtag = 0;
@@ -663,7 +681,7 @@ static void tagBegin (struct lexSpec *spec,
         return ;
     }
     
-    res = data1_mk_node (spec->m);
+    res = data1_mk_node (spec->dh, spec->m);
     res->parent = parent;
     res->which = DATA1N_tag;
     res->u.tag.tag = res->lbuf;
@@ -684,8 +702,8 @@ static void tagBegin (struct lexSpec *spec,
         if (!(e = partag->u.tag.element))
             localtag = 1;
     
-    elem = data1_getelementbytagname (d1_stack[0]->u.root.absyn, e,
-                                      res->u.tag.tag);
+    elem = data1_getelementbytagname (spec->dh, d1_stack[0]->u.root.absyn,
+                                     e, res->u.tag.tag);
     
     res->u.tag.element = elem;
     res->u.tag.node_selected = 0;
@@ -710,7 +728,7 @@ static void tagEnd (struct lexSpec *spec,
     {
         (*d1_level)--;
         if (!tag ||
-            (strlen(d1_stack[*d1_level]->u.tag.tag) == len &&
+            (strlen(d1_stack[*d1_level]->u.tag.tag) == (size_t) len &&
              !memcmp (d1_stack[*d1_level]->u.tag.tag, tag, len)))
             break;
     }
@@ -908,13 +926,13 @@ static int execCode (struct lexSpec *spec,
 #if REGX_DEBUG
                     logf (LOG_DEBUG, "begin record %s", absynName);
 #endif
-                    if (!(absyn = data1_get_absyn (absynName)))
+                    if (!(absyn = data1_get_absyn (spec->dh, absynName)))
                         logf (LOG_WARN, "Unknown tagset: %s", absynName);
                     else
                     {
                         data1_node *res;
 
-                        res = data1_mk_node (spec->m);
+                        res = data1_mk_node (spec->dh, spec->m);
                         res->which = DATA1N_root;
                         res->u.root.type = absynName;
                         res->u.root.absyn = absyn;
@@ -1298,6 +1316,7 @@ data1_node *grs_read_regx (struct grs_read_info *p)
         if (curLexSpec)
             lexSpecDel (&curLexSpec);
         curLexSpec = lexSpecMk (p->type);
+       curLexSpec->dh = p->dh;
         res = readFileSpec (curLexSpec);
         if (res)
         {