commit 2901b2952d6868aff2c4661e716b81bd0207e21c
parent 82853163f0be76ca118c7efd7b02acec82a9b16d
Author: Sebastian <sebastian@sebsite.pw>
Date: Mon, 7 Mar 2022 20:48:15 -0500
strings: rename iter_str to iterstr
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/fnmatch/fnmatch.ha b/fnmatch/fnmatch.ha
@@ -95,7 +95,7 @@ fn fnmatch_pathname(
yield s;
};
strings::prev(&p_iter);
- let p = cut_tail(strings::iter_str(&start), &p_iter);
+ let p = cut_tail(strings::iterstr(&start), &p_iter);
strings::next(&p_iter);
if (!fnmatch_internal(p, s, fl)?) {
return false;
@@ -107,7 +107,7 @@ fn fnmatch_pathname(
case let s: str =>
yield s;
};
- let p = strings::iter_str(&start);
+ let p = strings::iterstr(&start);
return fnmatch_internal(p, s, fl)? && strings::next_token(&tok) is void;
};
@@ -201,11 +201,11 @@ fn fnmatch_internal(
};
// match the "sea of stars" in the middle
- s_copy = strings::iter(cut_tail(strings::iter_str(&s_copy), &s_last));
- p_copy = strings::iter(cut_tail(strings::iter_str(&p_copy), &p_last.0));
+ s_copy = strings::iter(cut_tail(strings::iterstr(&s_copy), &s_last));
+ p_copy = strings::iter(cut_tail(strings::iterstr(&p_copy), &p_last.0));
for (true) :outer {
p = p_copy;
- if (len(strings::iter_str(&p)) == 0) {
+ if (len(strings::iterstr(&p)) == 0) {
return true;
};
s = s_copy;
@@ -297,7 +297,7 @@ fn match_bracket(
};
};
- let cnt = len(strings::iter_str(&old)) - len(strings::iter_str(it));
+ let cnt = len(strings::iterstr(&old)) - len(strings::iterstr(it));
if (last is rune && first == last: rune && cnt >= 4) {
switch (first) {
case '=', '.', ':' =>
@@ -309,7 +309,7 @@ fn match_bracket(
};
fn match_ctype(it: *strings::iterator, c: rune) (bool | errors::invalid) = {
- let s = strings::iter_str(it);
+ let s = strings::iterstr(it);
let i = 0z;
for (let r = '\0'; r != ':'; i+= 1) {
r = advance_or_err(it)?;
@@ -385,7 +385,7 @@ fn advance_or_err(it: *strings::iterator) (rune | errors::invalid) = {
};
fn cut_tail(s: str, it: *strings::iterator) str = {
- let s_len = len(s), t_len = len(strings::iter_str(it));
+ let s_len = len(s), t_len = len(strings::iterstr(it));
let b = strings::toutf8(s);
return strings::fromutf8(b[..s_len - t_len]);
};
diff --git a/strings/iter.ha b/strings/iter.ha
@@ -89,7 +89,7 @@ export fn prev(iter: *iterator) (rune | void) = {
// un-reading it. The next call using this iterator *must* be [[next]]; all other
// functions will cause the program to abort until the pushed rune is consumed.
// This does not modify the underlying string, and as such, subsequent calls to
-// functions like [[prev]] or [[iter_str]] will behave as if push were never called.
+// functions like [[prev]] or [[iterstr]] will behave as if push were never called.
export fn push(iter: *iterator, r: rune) void = {
// TODO: This should probably be removed, and the push field removed
// from the struct.
@@ -98,7 +98,7 @@ export fn push(iter: *iterator, r: rune) void = {
};
// Return a substring from the next rune to the end of the string.
-export fn iter_str(iter: *iterator) str = {
+export fn iterstr(iter: *iterator) str = {
assert(iter.push is void);
return fromutf8(iter.dec.src[iter.dec.offs..]);
};
@@ -115,7 +115,7 @@ export fn iter_str(iter: *iterator) str = {
abort();
};
};
- assert(iter_str(&s) == "にちは");
+ assert(iterstr(&s) == "にちは");
assert(prev(&s) as rune == 'ん');
const expected2 = ['ん', 'に', 'ち', 'は'];
for (let i = 0z; i < len(expected2); i += 1) {