Commit af046fe6 authored by Alexandre Julliard's avatar Alexandre Julliard

wmc: Windows file formats are always little-endian.

parent 923461f3
...@@ -239,7 +239,7 @@ static int fill_inputbuffer(void) ...@@ -239,7 +239,7 @@ static int fill_inputbuffer(void)
case INPUT_UNICODE: case INPUT_UNICODE:
len += fread( inputbuffer + len, sizeof(WCHAR), INPUTBUFFER_SIZE - len, yyin ); len += fread( inputbuffer + len, sizeof(WCHAR), INPUTBUFFER_SIZE - len, yyin );
if (!len) break; 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; ninputbuffer = len;
return 1; return 1;
case INPUT_UNKNOWN: case INPUT_UNKNOWN:
......
...@@ -439,7 +439,6 @@ WCHAR *codepage_to_unicode( int codepage, const char *src, int srclen, int *dstl ...@@ -439,7 +439,6 @@ WCHAR *codepage_to_unicode( int codepage, const char *src, int srclen, int *dstl
* Function for writing to a memory buffer. * Function for writing to a memory buffer.
*/ */
int byte_swapped = 0;
unsigned char *output_buffer; unsigned char *output_buffer;
size_t output_buffer_pos; size_t output_buffer_pos;
size_t output_buffer_size; size_t output_buffer_size;
...@@ -470,13 +469,6 @@ void flush_output_buffer( const char *name ) ...@@ -470,13 +469,6 @@ void flush_output_buffer( const char *name )
free( output_buffer ); 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 ) void put_byte( unsigned char val )
{ {
check_output_buffer_space( 1 ); check_output_buffer_space( 1 );
...@@ -485,15 +477,18 @@ void put_byte( unsigned char val ) ...@@ -485,15 +477,18 @@ void put_byte( unsigned char val )
void put_word( unsigned short val ) void put_word( unsigned short val )
{ {
if (byte_swapped) val = (val << 8) | (val >> 8); check_output_buffer_space( 2 );
put_data( &val, sizeof(val) ); output_buffer[output_buffer_pos++] = val;
output_buffer[output_buffer_pos++] = val >> 8;
} }
void put_dword( unsigned int val ) void put_dword( unsigned int val )
{ {
if (byte_swapped) check_output_buffer_space( 4 );
val = ((val << 24) | ((val << 8) & 0x00ff0000) | ((val >> 8) & 0x0000ff00) | (val >> 24)); output_buffer[output_buffer_pos++] = val;
put_data( &val, sizeof(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 ) void align_output( unsigned int align )
......
...@@ -43,14 +43,12 @@ WCHAR *codepage_to_unicode( int codepage, const char *src, int srclen, int *dstl ...@@ -43,14 +43,12 @@ WCHAR *codepage_to_unicode( int codepage, const char *src, int srclen, int *dstl
/* buffer management */ /* buffer management */
extern int byte_swapped;
extern unsigned char *output_buffer; extern unsigned char *output_buffer;
extern size_t output_buffer_pos; extern size_t output_buffer_pos;
extern size_t output_buffer_size; extern size_t output_buffer_size;
extern void init_output_buffer(void); extern void init_output_buffer(void);
extern void flush_output_buffer( const char *name ); 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_byte( unsigned char val );
extern void put_word( unsigned short val ); extern void put_word( unsigned short val );
extern void put_dword( unsigned int val ); extern void put_dword( unsigned int val );
......
...@@ -37,14 +37,6 @@ ...@@ -37,14 +37,6 @@
static const char usage[] = static const char usage[] =
"Usage: wmc [options...] [inputfile.mc]\n" "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" " -c Set 'custom-bit' in values\n"
" -d Use decimal values in output\n" " -d Use decimal values in output\n"
" -D Set debug flag\n" " -D Set debug flag\n"
...@@ -71,11 +63,6 @@ static const char version_string[] = ...@@ -71,11 +63,6 @@ static const char version_string[] =
; ;
/* /*
* 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) * Custom bit (bit 29) in output values must be set (-c option)
*/ */
int custombit = 0; int custombit = 0;
...@@ -136,7 +123,7 @@ enum long_options_values ...@@ -136,7 +123,7 @@ enum long_options_values
LONG_OPT_NLS_DIR = 1, 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[] = static const struct long_option long_options[] =
{ {
{ "help", 0, 'h' }, { "help", 0, 'h' },
...@@ -190,25 +177,6 @@ static void option_callback( int optc, char *optarg ) ...@@ -190,25 +177,6 @@ static void option_callback( int optc, char *optarg )
{ {
switch(optc) 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': case 'c':
custombit = 1; custombit = 1;
break; break;
...@@ -347,12 +315,6 @@ int main(int argc,char *argv[]) ...@@ -347,12 +315,6 @@ int main(int argc,char *argv[])
exit(1); exit(1);
} }
#ifdef WORDS_BIGENDIAN
byte_swapped = (byteorder == WMC_BO_LITTLE);
#else
byte_swapped = (byteorder == WMC_BO_BIG);
#endif
switch (output_format) switch (output_format)
{ {
case FORMAT_RC: case FORMAT_RC:
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
extern int pedantic; extern int pedantic;
extern int leave_case; extern int leave_case;
extern int byteorder;
extern int decimal; extern int decimal;
extern int custombit; extern int custombit;
extern int unicodein; extern int unicodein;
......
...@@ -22,9 +22,6 @@ with \fB-o\fR, then \fBwmc\fR will write the output to \fIinputfile.{rc,h}\fR. ...@@ -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. The outputfile is named \fIwmc.tab.{rc,h}\fR if no inputfile was given.
.SH OPTIONS .SH OPTIONS
.TP .TP
.BI \-B\ x
Set output byte-order x={n[ative], l[ittle], b[ig]}. Default is n[ative].
.TP
.B \-c .B \-c
Set 'custom-bit' in message-code values. Set 'custom-bit' in message-code values.
.TP .TP
......
...@@ -25,18 +25,6 @@ ...@@ -25,18 +25,6 @@
#include "windef.h" #include "windef.h"
#include "winbase.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 * Tokenizer types
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment