Date: 11 Sep 2012 11:28:39 -0000 From: Michael Gmelin <freebsd@grem.de> To: FreeBSD-gnats-submit@FreeBSD.org Cc: gahr@FreeBSD.org Subject: ports/171537: [PATCH] textproc/xerces-c3: Fix bug in ContentSpecNode and allow compilation using C++11 (Clang) Message-ID: <20120911112839.66868.qmail@mail.grem.de> Resent-Message-ID: <201209111130.q8BBU3dP034314@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 171537 >Category: ports >Synopsis: [PATCH] textproc/xerces-c3: Fix bug in ContentSpecNode and allow compilation using C++11 (Clang) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 11 11:30:03 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Michael Gmelin >Release: FreeBSD 9.1-RC1 amd64 >Organization: Grem Equity GmbH >Environment: System: FreeBSD clangcompile 9.1-RC1 FreeBSD 9.1-RC1 #1 r240177: Fri Sep 7 14:37:21 UTC 2012 >Description: Fix an operator precedence error in ContentSpecNode::getMaxTotalRange that leads to wrong max calculation in choices while parsing xml schemata (see also https://issues.apache.org/jira/browse/XERCESC-1994). Add static_cast to explicitely narrow down types to allow compilation using C++11. especially Clang, since it treats those as errors (see also https://issues.apache.org/jira/browse/XERCESC-1995) Added file(s): - files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp - files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp - files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp - files/patch-src-xercesc-util-regx-RegxParser.cpp - files/patch-src-xercesc-validators-common-ContentSpecNode.cpp Port maintainer (gahr@FreeBSD.org) is cc'd. Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: suffix) >How-To-Repeat: >Fix: --- xerces-c3-3.1.1_1.patch begins here --- diff -ruN --exclude=CVS ../xerces-c3.orig/Makefile ./Makefile --- ../xerces-c3.orig/Makefile 2012-09-11 13:04:01.239569124 +0200 +++ ./Makefile 2012-09-11 13:04:15.272531693 +0200 @@ -7,6 +7,7 @@ PORTNAME= xerces-c3 PORTVERSION= 3.1.1 +PORTREVISION= 1 CATEGORIES= textproc MASTER_SITES= ${MASTER_SITE_APACHE} MASTER_SITE_SUBDIR= xerces/c/3/sources diff -ruN --exclude=CVS ../xerces-c3.orig/files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp ./files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp --- ../xerces-c3.orig/files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp 1970-01-01 01:00:00.000000000 +0100 +++ ./files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp 2012-09-11 13:07:20.169566372 +0200 @@ -0,0 +1,53 @@ +--- src.orig/xercesc/util/XMLUTF8Transcoder.cpp ++++ src/xercesc/util/XMLUTF8Transcoder.cpp +@@ -178,7 +178,7 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData + if((gUTFByteIndicatorTest[trailingBytes] & *srcPtr) != gUTFByteIndicator[trailingBytes]) { + char pos[2] = {(char)0x31, 0}; + char len[2] = {(char)(trailingBytes+0x31), 0}; +- char byte[2] = {*srcPtr,0}; ++ char byte[2] = {static_cast<char>(*srcPtr),0}; + ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager()); + } + +@@ -246,8 +246,8 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData + // + if (( *srcPtr == 0xE0) && ( *(srcPtr+1) < 0xA0)) + { +- char byte0[2] = {*srcPtr ,0}; +- char byte1[2] = {*(srcPtr+1),0}; ++ char byte0[2] = {static_cast<char>(*srcPtr) ,0}; ++ char byte1[2] = {static_cast<char>(*(srcPtr+1)),0}; + + ThrowXMLwithMemMgr2(UTFDataFormatException + , XMLExcepts::UTF8_Invalid_3BytesSeq +@@ -284,8 +284,8 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData + + if ((*srcPtr == 0xED) && (*(srcPtr+1) >= 0xA0)) + { +- char byte0[2] = {*srcPtr, 0}; +- char byte1[2] = {*(srcPtr+1),0}; ++ char byte0[2] = {static_cast<char>(*srcPtr), 0}; ++ char byte1[2] = {static_cast<char>(*(srcPtr+1)),0}; + + ThrowXMLwithMemMgr2(UTFDataFormatException + , XMLExcepts::UTF8_Irregular_3BytesSeq +@@ -310,8 +310,8 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData + if (((*srcPtr == 0xF0) && (*(srcPtr+1) < 0x90)) || + ((*srcPtr == 0xF4) && (*(srcPtr+1) > 0x8F)) ) + { +- char byte0[2] = {*srcPtr ,0}; +- char byte1[2] = {*(srcPtr+1),0}; ++ char byte0[2] = {static_cast<char>(*srcPtr) ,0}; ++ char byte1[2] = {static_cast<char>(*(srcPtr+1)),0}; + + ThrowXMLwithMemMgr2(UTFDataFormatException + , XMLExcepts::UTF8_Invalid_4BytesSeq +@@ -344,7 +344,7 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData + * surrogates, nor U+FFFE and U+FFFF (but it does allow other noncharacters). + ***/ + char len[2] = {(char)(trailingBytes+0x31), 0}; +- char byte[2] = {*srcPtr,0}; ++ char byte[2] = {static_cast<char>(*srcPtr),0}; + + ThrowXMLwithMemMgr2(UTFDataFormatException + , XMLExcepts::UTF8_Exceeds_BytesLimit diff -ruN --exclude=CVS ../xerces-c3.orig/files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp ./files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp --- ../xerces-c3.orig/files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp 1970-01-01 01:00:00.000000000 +0100 +++ ./files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp 2012-09-11 13:07:40.239741772 +0200 @@ -0,0 +1,11 @@ +--- src.orig/xercesc/util/XMLUTF8Transcoder.hpp ++++ src/xercesc/util/XMLUTF8Transcoder.hpp +@@ -107,7 +107,7 @@ void XMLUTF8Transcoder::checkTrailingBytes(const XMLByte toCheck + { + char len[2] = {(char)(trailingBytes+0x31), 0}; + char pos[2] = {(char)(position+0x31), 0}; +- char byte[2] = {toCheck,0}; ++ char byte[2] = {static_cast<char>(toCheck),0}; + ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager()); + } + diff -ruN --exclude=CVS ../xerces-c3.orig/files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp ./files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp --- ../xerces-c3.orig/files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp 1970-01-01 01:00:00.000000000 +0100 +++ ./files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp 2012-09-11 13:08:12.329569948 +0200 @@ -0,0 +1,11 @@ +--- src.orig/xercesc/util/regx/ParserForXMLSchema.cpp ++++ src/xercesc/util/regx/ParserForXMLSchema.cpp +@@ -156,7 +156,7 @@ XMLInt32 ParserForXMLSchema::decodeEscaped() { + break; + default: + { +- XMLCh chString[] = {chBackSlash, ch, chNull}; ++ XMLCh chString[] = {chBackSlash, static_cast<XMLCh>(ch), chNull}; + ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager()); + } + } diff -ruN --exclude=CVS ../xerces-c3.orig/files/patch-src-xercesc-util-regx-RegxParser.cpp ./files/patch-src-xercesc-util-regx-RegxParser.cpp --- ../xerces-c3.orig/files/patch-src-xercesc-util-regx-RegxParser.cpp 1970-01-01 01:00:00.000000000 +0100 +++ ./files/patch-src-xercesc-util-regx-RegxParser.cpp 2012-09-11 13:08:38.879723669 +0200 @@ -0,0 +1,43 @@ +--- src.orig/xercesc/util/regx/RegxParser.cpp ++++ src/xercesc/util/regx/RegxParser.cpp +@@ -691,11 +691,11 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { + || (ch == chDash && getCharData() == chCloseSquare && firstLoop))) { + // if regex = [-] then invalid... + // '[', ']', '-' not allowed and should be escaped +- XMLCh chStr[] = { ch, chNull }; ++ XMLCh chStr[] = { static_cast<XMLCh>(ch), chNull }; + ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, chStr, chStr, getMemoryManager()); + } + if (ch == chDash && getCharData() == chDash && getState() != REGX_T_BACKSOLIDUS && !wasDecoded) { +- XMLCh chStr[] = { ch, chNull }; ++ XMLCh chStr[] = { static_cast<XMLCh>(ch), chNull }; + ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, chStr, chStr, getMemoryManager()); + } + +@@ -720,7 +720,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { + else { + + XMLInt32 rangeEnd = getCharData(); +- XMLCh rangeEndStr[] = { rangeEnd, chNull }; ++ XMLCh rangeEndStr[] = { static_cast<XMLCh>(rangeEnd), chNull }; + + if (type == REGX_T_CHAR) { + +@@ -737,7 +737,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { + processNext(); + + if (ch > rangeEnd) { +- XMLCh chStr[] = { ch, chNull }; ++ XMLCh chStr[] = { static_cast<XMLCh>(ch), chNull }; + ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_Ope3, rangeEndStr, chStr, getMemoryManager()); + } + +@@ -845,7 +845,7 @@ XMLInt32 RegxParser::decodeEscaped() { + break; + default: + { +- XMLCh chString[] = {chBackSlash, ch, chNull}; ++ XMLCh chString[] = {chBackSlash, static_cast<XMLCh>(ch), chNull}; + ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager()); + } + } diff -ruN --exclude=CVS ../xerces-c3.orig/files/patch-src-xercesc-validators-common-ContentSpecNode.cpp ./files/patch-src-xercesc-validators-common-ContentSpecNode.cpp --- ../xerces-c3.orig/files/patch-src-xercesc-validators-common-ContentSpecNode.cpp 1970-01-01 01:00:00.000000000 +0100 +++ ./files/patch-src-xercesc-validators-common-ContentSpecNode.cpp 2012-09-11 13:09:09.899729005 +0200 @@ -0,0 +1,11 @@ +--- src.orig/xercesc/validators/common/ContentSpecNode.cpp ++++ src/xercesc/validators/common/ContentSpecNode.cpp +@@ -259,7 +259,7 @@ int ContentSpecNode::getMaxTotalRange() const { + else { + + if ((fType & 0x0f) == ContentSpecNode::Choice) { +- max = max * (maxFirst > maxSecond) ? maxFirst : maxSecond; ++ max = max * ((maxFirst > maxSecond) ? maxFirst : maxSecond); + } + else { + max = max * (maxFirst + maxSecond); --- xerces-c3-3.1.1_1.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120911112839.66868.qmail>