From: Adam Dickmeiss Date: Wed, 5 May 2010 11:30:45 +0000 (+0200) Subject: Fun normalize_record_transform: fix un-init var X-Git-Tag: v1.4.1~35 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=8c93530f7b60e9125f661654dd47bb623a64b661;p=pazpar2-moved-to-github.git Fun normalize_record_transform: fix un-init var And reformat a bit. --- 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;