Skip to content

Commit

Permalink
Fix inconsistent indentation (buildhelper)
Browse files Browse the repository at this point in the history
  • Loading branch information
skejeton committed Mar 14, 2024
1 parent 28f8de9 commit 8ae4eaf
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions cmd/buildhelper.um
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -105,15 +105,15 @@ 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)
data := readall(f)
printf("%s\n", strtoc(data)+",")
std.fclose(f)
}

printf("};\n")
// creates a string array with args as values
} else if mode == "argarr" {
Expand Down

0 comments on commit 8ae4eaf

Please sign in to comment.