aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-12-02 11:23:55 +0000
committergingerBill <bill@gingerbill.org>2024-12-02 11:23:55 +0000
commite2ba8ff6e6fdbd23a10dcaf8b04f85960b8aa7c3 (patch)
tree381714533720ae7f89e5345c5e997a1192acf377 /src
parentd0f87913e2133b8101faef6ea76e0853d4da524b (diff)
Fix #4530
Diffstat (limited to 'src')
-rw-r--r--src/exact_value.cpp6
-rw-r--r--src/string.cpp10
2 files changed, 10 insertions, 6 deletions
diff --git a/src/exact_value.cpp b/src/exact_value.cpp
index 5d6016ecc..ceaed84c1 100644
--- a/src/exact_value.cpp
+++ b/src/exact_value.cpp
@@ -370,7 +370,11 @@ gb_internal ExactValue exact_value_from_basic_literal(TokenKind kind, String con
}
case Token_Rune: {
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);
}
}
diff --git a/src/string.cpp b/src/string.cpp
index f8ee6c53e..b001adf0e 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -718,12 +718,12 @@ gb_internal bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_byt
Rune r = -1;
isize size = utf8_decode(s.text, s.len, &r);
*rune = r;
- *multiple_bytes = true;
- *tail_string = make_string(s.text+size, s.len-size);
+ if (multiple_bytes) *multiple_bytes = true;
+ if (tail_string) *tail_string = make_string(s.text+size, s.len-size);
return true;
} else if (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;
}
@@ -809,10 +809,10 @@ gb_internal bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_byt
return false;
}
*rune = r;
- *multiple_bytes = true;
+ if (multiple_bytes) *multiple_bytes = true;
} break;
}
- *tail_string = s;
+ if (tail_string) *tail_string = s;
return true;
}