Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
923461f3
Commit
923461f3
authored
Nov 11, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc: Windows file formats are always little-endian.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7c5761ed
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
238 deletions
+28
-238
genres.c
tools/wrc/genres.c
+16
-100
newstruc.c
tools/wrc/newstruc.c
+0
-0
parser.y
tools/wrc/parser.y
+9
-86
wrc.c
tools/wrc/wrc.c
+0
-34
wrc.h
tools/wrc/wrc.h
+1
-1
wrc.man.in
tools/wrc/wrc.man.in
+0
-6
wrctypes.h
tools/wrc/wrctypes.h
+2
-11
No files found.
tools/wrc/genres.c
View file @
923461f3
...
...
@@ -90,24 +90,8 @@ void put_word(res_t *res, unsigned w)
{
if
(
res
->
allocsize
-
res
->
size
<
sizeof
(
WORD
))
grow_res
(
res
,
RES_BLOCKSIZE
);
switch
(
byteorder
)
{
#ifdef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_BIG
:
res
->
data
[
res
->
size
+
0
]
=
HIBYTE
(
w
);
res
->
data
[
res
->
size
+
1
]
=
LOBYTE
(
w
);
break
;
#ifndef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_LITTLE
:
res
->
data
[
res
->
size
+
1
]
=
HIBYTE
(
w
);
res
->
data
[
res
->
size
+
0
]
=
LOBYTE
(
w
);
break
;
}
res
->
data
[
res
->
size
+
0
]
=
w
;
res
->
data
[
res
->
size
+
1
]
=
w
>>
8
;
res
->
size
+=
sizeof
(
WORD
);
}
...
...
@@ -115,28 +99,10 @@ void put_dword(res_t *res, unsigned d)
{
if
(
res
->
allocsize
-
res
->
size
<
sizeof
(
DWORD
))
grow_res
(
res
,
RES_BLOCKSIZE
);
switch
(
byteorder
)
{
#ifdef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_BIG
:
res
->
data
[
res
->
size
+
0
]
=
HIBYTE
(
HIWORD
(
d
));
res
->
data
[
res
->
size
+
1
]
=
LOBYTE
(
HIWORD
(
d
));
res
->
data
[
res
->
size
+
2
]
=
HIBYTE
(
LOWORD
(
d
));
res
->
data
[
res
->
size
+
3
]
=
LOBYTE
(
LOWORD
(
d
));
break
;
#ifndef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_LITTLE
:
res
->
data
[
res
->
size
+
3
]
=
HIBYTE
(
HIWORD
(
d
));
res
->
data
[
res
->
size
+
2
]
=
LOBYTE
(
HIWORD
(
d
));
res
->
data
[
res
->
size
+
1
]
=
HIBYTE
(
LOWORD
(
d
));
res
->
data
[
res
->
size
+
0
]
=
LOBYTE
(
LOWORD
(
d
));
break
;
}
res
->
data
[
res
->
size
+
0
]
=
d
;
res
->
data
[
res
->
size
+
1
]
=
d
>>
8
;
res
->
data
[
res
->
size
+
2
]
=
d
>>
16
;
res
->
data
[
res
->
size
+
3
]
=
d
>>
24
;
res
->
size
+=
sizeof
(
DWORD
);
}
...
...
@@ -164,50 +130,16 @@ static void put_pad(res_t *res)
*/
static
void
set_word
(
res_t
*
res
,
int
ofs
,
unsigned
w
)
{
switch
(
byteorder
)
{
#ifdef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_BIG
:
res
->
data
[
ofs
+
0
]
=
HIBYTE
(
w
);
res
->
data
[
ofs
+
1
]
=
LOBYTE
(
w
);
break
;
#ifndef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_LITTLE
:
res
->
data
[
ofs
+
1
]
=
HIBYTE
(
w
);
res
->
data
[
ofs
+
0
]
=
LOBYTE
(
w
);
break
;
}
res
->
data
[
ofs
+
0
]
=
w
;
res
->
data
[
ofs
+
1
]
=
w
>>
8
;
}
static
void
set_dword
(
res_t
*
res
,
int
ofs
,
unsigned
d
)
{
switch
(
byteorder
)
{
#ifdef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_BIG
:
res
->
data
[
ofs
+
0
]
=
HIBYTE
(
HIWORD
(
d
));
res
->
data
[
ofs
+
1
]
=
LOBYTE
(
HIWORD
(
d
));
res
->
data
[
ofs
+
2
]
=
HIBYTE
(
LOWORD
(
d
));
res
->
data
[
ofs
+
3
]
=
LOBYTE
(
LOWORD
(
d
));
break
;
#ifndef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_LITTLE
:
res
->
data
[
ofs
+
3
]
=
HIBYTE
(
HIWORD
(
d
));
res
->
data
[
ofs
+
2
]
=
LOBYTE
(
HIWORD
(
d
));
res
->
data
[
ofs
+
1
]
=
HIBYTE
(
LOWORD
(
d
));
res
->
data
[
ofs
+
0
]
=
LOBYTE
(
LOWORD
(
d
));
break
;
}
res
->
data
[
ofs
+
0
]
=
d
;
res
->
data
[
ofs
+
1
]
=
d
>>
8
;
res
->
data
[
ofs
+
2
]
=
d
>>
16
;
res
->
data
[
ofs
+
3
]
=
d
>>
24
;
}
/*
...
...
@@ -224,26 +156,10 @@ static void set_dword(res_t *res, int ofs, unsigned d)
*/
static
DWORD
get_dword
(
res_t
*
res
,
int
ofs
)
{
switch
(
byteorder
)
{
#ifdef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_BIG
:
return
(
res
->
data
[
ofs
+
0
]
<<
24
)
|
(
res
->
data
[
ofs
+
1
]
<<
16
)
|
(
res
->
data
[
ofs
+
2
]
<<
8
)
|
res
->
data
[
ofs
+
3
];
#ifndef WORDS_BIGENDIAN
default:
#endif
case
WRC_BO_LITTLE
:
return
(
res
->
data
[
ofs
+
3
]
<<
24
)
|
(
res
->
data
[
ofs
+
2
]
<<
16
)
|
(
res
->
data
[
ofs
+
1
]
<<
8
)
|
res
->
data
[
ofs
+
0
];
}
return
(
res
->
data
[
ofs
+
3
]
<<
24
)
|
(
res
->
data
[
ofs
+
2
]
<<
16
)
|
(
res
->
data
[
ofs
+
1
]
<<
8
)
|
res
->
data
[
ofs
+
0
];
}
static
res_t
*
end_res
(
res_t
*
res
,
int
ofs
)
...
...
tools/wrc/newstruc.c
View file @
923461f3
This diff is collapsed.
Click to expand it.
tools/wrc/parser.y
View file @
923461f3
...
...
@@ -704,12 +704,6 @@ dlginit : tDLGINIT loadmemopts file_raw { $$ = new_dlginit($3, $2); }
/* ------------------------------ UserType ------------------------------ */
userres
:
usertype
loadmemopts
file_raw
{
#ifdef
WORDS_BIGENDIAN
if(pedantic
&&
byteorder
!=
WRC_BO_LITTLE)
#else
if(pedantic
&&
byteorder
==
WRC_BO_BIG)
#endif
parser_warning("Byteordering
is
not
little-endian
and
type
cannot
be
interpreted\n");
$$
=
new_user($1,
$3,
$2);
}
;
...
...
@@ -2197,24 +2191,8 @@ static raw_data_t *int2raw_data(int i)
rd
=
new_raw_data();
rd->size
=
sizeof(short);
rd->data
=
xmalloc(rd->size);
switch(byteorder)
{
#ifdef
WORDS_BIGENDIAN
default
:
#e
ndif
case
WRC_BO_BIG
:
rd-
>
data
[
0
]
=
HIBYTE
(
i
);
rd->data[1]
=
LOBYTE(i);
break;
#ifndef
WORDS_BIGENDIAN
default
:
#e
ndif
case
WRC_BO_LITTLE
:
rd-
>
data
[
1
]
=
HIBYTE
(
i
);
rd->data[0]
=
LOBYTE(i);
break;
}
rd->data[0]
=
i;
rd->data[1]
=
i
>>
8;
return
rd;
}
...
...
@@ -2224,28 +2202,10 @@ static raw_data_t *long2raw_data(int i)
rd
=
new_raw_data();
rd->size
=
sizeof(int);
rd->data
=
xmalloc(rd->size);
switch(byteorder)
{
#ifdef
WORDS_BIGENDIAN
default
:
#e
ndif
case
WRC_BO_BIG
:
rd-
>
data
[
0
]
=
HIBYTE
(
HIWORD
(
i
));
rd->data[1]
=
LOBYTE(HIWORD(i));
rd->data[2]
=
HIBYTE(LOWORD(i));
rd->data[3]
=
LOBYTE(LOWORD(i));
break;
#ifndef
WORDS_BIGENDIAN
default
:
#e
ndif
case
WRC_BO_LITTLE
:
rd-
>
data
[
3
]
=
HIBYTE
(
HIWORD
(
i
));
rd->data[2]
=
LOBYTE(HIWORD(i));
rd->data[1]
=
HIBYTE(LOWORD(i));
rd->data[0]
=
LOBYTE(LOWORD(i));
break;
}
rd->data[0]
=
i;
rd->data[1]
=
i
>>
8;
rd->data[2]
=
i
>>
16;
rd->data[3]
=
i
>>
24;
return
rd;
}
...
...
@@ -2263,28 +2223,10 @@ static raw_data_t *str2raw_data(string_t *str)
case
str_unicode
:
{
int
i
;
switch(byteorder
)
for(i
=
0;
i
<
str->size;
i++
)
{
#ifdef
WORDS_BIGENDIAN
default
:
#e
ndif
case
WRC_BO_BIG
:
for
(
i
=
0
;
i
<
str->size;
i++)
{
rd->data[2*i
+
0]
=
HIBYTE((WORD)str->str.wstr[i]);
rd->data[2*i
+
1]
=
LOBYTE((WORD)str->str.wstr[i]);
}
break
;
#ifndef
WORDS_BIGENDIAN
default
:
#endif
case
WRC_BO_LITTLE
:
for
(
i
=
0
;
i
<
str-
>
size
;
i
++)
{
rd->data[2*i
+
1]
=
HIBYTE((WORD)str->str.wstr[i]);
rd->data[2*i
+
0]
=
LOBYTE((WORD)str->str.wstr[i]);
}
break
;
rd->data[2*i
+
0]
=
str->str.wstr[i];
rd->data[2*i
+
1]
=
str->str.wstr[i]
>>
8;
}
}
}
...
...
@@ -2688,8 +2630,6 @@ static resource_t *build_fontdirs(resource_t *tail)
for
(
i
=
0
;
i
<
nfnd
;
i
++)
{
int
j;
WORD
cnt;
int
isswapped
=
0;
if(!fnd[i])
continue;
...
...
@@ -2704,23 +2644,6 @@ static resource_t *build_fontdirs(resource_t *tail)
fnt[j]
=
NULL;
}
}
cnt
=
*(
WORD
*)
fnd
[
i
]
-
>
res
.fnd-
>
data-
>
data
;
if
(
nlanfnt
==
cnt
)
isswapped
=
0
;
else
if
(
nlanfnt
==
BYTESWAP_WORD
(
cnt
))
isswapped
=
1
;
else
error
(
"FONTDIR for language %d,%d has wrong count (%d, expected %d)\n"
,
fnd
[
i
]
-
>
lan-
>
id
,
fnd
[
i
]
-
>
lan-
>
sub
,
cnt
,
nlanfnt
);
#ifdef
WORDS_BIGENDIAN
if
((
byteorder
==
WRC_BO_LITTLE
&&
!
isswapped
)
||
(
byteorder
!=
WRC_BO_LITTLE
&&
isswapped
))
#else
if
((
byteorder
==
WRC_BO_BIG
&&
!
isswapped
)
||
(
byteorder
!=
WRC_BO_BIG
&&
isswapped
))
#endif
{
error("User
supplied
FONTDIR
needs
byteswapping\n");
}
}
/* We now have fonts left where we need to make a fontdir resource */
...
...
tools/wrc/wrc.c
View file @
923461f3
...
...
@@ -42,19 +42,11 @@
#include "parser.h"
#include "wpp_private.h"
#ifdef WORDS_BIGENDIAN
#define ENDIAN "big"
#else
#define ENDIAN "little"
#endif
static
const
char
usage
[]
=
"Usage: wrc [options...] [infile[.rc|.res]]
\n
"
" -D, --define id[=val] Define preprocessor identifier id=val
\n
"
" --debug=nn Set debug level to 'nn'
\n
"
" -E Preprocess only
\n
"
" --endianness=e Set output byte-order e={n[ative], l[ittle], b[ig]}
\n
"
" (win32 only; default is "
ENDIAN
"-endian)
\n
"
" -F TARGET Ignored, for compatibility with windres
\n
"
" -fo FILE Synonym for -o for compatibility with windres
\n
"
" -h, --help Prints this summary
\n
"
...
...
@@ -128,11 +120,6 @@ language_t *currentlanguage = NULL;
int
pedantic
=
0
;
/*
* The output byte-order of resources (set with -B)
*/
int
byteorder
=
WRC_BO_NATIVE
;
/*
* Set when _only_ to run the preprocessor (-E option)
*/
int
preprocess_only
=
0
;
...
...
@@ -181,7 +168,6 @@ enum long_options_values
LONG_OPT_SYSROOT
,
LONG_OPT_VERSION
,
LONG_OPT_DEBUG
,
LONG_OPT_ENDIANNESS
,
LONG_OPT_PEDANTIC
,
LONG_OPT_VERIFY_TRANSL
};
...
...
@@ -191,7 +177,6 @@ static const char short_options[] =
static
const
struct
long_option
long_options
[]
=
{
{
"debug"
,
1
,
LONG_OPT_DEBUG
},
{
"define"
,
1
,
'D'
},
{
"endianness"
,
1
,
LONG_OPT_ENDIANNESS
},
{
"help"
,
0
,
'h'
},
{
"include-dir"
,
1
,
'I'
},
{
"input"
,
1
,
'i'
},
...
...
@@ -372,25 +357,6 @@ static void option_callback( int optc, char *optarg )
case
LONG_OPT_DEBUG
:
debuglevel
=
strtol
(
optarg
,
NULL
,
0
);
break
;
case
LONG_OPT_ENDIANNESS
:
switch
(
optarg
[
0
])
{
case
'n'
:
case
'N'
:
byteorder
=
WRC_BO_NATIVE
;
break
;
case
'l'
:
case
'L'
:
byteorder
=
WRC_BO_LITTLE
;
break
;
case
'b'
:
case
'B'
:
byteorder
=
WRC_BO_BIG
;
break
;
default:
error
(
"Byte ordering must be n[ative], l[ittle] or b[ig]
\n
"
);
}
break
;
case
LONG_OPT_PEDANTIC
:
pedantic
=
1
;
break
;
...
...
tools/wrc/wrc.h
View file @
923461f3
...
...
@@ -35,7 +35,7 @@ extern int debuglevel;
extern
int
win32
;
extern
int
extensions
;
extern
int
byteorder
;
extern
int
pedantic
;
extern
int
preprocess_only
;
extern
int
no_preprocess
;
extern
int
utf8_input
;
...
...
tools/wrc/wrc.man.in
View file @
923461f3
...
...
@@ -32,12 +32,6 @@ Set debug level to \fInn\fR. The value is a bitmask consisting of
1=verbose, 2=dump internals, 4=resource parser trace, 8=preprocessor
messages, 16=preprocessor scanner and 32=preprocessor parser trace.
.TP
.I \fB\-\-endianness\fR=\fIe\fR
Win32 only; set output byte\-ordering, where \fIe\fR is one of n[ative],
l[ittle] or b[ig]. Only resources in source-form can be reordered. Native
ordering depends on the system on which \fBwrc\fR was built. You can see
the native ordering by typing \fIwrc \-h\fR.
.TP
.I \fB\-E\fR
Preprocess only. The output is written to standard output if no
outputfile was selected. The output is compatible with what gcc would
...
...
tools/wrc/wrctypes.h
View file @
923461f3
...
...
@@ -68,17 +68,8 @@
#define CT_SCROLLBAR 0x84
#define CT_COMBOBOX 0x85
/* Byteordering defines */
#define WRC_BO_NATIVE 0x00
#define WRC_BO_LITTLE 0x01
#define WRC_BO_BIG 0x02
#define WRC_LOBYTE(w) ((WORD)(w) & 0xff)
#define WRC_HIBYTE(w) (((WORD)(w) >> 8) & 0xff)
#define WRC_LOWORD(d) ((DWORD)(d) & 0xffff)
#define WRC_HIWORD(d) (((DWORD)(d) >> 16) & 0xffff)
#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)))))
#define GET_WORD(ptr) (((BYTE *)(ptr))[0] | (((BYTE *)(ptr))[1] << 8))
#define GET_DWORD(ptr) (((BYTE *)(ptr))[0] | (((BYTE *)(ptr))[1] << 8) | (((BYTE *)(ptr))[2] << 16) | (((BYTE *)(ptr))[3] << 24))
typedef
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment