From 4742c552904c44bc77604b7cf03ed7b14e2e7ef4 Mon Sep 17 00:00:00 2001 From: rodri Date: Wed, 25 Sep 2024 15:29:23 +0000 Subject: don't write a \n to errstr. survive referring to files in dot. --- obj.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/obj.c b/obj.c index 288d446..aa52515 100644 --- a/obj.c +++ b/obj.c @@ -29,7 +29,7 @@ error(char *fmt, ...) bp = seprint(buf, buf + sizeof buf, "%s:%lud ", curline.file, curline.lineno); vseprint(bp, buf + sizeof buf, fmt, va); va_end(va); - werrstr("%s\n", buf); + werrstr("%s", buf); } static void @@ -42,7 +42,7 @@ mterror(char *fmt, ...) bp = seprint(buf, buf + sizeof buf, "%s:%lud ", curmtline.file, curmtline.lineno); vseprint(bp, buf + sizeof buf, fmt, va); va_end(va); - werrstr("%s\n", buf); + werrstr("%s", buf); } static void * @@ -382,6 +382,8 @@ objmtlparse(char *file) if((p = strrchr(curline.file, '/')) != nil) snprint(buf, sizeof buf, "%.*s/%s", (int)(p-curline.file), curline.file, file); + else + snprint(buf, sizeof buf, "%s", file); bin = Bopen(buf, OREAD); if(bin == nil) @@ -510,7 +512,10 @@ objmtlparse(char *file) mterror("no material found"); goto error; } - snprint(buf, sizeof buf, "%.*s/%s", (int)(p-curline.file), curline.file, f[1]); + if(p != nil) + snprint(buf, sizeof buf, "%.*s/%s", (int)(p-curline.file), curline.file, f[1]); + else + snprint(buf, sizeof buf, "%s", f[1]); if((m->map_Kd = readimagefile(buf)) == nil){ mterror("readimagefile: %r"); goto error; @@ -524,7 +529,10 @@ objmtlparse(char *file) mterror("no material found"); goto error; } - snprint(buf, sizeof buf, "%.*s/%s", (int)(p-curline.file), curline.file, f[1]); + if(p != nil) + snprint(buf, sizeof buf, "%.*s/%s", (int)(p-curline.file), curline.file, f[1]); + else + snprint(buf, sizeof buf, "%s", f[1]); if((m->norm = readimagefile(buf)) == nil){ mterror("readimagefile: %r"); goto error; -- cgit v1.2.3