Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions std/string/ascii.wave
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ pub fun is_space(c: u8) -> bool {
return true;
}

if (c == 11 || c == 12) {
return true;
}

if (c == 13) {
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions std/string/trim.wave
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
//
// SPDX-License-Identifier: Apache-2.0

import("std::string::ascii")::{is_space};

pub fun trim_left_index(s: str) -> i32 {
var i: i32 = 0;

while (s[i] != 0) {
var c: u8 = s[i];

if (c == 32 || c == 9 || c == 10 || c == 13) {
if (is_space(c)) {
i += 1;
} else {
return i;
Expand All @@ -48,7 +50,7 @@ pub fun trim_right_index(s: str) -> i32 {
while (i >= 0) {
var c: u8 = s[i];

if (c == 32 || c == 9 || c == 10 || c == 13) {
if (is_space(c)) {
i -= 1;
} else {
return i + 1;
Expand Down
4 changes: 3 additions & 1 deletion tests/cases/shared/test81.wave
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ fun main() -> i32 {
if (!starts_with("wave-lang", "wave") || !ends_with("main.wave", ".wave")) { failed += 1; }
if (find_char("banana", 97) != 1 || rfind_char("banana", 97) != 5) { failed += 1; }
if (!contains_char("wave", 118) || count_char("banana", 97) != 3) { failed += 1; }
if (!is_alpha(87) || !is_digit(55) || !is_space(10)) { failed += 1; }
if (!is_alpha(87) || !is_digit(55)) { failed += 1; }
if (!is_space(9) || !is_space(10) || !is_space(11) || !is_space(12) || !is_space(13) || !is_space(32) || is_space(8)) { failed += 1; }
if (to_lower(87) != 119 || to_upper(119) != 87) { failed += 1; }
if (trim_left_index(" wave \n") != 2 || trim_right_index(" wave \n") != 6) { failed += 1; }
if (trim_left_index("\x0b\x0cwave") != 2 || trim_right_index("wave\x0b\x0c") != 4) { failed += 1; }
if (djb2_32("wave") == 0 || fnv1a_64("wave") == 0) { failed += 1; }

return failed;
Expand Down
Loading