From 8c93530f7b60e9125f661654dd47bb623a64b661 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 5 May 2010 13:30:45 +0200 Subject: [PATCH] Fun normalize_record_transform: fix un-init var And reformat a bit. --- src/normalize_record.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/normalize_record.c b/src/normalize_record.c index fa39da2..5623c33 100644 --- a/src/normalize_record.c +++ b/src/normalize_record.c @@ -121,34 +121,35 @@ void normalize_record_destroy(normalize_record_t nt) } int normalize_record_transform(normalize_record_t nt, xmlDoc **doc, - const char **parms) + const char **parms) { - struct normalize_step *m; - if (nt) { + if (nt) + { + struct normalize_step *m; for (m = nt->steps; m; m = m->next) { xmlNodePtr root = 0; - xmlDoc *new; + xmlDoc *ndoc; if (m->stylesheet) - { - new = xsltApplyStylesheet(m->stylesheet, *doc, parms); - } + ndoc = xsltApplyStylesheet(m->stylesheet, *doc, parms); else if (m->marcmap) - { - new = marcmap_apply(m->marcmap, *doc); - } - - root = xmlDocGetRootElement(new); - + ndoc = marcmap_apply(m->marcmap, *doc); + else + ndoc = 0; xmlFreeDoc(*doc); - if (!new || !root || !root->children) + *doc = 0; + + if (ndoc) + root = xmlDocGetRootElement(ndoc); + + if (ndoc && root && root->children) + *doc = ndoc; + else { - if (new) - xmlFreeDoc(new); - *doc = 0; + if (ndoc) + xmlFreeDoc(ndoc); return -1; } - *doc = new; } } return 0; -- 1.7.10.4