X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=util%2Fsnippet.c;h=a1a289f488056cf722b23ff8ed49be7a7735e61b;hp=b299e5f84724ad6d51356d6aa3ec2f3e07014fed;hb=426d07a60c57c3555934655a78437cf4677c65c8;hpb=6988ba91e363565638c27a8d5895ad9afc409e75 diff --git a/util/snippet.c b/util/snippet.c index b299e5f..a1a289f 100644 --- a/util/snippet.c +++ b/util/snippet.c @@ -1,8 +1,5 @@ -/* $Id: snippet.c,v 1.13 2007-08-21 11:06:47 adam Exp $ - Copyright (C) 1995-2007 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2009 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -24,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include struct zebra_snippets { @@ -105,10 +103,15 @@ void zebra_snippets_log(const zebra_snippets *l, int log_level, int all) zebra_snippet_word *w; for (w = l->front; w; w = w->next) { + WRBUF wr_term = wrbuf_alloc(); + wrbuf_puts_escaped(wr_term, w->term); + if (all || w->mark) yaz_log(log_level, "term='%s'%s mark=%d seqno=" ZINT_FORMAT " ord=%d", - w->term, (w->match && !w->ws ? "*" : ""), w->mark, + wrbuf_cstr(wr_term), + (w->match && !w->ws ? "*" : ""), w->mark, w->seqno, w->ord); + wrbuf_destroy(wr_term); } } @@ -209,6 +212,25 @@ static void zebra_snippets_clear(zebra_snippets *sn) } } +const struct zebra_snippet_word *zebra_snippets_lookup( + const zebra_snippets *doc, const zebra_snippets *hit) +{ + const zebra_snippet_word *hit_w; + for (hit_w = zebra_snippets_constlist(hit); hit_w; hit_w = hit_w->next) + { + const zebra_snippet_word *doc_w; + for (doc_w = zebra_snippets_constlist(doc); doc_w; doc_w = doc_w->next) + { + if (doc_w->ord == hit_w->ord && doc_w->seqno == hit_w->seqno + && !doc_w->ws) + { + return doc_w; + } + } + } + return 0; +} + void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, int before, int after) { @@ -285,6 +307,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab