Fix broken xml entity.
[idzebra-moved-to-github.git] / util / snippet.c
index 10e69c0..cb8b65b 100644 (file)
@@ -1,8 +1,5 @@
-/* $Id: snippet.c,v 1.14 2007-08-21 13:27:04 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) 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
@@ -20,10 +17,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 */
 
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <stddef.h>
 #include <string.h>
 #include <yaz/nmem.h>
 #include <yaz/log.h>
+#include <yaz/wrbuf.h>
 #include <idzebra/snippet.h>
 
 struct zebra_snippets {
@@ -105,10 +106,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);
     }
 }
 
@@ -183,7 +189,7 @@ zebra_snippets *zebra_snippets_window(const zebra_snippets *doc,
                     hit_w = hit_w->next)
                {
                    if (hit_w->ord == ord && hit_w->seqno == doc_w->seqno)
-                       
+
                    {
                        match = 1;
                        break;
@@ -191,7 +197,7 @@ zebra_snippets *zebra_snippets_window(const zebra_snippets *doc,
                }
                zebra_snippets_append_match(result, doc_w->seqno,
                                             doc_w->ws,
-                                           ord, doc_w->term, 
+                                           ord, doc_w->term,
                                             strlen(doc_w->term), match);
            }
     }
@@ -263,7 +269,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit,
                         doc_w->mark = 1;
                         break;
                     }
-                    
+
                 }
                 /* mark following terms */
                 if (doc_w)
@@ -271,7 +277,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit,
                     zebra_snippet_word *w = doc_w->next;
                     while (w)
                         if (w->ord == ord
-                            && hit_w->seqno - before < w->seqno 
+                            && hit_w->seqno - before < w->seqno
                             && hit_w->seqno + after > w->seqno)
                         {
                             w->mark = 1;
@@ -286,7 +292,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit,
                     zebra_snippet_word *w = doc_w->prev;
                     while (w)
                         if (w->ord == ord
-                            && hit_w->seqno - before < w->seqno 
+                            && hit_w->seqno - before < w->seqno
                             && hit_w->seqno + after > w->seqno)
                         {
                             w->mark = 1;
@@ -300,10 +306,11 @@ 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