Skip to content

Commit

Permalink
Fix using uint suffix at the hex number declaration in shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaosus committed Jul 1, 2023
1 parent 4642448 commit 1994c25
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion servers/rendering/shader_language.cpp
Expand Up @@ -659,7 +659,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
char t = char(i);

suffix_lut[CASE_ALL][i] = t == '.' || t == 'x' || t == 'e' || t == 'f' || t == 'u' || t == '-' || t == '+';
suffix_lut[CASE_HEXA_PERIOD][i] = t == 'e' || t == 'f';
suffix_lut[CASE_HEXA_PERIOD][i] = t == 'e' || t == 'f' || t == 'u';
suffix_lut[CASE_EXPONENT][i] = t == 'f' || t == '-' || t == '+';
suffix_lut[CASE_SIGN_AFTER_EXPONENT][i] = t == 'f';
suffix_lut[CASE_NONE][i] = false;
Expand Down Expand Up @@ -738,6 +738,13 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
char32_t last_char = str[str.length() - 1];

if (hexa_found) { // Integer (hex).
if (uint_suffix_found) {
// Strip the suffix.
str = str.left(str.length() - 1);

// Compensate reading cursor position.
char_idx += 1;
}
if (str.size() > 11 || !str.is_valid_hex_number(true)) { // > 0xFFFFFFFF
return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant");
}
Expand Down

0 comments on commit 1994c25

Please sign in to comment.