gingerBill 8 months ago
parent
commit
e2ba8ff6e6
2 changed files with 10 additions and 6 deletions
  1. 5 1
      src/exact_value.cpp
  2. 5 5
      src/string.cpp

+ 5 - 1
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);
 	}
 	}

+ 5 - 5
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;
 }