X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=recctrl%2Fregxread.c;h=4b26b8a4b3a622cde7579ea8f170f52d5aa6ce83;hb=2afddbf2fbd917d03179d53ea602f22645182fa3;hp=b2290a5b13da5ae3ffa12ca27db4302f5fd12d8a;hpb=c4318fe5480927a441042829d2953fc1484fb46b;p=idzebra-moved-to-github.git diff --git a/recctrl/regxread.c b/recctrl/regxread.c index b2290a5..4b26b8a 100644 --- a/recctrl/regxread.c +++ b/recctrl/regxread.c @@ -1,5 +1,5 @@ -/* $Id: regxread.c,v 1.48 2003-06-17 22:22:57 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 +/* $Id: regxread.c,v 1.50 2004-05-25 12:13:15 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -882,7 +882,7 @@ static int tryMatch (struct lexSpec *spec, int *pptr, int *mptr, { struct DFA_state *state = dfa->states[0]; struct DFA_tran *t; - unsigned char c; + unsigned char c = 0; unsigned char c_prev = 0; int ptr = *pptr; /* current pointer */ int start_ptr = *pptr; /* first char of match */ @@ -903,7 +903,6 @@ static int tryMatch (struct lexSpec *spec, int *pptr, int *mptr, c_prev = c; restore_ptr = ptr; } - c = f_win_advance (spec, &ptr); if (ptr == F_WIN_EOF) @@ -920,7 +919,7 @@ static int tryMatch (struct lexSpec *spec, int *pptr, int *mptr, t = state->trans; i = state->tran_no; while (1) - if (--i < 0) + if (--i < 0) /* no transition for character c */ { if (last_rule) { @@ -950,8 +949,7 @@ static int tryMatch (struct lexSpec *spec, int *pptr, int *mptr, last_rule = state->rule_nno; last_ptr = ptr; } - else - break; + break; } else t++; @@ -1050,6 +1048,8 @@ static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp, #endif res = data1_mk_root (spec->dh, spec->m, absynName); + spec->d1_level = 0; + spec->d1_stack[spec->d1_level++] = res; res = data1_mk_tag (spec->dh, spec->m, absynName, 0, res); @@ -1109,7 +1109,7 @@ static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp, } else if (!strcmp (argv[1], "element")) { - int min_level = 1; + int min_level = 2; char *element = 0; if (argc >= 3 && !strcmp(argv[2], "-record")) { @@ -1121,7 +1121,7 @@ static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp, if (argc == 3) element = argv[2]; tagEnd (spec, min_level, element, (element ? strlen(element) : 0)); - if (spec->d1_level == 0) + if (spec->d1_level <= 1) { #if REGX_DEBUG logf (LOG_LOG, "end element end records"); @@ -1182,7 +1182,7 @@ static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp, argi++; } if (element) - tagEnd (spec, 1, NULL, 0); + tagEnd (spec, 2, NULL, 0); return TCL_OK; } @@ -1285,7 +1285,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) continue; - if (spec->d1_level == 0) + if (spec->d1_level <= 1) { static char absynName[64]; data1_node *res; @@ -1299,6 +1299,8 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) #endif res = data1_mk_root (spec->dh, spec->m, absynName); + spec->d1_level = 0; + spec->d1_stack[spec->d1_level++] = res; res = data1_mk_tag (spec->dh, spec->m, absynName, 0, res); @@ -1397,7 +1399,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) } else if (!strcmp (p, "element")) { - int min_level = 1; + int min_level = 2; while ((r = execTok (spec, &s, &cmd_str, &cmd_len)) == 3) { if (cmd_len==7 && !memcmp ("-record", cmd_str, cmd_len)) @@ -1410,7 +1412,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) } else tagEnd (spec, min_level, NULL, 0); - if (spec->d1_level == 0) + if (spec->d1_level <= 1) { #if REGX_DEBUG logf (LOG_LOG, "end element end records"); @@ -1464,7 +1466,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) r = execTok (spec, &s, &cmd_str, &cmd_len); } while (r > 1); if (element_str) - tagEnd (spec, 1, NULL, 0); + tagEnd (spec, 2, NULL, 0); } else if (!strcmp (p, "unread")) {