mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Handle possible unsigned char by default.
This commit is contained in:
@@ -606,7 +606,7 @@ static inline bool scan_char(Lexer *lexer)
|
||||
{
|
||||
c = next(lexer);
|
||||
const char *start = lexer->current;
|
||||
char escape = is_valid_escape(c);
|
||||
signed char escape = is_valid_escape(c);
|
||||
if (escape == -1)
|
||||
{
|
||||
lexer->lexing_start = start;
|
||||
@@ -623,7 +623,7 @@ static inline bool scan_char(Lexer *lexer)
|
||||
// Fix underlining if this is an unfinished escape.
|
||||
return add_error_token(lexer, "Expected a two character hex value after \\x.");
|
||||
}
|
||||
bytes.b[width++] = hex;
|
||||
bytes.b[width++] = (uint8_t)hex;
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
@@ -636,13 +636,13 @@ static inline bool scan_char(Lexer *lexer)
|
||||
}
|
||||
if (platform_target.little_endian)
|
||||
{
|
||||
bytes.b[width++] = hex & 0xFF;
|
||||
bytes.b[width++] = hex >> 8;
|
||||
bytes.b[width++] = (uint8_t)hex & 0xFF;
|
||||
bytes.b[width++] = (uint8_t)(hex >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.b[width++] = hex >> 8;
|
||||
bytes.b[width++] = hex & 0xFF;
|
||||
bytes.b[width++] = (uint8_t)(hex >> 8);
|
||||
bytes.b[width++] = (uint8_t)(hex & 0xFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -656,22 +656,22 @@ static inline bool scan_char(Lexer *lexer)
|
||||
}
|
||||
if (platform_target.little_endian)
|
||||
{
|
||||
bytes.b[width++] = hex & 0xFF;
|
||||
bytes.b[width++] = (hex >> 8) & 0xFF;
|
||||
bytes.b[width++] = (hex >> 16) & 0xFF;
|
||||
bytes.b[width++] = hex >> 24;
|
||||
bytes.b[width++] = (uint8_t)(hex & 0xFF);
|
||||
bytes.b[width++] = (uint8_t)((hex >> 8) & 0xFF);
|
||||
bytes.b[width++] = (uint8_t)((hex >> 16) & 0xFF);
|
||||
bytes.b[width++] = (uint8_t)(hex >> 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.b[width++] = hex >> 24;
|
||||
bytes.b[width++] = (hex >> 16) & 0xFF;
|
||||
bytes.b[width++] = (hex >> 8) & 0xFF;
|
||||
bytes.b[width++] = hex & 0xFF;
|
||||
bytes.b[width++] = (uint8_t)(hex >> 24);
|
||||
bytes.b[width++] = (uint8_t)((hex >> 16) & 0xFF);
|
||||
bytes.b[width++] = (uint8_t)((hex >> 8) & 0xFF);
|
||||
bytes.b[width++] = (uint8_t)(hex & 0xFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
bytes.b[width++] = escape;
|
||||
bytes.b[width++] = (uint8_t)escape;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user