From ce91b4f0135dec0871730306abd6134b42a7ca89 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Wed, 20 Jun 2018 14:19:21 +0200 Subject: [PATCH] Fixed comment interrupting bug in xsd2ttcn (bug 536084) Change-Id: If266724dda5edd38d6a86823677bc3c9f928e664 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- .../tail_f_com_ns_confd_1_0_e.ttcn | 56 +++++++------------ ...isco_IntegratedSite_R4L06_R4AB_1_02_e.ttcn | 5 +- .../www_ericsson_com_is_isco_Mgw_R9B27_e.ttcn | 31 ++++------ .../www_w3_org_XML_1998_namespace_PIDF_e.ttcn | 15 ++--- xsdconvert/XMLParser.cc | 34 +++++++++-- 5 files changed, 69 insertions(+), 72 deletions(-) diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/tail_f_com_ns_confd_1_0_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/tail_f_com_ns_confd_1_0_e.ttcn index d41790dca..51a695dc0 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/tail_f_com_ns_confd_1_0_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/tail_f_com_ns_confd_1_0_e.ttcn @@ -281,19 +281,17 @@ with { standard 'xs:default' attribute. Consider this example: */ -/* < */ -/* xs:element name="size" type="xs:long" minOccurs="0" +/* <xs:element name="size" type="xs:long" minOccurs="0" xmlns:confd="http://tail-f.com/ns/confd/1.0" confd:default="42" */ -/* > */ -/* In an instance document this means: +/* > + + In an instance document this means: o If the size tag is left out; "42" is stored in the configuration database. o If the size tag is empty, i.e. */ -/* < */ -/* size/ */ -/* > */ -/* , the empty string is +/* <size/ */ +/* >, the empty string is stored in the configuration database. Using the standard attribute this would have happened: @@ -326,43 +324,29 @@ with { xs:simpleType constructs in confspec files. Consider this example: */ -/* < */ -/* xs:simpleType name="foo" */ -/* > */ -/* < */ -/* xs:restriction base="xs:string" */ -/* > */ -/* < */ -/* xs:minLength value="7"/ */ +/* <xs:simpleType name="foo" */ /* > */ -/* < */ -/* xs:maxLength value="15"/ */ +/* <xs:restriction base="xs:string" */ /* > */ -/* < */ -/* xs:pattern value="[a-z]*" */ +/* <xs:minLength value="7"/ */ /* > */ -/* < */ -/* confd:error-app-tag */ +/* <xs:maxLength value="15"/ */ /* > */ -/* ... */ -/* < */ -/* /confd:error-app-tag */ +/* <xs:pattern value="[a-z]*" */ /* > */ -/* < */ -/* confd:error-message */ +/* <confd:error-app-tag */ +/* >... */ +/* </confd:error-app-tag */ /* > */ -/* ... */ -/* < */ -/* /confd:error-message */ +/* <confd:error-message */ +/* >... */ +/* </confd:error-message */ /* > */ -/* < */ -/* /xs:pattern */ +/* </xs:pattern */ /* > */ -/* < */ -/* /xs:restriction */ +/* </xs:restriction */ /* > */ -/* < */ -/* /xs:simpleType */ +/* </xs:simpleType */ /* > */ type XSD.String ErrorMessage with { diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_IntegratedSite_R4L06_R4AB_1_02_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_IntegratedSite_R4L06_R4AB_1_02_e.ttcn index fdeb3d0eb..145735b0f 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_IntegratedSite_R4L06_R4AB_1_02_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_IntegratedSite_R4L06_R4AB_1_02_e.ttcn @@ -757,8 +757,9 @@ type record IntegratedSite are created, each one needs to be mapped to an IS Subnet Segment before the blades can be unlocked via the Hardware service. The mapping is done - with the 'isSubnetSegmentRef' attribute. */ - /* Different instances of a blade system type may + with the 'isSubnetSegmentRef' attribute. + + Different instances of a blade system type may call their BS Subnet Segments the same thing but in the end the IS Site Designer can choose to map them to the same or different IS Subnet diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_Mgw_R9B27_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_Mgw_R9B27_e.ttcn index 6e129a529..fb787890d 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_Mgw_R9B27_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_ericsson_com_is_isco_Mgw_R9B27_e.ttcn @@ -417,8 +417,7 @@ type XSD.Token GwmAlphaNumericString_l35 (pattern "[a-zA-Z0-9]*") length(1 .. 35 /* This datatype defines the images that can be loaded on the media processing devices. Image type is called 'media profile' in the CPI (Customer Product Information) and in the ISM (IS Management). - The media profile supports various types of compress */ -/* ion algorithms. + The media profile supports various types of compression algorithms. 1 - voiceStandard, supports the following codecs: * G.711 (PCM 64 kbit/s) for voice coding, fax, text telephone, TTY/Telecommunication Device for Deaf (TDD) or modem @@ -2149,8 +2148,7 @@ with { Delete MO cannot be performed (operation-failed) in the following cases: - if MO is system created - if MO contains childs and the childs are not system created - - if MO is referred to fro */ -/* m other MO in the model + - if MO is referred to from other MO in the model 3) Any MOC specific error case is described in the MOC description. */ type record Mgw @@ -2295,8 +2293,7 @@ type record Mgw The threshold value is 10 raised to -N (10^-N). An alarm will be issued when the threshold has been reached. The alarm will be cleared when the excessive BER falls below one tenth of the threshold value. The threshold value must not be less than the linkDegBerThr threshold. - The default a */ - /* ttribute value is 3, corresponding to a threshold value of 10^-3, for both CRC4 and Basic frame mode. */ + The default attribute value is 3, corresponding to a threshold value of 10^-3, for both CRC4 and Basic frame mode. */ IntfE1ExcBerThreshold linkExcBerThr optional, /* An integer value N that defines the threshold value for degraded Bit Error Rate (BER) on the E1 interface. The threshold value is 10 raised to -N (10^-N). An alarm will be issued when the threshold has been reached. @@ -3999,8 +3996,7 @@ associated interface route is also deleted. */ _ (underscore). Uppercase letters may be entered but are converted to lower case when the attribute is stored internally. The name is optional and - may be */ - /* left empty. Used for ISM purpose only */ + may be left empty. Used for ISM purpose only */ InterfaceNameType_195 interfaceName optional, /* A hexadecimal indicating which timeslots are used as signaling interfaces. @@ -4154,8 +4150,7 @@ associated interface route is also deleted. */ 30 ms for G.723. For example: If G.711 with ptime 20 ms and G.723 with ptime 30 ms are - used in the network, the b */ - /* uffer size must at least have a size of + used in the network, the buffer size must at least have a size of 60 ms, since G.723 is the worst case (30 ms ptime + 30 ms frame time) A modification of this attribute does only affect new calls, not @@ -4786,8 +4781,7 @@ associated interface route is also deleted. */ normalMGExecutionTime received via H.248 from the GC overwrites the configured value. - Attribute admState must be locked when cha */ - /* nged. + Attribute admState must be locked when changed. Recommended value: 2000 */ NormalMGExecutionTimeType_147 normalMGExecutionTime optional, @@ -4949,8 +4943,7 @@ associated interface route is also deleted. */ (which implies that the remote IP address is disregarded when sorting the connection). - Note! When changing defaultRemotePre */ - /* fixMaskLength, streams set up after + Note! When changing defaultRemotePrefixMaskLength, streams set up after the change will be sorted according to the new value, but existing streams will not be affected. */ DefaultRemotePrefixMaskLengthType_3 defaultRemotePrefixMaskLength optional, @@ -4992,8 +4985,8 @@ associated interface route is also deleted. */ A new NetworkPathGroup is dynamically created when a RTP media connection with a new local and remote IP address prefix combination is established. Connections established later on with the same IP - address prefix combination will be placed in the same group. */ - /* Once a day the unused NetworkPathGroups are removed.(A + address prefix combination will be placed in the same group. + Once a day the unused NetworkPathGroups are removed.(A NetworkPathGroup is considered as unused when there has been no connection part of that group during the last 24 hours). @@ -5118,8 +5111,7 @@ associated interface route is also deleted. */ /* The amount of received RTP packets for the video streams. Lost packets are not included. To get an average value, this counter can be divided by the counter - accumVideoNoOfReadings. The */ - /* division will result in an average + accumVideoNoOfReadings. The division will result in an average per video channel and 15-second period. Family=Accumulated RTP/RTCP statistics. */ MbqmCounter64 accumVideoPackRcvd optional, @@ -5177,8 +5169,7 @@ associated interface route is also deleted. */ } qosMonitoring, /* The 3G-324M parameters. */ record { - /* The attribute is used to enable or disable continous AMR transmission towards the 3G-324M terminal. The attribute affects channels configured for transcoder-free AMR operation. Continuous AMR transmission means that AMR 'No Data' frames will be inserted in the audio stream towards the 3G-324M terminal if the channel runs out of audio data, for example, due to loss */ - /* of audio RTP packets in the IP network. The default value is 1 (enabled). */ + /* The attribute is used to enable or disable continous AMR transmission towards the 3G-324M terminal. The attribute affects channels configured for transcoder-free AMR operation. Continuous AMR transmission means that AMR 'No Data' frames will be inserted in the audio stream towards the 3G-324M terminal if the channel runs out of audio data, for example, due to loss of audio RTP packets in the IP network. The default value is 1 (enabled). */ DspcpContinousAmrTrans continousAmrTrans optional, /* The size (number of bytes) of the video buffer per channel towards the 3G-324M terminal. The buffer absorbs network jitter and video bit rate peaks sent by the remote IP terminal. Additional received video RTP packets are discarded when reaching the limit. */ VideoBufferSizeType_5 videoBufferSize optional, diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_w3_org_XML_1998_namespace_PIDF_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_w3_org_XML_1998_namespace_PIDF_e.ttcn index fbba75bfa..b3a3bdf80 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_w3_org_XML_1998_namespace_PIDF_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_w3_org_XML_1998_namespace_PIDF_e.ttcn @@ -96,20 +96,16 @@ const Space c_defaultForEmpty_1 := preserve; To enable this, such a schema must import this schema for the XML namespace, e.g. as follows: */ -/* < */ -/* schema . . .> +/* <schema . . .> . . . */ -/* < */ -/* import namespace="http://www.w3.org/XML/1998/namespace" +/* <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> Subsequently, qualified reference to any of the attributes or the group defined below will have the desired effect, e.g. */ -/* < */ -/* type . . .> +/* <type . . .> . . . */ -/* < */ -/* attributeGroup ref="xml:specialAttrs"/> +/* <attributeGroup ref="xml:specialAttrs"/> will define a type which will schema-validate an instance element with any of those attributes */ @@ -124,8 +120,7 @@ const Space c_defaultForEmpty_1 := preserve; in order to remain compatible with the latest version of XML Schema itself. In other words, if the XML Schema namespace changes, the version of this document at - http://www.w3. */ -/* org/2001/xml.xsd will change + http://www.w3.org/2001/xml.xsd will change accordingly; the version at http://www.w3.org/2001/03/xml.xsd will not change. */ diff --git a/xsdconvert/XMLParser.cc b/xsdconvert/XMLParser.cc index 4defa83bd..59bba6465 100644 --- a/xsdconvert/XMLParser.cc +++ b/xsdconvert/XMLParser.cc @@ -436,10 +436,36 @@ void XMLParser::characterdataHandler(const xmlChar * text, const int length) { if (suspended) { return; } - - char * temp = (char *) Malloc(length + 1); - memcpy(temp, text, length); - temp[length] = '\0'; + + // the parser sometimes sends a comment in multiple parts (most likely when + // the parser's read buffer ends in the middle of a comment) + // use static variables to flag this event and store the data for the next call + static bool interrupted = false; + static char* temp; + size_t old_length; + if (interrupted) { + // the comment was interrupted in the previous call, append this call's data + // to the previous call's + old_length = strlen(temp); + temp = (char *) Realloc(temp, old_length + length + 1); + } + else { + // the comment was not interrupted in the previous call, proceed as normal + temp = (char *) Malloc(length + 1); + old_length = 0; + } + memcpy(temp + old_length, text, length); + temp[old_length + length] = '\0'; + + if (text[length] == '\0') { + // a \0 character means the parser's read buffer has ended (otherwise the + // next character would be the beginning of an XML tag) + interrupted = true; + return; // the comment will continue in the next call + } + + // the comment is assembled + interrupted = false; Mstring comment(temp); Free(temp); -- GitLab