(svn r2985) Print warnings and errors in the canonical file:line: form to make life for IDEs easier (ln-)
authortron
Sun, 25 Sep 2005 09:15:09 +0000
changeset 2459 a2f63b331830
parent 2458 dbaf5dffbb28
child 2460 83a73bae1adb
(svn r2985) Print warnings and errors in the canonical file:line: form to make life for IDEs easier (ln-)
strgen/strgen.c
--- a/strgen/strgen.c	Sun Sep 25 09:04:59 2005 +0000
+++ b/strgen/strgen.c	Sun Sep 25 09:15:09 2005 +0000
@@ -54,6 +54,7 @@
 	struct Case *next;
 } Case;
 
+static const char* _file = "(unknown file)";
 static int _cur_line;
 static int _errors, _warnings;
 
@@ -143,7 +144,7 @@
 	va_start(va, s);
 	vsprintf(buf, s, va);
 	va_end(va);
-	fprintf(stderr, "Warning:(%d): %s\n", _cur_line, buf);
+	fprintf(stderr, "%s:%d: Warning: %s\n", _file, _cur_line, buf);
 	_warnings++;
 }
 
@@ -155,7 +156,7 @@
 	va_start(va, s);
 	vsprintf(buf, s, va);
 	va_end(va);
-	fprintf(stderr, "Error:(%d): %s\n", _cur_line, buf);
+	fprintf(stderr, "%s:%d: Error: %s\n", _file, _cur_line, buf);
 	_errors++;
 }
 
@@ -167,7 +168,7 @@
 	va_start(va, s);
 	vsprintf(buf, s, va);
 	va_end(va);
-	fprintf(stderr, "%d: FATAL: %s\n", _cur_line, buf);
+	fprintf(stderr, "%s:%d: FATAL: %s\n", _file, _cur_line, buf);
 	exit(1);
 }
 
@@ -846,6 +847,8 @@
 	FILE *in;
 	char buf[2048];
 
+	_file = file;
+
 	// For each new file we parse, reset the genders.
 	_numgenders = 0;
 	// TODO:!! We can't reset the cases. In case the translated strings
@@ -853,7 +856,7 @@
 
 
 	in = fopen(file, "r");
-	if (in == NULL) { Fatal("Cannot open file '%s'", file); }
+	if (in == NULL) Fatal("Cannot open file");
 	_cur_line = 1;
 	while (fgets(buf, sizeof(buf),in) != NULL) {
 		rstrip(buf);