Fix for bug 460
[idzebra-moved-to-github.git] / data1 / d1_absyn.c
index 34c4dd1..dfe0484 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: d1_absyn.c,v 1.21 2005-06-29 16:52:26 adam Exp $
+/* $Id: d1_absyn.c,v 1.22 2006-02-06 23:22:28 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -461,7 +461,7 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr)
     {
        int is_predicate = 0;
        char *s;
-       int j;
+       int i, j;
         for (i = 0; *p && !strchr("/",*p); i++, p++)
            ;
        res_size += (i+3); /* we'll add / between later .. */
@@ -490,8 +490,10 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr)
     }
     res_p = res = nmem_malloc(data1_nmem_get(dh), res_size + 10);
 
-    i = 0;
-    sprintf(res_p, ".*/");
+    if (stack[e-1][0] == '@')  /* path/@attr spec (leaf is attribute) */
+       sprintf(res_p, "/");
+    else
+       sprintf(res_p, "[^@]*/");  /* path .. (index all cdata below it) */
     res_p = res_p + strlen(res_p);
     while (--e >= 0) {
        sprintf(res_p, "%s/", stack[e]);