mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 02:40:05 +00:00
Remove usage of do in core library
This commit is contained in:
@@ -35,19 +35,19 @@ encode :: proc(d: []u16, s: []rune) -> int {
|
||||
loop: for r in s {
|
||||
switch r {
|
||||
case 0..<_surr1, _surr3 ..< _surr_self:
|
||||
if m+1 < n do break loop;
|
||||
if m+1 < n { break loop; }
|
||||
d[n] = u16(r);
|
||||
n += 1;
|
||||
|
||||
case _surr_self .. MAX_RUNE:
|
||||
if m+2 < n do break loop;
|
||||
if m+2 < n { break loop; }
|
||||
r1, r2 := encode_surrogate_pair(r);
|
||||
d[n] = u16(r1);
|
||||
d[n+1] = u16(r2);
|
||||
n += 2;
|
||||
|
||||
case:
|
||||
if m+1 < n do break loop;
|
||||
if m+1 < n { break loop; }
|
||||
d[n] = u16(REPLACEMENT_CHAR);
|
||||
n += 1;
|
||||
}
|
||||
@@ -61,19 +61,19 @@ encode_string :: proc(d: []u16, s: string) -> int {
|
||||
loop: for r in s {
|
||||
switch r {
|
||||
case 0..<_surr1, _surr3 ..< _surr_self:
|
||||
if m+1 < n do break loop;
|
||||
if m+1 < n { break loop; }
|
||||
d[n] = u16(r);
|
||||
n += 1;
|
||||
|
||||
case _surr_self .. MAX_RUNE:
|
||||
if m+2 < n do break loop;
|
||||
if m+2 < n { break loop; }
|
||||
r1, r2 := encode_surrogate_pair(r);
|
||||
d[n] = u16(r1);
|
||||
d[n+1] = u16(r2);
|
||||
n += 2;
|
||||
|
||||
case:
|
||||
if m+1 < n do break loop;
|
||||
if m+1 < n { break loop; }
|
||||
d[n] = u16(REPLACEMENT_CHAR);
|
||||
n += 1;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,9 @@ encode_rune :: proc(c: rune) -> ([4]u8, int) {
|
||||
return buf, 4;
|
||||
}
|
||||
|
||||
decode_rune_in_string :: inline proc(s: string) -> (rune, int) do return decode_rune(transmute([]u8)s);
|
||||
decode_rune_in_string :: inline proc(s: string) -> (rune, int) {
|
||||
return decode_rune(transmute([]u8)s);
|
||||
}
|
||||
decode_rune :: proc(s: []u8) -> (rune, int) {
|
||||
n := len(s);
|
||||
if n < 1 {
|
||||
@@ -159,7 +161,9 @@ runes_to_string :: proc(runes: []rune, allocator := context.allocator) -> string
|
||||
}
|
||||
|
||||
|
||||
decode_last_rune_in_string :: inline proc(s: string) -> (rune, int) do return decode_last_rune(transmute([]u8)s);
|
||||
decode_last_rune_in_string :: inline proc(s: string) -> (rune, int) {
|
||||
return decode_last_rune(transmute([]u8)s);
|
||||
}
|
||||
decode_last_rune :: proc(s: []u8) -> (rune, int) {
|
||||
r: rune;
|
||||
size: int;
|
||||
@@ -179,7 +183,9 @@ decode_last_rune :: proc(s: []u8) -> (rune, int) {
|
||||
limit = max(end - UTF_MAX, 0);
|
||||
|
||||
for start-=1; start >= limit; start-=1 {
|
||||
if rune_start(s[start]) do break;
|
||||
if rune_start(s[start]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
start = max(start, 0);
|
||||
@@ -287,9 +293,13 @@ valid_string :: proc(s: string) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
rune_start :: inline proc(b: u8) -> bool do return b&0xc0 != 0x80;
|
||||
rune_start :: inline proc(b: u8) -> bool {
|
||||
return b&0xc0 != 0x80;
|
||||
}
|
||||
|
||||
rune_count_in_string :: inline proc(s: string) -> int do return rune_count(transmute([]u8)s);
|
||||
rune_count_in_string :: inline proc(s: string) -> int {
|
||||
return rune_count(transmute([]u8)s);
|
||||
}
|
||||
rune_count :: proc(s: []u8) -> int {
|
||||
count := 0;
|
||||
n := len(s);
|
||||
|
||||
Reference in New Issue
Block a user