summary refs log tree commit diff
path: root/lisc/parse.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-02-28 19:38:11 -0800
committerOri Bernstein <ori@eigenstate.org>2016-02-28 19:38:11 -0800
commit7f738bb025195cfb91403588480877c12e72a6d6 (patch)
tree840882c19c3a429e6bc0f79ccebaa18de24b3018 /lisc/parse.c
parent09c45b936d8977ed0896905ad2fb9e5d1e1e9b65 (diff)
downloadroux-7f738bb025195cfb91403588480877c12e72a6d6.tar.gz
More standard/better error message formatting.
Diffstat (limited to 'lisc/parse.c')
-rw-r--r--lisc/parse.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/lisc/parse.c b/lisc/parse.c
index 49ed139..2c25476 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -1,5 +1,6 @@
 #include "lisc.h"
 #include <ctype.h>
+#include <stdarg.h>
 
 OpDesc opdesc[NOp] = {
 	/*            NAME     NM */
@@ -107,6 +108,7 @@ enum {
 
 
 static FILE *inf;
+static char *inpath;
 static int thead;
 static struct {
 	double fltd;
@@ -129,12 +131,22 @@ static int rcls;
 static int ntyp;
 
 
+
 static void
-err(char *s)
+err(char *s, ...)
 {
-	char buf[100];
+	char buf[100], *p, *end;
+	va_list ap;
+
+
+	p = buf;
+	end = buf + sizeof(buf);
+
+	va_start(ap, s);
+	p += snprintf(p, end - p, "%s:%d: ", inpath, lnum);
+	p += vsnprintf(p, end - p, s, ap);
+	va_end(ap);
 
-	snprintf(buf, sizeof buf, "parse: %s (line %d)", s, lnum);
 	diag(buf);
 }
 
@@ -815,9 +827,10 @@ parsedat(void cb(Dat *))
 }
 
 void
-parse(FILE *f, void data(Dat *), void func(Fn *))
+parse(FILE *f, char *path, void data(Dat *), void func(Fn *))
 {
 	inf = f;
+	inpath = path;
 	lnum = 1;
 	thead = TXXX;
 	ntyp = 0;