From 804cbe110c2f61627074d7f495f7d97d086105ff Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 5 May 2003 20:13:28 +0000 Subject: [PATCH] New function data1_concat_text that concatenates text nodes. --- data1/d1_read.c | 29 ++++++++++++++++++++++++++++- include/data1.h | 4 +++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/data1/d1_read.c b/data1/d1_read.c index 438f85d..09d7c52 100644 --- a/data1/d1_read.c +++ b/data1/d1_read.c @@ -1,4 +1,4 @@ -/* $Id: d1_read.c,v 1.3 2003-02-28 12:33:38 oleg Exp $ +/* $Id: d1_read.c,v 1.4 2003-05-05 20:13:29 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -1109,3 +1109,30 @@ int data1_iconv (data1_handle dh, NMEM m, data1_node *n, } return 0; } + +void data1_concat_text(data1_handle dh, NMEM m, data1_node *n) +{ + for (; n; n = n->next) + { + if (n->which == DATA1N_data && n->next && + n->next->which == DATA1N_data) + { + int sz = 0; + int off = 0; + char *ndata; + data1_node *np; + for (np = n; np && np->which == DATA1N_data; np=np->next) + sz += np->u.data.len; + ndata = nmem_malloc(m, sz); + for (np = n; np && np->which == DATA1N_data; np=np->next) + { + memcpy(ndata+off, np->u.data.data, np->u.data.len); + off += np->u.data.len; + } + n->u.data.data = ndata; + n->u.data.len = sz; + n->next = np; + } + data1_concat_text(dh, m, n->child); + } +} diff --git a/include/data1.h b/include/data1.h index 24cf9af..7dabbd9 100644 --- a/include/data1.h +++ b/include/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.6 2003-02-28 12:33:38 oleg Exp $ +/* $Id: data1.h,v 1.7 2003-05-05 20:13:28 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -512,6 +512,8 @@ YAZ_EXPORT int data1_is_xmlmode(data1_handle dh); YAZ_EXPORT const char *data1_systag_lookup(data1_absyn *absyn, const char *tag, const char *default_value); +YAZ_EXPORT void data1_concat_text(data1_handle dh, NMEM m, data1_node *n); + YAZ_END_CDECL #endif -- 1.7.10.4