summaryrefslogtreecommitdiff
path: root/strgen
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-09-25 09:15:09 +0000
committertron <tron@openttd.org>2005-09-25 09:15:09 +0000
commitd1694a1c762c9f3d03fa36d188d3733571e77c2c (patch)
tree1979b3ef6bf80cceb83a84a4715f8b221ab3039b /strgen
parentbdbceba0cb70ddd0ba8f17d0bfae31e973f7d0f2 (diff)
downloadopenttd-d1694a1c762c9f3d03fa36d188d3733571e77c2c.tar.xz
(svn r2985) Print warnings and errors in the canonical file:line: form to make life for IDEs easier (ln-)
Diffstat (limited to 'strgen')
-rw-r--r--strgen/strgen.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/strgen/strgen.c b/strgen/strgen.c
index 16c081089..b6f6717b0 100644
--- a/strgen/strgen.c
+++ b/strgen/strgen.c
@@ -54,6 +54,7 @@ typedef struct Case {
struct Case *next;
} Case;
+static const char* _file = "(unknown file)";
static int _cur_line;
static int _errors, _warnings;
@@ -143,7 +144,7 @@ static void CDECL Warning(const char *s, ...)
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 @@ static void CDECL Error(const char *s, ...)
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 @@ static void NORETURN CDECL Fatal(const char *s, ...)
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 @@ static void ParseFile(const char *file, bool english)
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 @@ static void ParseFile(const char *file, bool english)
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);