3 * Copyright 1994 Martin von Loewis
4 * Copyright 1998-2000 Bertho A. Stultiens (BS)
5 * 1999 Juergen Schmied (JS)
7 * 21-May-2000 BS - Partial implementation of font resources.
8 * - Corrected language propagation for binary
9 * resources such as bitmaps, isons, cursors,
10 * userres and rcdata. The language is now
11 * correct in .res files.
12 * - Fixed reading the resource name as ident,
13 * so that it may overlap keywords.
14 * 20-May-2000 BS - Implemented animated cursors and icons
16 * 30-Apr-2000 BS - Reintegration into the wine-tree
17 * 14-Jan-2000 BS - Redid the usertype resources so that they
19 * 02-Jan-2000 BS - Removed the preprocessor from the grammar
20 * expect for the # command (line numbers).
22 * 06-Nov-1999 JS - see CHANGES
24 * 29-Dec-1998 AdH - Grammar and function extensions.
25 * grammar: TOOLBAR resources, Named ICONs in
27 * functions: semantic actions for the grammar
28 * changes, resource files can now be anywhere
29 * on the include path instead of just in the
32 * 20-Jun-1998 BS - Fixed a bug in load_file() where the name was not
33 * printed out correctly.
35 * 17-Jun-1998 BS - Fixed a bug in CLASS statement parsing which should
36 * also accept a tSTRING as argument.
38 * 25-May-1998 BS - Found out that I need to support language, version
39 * and characteristics in inline resources (bitmap,
40 * cursor, etc) but they can also be specified with
41 * a filename. This renders my filename-scanning scheme
42 * worthless. Need to build newline parsing to solve
44 * It will come with version 1.1.0 (sigh).
46 * 19-May-1998 BS - Started to build a builtin preprocessor
48 * 30-Apr-1998 BS - Redid the stringtable parsing/handling. My previous
49 * ideas had some serious flaws.
51 * 27-Apr-1998 BS - Removed a lot of dead comments and put it in a doc
54 * 21-Apr-1998 BS - Added correct behavior for cursors and icons.
55 * - This file is growing too big. It is time to strip
56 * things and put it in a support file.
58 * 19-Apr-1998 BS - Tagged the stringtable resource so that only one
59 * resource will be created. This because the table
60 * has a different layout than other resources. The
61 * table has to be sorted, and divided into smaller
62 * resource entries (see comment in source).
64 * 17-Apr-1998 BS - Almost all strings, including identifiers, are parsed
65 * as string_t which include unicode strings upon
67 * - Parser now emits a warning when compiling win32
68 * extensions in win16 mode.
70 * 16-Apr-1998 BS - Raw data elements are now *optionally* seperated
71 * by commas. Read the comments in file sq2dq.l.
72 * - FIXME: there are instances in the source that rely
73 * on the fact that int==32bit and pointers are int size.
74 * - Fixed the conflict in menuex by changing a rule
75 * back into right recursion. See note in source.
76 * - UserType resources cannot have an expression as its
77 * typeclass. See note in source.
79 * 15-Apr-1998 BS - Changed all right recursion into left recursion to
80 * get reduction of the parsestack.
81 * This also helps communication between bison and flex.
82 * Main advantage is that the Empty rule gets reduced
83 * first, which is used to allocate/link things.
84 * It also added a shift/reduce conflict in the menuex
85 * handling, due to expression/option possibility,
86 * although not serious.
88 * 14-Apr-1998 BS - Redone almost the entire parser. We're not talking
89 * about making it more efficient, but readable (for me)
90 * and slightly easier to expand/change.
91 * This is done primarily by using more reduce states
92 * with many (intuitive) types for the various resource
94 * - Added expression handling for all resources where a
95 * number is accepted (not only for win32). Also added
96 * multiply and division (not MS compatible, but handy).
97 * Unary minus introduced a shift/reduce conflict, but
100 * 13-Apr-1998 BS - Reordered a lot of things
101 * - Made the source more readable
102 * - Added Win32 resource definitions
103 * - Corrected syntax problems with an old yacc (;)
104 * - Added extra comment about grammar
120 #include "newstruc.h"
128 int want_nl
= 0; /* Signal flex that we need the next newline */
129 int want_id
= 0; /* Signal flex that we need the next identifier */
130 stringtable_t
*tagstt
; /* Stringtable tag.
131 * It is set while parsing a stringtable to one of
132 * the stringtables in the sttres list or a new one
133 * if the language was not parsed before.
135 stringtable_t
*sttres
; /* Stringtable resources. This holds the list of
136 * stringtables with different lanuages
138 /* Set to the current options of the currently scanning stringtable */
139 static int *tagstt_memopt
;
140 static characts_t
*tagstt_characts
;
141 static version_t
*tagstt_version
;
143 static const char riff
[4] = "RIFF"; /* RIFF file magic for animated cursor/icon */
145 /* Prototypes of here defined functions */
146 static event_t
*get_event_head
(event_t
*p
);
147 static control_t
*get_control_head
(control_t
*p
);
148 static ver_value_t
*get_ver_value_head
(ver_value_t
*p
);
149 static ver_block_t
*get_ver_block_head
(ver_block_t
*p
);
150 static resource_t
*get_resource_head
(resource_t
*p
);
151 static menuex_item_t
*get_itemex_head
(menuex_item_t
*p
);
152 static menu_item_t
*get_item_head
(menu_item_t
*p
);
153 static raw_data_t
*merge_raw_data_str
(raw_data_t
*r1
, string_t
*str
);
154 static raw_data_t
*merge_raw_data_int
(raw_data_t
*r1
, int i
);
155 static raw_data_t
*merge_raw_data_long
(raw_data_t
*r1
, int i
);
156 static raw_data_t
*merge_raw_data
(raw_data_t
*r1
, raw_data_t
*r2
);
157 static raw_data_t
*str2raw_data
(string_t
*str
);
158 static raw_data_t
*int2raw_data
(int i
);
159 static raw_data_t
*long2raw_data
(int i
);
160 static raw_data_t
*load_file
(string_t
*name
);
161 static itemex_opt_t
*new_itemex_opt
(int id
, int type
, int state
, int helpid
);
162 static event_t
*add_string_event
(string_t
*key
, int id
, int flags
, event_t
*prev
);
163 static event_t
*add_event
(int key
, int id
, int flags
, event_t
*prev
);
164 static dialogex_t
*dialogex_version
(version_t
*v
, dialogex_t
*dlg
);
165 static dialogex_t
*dialogex_characteristics
(characts_t
*c
, dialogex_t
*dlg
);
166 static dialogex_t
*dialogex_language
(language_t
*l
, dialogex_t
*dlg
);
167 static dialogex_t
*dialogex_menu
(name_id_t
*m
, dialogex_t
*dlg
);
168 static dialogex_t
*dialogex_class
(name_id_t
*n
, dialogex_t
*dlg
);
169 static dialogex_t
*dialogex_font
(font_id_t
*f
, dialogex_t
*dlg
);
170 static dialogex_t
*dialogex_caption
(string_t
*s
, dialogex_t
*dlg
);
171 static dialogex_t
*dialogex_exstyle
(style_t
*st
, dialogex_t
*dlg
);
172 static dialogex_t
*dialogex_style
(style_t
*st
, dialogex_t
*dlg
);
173 static name_id_t
*convert_ctlclass
(name_id_t
*cls
);
174 static control_t
*ins_ctrl
(int type
, int special_style
, control_t
*ctrl
, control_t
*prev
);
175 static dialog_t
*dialog_version
(version_t
*v
, dialog_t
*dlg
);
176 static dialog_t
*dialog_characteristics
(characts_t
*c
, dialog_t
*dlg
);
177 static dialog_t
*dialog_language
(language_t
*l
, dialog_t
*dlg
);
178 static dialog_t
*dialog_menu
(name_id_t
*m
, dialog_t
*dlg
);
179 static dialog_t
*dialog_class
(name_id_t
*n
, dialog_t
*dlg
);
180 static dialog_t
*dialog_font
(font_id_t
*f
, dialog_t
*dlg
);
181 static dialog_t
*dialog_caption
(string_t
*s
, dialog_t
*dlg
);
182 static dialog_t
*dialog_exstyle
(style_t
* st
, dialog_t
*dlg
);
183 static dialog_t
*dialog_style
(style_t
* st
, dialog_t
*dlg
);
184 static resource_t
*build_stt_resources
(stringtable_t
*stthead
);
185 static stringtable_t
*find_stringtable
(lvc_t
*lvc
);
186 static toolbar_item_t
*ins_tlbr_button
(toolbar_item_t
*prev
, toolbar_item_t
*idrec
);
187 static toolbar_item_t
*get_tlbr_buttons_head
(toolbar_item_t
*p
, int *nitems
);
188 static string_t
*make_filename
(string_t
*s
);
189 static resource_t
*build_fontdirs
(resource_t
*tail
);
190 static resource_t
*build_fontdir
(resource_t
**fnt
, int nfnt
);
191 static int rsrcid_to_token
(int lookahead
);
222 menuex_item_t
*menexitm
;
230 toolbar_item_t
*tlbarItems
;
232 style_pair_t
*styles
;
237 %token tTYPEDEF tEXTERN tSTRUCT tENUM tCPPCLASS tINLINE tSTATIC tNL
238 %token
<num
> tNUMBER tLNUMBER
239 %token
<str
> tSTRING tIDENT tFILENAME
240 %token
<raw
> tRAWDATA
241 %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE
242 %token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON
243 %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON
244 %token tPUSHBUTTON tRADIOBUTTON tSTATE3
/* PUSHBOX */
245 %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR
246 %token tCONTROL tEDITTEXT
247 %token tRTEXT tCTEXT tLTEXT
249 %token tSHIFT tALT tASCII tVIRTKEY tGRAYED tCHECKED tINACTIVE tNOINVERT
250 %token tPURE tIMPURE tDISCARDABLE tLOADONCALL tPRELOAD tFIXED tMOVEABLE
251 %token tCLASS tCAPTION tCHARACTERISTICS tEXSTYLE tSTYLE tVERSION tLANGUAGE
252 %token tFILEVERSION tPRODUCTVERSION tFILEFLAGSMASK tFILEOS tFILETYPE tFILEFLAGS tFILESUBTYPE
253 %token tMENUBARBREAK tMENUBREAK tMENUITEM tPOPUP tSEPARATOR
255 %token tSTRING tIDENT tRAWDATA
256 %token tTOOLBAR tBUTTON
267 %type
<res
> resource_file resource resources resource_definition
268 %type
<stt
> stringtable strings
271 %type
<acc
> accelerators
274 %type
<ani
> cursor icon
275 %type
<dlg
> dialog dlg_attributes
276 %type
<ctl
> ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo
278 %type
<dlgex
> dialogex dlgex_attribs
279 %type
<ctl
> exctrls gen_exctrl lab_exctrl exctrl_desc
281 %type
<raw
> raw_data raw_elements opt_data file_raw
282 %type
<veri
> versioninfo fix_version
283 %type
<verw
> ver_words
284 %type
<blk
> ver_blocks ver_block
285 %type
<val
> ver_values ver_value
287 %type
<menitm
> item_definitions menu_body
289 %type
<menexitm
> itemex_definitions menuex_body
290 %type
<exopt
> itemex_p_options itemex_options
291 %type
<msg
> messagetable
293 %type
<num
> item_options
294 %type
<nid
> nameid nameid_s ctlclass usertype
295 %type
<num
> acc_opt acc accs
296 %type
<iptr
> loadmemopts lamo lama
297 %type
<fntid
> opt_font opt_exfont opt_expr
299 %type
<lan
> opt_language
300 %type
<chars
> opt_characts
301 %type
<ver
> opt_version
304 %type
<tlbar
> toolbar
305 %type
<tlbarItems
> toolbar_items
306 %type
<dginit
> dlginit
307 %type
<styles
> optional_style_pair
308 %type
<num
> any_num any_nums
309 %type
<style
> optional_style
318 /* First add stringtables to the resource-list */
319 rsc
= build_stt_resources
(sttres
);
320 /* 'build_stt_resources' returns a head and $1 is a tail */
329 /* Find the tail again */
330 while
($1 && $1->next
)
332 /* Now add any fontdirecory */
333 rsc
= build_fontdirs
($1);
334 /* 'build_fontdir' returns a head and $1 is a tail */
343 /* Final statement before were done */
344 resource_top
= get_resource_head
($1);
348 /* Resources are put into a linked list */
350 : /* Empty */ { $$
= NULL
; want_id
= 1; }
351 | resources resource
{
354 resource_t
*tail
= $2;
355 resource_t
*head
= $2;
364 /* Check for duplicate identifiers */
367 resource_t
*rsc
= $1;
370 if
(rsc
->type
== head
->type
371 && rsc
->lan
->id
== head
->lan
->id
372 && rsc
->lan
->sub
== head
->lan
->sub
373 && !compare_name_id
(rsc
->name
, head
->name
))
375 yyerror("Duplicate resource name '%s'", get_nameid_str
(rsc
->name
));
384 resource_t
*tail
= $1;
393 | resources preprocessor
{ $$
= $1; want_id
= 1; }
394 | resources cjunk
{ $$
= $1; want_id
= 1; }
398 * The preprocessor generates line directives a la gcc
400 * # <linenum> "filename" <codes>
402 * Codes can be a sequence of:
403 * - 1 start of new file
404 * - 2 returning to previous
406 * - 4 interpret as C-code
408 * 4 is not used and 1 mutually excludes 2
409 * Anyhow, we are not really interested in these at all
410 * because we only want to know the linenumber and
414 : '#' { want_nl
= 1; } tNUMBER tSTRING any_nums tNL
{
416 input_name
= $4->str.cstr
;
417 /* fprintf(stderr, "Now at %s:%d\n", input_name, line_number); */
426 cjunk
: tTYPEDEF
{ strip_til_semicolon
(); }
427 | tSTRUCT
{ strip_til_semicolon
(); }
428 | tEXTERN
{ strip_til_semicolon
(); }
429 | tENUM
{ strip_til_semicolon
(); }
430 | tCPPCLASS
{ strip_til_semicolon
(); }
431 | tSTATIC
{ strip_til_semicolon
(); }
432 | tINLINE
{ internal_error
(__FILE__
, __LINE__
, "Don't yet know how to strip inline functions\n"); }
433 /* | tIDENT tIDENT { strip_til_semicolon(); } */
434 | tIDENT tIDENT
'(' { strip_til_parenthesis
(); }
435 /* | tIDENT '(' { strip_til_parenthesis(); } */
436 | tIDENT
'*' { strip_til_semicolon
(); }
439 /* Parse top level resource definitions etc. */
441 : nameid usrcvt resource_definition
{
446 if
($1->type
== name_ord
)
448 chat
("Got %s (%d)",get_typename
($3),$1->name.i_name
);
450 else if
($1->type
== name_str
)
452 chat
("Got %s (%s)",get_typename
($3),$1->name.s_name
->str.cstr
);
457 /* Don't do anything, stringtables are converted to
458 * resource_t structures when we are finished parsing and
459 * the final rule of the parser is reduced (see above)
462 chat
("Got STRINGTABLE");
464 | tLANGUAGE
{want_nl
= 1; } expr
',' expr tNL
{
465 /* We *NEED* the newline to delimit the expression.
466 * Otherwise, we would not be able to set the next
467 * want_id anymore because of the token-lookahead.
470 yywarning
("LANGUAGE not supported in 16-bit mode");
472 free
(currentlanguage
);
473 currentlanguage
= new_language
($3, $5);
479 * Remapping of numerical resource types
480 * (see also comment of called function below)
482 usrcvt
: /* Empty */ { yychar = rsrcid_to_token
(yychar); }
486 * Get a valid name/id
489 if
($1 > 65535 ||
$1 < -32768)
490 yyerror("Resource's ID out of range (%d)", $1);
493 $$
->name.i_name
= $1;
498 $$
->name.s_name
= $1;
503 * Extra string recognition for CLASS statement in dialogs
505 nameid_s: nameid
{ $$
= $1; }
509 $$
->name.s_name
= $1;
513 /* get the value for a single resource*/
515 : accelerators
{ $$
= new_resource
(res_acc
, $1, $1->memopt
, $1->lvc.language
); }
516 | bitmap
{ $$
= new_resource
(res_bmp
, $1, $1->memopt
, $1->data
->lvc.language
); }
519 if
($1->type
== res_anicur
)
521 $$
= rsc
= new_resource
(res_anicur
, $1->u.ani
, $1->u.ani
->memopt
, $1->u.ani
->data
->lvc.language
);
523 else if
($1->type
== res_curg
)
526 $$
= rsc
= new_resource
(res_curg
, $1->u.curg
, $1->u.curg
->memopt
, $1->u.curg
->lvc.language
);
527 for
(cur
= $1->u.curg
->cursorlist
; cur
; cur
= cur
->next
)
529 rsc
->prev
= new_resource
(res_cur
, cur
, $1->u.curg
->memopt
, $1->u.curg
->lvc.language
);
530 rsc
->prev
->next
= rsc
;
532 rsc
->name
= new_name_id
();
533 rsc
->name
->type
= name_ord
;
534 rsc
->name
->name.i_name
= cur
->id
;
538 internal_error
(__FILE__
, __LINE__
, "Invalid top-level type %d in cursor resource", $1->type
);
541 | dialog
{ $$
= new_resource
(res_dlg
, $1, $1->memopt
, $1->lvc.language
); }
544 $$
= new_resource
(res_dlgex
, $1, $1->memopt
, $1->lvc.language
);
548 | dlginit
{ $$
= new_resource
(res_dlginit
, $1, $1->memopt
, $1->data
->lvc.language
); }
549 | font
{ $$
= new_resource
(res_fnt
, $1, $1->memopt
, $1->data
->lvc.language
); }
550 | fontdir
{ $$
= new_resource
(res_fntdir
, $1, $1->memopt
, $1->data
->lvc.language
); }
553 if
($1->type
== res_aniico
)
555 $$
= rsc
= new_resource
(res_aniico
, $1->u.ani
, $1->u.ani
->memopt
, $1->u.ani
->data
->lvc.language
);
557 else if
($1->type
== res_icog
)
560 $$
= rsc
= new_resource
(res_icog
, $1->u.icog
, $1->u.icog
->memopt
, $1->u.icog
->lvc.language
);
561 for
(ico
= $1->u.icog
->iconlist
; ico
; ico
= ico
->next
)
563 rsc
->prev
= new_resource
(res_ico
, ico
, $1->u.icog
->memopt
, $1->u.icog
->lvc.language
);
564 rsc
->prev
->next
= rsc
;
566 rsc
->name
= new_name_id
();
567 rsc
->name
->type
= name_ord
;
568 rsc
->name
->name.i_name
= ico
->id
;
572 internal_error
(__FILE__
, __LINE__
, "Invalid top-level type %d in icon resource", $1->type
);
575 | menu
{ $$
= new_resource
(res_men
, $1, $1->memopt
, $1->lvc.language
); }
578 $$
= new_resource
(res_menex
, $1, $1->memopt
, $1->lvc.language
);
582 | messagetable
{ $$
= new_resource
(res_msg
, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE
, dup_language
(currentlanguage
)); }
583 | rcdata
{ $$
= new_resource
(res_rdt
, $1, $1->memopt
, $1->data
->lvc.language
); }
584 | toolbar
{ $$
= new_resource
(res_toolbar
, $1, $1->memopt
, $1->lvc.language
); }
585 | userres
{ $$
= new_resource
(res_usr
, $1, $1->memopt
, $1->data
->lvc.language
); }
586 | versioninfo
{ $$
= new_resource
(res_ver
, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE
, $1->lvc.language
); }
590 filename: tFILENAME
{ $$
= make_filename
($1); }
591 | tIDENT
{ $$
= make_filename
($1); }
592 | tSTRING
{ $$
= make_filename
($1); }
595 /* ------------------------------ Bitmap ------------------------------ */
596 bitmap
: tBITMAP loadmemopts file_raw
{ $$
= new_bitmap
($3, $2); }
599 /* ------------------------------ Cursor ------------------------------ */
600 cursor
: tCURSOR loadmemopts file_raw
{
602 if
($3->size
> 4 && !memcmp
($3->data
, riff
, sizeof
(riff
)))
604 $$
->type
= res_anicur
;
605 $$
->u.ani
= new_ani_curico
(res_anicur
, $3, $2);
610 $$
->u.curg
= new_cursor_group
($3, $2);
615 /* ------------------------------ Icon ------------------------------ */
616 icon
: tICON loadmemopts file_raw
{
618 if
($3->size
> 4 && !memcmp
($3->data
, riff
, sizeof
(riff
)))
620 $$
->type
= res_aniico
;
621 $$
->u.ani
= new_ani_curico
(res_aniico
, $3, $2);
626 $$
->u.icog
= new_icon_group
($3, $2);
631 /* ------------------------------ Font ------------------------------ */
633 * The reading of raw_data for fonts is a Borland BRC
634 * extension. MS generates an error. However, it is
635 * most logical to support this, considering how wine
636 * enters things in CVS (ascii).
638 font
: tFONT loadmemopts file_raw
{ $$
= new_font
($3, $2); }
642 * The fontdir is a Borland BRC extension which only
643 * reads the data as 'raw_data' from the file.
644 * I don't know whether it is interpreted.
645 * The fontdir is generated if it was not present and
646 * fonts are defined in the source.
648 fontdir
: tFONTDIR loadmemopts file_raw
{ $$
= new_fontdir
($3, $2); }
651 /* ------------------------------ MessageTable ------------------------------ */
652 /* It might be interesting to implement the MS Message compiler here as well
653 * to get everything in one source. Might be a future project.
656 : tMESSAGETABLE loadmemopts file_raw
{
658 yywarning
("MESSAGETABLE not supported in 16-bit mode");
659 $$
= new_messagetable
($3, $2);
663 /* ------------------------------ RCData ------------------------------ */
664 rcdata
: tRCDATA loadmemopts file_raw
{ $$
= new_rcdata
($3, $2); }
667 /* ------------------------------ DLGINIT ------------------------------ */
668 dlginit
: tDLGINIT loadmemopts file_raw
{ $$
= new_dlginit
($3, $2); }
671 /* ------------------------------ UserType ------------------------------ */
672 userres
: usertype loadmemopts file_raw
{
673 #ifdef WORDS_BIGENDIAN
674 if
(pedantic
&& byteorder
!= WRC_BO_LITTLE
)
676 if
(pedantic
&& byteorder
== WRC_BO_BIG
)
678 yywarning
("Byteordering is not little-endian and type cannot be interpreted");
679 $$
= new_user
($1, $3, $2);
686 $$
->name.i_name
= $1;
691 $$
->name.s_name
= $1;
695 /* ------------------------------ Accelerator ------------------------------ */
697 : tACCELERATORS loadmemopts opt_lvc tBEGIN events tEND
{
698 $$
= new_accelerator
();
706 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE
;
709 yyerror("Accelerator table must have at least one entry");
710 $$
->events
= get_event_head
($5);
716 if
(!$$
->lvc.language
)
717 $$
->lvc.language
= dup_language
(currentlanguage
);
721 events
: /* Empty */ { $$
=NULL
; }
722 | events tSTRING
',' expr acc_opt
{ $$
=add_string_event
($2, $4, $5, $1); }
723 | events expr
',' expr acc_opt
{ $$
=add_event
($2, $4, $5, $1); }
727 * The empty rule generates a s/r conflict because of {bi,u}nary expr
728 * on - and +. It cannot be solved in any way because it is the same as
729 * the if/then/else problem (LALR(1) problem). The conflict is moved
730 * away by forcing it to be in the expression handling below.
732 acc_opt
: /* Empty */ { $$
= 0; }
733 |
',' accs
{ $$
= $2; }
736 accs
: acc
{ $$
= $1; }
737 | accs
',' acc
{ $$
= $1 |
$3; }
740 acc
: tNOINVERT
{ $$
= WRC_AF_NOINVERT
; }
741 | tSHIFT
{ $$
= WRC_AF_SHIFT
; }
742 | tCONTROL
{ $$
= WRC_AF_CONTROL
; }
743 | tALT
{ $$
= WRC_AF_ALT
; }
744 | tASCII
{ $$
= WRC_AF_ASCII
; }
745 | tVIRTKEY
{ $$
= WRC_AF_VIRTKEY
; }
748 /* ------------------------------ Dialog ------------------------------ */
749 /* FIXME: Support EXSTYLE in the dialog line itself */
750 dialog
: tDIALOG loadmemopts expr
',' expr
',' expr
',' expr dlg_attributes
758 $10->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
763 $10->controls
= get_control_head
($12);
767 $$
->style
->or_mask
= WS_POPUP
;
771 $$
->style
->or_mask |
= WS_CAPTION
;
773 $$
->style
->or_mask |
= DS_SETFONT
;
775 $$
->style
->or_mask
&= ~
($$
->style
->and_mask
);
776 $$
->style
->and_mask
= 0;
778 if
(!$$
->lvc.language
)
779 $$
->lvc.language
= dup_language
(currentlanguage
);
784 : /* Empty */ { $$
=new_dialog
(); }
785 | dlg_attributes tSTYLE style
{ $$
=dialog_style
($3,$1); }
786 | dlg_attributes tEXSTYLE style
{ $$
=dialog_exstyle
($3,$1); }
787 | dlg_attributes tCAPTION tSTRING
{ $$
=dialog_caption
($3,$1); }
788 | dlg_attributes opt_font
{ $$
=dialog_font
($2,$1); }
789 | dlg_attributes tCLASS nameid_s
{ $$
=dialog_class
($3,$1); }
790 | dlg_attributes tCPPCLASS nameid_s
{ $$
=dialog_class
($3,$1); }
791 | dlg_attributes tMENU nameid
{ $$
=dialog_menu
($3,$1); }
792 | dlg_attributes opt_language
{ $$
=dialog_language
($2,$1); }
793 | dlg_attributes opt_characts
{ $$
=dialog_characteristics
($2,$1); }
794 | dlg_attributes opt_version
{ $$
=dialog_version
($2,$1); }
797 ctrls
: /* Empty */ { $$
= NULL
; }
798 | ctrls tCONTROL gen_ctrl
{ $$
=ins_ctrl
(-1, 0, $3, $1); }
799 | ctrls tEDITTEXT ctrl_desc
{ $$
=ins_ctrl
(CT_EDIT
, 0, $3, $1); }
800 | ctrls tLISTBOX ctrl_desc
{ $$
=ins_ctrl
(CT_LISTBOX
, 0, $3, $1); }
801 | ctrls tCOMBOBOX ctrl_desc
{ $$
=ins_ctrl
(CT_COMBOBOX
, 0, $3, $1); }
802 | ctrls tSCROLLBAR ctrl_desc
{ $$
=ins_ctrl
(CT_SCROLLBAR
, 0, $3, $1); }
803 | ctrls tCHECKBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_CHECKBOX
, $3, $1); }
804 | ctrls tDEFPUSHBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $3, $1); }
805 | ctrls tGROUPBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_GROUPBOX
, $3, $1);}
806 | ctrls tPUSHBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_PUSHBUTTON
, $3, $1); }
807 /* | ctrls tPUSHBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
808 | ctrls tRADIOBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_RADIOBUTTON
, $3, $1); }
809 | ctrls tAUTO3STATE lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTO3STATE
, $3, $1); }
810 | ctrls tSTATE3 lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_3STATE
, $3, $1); }
811 | ctrls tAUTOCHECKBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTOCHECKBOX
, $3, $1); }
812 | ctrls tAUTORADIOBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTORADIOBUTTON
, $3, $1); }
813 | ctrls tLTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_LEFT
, $3, $1); }
814 | ctrls tCTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_CENTER
, $3, $1); }
815 | ctrls tRTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_RIGHT
, $3, $1); }
816 /* special treatment for icons, as the extent is optional */
817 | ctrls tICON nameid_s opt_comma expr
',' expr
',' expr iconinfo
{
822 $$
= ins_ctrl
(CT_STATIC
, SS_ICON
, $10, $1);
827 : tSTRING opt_comma expr
',' expr
',' expr
',' expr
',' expr optional_style
{
829 $$
->title
= new_name_id
();
830 $$
->title
->type
= name_str
;
831 $$
->title
->name.s_name
= $1;
846 : expr
',' expr
',' expr
',' expr
',' expr optional_style
{
861 iconinfo: /* Empty */
862 { $$
= new_control
(); }
864 |
',' expr
',' expr
{
869 |
',' expr
',' expr
',' style
{
876 |
',' expr
',' expr
',' style
',' style
{
883 $$
->gotexstyle
= TRUE
;
887 gen_ctrl: nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr
',' style
{
891 $$
->ctlclass
= convert_ctlclass
($5);
899 $$
->gotexstyle
= TRUE
;
901 | nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr
{
905 $$
->ctlclass
= convert_ctlclass
($5);
916 : tFONT expr
',' tSTRING
{ $$
= new_font_id
($2, $4, 0, 0); }
919 /* ------------------------------ style flags ------------------------------ */
920 optional_style
/* Abbused once to get optional ExStyle */
921 : /* Empty */ { $$
= NULL
; }
922 |
',' style
{ $$
= $2; }
926 : /* Empty */ { $$
= NULL
; }
927 |
',' style
{ $$
= new_style_pair
($2, 0); }
928 |
',' style
',' style
{ $$
= new_style_pair
($2, $4); }
932 : style
'|' style
{ $$
= new_style
($1->or_mask |
$3->or_mask
, $1->and_mask |
$3->and_mask
); free
($1); free
($3);}
933 |
'(' style
')' { $$
= $2; }
934 | any_num
{ $$
= new_style
($1, 0); }
935 | tNOT any_num
{ $$
= new_style
(0, $2); }
942 $$
->name.i_name
= $1;
947 $$
->name.s_name
= $1;
951 /* ------------------------------ DialogEx ------------------------------ */
952 dialogex: tDIALOGEX loadmemopts expr
',' expr
',' expr
',' expr helpid dlgex_attribs
953 tBEGIN exctrls tEND
{
955 yywarning
("DIALOGEX not supported in 16-bit mode");
962 $11->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
969 $11->helpid
= *($10);
970 $11->gothelpid
= TRUE
;
973 $11->controls
= get_control_head
($13);
976 assert
($$
->style
!= NULL
);
979 $$
->style
->or_mask
= WS_POPUP
;
983 $$
->style
->or_mask |
= WS_CAPTION
;
985 $$
->style
->or_mask |
= DS_SETFONT
;
987 $$
->style
->or_mask
&= ~
($$
->style
->and_mask
);
988 $$
->style
->and_mask
= 0;
990 if
(!$$
->lvc.language
)
991 $$
->lvc.language
= dup_language
(currentlanguage
);
996 : /* Empty */ { $$
=new_dialogex
(); }
997 | dlgex_attribs tSTYLE style
{ $$
=dialogex_style
($3,$1); }
998 | dlgex_attribs tEXSTYLE style
{ $$
=dialogex_exstyle
($3,$1); }
999 | dlgex_attribs tCAPTION tSTRING
{ $$
=dialogex_caption
($3,$1); }
1000 | dlgex_attribs opt_font
{ $$
=dialogex_font
($2,$1); }
1001 | dlgex_attribs opt_exfont
{ $$
=dialogex_font
($2,$1); }
1002 | dlgex_attribs tCLASS nameid_s
{ $$
=dialogex_class
($3,$1); }
1003 | dlgex_attribs tCPPCLASS nameid_s
{ $$
=dialogex_class
($3,$1); }
1004 | dlgex_attribs tMENU nameid
{ $$
=dialogex_menu
($3,$1); }
1005 | dlgex_attribs opt_language
{ $$
=dialogex_language
($2,$1); }
1006 | dlgex_attribs opt_characts
{ $$
=dialogex_characteristics
($2,$1); }
1007 | dlgex_attribs opt_version
{ $$
=dialogex_version
($2,$1); }
1010 exctrls
: /* Empty */ { $$
= NULL
; }
1011 | exctrls tCONTROL gen_exctrl
{ $$
=ins_ctrl
(-1, 0, $3, $1); }
1012 | exctrls tEDITTEXT exctrl_desc
{ $$
=ins_ctrl
(CT_EDIT
, 0, $3, $1); }
1013 | exctrls tLISTBOX exctrl_desc
{ $$
=ins_ctrl
(CT_LISTBOX
, 0, $3, $1); }
1014 | exctrls tCOMBOBOX exctrl_desc
{ $$
=ins_ctrl
(CT_COMBOBOX
, 0, $3, $1); }
1015 | exctrls tSCROLLBAR exctrl_desc
{ $$
=ins_ctrl
(CT_SCROLLBAR
, 0, $3, $1); }
1016 | exctrls tCHECKBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_CHECKBOX
, $3, $1); }
1017 | exctrls tDEFPUSHBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $3, $1); }
1018 | exctrls tGROUPBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_GROUPBOX
, $3, $1);}
1019 | exctrls tPUSHBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_PUSHBUTTON
, $3, $1); }
1020 /* | exctrls tPUSHBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
1021 | exctrls tRADIOBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_RADIOBUTTON
, $3, $1); }
1022 | exctrls tAUTO3STATE lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTO3STATE
, $3, $1); }
1023 | exctrls tSTATE3 lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_3STATE
, $3, $1); }
1024 | exctrls tAUTOCHECKBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTOCHECKBOX
, $3, $1); }
1025 | exctrls tAUTORADIOBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTORADIOBUTTON
, $3, $1); }
1026 | exctrls tLTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_LEFT
, $3, $1); }
1027 | exctrls tCTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_CENTER
, $3, $1); }
1028 | exctrls tRTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_RIGHT
, $3, $1); }
1029 /* special treatment for icons, as the extent is optional */
1030 | exctrls tICON nameid_s opt_comma expr
',' expr
',' expr iconinfo
{
1035 $$
= ins_ctrl
(CT_STATIC
, SS_ICON
, $10, $1);
1040 : nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
','
1041 expr
',' style helpid opt_data
{
1045 $$
->ctlclass
= convert_ctlclass
($5);
1047 $$
->gotstyle
= TRUE
;
1055 $$
->gotexstyle
= TRUE
;
1059 $$
->helpid
= *($18);
1060 $$
->gothelpid
= TRUE
;
1065 | nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr opt_data
{
1070 $$
->gotstyle
= TRUE
;
1071 $$
->ctlclass
= convert_ctlclass
($5);
1081 : tSTRING opt_comma expr
',' expr
',' expr
',' expr
',' expr optional_style_pair opt_data
{
1083 $$
->title
= new_name_id
();
1084 $$
->title
->type
= name_str
;
1085 $$
->title
->name.s_name
= $1;
1093 $$
->style
= $12->style
;
1094 $$
->gotstyle
= TRUE
;
1098 $$
->exstyle
= $12->exstyle
;
1099 $$
->gotexstyle
= TRUE
;
1109 : expr
',' expr
',' expr
',' expr
',' expr optional_style_pair opt_data
{
1118 $$
->style
= $10->style
;
1119 $$
->gotstyle
= TRUE
;
1123 $$
->exstyle
= $10->exstyle
;
1124 $$
->gotexstyle
= TRUE
;
1132 opt_data: /* Empty */ { $$
= NULL
; }
1133 | raw_data
{ $$
= $1; }
1136 helpid
: /* Empty */ { $$
= NULL
; }
1137 |
',' expr
{ $$
= new_int
($2); }
1141 : tFONT expr
',' tSTRING
',' expr
',' expr opt_expr
{ $$
= new_font_id
($2, $4, $6, $8); }
1145 * FIXME: This odd expression is here to nullify an extra token found
1146 * in some appstudio produced resources which appear to do nothing.
1148 opt_expr: /* Empty */ { $$
= NULL
; }
1149 |
',' expr
{ $$
= NULL
; }
1152 /* ------------------------------ Menu ------------------------------ */
1153 menu
: tMENU loadmemopts opt_lvc menu_body
{
1155 yyerror("Menu must contain items");
1163 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1164 $$
->items
= get_item_head
($4);
1170 if
(!$$
->lvc.language
)
1171 $$
->lvc.language
= dup_language
(currentlanguage
);
1176 : tBEGIN item_definitions tEND
{ $$
= $2; }
1180 : /* Empty */ {$$
= NULL
;}
1181 | item_definitions tMENUITEM tSTRING opt_comma expr item_options
{
1190 | item_definitions tMENUITEM tSEPARATOR
{
1196 | item_definitions tPOPUP tSTRING item_options menu_body
{
1197 $$
= new_menu_item
();
1201 $$
->popup
= get_item_head
($5);
1206 /* NOTE: item_options is right recursive because it would introduce
1207 * a shift/reduce conflict on ',' in itemex_options due to the
1208 * empty rule here. The parser is now forced to look beyond the ','
1209 * before reducing (force shift).
1210 * Right recursion here is not a problem because we cannot expect
1211 * more than 7 parserstack places to be occupied while parsing this
1212 * (who would want to specify a MF_x flag twice?).
1215 : /* Empty */ { $$
= 0; }
1216 |
',' tCHECKED item_options
{ $$
= $3 | MF_CHECKED
; }
1217 |
',' tGRAYED item_options
{ $$
= $3 | MF_GRAYED
; }
1218 |
',' tHELP item_options
{ $$
= $3 | MF_HELP
; }
1219 |
',' tINACTIVE item_options
{ $$
= $3 | MF_DISABLED
; }
1220 |
',' tMENUBARBREAK item_options
{ $$
= $3 | MF_MENUBARBREAK
; }
1221 |
',' tMENUBREAK item_options
{ $$
= $3 | MF_MENUBREAK
; }
1224 /* ------------------------------ MenuEx ------------------------------ */
1225 menuex
: tMENUEX loadmemopts opt_lvc menuex_body
{
1227 yywarning
("MENUEX not supported in 16-bit mode");
1229 yyerror("MenuEx must contain items");
1237 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1238 $$
->items
= get_itemex_head
($4);
1244 if
(!$$
->lvc.language
)
1245 $$
->lvc.language
= dup_language
(currentlanguage
);
1250 : tBEGIN itemex_definitions tEND
{ $$
= $2; }
1254 : /* Empty */ {$$
= NULL
; }
1255 | itemex_definitions tMENUITEM tSTRING itemex_options
{
1256 $$
= new_menuex_item
();
1262 $$
->type
= $4->type
;
1263 $$
->state
= $4->state
;
1264 $$
->helpid
= $4->helpid
;
1265 $$
->gotid
= $4->gotid
;
1266 $$
->gottype
= $4->gottype
;
1267 $$
->gotstate
= $4->gotstate
;
1268 $$
->gothelpid
= $4->gothelpid
;
1271 | itemex_definitions tMENUITEM tSEPARATOR
{
1272 $$
= new_menuex_item
();
1277 | itemex_definitions tPOPUP tSTRING itemex_p_options menuex_body
{
1278 $$
= new_menuex_item
();
1282 $$
->popup
= get_itemex_head
($5);
1285 $$
->type
= $4->type
;
1286 $$
->state
= $4->state
;
1287 $$
->helpid
= $4->helpid
;
1288 $$
->gotid
= $4->gotid
;
1289 $$
->gottype
= $4->gottype
;
1290 $$
->gotstate
= $4->gotstate
;
1291 $$
->gothelpid
= $4->gothelpid
;
1297 : /* Empty */ { $$
= new_itemex_opt
(0, 0, 0, 0); }
1299 $$
= new_itemex_opt
($2, 0, 0, 0);
1302 |
',' e_expr
',' e_expr item_options
{
1303 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $5, 0);
1306 $$
->gotstate
= TRUE
;
1310 |
',' e_expr
',' e_expr
',' expr
{
1311 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6, 0);
1314 $$
->gotstate
= TRUE
;
1321 : /* Empty */ { $$
= new_itemex_opt
(0, 0, 0, 0); }
1323 $$
= new_itemex_opt
($2, 0, 0, 0);
1326 |
',' e_expr
',' expr
{
1327 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4, 0, 0);
1332 |
',' e_expr
',' e_expr
',' expr
{
1333 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6, 0);
1338 $$
->gotstate
= TRUE
;
1340 |
',' e_expr
',' e_expr
',' e_expr
',' expr
{
1341 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6 ?
*($6) : 0, $8);
1347 $$
->gotstate
= TRUE
;
1348 $$
->gothelpid
= TRUE
;
1352 /* ------------------------------ StringTable ------------------------------ */
1353 /* Stringtables are parsed differently than other resources because their
1354 * layout is substantially different from other resources.
1355 * The table is parsed through a _global_ variable 'tagstt' which holds the
1356 * current stringtable descriptor (stringtable_t *) and 'sttres' that holds a
1357 * list of stringtables of different languages.
1360 : stt_head tBEGIN strings tEND
{
1363 yyerror("Stringtable must have at least one entry");
1368 /* Check if we added to a language table or created
1371 for
(stt
= sttres
; stt
; stt
= stt
->next
)
1378 /* It is a new one */
1381 sttres
->prev
= tagstt
;
1382 tagstt
->next
= sttres
;
1388 /* Else were done */
1392 free
(tagstt_memopt
);
1393 tagstt_memopt
= NULL
;
1400 /* This is to get the language of the currently parsed stringtable */
1401 stt_head: tSTRINGTABLE loadmemopts opt_lvc
{
1402 if
((tagstt
= find_stringtable
($3)) == NULL
)
1403 tagstt
= new_stringtable
($3);
1405 tagstt_version
= $3->version
;
1406 tagstt_characts
= $3->characts
;
1412 strings
: /* Empty */ { $$
= NULL
; }
1413 | strings expr opt_comma tSTRING
{
1415 assert
(tagstt
!= NULL
);
1416 if
($2 > 65535 ||
$2 < -32768)
1417 yyerror("Stringtable entry's ID out of range (%d)", $2);
1418 /* Search for the ID */
1419 for
(i
= 0; i
< tagstt
->nentries
; i
++)
1421 if
(tagstt
->entries
[i
].id
== $2)
1422 yyerror("Stringtable ID %d already in use", $2);
1424 /* If we get here, then we have a new unique entry */
1426 tagstt
->entries
= xrealloc
(tagstt
->entries
, sizeof
(tagstt
->entries
[0]) * tagstt
->nentries
);
1427 tagstt
->entries
[tagstt
->nentries
-1].id
= $2;
1428 tagstt
->entries
[tagstt
->nentries
-1].str
= $4;
1430 tagstt
->entries
[tagstt
->nentries
-1].memopt
= *tagstt_memopt
;
1432 tagstt
->entries
[tagstt
->nentries
-1].memopt
= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE
;
1433 tagstt
->entries
[tagstt
->nentries
-1].version
= tagstt_version
;
1434 tagstt
->entries
[tagstt
->nentries
-1].characts
= tagstt_characts
;
1436 if
(!win32
&& $4->size
> 254)
1437 yyerror("Stringtable entry more than 254 characters");
1438 if
(win32
&& $4->size
> 65534) /* Hmm..., does this happen? */
1439 yyerror("Stringtable entry more than 65534 characters (probably something else that went wrong)");
1444 opt_comma
/* There seem to be two ways to specify a stringtable... */
1449 /* ------------------------------ VersionInfo ------------------------------ */
1451 : tVERSIONINFO loadmemopts fix_version tBEGIN ver_blocks tEND
{
1459 $$
->memopt
= WRC_MO_MOVEABLE |
(win32 ? WRC_MO_PURE
: 0);
1460 $$
->blocks
= get_ver_block_head
($5);
1461 /* Set language; there is no version or characteristics */
1462 $$
->lvc.language
= dup_language
(currentlanguage
);
1467 : /* Empty */ { $$
= new_versioninfo
(); }
1468 | fix_version tFILEVERSION expr
',' expr
',' expr
',' expr
{
1470 yyerror("FILEVERSION already defined");
1472 $$
->filever_maj1
= $3;
1473 $$
->filever_maj2
= $5;
1474 $$
->filever_min1
= $7;
1475 $$
->filever_min2
= $9;
1478 | fix_version tPRODUCTVERSION expr
',' expr
',' expr
',' expr
{
1480 yyerror("PRODUCTVERSION already defined");
1482 $$
->prodver_maj1
= $3;
1483 $$
->prodver_maj2
= $5;
1484 $$
->prodver_min1
= $7;
1485 $$
->prodver_min2
= $9;
1488 | fix_version tFILEFLAGS expr
{
1490 yyerror("FILEFLAGS already defined");
1495 | fix_version tFILEFLAGSMASK expr
{
1497 yyerror("FILEFLAGSMASK already defined");
1499 $$
->fileflagsmask
= $3;
1502 | fix_version tFILEOS expr
{
1504 yyerror("FILEOS already defined");
1509 | fix_version tFILETYPE expr
{
1511 yyerror("FILETYPE already defined");
1516 | fix_version tFILESUBTYPE expr
{
1518 yyerror("FILESUBTYPE already defined");
1520 $$
->filesubtype
= $3;
1526 : /* Empty */ { $$
= NULL
; }
1527 | ver_blocks ver_block
{
1536 : tBLOCK tSTRING tBEGIN ver_values tEND
{
1537 $$
= new_ver_block
();
1539 $$
->values
= get_ver_value_head
($4);
1544 : /* Empty */ { $$
= NULL
; }
1545 | ver_values ver_value
{
1555 $$
= new_ver_value
();
1556 $$
->type
= val_block
;
1557 $$
->value.block
= $1;
1559 | tVALUE tSTRING
',' tSTRING
{
1560 $$
= new_ver_value
();
1565 | tVALUE tSTRING
',' ver_words
{
1566 $$
= new_ver_value
();
1567 $$
->type
= val_words
;
1569 $$
->value.words
= $4;
1574 : expr
{ $$
= new_ver_words
($1); }
1575 | ver_words
',' expr
{ $$
= add_ver_words
($1, $3); }
1578 /* ------------------------------ Toolbar ------------------------------ */
1579 toolbar: tTOOLBAR loadmemopts expr
',' expr opt_lvc tBEGIN toolbar_items tEND
{
1581 toolbar_item_t
*items
= get_tlbr_buttons_head
($8, &nitems
);
1582 $$
= new_toolbar
($3, $5, items
, nitems
);
1590 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE
;
1597 if
(!$$
->lvc.language
)
1599 $$
->lvc.language
= dup_language
(currentlanguage
);
1605 : /* Empty */ { $$
= NULL
; }
1606 | toolbar_items tBUTTON expr
{
1607 toolbar_item_t
*idrec
= new_toolbar_item
();
1609 $$
= ins_tlbr_button
($1, idrec
);
1611 | toolbar_items tSEPARATOR
{
1612 toolbar_item_t
*idrec
= new_toolbar_item
();
1614 $$
= ins_tlbr_button
($1, idrec
);
1618 /* ------------------------------ Memory options ------------------------------ */
1620 : /* Empty */ { $$
= NULL
; }
1621 | loadmemopts lamo
{
1631 | loadmemopts lama
{
1640 *$2 &= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE
;
1646 lamo
: tPRELOAD
{ $$
= new_int
(WRC_MO_PRELOAD
); }
1647 | tMOVEABLE
{ $$
= new_int
(WRC_MO_MOVEABLE
); }
1648 | tDISCARDABLE
{ $$
= new_int
(WRC_MO_DISCARDABLE
); }
1649 | tPURE
{ $$
= new_int
(WRC_MO_PURE
); }
1652 lama
: tLOADONCALL
{ $$
= new_int
(~WRC_MO_PRELOAD
); }
1653 | tFIXED
{ $$
= new_int
(~WRC_MO_MOVEABLE
); }
1654 | tIMPURE
{ $$
= new_int
(~WRC_MO_PURE
); }
1657 /* ------------------------------ Win32 options ------------------------------ */
1658 opt_lvc
: /* Empty */ { $$
= new_lvc
(); }
1659 | opt_lvc opt_language
{
1661 yywarning
("LANGUAGE not supported in 16-bit mode");
1663 yyerror("Language already defined");
1667 | opt_lvc opt_characts
{
1669 yywarning
("CHARACTERISTICS not supported in 16-bit mode");
1671 yyerror("Characteristics already defined");
1675 | opt_lvc opt_version
{
1677 yywarning
("VERSION not supported in 16-bit mode");
1679 yyerror("Version already defined");
1686 * This here is another s/r conflict on {bi,u}nary + and -.
1687 * It is due to the look-ahead which must determine when the
1688 * rule opt_language ends. It could be solved with adding a
1689 * tNL at the end, but that seems unreasonable to do.
1690 * The conflict is now moved to the expression handling below.
1693 : tLANGUAGE expr
',' expr
{ $$
= new_language
($2, $4); }
1697 : tCHARACTERISTICS expr
{ $$
= new_characts
($2); }
1701 : tVERSION expr
{ $$
= new_version
($2); }
1704 /* ------------------------------ Raw data handling ------------------------------ */
1705 raw_data: opt_lvc tBEGIN raw_elements tEND
{
1712 if
(!$3->lvc.language
)
1713 $3->lvc.language
= dup_language
(currentlanguage
);
1720 : tRAWDATA
{ $$
= $1; }
1721 | tNUMBER
{ $$
= int2raw_data
($1); }
1722 | tLNUMBER
{ $$
= long2raw_data
($1); }
1723 | tSTRING
{ $$
= str2raw_data
($1); }
1724 | raw_elements opt_comma tRAWDATA
{ $$
= merge_raw_data
($1, $3); free
($3->data
); free
($3); }
1725 | raw_elements opt_comma tNUMBER
{ $$
= merge_raw_data_int
($1, $3); }
1726 | raw_elements opt_comma tLNUMBER
{ $$
= merge_raw_data_long
($1, $3); }
1727 | raw_elements opt_comma tSTRING
{ $$
= merge_raw_data_str
($1, $3); }
1730 /* File data or raw data */
1731 file_raw: filename
{
1733 $$
->lvc.language
= dup_language
(currentlanguage
);
1735 | raw_data
{ $$
= $1; }
1738 /* ------------------------------ Win32 expressions ------------------------------ */
1739 /* All win16 numbers are also handled here. This is inconsistent with MS'
1740 * resource compiler, but what the heck, its just handy to have.
1742 e_expr
: /* Empty */ { $$
= 0; }
1743 | expr
{ $$
= new_int
($1); }
1746 /* This rule moves ALL s/r conflicts on {bi,u}nary - and + to here */
1747 expr
: xpr
{ $$
= ($1); }
1750 xpr
: xpr
'+' xpr
{ $$
= ($1) + ($3); }
1751 | xpr
'-' xpr
{ $$
= ($1) - ($3); }
1752 | xpr
'|' xpr
{ $$
= ($1) |
($3); }
1753 | xpr
'&' xpr
{ $$
= ($1) & ($3); }
1754 | xpr
'*' xpr
{ $$
= ($1) * ($3); }
1755 | xpr
'/' xpr
{ $$
= ($1) / ($3); }
1756 | xpr
'^' xpr
{ $$
= ($1) ^
($3); }
1757 |
'~' xpr
{ $$
= ~
($2); }
1758 |
'-' xpr %prec pUPM
{ $$
= -($2); }
1759 |
'+' xpr %prec pUPM
{ $$
= $2; }
1760 |
'(' xpr
')' { $$
= $2; }
1761 | any_num
{ $$
= $1; }
1762 | tNOT any_num
{ $$
= ~
($2); }
1765 any_num
: tNUMBER
{ $$
= $1; }
1766 | tLNUMBER
{ $$
= $1; }
1770 /* Dialog specific functions */
1771 static dialog_t
*dialog_style
(style_t
* st
, dialog_t
*dlg
)
1773 assert
(dlg
!= NULL
);
1774 if
(dlg
->style
== NULL
)
1776 dlg
->style
= new_style
(0,0);
1781 yywarning
("Style already defined, or-ing together");
1785 dlg
->style
->or_mask
= 0;
1786 dlg
->style
->and_mask
= 0;
1788 dlg
->style
->or_mask |
= st
->or_mask
;
1789 dlg
->style
->and_mask |
= st
->and_mask
;
1790 dlg
->gotstyle
= TRUE
;
1795 static dialog_t
*dialog_exstyle
(style_t
*st
, dialog_t
*dlg
)
1797 assert
(dlg
!= NULL
);
1798 if
(dlg
->exstyle
== NULL
)
1800 dlg
->exstyle
= new_style
(0,0);
1805 yywarning
("ExStyle already defined, or-ing together");
1809 dlg
->exstyle
->or_mask
= 0;
1810 dlg
->exstyle
->and_mask
= 0;
1812 dlg
->exstyle
->or_mask |
= st
->or_mask
;
1813 dlg
->exstyle
->and_mask |
= st
->and_mask
;
1814 dlg
->gotexstyle
= TRUE
;
1819 static dialog_t
*dialog_caption
(string_t
*s
, dialog_t
*dlg
)
1821 assert
(dlg
!= NULL
);
1823 yyerror("Caption already defined");
1828 static dialog_t
*dialog_font
(font_id_t
*f
, dialog_t
*dlg
)
1830 assert
(dlg
!= NULL
);
1832 yyerror("Font already defined");
1837 static dialog_t
*dialog_class
(name_id_t
*n
, dialog_t
*dlg
)
1839 assert
(dlg
!= NULL
);
1841 yyerror("Class already defined");
1846 static dialog_t
*dialog_menu
(name_id_t
*m
, dialog_t
*dlg
)
1848 assert
(dlg
!= NULL
);
1850 yyerror("Menu already defined");
1855 static dialog_t
*dialog_language
(language_t
*l
, dialog_t
*dlg
)
1857 assert
(dlg
!= NULL
);
1858 if
(dlg
->lvc.language
)
1859 yyerror("Language already defined");
1860 dlg
->lvc.language
= l
;
1864 static dialog_t
*dialog_characteristics
(characts_t
*c
, dialog_t
*dlg
)
1866 assert
(dlg
!= NULL
);
1867 if
(dlg
->lvc.characts
)
1868 yyerror("Characteristics already defined");
1869 dlg
->lvc.characts
= c
;
1873 static dialog_t
*dialog_version
(version_t
*v
, dialog_t
*dlg
)
1875 assert
(dlg
!= NULL
);
1876 if
(dlg
->lvc.version
)
1877 yyerror("Version already defined");
1878 dlg
->lvc.version
= v
;
1882 /* Controls specific functions */
1883 static control_t
*ins_ctrl
(int type
, int special_style
, control_t
*ctrl
, control_t
*prev
)
1885 /* Hm... this seems to be jammed in at all time... */
1886 int defaultstyle
= WS_CHILD | WS_VISIBLE
;
1888 assert
(ctrl
!= NULL
);
1896 ctrl
->ctlclass
= new_name_id
();
1897 ctrl
->ctlclass
->type
= name_ord
;
1898 ctrl
->ctlclass
->name.i_name
= type
;
1904 if
(special_style
!= BS_GROUPBOX
&& special_style
!= BS_RADIOBUTTON
)
1905 defaultstyle |
= WS_TABSTOP
;
1908 defaultstyle |
= WS_TABSTOP | WS_BORDER
;
1911 defaultstyle |
= LBS_NOTIFY | WS_BORDER
;
1914 defaultstyle |
= CBS_SIMPLE
;
1917 if
(special_style
== SS_CENTER || special_style
== SS_LEFT || special_style
== SS_RIGHT
)
1918 defaultstyle |
= WS_GROUP
;
1922 if
(!ctrl
->gotstyle
) /* Handle default style setting */
1927 defaultstyle |
= ES_LEFT
;
1930 defaultstyle |
= LBS_NOTIFY
;
1933 defaultstyle |
= CBS_SIMPLE | WS_TABSTOP
;
1936 defaultstyle |
= SBS_HORZ
;
1939 switch
(special_style
)
1942 case BS_DEFPUSHBUTTON
:
1945 /* case BS_PUSHBOX: */
1946 case BS_AUTORADIOBUTTON
:
1949 case BS_AUTOCHECKBOX
:
1950 defaultstyle |
= WS_TABSTOP
;
1953 yywarning
("Unknown default button control-style 0x%08x", special_style
);
1954 case BS_RADIOBUTTON
:
1960 switch
(special_style
)
1965 defaultstyle |
= WS_GROUP
;
1967 case SS_ICON
: /* Special case */
1970 yywarning
("Unknown default static control-style 0x%08x", special_style
);
1974 case
-1: /* Generic control */
1978 yyerror("Internal error (report this): Got weird control type 0x%08x", type
);
1982 /* The SS_ICON flag is always forced in for icon controls */
1983 if
(type
== CT_STATIC
&& special_style
== SS_ICON
)
1984 defaultstyle |
= SS_ICON
;
1986 if
(!ctrl
->gotstyle
)
1987 ctrl
->style
= new_style
(0,0);
1989 /* combine all styles */
1990 ctrl
->style
->or_mask
= ctrl
->style
->or_mask | defaultstyle | special_style
;
1991 ctrl
->gotstyle
= TRUE
;
1993 /* combine with NOT mask */
1996 ctrl
->style
->or_mask
&= ~
(ctrl
->style
->and_mask
);
1997 ctrl
->style
->and_mask
= 0;
1999 if
(ctrl
->gotexstyle
)
2001 ctrl
->exstyle
->or_mask
&= ~
(ctrl
->exstyle
->and_mask
);
2002 ctrl
->exstyle
->and_mask
= 0;
2007 static name_id_t
*convert_ctlclass
(name_id_t
*cls
)
2012 if
(cls
->type
== name_ord
)
2014 assert
(cls
->type
== name_str
);
2015 if
(cls
->type
== str_unicode
)
2017 yyerror("Don't yet support unicode class comparison");
2020 cc
= cls
->name.s_name
->str.cstr
;
2022 if
(!strcasecmp
("BUTTON", cc
))
2024 else if
(!strcasecmp
("COMBOBOX", cc
))
2025 iclass
= CT_COMBOBOX
;
2026 else if
(!strcasecmp
("LISTBOX", cc
))
2027 iclass
= CT_LISTBOX
;
2028 else if
(!strcasecmp
("EDIT", cc
))
2030 else if
(!strcasecmp
("STATIC", cc
))
2032 else if
(!strcasecmp
("SCROLLBAR", cc
))
2033 iclass
= CT_SCROLLBAR
;
2035 return cls
; /* No default, return user controlclass */
2037 free
(cls
->name.s_name
->str.cstr
);
2038 free
(cls
->name.s_name
);
2039 cls
->type
= name_ord
;
2040 cls
->name.i_name
= iclass
;
2044 /* DialogEx specific functions */
2045 static dialogex_t
*dialogex_style
(style_t
* st
, dialogex_t
*dlg
)
2047 assert
(dlg
!= NULL
);
2048 if
(dlg
->style
== NULL
)
2050 dlg
->style
= new_style
(0,0);
2055 yywarning
("Style already defined, or-ing together");
2059 dlg
->style
->or_mask
= 0;
2060 dlg
->style
->and_mask
= 0;
2062 dlg
->style
->or_mask |
= st
->or_mask
;
2063 dlg
->style
->and_mask |
= st
->and_mask
;
2064 dlg
->gotstyle
= TRUE
;
2069 static dialogex_t
*dialogex_exstyle
(style_t
* st
, dialogex_t
*dlg
)
2071 assert
(dlg
!= NULL
);
2072 if
(dlg
->exstyle
== NULL
)
2074 dlg
->exstyle
= new_style
(0,0);
2079 yywarning
("ExStyle already defined, or-ing together");
2083 dlg
->exstyle
->or_mask
= 0;
2084 dlg
->exstyle
->and_mask
= 0;
2086 dlg
->exstyle
->or_mask |
= st
->or_mask
;
2087 dlg
->exstyle
->and_mask |
= st
->and_mask
;
2088 dlg
->gotexstyle
= TRUE
;
2093 static dialogex_t
*dialogex_caption
(string_t
*s
, dialogex_t
*dlg
)
2095 assert
(dlg
!= NULL
);
2097 yyerror("Caption already defined");
2102 static dialogex_t
*dialogex_font
(font_id_t
*f
, dialogex_t
*dlg
)
2104 assert
(dlg
!= NULL
);
2106 yyerror("Font already defined");
2111 static dialogex_t
*dialogex_class
(name_id_t
*n
, dialogex_t
*dlg
)
2113 assert
(dlg
!= NULL
);
2115 yyerror("Class already defined");
2120 static dialogex_t
*dialogex_menu
(name_id_t
*m
, dialogex_t
*dlg
)
2122 assert
(dlg
!= NULL
);
2124 yyerror("Menu already defined");
2129 static dialogex_t
*dialogex_language
(language_t
*l
, dialogex_t
*dlg
)
2131 assert
(dlg
!= NULL
);
2132 if
(dlg
->lvc.language
)
2133 yyerror("Language already defined");
2134 dlg
->lvc.language
= l
;
2138 static dialogex_t
*dialogex_characteristics
(characts_t
*c
, dialogex_t
*dlg
)
2140 assert
(dlg
!= NULL
);
2141 if
(dlg
->lvc.characts
)
2142 yyerror("Characteristics already defined");
2143 dlg
->lvc.characts
= c
;
2147 static dialogex_t
*dialogex_version
(version_t
*v
, dialogex_t
*dlg
)
2149 assert
(dlg
!= NULL
);
2150 if
(dlg
->lvc.version
)
2151 yyerror("Version already defined");
2152 dlg
->lvc.version
= v
;
2156 /* Accelerator specific functions */
2157 static event_t
*add_event
(int key
, int id
, int flags
, event_t
*prev
)
2159 event_t
*ev
= new_event
();
2161 if
((flags
& (WRC_AF_VIRTKEY | WRC_AF_ASCII
)) == (WRC_AF_VIRTKEY | WRC_AF_ASCII
))
2162 yyerror("Cannot use both ASCII and VIRTKEY");
2166 ev
->flags
= flags
& ~WRC_AF_ASCII
;
2173 static event_t
*add_string_event
(string_t
*key
, int id
, int flags
, event_t
*prev
)
2176 event_t
*ev
= new_event
();
2178 if
(key
->type
!= str_char
)
2179 yyerror("Key code must be an ascii string");
2181 if
((flags
& WRC_AF_VIRTKEY
) && (!isupper
(key
->str.cstr
[0] & 0xff) && !isdigit
(key
->str.cstr
[0] & 0xff)))
2182 yyerror("VIRTKEY code is not equal to ascii value");
2184 if
(key
->str.cstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
2186 yyerror("Cannot use both '^' and CONTROL modifier");
2188 else if
(key
->str.cstr
[0] == '^')
2190 keycode
= toupper
(key
->str.cstr
[1]) - '@';
2192 yyerror("Control-code out of range");
2195 keycode
= key
->str.cstr
[0];
2198 ev
->flags
= flags
& ~WRC_AF_ASCII
;
2205 /* MenuEx specific functions */
2206 static itemex_opt_t
*new_itemex_opt
(int id
, int type
, int state
, int helpid
)
2208 itemex_opt_t
*opt
= (itemex_opt_t
*)xmalloc
(sizeof
(itemex_opt_t
));
2212 opt
->helpid
= helpid
;
2216 /* Raw data functions */
2217 static raw_data_t
*load_file
(string_t
*name
)
2221 if
(name
->type
!= str_char
)
2222 yyerror("Filename must be ASCII string");
2224 fp
= open_include
(name
->str.cstr
, 1, NULL
);
2226 yyerror("Cannot open file %s", name
->str.cstr
);
2227 rd
= new_raw_data
();
2228 fseek
(fp
, 0, SEEK_END
);
2229 rd
->size
= ftell
(fp
);
2230 fseek
(fp
, 0, SEEK_SET
);
2231 rd
->data
= (char *)xmalloc
(rd
->size
);
2232 fread
(rd
->data
, rd
->size
, 1, fp
);
2237 static raw_data_t
*int2raw_data
(int i
)
2241 if
((int)((short)i
) != i
)
2242 yywarning
("Integer constant out of 16bit range (%d), truncated to %d\n", i
, (short)i
);
2244 rd
= new_raw_data
();
2245 rd
->size
= sizeof
(short);
2246 rd
->data
= (char *)xmalloc
(rd
->size
);
2249 #ifndef WORDS_BIGENDIAN
2254 *(WORD
*)(rd
->data
) = BYTESWAP_WORD
((WORD
)i
);
2257 *(WORD
*)(rd
->data
) = (WORD
)i
;
2263 static raw_data_t
*long2raw_data
(int i
)
2266 rd
= new_raw_data
();
2267 rd
->size
= sizeof
(int);
2268 rd
->data
= (char *)xmalloc
(rd
->size
);
2271 #ifndef WORDS_BIGENDIAN
2276 *(DWORD
*)(rd
->data
) = BYTESWAP_DWORD
((DWORD
)i
);
2279 *(DWORD
*)(rd
->data
) = (DWORD
)i
;
2285 static raw_data_t
*str2raw_data
(string_t
*str
)
2288 rd
= new_raw_data
();
2289 rd
->size
= str
->size
* (str
->type
== str_char ?
1 : 2);
2290 rd
->data
= (char *)xmalloc
(rd
->size
);
2291 if
(str
->type
== str_char
)
2292 memcpy
(rd
->data
, str
->str.cstr
, rd
->size
);
2293 else if
(str
->type
== str_unicode
)
2298 #ifndef WORDS_BIGENDIAN
2303 for
(i
= 0; i
< str
->size
; i
++)
2304 *(WORD
*)&(rd
->data
[2*i
]) = BYTESWAP_WORD
((WORD
)str
->str.wstr
[i
]);
2307 for
(i
= 0; i
< str
->size
; i
++)
2308 *(WORD
*)&(rd
->data
[2*i
]) = (WORD
)str
->str.wstr
[i
];
2313 internal_error
(__FILE__
, __LINE__
, "Invalid stringtype");
2317 static raw_data_t
*merge_raw_data
(raw_data_t
*r1
, raw_data_t
*r2
)
2319 r1
->data
= xrealloc
(r1
->data
, r1
->size
+ r2
->size
);
2320 memcpy
(r1
->data
+ r1
->size
, r2
->data
, r2
->size
);
2321 r1
->size
+= r2
->size
;
2325 static raw_data_t
*merge_raw_data_int
(raw_data_t
*r1
, int i
)
2327 raw_data_t
*t
= int2raw_data
(i
);
2328 merge_raw_data
(r1
, t
);
2334 static raw_data_t
*merge_raw_data_long
(raw_data_t
*r1
, int i
)
2336 raw_data_t
*t
= long2raw_data
(i
);
2337 merge_raw_data
(r1
, t
);
2343 static raw_data_t
*merge_raw_data_str
(raw_data_t
*r1
, string_t
*str
)
2345 raw_data_t
*t
= str2raw_data
(str
);
2346 merge_raw_data
(r1
, t
);
2352 /* Function the go back in a list to get the head */
2353 static menu_item_t
*get_item_head
(menu_item_t
*p
)
2362 static menuex_item_t
*get_itemex_head
(menuex_item_t
*p
)
2371 static resource_t
*get_resource_head
(resource_t
*p
)
2380 static ver_block_t
*get_ver_block_head
(ver_block_t
*p
)
2389 static ver_value_t
*get_ver_value_head
(ver_value_t
*p
)
2398 static control_t
*get_control_head
(control_t
*p
)
2407 static event_t
*get_event_head
(event_t
*p
)
2416 /* Find a stringtable with given language */
2417 static stringtable_t
*find_stringtable
(lvc_t
*lvc
)
2421 assert
(lvc
!= NULL
);
2424 lvc
->language
= dup_language
(currentlanguage
);
2426 for
(stt
= sttres
; stt
; stt
= stt
->next
)
2428 if
(stt
->lvc.language
->id
== lvc
->language
->id
2429 && stt
->lvc.language
->id
== lvc
->language
->id
)
2431 /* Found a table with the same language */
2432 /* The version and characteristics are now handled
2433 * in the generation of the individual stringtables.
2434 * This enables localized analysis.
2435 if((stt->lvc.version && lvc->version && *(stt->lvc.version) != *(lvc->version))
2436 || (!stt->lvc.version && lvc->version)
2437 || (stt->lvc.version && !lvc->version))
2438 yywarning("Stringtable's versions are not the same, using first definition");
2440 if((stt->lvc.characts && lvc->characts && *(stt->lvc.characts) != *(lvc->characts))
2441 || (!stt->lvc.characts && lvc->characts)
2442 || (stt->lvc.characts && !lvc->characts))
2443 yywarning("Stringtable's characteristics are not the same, using first definition");
2451 /* qsort sorting function for string table entries */
2452 #define STE(p) ((stt_entry_t *)(p))
2453 static int sort_stt_entry
(const void *e1
, const void *e2
)
2455 return STE
(e1
)->id
- STE
(e2
)->id
;
2459 static resource_t
*build_stt_resources
(stringtable_t
*stthead
)
2462 stringtable_t
*newstt
;
2464 resource_t
*rsclist
= NULL
;
2465 resource_t
*rsctail
= NULL
;
2470 characts_t
*characts
;
2476 /* For all languages defined */
2477 for
(stt
= stthead
; stt
; stt
= stt
->next
)
2479 assert
(stt
->nentries
> 0);
2481 /* Sort the entries */
2482 if
(stt
->nentries
> 1)
2483 qsort
(stt
->entries
, stt
->nentries
, sizeof
(stt
->entries
[0]), sort_stt_entry
);
2485 for
(i
= 0; i
< stt
->nentries
; )
2487 newstt
= new_stringtable
(&stt
->lvc
);
2488 newstt
->entries
= (stt_entry_t
*)xmalloc
(16 * sizeof
(stt_entry_t
));
2489 newstt
->nentries
= 16;
2490 newstt
->idbase
= stt
->entries
[i
].id
& ~
0xf;
2491 for
(j
= 0; j
< 16 && i
< stt
->nentries
; j
++)
2493 if
(stt
->entries
[i
].id
- newstt
->idbase
== j
)
2495 newstt
->entries
[j
] = stt
->entries
[i
];
2503 /* Check individual memory options and get
2504 * the first characteristics/version
2506 for
(j
= 0; j
< 16; j
++)
2508 if
(!newstt
->entries
[j
].str
)
2510 andsum
&= newstt
->entries
[j
].memopt
;
2511 orsum |
= newstt
->entries
[j
].memopt
;
2513 characts
= newstt
->entries
[j
].characts
;
2515 version
= newstt
->entries
[j
].version
;
2519 warning
("Stringtable's memory options are not equal (idbase: %d)", newstt
->idbase
);
2521 /* Check version and characteristics */
2522 for
(j
= 0; j
< 16; j
++)
2525 && newstt
->entries
[j
].characts
2526 && *newstt
->entries
[j
].characts
!= *characts
)
2527 warning
("Stringtable's characteristics are not the same (idbase: %d)", newstt
->idbase
);
2529 && newstt
->entries
[j
].version
2530 && *newstt
->entries
[j
].version
!= *version
)
2531 warning
("Stringtable's versions are not the same (idbase: %d)", newstt
->idbase
);
2533 rsc
= new_resource
(res_stt
, newstt
, newstt
->memopt
, newstt
->lvc.language
);
2534 rsc
->name
= new_name_id
();
2535 rsc
->name
->type
= name_ord
;
2536 rsc
->name
->name.i_name
= (newstt
->idbase
>> 4) + 1;
2537 rsc
->memopt
= andsum
; /* Set to least common denominator */
2538 newstt
->memopt
= andsum
;
2539 newstt
->lvc.characts
= characts
;
2540 newstt
->lvc.version
= version
;
2548 rsctail
->next
= rsc
;
2549 rsc
->prev
= rsctail
;
2558 static toolbar_item_t
*ins_tlbr_button
(toolbar_item_t
*prev
, toolbar_item_t
*idrec
)
2567 static toolbar_item_t
*get_tlbr_buttons_head
(toolbar_item_t
*p
, int *nitems
)
2586 static string_t
*make_filename
(string_t
*str
)
2590 if
(str
->type
!= str_char
)
2591 yyerror("Cannot handle UNICODE filenames");
2593 /* Remove escaped backslash and convert to forward */
2594 cptr
= str
->str.cstr
;
2595 for
(cptr
= str
->str.cstr
; (cptr
= strchr
(cptr
, '\\')) != NULL
; cptr
++)
2599 memmove
(cptr
, cptr
+1, strlen
(cptr
));
2605 /* Convert to lower case. Seems to be reasonable to do */
2606 for
(cptr
= str
->str.cstr
; !leave_case
&& *cptr
; cptr
++)
2608 *cptr
= tolower
(*cptr
);
2614 * Process all resources to extract fonts and build
2615 * a fontdir resource.
2617 * Note: MS' resource compiler (build 1472) does not
2618 * handle font resources with different languages.
2619 * The fontdir is generated in the last active language
2620 * and font identifiers must be unique across the entire
2622 * This is not logical considering the localization
2623 * constraints of all other resource types. MS has,
2624 * most probably, never testet localized fonts. However,
2625 * using fontresources is rare, so it might not occur
2626 * in normal applications.
2627 * Wine does require better localization because a lot
2628 * of languages are coded into the same executable.
2629 * Therefore, I will generate fontdirs for *each*
2630 * localized set of fonts.
2632 static resource_t
*build_fontdir
(resource_t
**fnt
, int nfnt
)
2634 static int once
= 0;
2637 warning
("Need to parse fonts, not yet implemented");
2643 static resource_t
*build_fontdirs
(resource_t
*tail
)
2646 resource_t
*lst
= NULL
;
2647 resource_t
**fnt
= NULL
; /* List of all fonts */
2649 resource_t
**fnd
= NULL
; /* List of all fontdirs */
2651 resource_t
**lanfnt
= NULL
;
2658 nid.type
= name_str
;
2659 nid.name.s_name
= &str
;
2660 str.type
= str_char
;
2661 str.str.cstr
= "FONTDIR";
2664 /* Extract all fonts and fontdirs */
2665 for
(rsc
= tail
; rsc
; rsc
= rsc
->prev
)
2667 if
(rsc
->type
== res_fnt
)
2670 fnt
= xrealloc
(fnt
, nfnt
* sizeof
(*fnt
));
2673 else if
(rsc
->type
== res_fntdir
)
2676 fnd
= xrealloc
(fnd
, nfnd
* sizeof
(*fnd
));
2681 /* Verify the name of the present fontdirs */
2682 for
(i
= 0; i
< nfnd
; i
++)
2684 if
(compare_name_id
(&nid
, fnd
[i
]->name
))
2686 warning
("User supplied FONTDIR entry has an invalid name '%s', ignored",
2687 get_nameid_str
(fnd
[i
]->name
));
2696 warning
("Found %d FONTDIR entries without any fonts present", nfnd
);
2701 lanfnt
= xmalloc
(nfnt
* sizeof
(*lanfnt
));
2703 /* Get all fonts covered by fontdirs */
2704 for
(i
= 0; i
< nfnd
; i
++)
2712 for
(j
= 0; j
< nfnt
; j
++)
2716 if
(fnt
[j
]->lan
->id
== fnd
[i
]->lan
->id
&& fnt
[j
]->lan
->sub
== fnd
[i
]->lan
->sub
)
2718 lanfnt
[nlanfnt
] = fnt
[j
];
2724 cnt
= *(WORD
*)fnd
[i
]->res.fnd
->data
->data
;
2727 else if
(nlanfnt
== BYTESWAP_WORD
(cnt
))
2730 error("FONTDIR for language %d,%d has wrong count (%d, expected %d)",
2731 fnd
[i
]->lan
->id
, fnd
[i
]->lan
->sub
, cnt
, nlanfnt
);
2732 #ifdef WORDS_BIGENDIAN
2733 if
((byteorder
== WRC_BO_LITTLE
&& !isswapped
) ||
(byteorder
!= WRC_BO_LITTLE
&& isswapped
))
2735 if
((byteorder
== WRC_BO_BIG
&& !isswapped
) ||
(byteorder
!= WRC_BO_BIG
&& isswapped
))
2738 internal_error
(__FILE__
, __LINE__
, "User supplied FONTDIR needs byteswapping");
2742 /* We now have fonts left where we need to make a fontdir resource */
2743 for
(i
= fntleft
= 0; i
< nfnt
; i
++)
2750 /* Get fonts of same language in lanfnt[] */
2751 for
(i
= nlanfnt
= 0; i
< nfnt
; i
++)
2758 lanfnt
[nlanfnt
] = fnt
[i
];
2763 else if
(fnt
[i
]->lan
->id
== lanfnt
[0]->lan
->id
&& fnt
[i
]->lan
->sub
== lanfnt
[0]->lan
->sub
)
2767 /* and build a fontdir */
2768 rsc
= build_fontdir
(lanfnt
, nlanfnt
);
2790 * This gets invoked to determine whether the next resource
2791 * is to be of a standard-type (e.g. bitmaps etc.), or should
2792 * be a user-type resource. This function is required because
2793 * there is the _possibility_ of a lookahead token in the
2794 * parser, which is generated from the "expr" state in the
2797 * The general resource format is:
2798 * <identifier> <type> <flags> <resourcebody>
2800 * The <identifier> can either be tIDENT or "expr". The latter
2801 * will always generate a lookahead, which is the <type> of the
2802 * resource to parse. Otherwise, we need to get a new token from
2803 * the scanner to determine the next step.
2805 * The problem arrises when <type> is numerical. This case should
2806 * map onto default resource-types and be parsed as such instead
2807 * of being mapped onto user-type resources.
2809 * The trick lies in the fact that yacc (bison) doesn't care about
2810 * intermediate changes of the lookahead while reducing a rule. We
2811 * simply replace the lookahead with a token that will result in
2812 * a shift to the appropriate rule for the specific resource-type.
2814 static int rsrcid_to_token
(int lookahead
)
2819 /* Get a token if we don't have one yet */
2820 if
(lookahead
== YYEMPTY
)
2823 /* Only numbers are possibly interesting */
2853 case WRC_RT_FONTDIR
:
2861 case WRC_RT_MESSAGETABLE
:
2862 type
= "MESSAGETABLE";
2863 token
= tMESSAGETABLE
;
2865 case WRC_RT_DLGINIT
:
2869 case WRC_RT_ACCELERATOR
:
2870 type
= "ACCELERATOR";
2871 token
= tACCELERATORS
;
2881 case WRC_RT_VERSION
:
2883 token
= tVERSIONINFO
;
2885 case WRC_RT_TOOLBAR
:
2891 type
= "STRINGTABLE";
2894 case WRC_RT_ANICURSOR
:
2895 case WRC_RT_ANIICON
:
2896 case WRC_RT_GROUP_CURSOR
:
2897 case WRC_RT_GROUP_ICON
:
2898 yywarning
("Usertype uses reserved type-ID %d, which is auto-generated", yylval.num
);
2901 case WRC_RT_DLGINCLUDE
:
2902 case WRC_RT_PLUGPLAY
:
2905 yywarning
("Usertype uses reserved type-ID %d, which is not supported by wrc", yylval.num
);
2913 yywarning
("Usertype uses reserved type-ID %d, which is used by %s", yylval.num
, type
);