wrc: Store location information in strings.
This commit is contained in:
parent
d0a6c806a9
commit
df45a347ac
|
@ -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++)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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" );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue