From 9a7eeca8f238807650780be2cd37e1851396c9d9 Mon Sep 17 00:00:00 2001 From: Marc-Philip Werner Date: Tue, 17 Jul 2018 12:08:09 +0000 Subject: [PATCH] move variable declarations Need that at the beginning of the blocks to make it real C code that is understood by MSVC. --- perl-libxml-mm.c | 2 +- perl-libxml-sax.c | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/perl-libxml-mm.c b/perl-libxml-mm.c index 4ee84748..afe82d5e 100644 --- a/perl-libxml-mm.c +++ b/perl-libxml-mm.c @@ -1207,8 +1207,8 @@ nodeSv2C( SV * scalar, xmlNodePtr refnode ) xmlDocPtr real_dom = refnode->doc; xs_warn("nodeSv2C: have node!\n"); if (real_dom != NULL && real_dom->encoding != NULL ) { - xs_warn("nodeSv2C: encode string!\n"); dTHX; + xs_warn("nodeSv2C: encode string!\n"); /* speed things a bit up.... */ if ( scalar != NULL && scalar != &PL_sv_undef ) { STRLEN len = 0; diff --git a/perl-libxml-sax.c b/perl-libxml-sax.c index e58b5d13..b949d3c2 100644 --- a/perl-libxml-sax.c +++ b/perl-libxml-sax.c @@ -845,22 +845,23 @@ PmmGenLocator( xmlSAXLocatorPtr loc) void PmmUpdateLocator( xmlParserCtxtPtr ctxt ) { + dTHX; + const xmlChar * encoding; + const xmlChar * version; PmmSAXVectorPtr sax = (PmmSAXVectorPtr)ctxt->_private; if (sax->locator == NULL) { return; } - dTHX; - (void) hv_store(sax->locator, "LineNumber", 10, newSViv(ctxt->input->line), 0); (void) hv_store(sax->locator, "ColumnNumber", 12, newSViv(ctxt->input->col), 0); - const xmlChar * encoding = ctxt->input->encoding; - const xmlChar * version = ctxt->input->version; + encoding = ctxt->input->encoding; + version = ctxt->input->version; if ( encoding != NULL && XML_STR_NOT_EMPTY( encoding ) ) { (void) hv_store(sax->locator, "Encoding", 8, @@ -929,9 +930,8 @@ PSaxStartDocument(void * ctx) SV * rv; if ( handler != NULL ) { - PmmUpdateLocator(ctx); - dSP; + PmmUpdateLocator(ctx); ENTER; SAVETMPS; @@ -1211,11 +1211,10 @@ PSaxComment(void *ctx, const xmlChar * ch) { dTHX; HV* element; SV * handler = sax->handler; + SV * rv = NULL; PmmUpdateLocator(ctx); - SV * rv = NULL; - if ( ch != NULL && handler != NULL ) { dSP; @@ -1256,14 +1255,12 @@ PSaxCDATABlock(void *ctx, const xmlChar * ch, int len) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx; PmmSAXVectorPtr sax = (PmmSAXVectorPtr)ctxt->_private; dTHX; - - PmmUpdateLocator(ctx); - HV* element; SV * handler = sax->handler; - SV * rv = NULL; + PmmUpdateLocator(ctx); + if ( ch != NULL && handler != NULL ) { dSP; @@ -1328,12 +1325,11 @@ PSaxProcessingInstruction( void * ctx, const xmlChar * target, const xmlChar * d PmmSAXVectorPtr sax = (PmmSAXVectorPtr)ctxt->_private; dTHX; SV * handler = sax->handler; - - PmmUpdateLocator(ctx); - SV * element; SV * rv = NULL; + PmmUpdateLocator(ctx); + if ( handler != NULL ) { dSP; @@ -1375,14 +1371,14 @@ void PSaxExternalSubset (void * ctx, { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx; PmmSAXVectorPtr sax = (PmmSAXVectorPtr)ctxt->_private; - PmmUpdateLocator(ctx); dTHX; SV * handler = sax->handler; - SV * element; SV * rv = NULL; + PmmUpdateLocator(ctx); + if ( handler != NULL ) { dSP;