X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=data1%2Fd1_read.c;h=54f752517dbb49ce20c8f458a66aeee08736ff5a;hb=e4e44d1916c6e80e01aad163b487ee41c22272ba;hp=fe95dd0ce93e73f863a24c39891a428361fff3de;hpb=60b519816aefda59ed16a7b484f13f144cd1fcac;p=idzebra-moved-to-github.git diff --git a/data1/d1_read.c b/data1/d1_read.c index fe95dd0..54f7525 100644 --- a/data1/d1_read.c +++ b/data1/d1_read.c @@ -1,8 +1,5 @@ -/* $Id: d1_read.c,v 1.26 2007-05-21 11:53:49 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-2011 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 @@ -25,6 +22,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * This module reads "loose" SGML and converts it to data1 tree */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -1105,6 +1105,35 @@ int data1_iconv (data1_handle dh, NMEM m, data1_node *n, return 0; } +void data1_chop_text(data1_handle dh, NMEM m, data1_node *n) +{ + for (; n; n = n->next) + { + if (n->which == DATA1N_data) + { + + int sz = n->u.data.len; + const char *ndata = n->u.data.data; + int off = 0; + + for (off = 0; off < sz; off++) + if (!d1_isspace(ndata[off])) + break; + sz = sz - off; + ndata += off; + + while (sz && d1_isspace(ndata[sz - 1])) + sz--; + + n->u.data.data = nmem_malloc(m, sz); + n->u.data.len = sz; + memcpy(n->u.data.data, ndata, sz); + + } + data1_chop_text(dh, m, n->child); + } +} + void data1_concat_text(data1_handle dh, NMEM m, data1_node *n) { for (; n; n = n->next) @@ -1134,9 +1163,11 @@ void data1_concat_text(data1_handle dh, NMEM m, data1_node *n) data1_concat_text(dh, m, n->child); } } + /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab