diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-04-22 09:40:32 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-04-22 09:40:32 +0100 |
| commit | 0ea815db498d52ffd654801cc68bb95f4fdb437e (patch) | |
| tree | 913cbb2e27b89e9322ac172bcd1e1dbdca6350f4 /core | |
| parent | 91ed51ff5c9c49a739f6a835acf6df492690e2cd (diff) | |
Fix constant bounds checking for slicing
Diffstat (limited to 'core')
| -rw-r--r-- | core/_preload.odin | 1 | ||||
| -rw-r--r-- | core/strconv.odin | 8 | ||||
| -rw-r--r-- | core/utf16.odin | 6 |
3 files changed, 8 insertions, 7 deletions
diff --git a/core/_preload.odin b/core/_preload.odin index 6939a8c17..3419c78d8 100644 --- a/core/_preload.odin +++ b/core/_preload.odin @@ -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; diff --git a/core/strconv.odin b/core/strconv.odin index 21a466871..853134499 100644 --- a/core/strconv.odin +++ b/core/strconv.odin @@ -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; diff --git a/core/utf16.odin b/core/utf16.odin index a01261493..222688f1d 100644 --- a/core/utf16.odin +++ b/core/utf16.odin @@ -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; |