aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-06-14 11:15:25 +0100
committergingerBill <bill@gingerbill.org>2021-06-14 11:15:25 +0100
commit86649e6b44877df3c5d0b81ed2f97aaa063a6f1d (patch)
tree700029b1021d4702e4877dd0c0355d3443df3865
parent3ca887a60ae1e681fd441edfe17805df97b6d6a3 (diff)
Core library clean up: Make range expressions more consistent and replace uses of `..` with `..=`
-rw-r--r--core/bytes/bytes.odin2
-rw-r--r--core/c/frontend/preprocessor/preprocess.odin8
-rw-r--r--core/c/frontend/preprocessor/unquote.odin8
-rw-r--r--core/c/frontend/tokenizer/tokenizer.odin8
-rw-r--r--core/compress/gzip/gzip.odin4
-rw-r--r--core/compress/zlib/zlib.odin14
-rw-r--r--core/encoding/cel/cel.odin8
-rw-r--r--core/encoding/cel/token.odin10
-rw-r--r--core/encoding/json/parser.odin12
-rw-r--r--core/encoding/json/tokenizer.odin16
-rw-r--r--core/image/png/png.odin20
-rw-r--r--core/os/file_windows.odin2
-rw-r--r--core/os/os2/stat_windows.odin2
-rw-r--r--core/path/filepath/path.odin2
-rw-r--r--core/strconv/strconv.odin14
-rw-r--r--core/strings/builder.odin4
-rw-r--r--core/strings/conversion.odin6
-rw-r--r--core/strings/strings.odin2
-rw-r--r--core/sync/sync_darwin.odin2
-rw-r--r--core/sync/sync_freebsd.odin2
-rw-r--r--core/sync/sync_linux.odin2
-rw-r--r--core/text/scanner/scanner.odin12
-rw-r--r--core/unicode/utf16/utf16.odin4
23 files changed, 80 insertions, 84 deletions
diff --git a/core/bytes/bytes.odin b/core/bytes/bytes.odin
index b3d332c67..a7cf23d1b 100644
--- a/core/bytes/bytes.odin
+++ b/core/bytes/bytes.odin
@@ -91,7 +91,7 @@ equal_fold :: proc(u, v: []byte) -> bool {
if tr < utf8.RUNE_SELF {
switch sr {
- case 'A'..'Z':
+ case 'A'..='Z':
if tr == (sr+'a')-'A' {
continue loop;
}
diff --git a/core/c/frontend/preprocessor/preprocess.odin b/core/c/frontend/preprocessor/preprocess.odin
index 767bb89b3..2136c19ba 100644
--- a/core/c/frontend/preprocessor/preprocess.odin
+++ b/core/c/frontend/preprocessor/preprocess.odin
@@ -139,18 +139,18 @@ append_token :: proc(a, b: ^Token) -> ^Token {
is_hex_digit :: proc(x: byte) -> bool {
switch x {
- case '0'..'9', 'a'..'f', 'A'..'F':
+ case '0'..='9', 'a'..='f', 'A'..='F':
return true;
}
return false;
}
from_hex :: proc(x: byte) -> i32 {
switch x {
- case '0'..'9':
+ case '0'..='9':
return i32(x) - '0';
- case 'a'..'f':
+ case 'a'..='f':
return i32(x) - 'a' + 10;
- case 'A'..'F':
+ case 'A'..='F':
return i32(x) - 'A' + 10;
}
return 16;
diff --git a/core/c/frontend/preprocessor/unquote.odin b/core/c/frontend/preprocessor/unquote.odin
index 4aa4926e7..a72a3601c 100644
--- a/core/c/frontend/preprocessor/unquote.odin
+++ b/core/c/frontend/preprocessor/unquote.odin
@@ -5,9 +5,9 @@ import "core:unicode/utf8"
unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool, tail_string: string, success: bool) {
hex_to_int :: proc(c: byte) -> int {
switch c {
- case '0'..'9': return int(c-'0');
- case 'a'..'f': return int(c-'a')+10;
- case 'A'..'F': return int(c-'A')+10;
+ case '0'..='9': return int(c-'0');
+ case 'a'..='f': return int(c-'a')+10;
+ case 'A'..='F': return int(c-'A')+10;
}
return -1;
}
@@ -45,7 +45,7 @@ unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool
case '"': r = '"';
case '\'': r = '\'';
- case '0'..'7':
+ case '0'..='7':
v := int(c-'0');
if len(s) < 2 {
return;
diff --git a/core/c/frontend/tokenizer/tokenizer.odin b/core/c/frontend/tokenizer/tokenizer.odin
index 254806cf4..8a3747434 100644
--- a/core/c/frontend/tokenizer/tokenizer.odin
+++ b/core/c/frontend/tokenizer/tokenizer.odin
@@ -224,11 +224,11 @@ scan_string :: proc(t: ^Tokenizer) -> string {
digit_val :: proc(r: rune) -> int {
switch r {
- case '0'..'9':
+ case '0'..='9':
return int(r-'0');
- case 'A'..'F':
+ case 'A'..='F':
return int(r-'A' + 10);
- case 'a'..'f':
+ case 'a'..='f':
return int(r-'a' + 10);
}
return 16;
@@ -245,7 +245,7 @@ scan_escape :: proc(t: ^Tokenizer) -> bool {
advance_rune(t);
return true;
- case '0'..'7':
+ case '0'..='7':
for digit_val(t.ch) < 8 {
advance_rune(t);
}
diff --git a/core/compress/gzip/gzip.odin b/core/compress/gzip/gzip.odin
index 2b5e513c7..82488a5a8 100644
--- a/core/compress/gzip/gzip.odin
+++ b/core/compress/gzip/gzip.odin
@@ -288,11 +288,11 @@ load_from_stream :: proc(stream: io.Stream, buf: ^bytes.Buffer, allocator := con
payload_crc_b: [4]u8;
payload_len_b: [4]u8;
- for i in 0..3 {
+ for _, i in payload_crc_b {
payload_crc_b[i] = u8(compress.read_bits_lsb(&ctx, 8));
}
payload_crc := transmute(u32le)payload_crc_b;
- for i in 0..3 {
+ for _, i in payload_len_b {
payload_len_b[i] = u8(compress.read_bits_lsb(&ctx, 8));
}
payload_len := int(transmute(u32le)payload_len_b);
diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin
index bc19c37ef..779122c1e 100644
--- a/core/compress/zlib/zlib.odin
+++ b/core/compress/zlib/zlib.odin
@@ -133,9 +133,7 @@ write_byte :: #force_inline proc(z: ^Context, c: u8) -> (err: io.Error) #no_boun
}
allocate_huffman_table :: proc(allocator := context.allocator) -> (z: ^Huffman_Table, err: Error) {
-
- z = new(Huffman_Table, allocator);
- return z, nil;
+ return new(Huffman_Table, allocator), nil;
}
build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: Error) {
@@ -152,14 +150,14 @@ build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: Error) {
}
sizes[0] = 0;
- for i in 1..16 {
+ for i in 1..<(HUFFMAN_MAX_BITS+1) {
if sizes[i] > (1 << uint(i)) {
return E_Deflate.Huffman_Bad_Sizes;
}
}
code := int(0);
- for i in 1..<16 {
+ for i in 1..<HUFFMAN_MAX_BITS {
next_code[i] = code;
z.firstcode[i] = u16(code);
z.firstsymbol[i] = u16(k);
@@ -169,12 +167,12 @@ build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: Error) {
return E_Deflate.Huffman_Bad_Code_Lengths;
}
}
- z.maxcode[i] = code << (16 - uint(i));
+ z.maxcode[i] = code << (HUFFMAN_MAX_BITS - uint(i));
code <<= 1;
k += int(sizes[i]);
}
- z.maxcode[16] = 0x10000; // Sentinel
+ z.maxcode[HUFFMAN_MAX_BITS] = 0x10000; // Sentinel
c: int;
for v, ci in code_lengths {
@@ -197,7 +195,6 @@ build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: Error) {
}
decode_huffman_slowpath :: proc(z: ^Context, t: ^Huffman_Table) -> (r: u16, err: Error) #no_bounds_check {
-
r = 0;
err = nil;
@@ -233,7 +230,6 @@ decode_huffman_slowpath :: proc(z: ^Context, t: ^Huffman_Table) -> (r: u16, err:
}
decode_huffman :: proc(z: ^Context, t: ^Huffman_Table) -> (r: u16, err: Error) #no_bounds_check {
-
if z.num_bits < 16 {
if z.num_bits == -100 {
return 0, E_ZLIB.Code_Buffer_Malformed;
diff --git a/core/encoding/cel/cel.odin b/core/encoding/cel/cel.odin
index f0cd49866..94f9281b3 100644
--- a/core/encoding/cel/cel.odin
+++ b/core/encoding/cel/cel.odin
@@ -201,9 +201,9 @@ next_token :: proc(p: ^Parser) -> Token {
unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool, tail_string: string, success: bool) {
hex_to_int :: proc(c: byte) -> int {
switch c {
- case '0'..'9': return int(c-'0');
- case 'a'..'f': return int(c-'a')+10;
- case 'A'..'F': return int(c-'A')+10;
+ case '0'..='9': return int(c-'0');
+ case 'a'..='f': return int(c-'a')+10;
+ case 'A'..='F': return int(c-'A')+10;
}
return -1;
}
@@ -241,7 +241,7 @@ unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool
case '"': r = '"';
case '\'': r = '\'';
- case '0'..'7':
+ case '0'..='7':
v := int(c-'0');
if len(s) < 2 {
return;
diff --git a/core/encoding/cel/token.odin b/core/encoding/cel/token.odin
index 7cd9e7c12..4d6b9473c 100644
--- a/core/encoding/cel/token.odin
+++ b/core/encoding/cel/token.odin
@@ -232,7 +232,7 @@ get_pos :: proc(t: ^Tokenizer) -> Pos {
is_letter :: proc(r: rune) -> bool {
switch r {
- case 'a'..'z', 'A'..'Z', '_':
+ case 'a'..='z', 'A'..='Z', '_':
return true;
}
return false;
@@ -240,7 +240,7 @@ is_letter :: proc(r: rune) -> bool {
is_digit :: proc(r: rune) -> bool {
switch r {
- case '0'..'9':
+ case '0'..='9':
return true;
}
return false;
@@ -273,9 +273,9 @@ scan_identifier :: proc(t: ^Tokenizer) -> string {
digit_value :: proc(r: rune) -> int {
switch r {
- case '0'..'9': return int(r - '0');
- case 'a'..'f': return int(r - 'a' + 10);
- case 'A'..'F': return int(r - 'A' + 10);
+ case '0'..='9': return int(r - '0');
+ case 'a'..='f': return int(r - 'a' + 10);
+ case 'A'..='F': return int(r - 'A' + 10);
}
return 16;
}
diff --git a/core/encoding/json/parser.odin b/core/encoding/json/parser.odin
index 448a0e41f..54cf9b6ef 100644
--- a/core/encoding/json/parser.odin
+++ b/core/encoding/json/parser.odin
@@ -290,9 +290,9 @@ unquote_string :: proc(token: Token, spec: Specification, allocator := context.a
for c in s[2:4] {
x: rune;
switch c {
- case '0'..'9': x = c - '0';
- case 'a'..'f': x = c - 'a' + 10;
- case 'A'..'F': x = c - 'A' + 10;
+ case '0'..='9': x = c - '0';
+ case 'a'..='f': x = c - 'a' + 10;
+ case 'A'..='F': x = c - 'A' + 10;
case: return -1;
}
r = r*16 + x;
@@ -308,9 +308,9 @@ unquote_string :: proc(token: Token, spec: Specification, allocator := context.a
for c in s[2:6] {
x: rune;
switch c {
- case '0'..'9': x = c - '0';
- case 'a'..'f': x = c - 'a' + 10;
- case 'A'..'F': x = c - 'A' + 10;
+ case '0'..='9': x = c - '0';
+ case 'a'..='f': x = c - 'a' + 10;
+ case 'A'..='F': x = c - 'A' + 10;
case: return -1;
}
r = r*16 + x;
diff --git a/core/encoding/json/tokenizer.odin b/core/encoding/json/tokenizer.odin
index b3860d428..df12ce0b6 100644
--- a/core/encoding/json/tokenizer.odin
+++ b/core/encoding/json/tokenizer.odin
@@ -82,7 +82,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
for t.offset < len(t.data) {
next_rune(t);
switch t.r {
- case '0'..'9', 'a'..'f', 'A'..'F':
+ case '0'..='9', 'a'..='f', 'A'..='F':
// Okay
case:
return;
@@ -100,7 +100,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
for i := 0; i < 4; i += 1 {
r := next_rune(t);
switch r {
- case '0'..'9', 'a'..'f', 'A'..'F':
+ case '0'..='9', 'a'..='f', 'A'..='F':
// Okay
case:
return false;
@@ -149,7 +149,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
skip_alphanum :: proc(t: ^Tokenizer) {
for t.offset < len(t.data) {
switch next_rune(t) {
- case 'A'..'Z', 'a'..'z', '0'..'9', '_':
+ case 'A'..='Z', 'a'..='z', '0'..='9', '_':
continue;
}
@@ -173,7 +173,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
token.kind = .EOF;
err = .EOF;
- case 'A'..'Z', 'a'..'z', '_':
+ case 'A'..='Z', 'a'..='z', '_':
token.kind = .Ident;
skip_alphanum(t);
@@ -200,7 +200,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
case '-':
switch t.r {
- case '0'..'9':
+ case '0'..='9':
// Okay
case:
// Illegal use of +/-
@@ -219,7 +219,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
}
fallthrough;
- case '0'..'9':
+ case '0'..='9':
token.kind = t.parse_integers ? .Integer : .Float;
if t.spec == .JSON5 { // Hexadecimal Numbers
if curr_rune == '0' && (t.r == 'x' || t.r == 'X') {
@@ -361,7 +361,7 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
switch s[0] {
case '0':
s = s[1:];
- case '1'..'9':
+ case '1'..='9':
s = s[1:];
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
s = s[1:];
@@ -453,7 +453,7 @@ is_valid_string_literal :: proc(str: string, spec: Specification) -> bool {
for j := 0; j < 4; j += 1 {
c2 := hex[j];
switch c2 {
- case '0'..'9', 'a'..'z', 'A'..'Z':
+ case '0'..='9', 'a'..='z', 'A'..='Z':
// Okay
case:
return false;
diff --git a/core/image/png/png.odin b/core/image/png/png.odin
index 7762f0106..642b30a26 100644
--- a/core/image/png/png.odin
+++ b/core/image/png/png.odin
@@ -1348,31 +1348,31 @@ defilter_less_than_8 :: proc(params: ^Filter_Params) -> (ok: bool) #no_bounds_ch
case .None:
copy(dest, src[:row_stride_in]);
case .Sub:
- for i in 0..channels {
+ for i in 0..=channels {
dest[i] = src[i];
}
- for k in 0..nk {
+ for k in 0..=nk {
dest[channels+k] = (src[channels+k] + dest[k]) & 255;
}
case .Up:
- for k in 0..row_stride_in {
+ for k in 0..=row_stride_in {
dest[k] = (src[k] + up[k]) & 255;
}
case .Average:
- for i in 0..channels {
+ for i in 0..=channels {
avg := up[i] >> 1;
dest[i] = (src[i] + avg) & 255;
}
- for k in 0..nk {
+ for k in 0..=nk {
avg := u8((u16(up[channels+k]) + u16(dest[k])) >> 1);
dest[channels+k] = (src[channels+k] + avg) & 255;
}
case .Paeth:
- for i in 0..channels {
+ for i in 0..=channels {
paeth := filter_paeth(0, up[i], 0);
dest[i] = (src[i] + paeth) & 255;
}
- for k in 0..nk {
+ for k in 0..=nk {
paeth := filter_paeth(dest[k], up[channels+k], up[k]);
dest[channels+k] = (src[channels+k] + paeth) & 255;
}
@@ -1380,9 +1380,9 @@ defilter_less_than_8 :: proc(params: ^Filter_Params) -> (ok: bool) #no_bounds_ch
return false;
}
- src = src [row_stride_in:];
- up = dest;
- dest = dest[row_stride_in:];
+ src = src[row_stride_in:];
+ up = dest;
+ dest = dest[row_stride_in:];
}
// Let's expand the bits
diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin
index 8b99ee9ee..9e22c96a2 100644
--- a/core/os/file_windows.odin
+++ b/core/os/file_windows.odin
@@ -347,7 +347,7 @@ is_abs :: proc(path: string) -> bool {
when ODIN_OS == "windows" {
if len(path) > 2 {
switch path[0] {
- case 'A'..'Z', 'a'..'z':
+ case 'A'..='Z', 'a'..='z':
return path[1] == ':' && is_path_separator(path[2]);
}
}
diff --git a/core/os/os2/stat_windows.odin b/core/os/os2/stat_windows.odin
index 48811340a..0b6834fe0 100644
--- a/core/os/os2/stat_windows.odin
+++ b/core/os/os2/stat_windows.odin
@@ -322,7 +322,7 @@ _is_abs :: proc(path: string) -> bool {
}
if len(path) > 2 {
switch path[0] {
- case 'A'..'Z', 'a'..'z':
+ case 'A'..='Z', 'a'..='z':
return path[1] == ':' && is_path_separator(path[2]);
}
}
diff --git a/core/path/filepath/path.odin b/core/path/filepath/path.odin
index 33ea5541c..7dd7484f0 100644
--- a/core/path/filepath/path.odin
+++ b/core/path/filepath/path.odin
@@ -39,7 +39,7 @@ volume_name_len :: proc(path: string) -> int {
c := path[0];
if path[1] == ':' {
switch c {
- case 'a'..'z', 'A'..'Z':
+ case 'a'..='z', 'A'..='Z':
return 2;
}
}
diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin
index 21a29b243..ca8934aa9 100644
--- a/core/strconv/strconv.odin
+++ b/core/strconv/strconv.odin
@@ -16,9 +16,9 @@ _digit_value :: proc(r: rune) -> int {
ri := int(r);
v: int = 16;
switch r {
- case '0'..'9': v = ri-'0';
- case 'a'..'z': v = ri-'a'+10;
- case 'A'..'Z': v = ri-'A'+10;
+ case '0'..='9': v = ri-'0';
+ case 'a'..='z': v = ri-'a'+10;
+ case 'A'..='Z': v = ri-'A'+10;
}
return v;
}
@@ -557,9 +557,9 @@ quote_rune :: proc(buf: []byte, r: rune) -> string {
unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool, tail_string: string, success: bool) {
hex_to_int :: proc(c: byte) -> int {
switch c {
- case '0'..'9': return int(c-'0');
- case 'a'..'f': return int(c-'a')+10;
- case 'A'..'F': return int(c-'A')+10;
+ case '0'..='9': return int(c-'0');
+ case 'a'..='f': return int(c-'a')+10;
+ case 'A'..='F': return int(c-'A')+10;
}
return -1;
}
@@ -597,7 +597,7 @@ unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool
case '"': r = '"';
case '\'': r = '\'';
- case '0'..'7':
+ case '0'..='7':
v := int(c-'0');
if len(s) < 2 {
return;
diff --git a/core/strings/builder.odin b/core/strings/builder.odin
index 843f79381..f2926b969 100644
--- a/core/strings/builder.odin
+++ b/core/strings/builder.odin
@@ -314,9 +314,9 @@ write_escaped_rune_writer :: proc(w: io.Writer, r: rune, quote: byte, html_safe
is_printable :: proc(r: rune) -> bool {
if r <= 0xff {
switch r {
- case 0x20..0x7e:
+ case 0x20..=0x7e:
return true;
- case 0xa1..0xff: // ¡ through ÿ except for the soft hyphen
+ case 0xa1..=0xff: // ¡ through ÿ except for the soft hyphen
return r != 0xad; //
}
}
diff --git a/core/strings/conversion.odin b/core/strings/conversion.odin
index c03bed86a..26535f8c0 100644
--- a/core/strings/conversion.odin
+++ b/core/strings/conversion.odin
@@ -85,9 +85,9 @@ is_delimiter :: proc(c: rune) -> bool {
is_separator :: proc(r: rune) -> bool {
if r <= 0x7f {
switch r {
- case '0'..'9': return false;
- case 'a'..'z': return false;
- case 'A'..'Z': return false;
+ case '0'..='9': return false;
+ case 'a'..='z': return false;
+ case 'A'..='Z': return false;
case '_': return false;
}
return true;
diff --git a/core/strings/strings.odin b/core/strings/strings.odin
index 5537822a8..e81b41222 100644
--- a/core/strings/strings.odin
+++ b/core/strings/strings.odin
@@ -104,7 +104,7 @@ equal_fold :: proc(u, v: string) -> bool {
if tr < utf8.RUNE_SELF {
switch sr {
- case 'A'..'Z':
+ case 'A'..='Z':
if tr == (sr+'a')-'A' {
continue loop;
}
diff --git a/core/sync/sync_darwin.odin b/core/sync/sync_darwin.odin
index c8e9632be..0fd2fc2a7 100644
--- a/core/sync/sync_darwin.odin
+++ b/core/sync/sync_darwin.odin
@@ -42,7 +42,7 @@ semaphore_destroy :: proc(s: ^Semaphore) {
semaphore_post :: proc(s: ^Semaphore, count := 1) {
// NOTE: SPEED: If there's one syscall to do this, we should use it instead of the loop.
- for in 0..count-1 {
+ for in 0..<count {
res := darwin.semaphore_signal(s.handle);
assert(res == 0);
}
diff --git a/core/sync/sync_freebsd.odin b/core/sync/sync_freebsd.odin
index 87532621d..0fa5f9e6f 100644
--- a/core/sync/sync_freebsd.odin
+++ b/core/sync/sync_freebsd.odin
@@ -33,7 +33,7 @@ semaphore_destroy :: proc(s: ^Semaphore) {
semaphore_post :: proc(s: ^Semaphore, count := 1) {
// NOTE: SPEED: If there's one syscall to do this, we should use it instead of the loop.
- for in 0..count-1 {
+ for in 0..<count {
assert(unix.sem_post(&s.handle) == 0);
}
}
diff --git a/core/sync/sync_linux.odin b/core/sync/sync_linux.odin
index aa3c7a068..6474cd900 100644
--- a/core/sync/sync_linux.odin
+++ b/core/sync/sync_linux.odin
@@ -33,7 +33,7 @@ semaphore_destroy :: proc(s: ^Semaphore) {
semaphore_post :: proc(s: ^Semaphore, count := 1) {
// NOTE: SPEED: If there's one syscall to do this, we should use it instead of the loop.
- for in 0..count-1 {
+ for in 0..<count {
assert(unix.sem_post(&s.handle) == 0);
}
}
diff --git a/core/text/scanner/scanner.odin b/core/text/scanner/scanner.odin
index 45c2a5d8f..9520b52df 100644
--- a/core/text/scanner/scanner.odin
+++ b/core/text/scanner/scanner.odin
@@ -421,8 +421,8 @@ scan_number :: proc(s: ^Scanner, ch: rune, seen_dot: bool) -> (rune, rune) {
scan_string :: proc(s: ^Scanner, quote: rune) -> (n: int) {
digit_val :: proc(ch: rune) -> int {
switch v := lower(ch); v {
- case '0'..'9': return int(v - '0');
- case 'a'..'z': return int(v - 'a');
+ case '0'..='9': return int(v - '0');
+ case 'a'..='z': return int(v - 'a');
}
return 16;
}
@@ -450,10 +450,10 @@ scan_string :: proc(s: ^Scanner, quote: rune) -> (n: int) {
switch ch {
case quote, 'a', 'b', 'e', 'f', 'n', 'r', 't', 'v', '\\':
ch = advance(s);
- case '0'..'7': ch = scan_digits(s, advance(s), 8, 3);
- case 'x': ch = scan_digits(s, advance(s), 16, 2);
- case 'u': ch = scan_digits(s, advance(s), 16, 4);
- case 'U': ch = scan_digits(s, advance(s), 16, 8);
+ case '0'..='7': ch = scan_digits(s, advance(s), 8, 3);
+ case 'x': ch = scan_digits(s, advance(s), 16, 2);
+ case 'u': ch = scan_digits(s, advance(s), 16, 4);
+ case 'U': ch = scan_digits(s, advance(s), 16, 8);
case:
error(s, "invalid char escape");
}
diff --git a/core/unicode/utf16/utf16.odin b/core/unicode/utf16/utf16.odin
index a436655b4..4c76956cc 100644
--- a/core/unicode/utf16/utf16.odin
+++ b/core/unicode/utf16/utf16.odin
@@ -39,7 +39,7 @@ encode :: proc(d: []u16, s: []rune) -> int {
d[n] = u16(r);
n += 1;
- case _surr_self .. MAX_RUNE:
+ case _surr_self ..= MAX_RUNE:
if m+2 < n { break loop; }
r1, r2 := encode_surrogate_pair(r);
d[n] = u16(r1);
@@ -65,7 +65,7 @@ encode_string :: proc(d: []u16, s: string) -> int {
d[n] = u16(r);
n += 1;
- case _surr_self .. MAX_RUNE:
+ case _surr_self ..= MAX_RUNE:
if m+2 < n { break loop; }
r1, r2 := encode_surrogate_pair(r);
d[n] = u16(r1);