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
);
221 menuex_item_t
*menexitm
;
229 toolbar_item_t
*tlbarItems
;
231 style_pair_t
*styles
;
236 %token tTYPEDEF tEXTERN tSTRUCT tENUM tCPPCLASS tINLINE tSTATIC tNL
237 %token
<num
> tNUMBER tLNUMBER
238 %token
<str
> tSTRING tIDENT tFILENAME
239 %token
<raw
> tRAWDATA
240 %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE
241 %token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON
242 %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON
243 %token tPUSHBUTTON tRADIOBUTTON tSTATE3
/* PUSHBOX */
244 %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR
245 %token tCONTROL tEDITTEXT
246 %token tRTEXT tCTEXT tLTEXT
248 %token tSHIFT tALT tASCII tVIRTKEY tGRAYED tCHECKED tINACTIVE tNOINVERT
249 %token tPURE tIMPURE tDISCARDABLE tLOADONCALL tPRELOAD tFIXED tMOVEABLE
250 %token tCLASS tCAPTION tCHARACTERISTICS tEXSTYLE tSTYLE tVERSION tLANGUAGE
251 %token tFILEVERSION tPRODUCTVERSION tFILEFLAGSMASK tFILEOS tFILETYPE tFILEFLAGS tFILESUBTYPE
252 %token tMENUBARBREAK tMENUBREAK tMENUITEM tPOPUP tSEPARATOR
254 %token tSTRING tIDENT tRAWDATA
255 %token tTOOLBAR tBUTTON
266 %type
<res
> resource_file resource resources resource_definition
267 %type
<stt
> stringtable strings
270 %type
<acc
> accelerators
273 %type
<ani
> cursor icon
274 %type
<dlg
> dialog dlg_attributes
275 %type
<ctl
> ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo
277 %type
<dlgex
> dialogex dlgex_attribs
278 %type
<ctl
> exctrls gen_exctrl lab_exctrl exctrl_desc
280 %type
<raw
> raw_data raw_elements opt_data file_raw
281 %type
<veri
> versioninfo fix_version
282 %type
<verw
> ver_words
283 %type
<blk
> ver_blocks ver_block
284 %type
<val
> ver_values ver_value
286 %type
<menitm
> item_definitions menu_body
288 %type
<menexitm
> itemex_definitions menuex_body
289 %type
<exopt
> itemex_p_options itemex_options
290 %type
<msg
> messagetable
292 %type
<num
> item_options
293 %type
<nid
> nameid nameid_s ctlclass usertype
294 %type
<num
> acc_opt acc accs
295 %type
<iptr
> loadmemopts lamo lama
296 %type
<fntid
> opt_font opt_exfont opt_expr
298 %type
<lan
> opt_language
299 %type
<chars
> opt_characts
300 %type
<ver
> opt_version
303 %type
<tlbar
> toolbar
304 %type
<tlbarItems
> toolbar_items
305 %type
<dginit
> dlginit
306 %type
<styles
> optional_style_pair
307 %type
<num
> any_num any_nums
308 %type
<style
> optional_style
317 /* First add stringtables to the resource-list */
318 rsc
= build_stt_resources
(sttres
);
319 /* 'build_stt_resources' returns a head and $1 is a tail */
328 /* Find the tail again */
329 while
($1 && $1->next
)
331 /* Now add any fontdirecory */
332 rsc
= build_fontdirs
($1);
333 /* 'build_fontdir' returns a head and $1 is a tail */
342 /* Final statement before were done */
343 resource_top
= get_resource_head
($1);
347 /* Resources are put into a linked list */
349 : /* Empty */ { $$
= NULL
; want_id
= 1; }
350 | resources resource
{
353 resource_t
*tail
= $2;
354 resource_t
*head
= $2;
363 /* Check for duplicate identifiers */
366 resource_t
*rsc
= $1;
369 if
(rsc
->type
== head
->type
370 && rsc
->lan
->id
== head
->lan
->id
371 && rsc
->lan
->sub
== head
->lan
->sub
372 && !compare_name_id
(rsc
->name
, head
->name
))
374 yyerror("Duplicate resource name '%s'", get_nameid_str
(rsc
->name
));
383 resource_t
*tail
= $1;
392 | resources preprocessor
{ $$
= $1; want_id
= 1; }
393 | resources cjunk
{ $$
= $1; want_id
= 1; }
397 * The preprocessor generates line directives a la gcc
399 * # <linenum> "filename" <codes>
401 * Codes can be a sequence of:
402 * - 1 start of new file
403 * - 2 returning to previous
405 * - 4 interpret as C-code
407 * 4 is not used and 1 mutually excludes 2
408 * Anyhow, we are not really interested in these at all
409 * because we only want to know the linenumber and
413 : '#' { want_nl
= 1; } tNUMBER tSTRING any_nums tNL
{
414 line_number
= $3 - 1;
415 input_name
= $4->str.cstr
;
416 /* fprintf(stderr, "Now at %s:%d\n", input_name, line_number); */
425 cjunk
: tTYPEDEF
{ strip_til_semicolon
(); }
426 | tSTRUCT
{ strip_til_semicolon
(); }
427 | tEXTERN
{ strip_til_semicolon
(); }
428 | tENUM
{ strip_til_semicolon
(); }
429 | tCPPCLASS
{ strip_til_semicolon
(); }
430 | tSTATIC
{ strip_til_semicolon
(); }
431 | tINLINE
{ internal_error
(__FILE__
, __LINE__
, "Don't yet know how to strip inline functions\n"); }
432 /* | tIDENT tIDENT { strip_til_semicolon(); } */
433 | tIDENT tIDENT
'(' { strip_til_parenthesis
(); }
434 /* | tIDENT '(' { strip_til_parenthesis(); } */
435 | tIDENT
'*' { strip_til_semicolon
(); }
438 /* Parse top level resource definitions etc. */
440 : nameid resource_definition
{
445 if
($1->type
== name_ord
)
447 chat
("Got %s (%d)",get_typename
($2),$1->name.i_name
);
449 else if
($1->type
== name_str
)
451 chat
("Got %s (%s)",get_typename
($2),$1->name.s_name
->str.cstr
);
456 /* Don't do anything, stringtables are converted to
457 * resource_t structures when we are finished parsing and
458 * the final rule of the parser is reduced (see above)
461 chat
("Got STRINGTABLE");
463 | tLANGUAGE
{want_nl
= 1; } expr
',' expr tNL
{
464 /* We *NEED* the newline to delimit the expression.
465 * Otherwise, we would not be able to set the next
466 * want_id anymore because of the token-lookahead.
469 yywarning
("LANGUAGE not supported in 16-bit mode");
471 free
(currentlanguage
);
472 currentlanguage
= new_language
($3, $5);
478 * Get a valid name/id
481 if
($1 > 65535 ||
$1 < -32768)
482 yyerror("Resource's ID out of range (%d)", $1);
485 $$
->name.i_name
= $1;
490 $$
->name.s_name
= $1;
495 * Extra string recognition for CLASS statement in dialogs
497 nameid_s: nameid
{ $$
= $1; }
501 $$
->name.s_name
= $1;
505 /* get the value for a single resource*/
507 : accelerators
{ $$
= new_resource
(res_acc
, $1, $1->memopt
, $1->lvc.language
); }
508 | bitmap
{ $$
= new_resource
(res_bmp
, $1, $1->memopt
, $1->data
->lvc.language
); }
511 if
($1->type
== res_anicur
)
513 $$
= rsc
= new_resource
(res_anicur
, $1->u.ani
, $1->u.ani
->memopt
, $1->u.ani
->data
->lvc.language
);
515 else if
($1->type
== res_curg
)
518 $$
= rsc
= new_resource
(res_curg
, $1->u.curg
, $1->u.curg
->memopt
, $1->u.curg
->lvc.language
);
519 for
(cur
= $1->u.curg
->cursorlist
; cur
; cur
= cur
->next
)
521 rsc
->prev
= new_resource
(res_cur
, cur
, $1->u.curg
->memopt
, $1->u.curg
->lvc.language
);
522 rsc
->prev
->next
= rsc
;
524 rsc
->name
= new_name_id
();
525 rsc
->name
->type
= name_ord
;
526 rsc
->name
->name.i_name
= cur
->id
;
530 internal_error
(__FILE__
, __LINE__
, "Invalid top-level type %d in cursor resource", $1->type
);
533 | dialog
{ $$
= new_resource
(res_dlg
, $1, $1->memopt
, $1->lvc.language
); }
536 $$
= new_resource
(res_dlgex
, $1, $1->memopt
, $1->lvc.language
);
540 | dlginit
{ $$
= new_resource
(res_dlginit
, $1, $1->memopt
, $1->data
->lvc.language
); }
541 | font
{ $$
= new_resource
(res_fnt
, $1, $1->memopt
, $1->data
->lvc.language
); }
542 | fontdir
{ $$
= new_resource
(res_fntdir
, $1, $1->memopt
, $1->data
->lvc.language
); }
545 if
($1->type
== res_aniico
)
547 $$
= rsc
= new_resource
(res_aniico
, $1->u.ani
, $1->u.ani
->memopt
, $1->u.ani
->data
->lvc.language
);
549 else if
($1->type
== res_icog
)
552 $$
= rsc
= new_resource
(res_icog
, $1->u.icog
, $1->u.icog
->memopt
, $1->u.icog
->lvc.language
);
553 for
(ico
= $1->u.icog
->iconlist
; ico
; ico
= ico
->next
)
555 rsc
->prev
= new_resource
(res_ico
, ico
, $1->u.icog
->memopt
, $1->u.icog
->lvc.language
);
556 rsc
->prev
->next
= rsc
;
558 rsc
->name
= new_name_id
();
559 rsc
->name
->type
= name_ord
;
560 rsc
->name
->name.i_name
= ico
->id
;
564 internal_error
(__FILE__
, __LINE__
, "Invalid top-level type %d in icon resource", $1->type
);
567 | menu
{ $$
= new_resource
(res_men
, $1, $1->memopt
, $1->lvc.language
); }
570 $$
= new_resource
(res_menex
, $1, $1->memopt
, $1->lvc.language
);
574 | messagetable
{ $$
= new_resource
(res_msg
, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE
, dup_language
(currentlanguage
)); }
575 | rcdata
{ $$
= new_resource
(res_rdt
, $1, $1->memopt
, $1->data
->lvc.language
); }
576 | toolbar
{ $$
= new_resource
(res_toolbar
, $1, $1->memopt
, $1->lvc.language
); }
577 | userres
{ $$
= new_resource
(res_usr
, $1, $1->memopt
, $1->data
->lvc.language
); }
578 | versioninfo
{ $$
= new_resource
(res_ver
, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE
, $1->lvc.language
); }
582 filename: tFILENAME
{ $$
= make_filename
($1); }
583 | tIDENT
{ $$
= make_filename
($1); }
584 | tSTRING
{ $$
= make_filename
($1); }
587 /* ------------------------------ Bitmap ------------------------------ */
588 bitmap
: tBITMAP loadmemopts file_raw
{ $$
= new_bitmap
($3, $2); }
591 /* ------------------------------ Cursor ------------------------------ */
592 cursor
: tCURSOR loadmemopts file_raw
{
594 if
($3->size
> 4 && !memcmp
($3->data
, riff
, sizeof
(riff
)))
596 $$
->type
= res_anicur
;
597 $$
->u.ani
= new_ani_curico
(res_anicur
, $3, $2);
602 $$
->u.curg
= new_cursor_group
($3, $2);
607 /* ------------------------------ Icon ------------------------------ */
608 icon
: tICON loadmemopts file_raw
{
610 if
($3->size
> 4 && !memcmp
($3->data
, riff
, sizeof
(riff
)))
612 $$
->type
= res_aniico
;
613 $$
->u.ani
= new_ani_curico
(res_aniico
, $3, $2);
618 $$
->u.icog
= new_icon_group
($3, $2);
623 /* ------------------------------ Font ------------------------------ */
625 * The reading of raw_data for fonts is a Borland BRC
626 * extension. MS generates an error. However, it is
627 * most logical to support this, considering how wine
628 * enters things in CVS (ascii).
630 font
: tFONT loadmemopts file_raw
{ $$
= new_font
($3, $2); }
634 * The fontdir is a Borland BRC extension which only
635 * reads the data as 'raw_data' from the file.
636 * I don't know whether it is interpreted.
637 * The fontdir is generated if it was not present and
638 * fonts are defined in the source.
640 fontdir
: tFONTDIR loadmemopts file_raw
{ $$
= new_fontdir
($3, $2); }
643 /* ------------------------------ MessageTable ------------------------------ */
644 /* It might be interesting to implement the MS Message compiler here as well
645 * to get everything in one source. Might be a future project.
648 : tMESSAGETABLE loadmemopts file_raw
{
650 yywarning
("MESSAGETABLE not supported in 16-bit mode");
651 $$
= new_messagetable
($3, $2);
655 /* ------------------------------ RCData ------------------------------ */
656 rcdata
: tRCDATA loadmemopts file_raw
{ $$
= new_rcdata
($3, $2); }
659 /* ------------------------------ DLGINIT ------------------------------ */
660 dlginit
: tDLGINIT loadmemopts file_raw
{ $$
= new_dlginit
($3, $2); }
663 /* ------------------------------ UserType ------------------------------ */
664 userres
: usertype loadmemopts file_raw
{
665 if
($1->type
== name_ord
)
667 switch
($1->name.i_name
)
669 case WRC_RT_CURSOR
: /* Bad idea; cursors should generate directories */
670 case WRC_RT_ANICURSOR
:
672 case WRC_RT_ANIICON
: /* Bad idea; icons should generate directories */
674 case WRC_RT_FONT
: /* Bad idea; fonts should generate directories */
676 case WRC_RT_RCDATA
: /* This cannot be interpreted anyway */
677 case WRC_RT_MESSAGETABLE
: /* This case is involked by mc.exe */
678 case WRC_RT_DLGINIT
: /* No real layout available */
680 /* These should never be invoked because they have their own layout */
681 case WRC_RT_ACCELERATOR
:
687 yywarning
("Usertype uses special type-ID %d (wrc cannot yet re-interpret the data)", $1->name.i_name
);
690 case WRC_RT_GROUP_CURSOR
:
691 case WRC_RT_GROUP_ICON
:
692 yywarning
("Usertype uses reserved type-ID %d, which is auto-generated", $1->name.i_name
);
695 case WRC_RT_DLGINCLUDE
:
696 case WRC_RT_PLUGPLAY
:
699 yywarning
("Usertype uses reserved type-ID %d, which is not supported by wrc", $1->name.i_name
);
707 #ifdef WORDS_BIGENDIAN
708 if
(pedantic
&& byteorder
!= WRC_BO_LITTLE
)
710 if
(pedantic
&& byteorder
== WRC_BO_BIG
)
712 yywarning
("Byteordering is not little-endian and type cannot be interpreted");
713 $$
= new_user
($1, $3, $2);
721 $$
->name.i_name
= $1;
726 $$
->name.s_name
= $1;
730 /* ------------------------------ Accelerator ------------------------------ */
732 : tACCELERATORS loadmemopts opt_lvc tBEGIN events tEND
{
733 $$
= new_accelerator
();
741 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE
;
744 yyerror("Accelerator table must have at least one entry");
745 $$
->events
= get_event_head
($5);
751 if
(!$$
->lvc.language
)
752 $$
->lvc.language
= dup_language
(currentlanguage
);
756 events
: /* Empty */ { $$
=NULL
; }
757 | events tSTRING
',' expr acc_opt
{ $$
=add_string_event
($2, $4, $5, $1); }
758 | events expr
',' expr acc_opt
{ $$
=add_event
($2, $4, $5, $1); }
762 * The empty rule generates a s/r conflict because of {bi,u}nary expr
763 * on - and +. It cannot be solved in any way because it is the same as
764 * the if/then/else problem (LALR(1) problem). The conflict is moved
765 * away by forcing it to be in the expression handling below.
767 acc_opt
: /* Empty */ { $$
= 0; }
768 |
',' accs
{ $$
= $2; }
771 accs
: acc
{ $$
= $1; }
772 | accs
',' acc
{ $$
= $1 |
$3; }
775 acc
: tNOINVERT
{ $$
= WRC_AF_NOINVERT
; }
776 | tSHIFT
{ $$
= WRC_AF_SHIFT
; }
777 | tCONTROL
{ $$
= WRC_AF_CONTROL
; }
778 | tALT
{ $$
= WRC_AF_ALT
; }
779 | tASCII
{ $$
= WRC_AF_ASCII
; }
780 | tVIRTKEY
{ $$
= WRC_AF_VIRTKEY
; }
783 /* ------------------------------ Dialog ------------------------------ */
784 /* FIXME: Support EXSTYLE in the dialog line itself */
785 dialog
: tDIALOG loadmemopts expr
',' expr
',' expr
',' expr dlg_attributes
793 $10->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
798 $10->controls
= get_control_head
($12);
802 $$
->style
->or_mask
= WS_POPUP
;
806 $$
->style
->or_mask |
= WS_CAPTION
;
808 $$
->style
->or_mask |
= DS_SETFONT
;
810 $$
->style
->or_mask
&= ~
($$
->style
->and_mask
);
811 $$
->style
->and_mask
= 0;
813 if
(!$$
->lvc.language
)
814 $$
->lvc.language
= dup_language
(currentlanguage
);
819 : /* Empty */ { $$
=new_dialog
(); }
820 | dlg_attributes tSTYLE style
{ $$
=dialog_style
($3,$1); }
821 | dlg_attributes tEXSTYLE style
{ $$
=dialog_exstyle
($3,$1); }
822 | dlg_attributes tCAPTION tSTRING
{ $$
=dialog_caption
($3,$1); }
823 | dlg_attributes opt_font
{ $$
=dialog_font
($2,$1); }
824 | dlg_attributes tCLASS nameid_s
{ $$
=dialog_class
($3,$1); }
825 | dlg_attributes tCPPCLASS nameid_s
{ $$
=dialog_class
($3,$1); }
826 | dlg_attributes tMENU nameid
{ $$
=dialog_menu
($3,$1); }
827 | dlg_attributes opt_language
{ $$
=dialog_language
($2,$1); }
828 | dlg_attributes opt_characts
{ $$
=dialog_characteristics
($2,$1); }
829 | dlg_attributes opt_version
{ $$
=dialog_version
($2,$1); }
832 ctrls
: /* Empty */ { $$
= NULL
; }
833 | ctrls tCONTROL gen_ctrl
{ $$
=ins_ctrl
(-1, 0, $3, $1); }
834 | ctrls tEDITTEXT ctrl_desc
{ $$
=ins_ctrl
(CT_EDIT
, 0, $3, $1); }
835 | ctrls tLISTBOX ctrl_desc
{ $$
=ins_ctrl
(CT_LISTBOX
, 0, $3, $1); }
836 | ctrls tCOMBOBOX ctrl_desc
{ $$
=ins_ctrl
(CT_COMBOBOX
, 0, $3, $1); }
837 | ctrls tSCROLLBAR ctrl_desc
{ $$
=ins_ctrl
(CT_SCROLLBAR
, 0, $3, $1); }
838 | ctrls tCHECKBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_CHECKBOX
, $3, $1); }
839 | ctrls tDEFPUSHBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $3, $1); }
840 | ctrls tGROUPBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_GROUPBOX
, $3, $1);}
841 | ctrls tPUSHBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_PUSHBUTTON
, $3, $1); }
842 /* | ctrls tPUSHBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
843 | ctrls tRADIOBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_RADIOBUTTON
, $3, $1); }
844 | ctrls tAUTO3STATE lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTO3STATE
, $3, $1); }
845 | ctrls tSTATE3 lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_3STATE
, $3, $1); }
846 | ctrls tAUTOCHECKBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTOCHECKBOX
, $3, $1); }
847 | ctrls tAUTORADIOBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTORADIOBUTTON
, $3, $1); }
848 | ctrls tLTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_LEFT
, $3, $1); }
849 | ctrls tCTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_CENTER
, $3, $1); }
850 | ctrls tRTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_RIGHT
, $3, $1); }
851 /* special treatment for icons, as the extent is optional */
852 | ctrls tICON nameid_s opt_comma expr
',' expr
',' expr iconinfo
{
857 $$
= ins_ctrl
(CT_STATIC
, SS_ICON
, $10, $1);
862 : tSTRING opt_comma expr
',' expr
',' expr
',' expr
',' expr optional_style
{
864 $$
->title
= new_name_id
();
865 $$
->title
->type
= name_str
;
866 $$
->title
->name.s_name
= $1;
881 : expr
',' expr
',' expr
',' expr
',' expr optional_style
{
896 iconinfo: /* Empty */
897 { $$
= new_control
(); }
899 |
',' expr
',' expr
{
904 |
',' expr
',' expr
',' style
{
911 |
',' expr
',' expr
',' style
',' style
{
918 $$
->gotexstyle
= TRUE
;
922 gen_ctrl: nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr
',' style
{
926 $$
->ctlclass
= convert_ctlclass
($5);
934 $$
->gotexstyle
= TRUE
;
936 | nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr
{
940 $$
->ctlclass
= convert_ctlclass
($5);
951 : tFONT expr
',' tSTRING
{ $$
= new_font_id
($2, $4, 0, 0); }
954 /* ------------------------------ style flags ------------------------------ */
955 optional_style
/* Abbused once to get optional ExStyle */
956 : /* Empty */ { $$
= NULL
; }
957 |
',' style
{ $$
= $2; }
961 : /* Empty */ { $$
= NULL
; }
962 |
',' style
{ $$
= new_style_pair
($2, 0); }
963 |
',' style
',' style
{ $$
= new_style_pair
($2, $4); }
967 : style
'|' style
{ $$
= new_style
($1->or_mask |
$3->or_mask
, $1->and_mask |
$3->and_mask
); free
($1); free
($3);}
968 |
'(' style
')' { $$
= $2; }
969 | any_num
{ $$
= new_style
($1, 0); }
970 | tNOT any_num
{ $$
= new_style
(0, $2); }
977 $$
->name.i_name
= $1;
982 $$
->name.s_name
= $1;
986 /* ------------------------------ DialogEx ------------------------------ */
987 dialogex: tDIALOGEX loadmemopts expr
',' expr
',' expr
',' expr helpid dlgex_attribs
988 tBEGIN exctrls tEND
{
990 yywarning
("DIALOGEX not supported in 16-bit mode");
997 $11->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1004 $11->helpid
= *($10);
1005 $11->gothelpid
= TRUE
;
1008 $11->controls
= get_control_head
($13);
1011 assert
($$
->style
!= NULL
);
1014 $$
->style
->or_mask
= WS_POPUP
;
1015 $$
->gotstyle
= TRUE
;
1018 $$
->style
->or_mask |
= WS_CAPTION
;
1020 $$
->style
->or_mask |
= DS_SETFONT
;
1022 $$
->style
->or_mask
&= ~
($$
->style
->and_mask
);
1023 $$
->style
->and_mask
= 0;
1025 if
(!$$
->lvc.language
)
1026 $$
->lvc.language
= dup_language
(currentlanguage
);
1031 : /* Empty */ { $$
=new_dialogex
(); }
1032 | dlgex_attribs tSTYLE style
{ $$
=dialogex_style
($3,$1); }
1033 | dlgex_attribs tEXSTYLE style
{ $$
=dialogex_exstyle
($3,$1); }
1034 | dlgex_attribs tCAPTION tSTRING
{ $$
=dialogex_caption
($3,$1); }
1035 | dlgex_attribs opt_font
{ $$
=dialogex_font
($2,$1); }
1036 | dlgex_attribs opt_exfont
{ $$
=dialogex_font
($2,$1); }
1037 | dlgex_attribs tCLASS nameid_s
{ $$
=dialogex_class
($3,$1); }
1038 | dlgex_attribs tCPPCLASS nameid_s
{ $$
=dialogex_class
($3,$1); }
1039 | dlgex_attribs tMENU nameid
{ $$
=dialogex_menu
($3,$1); }
1040 | dlgex_attribs opt_language
{ $$
=dialogex_language
($2,$1); }
1041 | dlgex_attribs opt_characts
{ $$
=dialogex_characteristics
($2,$1); }
1042 | dlgex_attribs opt_version
{ $$
=dialogex_version
($2,$1); }
1045 exctrls
: /* Empty */ { $$
= NULL
; }
1046 | exctrls tCONTROL gen_exctrl
{ $$
=ins_ctrl
(-1, 0, $3, $1); }
1047 | exctrls tEDITTEXT exctrl_desc
{ $$
=ins_ctrl
(CT_EDIT
, 0, $3, $1); }
1048 | exctrls tLISTBOX exctrl_desc
{ $$
=ins_ctrl
(CT_LISTBOX
, 0, $3, $1); }
1049 | exctrls tCOMBOBOX exctrl_desc
{ $$
=ins_ctrl
(CT_COMBOBOX
, 0, $3, $1); }
1050 | exctrls tSCROLLBAR exctrl_desc
{ $$
=ins_ctrl
(CT_SCROLLBAR
, 0, $3, $1); }
1051 | exctrls tCHECKBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_CHECKBOX
, $3, $1); }
1052 | exctrls tDEFPUSHBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $3, $1); }
1053 | exctrls tGROUPBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_GROUPBOX
, $3, $1);}
1054 | exctrls tPUSHBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_PUSHBUTTON
, $3, $1); }
1055 /* | exctrls tPUSHBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
1056 | exctrls tRADIOBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_RADIOBUTTON
, $3, $1); }
1057 | exctrls tAUTO3STATE lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTO3STATE
, $3, $1); }
1058 | exctrls tSTATE3 lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_3STATE
, $3, $1); }
1059 | exctrls tAUTOCHECKBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTOCHECKBOX
, $3, $1); }
1060 | exctrls tAUTORADIOBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTORADIOBUTTON
, $3, $1); }
1061 | exctrls tLTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_LEFT
, $3, $1); }
1062 | exctrls tCTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_CENTER
, $3, $1); }
1063 | exctrls tRTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_RIGHT
, $3, $1); }
1064 /* special treatment for icons, as the extent is optional */
1065 | exctrls tICON nameid_s opt_comma expr
',' expr
',' expr iconinfo
{
1070 $$
= ins_ctrl
(CT_STATIC
, SS_ICON
, $10, $1);
1075 : nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
','
1076 expr
',' style helpid opt_data
{
1080 $$
->ctlclass
= convert_ctlclass
($5);
1082 $$
->gotstyle
= TRUE
;
1090 $$
->gotexstyle
= TRUE
;
1094 $$
->helpid
= *($18);
1095 $$
->gothelpid
= TRUE
;
1100 | nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr opt_data
{
1105 $$
->gotstyle
= TRUE
;
1106 $$
->ctlclass
= convert_ctlclass
($5);
1116 : tSTRING opt_comma expr
',' expr
',' expr
',' expr
',' expr optional_style_pair opt_data
{
1118 $$
->title
= new_name_id
();
1119 $$
->title
->type
= name_str
;
1120 $$
->title
->name.s_name
= $1;
1128 $$
->style
= $12->style
;
1129 $$
->gotstyle
= TRUE
;
1133 $$
->exstyle
= $12->exstyle
;
1134 $$
->gotexstyle
= TRUE
;
1144 : expr
',' expr
',' expr
',' expr
',' expr optional_style_pair opt_data
{
1153 $$
->style
= $10->style
;
1154 $$
->gotstyle
= TRUE
;
1158 $$
->exstyle
= $10->exstyle
;
1159 $$
->gotexstyle
= TRUE
;
1167 opt_data: /* Empty */ { $$
= NULL
; }
1168 | raw_data
{ $$
= $1; }
1171 helpid
: /* Empty */ { $$
= NULL
; }
1172 |
',' expr
{ $$
= new_int
($2); }
1176 : tFONT expr
',' tSTRING
',' expr
',' expr opt_expr
{ $$
= new_font_id
($2, $4, $6, $8); }
1180 * FIXME: This odd expression is here to nullify an extra token found
1181 * in some appstudio produced resources which appear to do nothing.
1183 opt_expr: /* Empty */ { $$
= NULL
; }
1184 |
',' expr
{ $$
= NULL
; }
1187 /* ------------------------------ Menu ------------------------------ */
1188 menu
: tMENU loadmemopts opt_lvc menu_body
{
1190 yyerror("Menu must contain items");
1198 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1199 $$
->items
= get_item_head
($4);
1205 if
(!$$
->lvc.language
)
1206 $$
->lvc.language
= dup_language
(currentlanguage
);
1211 : tBEGIN item_definitions tEND
{ $$
= $2; }
1215 : /* Empty */ {$$
= NULL
;}
1216 | item_definitions tMENUITEM tSTRING opt_comma expr item_options
{
1225 | item_definitions tMENUITEM tSEPARATOR
{
1231 | item_definitions tPOPUP tSTRING item_options menu_body
{
1232 $$
= new_menu_item
();
1236 $$
->popup
= get_item_head
($5);
1241 /* NOTE: item_options is right recursive because it would introduce
1242 * a shift/reduce conflict on ',' in itemex_options due to the
1243 * empty rule here. The parser is now forced to look beyond the ','
1244 * before reducing (force shift).
1245 * Right recursion here is not a problem because we cannot expect
1246 * more than 7 parserstack places to be occupied while parsing this
1247 * (who would want to specify a MF_x flag twice?).
1250 : /* Empty */ { $$
= 0; }
1251 |
',' tCHECKED item_options
{ $$
= $3 | MF_CHECKED
; }
1252 |
',' tGRAYED item_options
{ $$
= $3 | MF_GRAYED
; }
1253 |
',' tHELP item_options
{ $$
= $3 | MF_HELP
; }
1254 |
',' tINACTIVE item_options
{ $$
= $3 | MF_DISABLED
; }
1255 |
',' tMENUBARBREAK item_options
{ $$
= $3 | MF_MENUBARBREAK
; }
1256 |
',' tMENUBREAK item_options
{ $$
= $3 | MF_MENUBREAK
; }
1259 /* ------------------------------ MenuEx ------------------------------ */
1260 menuex
: tMENUEX loadmemopts opt_lvc menuex_body
{
1262 yywarning
("MENUEX not supported in 16-bit mode");
1264 yyerror("MenuEx must contain items");
1272 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1273 $$
->items
= get_itemex_head
($4);
1279 if
(!$$
->lvc.language
)
1280 $$
->lvc.language
= dup_language
(currentlanguage
);
1285 : tBEGIN itemex_definitions tEND
{ $$
= $2; }
1289 : /* Empty */ {$$
= NULL
; }
1290 | itemex_definitions tMENUITEM tSTRING itemex_options
{
1291 $$
= new_menuex_item
();
1297 $$
->type
= $4->type
;
1298 $$
->state
= $4->state
;
1299 $$
->helpid
= $4->helpid
;
1300 $$
->gotid
= $4->gotid
;
1301 $$
->gottype
= $4->gottype
;
1302 $$
->gotstate
= $4->gotstate
;
1303 $$
->gothelpid
= $4->gothelpid
;
1306 | itemex_definitions tMENUITEM tSEPARATOR
{
1307 $$
= new_menuex_item
();
1312 | itemex_definitions tPOPUP tSTRING itemex_p_options menuex_body
{
1313 $$
= new_menuex_item
();
1317 $$
->popup
= get_itemex_head
($5);
1320 $$
->type
= $4->type
;
1321 $$
->state
= $4->state
;
1322 $$
->helpid
= $4->helpid
;
1323 $$
->gotid
= $4->gotid
;
1324 $$
->gottype
= $4->gottype
;
1325 $$
->gotstate
= $4->gotstate
;
1326 $$
->gothelpid
= $4->gothelpid
;
1332 : /* Empty */ { $$
= new_itemex_opt
(0, 0, 0, 0); }
1334 $$
= new_itemex_opt
($2, 0, 0, 0);
1337 |
',' e_expr
',' e_expr item_options
{
1338 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $5, 0);
1341 $$
->gotstate
= TRUE
;
1345 |
',' e_expr
',' e_expr
',' expr
{
1346 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6, 0);
1349 $$
->gotstate
= TRUE
;
1356 : /* Empty */ { $$
= new_itemex_opt
(0, 0, 0, 0); }
1358 $$
= new_itemex_opt
($2, 0, 0, 0);
1361 |
',' e_expr
',' expr
{
1362 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4, 0, 0);
1367 |
',' e_expr
',' e_expr
',' expr
{
1368 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6, 0);
1373 $$
->gotstate
= TRUE
;
1375 |
',' e_expr
',' e_expr
',' e_expr
',' expr
{
1376 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6 ?
*($6) : 0, $8);
1382 $$
->gotstate
= TRUE
;
1383 $$
->gothelpid
= TRUE
;
1387 /* ------------------------------ StringTable ------------------------------ */
1388 /* Stringtables are parsed differently than other resources because their
1389 * layout is substantially different from other resources.
1390 * The table is parsed through a _global_ variable 'tagstt' which holds the
1391 * current stringtable descriptor (stringtable_t *) and 'sttres' that holds a
1392 * list of stringtables of different languages.
1395 : stt_head tBEGIN strings tEND
{
1398 yyerror("Stringtable must have at least one entry");
1403 /* Check if we added to a language table or created
1406 for
(stt
= sttres
; stt
; stt
= stt
->next
)
1413 /* It is a new one */
1416 sttres
->prev
= tagstt
;
1417 tagstt
->next
= sttres
;
1423 /* Else were done */
1427 free
(tagstt_memopt
);
1428 tagstt_memopt
= NULL
;
1435 /* This is to get the language of the currently parsed stringtable */
1436 stt_head: tSTRINGTABLE loadmemopts opt_lvc
{
1437 if
((tagstt
= find_stringtable
($3)) == NULL
)
1438 tagstt
= new_stringtable
($3);
1440 tagstt_version
= $3->version
;
1441 tagstt_characts
= $3->characts
;
1447 strings
: /* Empty */ { $$
= NULL
; }
1448 | strings expr opt_comma tSTRING
{
1450 assert
(tagstt
!= NULL
);
1451 if
($2 > 65535 ||
$2 < -32768)
1452 yyerror("Stringtable entry's ID out of range (%d)", $2);
1453 /* Search for the ID */
1454 for
(i
= 0; i
< tagstt
->nentries
; i
++)
1456 if
(tagstt
->entries
[i
].id
== $2)
1457 yyerror("Stringtable ID %d already in use", $2);
1459 /* If we get here, then we have a new unique entry */
1461 tagstt
->entries
= xrealloc
(tagstt
->entries
, sizeof
(tagstt
->entries
[0]) * tagstt
->nentries
);
1462 tagstt
->entries
[tagstt
->nentries
-1].id
= $2;
1463 tagstt
->entries
[tagstt
->nentries
-1].str
= $4;
1465 tagstt
->entries
[tagstt
->nentries
-1].memopt
= *tagstt_memopt
;
1467 tagstt
->entries
[tagstt
->nentries
-1].memopt
= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE
;
1468 tagstt
->entries
[tagstt
->nentries
-1].version
= tagstt_version
;
1469 tagstt
->entries
[tagstt
->nentries
-1].characts
= tagstt_characts
;
1471 if
(!win32
&& $4->size
> 254)
1472 yyerror("Stringtable entry more than 254 characters");
1473 if
(win32
&& $4->size
> 65534) /* Hmm..., does this happen? */
1474 yyerror("Stringtable entry more than 65534 characters (probably something else that went wrong)");
1479 opt_comma
/* There seem to be two ways to specify a stringtable... */
1484 /* ------------------------------ VersionInfo ------------------------------ */
1486 : tVERSIONINFO loadmemopts fix_version tBEGIN ver_blocks tEND
{
1494 $$
->memopt
= WRC_MO_MOVEABLE |
(win32 ? WRC_MO_PURE
: 0);
1495 $$
->blocks
= get_ver_block_head
($5);
1496 /* Set language; there is no version or characteristics */
1497 $$
->lvc.language
= dup_language
(currentlanguage
);
1502 : /* Empty */ { $$
= new_versioninfo
(); }
1503 | fix_version tFILEVERSION expr
',' expr
',' expr
',' expr
{
1505 yyerror("FILEVERSION already defined");
1507 $$
->filever_maj1
= $3;
1508 $$
->filever_maj2
= $5;
1509 $$
->filever_min1
= $7;
1510 $$
->filever_min2
= $9;
1513 | fix_version tPRODUCTVERSION expr
',' expr
',' expr
',' expr
{
1515 yyerror("PRODUCTVERSION already defined");
1517 $$
->prodver_maj1
= $3;
1518 $$
->prodver_maj2
= $5;
1519 $$
->prodver_min1
= $7;
1520 $$
->prodver_min2
= $9;
1523 | fix_version tFILEFLAGS expr
{
1525 yyerror("FILEFLAGS already defined");
1530 | fix_version tFILEFLAGSMASK expr
{
1532 yyerror("FILEFLAGSMASK already defined");
1534 $$
->fileflagsmask
= $3;
1537 | fix_version tFILEOS expr
{
1539 yyerror("FILEOS already defined");
1544 | fix_version tFILETYPE expr
{
1546 yyerror("FILETYPE already defined");
1551 | fix_version tFILESUBTYPE expr
{
1553 yyerror("FILESUBTYPE already defined");
1555 $$
->filesubtype
= $3;
1561 : /* Empty */ { $$
= NULL
; }
1562 | ver_blocks ver_block
{
1571 : tBLOCK tSTRING tBEGIN ver_values tEND
{
1572 $$
= new_ver_block
();
1574 $$
->values
= get_ver_value_head
($4);
1579 : /* Empty */ { $$
= NULL
; }
1580 | ver_values ver_value
{
1590 $$
= new_ver_value
();
1591 $$
->type
= val_block
;
1592 $$
->value.block
= $1;
1594 | tVALUE tSTRING
',' tSTRING
{
1595 $$
= new_ver_value
();
1600 | tVALUE tSTRING
',' ver_words
{
1601 $$
= new_ver_value
();
1602 $$
->type
= val_words
;
1604 $$
->value.words
= $4;
1609 : expr
{ $$
= new_ver_words
($1); }
1610 | ver_words
',' expr
{ $$
= add_ver_words
($1, $3); }
1613 /* ------------------------------ Toolbar ------------------------------ */
1614 toolbar: tTOOLBAR loadmemopts expr
',' expr opt_lvc tBEGIN toolbar_items tEND
{
1616 toolbar_item_t
*items
= get_tlbr_buttons_head
($8, &nitems
);
1617 $$
= new_toolbar
($3, $5, items
, nitems
);
1625 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE
;
1632 if
(!$$
->lvc.language
)
1634 $$
->lvc.language
= dup_language
(currentlanguage
);
1640 : /* Empty */ { $$
= NULL
; }
1641 | toolbar_items tBUTTON expr
{
1642 toolbar_item_t
*idrec
= new_toolbar_item
();
1644 $$
= ins_tlbr_button
($1, idrec
);
1646 | toolbar_items tSEPARATOR
{
1647 toolbar_item_t
*idrec
= new_toolbar_item
();
1649 $$
= ins_tlbr_button
($1, idrec
);
1653 /* ------------------------------ Memory options ------------------------------ */
1655 : /* Empty */ { $$
= NULL
; }
1656 | loadmemopts lamo
{
1666 | loadmemopts lama
{
1675 *$2 &= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE
;
1681 lamo
: tPRELOAD
{ $$
= new_int
(WRC_MO_PRELOAD
); }
1682 | tMOVEABLE
{ $$
= new_int
(WRC_MO_MOVEABLE
); }
1683 | tDISCARDABLE
{ $$
= new_int
(WRC_MO_DISCARDABLE
); }
1684 | tPURE
{ $$
= new_int
(WRC_MO_PURE
); }
1687 lama
: tLOADONCALL
{ $$
= new_int
(~WRC_MO_PRELOAD
); }
1688 | tFIXED
{ $$
= new_int
(~WRC_MO_MOVEABLE
); }
1689 | tIMPURE
{ $$
= new_int
(~WRC_MO_PURE
); }
1692 /* ------------------------------ Win32 options ------------------------------ */
1693 opt_lvc
: /* Empty */ { $$
= new_lvc
(); }
1694 | opt_lvc opt_language
{
1696 yywarning
("LANGUAGE not supported in 16-bit mode");
1698 yyerror("Language already defined");
1702 | opt_lvc opt_characts
{
1704 yywarning
("CHARACTERISTICS not supported in 16-bit mode");
1706 yyerror("Characteristics already defined");
1710 | opt_lvc opt_version
{
1712 yywarning
("VERSION not supported in 16-bit mode");
1714 yyerror("Version already defined");
1721 * This here is another s/r conflict on {bi,u}nary + and -.
1722 * It is due to the look-ahead which must determine when the
1723 * rule opt_language ends. It could be solved with adding a
1724 * tNL at the end, but that seems unreasonable to do.
1725 * The conflict is now moved to the expression handling below.
1728 : tLANGUAGE expr
',' expr
{ $$
= new_language
($2, $4); }
1732 : tCHARACTERISTICS expr
{ $$
= new_characts
($2); }
1736 : tVERSION expr
{ $$
= new_version
($2); }
1739 /* ------------------------------ Raw data handling ------------------------------ */
1740 raw_data: opt_lvc tBEGIN raw_elements tEND
{
1747 if
(!$3->lvc.language
)
1748 $3->lvc.language
= dup_language
(currentlanguage
);
1755 : tRAWDATA
{ $$
= $1; }
1756 | tNUMBER
{ $$
= int2raw_data
($1); }
1757 | tLNUMBER
{ $$
= long2raw_data
($1); }
1758 | tSTRING
{ $$
= str2raw_data
($1); }
1759 | raw_elements opt_comma tRAWDATA
{ $$
= merge_raw_data
($1, $3); free
($3->data
); free
($3); }
1760 | raw_elements opt_comma tNUMBER
{ $$
= merge_raw_data_int
($1, $3); }
1761 | raw_elements opt_comma tLNUMBER
{ $$
= merge_raw_data_long
($1, $3); }
1762 | raw_elements opt_comma tSTRING
{ $$
= merge_raw_data_str
($1, $3); }
1765 /* File data or raw data */
1766 file_raw: filename
{
1768 $$
->lvc.language
= dup_language
(currentlanguage
);
1770 | raw_data
{ $$
= $1; }
1773 /* ------------------------------ Win32 expressions ------------------------------ */
1774 /* All win16 numbers are also handled here. This is inconsistent with MS'
1775 * resource compiler, but what the heck, its just handy to have.
1777 e_expr
: /* Empty */ { $$
= 0; }
1778 | expr
{ $$
= new_int
($1); }
1781 /* This rule moves ALL s/r conflicts on {bi,u}nary - and + to here */
1782 expr
: xpr
{ $$
= ($1); }
1785 xpr
: xpr
'+' xpr
{ $$
= ($1) + ($3); }
1786 | xpr
'-' xpr
{ $$
= ($1) - ($3); }
1787 | xpr
'|' xpr
{ $$
= ($1) |
($3); }
1788 | xpr
'&' xpr
{ $$
= ($1) & ($3); }
1789 | xpr
'*' xpr
{ $$
= ($1) * ($3); }
1790 | xpr
'/' xpr
{ $$
= ($1) / ($3); }
1791 | xpr
'^' xpr
{ $$
= ($1) ^
($3); }
1792 |
'~' xpr
{ $$
= ~
($2); }
1793 |
'-' xpr %prec pUPM
{ $$
= -($2); }
1794 |
'+' xpr %prec pUPM
{ $$
= $2; }
1795 |
'(' xpr
')' { $$
= $2; }
1796 | any_num
{ $$
= $1; }
1797 | tNOT any_num
{ $$
= ~
($2); }
1800 any_num
: tNUMBER
{ $$
= $1; }
1801 | tLNUMBER
{ $$
= $1; }
1805 /* Dialog specific functions */
1806 static dialog_t
*dialog_style
(style_t
* st
, dialog_t
*dlg
)
1808 assert
(dlg
!= NULL
);
1809 if
(dlg
->style
== NULL
)
1811 dlg
->style
= new_style
(0,0);
1816 yywarning
("Style already defined, or-ing together");
1820 dlg
->style
->or_mask
= 0;
1821 dlg
->style
->and_mask
= 0;
1823 dlg
->style
->or_mask |
= st
->or_mask
;
1824 dlg
->style
->and_mask |
= st
->and_mask
;
1825 dlg
->gotstyle
= TRUE
;
1830 static dialog_t
*dialog_exstyle
(style_t
*st
, dialog_t
*dlg
)
1832 assert
(dlg
!= NULL
);
1833 if
(dlg
->exstyle
== NULL
)
1835 dlg
->exstyle
= new_style
(0,0);
1840 yywarning
("ExStyle already defined, or-ing together");
1844 dlg
->exstyle
->or_mask
= 0;
1845 dlg
->exstyle
->and_mask
= 0;
1847 dlg
->exstyle
->or_mask |
= st
->or_mask
;
1848 dlg
->exstyle
->and_mask |
= st
->and_mask
;
1849 dlg
->gotexstyle
= TRUE
;
1854 static dialog_t
*dialog_caption
(string_t
*s
, dialog_t
*dlg
)
1856 assert
(dlg
!= NULL
);
1858 yyerror("Caption already defined");
1863 static dialog_t
*dialog_font
(font_id_t
*f
, dialog_t
*dlg
)
1865 assert
(dlg
!= NULL
);
1867 yyerror("Font already defined");
1872 static dialog_t
*dialog_class
(name_id_t
*n
, dialog_t
*dlg
)
1874 assert
(dlg
!= NULL
);
1876 yyerror("Class already defined");
1881 static dialog_t
*dialog_menu
(name_id_t
*m
, dialog_t
*dlg
)
1883 assert
(dlg
!= NULL
);
1885 yyerror("Menu already defined");
1890 static dialog_t
*dialog_language
(language_t
*l
, dialog_t
*dlg
)
1892 assert
(dlg
!= NULL
);
1893 if
(dlg
->lvc.language
)
1894 yyerror("Language already defined");
1895 dlg
->lvc.language
= l
;
1899 static dialog_t
*dialog_characteristics
(characts_t
*c
, dialog_t
*dlg
)
1901 assert
(dlg
!= NULL
);
1902 if
(dlg
->lvc.characts
)
1903 yyerror("Characteristics already defined");
1904 dlg
->lvc.characts
= c
;
1908 static dialog_t
*dialog_version
(version_t
*v
, dialog_t
*dlg
)
1910 assert
(dlg
!= NULL
);
1911 if
(dlg
->lvc.version
)
1912 yyerror("Version already defined");
1913 dlg
->lvc.version
= v
;
1917 /* Controls specific functions */
1918 static control_t
*ins_ctrl
(int type
, int special_style
, control_t
*ctrl
, control_t
*prev
)
1920 /* Hm... this seems to be jammed in at all time... */
1921 int defaultstyle
= WS_CHILD | WS_VISIBLE
;
1923 assert
(ctrl
!= NULL
);
1931 ctrl
->ctlclass
= new_name_id
();
1932 ctrl
->ctlclass
->type
= name_ord
;
1933 ctrl
->ctlclass
->name.i_name
= type
;
1939 if
(special_style
!= BS_GROUPBOX
&& special_style
!= BS_RADIOBUTTON
)
1940 defaultstyle |
= WS_TABSTOP
;
1943 defaultstyle |
= WS_TABSTOP | WS_BORDER
;
1946 defaultstyle |
= LBS_NOTIFY | WS_BORDER
;
1949 defaultstyle |
= CBS_SIMPLE
;
1952 if
(special_style
== SS_CENTER || special_style
== SS_LEFT || special_style
== SS_RIGHT
)
1953 defaultstyle |
= WS_GROUP
;
1957 if
(!ctrl
->gotstyle
) /* Handle default style setting */
1962 defaultstyle |
= ES_LEFT
;
1965 defaultstyle |
= LBS_NOTIFY
;
1968 defaultstyle |
= CBS_SIMPLE | WS_TABSTOP
;
1971 defaultstyle |
= SBS_HORZ
;
1974 switch
(special_style
)
1977 case BS_DEFPUSHBUTTON
:
1980 /* case BS_PUSHBOX: */
1981 case BS_AUTORADIOBUTTON
:
1984 case BS_AUTOCHECKBOX
:
1985 defaultstyle |
= WS_TABSTOP
;
1988 yywarning
("Unknown default button control-style 0x%08x", special_style
);
1989 case BS_RADIOBUTTON
:
1995 switch
(special_style
)
2000 defaultstyle |
= WS_GROUP
;
2002 case SS_ICON
: /* Special case */
2005 yywarning
("Unknown default static control-style 0x%08x", special_style
);
2009 case
-1: /* Generic control */
2013 yyerror("Internal error (report this): Got weird control type 0x%08x", type
);
2017 /* The SS_ICON flag is always forced in for icon controls */
2018 if
(type
== CT_STATIC
&& special_style
== SS_ICON
)
2019 defaultstyle |
= SS_ICON
;
2021 if
(!ctrl
->gotstyle
)
2022 ctrl
->style
= new_style
(0,0);
2024 /* combine all styles */
2025 ctrl
->style
->or_mask
= ctrl
->style
->or_mask | defaultstyle | special_style
;
2026 ctrl
->gotstyle
= TRUE
;
2028 /* combine with NOT mask */
2031 ctrl
->style
->or_mask
&= ~
(ctrl
->style
->and_mask
);
2032 ctrl
->style
->and_mask
= 0;
2034 if
(ctrl
->gotexstyle
)
2036 ctrl
->exstyle
->or_mask
&= ~
(ctrl
->exstyle
->and_mask
);
2037 ctrl
->exstyle
->and_mask
= 0;
2042 static name_id_t
*convert_ctlclass
(name_id_t
*cls
)
2047 if
(cls
->type
== name_ord
)
2049 assert
(cls
->type
== name_str
);
2050 if
(cls
->type
== str_unicode
)
2052 yyerror("Don't yet support unicode class comparison");
2055 cc
= cls
->name.s_name
->str.cstr
;
2057 if
(!strcasecmp
("BUTTON", cc
))
2059 else if
(!strcasecmp
("COMBOBOX", cc
))
2060 iclass
= CT_COMBOBOX
;
2061 else if
(!strcasecmp
("LISTBOX", cc
))
2062 iclass
= CT_LISTBOX
;
2063 else if
(!strcasecmp
("EDIT", cc
))
2065 else if
(!strcasecmp
("STATIC", cc
))
2067 else if
(!strcasecmp
("SCROLLBAR", cc
))
2068 iclass
= CT_SCROLLBAR
;
2070 return cls
; /* No default, return user controlclass */
2072 free
(cls
->name.s_name
->str.cstr
);
2073 free
(cls
->name.s_name
);
2074 cls
->type
= name_ord
;
2075 cls
->name.i_name
= iclass
;
2079 /* DialogEx specific functions */
2080 static dialogex_t
*dialogex_style
(style_t
* st
, dialogex_t
*dlg
)
2082 assert
(dlg
!= NULL
);
2083 if
(dlg
->style
== NULL
)
2085 dlg
->style
= new_style
(0,0);
2090 yywarning
("Style already defined, or-ing together");
2094 dlg
->style
->or_mask
= 0;
2095 dlg
->style
->and_mask
= 0;
2097 dlg
->style
->or_mask |
= st
->or_mask
;
2098 dlg
->style
->and_mask |
= st
->and_mask
;
2099 dlg
->gotstyle
= TRUE
;
2104 static dialogex_t
*dialogex_exstyle
(style_t
* st
, dialogex_t
*dlg
)
2106 assert
(dlg
!= NULL
);
2107 if
(dlg
->exstyle
== NULL
)
2109 dlg
->exstyle
= new_style
(0,0);
2114 yywarning
("ExStyle already defined, or-ing together");
2118 dlg
->exstyle
->or_mask
= 0;
2119 dlg
->exstyle
->and_mask
= 0;
2121 dlg
->exstyle
->or_mask |
= st
->or_mask
;
2122 dlg
->exstyle
->and_mask |
= st
->and_mask
;
2123 dlg
->gotexstyle
= TRUE
;
2128 static dialogex_t
*dialogex_caption
(string_t
*s
, dialogex_t
*dlg
)
2130 assert
(dlg
!= NULL
);
2132 yyerror("Caption already defined");
2137 static dialogex_t
*dialogex_font
(font_id_t
*f
, dialogex_t
*dlg
)
2139 assert
(dlg
!= NULL
);
2141 yyerror("Font already defined");
2146 static dialogex_t
*dialogex_class
(name_id_t
*n
, dialogex_t
*dlg
)
2148 assert
(dlg
!= NULL
);
2150 yyerror("Class already defined");
2155 static dialogex_t
*dialogex_menu
(name_id_t
*m
, dialogex_t
*dlg
)
2157 assert
(dlg
!= NULL
);
2159 yyerror("Menu already defined");
2164 static dialogex_t
*dialogex_language
(language_t
*l
, dialogex_t
*dlg
)
2166 assert
(dlg
!= NULL
);
2167 if
(dlg
->lvc.language
)
2168 yyerror("Language already defined");
2169 dlg
->lvc.language
= l
;
2173 static dialogex_t
*dialogex_characteristics
(characts_t
*c
, dialogex_t
*dlg
)
2175 assert
(dlg
!= NULL
);
2176 if
(dlg
->lvc.characts
)
2177 yyerror("Characteristics already defined");
2178 dlg
->lvc.characts
= c
;
2182 static dialogex_t
*dialogex_version
(version_t
*v
, dialogex_t
*dlg
)
2184 assert
(dlg
!= NULL
);
2185 if
(dlg
->lvc.version
)
2186 yyerror("Version already defined");
2187 dlg
->lvc.version
= v
;
2191 /* Accelerator specific functions */
2192 static event_t
*add_event
(int key
, int id
, int flags
, event_t
*prev
)
2194 event_t
*ev
= new_event
();
2196 if
((flags
& (WRC_AF_VIRTKEY | WRC_AF_ASCII
)) == (WRC_AF_VIRTKEY | WRC_AF_ASCII
))
2197 yyerror("Cannot use both ASCII and VIRTKEY");
2201 ev
->flags
= flags
& ~WRC_AF_ASCII
;
2208 static event_t
*add_string_event
(string_t
*key
, int id
, int flags
, event_t
*prev
)
2211 event_t
*ev
= new_event
();
2213 if
(key
->type
!= str_char
)
2214 yyerror("Key code must be an ascii string");
2216 if
((flags
& WRC_AF_VIRTKEY
) && (!isupper
(key
->str.cstr
[0]) && !isdigit
(key
->str.cstr
[0])))
2217 yyerror("VIRTKEY code is not equal to ascii value");
2219 if
(key
->str.cstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
2221 yyerror("Cannot use both '^' and CONTROL modifier");
2223 else if
(key
->str.cstr
[0] == '^')
2225 keycode
= toupper
(key
->str.cstr
[1]) - '@';
2227 yyerror("Control-code out of range");
2230 keycode
= key
->str.cstr
[0];
2233 ev
->flags
= flags
& ~WRC_AF_ASCII
;
2240 /* MenuEx specific functions */
2241 static itemex_opt_t
*new_itemex_opt
(int id
, int type
, int state
, int helpid
)
2243 itemex_opt_t
*opt
= (itemex_opt_t
*)xmalloc
(sizeof
(itemex_opt_t
));
2247 opt
->helpid
= helpid
;
2251 /* Raw data functions */
2252 static raw_data_t
*load_file
(string_t
*name
)
2256 if
(name
->type
!= str_char
)
2257 yyerror("Filename must be ASCII string");
2259 fp
= open_include
(name
->str.cstr
, 1, NULL
);
2261 yyerror("Cannot open file %s", name
->str.cstr
);
2262 rd
= new_raw_data
();
2263 fseek
(fp
, 0, SEEK_END
);
2264 rd
->size
= ftell
(fp
);
2265 fseek
(fp
, 0, SEEK_SET
);
2266 rd
->data
= (char *)xmalloc
(rd
->size
);
2267 fread
(rd
->data
, rd
->size
, 1, fp
);
2272 static raw_data_t
*int2raw_data
(int i
)
2276 if
((int)((short)i
) != i
)
2277 yywarning
("Integer constant out of 16bit range (%d), truncated to %d\n", i
, (short)i
);
2279 rd
= new_raw_data
();
2280 rd
->size
= sizeof
(short);
2281 rd
->data
= (char *)xmalloc
(rd
->size
);
2284 #ifndef WORDS_BIGENDIAN
2289 *(WORD
*)(rd
->data
) = BYTESWAP_WORD
((WORD
)i
);
2292 *(WORD
*)(rd
->data
) = (WORD
)i
;
2298 static raw_data_t
*long2raw_data
(int i
)
2301 rd
= new_raw_data
();
2302 rd
->size
= sizeof
(int);
2303 rd
->data
= (char *)xmalloc
(rd
->size
);
2306 #ifndef WORDS_BIGENDIAN
2311 *(DWORD
*)(rd
->data
) = BYTESWAP_DWORD
((DWORD
)i
);
2314 *(DWORD
*)(rd
->data
) = (DWORD
)i
;
2320 static raw_data_t
*str2raw_data
(string_t
*str
)
2323 rd
= new_raw_data
();
2324 rd
->size
= str
->size
* (str
->type
== str_char ?
1 : 2);
2325 rd
->data
= (char *)xmalloc
(rd
->size
);
2326 if
(str
->type
== str_char
)
2327 memcpy
(rd
->data
, str
->str.cstr
, rd
->size
);
2328 else if
(str
->type
== str_unicode
)
2333 #ifndef WORDS_BIGENDIAN
2338 for
(i
= 0; i
< str
->size
; i
++)
2339 *(WORD
*)&(rd
->data
[2*i
]) = BYTESWAP_WORD
((WORD
)str
->str.wstr
[i
]);
2342 for
(i
= 0; i
< str
->size
; i
++)
2343 *(WORD
*)&(rd
->data
[2*i
]) = (WORD
)str
->str.wstr
[i
];
2348 internal_error
(__FILE__
, __LINE__
, "Invalid stringtype");
2352 static raw_data_t
*merge_raw_data
(raw_data_t
*r1
, raw_data_t
*r2
)
2354 r1
->data
= xrealloc
(r1
->data
, r1
->size
+ r2
->size
);
2355 memcpy
(r1
->data
+ r1
->size
, r2
->data
, r2
->size
);
2356 r1
->size
+= r2
->size
;
2360 static raw_data_t
*merge_raw_data_int
(raw_data_t
*r1
, int i
)
2362 raw_data_t
*t
= int2raw_data
(i
);
2363 merge_raw_data
(r1
, t
);
2369 static raw_data_t
*merge_raw_data_long
(raw_data_t
*r1
, int i
)
2371 raw_data_t
*t
= long2raw_data
(i
);
2372 merge_raw_data
(r1
, t
);
2378 static raw_data_t
*merge_raw_data_str
(raw_data_t
*r1
, string_t
*str
)
2380 raw_data_t
*t
= str2raw_data
(str
);
2381 merge_raw_data
(r1
, t
);
2387 /* Function the go back in a list to get the head */
2388 static menu_item_t
*get_item_head
(menu_item_t
*p
)
2397 static menuex_item_t
*get_itemex_head
(menuex_item_t
*p
)
2406 static resource_t
*get_resource_head
(resource_t
*p
)
2415 static ver_block_t
*get_ver_block_head
(ver_block_t
*p
)
2424 static ver_value_t
*get_ver_value_head
(ver_value_t
*p
)
2433 static control_t
*get_control_head
(control_t
*p
)
2442 static event_t
*get_event_head
(event_t
*p
)
2451 /* Find a stringtable with given language */
2452 static stringtable_t
*find_stringtable
(lvc_t
*lvc
)
2456 assert
(lvc
!= NULL
);
2459 lvc
->language
= dup_language
(currentlanguage
);
2461 for
(stt
= sttres
; stt
; stt
= stt
->next
)
2463 if
(stt
->lvc.language
->id
== lvc
->language
->id
2464 && stt
->lvc.language
->id
== lvc
->language
->id
)
2466 /* Found a table with the same language */
2467 /* The version and characteristics are now handled
2468 * in the generation of the individual stringtables.
2469 * This enables localized analysis.
2470 if((stt->lvc.version && lvc->version && *(stt->lvc.version) != *(lvc->version))
2471 || (!stt->lvc.version && lvc->version)
2472 || (stt->lvc.version && !lvc->version))
2473 yywarning("Stringtable's versions are not the same, using first definition");
2475 if((stt->lvc.characts && lvc->characts && *(stt->lvc.characts) != *(lvc->characts))
2476 || (!stt->lvc.characts && lvc->characts)
2477 || (stt->lvc.characts && !lvc->characts))
2478 yywarning("Stringtable's characteristics are not the same, using first definition");
2486 /* qsort sorting function for string table entries */
2487 #define STE(p) ((stt_entry_t *)(p))
2488 static int sort_stt_entry
(const void *e1
, const void *e2
)
2490 return STE
(e1
)->id
- STE
(e2
)->id
;
2494 static resource_t
*build_stt_resources
(stringtable_t
*stthead
)
2497 stringtable_t
*newstt
;
2499 resource_t
*rsclist
= NULL
;
2500 resource_t
*rsctail
= NULL
;
2505 characts_t
*characts
;
2511 /* For all languages defined */
2512 for
(stt
= stthead
; stt
; stt
= stt
->next
)
2514 assert
(stt
->nentries
> 0);
2516 /* Sort the entries */
2517 if
(stt
->nentries
> 1)
2518 qsort
(stt
->entries
, stt
->nentries
, sizeof
(stt
->entries
[0]), sort_stt_entry
);
2520 for
(i
= 0; i
< stt
->nentries
; )
2522 newstt
= new_stringtable
(&stt
->lvc
);
2523 newstt
->entries
= (stt_entry_t
*)xmalloc
(16 * sizeof
(stt_entry_t
));
2524 newstt
->nentries
= 16;
2525 newstt
->idbase
= stt
->entries
[i
].id
& ~
0xf;
2526 for
(j
= 0; j
< 16 && i
< stt
->nentries
; j
++)
2528 if
(stt
->entries
[i
].id
- newstt
->idbase
== j
)
2530 newstt
->entries
[j
] = stt
->entries
[i
];
2538 /* Check individual memory options and get
2539 * the first characteristics/version
2541 for
(j
= 0; j
< 16; j
++)
2543 if
(!newstt
->entries
[j
].str
)
2545 andsum
&= newstt
->entries
[j
].memopt
;
2546 orsum |
= newstt
->entries
[j
].memopt
;
2548 characts
= newstt
->entries
[j
].characts
;
2550 version
= newstt
->entries
[j
].version
;
2554 warning
("Stringtable's memory options are not equal (idbase: %d)", newstt
->idbase
);
2556 /* Check version and characteristics */
2557 for
(j
= 0; j
< 16; j
++)
2560 && newstt
->entries
[j
].characts
2561 && *newstt
->entries
[j
].characts
!= *characts
)
2562 warning
("Stringtable's characteristics are not the same (idbase: %d)", newstt
->idbase
);
2564 && newstt
->entries
[j
].version
2565 && *newstt
->entries
[j
].version
!= *version
)
2566 warning
("Stringtable's versions are not the same (idbase: %d)", newstt
->idbase
);
2568 rsc
= new_resource
(res_stt
, newstt
, newstt
->memopt
, newstt
->lvc.language
);
2569 rsc
->name
= new_name_id
();
2570 rsc
->name
->type
= name_ord
;
2571 rsc
->name
->name.i_name
= (newstt
->idbase
>> 4) + 1;
2572 rsc
->memopt
= andsum
; /* Set to least common denominator */
2573 newstt
->memopt
= andsum
;
2574 newstt
->lvc.characts
= characts
;
2575 newstt
->lvc.version
= version
;
2583 rsctail
->next
= rsc
;
2584 rsc
->prev
= rsctail
;
2593 static toolbar_item_t
*ins_tlbr_button
(toolbar_item_t
*prev
, toolbar_item_t
*idrec
)
2602 static toolbar_item_t
*get_tlbr_buttons_head
(toolbar_item_t
*p
, int *nitems
)
2621 static string_t
*make_filename
(string_t
*str
)
2625 if
(str
->type
!= str_char
)
2626 yyerror("Cannot handle UNICODE filenames");
2628 /* Remove escaped backslash and convert to forward */
2629 cptr
= str
->str.cstr
;
2630 for
(cptr
= str
->str.cstr
; (cptr
= strchr
(cptr
, '\\')) != NULL
; cptr
++)
2634 memmove
(cptr
, cptr
+1, strlen
(cptr
));
2640 /* Convert to lower case. Seems to be reasonable to do */
2641 for
(cptr
= str
->str.cstr
; !leave_case
&& *cptr
; cptr
++)
2643 *cptr
= tolower
(*cptr
);
2649 * Process all resources to extract fonts and build
2650 * a fontdir resource.
2652 * Note: MS' resource compiler (build 1472) does not
2653 * handle font resources with different languages.
2654 * The fontdir is generated in the last active language
2655 * and font identifiers must be unique across the entire
2657 * This is not logical considering the localization
2658 * constraints of all other resource types. MS has,
2659 * most probably, never testet localized fonts. However,
2660 * using fontresources is rare, so it might not occur
2661 * in normal applications.
2662 * Wine does require better localization because a lot
2663 * of languages are coded into the same executable.
2664 * Therefore, I will generate fontdirs for *each*
2665 * localized set of fonts.
2667 static resource_t
*build_fontdir
(resource_t
**fnt
, int nfnt
)
2669 static int once
= 0;
2672 warning
("Need to parse fonts, not yet implemented");
2678 static resource_t
*build_fontdirs
(resource_t
*tail
)
2681 resource_t
*lst
= NULL
;
2682 resource_t
**fnt
= NULL
; /* List of all fonts */
2684 resource_t
**fnd
= NULL
; /* List of all fontdirs */
2686 resource_t
**lanfnt
= NULL
;
2693 nid.type
= name_str
;
2694 nid.name.s_name
= &str
;
2695 str.type
= str_char
;
2696 str.str.cstr
= "FONTDIR";
2699 /* Extract all fonts and fontdirs */
2700 for
(rsc
= tail
; rsc
; rsc
= rsc
->prev
)
2702 if
(rsc
->type
== res_fnt
)
2705 fnt
= xrealloc
(fnt
, nfnt
* sizeof
(*fnt
));
2708 else if
(rsc
->type
== res_fntdir
)
2711 fnd
= xrealloc
(fnd
, nfnd
* sizeof
(*fnd
));
2716 /* Verify the name of the present fontdirs */
2717 for
(i
= 0; i
< nfnd
; i
++)
2719 if
(compare_name_id
(&nid
, fnd
[i
]->name
))
2721 warning
("User supplied FONTDIR entry has an invalid name '%s', ignored",
2722 get_nameid_str
(fnd
[i
]->name
));
2731 warning
("Found %d FONTDIR entries without any fonts present", nfnd
);
2736 lanfnt
= xmalloc
(nfnt
* sizeof
(*lanfnt
));
2738 /* Get all fonts covered by fontdirs */
2739 for
(i
= 0; i
< nfnd
; i
++)
2747 for
(j
= 0; j
< nfnt
; j
++)
2751 if
(fnt
[j
]->lan
->id
== fnd
[i
]->lan
->id
&& fnt
[j
]->lan
->sub
== fnd
[i
]->lan
->sub
)
2753 lanfnt
[nlanfnt
] = fnt
[j
];
2759 cnt
= *(WORD
*)fnd
[i
]->res.fnd
->data
->data
;
2762 else if
(nlanfnt
== BYTESWAP_WORD
(cnt
))
2765 error("FONTDIR for language %d,%d has wrong count (%d, expected %d)",
2766 fnd
[i
]->lan
->id
, fnd
[i
]->lan
->sub
, cnt
, nlanfnt
);
2767 #ifdef WORDS_BIGENDIAN
2768 if
((byteorder
== WRC_BO_LITTLE
&& !isswapped
) ||
(byteorder
!= WRC_BO_LITTLE
&& isswapped
))
2770 if
((byteorder
== WRC_BO_BIG
&& !isswapped
) ||
(byteorder
!= WRC_BO_BIG
&& isswapped
))
2773 internal_error
(__FILE__
, __LINE__
, "User supplied FONTDIR needs byteswapping");
2777 /* We now have fonts left where we need to make a fontdir resource */
2778 for
(i
= fntleft
= 0; i
< nfnt
; i
++)
2785 /* Get fonts of same language in lanfnt[] */
2786 for
(i
= nlanfnt
= 0; i
< nfnt
; i
++)
2793 lanfnt
[nlanfnt
] = fnt
[i
];
2798 else if
(fnt
[i
]->lan
->id
== lanfnt
[0]->lan
->id
&& fnt
[i
]->lan
->sub
== lanfnt
[0]->lan
->sub
)
2802 /* and build a fontdir */
2803 rsc
= build_fontdir
(lanfnt
, nlanfnt
);