mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-20 01:48:21 +00:00
Fix constant bounds checking for slicing
This commit is contained in:
@@ -350,6 +350,7 @@ __slice_expr_error :: proc(file: string, line, column: int, low, high, max: int)
|
||||
file, line, column, low, high, max);
|
||||
__debug_trap();
|
||||
}
|
||||
|
||||
__substring_expr_error :: proc(file: string, line, column: int, low, high: int) {
|
||||
if 0 <= low && low <= high {
|
||||
return;
|
||||
|
||||
@@ -21,12 +21,12 @@ parse_bool :: proc(s: string) -> (result: bool, ok: bool) {
|
||||
_digit_value :: proc(r: rune) -> (int) {
|
||||
ri := cast(int)r;
|
||||
v: int = 16;
|
||||
match {
|
||||
case '0' <= r && r <= '9':
|
||||
match r {
|
||||
case '0'..'9':
|
||||
v = ri - '0';
|
||||
case 'a' <= r && r <= 'z':
|
||||
case 'a'..'z':
|
||||
v = ri - 'a' + 10;
|
||||
case 'A' <= r && r <= 'Z':
|
||||
case 'A'..'Z':
|
||||
v = ri - 'A' + 10;
|
||||
}
|
||||
return v;
|
||||
|
||||
@@ -39,12 +39,12 @@ encode :: proc(d: []u16, s: []rune) {
|
||||
n = 0;
|
||||
|
||||
for r in s {
|
||||
match {
|
||||
case 0 <= r && r < _surr1, _surr3 <= r && r < _surr_self:
|
||||
match r {
|
||||
case 0..<_surr1, _surr3..<_surr_self:
|
||||
d[n] = cast(u16)r;
|
||||
n++;
|
||||
|
||||
case _surr_self <= r && r <= MAX_RUNE:
|
||||
case _surr_self..MAX_RUNE:
|
||||
r1, r2 := encode_surrogate_pair(r);
|
||||
d[n] = cast(u16)r1;
|
||||
d[n+1] = cast(u16)r2;
|
||||
|
||||
Reference in New Issue
Block a user