commit de30fe2fcf07c7aa7921af384adf1aeb929c1de8
parent 42580280cbde37d3f04c137010699b405965f5d4
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 9 Dec 2023 21:11:29 -0500
all: update labelled loop syntax
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/bufio/stream.ha b/bufio/stream.ha
@@ -205,7 +205,7 @@ fn write(s: *io::stream, buf: const []u8) (size | io::error) = {
let doflush = false;
if (len(s.flush) != 0) {
- for (let i = 0z; i < len(buf); i += 1) :search {
+ for :search (let i = 0z; i < len(buf); i += 1) {
for (let j = 0z; j < len(s.flush); j += 1) {
if (buf[i] == s.flush[j]) {
doflush = true;
diff --git a/cmd/hare/util.ha b/cmd/hare/util.ha
@@ -15,7 +15,7 @@ fn merge_tags(current: *[]str, new: str) (void | module::error) = {
*current = [];
};
let newtags = module::parse_tags(trimmed)?;
- for (let i = 0z; i < len(newtags); i += 1) :new {
+ for :new (let i = 0z; i < len(newtags); i += 1) {
for (let j = 0z; j < len(current); j += 1) {
if (newtags[i].name == current[j]) {
if (!newtags[i].include) {
diff --git a/cmd/haredoc/util.ha b/cmd/haredoc/util.ha
@@ -17,7 +17,7 @@ fn merge_tags(current: *[]str, new: str) (void | module::error) = {
*current = [];
};
let newtags = module::parse_tags(trimmed)?;
- for (let i = 0z; i < len(newtags); i += 1) :new {
+ for :new (let i = 0z; i < len(newtags); i += 1) {
for (let j = 0z; j < len(current); j += 1) {
if (newtags[i].name == current[j]) {
if (!newtags[i].include) {
diff --git a/fnmatch/fnmatch.ha b/fnmatch/fnmatch.ha
@@ -66,7 +66,7 @@ fn fnmatch_pathname(
let tok = strings::tokenize(string, "/");
let p_iter = strings::iter(pattern);
let start = p_iter;
- for (true) :outer {
+ for :outer (true) {
start = p_iter;
for (true) match (pat_next(&p_iter, fl)?) {
case end =>
@@ -192,13 +192,13 @@ fn fnmatch_internal(
// match the "sea of stars" in the middle
s_copy = strings::iter(strings::slice(&s_copy, &s_last));
p_copy = strings::iter(strings::slice(&p_copy, &p_last.0));
- for (true) :outer {
+ for :outer (true) {
p = p_copy;
if (len(strings::iterstr(&p)) == 0) {
return true;
};
s = s_copy;
- for (true) :inner {
+ for (true) {
let copy = s;
let rn = strings::next(©);
let matched = match (pat_next(&p, fl)?) {
@@ -216,7 +216,7 @@ fn fnmatch_internal(
continue :outer;
};
if (!matched) {
- break :inner;
+ break;
};
s = copy;
};
diff --git a/getopt/getopts.ha b/getopt/getopts.ha
@@ -101,7 +101,7 @@ export fn parse(args: []str, help: help...) command = {
export fn tryparse(args: []str, help: help...) (command | error) = {
let opts: [](rune, str) = [];
let i = 1z;
- for (i < len(args); i += 1) :arg {
+ for :arg (i < len(args); i += 1) {
const arg = args[i];
if (len(arg) == 0 || arg == "-"
|| !strings::hasprefix(arg, "-")) {
diff --git a/strings/replace.ha b/strings/replace.ha
@@ -23,7 +23,7 @@ export fn multireplace(s: str, repls: (str, str)...) str = {
let res: []u8 = [];
let i = 0z;
let prev = 0z; // end of previous match, so we can append in chunks
- for (i < len(b)) :step {
+ for :step (i < len(b)) {
for (let j = 0z; j < len(repls); j += 1) {
const replb = (toutf8(repls[j].0), toutf8(repls[j].1));
if (bytes::hasprefix(b[i..], replb.0)) {
diff --git a/strings/trim.ha b/strings/trim.ha
@@ -14,7 +14,7 @@ export fn ltrim(input: str, trim: rune...) str = {
return fromutf8_unsafe(bytes::ltrim(input, whitespace...));
};
let it = iter(input);
- for (true) :outer {
+ for :outer (true) {
const r = match (next(&it)) {
case let r: rune =>
yield r;
@@ -41,7 +41,7 @@ export fn rtrim(input: str, trim: rune...) str = {
return fromutf8_unsafe(bytes::rtrim(input, whitespace...));
};
let it = riter(input);
- for (true) :outer {
+ for :outer (true) {
const r = match (next(&it)) {
case let r: rune =>
yield r;