From 8ecd6580fa39d2bb13304a48fd655d301b0fdc19 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Mon, 15 Oct 2018 18:18:29 +0200 Subject: [PATCH] XER dec: changed 'anyElement' fix in record of record (bug 539956) Change-Id: Ie5e57b155fa05e628f53c2ddcb8ed3714289bbe5 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/record.c | 25 +++++++++++++++++++++++ core/Universal_charstring.cc | 9 -------- core/Universal_charstring.hh | 3 --- core2/Basetype2.cc | 22 ++++++++++++-------- regression_test/XML/NegativeTest/Makefile | 2 +- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/compiler2/record.c b/compiler2/record.c index f13cd53e6..0eed9ea52 100644 --- a/compiler2/record.c +++ b/compiler2/record.c @@ -1961,6 +1961,17 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) /* The last component with which it can begin is the first non-optional. * Does that sentence makes sense to you ? */ } + for (i = 0; i < sdef->nElements; i++) { + if (strcmp(sdef->elements[i].type, "UNIVERSAL_CHARSTRING") == 0 && + !sdef->elements[i].xerAttribute) { + src = mputprintf(src, + " else if (%s_xer_.xer_bits & ANY_ELEMENT) return TRUE;\n" + , sdef->elements[i].typegen); + } + if (!sdef->elements[i].isOptional && !sdef->elements[i].xerAttribute) { + break; + } + } src = mputstr(src, " return FALSE;\n}\n\n"); /* * * * * * * * * * XER_encode * * * * * * * * * * * * * * */ @@ -7731,6 +7742,20 @@ check_generate_end: src = mputprintf(src, " else if (%s::can_start(p_name, p_uri, %s_xer_, p_flavor, p_flavor2)) return TRUE;\n" , sdef->elements[i].type, sdef->elements[i].typegen); + if (!sdef->elements[i].isOptional) { + break; + } + } + for (i = 0; i < sdef->nElements; i++) { + if (strcmp(sdef->elements[i].type, "UNIVERSAL_CHARSTRING") == 0 && + !sdef->elements[i].xerAttribute) { + src = mputprintf(src, + " else if (%s_xer_.xer_bits & ANY_ELEMENT) return TRUE;\n" + , sdef->elements[i].typegen); + } + if (!sdef->elements[i].isOptional && !sdef->elements[i].xerAttribute) { + break; + } } src = mputstr(src, " return FALSE;\n" diff --git a/core/Universal_charstring.cc b/core/Universal_charstring.cc index cc777a956..6e8318042 100644 --- a/core/Universal_charstring.cc +++ b/core/Universal_charstring.cc @@ -891,15 +891,6 @@ void UNIVERSAL_CHARSTRING::dump() const } } -boolean UNIVERSAL_CHARSTRING::can_start(const char *name, const char *uri, - XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2) -{ - if (is_exer(flavor) && (xd.xer_bits & ANY_ELEMENT)) { - return TRUE; - } - return Base_Type::can_start(name, uri, xd, flavor, flavor2); -} - void UNIVERSAL_CHARSTRING::log() const { if (charstring) { diff --git a/core/Universal_charstring.hh b/core/Universal_charstring.hh index bdb8c279e..478965c55 100644 --- a/core/Universal_charstring.hh +++ b/core/Universal_charstring.hh @@ -271,9 +271,6 @@ public: CHARSTRING get_stringRepr_for_pattern() const; void dump() const; - - static boolean can_start(const char *name, const char *uri, - XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2); private: // convert this string to character string for pattern matching: ([A-P]{8})* diff --git a/core2/Basetype2.cc b/core2/Basetype2.cc index cc0036ccf..9777189db 100644 --- a/core2/Basetype2.cc +++ b/core2/Basetype2.cc @@ -5820,15 +5820,21 @@ int Record_Type::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, else { // In case the field is an optional anyElement -> check if it should be omitted boolean optional_any_elem_check = TRUE; - if (get_at(i)->is_optional() && (xer_descr(i)->xer_bits & ANY_ELEMENT)) { - // The "anyElement" coding instruction can only be applied to a universal charstring field - OPTIONAL<UNIVERSAL_CHARSTRING>* opt_field = dynamic_cast<OPTIONAL<UNIVERSAL_CHARSTRING>*>(get_at(i)); - if (opt_field) { - const char* next_field_name = NULL; - if (i < field_cnt - 1) { - next_field_name = fld_name(i + 1); + if (xer_descr(i)->xer_bits & ANY_ELEMENT) { + if (get_at(i)->is_optional()) { + // The "anyElement" coding instruction can only be applied to a universal charstring field + OPTIONAL<UNIVERSAL_CHARSTRING>* opt_field = dynamic_cast<OPTIONAL<UNIVERSAL_CHARSTRING>*>(get_at(i)); + if (opt_field) { + const char* next_field_name = NULL; + if (i < field_cnt - 1) { + next_field_name = fld_name(i + 1); + } + optional_any_elem_check = opt_field->XER_check_any_elem(reader, next_field_name, tag_closed); } - optional_any_elem_check = opt_field->XER_check_any_elem(reader, next_field_name, tag_closed); + } + else if (tag_closed) { + // If the record is emptyElement, there's no way it will have an anyElement field + reader.Read(); } } if (optional_any_elem_check && !already_processed) { diff --git a/regression_test/XML/NegativeTest/Makefile b/regression_test/XML/NegativeTest/Makefile index 0146c2f19..1359cfc52 100644 --- a/regression_test/XML/NegativeTest/Makefile +++ b/regression_test/XML/NegativeTest/Makefile @@ -166,5 +166,5 @@ RUN := endif run: $(TARGET) run.cfg - if $(RUN) ./$^; then ./indent.pl neg.log; else ./indent.pl neg.log; exit 1; fi + $(RUN) ./$^ -- GitLab