aboutsummaryrefslogtreecommitdiff
path: root/obj.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-09-25 15:29:23 +0000
committerrodri <rgl@antares-labs.eu>2024-09-25 15:29:23 +0000
commit4742c552904c44bc77604b7cf03ed7b14e2e7ef4 (patch)
tree99dd2df6bffcf44f62fdec0dba5d2b5f2490146e /obj.c
parentd8d7e5747b363f8400f198c79875456b7f6c5193 (diff)
downloadlibobj-4742c552904c44bc77604b7cf03ed7b14e2e7ef4.tar.gz
libobj-4742c552904c44bc77604b7cf03ed7b14e2e7ef4.tar.bz2
libobj-4742c552904c44bc77604b7cf03ed7b14e2e7ef4.zip
don't write a \n to errstr. survive referring to files in dot.
Diffstat (limited to 'obj.c')
-rw-r--r--obj.c16
1 files 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;