Fix dfa_match_first to avoid match past nul byte
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 7 Feb 2006 00:17:44 +0000 (00:17 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 7 Feb 2006 00:17:44 +0000 (00:17 +0000)
buildconf.sh
data1/d1_absyn.c
recctrl/recgrs.c

index f6560e6..d409b79 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 #!/bin/sh
-# $Id: buildconf.sh,v 1.13 2005-03-04 12:00:06 adam Exp $
+# $Id: buildconf.sh,v 1.14 2006-02-07 00:17:44 adam Exp $
 set -x
 dir=`aclocal --print-ac-dir`
 aclocal -I .
 set -x
 dir=`aclocal --print-ac-dir`
 aclocal -I .
@@ -18,7 +18,7 @@ sh_flags=""
 conf_flags=""
 case $1 in
     -d)
 conf_flags=""
 case $1 in
     -d)
-       sh_flags="-g -Wall"
+       sh_flags="-g -Wall -O0"
        enable_configure=true
        enable_help=false
        shift
        enable_configure=true
        enable_help=false
        shift
index dfe0484..4a008df 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: d1_absyn.c,v 1.22 2006-02-06 23:22:28 adam Exp $
+/* $Id: d1_absyn.c,v 1.23 2006-02-07 00:17:44 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -443,7 +443,6 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr)
 {
     const char *p = expr;
     int abs = 1;
 {
     const char *p = expr;
     int abs = 1;
-    int i;
     int e = 0;
     char *stack[32];
     char *res_p, *res = 0;
     int e = 0;
     char *stack[32];
     char *res_p, *res = 0;
@@ -491,9 +490,9 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr)
     res_p = res = nmem_malloc(data1_nmem_get(dh), res_size + 10);
 
     if (stack[e-1][0] == '@')  /* path/@attr spec (leaf is attribute) */
     res_p = res = nmem_malloc(data1_nmem_get(dh), res_size + 10);
 
     if (stack[e-1][0] == '@')  /* path/@attr spec (leaf is attribute) */
-       sprintf(res_p, "/");
+       strcpy(res_p, "/");
     else
     else
-       sprintf(res_p, "[^@]*/");  /* path .. (index all cdata below it) */
+       strcpy(res_p, "[^@]*/");  /* path .. (index all cdata below it) */
     res_p = res_p + strlen(res_p);
     while (--e >= 0) {
        sprintf(res_p, "%s/", stack[e]);
     res_p = res_p + strlen(res_p);
     while (--e >= 0) {
        sprintf(res_p, "%s/", stack[e]);
index df538ce..da1ad60 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recgrs.c,v 1.107 2006-02-06 23:22:29 adam Exp $
+/* $Id: recgrs.c,v 1.108 2006-02-07 00:17:44 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -350,6 +350,7 @@ static int dfa_match_first(struct DFA_state **dfaar, const char *text)
     unsigned char c;
     
     for (c = *p++, t = s->trans, i = s->tran_no; --i >= 0; t++)
     unsigned char c;
     
     for (c = *p++, t = s->trans, i = s->tran_no; --i >= 0; t++)
+    {
        if (c >= t->ch[0] && c <= t->ch[1])
        {
            while (i >= 0)
        if (c >= t->ch[0] && c <= t->ch[1])
        {
            while (i >= 0)
@@ -359,12 +360,15 @@ static int dfa_match_first(struct DFA_state **dfaar, const char *text)
                if (s->rule_no)
                    return 1;
                /* next char */
                if (s->rule_no)
                    return 1;
                /* next char */
+               if (!c)
+                   return 0;
                c = *p++;
                for (t = s->trans, i = s->tran_no; --i >= 0; t++)
                    if (c >= t->ch[0] && c <= t->ch[1])
                        break;
            }
        }
                c = *p++;
                for (t = s->trans, i = s->tran_no; --i >= 0; t++)
                    if (c >= t->ch[0] && c <= t->ch[1])
                        break;
            }
        }
+    }
     return 0;
 }
 
     return 0;
 }