wmc: Windows file formats are always little-endian.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
923461f3d8
commit
af046fe636
|
@ -239,7 +239,7 @@ static int fill_inputbuffer(void)
|
|||
case INPUT_UNICODE:
|
||||
len += fread( inputbuffer + len, sizeof(WCHAR), INPUTBUFFER_SIZE - len, yyin );
|
||||
if (!len) break;
|
||||
if (swapped) for (i = 0; i < len; i++) inputbuffer[i] = BYTESWAP_WORD( inputbuffer[i] );
|
||||
if (swapped) for (i = 0; i < len; i++) inputbuffer[i] = (inputbuffer[i] << 8) | (inputbuffer[i] >> 8);
|
||||
ninputbuffer = len;
|
||||
return 1;
|
||||
case INPUT_UNKNOWN:
|
||||
|
|
|
@ -439,7 +439,6 @@ WCHAR *codepage_to_unicode( int codepage, const char *src, int srclen, int *dstl
|
|||
* Function for writing to a memory buffer.
|
||||
*/
|
||||
|
||||
int byte_swapped = 0;
|
||||
unsigned char *output_buffer;
|
||||
size_t output_buffer_pos;
|
||||
size_t output_buffer_size;
|
||||
|
@ -470,13 +469,6 @@ void flush_output_buffer( const char *name )
|
|||
free( output_buffer );
|
||||
}
|
||||
|
||||
void put_data( const void *data, size_t size )
|
||||
{
|
||||
check_output_buffer_space( size );
|
||||
memcpy( output_buffer + output_buffer_pos, data, size );
|
||||
output_buffer_pos += size;
|
||||
}
|
||||
|
||||
void put_byte( unsigned char val )
|
||||
{
|
||||
check_output_buffer_space( 1 );
|
||||
|
@ -485,15 +477,18 @@ void put_byte( unsigned char val )
|
|||
|
||||
void put_word( unsigned short val )
|
||||
{
|
||||
if (byte_swapped) val = (val << 8) | (val >> 8);
|
||||
put_data( &val, sizeof(val) );
|
||||
check_output_buffer_space( 2 );
|
||||
output_buffer[output_buffer_pos++] = val;
|
||||
output_buffer[output_buffer_pos++] = val >> 8;
|
||||
}
|
||||
|
||||
void put_dword( unsigned int val )
|
||||
{
|
||||
if (byte_swapped)
|
||||
val = ((val << 24) | ((val << 8) & 0x00ff0000) | ((val >> 8) & 0x0000ff00) | (val >> 24));
|
||||
put_data( &val, sizeof(val) );
|
||||
check_output_buffer_space( 4 );
|
||||
output_buffer[output_buffer_pos++] = val;
|
||||
output_buffer[output_buffer_pos++] = val >> 8;
|
||||
output_buffer[output_buffer_pos++] = val >> 16;
|
||||
output_buffer[output_buffer_pos++] = val >> 24;
|
||||
}
|
||||
|
||||
void align_output( unsigned int align )
|
||||
|
|
|
@ -43,14 +43,12 @@ WCHAR *codepage_to_unicode( int codepage, const char *src, int srclen, int *dstl
|
|||
|
||||
/* buffer management */
|
||||
|
||||
extern int byte_swapped;
|
||||
extern unsigned char *output_buffer;
|
||||
extern size_t output_buffer_pos;
|
||||
extern size_t output_buffer_size;
|
||||
|
||||
extern void init_output_buffer(void);
|
||||
extern void flush_output_buffer( const char *name );
|
||||
extern void put_data( const void *data, size_t size );
|
||||
extern void put_byte( unsigned char val );
|
||||
extern void put_word( unsigned short val );
|
||||
extern void put_dword( unsigned int val );
|
||||
|
|
|
@ -37,14 +37,6 @@
|
|||
|
||||
static const char usage[] =
|
||||
"Usage: wmc [options...] [inputfile.mc]\n"
|
||||
" -B x Set output byte-order x={n[ative], l[ittle], b[ig]}\n"
|
||||
" (default is n[ative] which equals "
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
"big"
|
||||
#else
|
||||
"little"
|
||||
#endif
|
||||
"-endian)\n"
|
||||
" -c Set 'custom-bit' in values\n"
|
||||
" -d Use decimal values in output\n"
|
||||
" -D Set debug flag\n"
|
||||
|
@ -70,11 +62,6 @@ static const char version_string[] =
|
|||
"Copyright 2000 Bertho A. Stultiens\n"
|
||||
;
|
||||
|
||||
/*
|
||||
* The output byte-order of resources (set with -B)
|
||||
*/
|
||||
int byteorder = WMC_BO_NATIVE;
|
||||
|
||||
/*
|
||||
* Custom bit (bit 29) in output values must be set (-c option)
|
||||
*/
|
||||
|
@ -136,7 +123,7 @@ enum long_options_values
|
|||
LONG_OPT_NLS_DIR = 1,
|
||||
};
|
||||
|
||||
static const char short_options[] = "B:cdDhH:io:O:P:uUvVW";
|
||||
static const char short_options[] = "cdDhH:io:O:P:uUvVW";
|
||||
static const struct long_option long_options[] =
|
||||
{
|
||||
{ "help", 0, 'h' },
|
||||
|
@ -190,25 +177,6 @@ static void option_callback( int optc, char *optarg )
|
|||
{
|
||||
switch(optc)
|
||||
{
|
||||
case 'B':
|
||||
switch(optarg[0])
|
||||
{
|
||||
case 'n':
|
||||
case 'N':
|
||||
byteorder = WMC_BO_NATIVE;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
byteorder = WMC_BO_LITTLE;
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
byteorder = WMC_BO_BIG;
|
||||
break;
|
||||
default:
|
||||
error("Byteordering must be n[ative], l[ittle] or b[ig]\n");
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
custombit = 1;
|
||||
break;
|
||||
|
@ -347,12 +315,6 @@ int main(int argc,char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
byte_swapped = (byteorder == WMC_BO_LITTLE);
|
||||
#else
|
||||
byte_swapped = (byteorder == WMC_BO_BIG);
|
||||
#endif
|
||||
|
||||
switch (output_format)
|
||||
{
|
||||
case FORMAT_RC:
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
extern int pedantic;
|
||||
extern int leave_case;
|
||||
extern int byteorder;
|
||||
extern int decimal;
|
||||
extern int custombit;
|
||||
extern int unicodein;
|
||||
|
|
|
@ -22,9 +22,6 @@ with \fB-o\fR, then \fBwmc\fR will write the output to \fIinputfile.{rc,h}\fR.
|
|||
The outputfile is named \fIwmc.tab.{rc,h}\fR if no inputfile was given.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BI \-B\ x
|
||||
Set output byte-order x={n[ative], l[ittle], b[ig]}. Default is n[ative].
|
||||
.TP
|
||||
.B \-c
|
||||
Set 'custom-bit' in message-code values.
|
||||
.TP
|
||||
|
|
|
@ -25,18 +25,6 @@
|
|||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
/* Byteordering defines */
|
||||
#define WMC_BO_NATIVE 0x00
|
||||
#define WMC_BO_LITTLE 0x01
|
||||
#define WMC_BO_BIG 0x02
|
||||
|
||||
#define WMC_LOBYTE(w) ((WORD)(w) & 0xff)
|
||||
#define WMC_HIBYTE(w) (((WORD)(w) >> 8) & 0xff)
|
||||
#define WMC_LOWORD(d) ((DWORD)(d) & 0xffff)
|
||||
#define WMC_HIWORD(d) (((DWORD)(d) >> 16) & 0xffff)
|
||||
#define BYTESWAP_WORD(w) ((WORD)(((WORD)WMC_LOBYTE(w) << 8) + (WORD)WMC_HIBYTE(w)))
|
||||
#define BYTESWAP_DWORD(d) ((DWORD)(((DWORD)BYTESWAP_WORD(WMC_LOWORD(d)) << 16) + ((DWORD)BYTESWAP_WORD(WMC_HIWORD(d)))))
|
||||
|
||||
/*
|
||||
* Tokenizer types
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue