Fix xpath indexing for non-existent attribute value
[idzebra-moved-to-github.git] / recctrl / recgrs.c
index 6399224..12ad348 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recgrs.c,v 1.62 2002-08-28 12:47:10 adam Exp $
+/* $Id: recgrs.c,v 1.64 2002-08-29 15:10:47 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
    Index Data Aps
 
@@ -225,9 +225,10 @@ static void index_xpath (data1_node *n, struct recExtractCtrl *p,
                 for (xp = n->u.tag.attributes; xp; xp = xp->next)
                 {
                     char attr_tag_path_full[1024];
+                    int int_len = flen;
                     
                     sprintf (attr_tag_path_full, "@%s/%.*s",
-                             xp->name, flen, tag_path_full);
+                             xp->name, int_len, tag_path_full);
 
                     wrd->reg_type = '0';
                     wrd->attrUse = 1;
@@ -235,12 +236,14 @@ static void index_xpath (data1_node *n, struct recExtractCtrl *p,
                     wrd->length = strlen(attr_tag_path_full);
                     (*p->tokenAdd)(wrd);
                     
-                    wrd->attrUse = 1015;
-                    wrd->reg_type = 'w';
-                    wrd->string = xp->value;
-                    wrd->length = strlen(xp->value);
-                    
-                    (*p->tokenAdd)(wrd);
+                   if (xp->value)
+                   {
+                        wrd->attrUse = 1015;
+                        wrd->reg_type = 'w';
+                        wrd->string = xp->value;
+                        wrd->length = strlen(xp->value);
+                        (*p->tokenAdd)(wrd);
+                    }
                     
                     wrd->reg_type = '0';
                     wrd->attrUse = 2;