#7162 Support multicharacter char literals.
This commit is contained in:
parent
e2b859bf42
commit
9ca6704c81
|
@ -320,8 +320,13 @@ MathLib::bigint MathLib::characterLiteralToLongNumber(const std::string& str)
|
||||||
return 0; // for unit-testing...
|
return 0; // for unit-testing...
|
||||||
if (str.size()==1)
|
if (str.size()==1)
|
||||||
return str[0] & 0xff;
|
return str[0] & 0xff;
|
||||||
if (str[0] != '\\')
|
if (str[0] != '\\') {
|
||||||
throw InternalError(0, "Internal Error. MathLib::toLongNumber: Unhandled char constant " + str);
|
// C99 6.4.4.4
|
||||||
|
// The value of an integer character constant containing more than one character (e.g., 'ab'),
|
||||||
|
// or containing a character or escape sequence that does not map to a single-byte execution character,
|
||||||
|
// is implementation-defined.
|
||||||
|
return str[0] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
switch (str[1]) {
|
switch (str[1]) {
|
||||||
case 'x':
|
case 'x':
|
||||||
|
|
|
@ -271,6 +271,7 @@ private:
|
||||||
|
|
||||||
// from char
|
// from char
|
||||||
ASSERT_EQUALS((int)('A'), MathLib::toLongNumber("'A'"));
|
ASSERT_EQUALS((int)('A'), MathLib::toLongNumber("'A'"));
|
||||||
|
ASSERT_EQUALS((int)('A'), MathLib::toLongNumber("'ABC'"));
|
||||||
ASSERT_EQUALS((int)('\0'), MathLib::toLongNumber("'\\0'"));
|
ASSERT_EQUALS((int)('\0'), MathLib::toLongNumber("'\\0'"));
|
||||||
ASSERT_EQUALS((int)('\r'), MathLib::toLongNumber("'\\r'"));
|
ASSERT_EQUALS((int)('\r'), MathLib::toLongNumber("'\\r'"));
|
||||||
ASSERT_EQUALS((int)('\x12'), MathLib::toLongNumber("'\\x12'"));
|
ASSERT_EQUALS((int)('\x12'), MathLib::toLongNumber("'\\x12'"));
|
||||||
|
|
Loading…
Reference in New Issue