From 8ae4eaf6947d79b807449739d13124e9230140db Mon Sep 17 00:00:00 2001 From: skejeton Date: Thu, 14 Mar 2024 11:27:38 -0300 Subject: [PATCH] Fix inconsistent indentation (buildhelper) --- cmd/buildhelper.um | 102 ++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/cmd/buildhelper.um b/cmd/buildhelper.um index 73f6b9e..c6c8c53 100644 --- a/cmd/buildhelper.um +++ b/cmd/buildhelper.um @@ -1,68 +1,68 @@ import ( - "std.um" + "std.um" ) fn peekstr(f: std.File, next: int): str { - tr := "" - var c: char - for i:=0; i < next; i++ { - fscanf(f, "%c", &c) - tr += str(c) - } - - return tr + tr := "" + var c: char + for i:=0; i < next; i++ { + fscanf(f, "%c", &c) + tr += str(c) + } + + return tr } fn peekn(f: std.File, next: int): int { - tr := 0 - var c: char - for i:=0; i < next; i++ { - fscanf(f, "%c", &c) - ic := int(c) - if ic < 0 { ic += 256 } - tr += ic << (8 * (next - i - 1)) - } - - return tr + tr := 0 + var c: char + for i:=0; i < next; i++ { + fscanf(f, "%c", &c) + ic := int(c) + if ic < 0 { ic += 256 } + tr += ic << (8 * (next - i - 1)) + } + + return tr } fn loadFF*(path: str): ([]uint32, int, int, int) { - f, err := std.fopen(path, "r") + f, err := std.fopen(path, "r") std.exitif(err) - if f == null { return []uint32{}, -1, -1, 1 } - var w, h: int - var tr: []uint32 - - if val := peekstr(f, 8); val != "farbfeld" { return []uint32{}, -1, -1, 2 } - w = peekn(f, 4) - h = peekn(f, 4) - tr = make([]uint32, w * h) - var c: char - for j:=0; j < w * h; j++ { - for h:=0; h < 4; h++ { - fscanf(f, "%c", &c) - fscanf(f, "%c", &c) - ic := int(c) - if ic < 0 { ic += 256 } - tr[j] += ic << (8 * (3 - h)) - } - } - - std.fclose(f) - return tr, w, h, 0 + if f == null { return []uint32{}, -1, -1, 1 } + var w, h: int + var tr: []uint32 + + if val := peekstr(f, 8); val != "farbfeld" { return []uint32{}, -1, -1, 2 } + w = peekn(f, 4) + h = peekn(f, 4) + tr = make([]uint32, w * h) + var c: char + for j:=0; j < w * h; j++ { + for h:=0; h < 4; h++ { + fscanf(f, "%c", &c) + fscanf(f, "%c", &c) + ic := int(c) + if ic < 0 { ic += 256 } + tr[j] += ic << (8 * (3 - h)) + } + } + + std.fclose(f) + return tr, w, h, 0 } fn readall(f: std.File): str { - const blockSize = 16 - res := "" + const blockSize = 16 + res := "" - for ok := true; ok { - var buff: [blockSize + 1]char - ok = std.fread(f, ^[blockSize]char(&buff)).item1.code == 0 - res += str([]char(buff)) - } + for ok := true; ok { + var buff: [blockSize + 1]char + ok = std.fread(f, ^[blockSize]char(&buff)).item1.code == 0 + res += str([]char(buff)) + } - return res + return res } fn chcnt(chars: str, c: str): bool { @@ -105,7 +105,7 @@ fn main() { // embeds contents of a file as a string. TODO just as bytes if mode == "em" { printf("const char *%s[] = {\n", std.argv(2)) - + for i:=3; i < std.argc(); i++ { f, err := std.fopen(std.argv(i), "r") std.exitif(err) @@ -113,7 +113,7 @@ fn main() { printf("%s\n", strtoc(data)+",") std.fclose(f) } - + printf("};\n") // creates a string array with args as values } else if mode == "argarr" {