From ea527a2065c945663978ffb27f6a5c76c17ea8fb Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 11 Oct 2024 17:08:16 -0400 Subject: [PATCH] Don't use for each loops The hare compiler on OpenBSD doesn't support them :( --- internal/bulb/bulb.ha | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/bulb/bulb.ha b/internal/bulb/bulb.ha index 2ab0fe1..7a3d235 100644 --- a/internal/bulb/bulb.ha +++ b/internal/bulb/bulb.ha @@ -116,14 +116,16 @@ export fn post(input: io::handle, board: str, user_name: (str | void)) (void | e }; export fn list(output: io::handle) (void | error) = { - for (let directory .. bulb_path) list_boards_in(output, directory)?; + for (let index = 0z; index < len(bulb_path); index += 1) { + list_boards_in(output, bulb_path[index])?; + }; }; export fn look_up_board(board: str) (str | no_such_board | invalid_board) = { validate_board_name(board)?; static let buf = path::buffer { ... }; - for (let directory .. bulb_path) { - let location = path::set(&buf, directory, board)!; + for (let index = 0z; index < len(bulb_path); index += 1) { + let location = path::set(&buf, bulb_path[index], board)!; match (os::stat(location)) { case fs::filestat => return location; case => void; @@ -150,8 +152,8 @@ export fn validate_board_name(board: str) (void | invalid_board) = { fn list_boards_in(output: io:: handle, directory: str) (void | error) = { let entries = os::readdir(directory)?; defer fs::dirents_free(entries); - for (let entry .. entries) { - fmt::fprintln(output, entry.name)?; + for (let index = 0z; index < len(entries); index += 1) { + fmt::fprintln(output, entries[index].name)?; }; };