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 raw_data
{ $$
= 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 filename
{
650 yywarning
("MESSAGETABLE not supported in 16-bit mode");
651 $$
= new_messagetable
(load_file
($2));
655 /* ------------------------------ RCData ------------------------------ */
656 rcdata
: tRCDATA loadmemopts raw_data
{ $$
= new_rcdata
($3, $2); }
659 /* ------------------------------ DLGINIT ------------------------------ */
660 dlginit
: tDLGINIT loadmemopts raw_data
{ $$
= new_dlginit
($3, $2); }
663 /* ------------------------------ UserType ------------------------------ */
664 userres
: usertype loadmemopts file_raw
{ $$
= new_user
($1, $3, $2); }
670 $$
->name.i_name
= $1;
675 $$
->name.s_name
= $1;
679 /* ------------------------------ Accelerator ------------------------------ */
681 : tACCELERATORS loadmemopts opt_lvc tBEGIN events tEND
{
682 $$
= new_accelerator
();
690 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE
;
693 yyerror("Accelerator table must have at least one entry");
694 $$
->events
= get_event_head
($5);
700 if
(!$$
->lvc.language
)
701 $$
->lvc.language
= dup_language
(currentlanguage
);
705 events
: /* Empty */ { $$
=NULL
; }
706 | events tSTRING
',' expr acc_opt
{ $$
=add_string_event
($2, $4, $5, $1); }
707 | events expr
',' expr acc_opt
{ $$
=add_event
($2, $4, $5, $1); }
711 * The empty rule generates a s/r conflict because of {bi,u}nary expr
712 * on - and +. It cannot be solved in any way because it is the same as
713 * the if/then/else problem (LALR(1) problem). The conflict is moved
714 * away by forcing it to be in the expression handling below.
716 acc_opt
: /* Empty */ { $$
= 0; }
717 |
',' accs
{ $$
= $2; }
720 accs
: acc
{ $$
= $1; }
721 | accs
',' acc
{ $$
= $1 |
$3; }
724 acc
: tNOINVERT
{ $$
= WRC_AF_NOINVERT
; }
725 | tSHIFT
{ $$
= WRC_AF_SHIFT
; }
726 | tCONTROL
{ $$
= WRC_AF_CONTROL
; }
727 | tALT
{ $$
= WRC_AF_ALT
; }
728 | tASCII
{ $$
= WRC_AF_ASCII
; }
729 | tVIRTKEY
{ $$
= WRC_AF_VIRTKEY
; }
732 /* ------------------------------ Dialog ------------------------------ */
733 /* FIXME: Support EXSTYLE in the dialog line itself */
734 dialog
: tDIALOG loadmemopts expr
',' expr
',' expr
',' expr dlg_attributes
742 $10->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
747 $10->controls
= get_control_head
($12);
751 $$
->style
->or_mask
= WS_POPUP
;
755 $$
->style
->or_mask |
= WS_CAPTION
;
757 $$
->style
->or_mask |
= DS_SETFONT
;
759 $$
->style
->or_mask
&= ~
($$
->style
->and_mask
);
760 $$
->style
->and_mask
= 0;
762 if
(!$$
->lvc.language
)
763 $$
->lvc.language
= dup_language
(currentlanguage
);
768 : /* Empty */ { $$
=new_dialog
(); }
769 | dlg_attributes tSTYLE style
{ $$
=dialog_style
($3,$1); }
770 | dlg_attributes tEXSTYLE style
{ $$
=dialog_exstyle
($3,$1); }
771 | dlg_attributes tCAPTION tSTRING
{ $$
=dialog_caption
($3,$1); }
772 | dlg_attributes opt_font
{ $$
=dialog_font
($2,$1); }
773 | dlg_attributes tCLASS nameid_s
{ $$
=dialog_class
($3,$1); }
774 | dlg_attributes tCPPCLASS nameid_s
{ $$
=dialog_class
($3,$1); }
775 | dlg_attributes tMENU nameid
{ $$
=dialog_menu
($3,$1); }
776 | dlg_attributes opt_language
{ $$
=dialog_language
($2,$1); }
777 | dlg_attributes opt_characts
{ $$
=dialog_characteristics
($2,$1); }
778 | dlg_attributes opt_version
{ $$
=dialog_version
($2,$1); }
781 ctrls
: /* Empty */ { $$
= NULL
; }
782 | ctrls tCONTROL gen_ctrl
{ $$
=ins_ctrl
(-1, 0, $3, $1); }
783 | ctrls tEDITTEXT ctrl_desc
{ $$
=ins_ctrl
(CT_EDIT
, 0, $3, $1); }
784 | ctrls tLISTBOX ctrl_desc
{ $$
=ins_ctrl
(CT_LISTBOX
, 0, $3, $1); }
785 | ctrls tCOMBOBOX ctrl_desc
{ $$
=ins_ctrl
(CT_COMBOBOX
, 0, $3, $1); }
786 | ctrls tSCROLLBAR ctrl_desc
{ $$
=ins_ctrl
(CT_SCROLLBAR
, 0, $3, $1); }
787 | ctrls tCHECKBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_CHECKBOX
, $3, $1); }
788 | ctrls tDEFPUSHBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $3, $1); }
789 | ctrls tGROUPBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_GROUPBOX
, $3, $1);}
790 | ctrls tPUSHBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_PUSHBUTTON
, $3, $1); }
791 /* | ctrls tPUSHBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
792 | ctrls tRADIOBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_RADIOBUTTON
, $3, $1); }
793 | ctrls tAUTO3STATE lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTO3STATE
, $3, $1); }
794 | ctrls tSTATE3 lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_3STATE
, $3, $1); }
795 | ctrls tAUTOCHECKBOX lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTOCHECKBOX
, $3, $1); }
796 | ctrls tAUTORADIOBUTTON lab_ctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTORADIOBUTTON
, $3, $1); }
797 | ctrls tLTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_LEFT
, $3, $1); }
798 | ctrls tCTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_CENTER
, $3, $1); }
799 | ctrls tRTEXT lab_ctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_RIGHT
, $3, $1); }
800 /* special treatment for icons, as the extent is optional */
801 | ctrls tICON nameid_s opt_comma expr
',' expr
',' expr iconinfo
{
806 $$
= ins_ctrl
(CT_STATIC
, SS_ICON
, $10, $1);
811 : tSTRING opt_comma expr
',' expr
',' expr
',' expr
',' expr optional_style
{
813 $$
->title
= new_name_id
();
814 $$
->title
->type
= name_str
;
815 $$
->title
->name.s_name
= $1;
830 : expr
',' expr
',' expr
',' expr
',' expr optional_style
{
845 iconinfo: /* Empty */
846 { $$
= new_control
(); }
848 |
',' expr
',' expr
{
853 |
',' expr
',' expr
',' style
{
860 |
',' expr
',' expr
',' style
',' style
{
867 $$
->gotexstyle
= TRUE
;
871 gen_ctrl: nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr
',' style
{
875 $$
->ctlclass
= convert_ctlclass
($5);
883 $$
->gotexstyle
= TRUE
;
885 | nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr
{
889 $$
->ctlclass
= convert_ctlclass
($5);
900 : tFONT expr
',' tSTRING
{ $$
= new_font_id
($2, $4, 0, 0); }
903 /* ------------------------------ style flags ------------------------------ */
904 optional_style
/* Abbused once to get optional ExStyle */
905 : /* Empty */ { $$
= NULL
; }
906 |
',' style
{ $$
= $2; }
910 : /* Empty */ { $$
= NULL
; }
911 |
',' style
{ $$
= new_style_pair
($2, 0); }
912 |
',' style
',' style
{ $$
= new_style_pair
($2, $4); }
916 : style
'|' style
{ $$
= new_style
($1->or_mask |
$3->or_mask
, $1->and_mask |
$3->and_mask
); free
($1); free
($3);}
917 |
'(' style
')' { $$
= $2; }
918 | any_num
{ $$
= new_style
($1, 0); }
919 | tNOT any_num
{ $$
= new_style
(0, $2); }
926 $$
->name.i_name
= $1;
931 $$
->name.s_name
= $1;
935 /* ------------------------------ DialogEx ------------------------------ */
936 dialogex: tDIALOGEX loadmemopts expr
',' expr
',' expr
',' expr helpid dlgex_attribs
937 tBEGIN exctrls tEND
{
939 yywarning
("DIALOGEX not supported in 16-bit mode");
946 $11->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
953 $11->helpid
= *($10);
954 $11->gothelpid
= TRUE
;
957 $11->controls
= get_control_head
($13);
960 assert
($$
->style
!= NULL
);
963 $$
->style
->or_mask
= WS_POPUP
;
967 $$
->style
->or_mask |
= WS_CAPTION
;
969 $$
->style
->or_mask |
= DS_SETFONT
;
971 $$
->style
->or_mask
&= ~
($$
->style
->and_mask
);
972 $$
->style
->and_mask
= 0;
974 if
(!$$
->lvc.language
)
975 $$
->lvc.language
= dup_language
(currentlanguage
);
980 : /* Empty */ { $$
=new_dialogex
(); }
981 | dlgex_attribs tSTYLE style
{ $$
=dialogex_style
($3,$1); }
982 | dlgex_attribs tEXSTYLE style
{ $$
=dialogex_exstyle
($3,$1); }
983 | dlgex_attribs tCAPTION tSTRING
{ $$
=dialogex_caption
($3,$1); }
984 | dlgex_attribs opt_font
{ $$
=dialogex_font
($2,$1); }
985 | dlgex_attribs opt_exfont
{ $$
=dialogex_font
($2,$1); }
986 | dlgex_attribs tCLASS nameid_s
{ $$
=dialogex_class
($3,$1); }
987 | dlgex_attribs tCPPCLASS nameid_s
{ $$
=dialogex_class
($3,$1); }
988 | dlgex_attribs tMENU nameid
{ $$
=dialogex_menu
($3,$1); }
989 | dlgex_attribs opt_language
{ $$
=dialogex_language
($2,$1); }
990 | dlgex_attribs opt_characts
{ $$
=dialogex_characteristics
($2,$1); }
991 | dlgex_attribs opt_version
{ $$
=dialogex_version
($2,$1); }
994 exctrls
: /* Empty */ { $$
= NULL
; }
995 | exctrls tCONTROL gen_exctrl
{ $$
=ins_ctrl
(-1, 0, $3, $1); }
996 | exctrls tEDITTEXT exctrl_desc
{ $$
=ins_ctrl
(CT_EDIT
, 0, $3, $1); }
997 | exctrls tLISTBOX exctrl_desc
{ $$
=ins_ctrl
(CT_LISTBOX
, 0, $3, $1); }
998 | exctrls tCOMBOBOX exctrl_desc
{ $$
=ins_ctrl
(CT_COMBOBOX
, 0, $3, $1); }
999 | exctrls tSCROLLBAR exctrl_desc
{ $$
=ins_ctrl
(CT_SCROLLBAR
, 0, $3, $1); }
1000 | exctrls tCHECKBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_CHECKBOX
, $3, $1); }
1001 | exctrls tDEFPUSHBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $3, $1); }
1002 | exctrls tGROUPBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_GROUPBOX
, $3, $1);}
1003 | exctrls tPUSHBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_PUSHBUTTON
, $3, $1); }
1004 /* | exctrls tPUSHBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
1005 | exctrls tRADIOBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_RADIOBUTTON
, $3, $1); }
1006 | exctrls tAUTO3STATE lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTO3STATE
, $3, $1); }
1007 | exctrls tSTATE3 lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_3STATE
, $3, $1); }
1008 | exctrls tAUTOCHECKBOX lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTOCHECKBOX
, $3, $1); }
1009 | exctrls tAUTORADIOBUTTON lab_exctrl
{ $$
=ins_ctrl
(CT_BUTTON
, BS_AUTORADIOBUTTON
, $3, $1); }
1010 | exctrls tLTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_LEFT
, $3, $1); }
1011 | exctrls tCTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_CENTER
, $3, $1); }
1012 | exctrls tRTEXT lab_exctrl
{ $$
=ins_ctrl
(CT_STATIC
, SS_RIGHT
, $3, $1); }
1013 /* special treatment for icons, as the extent is optional */
1014 | exctrls tICON nameid_s opt_comma expr
',' expr
',' expr iconinfo
{
1019 $$
= ins_ctrl
(CT_STATIC
, SS_ICON
, $10, $1);
1024 : nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
','
1025 expr
',' style helpid opt_data
{
1029 $$
->ctlclass
= convert_ctlclass
($5);
1031 $$
->gotstyle
= TRUE
;
1039 $$
->gotexstyle
= TRUE
;
1043 $$
->helpid
= *($18);
1044 $$
->gothelpid
= TRUE
;
1049 | nameid_s opt_comma expr
',' ctlclass
',' style
',' expr
',' expr
',' expr
',' expr opt_data
{
1054 $$
->gotstyle
= TRUE
;
1055 $$
->ctlclass
= convert_ctlclass
($5);
1065 : tSTRING opt_comma expr
',' expr
',' expr
',' expr
',' expr optional_style_pair opt_data
{
1067 $$
->title
= new_name_id
();
1068 $$
->title
->type
= name_str
;
1069 $$
->title
->name.s_name
= $1;
1077 $$
->style
= $12->style
;
1078 $$
->gotstyle
= TRUE
;
1082 $$
->exstyle
= $12->exstyle
;
1083 $$
->gotexstyle
= TRUE
;
1093 : expr
',' expr
',' expr
',' expr
',' expr optional_style_pair opt_data
{
1102 $$
->style
= $10->style
;
1103 $$
->gotstyle
= TRUE
;
1107 $$
->exstyle
= $10->exstyle
;
1108 $$
->gotexstyle
= TRUE
;
1116 opt_data: /* Empty */ { $$
= NULL
; }
1117 | raw_data
{ $$
= $1; }
1120 helpid
: /* Empty */ { $$
= NULL
; }
1121 |
',' expr
{ $$
= new_int
($2); }
1125 : tFONT expr
',' tSTRING
',' expr
',' expr opt_expr
{ $$
= new_font_id
($2, $4, $6, $8); }
1129 * FIXME: This odd expression is here to nullify an extra token found
1130 * in some appstudio produced resources which appear to do nothing.
1132 opt_expr: /* Empty */ { $$
= NULL
; }
1133 |
',' expr
{ $$
= NULL
; }
1136 /* ------------------------------ Menu ------------------------------ */
1137 menu
: tMENU loadmemopts opt_lvc menu_body
{
1139 yyerror("Menu must contain items");
1147 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1148 $$
->items
= get_item_head
($4);
1154 if
(!$$
->lvc.language
)
1155 $$
->lvc.language
= dup_language
(currentlanguage
);
1160 : tBEGIN item_definitions tEND
{ $$
= $2; }
1164 : /* Empty */ {$$
= NULL
;}
1165 | item_definitions tMENUITEM tSTRING opt_comma expr item_options
{
1174 | item_definitions tMENUITEM tSEPARATOR
{
1180 | item_definitions tPOPUP tSTRING item_options menu_body
{
1181 $$
= new_menu_item
();
1185 $$
->popup
= get_item_head
($5);
1190 /* NOTE: item_options is right recursive because it would introduce
1191 * a shift/reduce conflict on ',' in itemex_options due to the
1192 * empty rule here. The parser is now forced to look beyond the ','
1193 * before reducing (force shift).
1194 * Right recursion here is not a problem because we cannot expect
1195 * more than 7 parserstack places to be occupied while parsing this
1196 * (who would want to specify a MF_x flag twice?).
1199 : /* Empty */ { $$
= 0; }
1200 |
',' tCHECKED item_options
{ $$
= $3 | MF_CHECKED
; }
1201 |
',' tGRAYED item_options
{ $$
= $3 | MF_GRAYED
; }
1202 |
',' tHELP item_options
{ $$
= $3 | MF_HELP
; }
1203 |
',' tINACTIVE item_options
{ $$
= $3 | MF_DISABLED
; }
1204 |
',' tMENUBARBREAK item_options
{ $$
= $3 | MF_MENUBARBREAK
; }
1205 |
',' tMENUBREAK item_options
{ $$
= $3 | MF_MENUBREAK
; }
1208 /* ------------------------------ MenuEx ------------------------------ */
1209 menuex
: tMENUEX loadmemopts opt_lvc menuex_body
{
1211 yywarning
("MENUEX not supported in 16-bit mode");
1213 yyerror("MenuEx must contain items");
1221 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE
;
1222 $$
->items
= get_itemex_head
($4);
1228 if
(!$$
->lvc.language
)
1229 $$
->lvc.language
= dup_language
(currentlanguage
);
1234 : tBEGIN itemex_definitions tEND
{ $$
= $2; }
1238 : /* Empty */ {$$
= NULL
; }
1239 | itemex_definitions tMENUITEM tSTRING itemex_options
{
1240 $$
= new_menuex_item
();
1246 $$
->type
= $4->type
;
1247 $$
->state
= $4->state
;
1248 $$
->helpid
= $4->helpid
;
1249 $$
->gotid
= $4->gotid
;
1250 $$
->gottype
= $4->gottype
;
1251 $$
->gotstate
= $4->gotstate
;
1252 $$
->gothelpid
= $4->gothelpid
;
1255 | itemex_definitions tMENUITEM tSEPARATOR
{
1256 $$
= new_menuex_item
();
1261 | itemex_definitions tPOPUP tSTRING itemex_p_options menuex_body
{
1262 $$
= new_menuex_item
();
1266 $$
->popup
= get_itemex_head
($5);
1269 $$
->type
= $4->type
;
1270 $$
->state
= $4->state
;
1271 $$
->helpid
= $4->helpid
;
1272 $$
->gotid
= $4->gotid
;
1273 $$
->gottype
= $4->gottype
;
1274 $$
->gotstate
= $4->gotstate
;
1275 $$
->gothelpid
= $4->gothelpid
;
1281 : /* Empty */ { $$
= new_itemex_opt
(0, 0, 0, 0); }
1283 $$
= new_itemex_opt
($2, 0, 0, 0);
1286 |
',' e_expr
',' e_expr item_options
{
1287 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $5, 0);
1290 $$
->gotstate
= TRUE
;
1294 |
',' e_expr
',' e_expr
',' expr
{
1295 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6, 0);
1298 $$
->gotstate
= TRUE
;
1305 : /* Empty */ { $$
= new_itemex_opt
(0, 0, 0, 0); }
1307 $$
= new_itemex_opt
($2, 0, 0, 0);
1310 |
',' e_expr
',' expr
{
1311 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4, 0, 0);
1316 |
',' e_expr
',' e_expr
',' expr
{
1317 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6, 0);
1322 $$
->gotstate
= TRUE
;
1324 |
',' e_expr
',' e_expr
',' e_expr
',' expr
{
1325 $$
= new_itemex_opt
($2 ?
*($2) : 0, $4 ?
*($4) : 0, $6 ?
*($6) : 0, $8);
1331 $$
->gotstate
= TRUE
;
1332 $$
->gothelpid
= TRUE
;
1336 /* ------------------------------ StringTable ------------------------------ */
1337 /* Stringtables are parsed differently than other resources because their
1338 * layout is substantially different from other resources.
1339 * The table is parsed through a _global_ variable 'tagstt' which holds the
1340 * current stringtable descriptor (stringtable_t *) and 'sttres' that holds a
1341 * list of stringtables of different languages.
1344 : stt_head tBEGIN strings tEND
{
1347 yyerror("Stringtable must have at least one entry");
1352 /* Check if we added to a language table or created
1355 for
(stt
= sttres
; stt
; stt
= stt
->next
)
1362 /* It is a new one */
1365 sttres
->prev
= tagstt
;
1366 tagstt
->next
= sttres
;
1372 /* Else were done */
1376 free
(tagstt_memopt
);
1377 tagstt_memopt
= NULL
;
1384 /* This is to get the language of the currently parsed stringtable */
1385 stt_head: tSTRINGTABLE loadmemopts opt_lvc
{
1386 if
((tagstt
= find_stringtable
($3)) == NULL
)
1387 tagstt
= new_stringtable
($3);
1389 tagstt_version
= $3->version
;
1390 tagstt_characts
= $3->characts
;
1396 strings
: /* Empty */ { $$
= NULL
; }
1397 | strings expr opt_comma tSTRING
{
1399 assert
(tagstt
!= NULL
);
1400 if
($2 > 65535 ||
$2 < -32768)
1401 yyerror("Stringtable entry's ID out of range (%d)", $2);
1402 /* Search for the ID */
1403 for
(i
= 0; i
< tagstt
->nentries
; i
++)
1405 if
(tagstt
->entries
[i
].id
== $2)
1406 yyerror("Stringtable ID %d already in use", $2);
1408 /* If we get here, then we have a new unique entry */
1410 tagstt
->entries
= xrealloc
(tagstt
->entries
, sizeof
(tagstt
->entries
[0]) * tagstt
->nentries
);
1411 tagstt
->entries
[tagstt
->nentries
-1].id
= $2;
1412 tagstt
->entries
[tagstt
->nentries
-1].str
= $4;
1414 tagstt
->entries
[tagstt
->nentries
-1].memopt
= *tagstt_memopt
;
1416 tagstt
->entries
[tagstt
->nentries
-1].memopt
= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE
;
1417 tagstt
->entries
[tagstt
->nentries
-1].version
= tagstt_version
;
1418 tagstt
->entries
[tagstt
->nentries
-1].characts
= tagstt_characts
;
1420 if
(!win32
&& $4->size
> 254)
1421 yyerror("Stringtable entry more than 254 characters");
1422 if
(win32
&& $4->size
> 65534) /* Hmm..., does this happen? */
1423 yyerror("Stringtable entry more than 65534 characters (probably something else that went wrong)");
1428 opt_comma
/* There seem to be two ways to specify a stringtable... */
1433 /* ------------------------------ VersionInfo ------------------------------ */
1435 : tVERSIONINFO loadmemopts fix_version tBEGIN ver_blocks tEND
{
1443 $$
->memopt
= WRC_MO_MOVEABLE |
(win32 ? WRC_MO_PURE
: 0);
1444 $$
->blocks
= get_ver_block_head
($5);
1445 /* Set language; there is no version or characteristics */
1446 $$
->lvc.language
= dup_language
(currentlanguage
);
1451 : /* Empty */ { $$
= new_versioninfo
(); }
1452 | fix_version tFILEVERSION expr
',' expr
',' expr
',' expr
{
1454 yyerror("FILEVERSION already defined");
1456 $$
->filever_maj1
= $3;
1457 $$
->filever_maj2
= $5;
1458 $$
->filever_min1
= $7;
1459 $$
->filever_min2
= $9;
1462 | fix_version tPRODUCTVERSION expr
',' expr
',' expr
',' expr
{
1464 yyerror("PRODUCTVERSION already defined");
1466 $$
->prodver_maj1
= $3;
1467 $$
->prodver_maj2
= $5;
1468 $$
->prodver_min1
= $7;
1469 $$
->prodver_min2
= $9;
1472 | fix_version tFILEFLAGS expr
{
1474 yyerror("FILEFLAGS already defined");
1479 | fix_version tFILEFLAGSMASK expr
{
1481 yyerror("FILEFLAGSMASK already defined");
1483 $$
->fileflagsmask
= $3;
1486 | fix_version tFILEOS expr
{
1488 yyerror("FILEOS already defined");
1493 | fix_version tFILETYPE expr
{
1495 yyerror("FILETYPE already defined");
1500 | fix_version tFILESUBTYPE expr
{
1502 yyerror("FILESUBTYPE already defined");
1504 $$
->filesubtype
= $3;
1510 : /* Empty */ { $$
= NULL
; }
1511 | ver_blocks ver_block
{
1520 : tBLOCK tSTRING tBEGIN ver_values tEND
{
1521 $$
= new_ver_block
();
1523 $$
->values
= get_ver_value_head
($4);
1528 : /* Empty */ { $$
= NULL
; }
1529 | ver_values ver_value
{
1539 $$
= new_ver_value
();
1540 $$
->type
= val_block
;
1541 $$
->value.block
= $1;
1543 | tVALUE tSTRING
',' tSTRING
{
1544 $$
= new_ver_value
();
1549 | tVALUE tSTRING
',' ver_words
{
1550 $$
= new_ver_value
();
1551 $$
->type
= val_words
;
1553 $$
->value.words
= $4;
1558 : expr
{ $$
= new_ver_words
($1); }
1559 | ver_words
',' expr
{ $$
= add_ver_words
($1, $3); }
1562 /* ------------------------------ Toolbar ------------------------------ */
1563 toolbar: tTOOLBAR loadmemopts expr
',' expr opt_lvc tBEGIN toolbar_items tEND
{
1565 toolbar_item_t
*items
= get_tlbr_buttons_head
($8, &nitems
);
1566 $$
= new_toolbar
($3, $5, items
, nitems
);
1574 $$
->memopt
= WRC_MO_MOVEABLE | WRC_MO_PURE
;
1581 if
(!$$
->lvc.language
)
1583 $$
->lvc.language
= dup_language
(currentlanguage
);
1589 : /* Empty */ { $$
= NULL
; }
1590 | toolbar_items tBUTTON expr
{
1591 toolbar_item_t
*idrec
= new_toolbar_item
();
1593 $$
= ins_tlbr_button
($1, idrec
);
1595 | toolbar_items tSEPARATOR
{
1596 toolbar_item_t
*idrec
= new_toolbar_item
();
1598 $$
= ins_tlbr_button
($1, idrec
);
1602 /* ------------------------------ Memory options ------------------------------ */
1604 : /* Empty */ { $$
= NULL
; }
1605 | loadmemopts lamo
{
1615 | loadmemopts lama
{
1624 *$2 &= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE
;
1630 lamo
: tPRELOAD
{ $$
= new_int
(WRC_MO_PRELOAD
); }
1631 | tMOVEABLE
{ $$
= new_int
(WRC_MO_MOVEABLE
); }
1632 | tDISCARDABLE
{ $$
= new_int
(WRC_MO_DISCARDABLE
); }
1633 | tPURE
{ $$
= new_int
(WRC_MO_PURE
); }
1636 lama
: tLOADONCALL
{ $$
= new_int
(~WRC_MO_PRELOAD
); }
1637 | tFIXED
{ $$
= new_int
(~WRC_MO_MOVEABLE
); }
1638 | tIMPURE
{ $$
= new_int
(~WRC_MO_PURE
); }
1641 /* ------------------------------ Win32 options ------------------------------ */
1642 opt_lvc
: /* Empty */ { $$
= new_lvc
(); }
1643 | opt_lvc opt_language
{
1645 yywarning
("LANGUAGE not supported in 16-bit mode");
1647 yyerror("Language already defined");
1651 | opt_lvc opt_characts
{
1653 yywarning
("CHARACTERISTICS not supported in 16-bit mode");
1655 yyerror("Characteristics already defined");
1659 | opt_lvc opt_version
{
1661 yywarning
("VERSION not supported in 16-bit mode");
1663 yyerror("Version already defined");
1670 * This here is another s/r conflict on {bi,u}nary + and -.
1671 * It is due to the look-ahead which must determine when the
1672 * rule opt_language ends. It could be solved with adding a
1673 * tNL at the end, but that seems unreasonable to do.
1674 * The conflict is now moved to the expression handling below.
1677 : tLANGUAGE expr
',' expr
{ $$
= new_language
($2, $4); }
1681 : tCHARACTERISTICS expr
{ $$
= new_characts
($2); }
1685 : tVERSION expr
{ $$
= new_version
($2); }
1688 /* ------------------------------ Raw data handling ------------------------------ */
1689 raw_data: opt_lvc tBEGIN raw_elements tEND
{
1696 if
(!$3->lvc.language
)
1697 $3->lvc.language
= dup_language
(currentlanguage
);
1704 : tRAWDATA
{ $$
= $1; }
1705 | tNUMBER
{ $$
= int2raw_data
($1); }
1706 | tLNUMBER
{ $$
= long2raw_data
($1); }
1707 | tSTRING
{ $$
= str2raw_data
($1); }
1708 | raw_elements opt_comma tRAWDATA
{ $$
= merge_raw_data
($1, $3); free
($3->data
); free
($3); }
1709 | raw_elements opt_comma tNUMBER
{ $$
= merge_raw_data_int
($1, $3); }
1710 | raw_elements opt_comma tLNUMBER
{ $$
= merge_raw_data_long
($1, $3); }
1711 | raw_elements opt_comma tSTRING
{ $$
= merge_raw_data_str
($1, $3); }
1714 /* File data or raw data */
1715 file_raw: filename
{
1717 $$
->lvc.language
= dup_language
(currentlanguage
);
1719 | raw_data
{ $$
= $1; }
1722 /* ------------------------------ Win32 expressions ------------------------------ */
1723 /* All win16 numbers are also handled here. This is inconsistent with MS'
1724 * resource compiler, but what the heck, its just handy to have.
1726 e_expr
: /* Empty */ { $$
= 0; }
1727 | expr
{ $$
= new_int
($1); }
1730 /* This rule moves ALL s/r conflicts on {bi,u}nary - and + to here */
1731 expr
: xpr
{ $$
= ($1); }
1734 xpr
: xpr
'+' xpr
{ $$
= ($1) + ($3); }
1735 | xpr
'-' xpr
{ $$
= ($1) - ($3); }
1736 | xpr
'|' xpr
{ $$
= ($1) |
($3); }
1737 | xpr
'&' xpr
{ $$
= ($1) & ($3); }
1738 | xpr
'*' xpr
{ $$
= ($1) * ($3); }
1739 | xpr
'/' xpr
{ $$
= ($1) / ($3); }
1740 | xpr
'^' xpr
{ $$
= ($1) ^
($3); }
1741 |
'~' xpr
{ $$
= ~
($2); }
1742 |
'-' xpr %prec pUPM
{ $$
= -($2); }
1743 |
'+' xpr %prec pUPM
{ $$
= $2; }
1744 |
'(' xpr
')' { $$
= $2; }
1745 | any_num
{ $$
= $1; }
1746 | tNOT any_num
{ $$
= ~
($2); }
1749 any_num
: tNUMBER
{ $$
= $1; }
1750 | tLNUMBER
{ $$
= $1; }
1754 /* Dialog specific functions */
1755 static dialog_t
*dialog_style
(style_t
* st
, dialog_t
*dlg
)
1757 assert
(dlg
!= NULL
);
1758 if
(dlg
->style
== NULL
)
1760 dlg
->style
= new_style
(0,0);
1765 yywarning
("Style already defined, or-ing together");
1769 dlg
->style
->or_mask
= 0;
1770 dlg
->style
->and_mask
= 0;
1772 dlg
->style
->or_mask |
= st
->or_mask
;
1773 dlg
->style
->and_mask |
= st
->and_mask
;
1774 dlg
->gotstyle
= TRUE
;
1779 static dialog_t
*dialog_exstyle
(style_t
*st
, dialog_t
*dlg
)
1781 assert
(dlg
!= NULL
);
1782 if
(dlg
->exstyle
== NULL
)
1784 dlg
->exstyle
= new_style
(0,0);
1789 yywarning
("ExStyle already defined, or-ing together");
1793 dlg
->exstyle
->or_mask
= 0;
1794 dlg
->exstyle
->and_mask
= 0;
1796 dlg
->exstyle
->or_mask |
= st
->or_mask
;
1797 dlg
->exstyle
->and_mask |
= st
->and_mask
;
1798 dlg
->gotexstyle
= TRUE
;
1803 static dialog_t
*dialog_caption
(string_t
*s
, dialog_t
*dlg
)
1805 assert
(dlg
!= NULL
);
1807 yyerror("Caption already defined");
1812 static dialog_t
*dialog_font
(font_id_t
*f
, dialog_t
*dlg
)
1814 assert
(dlg
!= NULL
);
1816 yyerror("Font already defined");
1821 static dialog_t
*dialog_class
(name_id_t
*n
, dialog_t
*dlg
)
1823 assert
(dlg
!= NULL
);
1825 yyerror("Class already defined");
1830 static dialog_t
*dialog_menu
(name_id_t
*m
, dialog_t
*dlg
)
1832 assert
(dlg
!= NULL
);
1834 yyerror("Menu already defined");
1839 static dialog_t
*dialog_language
(language_t
*l
, dialog_t
*dlg
)
1841 assert
(dlg
!= NULL
);
1842 if
(dlg
->lvc.language
)
1843 yyerror("Language already defined");
1844 dlg
->lvc.language
= l
;
1848 static dialog_t
*dialog_characteristics
(characts_t
*c
, dialog_t
*dlg
)
1850 assert
(dlg
!= NULL
);
1851 if
(dlg
->lvc.characts
)
1852 yyerror("Characteristics already defined");
1853 dlg
->lvc.characts
= c
;
1857 static dialog_t
*dialog_version
(version_t
*v
, dialog_t
*dlg
)
1859 assert
(dlg
!= NULL
);
1860 if
(dlg
->lvc.version
)
1861 yyerror("Version already defined");
1862 dlg
->lvc.version
= v
;
1866 /* Controls specific functions */
1867 static control_t
*ins_ctrl
(int type
, int special_style
, control_t
*ctrl
, control_t
*prev
)
1869 /* Hm... this seems to be jammed in at all time... */
1870 int defaultstyle
= WS_CHILD | WS_VISIBLE
;
1872 assert
(ctrl
!= NULL
);
1880 ctrl
->ctlclass
= new_name_id
();
1881 ctrl
->ctlclass
->type
= name_ord
;
1882 ctrl
->ctlclass
->name.i_name
= type
;
1888 if
(special_style
!= BS_GROUPBOX
&& special_style
!= BS_RADIOBUTTON
)
1889 defaultstyle |
= WS_TABSTOP
;
1892 defaultstyle |
= WS_TABSTOP | WS_BORDER
;
1895 defaultstyle |
= LBS_NOTIFY | WS_BORDER
;
1898 defaultstyle |
= CBS_SIMPLE
;
1901 if
(special_style
== SS_CENTER || special_style
== SS_LEFT || special_style
== SS_RIGHT
)
1902 defaultstyle |
= WS_GROUP
;
1906 if
(!ctrl
->gotstyle
) /* Handle default style setting */
1911 defaultstyle |
= ES_LEFT
;
1914 defaultstyle |
= LBS_NOTIFY
;
1917 defaultstyle |
= CBS_SIMPLE | WS_TABSTOP
;
1920 defaultstyle |
= SBS_HORZ
;
1923 switch
(special_style
)
1926 case BS_DEFPUSHBUTTON
:
1929 /* case BS_PUSHBOX: */
1930 case BS_AUTORADIOBUTTON
:
1933 case BS_AUTOCHECKBOX
:
1934 defaultstyle |
= WS_TABSTOP
;
1937 yywarning
("Unknown default button control-style 0x%08x", special_style
);
1938 case BS_RADIOBUTTON
:
1944 switch
(special_style
)
1949 defaultstyle |
= WS_GROUP
;
1951 case SS_ICON
: /* Special case */
1954 yywarning
("Unknown default static control-style 0x%08x", special_style
);
1958 case
-1: /* Generic control */
1962 yyerror("Internal error (report this): Got weird control type 0x%08x", type
);
1966 /* The SS_ICON flag is always forced in for icon controls */
1967 if
(type
== CT_STATIC
&& special_style
== SS_ICON
)
1968 defaultstyle |
= SS_ICON
;
1970 if
(!ctrl
->gotstyle
)
1971 ctrl
->style
= new_style
(0,0);
1973 /* combine all styles */
1974 ctrl
->style
->or_mask
= ctrl
->style
->or_mask | defaultstyle | special_style
;
1975 ctrl
->gotstyle
= TRUE
;
1977 /* combine with NOT mask */
1980 ctrl
->style
->or_mask
&= ~
(ctrl
->style
->and_mask
);
1981 ctrl
->style
->and_mask
= 0;
1983 if
(ctrl
->gotexstyle
)
1985 ctrl
->exstyle
->or_mask
&= ~
(ctrl
->exstyle
->and_mask
);
1986 ctrl
->exstyle
->and_mask
= 0;
1991 static name_id_t
*convert_ctlclass
(name_id_t
*cls
)
1996 if
(cls
->type
== name_ord
)
1998 assert
(cls
->type
== name_str
);
1999 if
(cls
->type
== str_unicode
)
2001 yyerror("Don't yet support unicode class comparison");
2004 cc
= cls
->name.s_name
->str.cstr
;
2006 if
(!strcasecmp
("BUTTON", cc
))
2008 else if
(!strcasecmp
("COMBOBOX", cc
))
2009 iclass
= CT_COMBOBOX
;
2010 else if
(!strcasecmp
("LISTBOX", cc
))
2011 iclass
= CT_LISTBOX
;
2012 else if
(!strcasecmp
("EDIT", cc
))
2014 else if
(!strcasecmp
("STATIC", cc
))
2016 else if
(!strcasecmp
("SCROLLBAR", cc
))
2017 iclass
= CT_SCROLLBAR
;
2019 return cls
; /* No default, return user controlclass */
2021 free
(cls
->name.s_name
->str.cstr
);
2022 free
(cls
->name.s_name
);
2023 cls
->type
= name_ord
;
2024 cls
->name.i_name
= iclass
;
2028 /* DialogEx specific functions */
2029 static dialogex_t
*dialogex_style
(style_t
* st
, dialogex_t
*dlg
)
2031 assert
(dlg
!= NULL
);
2032 if
(dlg
->style
== NULL
)
2034 dlg
->style
= new_style
(0,0);
2039 yywarning
("Style already defined, or-ing together");
2043 dlg
->style
->or_mask
= 0;
2044 dlg
->style
->and_mask
= 0;
2046 dlg
->style
->or_mask |
= st
->or_mask
;
2047 dlg
->style
->and_mask |
= st
->and_mask
;
2048 dlg
->gotstyle
= TRUE
;
2053 static dialogex_t
*dialogex_exstyle
(style_t
* st
, dialogex_t
*dlg
)
2055 assert
(dlg
!= NULL
);
2056 if
(dlg
->exstyle
== NULL
)
2058 dlg
->exstyle
= new_style
(0,0);
2063 yywarning
("ExStyle already defined, or-ing together");
2067 dlg
->exstyle
->or_mask
= 0;
2068 dlg
->exstyle
->and_mask
= 0;
2070 dlg
->exstyle
->or_mask |
= st
->or_mask
;
2071 dlg
->exstyle
->and_mask |
= st
->and_mask
;
2072 dlg
->gotexstyle
= TRUE
;
2077 static dialogex_t
*dialogex_caption
(string_t
*s
, dialogex_t
*dlg
)
2079 assert
(dlg
!= NULL
);
2081 yyerror("Caption already defined");
2086 static dialogex_t
*dialogex_font
(font_id_t
*f
, dialogex_t
*dlg
)
2088 assert
(dlg
!= NULL
);
2090 yyerror("Font already defined");
2095 static dialogex_t
*dialogex_class
(name_id_t
*n
, dialogex_t
*dlg
)
2097 assert
(dlg
!= NULL
);
2099 yyerror("Class already defined");
2104 static dialogex_t
*dialogex_menu
(name_id_t
*m
, dialogex_t
*dlg
)
2106 assert
(dlg
!= NULL
);
2108 yyerror("Menu already defined");
2113 static dialogex_t
*dialogex_language
(language_t
*l
, dialogex_t
*dlg
)
2115 assert
(dlg
!= NULL
);
2116 if
(dlg
->lvc.language
)
2117 yyerror("Language already defined");
2118 dlg
->lvc.language
= l
;
2122 static dialogex_t
*dialogex_characteristics
(characts_t
*c
, dialogex_t
*dlg
)
2124 assert
(dlg
!= NULL
);
2125 if
(dlg
->lvc.characts
)
2126 yyerror("Characteristics already defined");
2127 dlg
->lvc.characts
= c
;
2131 static dialogex_t
*dialogex_version
(version_t
*v
, dialogex_t
*dlg
)
2133 assert
(dlg
!= NULL
);
2134 if
(dlg
->lvc.version
)
2135 yyerror("Version already defined");
2136 dlg
->lvc.version
= v
;
2140 /* Accelerator specific functions */
2141 static event_t
*add_event
(int key
, int id
, int flags
, event_t
*prev
)
2143 event_t
*ev
= new_event
();
2145 if
((flags
& (WRC_AF_VIRTKEY | WRC_AF_ASCII
)) == (WRC_AF_VIRTKEY | WRC_AF_ASCII
))
2146 yyerror("Cannot use both ASCII and VIRTKEY");
2150 ev
->flags
= flags
& ~WRC_AF_ASCII
;
2157 static event_t
*add_string_event
(string_t
*key
, int id
, int flags
, event_t
*prev
)
2160 event_t
*ev
= new_event
();
2162 if
(key
->type
!= str_char
)
2163 yyerror("Key code must be an ascii string");
2165 if
((flags
& WRC_AF_VIRTKEY
) && (!isupper
(key
->str.cstr
[0]) && !isdigit
(key
->str.cstr
[0])))
2166 yyerror("VIRTKEY code is not equal to ascii value");
2168 if
(key
->str.cstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
2170 yyerror("Cannot use both '^' and CONTROL modifier");
2172 else if
(key
->str.cstr
[0] == '^')
2174 keycode
= toupper
(key
->str.cstr
[1]) - '@';
2176 yyerror("Control-code out of range");
2179 keycode
= key
->str.cstr
[0];
2182 ev
->flags
= flags
& ~WRC_AF_ASCII
;
2189 /* MenuEx specific functions */
2190 static itemex_opt_t
*new_itemex_opt
(int id
, int type
, int state
, int helpid
)
2192 itemex_opt_t
*opt
= (itemex_opt_t
*)xmalloc
(sizeof
(itemex_opt_t
));
2196 opt
->helpid
= helpid
;
2200 /* Raw data functions */
2201 static raw_data_t
*load_file
(string_t
*name
)
2205 if
(name
->type
!= str_char
)
2206 yyerror("Filename must be ASCII string");
2208 fp
= open_include
(name
->str.cstr
, 1, NULL
);
2210 yyerror("Cannot open file %s", name
->str.cstr
);
2211 rd
= new_raw_data
();
2212 fseek
(fp
, 0, SEEK_END
);
2213 rd
->size
= ftell
(fp
);
2214 fseek
(fp
, 0, SEEK_SET
);
2215 rd
->data
= (char *)xmalloc
(rd
->size
);
2216 fread
(rd
->data
, rd
->size
, 1, fp
);
2221 static raw_data_t
*int2raw_data
(int i
)
2225 if
((int)((short)i
) != i
)
2226 yywarning
("Integer constant out of 16bit range (%d), truncated to %d\n", i
, (short)i
);
2228 rd
= new_raw_data
();
2229 rd
->size
= sizeof
(short);
2230 rd
->data
= (char *)xmalloc
(rd
->size
);
2233 #ifndef WORDS_BIGENDIAN
2238 *(WORD
*)(rd
->data
) = BYTESWAP_WORD
((WORD
)i
);
2241 *(WORD
*)(rd
->data
) = (WORD
)i
;
2247 static raw_data_t
*long2raw_data
(int i
)
2250 rd
= new_raw_data
();
2251 rd
->size
= sizeof
(int);
2252 rd
->data
= (char *)xmalloc
(rd
->size
);
2255 #ifndef WORDS_BIGENDIAN
2260 *(DWORD
*)(rd
->data
) = BYTESWAP_DWORD
((DWORD
)i
);
2263 *(DWORD
*)(rd
->data
) = (DWORD
)i
;
2269 static raw_data_t
*str2raw_data
(string_t
*str
)
2272 rd
= new_raw_data
();
2273 rd
->size
= str
->size
* (str
->type
== str_char ?
1 : 2);
2274 rd
->data
= (char *)xmalloc
(rd
->size
);
2275 if
(str
->type
== str_char
)
2276 memcpy
(rd
->data
, str
->str.cstr
, rd
->size
);
2277 else if
(str
->type
== str_unicode
)
2282 #ifndef WORDS_BIGENDIAN
2287 for
(i
= 0; i
< str
->size
; i
++)
2288 *(WORD
*)&(rd
->data
[2*i
]) = BYTESWAP_WORD
((WORD
)str
->str.wstr
[i
]);
2291 for
(i
= 0; i
< str
->size
; i
++)
2292 *(WORD
*)&(rd
->data
[2*i
]) = (WORD
)str
->str.wstr
[i
];
2297 internal_error
(__FILE__
, __LINE__
, "Invalid stringtype");
2301 static raw_data_t
*merge_raw_data
(raw_data_t
*r1
, raw_data_t
*r2
)
2303 r1
->data
= xrealloc
(r1
->data
, r1
->size
+ r2
->size
);
2304 memcpy
(r1
->data
+ r1
->size
, r2
->data
, r2
->size
);
2305 r1
->size
+= r2
->size
;
2309 static raw_data_t
*merge_raw_data_int
(raw_data_t
*r1
, int i
)
2311 raw_data_t
*t
= int2raw_data
(i
);
2312 merge_raw_data
(r1
, t
);
2318 static raw_data_t
*merge_raw_data_long
(raw_data_t
*r1
, int i
)
2320 raw_data_t
*t
= long2raw_data
(i
);
2321 merge_raw_data
(r1
, t
);
2327 static raw_data_t
*merge_raw_data_str
(raw_data_t
*r1
, string_t
*str
)
2329 raw_data_t
*t
= str2raw_data
(str
);
2330 merge_raw_data
(r1
, t
);
2336 /* Function the go back in a list to get the head */
2337 static menu_item_t
*get_item_head
(menu_item_t
*p
)
2346 static menuex_item_t
*get_itemex_head
(menuex_item_t
*p
)
2355 static resource_t
*get_resource_head
(resource_t
*p
)
2364 static ver_block_t
*get_ver_block_head
(ver_block_t
*p
)
2373 static ver_value_t
*get_ver_value_head
(ver_value_t
*p
)
2382 static control_t
*get_control_head
(control_t
*p
)
2391 static event_t
*get_event_head
(event_t
*p
)
2400 /* Find a stringtable with given language */
2401 static stringtable_t
*find_stringtable
(lvc_t
*lvc
)
2405 assert
(lvc
!= NULL
);
2408 lvc
->language
= dup_language
(currentlanguage
);
2410 for
(stt
= sttres
; stt
; stt
= stt
->next
)
2412 if
(stt
->lvc.language
->id
== lvc
->language
->id
2413 && stt
->lvc.language
->id
== lvc
->language
->id
)
2415 /* Found a table with the same language */
2416 /* The version and characteristics are now handled
2417 * in the generation of the individual stringtables.
2418 * This enables localized analysis.
2419 if((stt->lvc.version && lvc->version && *(stt->lvc.version) != *(lvc->version))
2420 || (!stt->lvc.version && lvc->version)
2421 || (stt->lvc.version && !lvc->version))
2422 yywarning("Stringtable's versions are not the same, using first definition");
2424 if((stt->lvc.characts && lvc->characts && *(stt->lvc.characts) != *(lvc->characts))
2425 || (!stt->lvc.characts && lvc->characts)
2426 || (stt->lvc.characts && !lvc->characts))
2427 yywarning("Stringtable's characteristics are not the same, using first definition");
2435 /* qsort sorting function for string table entries */
2436 #define STE(p) ((stt_entry_t *)(p))
2437 static int sort_stt_entry
(const void *e1
, const void *e2
)
2439 return STE
(e1
)->id
- STE
(e2
)->id
;
2443 static resource_t
*build_stt_resources
(stringtable_t
*stthead
)
2446 stringtable_t
*newstt
;
2448 resource_t
*rsclist
= NULL
;
2449 resource_t
*rsctail
= NULL
;
2454 characts_t
*characts
;
2460 /* For all languages defined */
2461 for
(stt
= stthead
; stt
; stt
= stt
->next
)
2463 assert
(stt
->nentries
> 0);
2465 /* Sort the entries */
2466 if
(stt
->nentries
> 1)
2467 qsort
(stt
->entries
, stt
->nentries
, sizeof
(stt
->entries
[0]), sort_stt_entry
);
2469 for
(i
= 0; i
< stt
->nentries
; )
2471 newstt
= new_stringtable
(&stt
->lvc
);
2472 newstt
->entries
= (stt_entry_t
*)xmalloc
(16 * sizeof
(stt_entry_t
));
2473 newstt
->nentries
= 16;
2474 newstt
->idbase
= stt
->entries
[i
].id
& ~
0xf;
2475 for
(j
= 0; j
< 16 && i
< stt
->nentries
; j
++)
2477 if
(stt
->entries
[i
].id
- newstt
->idbase
== j
)
2479 newstt
->entries
[j
] = stt
->entries
[i
];
2487 /* Check individual memory options and get
2488 * the first characteristics/version
2490 for
(j
= 0; j
< 16; j
++)
2492 if
(!newstt
->entries
[j
].str
)
2494 andsum
&= newstt
->entries
[j
].memopt
;
2495 orsum |
= newstt
->entries
[j
].memopt
;
2497 characts
= newstt
->entries
[j
].characts
;
2499 version
= newstt
->entries
[j
].version
;
2503 warning
("Stringtable's memory options are not equal (idbase: %d)", newstt
->idbase
);
2505 /* Check version and characteristics */
2506 for
(j
= 0; j
< 16; j
++)
2509 && newstt
->entries
[j
].characts
2510 && *newstt
->entries
[j
].characts
!= *characts
)
2511 warning
("Stringtable's characteristics are not the same (idbase: %d)", newstt
->idbase
);
2513 && newstt
->entries
[j
].version
2514 && *newstt
->entries
[j
].version
!= *version
)
2515 warning
("Stringtable's versions are not the same (idbase: %d)", newstt
->idbase
);
2517 rsc
= new_resource
(res_stt
, newstt
, newstt
->memopt
, newstt
->lvc.language
);
2518 rsc
->name
= new_name_id
();
2519 rsc
->name
->type
= name_ord
;
2520 rsc
->name
->name.i_name
= (newstt
->idbase
>> 4) + 1;
2521 rsc
->memopt
= andsum
; /* Set to least common denominator */
2522 newstt
->memopt
= andsum
;
2523 newstt
->lvc.characts
= characts
;
2524 newstt
->lvc.version
= version
;
2532 rsctail
->next
= rsc
;
2533 rsc
->prev
= rsctail
;
2542 static toolbar_item_t
*ins_tlbr_button
(toolbar_item_t
*prev
, toolbar_item_t
*idrec
)
2551 static toolbar_item_t
*get_tlbr_buttons_head
(toolbar_item_t
*p
, int *nitems
)
2570 static string_t
*make_filename
(string_t
*str
)
2574 if
(str
->type
!= str_char
)
2575 yyerror("Cannot handle UNICODE filenames");
2577 /* Remove escaped backslash and convert to forward */
2578 cptr
= str
->str.cstr
;
2579 for
(cptr
= str
->str.cstr
; (cptr
= strchr
(cptr
, '\\')) != NULL
; cptr
++)
2583 memmove
(cptr
, cptr
+1, strlen
(cptr
));
2589 /* Convert to lower case. Seems to be reasonable to do */
2590 for
(cptr
= str
->str.cstr
; !leave_case
&& *cptr
; cptr
++)
2592 *cptr
= tolower
(*cptr
);
2598 * Process all resources to extract fonts and build
2599 * a fontdir resource.
2601 * Note: MS' resource compiler (build 1472) does not
2602 * handle font resources with different languages.
2603 * The fontdir is generated in the last active language
2604 * and font identifiers must be unique across the entire
2606 * This is not logical considering the localization
2607 * constraints of all other resource types. MS has,
2608 * most probably, never testet localized fonts. However,
2609 * using fontresources is rare, so it might not occur
2610 * in normal applications.
2611 * Wine does require better localization because a lot
2612 * of languages are coded into the same executable.
2613 * Therefore, I will generate fontdirs for *each*
2614 * localized set of fonts.
2616 static resource_t
*build_fontdir
(resource_t
**fnt
, int nfnt
)
2618 static int once
= 0;
2621 warning
("Need to parse fonts, not yet implemented");
2627 static resource_t
*build_fontdirs
(resource_t
*tail
)
2630 resource_t
*lst
= NULL
;
2631 resource_t
**fnt
= NULL
; /* List of all fonts */
2633 resource_t
**fnd
= NULL
; /* List of all fontdirs */
2635 resource_t
**lanfnt
= NULL
;
2642 nid.type
= name_str
;
2643 nid.name.s_name
= &str
;
2644 str.type
= str_char
;
2645 str.str.cstr
= "FONTDIR";
2648 /* Extract all fonts and fontdirs */
2649 for
(rsc
= tail
; rsc
; rsc
= rsc
->prev
)
2651 if
(rsc
->type
== res_fnt
)
2654 fnt
= xrealloc
(fnt
, nfnt
* sizeof
(*fnt
));
2657 else if
(rsc
->type
== res_fntdir
)
2660 fnd
= xrealloc
(fnd
, nfnd
* sizeof
(*fnd
));
2665 /* Verify the name of the present fontdirs */
2666 for
(i
= 0; i
< nfnd
; i
++)
2668 if
(compare_name_id
(&nid
, fnd
[i
]->name
))
2670 warning
("User supplied FONTDIR entry has an invalid name '%s', ignored",
2671 get_nameid_str
(fnd
[i
]->name
));
2680 warning
("Found %d FONTDIR entries without any fonts present", nfnd
);
2685 lanfnt
= xmalloc
(nfnt
* sizeof
(*lanfnt
));
2687 /* Get all fonts covered by fontdirs */
2688 for
(i
= 0; i
< nfnd
; i
++)
2696 for
(j
= 0; j
< nfnt
; j
++)
2700 if
(fnt
[j
]->lan
->id
== fnd
[i
]->lan
->id
&& fnt
[j
]->lan
->sub
== fnd
[i
]->lan
->sub
)
2702 lanfnt
[nlanfnt
] = fnt
[j
];
2708 cnt
= *(WORD
*)fnd
[i
]->res.fnd
->data
->data
;
2711 else if
(nlanfnt
== BYTESWAP_WORD
(cnt
))
2714 error("FONTDIR for language %d,%d has wrong count (%d, expected %d)",
2715 fnd
[i
]->lan
->id
, fnd
[i
]->lan
->sub
, cnt
, nlanfnt
);
2716 #ifdef WORDS_BIGENDIAN
2717 if
((byteorder
== WRC_BO_LITTLE
&& !isswapped
) ||
(byteorder
!= WRC_BO_LITTLE
&& isswapped
))
2719 if
((byteorder
== WRC_BO_BIG
&& !isswapped
) ||
(byteorder
!= WRC_BO_BIG
&& isswapped
))
2722 internal_error
(__FILE__
, __LINE__
, "User supplied FONTDIR needs byteswapping");
2726 /* We now have fonts left where we need to make a fontdir resource */
2727 for
(i
= fntleft
= 0; i
< nfnt
; i
++)
2734 /* Get fonts of same language in lanfnt[] */
2735 for
(i
= nlanfnt
= 0; i
< nfnt
; i
++)
2742 lanfnt
[nlanfnt
] = fnt
[i
];
2747 else if
(fnt
[i
]->lan
->id
== lanfnt
[0]->lan
->id
&& fnt
[i
]->lan
->sub
== lanfnt
[0]->lan
->sub
)
2751 /* and build a fontdir */
2752 rsc
= build_fontdir
(lanfnt
, nlanfnt
);