Module: wine Branch: master Commit: df45a347acc7f352df5ccef529f14601fc1fa806 URL: http://source.winehq.org/git/wine.git/?a=commit;h=df45a347acc7f352df5ccef529...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Dec 30 13:08:30 2010 +0100
wrc: Store location information in strings.
---
tools/wrc/genres.c | 6 ++++++ tools/wrc/newstruc.c | 1 + tools/wrc/utils.c | 2 ++ tools/wrc/wrc.h | 12 ++++++++++++ tools/wrc/wrctypes.h | 8 ++++++++ 5 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c index 3d40180..6b2d7ed 100644 --- a/tools/wrc/genres.c +++ b/tools/wrc/genres.c @@ -312,11 +312,17 @@ static void put_string(res_t *res, const string_t *str, enum str_e type, int ist if (str->type == str_char) { if (!check_unicode_conversion( str, newstr, codepage )) + { + print_location( &str->loc ); error( "String %s does not convert identically to Unicode and back in codepage %d. " "Try using a Unicode string instead\n", str->str.cstr, codepage ); + } if (check_valid_utf8( str, codepage )) + { + print_location( &str->loc ); warning( "string "%s" seems to be UTF-8 but codepage %u is in use.\n", str->str.cstr, codepage ); + } } if (!isterm) put_word(res, newstr->size); for(cnt = 0; cnt < newstr->size; cnt++) diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c index c157cb4..4651617 100644 --- a/tools/wrc/newstruc.c +++ b/tools/wrc/newstruc.c @@ -166,6 +166,7 @@ string_t *new_string(void) { string_t *ret = xmalloc( sizeof(*ret) ); memset( ret, 0, sizeof(*ret) ); + set_location( &ret->loc ); return ret; }
diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index 5adebba..397c252 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -271,6 +271,8 @@ string_t *convert_string(const string_t *str, enum str_e type, int codepage) string_t *ret = xmalloc(sizeof(*ret)); int res;
+ ret->loc = str->loc; + if (!codepage && str->type != type) parser_error( "Current language is Unicode only, cannot convert string" );
diff --git a/tools/wrc/wrc.h b/tools/wrc/wrc.h index 0283546..4b90fd1 100644 --- a/tools/wrc/wrc.h +++ b/tools/wrc/wrc.h @@ -59,4 +59,16 @@ extern language_t *currentlanguage; void verify_translations(resource_t *top); void write_resfile(char *outname, resource_t *top);
+static inline void set_location( location_t *loc ) +{ + loc->file = input_name; + loc->line = line_number; + loc->col = char_number; +} + +static inline void print_location( const location_t *loc ) +{ + if (loc->file) fprintf(stderr, "%s:%d:%d: ", loc->file, loc->line, loc->col ); +} + #endif diff --git a/tools/wrc/wrctypes.h b/tools/wrc/wrctypes.h index 5644d9d..4df9279 100644 --- a/tools/wrc/wrctypes.h +++ b/tools/wrc/wrctypes.h @@ -83,6 +83,13 @@ #define BYTESWAP_WORD(w) ((WORD)(((WORD)WRC_LOBYTE(w) << 8) + (WORD)WRC_HIBYTE(w))) #define BYTESWAP_DWORD(d) ((DWORD)(((DWORD)BYTESWAP_WORD(WRC_LOWORD(d)) << 16) + ((DWORD)BYTESWAP_WORD(WRC_HIWORD(d)))))
+typedef struct +{ + const char *file; + int line; + int col; +} location_t; + /* Binary resource structure */ #define RES_BLOCKSIZE 512
@@ -103,6 +110,7 @@ typedef struct string { char *cstr; WCHAR *wstr; } str; + location_t loc; } string_t;
/* Resources are identified either by name or by number */