Compare commits

4 Commits
v0.1.0 ... main

Author SHA1 Message Date
ef3ef0950f Fix manpage install location 2024-10-11 17:38:07 -04:00
78bdf578bf Manpage fixes 2024-10-11 17:29:50 -04:00
cd3f296fc5 More compatibility fixes 2024-10-11 17:16:33 -04:00
ea527a2065 Don't use for each loops
The hare compiler on OpenBSD doesn't support them :(
2024-10-11 17:08:16 -04:00
3 changed files with 15 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ HAREFLAGS=
DESTDIR=
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
MANDIR=$(PREFIX)/man
all: bulb
@@ -22,9 +22,10 @@ clean:
install:
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
install -Dm755 bulb $(DESTDIR)$(BINDIR)/bulb
install -Dm755 doc/*.1 $(DESTDIR)$(MANDIR)/man1
install -Dm755 doc/bulb.1 $(DESTDIR)$(MANDIR)/man1
uninstall:
rm -f $(DESTDIR)$(BINDIR)/bulb
rm -f $(DESTDIR)$(MANDIR)/man1/bulb.1
.PHONY: all check clean install uninstall

View File

@@ -32,7 +32,8 @@ export fn main() void = {
let post = false;
let anonymous = false;
for (let opt .. cmd.opts) {
for (let index = 0z; index < len(cmd.opts); index += 1) {
let opt = cmd.opts[index];
switch (opt.0) {
case 'b' =>
board = opt.1;

View File

@@ -6,6 +6,7 @@ use io;
use os;
use path;
use strings;
use types;
// TODO
// two issues:
@@ -44,7 +45,7 @@ export fn read(output: io::handle, board: str, number: int) (void | error) = {
static let output_wbuf: [os::BUFSZ]u8 = [0...];
let output = bufio::init(output, [], output_wbuf);
let file = bufio::newscanner(file);
let file = bufio::newscanner(file, types::SIZE_MAX);
defer bufio::finish(&file);
let saw_escape = false;
@@ -87,7 +88,7 @@ export fn post(input: io::handle, board: str, user_name: (str | void)) (void | e
static let file_wbuf: [os::BUFSZ]u8 = [0...];
let file = bufio::init(file, [], file_wbuf);
let input = bufio::newscanner(input);
let input = bufio::newscanner(input, types::SIZE_MAX);
defer bufio::finish(&input);
let saw_break = false;
@@ -116,14 +117,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 +153,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)?;
};
};