This commit is contained in:
gingerBill
2024-12-02 11:23:55 +00:00
parent d0f87913e2
commit e2ba8ff6e6
2 changed files with 10 additions and 6 deletions
+5 -1
View File
@@ -370,7 +370,11 @@ gb_internal ExactValue exact_value_from_basic_literal(TokenKind kind, String con
} }
case Token_Rune: { case Token_Rune: {
Rune r = GB_RUNE_INVALID; Rune r = GB_RUNE_INVALID;
utf8_decode(string.text, string.len, &r); if (string.len == 1) {
r = cast(Rune)string.text[0];
} else {
utf8_decode(string.text, string.len, &r);
}
return exact_value_i64(r); return exact_value_i64(r);
} }
} }
+5 -5
View File
@@ -718,12 +718,12 @@ gb_internal bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_byt
Rune r = -1; Rune r = -1;
isize size = utf8_decode(s.text, s.len, &r); isize size = utf8_decode(s.text, s.len, &r);
*rune = r; *rune = r;
*multiple_bytes = true; if (multiple_bytes) *multiple_bytes = true;
*tail_string = make_string(s.text+size, s.len-size); if (tail_string) *tail_string = make_string(s.text+size, s.len-size);
return true; return true;
} else if (s[0] != '\\') { } else if (s[0] != '\\') {
*rune = s[0]; *rune = s[0];
*tail_string = make_string(s.text+1, s.len-1); if (tail_string) *tail_string = make_string(s.text+1, s.len-1);
return true; return true;
} }
@@ -809,10 +809,10 @@ gb_internal bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_byt
return false; return false;
} }
*rune = r; *rune = r;
*multiple_bytes = true; if (multiple_bytes) *multiple_bytes = true;
} break; } break;
} }
*tail_string = s; if (tail_string) *tail_string = s;
return true; return true;
} }