Commit a606c111 authored by Botond Baranyi's avatar Botond Baranyi Committed by Gerrit Code Review
Browse files

Merge "Revert "Fixed RAW encoding of -2147483648 (bug 533067)""

parents 884c7041 9d97f1e5
......@@ -1177,7 +1177,7 @@ int INTEGER::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf)
}
else { // not IntX, use the field length
length = (p_td.raw->fieldlength + 7) / 8;
if (min_bits(value, neg_sgbit) > p_td.raw->fieldlength) {
if (min_bits(value) > p_td.raw->fieldlength) {
TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_LEN_ERR,
"There are insufficient bits to encode '%s' : ", p_td.name);
value = 0; // substitute with zero
......
......@@ -309,16 +309,13 @@ RAW_enc_tree* RAW_enc_tree::get_node(RAW_enc_tr_pos &req_pos)
* @return the number of bits needed to represent the given integer
* in sign+magnitude
*/
int min_bits(int a, bool signbit)
int min_bits(int a)
{
if (a == INT_MIN) {
return sizeof(int) * 8 + signbit;
}
register int bits = 0;
register int tmp = a;
if (a < 0) {
bits = 1;
tmp = -a; // doesn't work on INT_MIN
tmp = -a;
}
while (tmp != 0) {
bits++;
......
......@@ -52,7 +52,7 @@ extern const unsigned char BitMaskTable[9];
class RAW_enc_tree;
struct TTCN_Typedescriptor_t;
struct TTCN_TEXTdescriptor_t;
int min_bits(int a, bool signbit);
int min_bits(int a);
int min_bits(BIGNUM *a);
enum ext_bit_t{
EXT_BIT_NO, /**< No extension bit */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment