From 3cbafbd31d5f79049afbf69f8dcba0b94cbf20b2 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Wed, 15 May 2019 12:12:58 +0200 Subject: [PATCH] Changed default octetstring RAW alignment for backward compatibility (bug 547307) Change-Id: Ie0dc06cb23af91047c5d1ef69afd3d355c7e4b08 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/Type_codegen.cc | 12 ++++++++++-- core/RAW.cc | 2 +- function_test/RAW_EncDec/RAW_EncDec_TD.fast_script | 12 ++++++------ .../referenceguide/4-ttcn3_language_extensions.adoc | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc index 1f277cdb8..a726a8893 100644 --- a/compiler2/Type_codegen.cc +++ b/compiler2/Type_codegen.cc @@ -722,8 +722,16 @@ void Type::generate_code_rawdescriptor(output_struct *target) else str = mputstr(str, "SG_NO,"); if (rawattrib->byteorder == XDEFLAST) str = mputstr(str, "ORDER_MSB,"); else str = mputstr(str, "ORDER_LSB,"); - if (rawattrib->align == XDEFLEFT) str = mputstr(str, "ORDER_MSB,"); - else str = mputstr(str, "ORDER_LSB,"); + if (get_type_refd_last()->typetype == T_OSTR) { + // the default alignment for octetstrings is 'left' + if (rawattrib->align == XDEFRIGHT) str = mputstr(str, "ORDER_LSB,"); + else str = mputstr(str, "ORDER_MSB,"); + } + else { + // the default alignment for all other types is 'right' + if (rawattrib->align == XDEFLEFT) str = mputstr(str, "ORDER_MSB,"); + else str = mputstr(str, "ORDER_LSB,"); + } if (rawattrib->bitorderinfield == XDEFMSB) str = mputstr(str, "ORDER_MSB,"); else str = mputstr(str, "ORDER_LSB,"); diff --git a/core/RAW.cc b/core/RAW.cc index 99482982f..27938bd68 100644 --- a/core/RAW.cc +++ b/core/RAW.cc @@ -514,7 +514,7 @@ int min_of_ints(unsigned int num_of_int,...) const TTCN_RAWdescriptor_t INTEGER_raw_= {8,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; const TTCN_RAWdescriptor_t BOOLEAN_raw_= {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; const TTCN_RAWdescriptor_t BITSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; -const TTCN_RAWdescriptor_t OCTETSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; +const TTCN_RAWdescriptor_t OCTETSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; const TTCN_RAWdescriptor_t HEXSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; const TTCN_RAWdescriptor_t CHARSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; const TTCN_RAWdescriptor_t FLOAT_raw_= {64,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL}; diff --git a/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script b/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script index c66ba5ee6..db294f9a1 100644 --- a/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script +++ b/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script @@ -375,9 +375,9 @@ testcase TC_FIELDLENGTH_4_and_BYTEORDER_first_for_octetstring() runs on TempComp testcase TC_FIELDLENGTH_4_for_octetstring_3_octets_long() runs on TempComp { const RAW_PDU_18 i := '123456'O - const octetstring o := '00123456'O + const octetstring o := '12345600'O - if ((enc_RAW_PDU_18(i) == o)and(dec_RAW_PDU_18(o) == '00'O & i)) {setverdict(pass);} + if ((enc_RAW_PDU_18(i) == o)and(dec_RAW_PDU_18(o) == i & '00'O)) {setverdict(pass);} else {setverdict(fail,"enc_RAW_PDU_18(i)= ", enc_RAW_PDU_18(i), "; dec_RAW_PDU_18(o)= ", dec_RAW_PDU_18(o));} } @@ -392,9 +392,9 @@ external function dec_RAW_PDU_19(in octetstring stream) return RAW_PDU_19 with { testcase TC_FIELDLENGTH_5_for_octetstring_2_octets_long() runs on TempComp { const RAW_PDU_19 i := '1234'O - const octetstring o := '0000001234'O + const octetstring o := '1234000000'O - if ((enc_RAW_PDU_19(i) == o)and(dec_RAW_PDU_19(o) == '000000'O & i)) {setverdict(pass);} + if ((enc_RAW_PDU_19(i) == o)and(dec_RAW_PDU_19(o) == i & '000000'O)) {setverdict(pass);} else {setverdict(fail,"enc_RAW_PDU_19(i)= ", enc_RAW_PDU_19(i), "; dec_RAW_PDU_19(o)= ", dec_RAW_PDU_19(o));} } @@ -418,9 +418,9 @@ testcase TC_FIELDLENGTH_4_and_BYTEORDER_last_for_octetstring() runs on TempComp testcase TC_FIELDLENGTH_4_and_BYTEORDER_last_for_octetstring_3_octets_long() runs on TempComp { const RAW_PDU_20 i := '123456'O - const octetstring o := '56341200'O + const octetstring o := '00563412'O - if ((enc_RAW_PDU_20(i) == o)and(dec_RAW_PDU_20(o) == '00'O & i)) {setverdict(pass);} + if ((enc_RAW_PDU_20(i) == o)and(dec_RAW_PDU_20(o) == i & '00'O)) {setverdict(pass);} else {setverdict(fail,"enc_RAW_PDU_20(i)= ", enc_RAW_PDU_20(i), "; dec_RAW_PDU_20(o)= ", dec_RAW_PDU_20(o));} } diff --git a/usrguide/referenceguide/4-ttcn3_language_extensions.adoc b/usrguide/referenceguide/4-ttcn3_language_extensions.adoc index d924dcb2a..76027e680 100644 --- a/usrguide/referenceguide/4-ttcn3_language_extensions.adoc +++ b/usrguide/referenceguide/4-ttcn3_language_extensions.adoc @@ -2514,7 +2514,7 @@ Attribute syntax: `ALIGN(<parameter>)` Parameters allowed: `left`, `right` -Default value: `right` +Default value: `left` for `octetstrings`, `right` for all other types Can be used with: stand-alone types or the field of a `record` or `set`. -- GitLab