silence Codacy

This commit is contained in:
Michiharu Ariza 2018-08-02 10:18:01 -07:00
parent 19ce0b24c0
commit 58279c3db4
2 changed files with 26 additions and 13 deletions

View File

@ -625,8 +625,7 @@ inline float parse_bcd (const ByteStr& str, unsigned int& offset, float& v)
struct Number
{
Number (int v = 0) { set_int (v); }
Number (float v) { set_real (v); }
inline Number (void) { set_int (0); }
inline void set_int (int v) { is_real = false; u.int_val = v; };
inline int to_int (void) const { return is_real? (int)u.real_val: u.int_val; }
@ -652,6 +651,20 @@ struct Stack
numbers[size++] = v;
}
inline void push_int (int v)
{
Number n;
n.set_int (v);
push (n);
}
inline void push_real (float v)
{
Number n;
n.set_real (v);
push (n);
}
inline const Number& pop (void)
{
if (likely (size > 0))
@ -787,7 +800,7 @@ struct Interpreter {
case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
if (unlikely (!str.check_limit (offset, 2) || !stack.check_overflow (1)))
return false;
stack.push ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + str[offset + 1] + 108));
stack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + str[offset + 1] + 108));
offset++;
break;
@ -795,14 +808,14 @@ struct Interpreter {
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
if (unlikely (!str.check_limit (offset, 2) || !stack.check_overflow (1)))
return false;
stack.push ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - str[offset + 1] - 108));
stack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - str[offset + 1] - 108));
offset++;
break;
case OpCode_shortint: /* 3-byte integer */
if (unlikely (!str.check_limit (offset, 3) || !stack.check_overflow (1)))
return false;
stack.push ((int16_t)*(const HBUINT16*)&str[offset + 1]);
stack.push_int ((int16_t)*(const HBUINT16*)&str[offset + 1]);
offset += 2;
break;
@ -811,7 +824,7 @@ struct Interpreter {
if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast)) &&
likely (stack.check_overflow (1)))
{
stack.push ((int)op - 139);
stack.push_int ((int)op - 139);
} else {
return false;
}

View File

@ -138,7 +138,7 @@ struct CFF2TopDictOpSet
case OpCode_longint: /* 5-byte integer */
if (unlikely (!str.check_limit (offset, 5) || !stack.check_overflow (1)))
return false;
stack.push ((int32_t)*(const HBUINT32*)&str[offset + 1]);
stack.push_int ((int32_t)*(const HBUINT32*)&str[offset + 1]);
offset += 4;
break;
@ -146,7 +146,7 @@ struct CFF2TopDictOpSet
float v;
if (unlikely (stack.check_overflow (1) || !parse_bcd (str, offset, v)))
return false;
stack.push (v);
stack.push_real (v);
break;
default:
@ -192,14 +192,14 @@ struct CFF2FontDictOpSet
case OpCode_longint: /* 5-byte integer */
if (unlikely (!str.check_limit (offset, 5) || !stack.check_overflow (1)))
return false;
stack.push ((int32_t)((str[offset + 1] << 24) | ((uint32_t)str[offset + 2] << 16) | ((uint32_t)str[offset + 3] << 8) | str[offset + 4]));
stack.push_int ((int32_t)((str[offset + 1] << 24) | ((uint32_t)str[offset + 2] << 16) | ((uint32_t)str[offset + 3] << 8) | str[offset + 4]));
offset += 4;
break;
case OpCode_BCD: /* real number */
float v;
if (unlikely (stack.check_overflow (1) || !parse_bcd (str, offset, v)))
return false;
stack.push (v);
stack.push_real (v);
break;
default:
@ -347,14 +347,14 @@ struct CFF2PrivateDictOpSet
case OpCode_longint: /* 5-byte integer */
if (unlikely (!str.check_limit (offset, 5) || !stack.check_overflow (1)))
return false;
stack.push ((int32_t)((str[offset + 1] << 24) | (str[offset + 2] << 16) || (str[offset + 3] << 8) || str[offset + 4]));
stack.push_int ((int32_t)((str[offset + 1] << 24) | (str[offset + 2] << 16) || (str[offset + 3] << 8) || str[offset + 4]));
offset += 4;
break;
case OpCode_BCD: /* real number */
float v;
if (unlikely (!stack.check_overflow (1) || !parse_bcd (str, offset, v)))
return false;
stack.push (v);
stack.push_real (v);
break;
default:
@ -493,7 +493,7 @@ struct cff2
return true;
}
private:
protected:
hb_blob_t *blob;
hb_sanitize_context_t sc;