run exe arg, deref -> read

This commit is contained in:
2025-08-21 10:34:32 +02:00
parent 3fd62c6083
commit ca8ae6e110
6 changed files with 55 additions and 40 deletions

View File

@@ -15,15 +15,15 @@ func main[] : I64
else if op == '<'
p = p - 1
else if op == '+'
str.set(memory, p, str.nth(memory, p)+1)
str.set(memory, p, mem.read8(memory + p)+1)
else if op == '-'
str.set(memory, p, str.nth(memory, p)-1)
str.set(memory, p, mem.read8(memory + p)-1)
else if op == '.'
c.printf("%c", str.nth(memory, p))
c.printf("%c", mem.read8(memory + p))
else if op == ','
str.set(memory, p, c.getchar())
else if op == '['
if !str.nth(memory, p)
if !mem.read8(memory + p)
i = i + 1
let opened: I64 = 0
while i < src_len & !(str.nth(src, i) == ']' & !opened)
@@ -33,7 +33,7 @@ func main[] : I64
opened = opened - 1
i = i + 1
else if op == ']'
if str.nth(memory, p)
if mem.read8(memory + p)
i = i - 1
let closed: I64 = 0
while i >= 0 & !(str.nth(src, i) == '[' & !closed)

View File

@@ -2,7 +2,7 @@ func main[argc: I64, argv: Ptr] : I64
if argc < 2
dbg.panic("url missing")
let url: String = mem.deref64(argv + 8)
let url: String = mem.read64(argv + 8)
if c.strncmp(url, "http://", 7) != 0
dbg.panic("invalid url scheme")
@@ -29,7 +29,7 @@ func main[argc: I64, argv: Ptr] : I64
c.send(s, req, str.len(req), 0)
mem.free(req)
let header_buf: Ptr = mem.alloc(8192)
let header_buf: String = mem.alloc(8192)
let header_size: I64 = 0
let found: Bool = false
let end_index: I64 = -1
@@ -41,8 +41,7 @@ func main[argc: I64, argv: Ptr] : I64
let current_size: I64 = header_size + n
i = 0
while i <= current_size - 4
let p: Ptr = header_buf + i
if str.nth(p, 0) == 13 & str.nth(p, 1) == 10 & str.nth(p, 2) == 13 & str.nth(p, 3) == 10
if str.nth(header_buf, i) == 13 & str.nth(header_buf, i+1) == 10 & str.nth(header_buf, i+2) == 13 & str.nth(header_buf, i+3) == 10
found = true
end_index = i + 4
break