From 2a14a8ba3d97562919f585383db0dc800636fe5a Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 5 Aug 2022 16:52:56 +0100 Subject: fix whitespaceness --- img/driver.lua | 3 +-- img/load_pnm.lua | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'img') diff --git a/img/driver.lua b/img/driver.lua index 7756124..7a8aa53 100644 --- a/img/driver.lua +++ b/img/driver.lua @@ -4,13 +4,12 @@ local load_pnm = require("load_pnm").load local shitty_disp = require("shitty_disp") local perr = require("util").perr -local file,err = io.open("/img/walter.pnm","rb") +local file,err = io.open(arg[1],"rb") perr(err,"io.open") local ff = file:read("a") local img = load_pnm(ff) term.clear() shitty_disp.disp(term.current(),img,1,1) -os.sleep(1) os.pullEvent("key") shitty_disp.reset_palette(term.current()) diff --git a/img/load_pnm.lua b/img/load_pnm.lua index 1fd4b70..af866ee 100644 --- a/img/load_pnm.lua +++ b/img/load_pnm.lua @@ -79,14 +79,14 @@ local function parse(imgf) local has_depth = not(typech == 1 or typech == 4) - local width,height,cur = imgf:match("%s*(%d+)%s*(%d+)%s*()",3) + local width,height,cur = imgf:match("\x0a(%d+) (%d+)\x0a()",3) width,height = tonumber(width),tonumber(height) assert(width,"couldn't find image dimensions") -- by 'depth' i mean 'maximum value' local depth = 1 if has_depth then - local ndepth,ncur = imgf:match("(%d+)%s*()",cur) + local ndepth,ncur = imgf:match("(%d+)\x0a()",cur) ndepth=tonumber(ndepth) assert(ndepth,"couldn't find image depth (max pixel value), in a format that needs it") depth=ndepth -- cgit v1.2.3