X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Frecgrs.c;h=6ebf807be559c0590fe3b4fc389e987aeb3bc675;hb=d5c921e71defabcb16299ee27bd7c9bdabe2e461;hp=c09f731f8f53b7b2d21b7a18f1f636191be12db1;hpb=852d5f1f9aa0a70f7e54a68143ee86752394a2f2;p=idzebra-moved-to-github.git diff --git a/index/recgrs.c b/index/recgrs.c index c09f731..6ebf807 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.5 2006-08-22 13:39:27 adam Exp $ +/* $Id: recgrs.c,v 1.9 2006-10-29 17:20:01 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -245,7 +245,7 @@ static int sp_expr(struct source_parser *sp, data1_node *n, RecWord *wrd) return 1; } -static struct source_parser *source_parser_create() +static struct source_parser *source_parser_create(void) { struct source_parser *sp = xmalloc(sizeof(*sp)); @@ -392,20 +392,37 @@ pop, 2003-01-17 data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) { data1_absyn *abs = n->root->u.root.absyn; - data1_xpelement *xpe = abs->xp_elements; + + data1_xpelement *xpe = 0; data1_node *nn; #ifdef ENHANCED_XELM struct xpath_location_step *xp; #endif char *pexpr = xmalloc(strlen(tagpath)+5); - int ok = 0; sprintf (pexpr, "/%s\n", tagpath); - for (; xpe; xpe = xpe->next) + + for (xpe = abs->xp_elements; xpe; xpe = xpe->next) + xpe->match_state = -1; /* don't know if it matches yet */ + + for (xpe = abs->xp_elements; xpe; xpe = xpe->next) { int i; - ok = dfa_match_first(xpe->dfa->states, pexpr); - + int ok = xpe->match_state; + if (ok == -1) + { /* don't know whether there is a match yet */ + data1_xpelement *xpe1; + + assert(xpe->dfa); + ok = dfa_match_first(xpe->dfa->states, pexpr); + +#if OPTIMIZE_MELM + /* mark this and following ones with same regexp */ + for (xpe1 = xpe; xpe1; xpe1 = xpe1->match_next) + xpe1->match_state = ok; +#endif + } + assert (ok == 0 || ok == 1); if (ok) { #ifdef ENHANCED_XELM /* we have to check the perdicates up to the root node */ @@ -440,7 +457,7 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) xfree(pexpr); - if (ok) { + if (xpe) { yaz_log(YLOG_DEBUG, "Got it"); return xpe->termlists; } else { @@ -547,6 +564,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, if (n->root->u.root.absyn && (tl = xpath_termlist_by_tagpath(tag_path_full, n))) { + zint max_seqno = 0; for (; tl; tl = tl->next) { /* need to copy recword because it may be changed */ @@ -594,7 +612,12 @@ static void index_xpath(struct source_parser *sp, data1_node *n, else (*p->tokenAdd)(&wrd_tl); } + if (wrd_tl.seqno > max_seqno) + max_seqno = wrd_tl.seqno; } + if (max_seqno) + wrd->seqno = max_seqno; + } /* xpath indexing is done, if there was no termlist given, or no ! in the termlist, and default indexing is enabled... */