Changeset 5522 for trunk/tools
- Timestamp:
- Apr 16, 2001, 7:11:03 PM (24 years ago)
- Location:
- trunk/tools/wrc
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/wrc/Makefile.in
r882 r5522 4 4 SRCDIR = @srcdir@ 5 5 VPATH = @srcdir@ 6 LEXOPT = -Cf #-w -b 7 YACCOPT = #-v 6 8 7 PROGRAMS = wrc @PROGEXT@9 PROGRAMS = wrc 8 10 MODULE = none 9 11 … … 18 20 writeres.c 19 21 22 GEN_C_SRCS = ppy.tab.c lex.ppl.c 20 23 EXTRA_SRCS = parser.y parser.l 21 24 EXTRA_OBJS = y.tab.o lex.yy.o … … 23 26 all: $(PROGRAMS) 24 27 25 depend:: y.tab.h26 27 28 @MAKE_RULES@ 28 29 29 wrc@PROGEXT@: $(OBJS) 30 $(CC) $(CFLAGS) -o wrc@PROGEXT@ $(OBJS) $(LEXLIB) 30 wrc: $(OBJS) $(TOPOBJDIR)/unicode/libwine_unicode.$(LIBEXT) 31 $(CC) $(CFLAGS) -o wrc $(OBJS) $(LIBUNICODE) $(LEXLIB) $(LDFLAGS) 32 33 $(TOPOBJDIR)/unicode/libwine_unicode.$(LIBEXT): 34 cd `dirname $@` && $(MAKE) `basename $@` 31 35 32 36 y.tab.c y.tab.h: parser.y 33 $(YACC) -d -t $(SRCDIR)/parser.y 37 $(YACC) $(YACCOPT) -d -t $(SRCDIR)/parser.y 38 39 ppy.tab.c ppy.tab.h: ppy.y 40 $(YACC) $(YACCOPT) -bppy -ppp -d -t $(SRCDIR)/ppy.y 34 41 35 42 lex.yy.c: parser.l 36 $(LEX) -8 $(SRCDIR)/parser.l 43 $(LEX) $(LEXOPT) -d -8 $(SRCDIR)/parser.l 44 45 lex.ppl.c: ppl.l 46 $(LEX) $(LEXOPT) -d -Ppp -8 -olex.ppl.c $(SRCDIR)/ppl.l 37 47 38 48 clean:: 39 $(RM) y.tab.c y.tab.h lex.yy.c 49 $(RM) ppy.tab.h ppy.output parser.output parser.tab.h lex.backup y.output 50 51 install:: $(PROGRAMS) 52 [ -d $(bindir) ] || $(MKDIR) $(bindir) 53 [ -d $(mandir)/man$(prog_manext) ] || $(MKDIR) $(mandir)/man$(prog_manext) 54 $(INSTALL_DATA) $(SRCDIR)/wrc.man $(mandir)/man$(prog_manext)/wrc.$(prog_manext) 55 $(INSTALL_PROGRAM) wrc $(bindir)/wrc 56 57 uninstall:: 58 $(RM) $(bindir)/wrc $(mandir)/man$(prog_manext)/wrc.$(prog_manext) 40 59 41 60 ### Dependencies: -
trunk/tools/wrc/README.wrc
r882 r5522 1 Release 1. 0.2 of wrc (20-Jun-1998), the wine resource compiler.1 Release 1.1.8 of wrc (24-Aug-2000), the wine resource compiler. 2 2 3 3 See the file CHANGES for differences between the version and what has been … … 6 6 Wrc features: 7 7 8 - source preprocessing8 - full source preprocessing 9 9 - 16 and 32 bit support 10 10 - LANGUAGE support (32 bit only) 11 - almost allresource types are supported11 - most resource types are supported 12 12 - enhanced expression capabilities and resource naming 13 13 - indirect loadable resources 14 14 - NE/PE resource directory generation 15 15 - binary .res file generation/reading 16 - byte-order conversions 16 17 17 18 Wrc generates an assembly file that can be assembled with GNU's gas, or … … 35 36 -D id[=val] Define preprocessor identifier id=val 36 37 -e Disable recognition of win32 keywords in 16bit compile 38 -E Preprocess only 37 39 -g Add symbols to the global c namespace 38 40 -h Also generate a .h file 39 41 -H file Same as -h but written to file 40 42 -I path Set include search dir to path (multiple -I allowed) 41 -l lan Set default language to lan (default is neutral {0 })43 -l lan Set default language to lan (default is neutral {0, 0}) 42 44 -L Leave case of embedded filenames as is 45 -m Do not remap numerical resource IDs 43 46 -n Do not generate .s file 47 -N Do not preprocess input 44 48 -o file Output to file (default is infile.[res|s|h] 45 49 -p prefix Give a prefix for the generated names … … 58 62 * 0x02 Dump internal structures 59 63 * 0x04 Create a parser trace (yydebug=1) 64 * 0x08 Preprocessor messages 65 * 0x10 Preprocessor lex messages 66 * 0x20 Preprocessor yacc trace 60 67 61 68 The -o option only applies to the final destination file, which is … … 65 72 with -o and/or -H, then the output is written to "wrc.tab.[sh]" 66 73 74 For more info see the wrc manpage. 75 67 76 68 77 Preprocessing 69 78 ------------- 70 The build-in preprocessor is not a full implementation of the C counterpart. 71 Wrc does not understand function-type macros. These are discarded as they 72 are scanned. This will be a future project. Wrc does understand these: 73 #define 79 The preprocessor is a fully operational C preprocessor. It handles all 80 directives supported by ANSI-C. It also includes some additions from 81 gcc/egcs. 82 Wrc understands these directives: 83 #define (both simple and macro) 84 #undef 74 85 #if 75 86 #ifdef … … 79 90 #endif 80 91 #error 81 82 Also 'defined' is supported as operator (both with and without parenthesis). 83 '#if' expressions can be anything valid that evaluates to an integer 84 expression (where 0 is false and anything else is true). Others (#pragma, 85 #line) are ignored. A special case '#' generates an error. This is due to 86 the implementation to enable generation of errors on preprocessing and will 87 be improved in the future. 92 #warning 93 #line 94 # 95 #pragma (ignored) 96 #ident (ignored) 97 98 The extensions include '#'-line directives. 99 Not handled at the moment are variable argument macros. They are parsed, 100 but not expanded properly. This will be corrected in the future. 101 102 The preprocessor handles the special defines and aditionally defines an 103 extra set of defines: 104 Define | Value | Comment 105 ---------------+---------------+--------------- 106 RC_INVOKED | 1 | Always defined 107 __FLAT__ | 1 | Only defined if win32 compile 108 __WIN32__ | 1 | Only defined if win32 compile 109 __FILE__ | "..." | Current filename as string 110 __LINE__ | nnn | Current linenumber as integer 111 __TIME__ | "23:59:59" | Timestring of compilation 112 __DATE__ | "May 1 2000" | Datestring of compilation 113 __WRC__ | 1 | Wrc's major version 114 __WRC_MINOR__ | 1 | Wrc's minor version 115 __WRC_MICRO__ | 7 | Wrc's minor version 116 __WRC_PATCH__ | 8 | Alias of __WRC_MICRO__ 117 118 Include-files are not read twice if they are protected with this scheme: 119 #ifndef SOME_DEFINE 120 #define SOME_DEFINE 121 ... 122 #endif 123 This strategy has been borrowed from gcc/egcs and results in significantly 124 reduced preprocessing times (20..30%). There must not be any junk before 125 the first #ifndef and not after the last #endif; comments and whitespace 126 excepted. Wrc will check the existance of the define prior to inclusion to 127 detect "#undef SOME_DEFINE" (notably poppack.h) and act accordingly. 88 128 89 129 … … 106 146 compiler runs on. 107 147 108 Not all resource-types can have local language keywords attached yet 109 (notably: BITMAP, CURSOR, ICON and usertype). This is due to implementation 110 of filename-scanning and the complexity that it poses. This will be changed 111 in the next release. You can work arround this problem by putting a LANGUAGE 112 statement before (and evt. after) the code in the resource file. 148 Language, version and characteristics can be bound to all resource types that 149 have inline data, such as RCDATA. This is an extension to MS' resource 150 compiler, which lacks this support completely. Only VERSIONINFO cannot have 151 version and characteristics attached, but languages are propagated properly if 152 you declare it correctly before the VERSIONINFO resource starts. 153 154 Example: 155 156 1 RCDATA DISCARDABLE 157 LANGUAGE 1, 0 158 VERSION 312 159 CHARACTERISTICS 876 160 { 161 1, 2, 3, 4, 5, "and whatever more data you want" 162 '00 01 02 03 04 05 06 07 08' 163 } 113 164 114 165 … … 116 167 ------------------------ 117 168 All types are supported except for: 118 - FONT 119 - MESSAGETABLE 120 - extensions like TOOLBAR and the like (is this a user-type?) 169 - RT_VXD 170 - RT_PLUGPLAY 171 - RT_HTML 172 - RT_DLGINCLUDE 121 173 122 174 These types will be implemented as soon as I get a proper specification of 123 175 the layout. 124 176 125 Note: Usertype resources with character strings as types have a different 126 layout and do not accept expressions when a numerical type is specified. The 127 must be enclosed in double quotes. These are examples of valid usertype 128 resources: 129 130 MyName "MyType" mydata.bin 131 MyName 12345 mydata.bin 132 MyName "MyType" "mydata.bin" 133 MyName 12345 "mydata.bin" 134 135 MyName "MyType" 136 { 137 ..., data, ... 138 } 139 140 or 141 142 MyName 12345 143 { 144 ..., data, ... 145 } 177 Font type resources (RT_FONT, RT_FONTDIR) are partially supported and will 178 be enhanced when I have the complete spec. The font resources work only if 179 you supply the FONTDIR resource yourself. 146 180 147 181 … … 153 187 * multiply 154 188 / divide 155 + add189 + plus/add 156 190 - minus/substract 157 191 | binary or … … 160 194 NOT ... (sigh) 161 195 162 Minus (-) can both be unary and binary. The NOT operator is (primarily) 163 used to disable window styles but I strongly suggest to refrain from using 164 this operator. 165 There is a shift/reduce conflict on the unary minus, but this is not 166 problematic. I was too lazy to make a new expression parser (next version or 167 so). Unary plus (+) would cause another confilct, so I let it out for now. 196 Plus (+) and minus (-) can both be unary and binary. The NOT operator is 197 (primarily) used to disable window styles but I strongly suggest to refrain 198 from using this operator. 168 199 169 200 Resource names can be both numerical (expressions) and character typed. Wrc 170 does support sthis insane (deep sigh) construct:201 does support this insane (deep sigh) construct: 171 202 172 203 MENU MENU … … 248 279 - No codepage translation 249 280 - UNICODE translations are not/not correct implemented 250 - No documentation ('wrc -?' gives command-line options though)281 - No documentation ('wrc -?' gives command-line options and a manpage) 251 282 - grep for FIXME in the source 252 283 - Memory options are wrong under some conditions. There seems to be a 253 different action for win32 and win16 .254 - User-type resources have slightly different layout.255 - Filename scanning is still hopeless.284 different action for win32 and win16 285 - PUSHBOX control is unsupported. The MS docs use it plenty, but neither 286 MS' nor Borland's compiler supports it. 256 287 257 288 Reporting bugs and patches -
trunk/tools/wrc/dumpres.c
r3426 r5522 47 47 case res_dlginit: return "DLGINIT"; 48 48 case res_toolbar: return "TOOLBAR"; 49 case res_anicur: return "CURSOR (animated)"; 50 case res_aniico: return "ICON (animated)"; 49 51 default: return "Unknown"; 50 52 } … … 153 155 ***************************************************************************** 154 156 */ 155 void dump_memopt(DWORD memopt)157 static void dump_memopt(DWORD memopt) 156 158 { 157 159 printf("Memory/load options: "); … … 184 186 ***************************************************************************** 185 187 */ 186 void dump_lvc(lvc_t *l)188 static void dump_lvc(lvc_t *l) 187 189 { 188 190 if(l->language) … … 213 215 ***************************************************************************** 214 216 */ 215 void dump_raw_data(raw_data_t *d)216 { 217 int n;217 static void dump_raw_data(raw_data_t *d) 218 { 219 unsigned int n; 218 220 int i; 219 221 int j; … … 236 238 printf("- "); 237 239 for(i = 0; i < 16; i++) 238 printf("%c", isprint(d->data[n-16+i] ) ? d->data[n-16+i] : '.');240 printf("%c", isprint(d->data[n-16+i] & 0xff) ? d->data[n-16+i] : '.'); 239 241 printf("\n%08x: ", n); 240 242 } … … 249 251 j = 16; 250 252 for(i = 0; i < j; i++) 251 printf("%c", isprint(d->data[n-j+i] ) ? d->data[n-j+i] : '.');253 printf("%c", isprint(d->data[n-j+i] & 0xff) ? d->data[n-j+i] : '.'); 252 254 printf("\n"); 253 255 } … … 264 266 ***************************************************************************** 265 267 */ 266 void dump_accelerator(accelerator_t *acc)268 static void dump_accelerator(accelerator_t *acc) 267 269 { 268 270 event_t *ev = acc->events; … … 298 300 ***************************************************************************** 299 301 */ 300 void dump_cursor(cursor_t *cur)302 static void dump_cursor(cursor_t *cur) 301 303 { 302 304 printf("Id: %d\n", cur->id); … … 319 321 ***************************************************************************** 320 322 */ 321 void dump_cursor_group(cursor_group_t *curg)323 static void dump_cursor_group(cursor_group_t *curg) 322 324 { 323 325 dump_memopt(curg->memopt); … … 336 338 ***************************************************************************** 337 339 */ 338 void dump_icon(icon_t *ico)340 static void dump_icon(icon_t *ico) 339 341 { 340 342 printf("Id: %d\n", ico->id); … … 358 360 ***************************************************************************** 359 361 */ 360 void dump_icon_group(icon_group_t *icog)362 static void dump_icon_group(icon_group_t *icog) 361 363 { 362 364 dump_memopt(icog->memopt); … … 366 368 /* 367 369 ***************************************************************************** 370 * Function : dump_ani_curico 371 * Syntax : void dump_ani_curico(ani_curico_t *ani) 372 * Input : 373 * ani - Animated object resource descriptor 374 * Output : nop 375 * Description : 376 * Remarks : 377 ***************************************************************************** 378 */ 379 static void dump_ani_curico(ani_curico_t *ani) 380 { 381 dump_memopt(ani->memopt); 382 dump_lvc(&ani->data->lvc); 383 dump_raw_data(ani->data); 384 } 385 386 /* 387 ***************************************************************************** 368 388 * Function : dump_font 369 389 * Syntax : void dump_font(font_t *fnt) … … 375 395 ***************************************************************************** 376 396 */ 377 void dump_font(font_t *fnt)397 static void dump_font(font_t *fnt) 378 398 { 379 399 dump_memopt(fnt->memopt); 400 dump_lvc(&(fnt->data->lvc)); 380 401 dump_raw_data(fnt->data); 381 402 } … … 392 413 ***************************************************************************** 393 414 */ 394 void dump_bitmap(bitmap_t *bmp)415 static void dump_bitmap(bitmap_t *bmp) 395 416 { 396 417 dump_memopt(bmp->memopt); 418 dump_lvc(&(bmp->data->lvc)); 397 419 dump_raw_data(bmp->data); 398 420 } … … 409 431 ***************************************************************************** 410 432 */ 411 void dump_rcdata(rcdata_t *rdt)433 static void dump_rcdata(rcdata_t *rdt) 412 434 { 413 435 dump_memopt(rdt->memopt); 436 dump_lvc(&(rdt->data->lvc)); 414 437 dump_raw_data(rdt->data); 415 438 } … … 426 449 ***************************************************************************** 427 450 */ 428 void dump_user(user_t *usr)451 static void dump_user(user_t *usr) 429 452 { 430 453 dump_memopt(usr->memopt); 454 dump_lvc(&(usr->data->lvc)); 431 455 printf("Class %s\n", get_nameid_str(usr->type)); 432 456 dump_raw_data(usr->data); … … 444 468 ***************************************************************************** 445 469 */ 446 void dump_messagetable(messagetable_t *msg) 447 { 470 static void dump_messagetable(messagetable_t *msg) 471 { 472 dump_memopt(msg->memopt); 473 dump_lvc(&(msg->data->lvc)); 448 474 dump_raw_data(msg->data); 449 475 } … … 460 486 ***************************************************************************** 461 487 */ 462 void dump_stringtable(stringtable_t *stt)488 static void dump_stringtable(stringtable_t *stt) 463 489 { 464 490 int i; … … 492 518 ***************************************************************************** 493 519 */ 494 void dump_control(control_t *ctrl)520 static void dump_control(control_t *ctrl) 495 521 { 496 522 printf("Control {\n\tClass: %s\n", get_nameid_str(ctrl->ctlclass)); … … 531 557 ***************************************************************************** 532 558 */ 533 void dump_dialog(dialog_t *dlg)559 static void dump_dialog(dialog_t *dlg) 534 560 { 535 561 control_t *c = dlg->controls; … … 581 607 ***************************************************************************** 582 608 */ 583 void dump_dialogex(dialogex_t *dlgex)609 static void dump_dialogex(dialogex_t *dlgex) 584 610 { 585 611 control_t *c = dlgex->controls; … … 631 657 ***************************************************************************** 632 658 */ 633 void dump_menu_item(menu_item_t *item)659 static void dump_menu_item(menu_item_t *item) 634 660 { 635 661 while(item) … … 669 695 ***************************************************************************** 670 696 */ 671 void dump_menu(menu_t *men)697 static void dump_menu(menu_t *men) 672 698 { 673 699 dump_memopt(men->memopt); … … 686 712 ***************************************************************************** 687 713 */ 688 void dump_menuex_item(menuex_item_t *item)714 static void dump_menuex_item(menuex_item_t *item) 689 715 { 690 716 while(item) … … 739 765 ***************************************************************************** 740 766 */ 741 void dump_menuex(menuex_t *menex)767 static void dump_menuex(menuex_t *menex) 742 768 { 743 769 dump_memopt(menex->memopt); … … 756 782 ***************************************************************************** 757 783 */ 758 void dump_ver_value(ver_value_t *val) 759 { 760 extern void dump_ver_block(ver_block_t *); 784 static void dump_ver_block(ver_block_t *); /* Forward ref */ 785 786 static void dump_ver_value(ver_value_t *val) 787 { 761 788 if(val->type == val_str) 762 789 { … … 792 819 ***************************************************************************** 793 820 */ 794 void dump_ver_block(ver_block_t *blk)821 static void dump_ver_block(ver_block_t *blk) 795 822 { 796 823 ver_value_t *val = blk->values; … … 817 844 ***************************************************************************** 818 845 */ 819 void dump_versioninfo(versioninfo_t *ver)846 static void dump_versioninfo(versioninfo_t *ver) 820 847 { 821 848 ver_block_t *blk = ver->blocks; 849 850 dump_lvc(&(ver->lvc)); 822 851 823 852 if(ver->gotit.fv) … … 860 889 ***************************************************************************** 861 890 */ 862 void dump_toolbar_items(toolbar_item_t *items)891 static void dump_toolbar_items(toolbar_item_t *items) 863 892 { 864 893 while(items) … … 886 915 ***************************************************************************** 887 916 */ 888 void dump_toolbar(toolbar_t *toolbar)917 static void dump_toolbar(toolbar_t *toolbar) 889 918 { 890 919 dump_memopt(toolbar->memopt); … … 904 933 ***************************************************************************** 905 934 */ 906 void dump_dlginit(dlginit_t *dit)935 static void dump_dlginit(dlginit_t *dit) 907 936 { 908 937 dump_memopt(dit->memopt); 909 dump_lvc(&(dit-> lvc));938 dump_lvc(&(dit->data->lvc)); 910 939 dump_raw_data(dit->data); 911 940 } … … 997 1026 dump_toolbar(top->res.tbt); 998 1027 break; 1028 case res_anicur: 1029 case res_aniico: 1030 dump_ani_curico(top->res.ani); 1031 break; 999 1032 default: 1000 1033 printf("Report this: Unknown resource type parsed %08x\n", top->type); -
trunk/tools/wrc/dumpres.h
r882 r5522 15 15 char *get_typename(resource_t* r); 16 16 void dump_resources(resource_t *top); 17 char *get_nameid_str(name_id_t *n); 17 18 18 19 #endif -
trunk/tools/wrc/genres.c
r3426 r5522 4 4 * Copyright 1998 Bertho A. Stultiens 5 5 * 6 * 05-May-2000 BS - Added code to support endian conversions. The 7 * extra functions also aid unaligned access, but 8 * this is not yet implemented. 6 9 * 25-May-1998 BS - Added simple unicode -> char conversion for resource 7 10 * names in .s and .h files. … … 20 23 #include "utils.h" 21 24 #include "windef.h" 25 #include "winbase.h" 22 26 #include "wingdi.h" 23 27 #include "winuser.h" 24 28 25 #define SetResSize(res, tag) *(DWORD *)&((res)->data[(tag)]) = \ 26 (res)->size - *(DWORD *)&((res)->data[(tag)]) 29 #define SetResSize(res, tag) set_dword((res), (tag), (res)->size - get_dword((res), (tag))) 27 30 28 31 res_t *new_res(void) … … 64 67 if(res->allocsize - res->size < sizeof(char)) 65 68 grow_res(res, RES_BLOCKSIZE); 66 *(char *)&(res->data[res->size])= (char)c;69 res->data[res->size] = (char)c; 67 70 res->size += sizeof(char); 68 71 } … … 72 75 if(res->allocsize - res->size < sizeof(WORD)) 73 76 grow_res(res, RES_BLOCKSIZE); 74 *(WORD *)&(res->data[res->size]) = (WORD)w; 77 switch(byteorder) 78 { 79 #ifdef WORDS_BIGENDIAN 80 default: 81 #endif 82 case WRC_BO_BIG: 83 res->data[res->size+0] = HIBYTE(w); 84 res->data[res->size+1] = LOBYTE(w); 85 break; 86 87 #ifndef WORDS_BIGENDIAN 88 default: 89 #endif 90 case WRC_BO_LITTLE: 91 res->data[res->size+1] = HIBYTE(w); 92 res->data[res->size+0] = LOBYTE(w); 93 break; 94 } 75 95 res->size += sizeof(WORD); 76 96 } … … 80 100 if(res->allocsize - res->size < sizeof(DWORD)) 81 101 grow_res(res, RES_BLOCKSIZE); 82 *(DWORD *)&(res->data[res->size]) = (DWORD)d; 102 switch(byteorder) 103 { 104 #ifdef WORDS_BIGENDIAN 105 default: 106 #endif 107 case WRC_BO_BIG: 108 res->data[res->size+0] = HIBYTE(HIWORD(d)); 109 res->data[res->size+1] = LOBYTE(HIWORD(d)); 110 res->data[res->size+2] = HIBYTE(LOWORD(d)); 111 res->data[res->size+3] = LOBYTE(LOWORD(d)); 112 break; 113 114 #ifndef WORDS_BIGENDIAN 115 default: 116 #endif 117 case WRC_BO_LITTLE: 118 res->data[res->size+3] = HIBYTE(HIWORD(d)); 119 res->data[res->size+2] = LOBYTE(HIWORD(d)); 120 res->data[res->size+1] = HIBYTE(LOWORD(d)); 121 res->data[res->size+0] = LOBYTE(LOWORD(d)); 122 break; 123 } 83 124 res->size += sizeof(DWORD); 84 125 } … … 88 129 while(res->size & 0x3) 89 130 put_byte(res, 0); 131 } 132 133 /* 134 ***************************************************************************** 135 * Function : set_word 136 * set_dword 137 * Syntax : void set_word(res_t *res, int ofs, unsigned w) 138 * void set_dword(res_t *res, int ofs, unsigned d) 139 * Input : 140 * res - Binary resource to put the data in 141 * ofs - Byte offset in data-array 142 * w, d - Data to put 143 * Output : nop 144 * Description : Set the value of a binary resource data array to a 145 * specific value. 146 * Remarks : 147 ***************************************************************************** 148 */ 149 void set_word(res_t *res, int ofs, unsigned w) 150 { 151 switch(byteorder) 152 { 153 #ifdef WORDS_BIGENDIAN 154 default: 155 #endif 156 case WRC_BO_BIG: 157 res->data[ofs+0] = HIBYTE(w); 158 res->data[ofs+1] = LOBYTE(w); 159 break; 160 161 #ifndef WORDS_BIGENDIAN 162 default: 163 #endif 164 case WRC_BO_LITTLE: 165 res->data[ofs+1] = HIBYTE(w); 166 res->data[ofs+0] = LOBYTE(w); 167 break; 168 } 169 } 170 171 void set_dword(res_t *res, int ofs, unsigned d) 172 { 173 switch(byteorder) 174 { 175 #ifdef WORDS_BIGENDIAN 176 default: 177 #endif 178 case WRC_BO_BIG: 179 res->data[ofs+0] = HIBYTE(HIWORD(d)); 180 res->data[ofs+1] = LOBYTE(HIWORD(d)); 181 res->data[ofs+2] = HIBYTE(LOWORD(d)); 182 res->data[ofs+3] = LOBYTE(LOWORD(d)); 183 break; 184 185 #ifndef WORDS_BIGENDIAN 186 default: 187 #endif 188 case WRC_BO_LITTLE: 189 res->data[ofs+3] = HIBYTE(HIWORD(d)); 190 res->data[ofs+2] = LOBYTE(HIWORD(d)); 191 res->data[ofs+1] = HIBYTE(LOWORD(d)); 192 res->data[ofs+0] = LOBYTE(LOWORD(d)); 193 break; 194 } 195 } 196 197 /* 198 ***************************************************************************** 199 * Function : get_word 200 * get_dword 201 * Syntax : WORD get_word(res_t *res, int ofs) 202 * DWORD get_dword(res_t *res, int ofs) 203 * Input : 204 * res - Binary resource to put the data in 205 * ofs - Byte offset in data-array 206 * Output : The data in native endian 207 * Description : Get the value of a binary resource data array in native 208 * endian. 209 * Remarks : 210 ***************************************************************************** 211 */ 212 WORD get_word(res_t *res, int ofs) 213 { 214 switch(byteorder) 215 { 216 #ifdef WORDS_BIGENDIAN 217 default: 218 #endif 219 case WRC_BO_BIG: 220 return (res->data[ofs+0] << 8) 221 | res->data[ofs+1]; 222 223 #ifndef WORDS_BIGENDIAN 224 default: 225 #endif 226 case WRC_BO_LITTLE: 227 return (res->data[ofs+1] << 8) 228 | res->data[ofs+0]; 229 } 230 } 231 232 DWORD get_dword(res_t *res, int ofs) 233 { 234 switch(byteorder) 235 { 236 #ifdef WORDS_BIGENDIAN 237 default: 238 #endif 239 case WRC_BO_BIG: 240 return (res->data[ofs+0] << 24) 241 | (res->data[ofs+1] << 16) 242 | (res->data[ofs+2] << 8) 243 | res->data[ofs+3]; 244 245 #ifndef WORDS_BIGENDIAN 246 default: 247 #endif 248 case WRC_BO_LITTLE: 249 return (res->data[ofs+3] << 24) 250 | (res->data[ofs+2] << 16) 251 | (res->data[ofs+1] << 8) 252 | res->data[ofs+0]; 253 } 90 254 } 91 255 … … 137 301 ***************************************************************************** 138 302 */ 139 void put_string(res_t *res, string_t *str, enum str_e type, int isterm)303 static void put_string(res_t *res, string_t *str, enum str_e type, int isterm) 140 304 { 141 305 int cnt; … … 149 313 } 150 314 315 str = convert_string(str, type); 151 316 if(str->type == str_unicode && type == str_unicode) 152 317 { … … 197 362 put_word(res, 0); 198 363 } 364 free(str); 199 365 } 200 366 … … 255 421 else 256 422 put_dword(res, 0); 423 if(lvc && lvc->language) 424 set_language( lvc->language->id, lvc->language->sub ); 425 else if (currentlanguage) 426 set_language( currentlanguage->id, currentlanguage->sub ); 427 else 428 set_language( LANG_NEUTRAL, SUBLANG_NEUTRAL ); 257 429 } 258 430 … … 314 486 put_word(res, memopt); /* Memory options */ 315 487 put_lvc(res, lvc); /* Language, version and characts */ 316 ((DWORD *)res->data)[0] = res->size; /* Set preliminary resource */317 ((DWORD *)res->data)[1] = res->size; /* Set HeaderSize */488 set_dword(res, 0*sizeof(DWORD), res->size); /* Set preliminary resource */ 489 set_dword(res, 1*sizeof(DWORD), res->size); /* Set HeaderSize */ 318 490 res->dataidx = res->size; 319 491 return 0; … … 333 505 tag = res->size; 334 506 put_dword(res, 0); /* ResSize overwritten later*/ 335 *(DWORD *)&(res->data[tag]) = res->size;507 set_dword(res, tag, res->size); 336 508 res->dataidx = res->size; 337 509 return tag; … … 351 523 ***************************************************************************** 352 524 */ 353 res_t *accelerator2res(name_id_t *name, accelerator_t *acc)525 static res_t *accelerator2res(name_id_t *name, accelerator_t *acc) 354 526 { 355 527 int restag; … … 402 574 ***************************************************************************** 403 575 */ 404 res_t *dialog2res(name_id_t *name, dialog_t *dlg)576 static res_t *dialog2res(name_id_t *name, dialog_t *dlg) 405 577 { 406 578 int restag; … … 478 650 } 479 651 /* Set number of controls */ 480 *(WORD *)&((char *)res->data)[tag_nctrl] = (WORD)nctrl;652 set_word(res, tag_nctrl, (WORD)nctrl); 481 653 } 482 654 else /* win16 */ … … 561 733 ***************************************************************************** 562 734 */ 563 res_t *dialogex2res(name_id_t *name, dialogex_t *dlgex)735 static res_t *dialogex2res(name_id_t *name, dialogex_t *dlgex) 564 736 { 565 737 int restag; … … 654 826 } 655 827 /* Set number of controls */ 656 *(WORD *)&((char *)res->data)[tag_nctrl] = (WORD)nctrl;828 set_word(res, tag_nctrl, (WORD)nctrl); 657 829 /* Set ResourceSize */ 658 830 SetResSize(res, restag); … … 679 851 ***************************************************************************** 680 852 */ 681 void menuitem2res(res_t *res, menu_item_t *menitem)853 static void menuitem2res(res_t *res, menu_item_t *menitem) 682 854 { 683 855 menu_item_t *itm = menitem; … … 729 901 ***************************************************************************** 730 902 */ 731 res_t *menu2res(name_id_t *name, menu_t *men)903 static res_t *menu2res(name_id_t *name, menu_t *men) 732 904 { 733 905 int restag; … … 758 930 ***************************************************************************** 759 931 */ 760 void menuexitem2res(res_t *res, menuex_item_t *menitem)932 static void menuexitem2res(res_t *res, menuex_item_t *menitem) 761 933 { 762 934 menuex_item_t *itm = menitem; … … 795 967 ***************************************************************************** 796 968 */ 797 res_t *menuex2res(name_id_t *name, menuex_t *menex)969 static res_t *menuex2res(name_id_t *name, menuex_t *menex) 798 970 { 799 971 int restag; … … 838 1010 ***************************************************************************** 839 1011 */ 840 res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg)1012 static res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg) 841 1013 { 842 1014 int restag; … … 946 1118 ***************************************************************************** 947 1119 */ 948 res_t *cursor2res(cursor_t *cur)1120 static res_t *cursor2res(cursor_t *cur) 949 1121 { 950 1122 int restag; … … 981 1153 ***************************************************************************** 982 1154 */ 983 res_t *icongroup2res(name_id_t *name, icon_group_t *icog)1155 static res_t *icongroup2res(name_id_t *name, icon_group_t *icog) 984 1156 { 985 1157 int restag; … … 1049 1221 ***************************************************************************** 1050 1222 */ 1051 res_t *icon2res(icon_t *ico)1223 static res_t *icon2res(icon_t *ico) 1052 1224 { 1053 1225 int restag; … … 1072 1244 /* 1073 1245 ***************************************************************************** 1246 * Function : anicurico2res 1247 * Syntax : res_t *anicurico2res(name_id_t *name, ani_curico_t *ani) 1248 * Input : 1249 * name - Name/ordinal of the resource 1250 * ani - The animated object descriptor 1251 * Output : New .res format structure 1252 * Description : 1253 * Remarks : The endian of the object's structures have been converted 1254 * by the loader. 1255 * There are rumors that win311 could handle animated stuff. 1256 * That is why they are generated for both win16 and win32 1257 * compile. 1258 ***************************************************************************** 1259 */ 1260 static res_t *anicurico2res(name_id_t *name, ani_curico_t *ani, enum res_e type) 1261 { 1262 int restag; 1263 res_t *res; 1264 assert(name != NULL); 1265 assert(ani != NULL); 1266 1267 res = new_res(); 1268 restag = put_res_header(res, type == res_anicur ? WRC_RT_ANICURSOR : WRC_RT_ANIICON, 1269 NULL, name, ani->memopt, NULL); 1270 put_raw_data(res, ani->data, 0); 1271 /* Set ResourceSize */ 1272 SetResSize(res, restag); 1273 if(win32) 1274 put_pad(res); 1275 return res; 1276 } 1277 1278 /* 1279 ***************************************************************************** 1074 1280 * Function : bitmap2res 1075 1281 * Syntax : res_t *bitmap2res(name_id_t *name, bitmap_t *bmp) … … 1079 1285 * Output : New .res format structure 1080 1286 * Description : 1081 * Remarks : 1082 ***************************************************************************** 1083 */ 1084 res_t *bitmap2res(name_id_t *name, bitmap_t *bmp) 1287 * Remarks : The endian of the bitmap structures have been converted 1288 * by the loader. 1289 ***************************************************************************** 1290 */ 1291 static res_t *bitmap2res(name_id_t *name, bitmap_t *bmp) 1085 1292 { 1086 1293 int restag; … … 1089 1296 assert(bmp != NULL); 1090 1297 1091 HEAPCHECK();1092 1298 res = new_res(); 1093 HEAPCHECK(); 1094 restag = put_res_header(res, WRC_RT_BITMAP, NULL, name, bmp->memopt, NULL); 1095 HEAPCHECK(); 1299 restag = put_res_header(res, WRC_RT_BITMAP, NULL, name, bmp->memopt, &(bmp->data->lvc)); 1096 1300 if(bmp->data->data[0] == 'B' 1097 1301 && bmp->data->data[1] == 'M' … … 1106 1310 put_raw_data(res, bmp->data, 0); 1107 1311 } 1108 HEAPCHECK();1109 1312 /* Set ResourceSize */ 1110 1313 SetResSize(res, restag); 1111 HEAPCHECK(); 1112 if(win32) 1113 put_pad(res); 1114 HEAPCHECK(); 1314 if(win32) 1315 put_pad(res); 1115 1316 return res; 1116 1317 } … … 1125 1326 * Output : New .res format structure 1126 1327 * Description : 1127 * Remarks : 1128 ***************************************************************************** 1129 */ 1130 res_t *font2res(name_id_t *name, font_t *fnt) 1131 { 1328 * Remarks : The data has been prepared just after parsing. 1329 ***************************************************************************** 1330 */ 1331 static res_t *font2res(name_id_t *name, font_t *fnt) 1332 { 1333 int restag; 1334 res_t *res; 1132 1335 assert(name != NULL); 1133 1336 assert(fnt != NULL); 1134 warning("Fonts not yet implemented"); 1135 return NULL; 1337 1338 res = new_res(); 1339 restag = put_res_header(res, WRC_RT_FONT, NULL, name, fnt->memopt, &(fnt->data->lvc)); 1340 put_raw_data(res, fnt->data, 0); 1341 /* Set ResourceSize */ 1342 SetResSize(res, restag); 1343 if(win32) 1344 put_pad(res); 1345 return res; 1346 } 1347 1348 /* 1349 ***************************************************************************** 1350 * Function : fontdir2res 1351 * Syntax : res_t *fontdir2res(name_id_t *name, fontdir_t *fnd) 1352 * Input : 1353 * name - Name/ordinal of the resource 1354 * fntdir - The fontdir descriptor 1355 * Output : New .res format structure 1356 * Description : 1357 * Remarks : The data has been prepared just after parsing. 1358 ***************************************************************************** 1359 */ 1360 static res_t *fontdir2res(name_id_t *name, fontdir_t *fnd) 1361 { 1362 int restag; 1363 res_t *res; 1364 assert(name != NULL); 1365 assert(fnd != NULL); 1366 1367 res = new_res(); 1368 restag = put_res_header(res, WRC_RT_FONTDIR, NULL, name, fnd->memopt, &(fnd->data->lvc)); 1369 put_raw_data(res, fnd->data, 0); 1370 /* Set ResourceSize */ 1371 SetResSize(res, restag); 1372 if(win32) 1373 put_pad(res); 1374 return res; 1136 1375 } 1137 1376 … … 1148 1387 ***************************************************************************** 1149 1388 */ 1150 res_t *rcdata2res(name_id_t *name, rcdata_t *rdt)1389 static res_t *rcdata2res(name_id_t *name, rcdata_t *rdt) 1151 1390 { 1152 1391 int restag; … … 1156 1395 1157 1396 res = new_res(); 1158 restag = put_res_header(res, WRC_RT_RCDATA, NULL, name, rdt->memopt, NULL);1397 restag = put_res_header(res, WRC_RT_RCDATA, NULL, name, rdt->memopt, &(rdt->data->lvc)); 1159 1398 put_raw_data(res, rdt->data, 0); 1160 1399 /* Set ResourceSize */ … … 1174 1413 * Output : New .res format structure 1175 1414 * Description : 1176 * Remarks : 1177 ***************************************************************************** 1178 */ 1179 res_t *messagetable2res(name_id_t *name, messagetable_t *msg) 1180 { 1415 * Remarks : The data has been converted to the appropriate endian 1416 * after is was parsed. 1417 ***************************************************************************** 1418 */ 1419 static res_t *messagetable2res(name_id_t *name, messagetable_t *msg) 1420 { 1421 int restag; 1422 res_t *res; 1181 1423 assert(name != NULL); 1182 1424 assert(msg != NULL); 1183 warning("Messagetable not yet implemented"); 1184 return NULL; 1425 1426 res = new_res(); 1427 restag = put_res_header(res, WRC_RT_MESSAGETABLE, NULL, name, msg->memopt, &(msg->data->lvc)); 1428 put_raw_data(res, msg->data, 0); 1429 /* Set ResourceSize */ 1430 SetResSize(res, restag); 1431 if(win32) 1432 put_pad(res); 1433 return res; 1185 1434 } 1186 1435 … … 1196 1445 ***************************************************************************** 1197 1446 */ 1198 res_t *stringtable2res(stringtable_t *stt)1447 static res_t *stringtable2res(stringtable_t *stt) 1199 1448 { 1200 1449 res_t *res; … … 1219 1468 for(i = 0; i < stt->nentries; i++) 1220 1469 { 1221 if(stt->entries[i].str )1470 if(stt->entries[i].str && stt->entries[i].str->size) 1222 1471 { 1223 if(win32) 1224 put_word(res, stt->entries[i].str->size); 1472 string_t *str = convert_string(stt->entries[i].str, win32 ? str_unicode : str_char); 1473 if(win32) 1474 put_word(res, str->size); 1225 1475 else 1226 put_byte(res, stt->entries[i].str->size); 1227 put_string(res, stt->entries[i].str, win32 ? str_unicode : str_char, FALSE); 1476 put_byte(res, str->size); 1477 put_string(res, str, win32 ? str_unicode : str_char, FALSE); 1478 free(str); 1228 1479 } 1229 1480 else … … 1256 1507 ***************************************************************************** 1257 1508 */ 1258 res_t *user2res(name_id_t *name, user_t *usr)1509 static res_t *user2res(name_id_t *name, user_t *usr) 1259 1510 { 1260 1511 int restag; … … 1264 1515 1265 1516 res = new_res(); 1266 restag = put_res_header(res, 0, usr->type, name, usr->memopt, NULL);1517 restag = put_res_header(res, 0, usr->type, name, usr->memopt, &(usr->data->lvc)); 1267 1518 put_raw_data(res, usr->data, 0); 1268 1519 /* Set ResourceSize */ … … 1285 1536 ***************************************************************************** 1286 1537 */ 1287 void versionblock2res(res_t *res, ver_block_t *blk, int level)1538 static void versionblock2res(res_t *res, ver_block_t *blk, int level) 1288 1539 { 1289 1540 ver_value_t *val; … … 1318 1569 put_string(res, val->value.str, win32 ? str_unicode : str_char, TRUE); 1319 1570 if(win32) 1320 *(WORD *)&(res->data[valvalsizetag]) = (WORD)((res->size - tag) >> 1);1571 set_word(res, valvalsizetag, (WORD)((res->size - tag) >> 1)); 1321 1572 else 1322 *(WORD *)&(res->data[valvalsizetag]) = (WORD)(res->size - tag);1323 *(WORD *)&(res->data[valblksizetag]) = (WORD)(res->size - valblksizetag);1573 set_word(res, valvalsizetag, (WORD)(res->size - tag)); 1574 set_word(res, valblksizetag, (WORD)(res->size - valblksizetag)); 1324 1575 put_pad(res); 1325 1576 } … … 1341 1592 put_word(res, val->value.words->words[i]); 1342 1593 } 1343 *(WORD *)&(res->data[valvalsizetag]) = (WORD)(res->size - tag);1344 *(WORD *)&(res->data[valblksizetag]) = (WORD)(res->size - valblksizetag);1594 set_word(res, valvalsizetag, (WORD)(res->size - tag)); 1595 set_word(res, valblksizetag, (WORD)(res->size - valblksizetag)); 1345 1596 put_pad(res); 1346 1597 } … … 1356 1607 1357 1608 /* Set blocksize */ 1358 *(WORD *)&(res->data[blksizetag]) = (WORD)(res->size - blksizetag);1609 set_word(res, blksizetag, (WORD)(res->size - blksizetag)); 1359 1610 } 1360 1611 … … 1371 1622 ***************************************************************************** 1372 1623 */ 1373 res_t *versioninfo2res(name_id_t *name, versioninfo_t *ver)1624 static res_t *versioninfo2res(name_id_t *name, versioninfo_t *ver) 1374 1625 { 1375 1626 int restag; … … 1389 1640 1390 1641 res = new_res(); 1391 restag = put_res_header(res, WRC_RT_VERSION, NULL, name, WRC_MO_MOVEABLE | WRC_MO_PURE, NULL);1642 restag = put_res_header(res, WRC_RT_VERSION, NULL, name, ver->memopt, &(ver->lvc)); 1392 1643 rootblocksizetag = res->size; 1393 1644 put_word(res, 0); /* BlockSize filled in later */ … … 1414 1665 put_dword(res, 0); /* FileDateLS */ 1415 1666 /* Set ValueSize */ 1416 *(WORD *)&(res->data[valsizetag]) = (WORD)(res->size - tag);1667 set_word(res, valsizetag, (WORD)(res->size - tag)); 1417 1668 /* Descend into the blocks */ 1418 1669 for(blk = ver->blocks; blk; blk = blk->next) 1419 1670 versionblock2res(res, blk, 0); 1420 1671 /* Set root block's size */ 1421 *(WORD *)&(res->data[rootblocksizetag]) = (WORD)(res->size - rootblocksizetag);1672 set_word(res, rootblocksizetag, (WORD)(res->size - rootblocksizetag)); 1422 1673 1423 1674 SetResSize(res, restag); … … 1438 1689 ***************************************************************************** 1439 1690 */ 1440 void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)1691 static void toolbaritem2res(res_t *res, toolbar_item_t *tbitem) 1441 1692 { 1442 1693 toolbar_item_t *itm = tbitem; … … 1462 1713 ***************************************************************************** 1463 1714 */ 1464 res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)1715 static res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar) 1465 1716 { 1466 1717 int restag; … … 1506 1757 ***************************************************************************** 1507 1758 */ 1508 res_t *dlginit2res(name_id_t *name, dlginit_t *dit)1759 static res_t *dlginit2res(name_id_t *name, dlginit_t *dit) 1509 1760 { 1510 1761 int restag; … … 1514 1765 1515 1766 res = new_res(); 1516 restag = put_res_header(res, WRC_RT_DLGINIT, NULL, name, dit->memopt, &(dit-> lvc));1767 restag = put_res_header(res, WRC_RT_DLGINIT, NULL, name, dit->memopt, &(dit->data->lvc)); 1517 1768 put_raw_data(res, dit->data, 0); 1518 1769 /* Set ResourceSize */ … … 1549 1800 for(i = 0; *sptr && i < MAXNAMELEN; i++) 1550 1801 { 1551 if((unsigned)*sptr < 0x80 && isprint( (char)*sptr))1802 if((unsigned)*sptr < 0x80 && isprint(*sptr & 0xff)) 1552 1803 buf[i] = *sptr++; 1553 1804 else … … 1564 1815 for(i = 0; *cptr && i < MAXNAMELEN; i++) 1565 1816 { 1566 if((unsigned)*cptr < 0x80 && isprint(*cptr ))1817 if((unsigned)*cptr < 0x80 && isprint(*cptr & 0xff)) 1567 1818 buf[i] = *cptr++; 1568 1819 else … … 1631 1882 { 1632 1883 case res_acc: return "Acc"; 1884 case res_anicur:return "AniCur"; 1885 case res_aniico:return "AniIco"; 1633 1886 case res_bmp: return "Bmp"; 1634 1887 case res_cur: return "Cur"; … … 1637 1890 case res_dlgex: return "Dlg"; 1638 1891 case res_fnt: return "Fnt"; 1892 case res_fntdir:return "FntDir"; 1639 1893 case res_ico: return "Ico"; 1640 1894 case res_icog: return "IcoGrp"; … … 1696 1950 if(!top->binres) 1697 1951 top->binres = font2res(top->name, top->res.fnt); 1952 break; 1953 case res_fntdir: 1954 if(!top->binres) 1955 top->binres = fontdir2res(top->name, top->res.fnd); 1698 1956 break; 1699 1957 case res_ico: … … 1741 1999 top->binres = dlginit2res(top->name, top->res.dlgi); 1742 2000 break; 1743 2001 case res_anicur: 2002 case res_aniico: 2003 if(!top->binres) 2004 top->binres = anicurico2res(top->name, top->res.ani, top->type); 2005 break; 1744 2006 default: 1745 2007 internal_error(__FILE__, __LINE__, "Unknown resource type encountered %d in binary res generation", top->type); -
trunk/tools/wrc/lexyy.c
r3426 r5522 2 2 3 3 /* Scanner skeleton version: 4 * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/tools/wrc/lexyy.c,v 1. 2 2000-04-19 14:44:58sandervl Exp $4 * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/tools/wrc/lexyy.c,v 1.3 2001-04-16 17:10:49 sandervl Exp $ 5 5 */ 6 6 … … 261 261 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) 262 262 263 264 #define FLEX_DEBUG 263 265 typedef unsigned char YY_CHAR; 264 266 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; 265 267 typedef int yy_state_type; 268 269 #define FLEX_DEBUG 266 270 extern char *yytext; 267 271 #define yytext_ptr yytext … … 282 286 yy_c_buf_p = yy_cp; 283 287 284 #define YY_NUM_RULES 124285 #define YY_END_OF_BUFFER 125286 static yyconst short int yy_accept[ 369] =288 #define YY_NUM_RULES 84 289 #define YY_END_OF_BUFFER 85 290 static yyconst short int yy_accept[162] = 287 291 { 0, 288 0, 0, 66, 66, 0, 0, 0, 0, 0, 0, 289 0, 0, 114, 114, 0, 0, 0, 0, 0, 0, 290 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 291 0, 0, 22, 22, 9, 9, 9, 9, 46, 46, 292 0, 0, 36, 36, 31, 31, 40, 40, 41, 41, 293 125, 122, 121, 120, 122, 88, 122, 107, 122, 56, 294 56, 118, 122, 122, 122, 59, 59, 54, 122, 55, 295 121, 122, 66, 121, 67, 66, 66, 66, 66, 66, 296 66, 123, 69, 68, 102, 90, 89, 106, 87, 72, 297 71, 123, 112, 110, 111, 108, 112, 114, 116, 115, 298 299 4, 123, 4, 4, 8, 6, 14, 22, 9, 12, 300 123, 123, 46, 45, 45, 45, 36, 123, 34, 32, 301 33, 36, 123, 31, 123, 29, 27, 28, 31, 40, 302 37, 38, 123, 40, 44, 41, 43, 42, 121, 63, 303 61, 113, 119, 56, 59, 56, 59, 59, 118, 64, 304 62, 65, 70, 60, 121, 0, 0, 0, 0, 0, 305 0, 0, 0, 66, 66, 66, 66, 66, 66, 66, 306 66, 0, 68, 102, 0, 103, 101, 101, 91, 93, 307 94, 95, 96, 97, 98, 99, 100, 101, 87, 0, 308 84, 83, 83, 73, 75, 76, 77, 78, 79, 80, 309 310 81, 82, 83, 110, 109, 114, 115, 115, 117, 0, 311 0, 7, 6, 14, 22, 9, 10, 0, 11, 46, 312 0, 0, 0, 0, 0, 36, 35, 36, 0, 0, 313 31, 30, 31, 40, 39, 40, 41, 119, 58, 57, 314 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 315 66, 66, 66, 66, 66, 66, 66, 105, 104, 91, 316 93, 0, 86, 85, 73, 75, 0, 3, 2, 10, 317 0, 58, 57, 0, 0, 0, 0, 0, 0, 15, 318 0, 0, 0, 0, 0, 0, 66, 66, 66, 66, 319 66, 66, 53, 91, 92, 73, 0, 0, 0, 18, 320 321 19, 0, 0, 0, 0, 0, 0, 26, 0, 0, 322 66, 48, 66, 66, 66, 66, 73, 0, 0, 0, 323 18, 19, 20, 21, 25, 16, 0, 0, 26, 0, 324 13, 66, 49, 66, 66, 66, 73, 74, 23, 5, 325 20, 21, 25, 16, 17, 0, 24, 13, 66, 66, 326 66, 52, 73, 23, 5, 17, 1, 24, 66, 66, 327 50, 1, 66, 66, 66, 51, 47, 0 292 0, 0, 0, 0, 0, 0, 0, 0, 74, 74, 293 0, 0, 7, 7, 12, 12, 14, 14, 2, 2, 294 85, 82, 81, 80, 46, 67, 24, 24, 20, 20, 295 78, 23, 23, 18, 19, 81, 1, 62, 66, 48, 296 83, 44, 45, 27, 83, 72, 70, 71, 68, 72, 297 74, 76, 75, 83, 7, 8, 83, 5, 3, 4, 298 7, 1, 12, 13, 9, 10, 83, 12, 17, 14, 299 16, 15, 2, 81, 24, 73, 24, 20, 23, 20, 300 23, 23, 78, 25, 81, 1, 1, 62, 47, 63, 301 60, 60, 60, 49, 52, 53, 54, 55, 56, 57, 302 303 58, 59, 60, 44, 26, 41, 39, 39, 39, 28, 304 31, 32, 33, 34, 35, 36, 37, 38, 39, 70, 305 69, 74, 75, 75, 77, 7, 6, 7, 12, 11, 306 12, 14, 2, 79, 24, 22, 21, 65, 61, 64, 307 49, 52, 51, 43, 40, 42, 28, 31, 30, 22, 308 21, 49, 50, 28, 30, 28, 30, 28, 29, 28, 309 0 328 310 } ; 329 311 … … 331 313 { 0, 332 314 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 333 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,315 1, 2, 4, 1, 1, 1, 1, 1, 1, 1, 334 316 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 335 1, 2, 4, 5, 6, 1, 1, 7, 8, 9,336 10, 11, 1, 1, 1,1, 12, 13, 14, 14,337 14, 14, 14, 14, 14, 15, 15, 1, 16, 17,338 18, 19, 1, 1, 20, 21, 22, 23, 24, 25,339 26, 26, 27, 26, 26, 28, 29, 30, 31, 32,340 26, 33, 34, 26, 35, 36, 26, 37, 26, 26,341 1, 38, 1, 1, 26, 1, 39, 40, 41, 42,342 343 43, 44, 45, 26, 46, 26, 26, 47, 48, 49,344 50, 51, 26, 52, 53, 54, 55, 56, 26, 57,345 26, 26, 58, 59, 60, 1, 1, 1, 1, 1,317 1, 2, 1, 5, 6, 1, 1, 1, 7, 8, 318 9, 10, 1, 1, 1, 11, 12, 13, 14, 14, 319 14, 14, 14, 14, 14, 15, 15, 1, 16, 1, 320 1, 1, 1, 1, 17, 17, 17, 17, 17, 17, 321 18, 18, 18, 18, 18, 19, 18, 18, 20, 18, 322 18, 18, 18, 18, 18, 18, 18, 21, 18, 18, 323 1, 22, 1, 1, 18, 1, 23, 24, 17, 17, 324 325 17, 25, 18, 18, 18, 18, 18, 26, 18, 27, 326 20, 18, 18, 28, 18, 29, 18, 30, 18, 31, 327 18, 18, 32, 1, 33, 1, 1, 1, 1, 1, 346 328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 347 329 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … … 360 342 } ; 361 343 362 static yyconst int yy_meta[ 61] =344 static yyconst int yy_meta[34] = 363 345 { 0, 364 1, 2, 3, 1, 4, 5, 1, 1, 6, 7, 365 8, 9, 10, 10, 10, 5, 1, 1, 11, 10, 366 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 367 12, 12, 12, 12, 12, 12, 12, 13, 10, 10, 368 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 369 12, 12, 12, 12, 12, 12, 12, 14, 1, 14 346 1, 1, 2, 1, 3, 4, 1, 5, 5, 6, 347 7, 8, 9, 9, 9, 4, 9, 7, 7, 7, 348 7, 10, 9, 9, 9, 7, 7, 7, 7, 7, 349 7, 11, 11 370 350 } ; 371 351 372 static yyconst short int yy_base[ 425] =352 static yyconst short int yy_base[191] = 373 353 { 0, 374 0, 60, 119, 169, 17, 18, 42, 43, 46, 47, 375 219, 262, 21, 22, 24, 37, 306, 366, 426, 486, 376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 377 0, 0, 1053, 1048, 79, 87, 89, 90, 1030, 1021, 378 1020, 28, 94, 127, 120, 187, 323, 339, 41, 92, 379 1005, 1334, 994, 1334, 977, 1334, 974, 1334, 24, 241, 380 191, 0, 950, 949, 948, 0, 948, 1334, 619, 1334, 381 81, 113, 0, 675, 1334, 10, 59, 83, 85, 103, 382 174, 671, 1334, 1334, 0, 1334, 102, 542, 0, 1334, 383 109, 595, 1334, 673, 1334, 1334, 0, 0, 1334, 126, 384 385 1334, 1334, 0, 0, 1334, 665, 0, 0, 0, 1334, 386 129, 147, 0, 1334, 107, 206, 0, 662, 1334, 1334, 387 1334, 156, 246, 0, 661, 1334, 1334, 1334, 167, 0, 388 1334, 1334, 660, 173, 1334, 668, 1334, 1334, 667, 1334, 389 1334, 1334, 0, 253, 0, 0, 163, 640, 0, 1334, 390 1334, 1334, 1334, 1334, 180, 344, 350, 625, 176, 139, 391 621, 614, 610, 0, 157, 193, 163, 192, 215, 194, 392 247, 653, 1334, 0, 325, 1334, 1334, 652, 281, 323, 393 1334, 1334, 1334, 1334, 1334, 1334, 1334, 0, 0, 326, 394 1334, 1334, 651, 343, 346, 1334, 1334, 1334, 1334, 1334, 395 396 1334, 1334, 0, 648, 1334, 0, 224, 262, 1334, 643, 397 627, 1334, 636, 0, 0, 0, 0, 351, 1334, 0, 398 341, 360, 406, 363, 11, 0, 1334, 392, 412, 419, 399 0, 1334, 407, 0, 1334, 414, 641, 0, 433, 372, 400 598, 43, 599, 588, 595, 465, 596, 587, 594, 590, 401 428, 430, 367, 433, 436, 478, 484, 1334, 1334, 463, 402 468, 0, 1334, 1334, 496, 502, 0, 626, 1334, 0, 403 578, 0, 0, 583, 584, 584, 580, 575, 575, 621, 404 579, 579, 573, 576, 573, 574, 492, 490, 485, 488, 405 500, 490, 0, 515, 1334, 520, 0, 566, 566, 612, 406 407 611, 568, 559, 553, 561, 561, 546, 0, 549, 548, 408 489, 0, 499, 513, 527, 529, 537, 0, 538, 546, 409 586, 573, 534, 524, 0, 469, 424, 409, 0, 409, 410 421, 530, 0, 532, 530, 536, 550, 1334, 0, 416, 411 415, 387, 0, 386, 361, 307, 0, 338, 540, 541, 412 542, 0, 556, 0, 332, 288, 277, 0, 553, 548, 413 0, 244, 555, 556, 563, 0, 0, 1334, 684, 698, 414 712, 726, 740, 754, 768, 782, 796, 810, 824, 838, 415 852, 866, 880, 894, 908, 922, 936, 190, 950, 964, 416 978, 992, 1006, 1020, 1034, 214, 1048, 1062, 1076, 1090, 417 418 1099, 462, 1111, 1125, 1139, 1153, 1167, 1180, 1194, 1207, 419 1221, 1235, 1249, 174, 147, 1263, 135, 93, 29, 1277, 420 16, 1291, 1305, 1319 354 0, 32, 32, 36, 37, 40, 61, 85, 41, 43, 355 0, 0, 108, 140, 171, 186, 45, 53, 183, 182, 356 181, 622, 48, 622, 622, 622, 0, 60, 192, 46, 357 0, 211, 170, 622, 622, 77, 69, 0, 622, 89, 358 242, 0, 622, 99, 275, 622, 78, 622, 622, 0, 359 0, 622, 85, 622, 0, 622, 161, 622, 622, 622, 360 111, 103, 0, 622, 622, 622, 160, 117, 622, 114, 361 622, 622, 0, 123, 0, 622, 308, 108, 0, 0, 362 117, 329, 0, 622, 130, 131, 143, 0, 146, 622, 363 622, 158, 144, 140, 144, 622, 622, 622, 622, 622, 364 365 622, 622, 0, 0, 158, 622, 622, 135, 132, 151, 366 154, 622, 622, 622, 622, 622, 622, 622, 0, 174, 367 622, 0, 172, 181, 622, 0, 622, 195, 0, 622, 368 232, 225, 0, 0, 354, 306, 209, 622, 622, 622, 369 226, 308, 0, 622, 622, 622, 313, 316, 0, 0, 370 0, 320, 622, 323, 0, 334, 0, 352, 622, 358, 371 622, 387, 398, 409, 420, 431, 442, 453, 464, 475, 372 480, 490, 501, 512, 117, 523, 534, 545, 555, 566, 373 577, 588, 599, 113, 103, 610, 97, 87, 81, 51 421 374 } ; 422 375 423 static yyconst short int yy_def[ 425] =376 static yyconst short int yy_def[191] = 424 377 { 0, 425 369, 369, 370, 370, 371, 371, 372, 372, 373, 373, 426 374, 374, 375, 375, 376, 376, 377, 377, 378, 378, 427 379, 379, 379, 379, 379, 379, 379, 379, 379, 379, 428 379, 379, 380, 380, 381, 381, 381, 381, 382, 382, 429 383, 383, 384, 384, 385, 385, 386, 386, 387, 387, 430 368, 368, 368, 368, 368, 368, 368, 368, 368, 388, 431 388, 389, 368, 368, 368, 388, 388, 368, 368, 368, 432 368, 368, 390, 368, 368, 390, 390, 390, 390, 390, 433 390, 391, 368, 368, 392, 368, 368, 393, 394, 368, 434 368, 395, 368, 368, 368, 368, 396, 397, 368, 398, 435 436 368, 368, 399, 400, 368, 401, 402, 403, 404, 368, 437 405, 368, 406, 368, 368, 368, 407, 408, 368, 368, 438 368, 407, 368, 409, 410, 368, 368, 368, 409, 411, 439 368, 368, 412, 411, 368, 368, 368, 368, 368, 368, 440 368, 368, 413, 388, 388, 388, 388, 388, 389, 368, 441 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 442 368, 368, 368, 390, 390, 390, 390, 390, 390, 390, 443 390, 391, 368, 392, 368, 368, 368, 368, 368, 368, 444 368, 368, 368, 368, 368, 368, 368, 414, 394, 368, 445 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 446 447 368, 368, 415, 368, 368, 397, 398, 398, 368, 399, 448 400, 368, 401, 402, 403, 404, 416, 368, 368, 406, 449 368, 368, 368, 368, 368, 407, 368, 407, 368, 368, 450 409, 368, 409, 411, 368, 411, 368, 413, 388, 148, 451 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 452 390, 390, 390, 390, 390, 390, 390, 368, 368, 368, 453 368, 417, 368, 368, 368, 368, 418, 399, 368, 416, 454 368, 388, 388, 368, 368, 368, 368, 368, 368, 368, 455 368, 368, 368, 368, 368, 368, 390, 390, 390, 390, 456 390, 390, 390, 368, 368, 368, 419, 368, 368, 368, 457 458 368, 368, 368, 368, 368, 368, 368, 420, 368, 368, 459 390, 390, 390, 390, 390, 390, 368, 421, 368, 368, 460 368, 368, 368, 368, 422, 368, 368, 368, 420, 368, 461 368, 390, 390, 390, 390, 390, 368, 368, 423, 368, 462 368, 368, 422, 368, 368, 368, 424, 368, 390, 390, 463 390, 390, 368, 423, 368, 368, 368, 424, 390, 390, 464 390, 368, 390, 390, 390, 390, 390, 0, 368, 368, 465 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 466 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 467 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 468 469 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 470 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 471 368, 368, 368, 368 378 161, 1, 162, 162, 163, 163, 164, 164, 165, 165, 379 166, 166, 167, 167, 168, 168, 169, 169, 170, 170, 380 161, 161, 161, 161, 161, 161, 171, 171, 161, 29, 381 172, 29, 32, 161, 161, 161, 161, 173, 161, 161, 382 161, 174, 161, 161, 161, 161, 161, 161, 161, 175, 383 176, 161, 177, 161, 178, 161, 179, 161, 161, 161, 384 178, 161, 180, 161, 161, 161, 181, 180, 161, 161, 385 161, 161, 182, 161, 171, 161, 183, 29, 32, 32, 386 32, 32, 172, 161, 161, 161, 161, 173, 161, 161, 387 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 388 389 161, 161, 184, 174, 161, 161, 161, 161, 161, 161, 390 161, 161, 161, 161, 161, 161, 161, 161, 185, 161, 391 161, 176, 177, 177, 161, 178, 161, 178, 180, 161, 392 180, 161, 182, 186, 183, 32, 82, 161, 161, 161, 393 161, 161, 187, 161, 161, 161, 161, 161, 188, 32, 394 32, 161, 161, 161, 189, 161, 190, 161, 161, 161, 395 0, 161, 161, 161, 161, 161, 161, 161, 161, 161, 396 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 397 161, 161, 161, 161, 161, 161, 161, 161, 161, 161 472 398 } ; 473 399 474 static yyconst short int yy_nxt[ 1395] =400 static yyconst short int yy_nxt[656] = 475 401 { 0, 476 52, 53, 54, 55, 56, 52, 57, 58, 52, 52, 477 52, 59, 60, 61, 61, 62, 63, 64, 65, 83, 478 83, 84, 84, 99, 99, 338, 102, 67, 103, 115, 479 54, 100, 100, 116, 142, 143, 165, 52, 318, 102, 480 104, 103, 136, 137, 86, 86, 87, 87, 90, 90, 481 91, 91, 245, 104, 246, 165, 138, 68, 69, 70, 482 52, 71, 54, 55, 56, 72, 57, 58, 52, 52, 483 52, 59, 60, 61, 61, 62, 63, 64, 65, 88, 484 88, 110, 155, 92, 92, 166, 156, 67, 275, 110, 485 111, 110, 110, 136, 137, 276, 54, 52, 111, 102, 486 487 111, 111, 297, 175, 166, 118, 176, 138, 221, 119, 488 190, 167, 222, 191, 157, 168, 112, 68, 69, 70, 489 74, 54, 54, 75, 112, 102, 112, 112, 122, 54, 490 167, 125, 123, 169, 168, 126, 208, 209, 118, 142, 491 143, 76, 119, 77, 295, 78, 79, 80, 218, 219, 492 81, 120, 169, 121, 158, 159, 267, 228, 160, 161, 493 76, 229, 77, 162, 78, 79, 80, 163, 233, 81, 494 74, 54, 229, 75, 236, 239, 239, 127, 229, 128, 495 245, 155, 246, 262, 120, 156, 121, 247, 129, 54, 496 251, 76, 123, 77, 253, 78, 79, 80, 125, 145, 497 498 81, 145, 126, 144, 144, 144, 170, 223, 171, 251, 499 76, 254, 77, 253, 78, 79, 80, 256, 146, 81, 500 94, 95, 242, 205, 243, 170, 96, 244, 171, 252, 501 254, 97, 97, 97, 368, 368, 256, 146, 97, 97, 502 97, 97, 97, 97, 127, 362, 128, 230, 224, 252, 503 255, 225, 161, 144, 144, 144, 162, 97, 97, 97, 504 97, 97, 97, 94, 95, 144, 144, 144, 146, 96, 505 255, 147, 208, 209, 97, 97, 97, 148, 362, 257, 506 146, 97, 97, 97, 97, 97, 97, 146, 159, 356, 507 147, 225, 161, 260, 260, 261, 162, 148, 257, 146, 508 509 97, 97, 97, 97, 97, 97, 105, 105, 102, 105, 510 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 511 105, 105, 105, 105, 105, 54, 175, 190, 102, 258, 512 263, 131, 132, 355, 133, 261, 261, 261, 102, 348, 513 134, 54, 221, 105, 123, 157, 222, 131, 132, 357, 514 133, 157, 218, 219, 102, 265, 265, 266, 266, 266, 515 266, 223, 356, 105, 105, 105, 105, 105, 102, 105, 516 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 517 105, 105, 105, 105, 105, 158, 159, 344, 342, 160, 518 161, 158, 159, 228, 162, 160, 161, 229, 163, 273, 519 520 162, 289, 224, 105, 163, 225, 161, 223, 233, 242, 521 162, 243, 229, 230, 271, 236, 341, 355, 273, 229, 522 230, 289, 348, 105, 105, 105, 102, 102, 102, 102, 523 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 524 102, 102, 102, 102, 102, 239, 239, 347, 224, 287, 525 346, 225, 161, 288, 159, 290, 162, 225, 161, 291, 526 272, 159, 162, 102, 225, 161, 280, 345, 287, 162, 527 344, 214, 288, 214, 290, 294, 294, 261, 291, 272, 528 261, 261, 261, 102, 102, 102, 102, 102, 102, 102, 529 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 530 531 102, 102, 102, 102, 102, 292, 281, 293, 296, 296, 532 266, 311, 312, 282, 266, 266, 266, 313, 314, 315, 533 316, 332, 333, 102, 292, 342, 293, 261, 261, 261, 534 311, 312, 317, 317, 266, 341, 313, 314, 315, 316, 535 332, 333, 334, 102, 102, 102, 178, 335, 336, 337, 536 337, 266, 349, 350, 179, 179, 180, 351, 352, 359, 537 360, 334, 353, 353, 266, 361, 335, 336, 266, 266, 538 266, 349, 350, 363, 322, 364, 351, 352, 359, 360, 539 181, 182, 365, 366, 361, 183, 367, 321, 340, 339, 540 184, 331, 363, 185, 364, 186, 330, 187, 188, 193, 541 542 328, 365, 366, 327, 326, 367, 325, 194, 194, 195, 543 324, 323, 322, 321, 320, 319, 310, 309, 308, 307, 544 306, 305, 280, 304, 303, 302, 301, 300, 299, 298, 545 268, 286, 285, 196, 197, 284, 283, 279, 198, 278, 546 277, 274, 237, 199, 212, 269, 200, 268, 201, 204, 547 202, 203, 240, 240, 240, 264, 259, 173, 250, 240, 548 240, 240, 240, 240, 240, 249, 248, 241, 139, 237, 549 142, 142, 142, 212, 204, 173, 139, 154, 240, 240, 550 240, 240, 240, 240, 66, 66, 66, 66, 66, 66, 551 66, 66, 66, 66, 66, 66, 66, 66, 73, 73, 552 553 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 554 73, 73, 82, 82, 82, 82, 82, 82, 82, 82, 555 82, 82, 82, 82, 82, 82, 85, 85, 85, 85, 556 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 557 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 558 89, 89, 89, 89, 93, 93, 93, 93, 93, 93, 559 93, 93, 93, 93, 93, 93, 93, 93, 98, 98, 560 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 561 98, 98, 101, 101, 101, 101, 101, 101, 101, 101, 562 101, 101, 101, 101, 101, 101, 106, 106, 106, 106, 563 564 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 565 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 566 107, 107, 107, 107, 102, 102, 102, 102, 102, 102, 567 102, 102, 102, 102, 102, 102, 102, 102, 108, 108, 568 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 569 108, 108, 109, 109, 109, 109, 109, 109, 109, 109, 570 109, 109, 109, 109, 109, 109, 113, 113, 113, 113, 571 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 572 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 573 114, 114, 114, 114, 117, 117, 117, 117, 117, 117, 574 575 117, 117, 117, 117, 117, 117, 117, 117, 124, 124, 576 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 577 124, 124, 130, 130, 130, 130, 130, 130, 130, 130, 578 130, 130, 130, 130, 130, 130, 135, 135, 135, 135, 579 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 580 149, 149, 153, 149, 149, 149, 149, 149, 149, 149, 581 149, 149, 149, 149, 164, 152, 151, 150, 164, 164, 582 164, 164, 164, 164, 164, 164, 164, 164, 172, 172, 583 141, 172, 172, 172, 172, 172, 172, 172, 172, 172, 584 172, 172, 174, 174, 140, 139, 174, 174, 174, 174, 585 586 174, 174, 174, 174, 368, 174, 177, 177, 177, 177, 587 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 588 189, 189, 54, 102, 189, 189, 189, 189, 189, 189, 589 189, 189, 102, 189, 192, 192, 192, 192, 192, 192, 590 192, 192, 192, 192, 192, 192, 192, 192, 206, 206, 591 102, 206, 206, 206, 206, 102, 206, 206, 206, 206, 592 206, 206, 207, 207, 368, 207, 207, 207, 207, 207, 593 207, 207, 207, 207, 207, 207, 210, 210, 368, 210, 594 210, 210, 210, 210, 210, 210, 368, 210, 210, 210, 595 211, 211, 368, 211, 211, 211, 211, 211, 211, 211, 596 597 368, 211, 211, 211, 213, 368, 368, 368, 213, 368, 598 213, 215, 215, 368, 215, 215, 215, 215, 215, 215, 599 215, 215, 215, 215, 215, 216, 216, 368, 216, 216, 600 216, 216, 216, 368, 216, 216, 216, 368, 216, 217, 601 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 602 217, 217, 217, 220, 220, 368, 220, 220, 220, 220, 603 220, 220, 220, 220, 220, 220, 220, 226, 226, 368, 604 226, 368, 226, 226, 226, 368, 226, 226, 226, 226, 605 227, 227, 368, 227, 227, 227, 227, 227, 227, 227, 606 227, 227, 227, 227, 231, 231, 368, 231, 368, 231, 607 608 231, 231, 368, 231, 231, 231, 231, 232, 232, 368, 609 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 610 232, 234, 234, 368, 234, 368, 368, 368, 234, 368, 611 234, 234, 234, 234, 234, 235, 235, 368, 235, 235, 612 235, 235, 235, 235, 235, 235, 235, 235, 235, 238, 613 238, 368, 238, 238, 238, 238, 238, 238, 238, 238, 614 238, 238, 238, 270, 270, 368, 270, 270, 270, 270, 615 270, 368, 270, 270, 270, 368, 270, 329, 329, 368, 616 329, 329, 329, 329, 329, 329, 329, 329, 329, 329, 617 329, 343, 343, 368, 343, 343, 343, 343, 343, 343, 618 619 343, 343, 343, 343, 343, 354, 354, 368, 354, 354, 620 354, 354, 354, 354, 354, 354, 354, 354, 354, 358, 621 358, 368, 358, 358, 358, 358, 358, 358, 358, 358, 622 358, 358, 358, 51, 368, 368, 368, 368, 368, 368, 623 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 624 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 625 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 626 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 627 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 628 368, 368, 368, 368 629 402 22, 23, 24, 23, 25, 22, 26, 22, 22, 22, 403 27, 28, 29, 30, 30, 31, 32, 32, 33, 32, 404 32, 27, 32, 32, 32, 32, 32, 32, 32, 32, 405 32, 34, 35, 36, 39, 36, 40, 37, 39, 43, 406 40, 44, 43, 52, 44, 52, 70, 71, 70, 74, 407 53, 74, 53, 41, 70, 71, 70, 41, 45, 159, 408 72, 45, 47, 48, 47, 79, 79, 49, 72, 76, 409 87, 77, 87, 50, 50, 50, 79, 50, 85, 120, 410 85, 120, 86, 50, 50, 50, 47, 48, 47, 157, 411 89, 49, 89, 90, 124, 155, 125, 50, 50, 50, 412 413 105, 50, 105, 106, 87, 153, 87, 50, 50, 50, 414 56, 149, 128, 54, 128, 132, 86, 132, 131, 57, 415 131, 143, 86, 58, 74, 121, 74, 79, 79, 136, 416 136, 85, 87, 85, 87, 86, 146, 145, 79, 59, 417 60, 61, 56, 61, 87, 62, 87, 89, 140, 89, 418 138, 57, 141, 141, 142, 58, 142, 142, 142, 105, 419 139, 105, 144, 147, 147, 148, 148, 148, 148, 76, 420 76, 59, 60, 64, 84, 120, 54, 120, 65, 66, 421 161, 161, 67, 161, 54, 54, 54, 68, 64, 68, 422 124, 62, 125, 65, 66, 161, 128, 67, 128, 161, 423 424 86, 54, 75, 75, 78, 78, 78, 161, 79, 79, 425 80, 81, 82, 75, 79, 79, 79, 80, 79, 79, 426 79, 79, 82, 79, 79, 79, 132, 151, 132, 79, 427 79, 79, 161, 131, 151, 131, 79, 86, 152, 152, 428 142, 79, 91, 91, 91, 92, 93, 91, 91, 91, 429 91, 91, 91, 91, 94, 94, 95, 91, 91, 91, 430 91, 91, 91, 91, 96, 97, 98, 91, 99, 100, 431 101, 102, 103, 91, 91, 107, 107, 107, 108, 109, 432 107, 107, 107, 107, 107, 107, 107, 110, 110, 111, 433 107, 107, 107, 107, 107, 107, 107, 112, 113, 114, 434 435 107, 115, 116, 117, 118, 119, 107, 107, 134, 134, 436 161, 134, 134, 134, 134, 134, 134, 134, 136, 136, 437 142, 142, 142, 134, 150, 154, 154, 148, 148, 148, 438 148, 150, 142, 142, 142, 156, 156, 148, 161, 134, 439 134, 137, 137, 137, 161, 137, 158, 158, 148, 161, 440 161, 137, 137, 137, 134, 134, 161, 134, 134, 134, 441 134, 134, 134, 134, 160, 160, 148, 161, 161, 134, 442 148, 148, 148, 161, 161, 161, 161, 161, 161, 161, 443 161, 161, 161, 161, 161, 134, 134, 38, 38, 38, 444 38, 38, 38, 38, 38, 38, 38, 38, 42, 42, 445 446 42, 42, 42, 42, 42, 42, 42, 42, 42, 46, 447 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 448 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 449 51, 54, 54, 54, 54, 54, 54, 54, 54, 54, 450 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 451 55, 55, 55, 63, 63, 63, 63, 63, 63, 63, 452 63, 63, 63, 63, 69, 69, 69, 69, 69, 69, 453 69, 69, 69, 69, 69, 73, 73, 73, 73, 73, 454 73, 73, 73, 73, 73, 73, 75, 75, 75, 75, 455 83, 161, 83, 83, 83, 83, 83, 83, 83, 83, 456 457 83, 88, 161, 161, 88, 88, 88, 88, 88, 88, 458 161, 88, 104, 161, 161, 104, 104, 104, 104, 104, 459 104, 161, 104, 122, 161, 122, 122, 122, 161, 122, 460 122, 122, 122, 122, 123, 161, 123, 123, 123, 123, 461 123, 123, 123, 123, 123, 126, 161, 126, 161, 126, 462 126, 126, 161, 126, 126, 127, 161, 127, 127, 127, 463 127, 127, 127, 127, 127, 127, 129, 161, 129, 161, 464 161, 129, 129, 161, 129, 129, 129, 130, 161, 130, 465 130, 130, 130, 130, 130, 130, 130, 130, 133, 161, 466 133, 133, 133, 133, 133, 133, 133, 133, 133, 135, 467 468 161, 135, 135, 135, 135, 135, 135, 135, 135, 135, 469 134, 161, 134, 134, 134, 134, 134, 134, 134, 134, 470 134, 21, 161, 161, 161, 161, 161, 161, 161, 161, 471 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 472 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 473 161, 161, 161, 161, 161 630 474 } ; 631 475 632 static yyconst short int yy_chk[ 1395] =476 static yyconst short int yy_chk[656] = 633 477 { 0, 634 478 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 635 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 636 6, 5, 6, 13, 14, 421, 15, 1, 15, 42, 637 42, 13, 14, 42, 59, 59, 76, 1, 419, 16, 638 15, 16, 49, 49, 7, 8, 7, 8, 9, 10, 639 9, 10, 225, 16, 225, 76, 49, 1, 1, 1, 640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 641 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 642 8, 35, 71, 9, 10, 77, 71, 2, 242, 36, 643 35, 37, 38, 50, 50, 242, 43, 2, 36, 43, 644 645 37, 38, 418, 87, 77, 43, 87, 50, 115, 43, 646 91, 78, 115, 91, 72, 79, 35, 2, 2, 2, 647 3, 3, 45, 3, 36, 45, 37, 38, 44, 44, 648 78, 45, 44, 80, 79, 45, 100, 100, 44, 111, 649 111, 3, 44, 3, 417, 3, 3, 3, 112, 112, 650 3, 43, 80, 43, 72, 72, 415, 122, 72, 72, 651 3, 122, 3, 72, 3, 3, 3, 72, 129, 3, 652 4, 4, 129, 4, 134, 147, 147, 45, 134, 45, 653 160, 155, 160, 414, 44, 155, 44, 160, 46, 46, 654 165, 4, 46, 4, 167, 4, 4, 4, 46, 388, 655 656 4, 388, 46, 61, 61, 61, 81, 116, 81, 165, 657 4, 168, 4, 167, 4, 4, 4, 170, 61, 4, 658 11, 11, 159, 396, 159, 81, 11, 159, 81, 166, 659 168, 11, 11, 11, 207, 207, 170, 61, 11, 11, 660 11, 11, 11, 11, 46, 362, 46, 123, 116, 166, 661 169, 116, 116, 60, 60, 60, 116, 11, 11, 11, 662 11, 11, 11, 12, 12, 144, 144, 144, 60, 12, 663 169, 60, 208, 208, 12, 12, 12, 60, 357, 171, 664 144, 12, 12, 12, 12, 12, 12, 60, 123, 356, 665 60, 123, 123, 179, 179, 179, 123, 60, 171, 144, 666 667 12, 12, 12, 12, 12, 12, 17, 17, 17, 17, 668 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 669 17, 17, 17, 17, 17, 47, 175, 190, 47, 175, 670 190, 47, 47, 355, 47, 180, 180, 180, 47, 348, 671 48, 48, 221, 17, 48, 156, 221, 48, 48, 346, 672 48, 157, 218, 218, 48, 194, 194, 194, 195, 195, 673 195, 222, 345, 17, 17, 17, 18, 18, 18, 18, 674 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 675 18, 18, 18, 18, 18, 156, 156, 344, 342, 156, 676 156, 157, 157, 228, 156, 157, 157, 228, 156, 240, 677 678 157, 253, 222, 18, 157, 222, 222, 223, 233, 224, 679 222, 224, 233, 229, 224, 236, 341, 340, 240, 236, 680 230, 253, 331, 18, 18, 18, 19, 19, 19, 19, 681 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 682 19, 19, 19, 19, 19, 239, 239, 330, 223, 251, 683 328, 223, 223, 252, 229, 254, 223, 229, 229, 255, 684 239, 230, 229, 19, 230, 230, 246, 327, 251, 230, 685 326, 402, 252, 402, 254, 260, 260, 260, 255, 239, 686 261, 261, 261, 19, 19, 19, 20, 20, 20, 20, 687 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 688 689 20, 20, 20, 20, 20, 256, 246, 257, 265, 265, 690 265, 287, 288, 246, 266, 266, 266, 289, 290, 291, 691 292, 311, 313, 20, 256, 324, 257, 294, 294, 294, 692 287, 288, 296, 296, 296, 323, 289, 290, 291, 292, 693 311, 313, 314, 20, 20, 20, 88, 315, 316, 317, 694 317, 317, 332, 334, 88, 88, 88, 335, 336, 349, 695 350, 314, 337, 337, 337, 351, 315, 316, 353, 353, 696 353, 332, 334, 359, 322, 360, 335, 336, 349, 350, 697 88, 88, 363, 364, 351, 88, 365, 321, 320, 319, 698 88, 310, 359, 88, 360, 88, 309, 88, 88, 92, 699 700 307, 363, 364, 306, 305, 365, 304, 92, 92, 92, 701 303, 302, 301, 300, 299, 298, 286, 285, 284, 283, 702 282, 281, 280, 279, 278, 277, 276, 275, 274, 271, 703 268, 250, 249, 92, 92, 248, 247, 245, 92, 244, 704 243, 241, 237, 92, 213, 211, 92, 210, 92, 204, 705 92, 92, 148, 148, 148, 193, 178, 172, 163, 148, 706 148, 148, 148, 148, 148, 162, 161, 158, 139, 136, 707 133, 125, 118, 106, 94, 82, 74, 69, 148, 148, 708 148, 148, 148, 148, 369, 369, 369, 369, 369, 369, 709 369, 369, 369, 369, 369, 369, 369, 369, 370, 370, 710 711 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 712 370, 370, 371, 371, 371, 371, 371, 371, 371, 371, 713 371, 371, 371, 371, 371, 371, 372, 372, 372, 372, 714 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 715 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 716 373, 373, 373, 373, 374, 374, 374, 374, 374, 374, 717 374, 374, 374, 374, 374, 374, 374, 374, 375, 375, 718 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, 719 375, 375, 376, 376, 376, 376, 376, 376, 376, 376, 720 376, 376, 376, 376, 376, 376, 377, 377, 377, 377, 721 722 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 723 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 724 378, 378, 378, 378, 379, 379, 379, 379, 379, 379, 725 379, 379, 379, 379, 379, 379, 379, 379, 380, 380, 726 380, 380, 380, 380, 380, 380, 380, 380, 380, 380, 727 380, 380, 381, 381, 381, 381, 381, 381, 381, 381, 728 381, 381, 381, 381, 381, 381, 382, 382, 382, 382, 729 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 730 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 731 383, 383, 383, 383, 384, 384, 384, 384, 384, 384, 732 733 384, 384, 384, 384, 384, 384, 384, 384, 385, 385, 734 385, 385, 385, 385, 385, 385, 385, 385, 385, 385, 735 385, 385, 386, 386, 386, 386, 386, 386, 386, 386, 736 386, 386, 386, 386, 386, 386, 387, 387, 387, 387, 737 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 738 389, 389, 67, 389, 389, 389, 389, 389, 389, 389, 739 389, 389, 389, 389, 390, 65, 64, 63, 390, 390, 740 390, 390, 390, 390, 390, 390, 390, 390, 391, 391, 741 57, 391, 391, 391, 391, 391, 391, 391, 391, 391, 742 391, 391, 392, 392, 55, 53, 392, 392, 392, 392, 743 744 392, 392, 392, 392, 51, 392, 393, 393, 393, 393, 745 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 746 394, 394, 41, 40, 394, 394, 394, 394, 394, 394, 747 394, 394, 39, 394, 395, 395, 395, 395, 395, 395, 748 395, 395, 395, 395, 395, 395, 395, 395, 397, 397, 749 34, 397, 397, 397, 397, 33, 397, 397, 397, 397, 750 397, 397, 398, 398, 0, 398, 398, 398, 398, 398, 751 398, 398, 398, 398, 398, 398, 399, 399, 0, 399, 752 399, 399, 399, 399, 399, 399, 0, 399, 399, 399, 753 400, 400, 0, 400, 400, 400, 400, 400, 400, 400, 754 755 0, 400, 400, 400, 401, 0, 0, 0, 401, 0, 756 401, 403, 403, 0, 403, 403, 403, 403, 403, 403, 757 403, 403, 403, 403, 403, 404, 404, 0, 404, 404, 758 404, 404, 404, 0, 404, 404, 404, 0, 404, 405, 759 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 760 405, 405, 405, 406, 406, 0, 406, 406, 406, 406, 761 406, 406, 406, 406, 406, 406, 406, 407, 407, 0, 762 407, 0, 407, 407, 407, 0, 407, 407, 407, 407, 763 408, 408, 0, 408, 408, 408, 408, 408, 408, 408, 764 408, 408, 408, 408, 409, 409, 0, 409, 0, 409, 765 766 409, 409, 0, 409, 409, 409, 409, 410, 410, 0, 767 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, 768 410, 411, 411, 0, 411, 0, 0, 0, 411, 0, 769 411, 411, 411, 411, 411, 412, 412, 0, 412, 412, 770 412, 412, 412, 412, 412, 412, 412, 412, 412, 413, 771 413, 0, 413, 413, 413, 413, 413, 413, 413, 413, 772 413, 413, 413, 416, 416, 0, 416, 416, 416, 416, 773 416, 0, 416, 416, 416, 0, 416, 420, 420, 0, 774 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 775 420, 422, 422, 0, 422, 422, 422, 422, 422, 422, 776 777 422, 422, 422, 422, 422, 423, 423, 0, 423, 423, 778 423, 423, 423, 423, 423, 423, 423, 423, 423, 424, 779 424, 0, 424, 424, 424, 424, 424, 424, 424, 424, 780 424, 424, 424, 368, 368, 368, 368, 368, 368, 368, 781 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 782 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 783 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 784 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 785 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 786 368, 368, 368, 368 787 479 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 480 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 481 1, 1, 1, 2, 3, 2, 3, 2, 4, 5, 482 4, 5, 6, 9, 6, 10, 17, 17, 17, 23, 483 9, 23, 10, 3, 18, 18, 18, 4, 5, 190, 484 17, 6, 7, 7, 7, 30, 30, 7, 18, 28, 485 37, 28, 37, 7, 7, 7, 30, 7, 36, 47, 486 36, 47, 36, 7, 7, 7, 8, 8, 8, 189, 487 40, 8, 40, 40, 53, 188, 53, 8, 8, 8, 488 489 44, 8, 44, 44, 62, 187, 62, 8, 8, 8, 490 13, 185, 61, 13, 61, 70, 61, 70, 68, 13, 491 68, 184, 68, 13, 74, 175, 74, 78, 78, 81, 492 81, 85, 86, 85, 86, 85, 109, 108, 78, 13, 493 13, 14, 14, 14, 87, 14, 87, 89, 93, 89, 494 89, 14, 94, 94, 94, 14, 95, 95, 95, 105, 495 92, 105, 105, 110, 110, 110, 111, 111, 111, 67, 496 57, 14, 14, 15, 33, 120, 15, 120, 15, 15, 497 21, 123, 15, 123, 20, 19, 15, 16, 16, 16, 498 124, 16, 124, 16, 16, 0, 128, 16, 128, 0, 499 500 128, 16, 29, 29, 29, 29, 29, 0, 29, 29, 501 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 502 29, 29, 29, 32, 32, 32, 132, 137, 132, 32, 503 32, 32, 0, 131, 137, 131, 32, 131, 141, 141, 504 141, 32, 41, 41, 41, 41, 41, 41, 41, 41, 505 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 506 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 507 41, 41, 41, 41, 41, 45, 45, 45, 45, 45, 508 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 509 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 510 511 45, 45, 45, 45, 45, 45, 45, 45, 77, 77, 512 0, 77, 77, 77, 77, 77, 77, 77, 136, 136, 513 142, 142, 142, 77, 136, 147, 147, 147, 148, 148, 514 148, 136, 152, 152, 152, 154, 154, 154, 0, 77, 515 77, 82, 82, 82, 0, 82, 156, 156, 156, 0, 516 0, 82, 82, 82, 135, 135, 0, 135, 135, 135, 517 135, 135, 135, 135, 158, 158, 158, 0, 0, 135, 518 160, 160, 160, 0, 0, 0, 0, 0, 0, 0, 519 0, 0, 0, 0, 0, 135, 135, 162, 162, 162, 520 162, 162, 162, 162, 162, 162, 162, 162, 163, 163, 521 522 163, 163, 163, 163, 163, 163, 163, 163, 163, 164, 523 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 524 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 525 165, 166, 166, 166, 166, 166, 166, 166, 166, 166, 526 166, 166, 167, 167, 167, 167, 167, 167, 167, 167, 527 167, 167, 167, 168, 168, 168, 168, 168, 168, 168, 528 168, 168, 168, 168, 169, 169, 169, 169, 169, 169, 529 169, 169, 169, 169, 169, 170, 170, 170, 170, 170, 530 170, 170, 170, 170, 170, 170, 171, 171, 171, 171, 531 172, 0, 172, 172, 172, 172, 172, 172, 172, 172, 532 533 172, 173, 0, 0, 173, 173, 173, 173, 173, 173, 534 0, 173, 174, 0, 0, 174, 174, 174, 174, 174, 535 174, 0, 174, 176, 0, 176, 176, 176, 0, 176, 536 176, 176, 176, 176, 177, 0, 177, 177, 177, 177, 537 177, 177, 177, 177, 177, 178, 0, 178, 0, 178, 538 178, 178, 0, 178, 178, 179, 0, 179, 179, 179, 539 179, 179, 179, 179, 179, 179, 180, 0, 180, 0, 540 0, 180, 180, 0, 180, 180, 180, 181, 0, 181, 541 181, 181, 181, 181, 181, 181, 181, 181, 182, 0, 542 182, 182, 182, 182, 182, 182, 182, 182, 182, 183, 543 544 0, 183, 183, 183, 183, 183, 183, 183, 183, 183, 545 186, 0, 186, 186, 186, 186, 186, 186, 186, 186, 546 186, 161, 161, 161, 161, 161, 161, 161, 161, 161, 547 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 548 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 549 161, 161, 161, 161, 161 788 550 } ; 789 551 790 552 static yy_state_type yy_last_accepting_state; 791 553 static char *yy_last_accepting_cpos; 554 555 extern int yy_flex_debug; 556 int yy_flex_debug = 1; 557 558 static yyconst short int yy_rule_linenum[84] = 559 { 0, 560 313, 314, 339, 340, 341, 342, 343, 344, 346, 347, 561 355, 356, 357, 359, 360, 361, 362, 364, 365, 367, 562 368, 369, 378, 399, 404, 410, 411, 416, 423, 428, 563 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 564 440, 441, 442, 443, 448, 453, 454, 455, 460, 467, 565 472, 474, 475, 476, 477, 478, 479, 480, 481, 482, 566 483, 484, 489, 490, 491, 492, 497, 498, 506, 511, 567 512, 513, 519, 525, 526, 527, 528, 530, 531, 533, 568 543, 545, 554 569 } ; 792 570 793 571 /* The intent behind this definition is that it'll catch … … 802 580 /* -*-C-*- 803 581 * 804 * Copyright 1994 Martin von Loewis 805 * Copyright 1998 Bertho A. Stultiens (BS) 582 * Copyright 1998-2000 Bertho A. Stultiens (BS) 806 583 * 584 * 21-May-2000 BS - Fixed the ident requirement of resource names 585 * which can be keywords. 586 * 30-Apr-2000 BS - Reintegration into the wine-tree 587 * 11-Jan-2000 BS - Very drastic cleanup because we don't have a 588 * preprocessor in here anymore. 589 * 02-Jan-2000 BS - Removed the preprocessor code 590 * 23-Dec-1999 BS - Removed the copyright for Martin von Loewis. 591 * There is really nothing left of his code in 592 * this parser. 807 593 * 20-Jun-1998 BS - Changed the filename conversion. Filenames are 808 594 * case-sensitive inder *nix, but not under dos. … … 845 631 * escaped '\0'. 846 632 */ 847 /* Exclusive rules when looking for a filename */848 #define yywf 1849 850 #define yywf_s 2851 852 633 /* Exclusive string handling */ 853 #define yystr 3634 #define yystr 1 854 635 855 636 /* Exclusive unicode string handling */ 856 #define yylstr 4637 #define yylstr 2 857 638 858 639 /* Exclusive rcdata single quoted data handling */ 859 #define yyrcd 5640 #define yyrcd 3 860 641 861 642 /* Exclusive comment eating... */ 862 #define comment 6 863 864 /* Preprocessor exclusives */ 865 #define pp_incl 7 866 867 #define pp_def 8 868 869 #define pp_undef 9 870 871 #define pp_if 10 872 873 #define pp_ifdef 11 874 875 #define pp_ifndef 12 876 877 #define pp_elif 13 878 879 #define pp_else 14 880 881 #define pp_endif 15 882 883 #define pp_error 16 884 885 /* Set when accumulating #define's expansion text */ 886 #define pp_def_s 17 887 888 /* Set when processing function type defines */ 889 #define pp_ignore 18 890 891 /* Set when need to strip to eol */ 892 #define pp_ignore_eol 19 893 894 /* Set when handling a false #if case */ 895 #define pp_false 20 643 #define comment 4 896 644 897 645 /* Set when stripping c-junk */ 898 #define pp_stripe 21 899 900 #define pp_strips 22 901 902 #define pp_stripp 23 903 904 #define pp_stripp_final 24 905 906 /*%option stack*/ 646 #define pp_stripe 5 647 648 #define pp_strips 6 649 650 #define pp_stripp 7 651 652 #define pp_stripp_final 8 653 654 /* Set when scanning #line style directives */ 655 #define pp_line 9 656 657 #define YY_STACK_USED 1 907 658 #define YY_NEVER_INTERACTIVE 1 908 /*%option noyywrap */909 659 /* Some shortcut definitions */ 910 #line 91 "parser.l" 911 912 #if !defined(YY_FLEX_MAJOR_VERSION) || (1000 * YY_FLEX_MAJOR_VERSION + YY_FLEX_MINOR_VERSION < 2005) 913 #error Must use flex version 2.5.1 or higher (yy_scan_* routines are required). 914 #endif 660 #line 79 "parser.l" 915 661 916 662 /*#define LEX_DEBUG*/ … … 922 668 #include <string.h> 923 669 #include <ctype.h> 670 #include <assert.h> 924 671 925 672 #include "wrc.h" … … 933 680 #define YY_USE_PROTOS 934 681 #define YY_NO_UNPUT 682 #define YY_NO_TOP_STATE 935 683 936 684 /* Always update the current character position within a line */ 937 #define YY_USER_ACTION char_number+=yyleng; 938 939 raw_data_t *new_raw_data(void); 940 941 void addcchar(char c); 942 void addwchar(short s); 943 string_t *get_buffered_cstring(void); 944 string_t *get_buffered_wstring(void); 945 string_t *make_string(char *s); 946 string_t *make_filename(char *s, int len); 947 948 int line_number = 1; /* The current line */ 949 int char_number = 1; /* The current char pos within the line */ 685 #define YY_USER_ACTION char_number+=yyleng; wanted_id = want_id; want_id = 0; 686 687 static void addcchar(char c); 688 static void addwchar(short s); 689 static string_t *get_buffered_cstring(void); 690 static string_t *get_buffered_wstring(void); 691 static string_t *make_string(char *s); 692 950 693 static char *cbuffer; /* Buffers for string collection */ 951 694 static int cbufidx; … … 954 697 static int wbufidx; 955 698 static int wbufalloc = 0; 956 static int want_nl = 0; /* Set when newline needs to go to parser */957 static int want_ident = 0; /* Set is #ifdef, #ifndef or defined is seen */958 699 static int stripslevel = 0; /* Count {} during pp_strips/pp_stripe mode */ 959 700 static int stripplevel = 0; /* Count () during pp_strips mode */ 960 static char *substtext = NULL; /* Holds the substition text while getting a define */961 701 static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */ 962 702 963 #ifdef YY_USE_STACK 964 void push_to(int start) { yy_push_state(start); } 965 void pop_start(void) { yy_pop_state(start); } 966 #else 967 #define MAXSTARTSTACK 32 968 static int startstack[MAXSTARTSTACK]; 969 static int startstackidx = 0; 970 971 void push_to(int start) 972 { 973 if(yydebug) 974 printf("push_to(%d): %d -> %d\n", line_number, YY_START, start); 975 if(startstackidx >= MAXSTARTSTACK-1) 976 internal_error(__FILE__, __LINE__, "Start condition stack overflow"); 977 startstack[startstackidx++] = YY_START; 978 BEGIN(start); 979 } 980 981 void pop_start(void) 982 { 983 if(yydebug) 984 printf("pop_start(%d): %d <- %d\n", line_number, startstack[startstackidx-1], YY_START); 985 if(startstackidx <= 0) 986 internal_error(__FILE__, __LINE__, "Start condition stack underflow"); 987 --startstackidx; 988 BEGIN(startstack[startstackidx]); 989 } 990 #endif 991 992 993 struct bufferstackentry { 994 YY_BUFFER_STATE bufferstate; /* Buffer to switch back to */ 995 struct pp_entry *define; /* Points to expanding define 996 or NULL if handling includes 997 */ 998 int line_number; /* Line that we were handling */ 999 int char_number; /* The current position */ 1000 char *filename; /* Filename that we were handling */ 1001 }; 1002 1003 #define MAXBUFFERSTACK 128 1004 static struct bufferstackentry bufferstack[MAXBUFFERSTACK]; 1005 static int bufferstackidx = 0; 1006 1007 void push_buffer(YY_BUFFER_STATE buf, struct pp_entry *ppp, char *filename) 1008 { 1009 if(yydebug) 1010 printf("push_buffer: %p %p %p\n", buf, ppp, filename); 1011 if(bufferstackidx >= MAXBUFFERSTACK-1) 1012 internal_error(__FILE__, __LINE__, "Buffer stack overflow"); 1013 memset(&bufferstack[bufferstackidx], 0, sizeof(bufferstack[0])); 1014 bufferstack[bufferstackidx].bufferstate = buf; 1015 bufferstack[bufferstackidx].define = ppp; 1016 if(ppp) 1017 ppp->expanding = 1; 1018 else if(filename) 1019 { 1020 /* These will track the yyerror to the correct file and line */ 1021 bufferstack[bufferstackidx].line_number = line_number; 1022 bufferstack[bufferstackidx].char_number = char_number; 1023 line_number = 1; 1024 char_number = 1; 1025 bufferstack[bufferstackidx].filename = input_name; 1026 input_name = filename; 1027 } 1028 else 1029 internal_error(__FILE__, __LINE__, "Pushing buffer without knowing where to go to"); 1030 bufferstackidx++; 1031 } 1032 1033 YY_BUFFER_STATE pop_buffer(void) 1034 { 1035 if(bufferstackidx <= 0) 1036 return (YY_BUFFER_STATE)0; 1037 bufferstackidx--; 1038 if(bufferstack[bufferstackidx].define) 1039 bufferstack[bufferstackidx].define->expanding = 0; 1040 else 1041 { 1042 line_number = bufferstack[bufferstackidx].line_number; 1043 char_number = bufferstack[bufferstackidx].char_number; 1044 input_name = bufferstack[bufferstackidx].filename; 1045 fclose(yyin); 1046 } 1047 if(yydebug) 1048 printf("pop_buffer: %p %p (%d, %d) %p\n", 1049 bufferstack[bufferstackidx].bufferstate, 1050 bufferstack[bufferstackidx].define, 1051 bufferstack[bufferstackidx].line_number, 1052 bufferstack[bufferstackidx].char_number, 1053 bufferstack[bufferstackidx].filename); 1054 yy_switch_to_buffer(bufferstack[bufferstackidx].bufferstate); 1055 return bufferstack[bufferstackidx].bufferstate; 1056 } 1057 1058 void do_include(char *name, int namelen) 1059 { 1060 char *cpy = (char *)xmalloc(namelen); 1061 strcpy(cpy, name+1); /* strip leading " or < */ 1062 cpy[namelen-2] = '\0'; /* strip trailing " or > */ 1063 if((yyin = open_include(cpy, name[0] == '"')) == NULL) 1064 yyerror("Unable to open include file %s", cpy); 1065 push_buffer(YY_CURRENT_BUFFER, NULL, cpy); 1066 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); 1067 } 1068 703 /* 704 * This one is a bit tricky. 705 * We set 'want_id' in the parser to get the first 706 * identifier we get across in the scanner, but we 707 * also want it to be reset at nearly any token we 708 * see. Exceptions are: 709 * - newlines 710 * - comments 711 * - whitespace 712 * 713 * The scanner will automatically reset 'want_id' 714 * after *each* scanner reduction and puts is value 715 * into the var below. In this way we can see the 716 * state after the YY_RULE_SETUP (i.e. the user action; 717 * see above) and don't have to worry too much when 718 * it needs to be reset. 719 */ 720 static int wanted_id = 0; 721 static int save_wanted_id; /* To save across comment reductions */ 1069 722 1070 723 struct keyword { … … 1073 726 int isextension; 1074 727 int needcase; 1075 int alwaysk eyword;728 int alwayskw; 1076 729 }; 1077 730 1078 731 static struct keyword keywords[] = { 1079 { "ACCELERATORS", ACCELERATORS, 0, 0, 0}, 1080 { "ALT", ALT, 0, 0, 0}, 1081 { "ASCII", ASCII, 0, 0, 0}, 1082 { "AUTO3STATE", AUTO3STATE, 1, 0, 0}, 1083 { "AUTOCHECKBOX", AUTOCHECKBOX, 1, 0, 0}, 1084 { "AUTORADIOBUTTON", AUTORADIOBUTTON, 1, 0, 0}, 1085 { "BEGIN", tBEGIN, 0, 0, 1}, 1086 { "BITMAP", tBITMAP, 0, 0, 0}, 1087 { "BLOCK", BLOCK, 0, 0, 1}, 1088 { "BUTTON", BUTTON, 1, 0, 0}, 1089 { "CAPTION", CAPTION, 0, 0, 0}, 1090 { "CHARACTERISTICS", CHARACTERISTICS, 1, 0, 0}, 1091 { "CHECKBOX", CHECKBOX, 0, 0, 0}, 1092 { "CHECKED", CHECKED, 0, 0, 0}, 1093 { "CLASS", CLASS, 0, 0, 0}, 1094 { "COMBOBOX", COMBOBOX, 0, 0, 0}, 1095 { "CONTROL", CONTROL, 0, 0, 0}, 1096 { "CTEXT", CTEXT, 0, 0, 0}, 1097 { "CURSOR", CURSOR, 0, 0, 0}, 1098 { "defined", tDEFINED, 0, 1, 1}, 1099 { "DEFPUSHBUTTON", DEFPUSHBUTTON, 0, 0, 1}, 1100 { "DIALOG", DIALOG, 0, 0, 0}, 1101 { "DIALOGEX", DIALOGEX, 1, 0, 0}, 1102 { "DISCARDABLE", DISCARDABLE, 0, 0, 0}, 1103 { "DLGINIT", DLGINIT, 0, 0, 0}, 1104 { "EDITTEXT", EDITTEXT, 0, 0, 0}, 1105 { "END", tEND, 0, 0, 1}, 1106 { "EXSTYLE", EXSTYLE, 0, 0, 0}, 1107 { "extern", tEXTERN, 0, 1, 1}, 1108 { "FILEFLAGS", FILEFLAGS, 0, 0, 0}, 1109 { "FILEFLAGSMASK", FILEFLAGSMASK, 0, 0, 0}, 1110 { "FILEOS", FILEOS, 0, 0, 0}, 1111 { "FILESUBTYPE", FILESUBTYPE, 0, 0, 0}, 1112 { "FILETYPE", FILETYPE, 0, 0, 0}, 1113 { "FILEVERSION", FILEVERSION, 0, 0, 0}, 1114 { "FIXED", tFIXED, 0, 0, 0}, 1115 { "FONT", FONT, 0, 0, 0}, 1116 { "GRAYED", GRAYED, 0, 0, 0}, 1117 { "GROUPBOX", GROUPBOX, 0, 0, 0}, 1118 { "HELP", HELP, 0, 0, 0}, 1119 { "ICON", ICON, 0, 0, 0}, 1120 { "IMPURE", IMPURE, 0, 0, 0}, 1121 { "INACTIVE", INACTIVE, 0, 0, 0}, 1122 { "LANGUAGE", LANGUAGE, 1, 0, 1}, 1123 { "LISTBOX", LISTBOX, 0, 0, 0}, 1124 { "LOADONCALL", LOADONCALL, 0, 0, 0}, 1125 { "LTEXT", LTEXT, 0, 0, 0}, 1126 { "MENU", MENU, 0, 0, 0}, 1127 { "MENUBARBREAK", MENUBARBREAK, 0, 0, 0}, 1128 { "MENUBREAK", MENUBREAK, 0, 0, 0}, 1129 { "MENUEX", MENUEX, 1, 0, 0}, 1130 { "MENUITEM", MENUITEM, 0, 0, 0}, 1131 { "MESSAGETABLE", MESSAGETABLE, 1, 0, 0}, 1132 { "MOVEABLE", MOVEABLE, 0, 0, 0}, 1133 { "NOINVERT", NOINVERT, 0, 0, 0}, 1134 { "NOT", NOT, 0, 0, 0}, 1135 { "POPUP", POPUP, 0, 0, 0}, 1136 { "PRELOAD", PRELOAD, 0, 0, 0}, 1137 { "PRODUCTVERSION", PRODUCTVERSION, 0, 0, 0}, 1138 { "PURE", tPURE, 0, 0, 0}, 1139 { "PUSHBUTTON", PUSHBUTTON, 0, 0, 0}, 1140 { "RADIOBUTTON", RADIOBUTTON, 0, 0, 0}, 1141 { "RCDATA", RCDATA, 0, 0, 0}, 1142 { "RTEXT", RTEXT, 0, 0, 0}, 1143 { "SCROLLBAR", SCROLLBAR, 0, 0, 0}, 1144 { "SEPARATOR", SEPARATOR, 0, 0, 0}, 1145 { "SHIFT", SHIFT, 0, 0, 0}, 1146 { "STATE3", STATE3, 1, 0, 0}, 1147 { "STRING", tSTRING, 0, 0, 0}, 1148 { "STRINGTABLE", STRINGTABLE, 0, 0, 1}, 1149 { "STYLE", STYLE, 0, 0, 0}, 1150 { "TOOLBAR", TOOLBAR, 1, 0, 0}, 1151 { "typedef", tTYPEDEF, 0, 1, 1}, 1152 { "VALUE", VALUE, 0, 0, 0}, 1153 { "VERSION", VERSION, 1, 0, 0}, 1154 { "VERSIONINFO", VERSIONINFO, 0, 0, 0}, 1155 { "VIRTKEY", VIRTKEY, 0, 0, 0} 732 { "ACCELERATORS", tACCELERATORS, 0, 0, 0}, 733 { "ALT", tALT, 0, 0, 0}, 734 { "ASCII", tASCII, 0, 0, 0}, 735 { "AUTO3STATE", tAUTO3STATE, 1, 0, 0}, 736 { "AUTOCHECKBOX", tAUTOCHECKBOX, 1, 0, 0}, 737 { "AUTORADIOBUTTON", tAUTORADIOBUTTON, 1, 0, 0}, 738 { "BEGIN", tBEGIN, 0, 0, 0}, 739 { "BITMAP", tBITMAP, 0, 0, 0}, 740 { "BLOCK", tBLOCK, 0, 0, 0}, 741 { "BUTTON", tBUTTON, 1, 0, 0}, 742 { "CAPTION", tCAPTION, 0, 0, 0}, 743 { "CHARACTERISTICS", tCHARACTERISTICS, 1, 0, 0}, 744 { "CHECKBOX", tCHECKBOX, 0, 0, 0}, 745 { "CHECKED", tCHECKED, 0, 0, 0}, 746 { "CLASS", tCLASS, 0, 0, 0}, 747 { "COMBOBOX", tCOMBOBOX, 0, 0, 0}, 748 { "CONTROL", tCONTROL, 0, 0, 0}, 749 { "CTEXT", tCTEXT, 0, 0, 0}, 750 { "CURSOR", tCURSOR, 0, 0, 0}, 751 { "DEFPUSHBUTTON", tDEFPUSHBUTTON, 0, 0, 0}, 752 { "DIALOG", tDIALOG, 0, 0, 0}, 753 { "DIALOGEX", tDIALOGEX, 1, 0, 0}, 754 { "DISCARDABLE", tDISCARDABLE, 0, 0, 0}, 755 { "DLGINIT", tDLGINIT, 0, 0, 0}, 756 { "EDITTEXT", tEDITTEXT, 0, 0, 0}, 757 { "END", tEND, 0, 0, 0}, 758 { "enum", tENUM, 0, 1, 1}, 759 { "EXSTYLE", tEXSTYLE, 0, 0, 0}, 760 { "extern", tEXTERN, 0, 1, 1}, 761 { "FILEFLAGS", tFILEFLAGS, 0, 0, 0}, 762 { "FILEFLAGSMASK", tFILEFLAGSMASK, 0, 0, 0}, 763 { "FILEOS", tFILEOS, 0, 0, 0}, 764 { "FILESUBTYPE", tFILESUBTYPE, 0, 0, 0}, 765 { "FILETYPE", tFILETYPE, 0, 0, 0}, 766 { "FILEVERSION", tFILEVERSION, 0, 0, 0}, 767 { "FIXED", tFIXED, 0, 0, 0}, 768 { "FONT", tFONT, 0, 0, 0}, 769 { "FONTDIR", tFONTDIR, 0, 0, 0}, /* This is a Borland BRC extension */ 770 { "GRAYED", tGRAYED, 0, 0, 0}, 771 { "GROUPBOX", tGROUPBOX, 0, 0, 0}, 772 { "HELP", tHELP, 0, 0, 0}, 773 { "ICON", tICON, 0, 0, 0}, 774 { "IMPURE", tIMPURE, 0, 0, 0}, 775 { "INACTIVE", tINACTIVE, 0, 0, 0}, 776 { "inline", tINLINE, 0, 1, 1}, 777 { "LANGUAGE", tLANGUAGE, 1, 0, 1}, 778 { "LISTBOX", tLISTBOX, 0, 0, 0}, 779 { "LOADONCALL", tLOADONCALL, 0, 0, 0}, 780 { "LTEXT", tLTEXT, 0, 0, 0}, 781 { "MENU", tMENU, 0, 0, 0}, 782 { "MENUBARBREAK", tMENUBARBREAK, 0, 0, 0}, 783 { "MENUBREAK", tMENUBREAK, 0, 0, 0}, 784 { "MENUEX", tMENUEX, 1, 0, 0}, 785 { "MENUITEM", tMENUITEM, 0, 0, 0}, 786 { "MESSAGETABLE", tMESSAGETABLE, 1, 0, 0}, 787 { "MOVEABLE", tMOVEABLE, 0, 0, 0}, 788 { "NOINVERT", tNOINVERT, 0, 0, 0}, 789 { "NOT", tNOT, 0, 0, 0}, 790 { "POPUP", tPOPUP, 0, 0, 0}, 791 { "PRELOAD", tPRELOAD, 0, 0, 0}, 792 { "PRODUCTVERSION", tPRODUCTVERSION, 0, 0, 0}, 793 { "PURE", tPURE, 0, 0, 0}, 794 { "PUSHBUTTON", tPUSHBUTTON, 0, 0, 0}, 795 { "RADIOBUTTON", tRADIOBUTTON, 0, 0, 0}, 796 { "RCDATA", tRCDATA, 0, 0, 0}, 797 { "RTEXT", tRTEXT, 0, 0, 0}, 798 { "SCROLLBAR", tSCROLLBAR, 0, 0, 0}, 799 { "SEPARATOR", tSEPARATOR, 0, 0, 0}, 800 { "SHIFT", tSHIFT, 0, 0, 0}, 801 { "STATE3", tSTATE3, 1, 0, 0}, 802 { "static", tSTATIC, 0, 1, 1}, 803 { "STRING", tSTRING, 0, 0, 0}, 804 { "STRINGTABLE", tSTRINGTABLE, 0, 0, 1}, 805 { "struct", tSTRUCT, 0, 1, 1}, 806 { "STYLE", tSTYLE, 0, 0, 0}, 807 { "TOOLBAR", tTOOLBAR, 1, 0, 0}, 808 { "typedef", tTYPEDEF, 0, 1, 1}, 809 { "VALUE", tVALUE, 0, 0, 0}, 810 { "VERSION", tVERSION, 1, 0, 0}, 811 { "VERSIONINFO", tVERSIONINFO, 0, 0, 0}, 812 { "VIRTKEY", tVIRTKEY, 0, 0, 0} 1156 813 }; 1157 814 1158 815 #define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0])) 1159 816 #define KWP(p) ((struct keyword *)(p)) 1160 int kw_cmp_func(const void *s1, const void *s2)817 static int kw_cmp_func(const void *s1, const void *s2) 1161 818 { 1162 819 int ret; … … 1170 827 #define KW_BSEARCH 1171 828 #define DO_SORT 1172 st ruct keyword *iskeyword(char *kw)829 static struct keyword *iskeyword(char *kw) 1173 830 { 1174 831 struct keyword *kwp; … … 1204 861 #endif 1205 862 1206 #ifdef LEX_DEBUG1207 if(kwp && !strcmp(kwp->keyword, "LANGUAGE"))1208 printf("Got Language\n");1209 #endif1210 863 if(kwp == NULL || (kwp->isextension && !extensions)) 1211 864 return NULL; … … 1214 867 } 1215 868 1216 void add_to_substtext(char *text, int len) 1217 { 1218 if(!substtext) 1219 { 1220 substtext = xstrdup(text); 1221 } 1222 else 1223 { 1224 substtext = (char *)xrealloc(substtext, strlen(substtext)+len+1); 1225 strcat(substtext, text); 1226 } 1227 } 1228 1229 #line 1230 "lexyy.c" 869 /* 870 ************************************************************************** 871 * The flexer starts here 872 ************************************************************************** 873 */ 874 #line 875 "lexyy.c" 1230 875 1231 876 /* Macros after this point can all be overridden by user definitions in … … 1377 1022 register int yy_act; 1378 1023 1379 #line 411 "parser.l" 1380 1381 /* #include handling */ 1382 #line 1383 "lexyy.c" 1024 #line 294 "parser.l" 1025 1026 /* 1027 * Catch the GCC-style line statements here and parse them. 1028 * This has the advantage that you can #include at any 1029 * stage in the resource file. 1030 * The preprocessor generates line directives in the format: 1031 * # <linenum> "filename" <codes> 1032 * 1033 * Codes can be a sequence of: 1034 * - 1 start of new file 1035 * - 2 returning to previous 1036 * - 3 system header 1037 * - 4 interpret as C-code 1038 * 1039 * 4 is not used and 1 mutually excludes 2 1040 * Anyhow, we are not really interested in these at all 1041 * because we only want to know the linenumber and 1042 * filename. 1043 */ 1044 #line 1045 "lexyy.c" 1383 1045 1384 1046 if ( yy_init ) … … 1432 1094 { 1433 1095 yy_current_state = (int) yy_def[yy_current_state]; 1434 if ( yy_current_state >= 369)1096 if ( yy_current_state >= 162 ) 1435 1097 yy_c = yy_meta[(unsigned int) yy_c]; 1436 1098 } … … 1438 1100 ++yy_cp; 1439 1101 } 1440 while ( yy_base[yy_current_state] != 1334);1102 while ( yy_base[yy_current_state] != 622 ); 1441 1103 1442 1104 yy_find_action: … … 1454 1116 do_action: /* This label is used only to access EOF actions. */ 1455 1117 1118 if ( yy_flex_debug ) 1119 { 1120 if ( yy_act == 0 ) 1121 fprintf( stderr, "--scanner backing up\n" ); 1122 else if ( yy_act < 84 ) 1123 fprintf( stderr, "--accepting rule at line %d (\"%s\")\n", 1124 yy_rule_linenum[yy_act], yytext ); 1125 else if ( yy_act == 84 ) 1126 fprintf( stderr, "--accepting default rule (\"%s\")\n", 1127 yytext ); 1128 else if ( yy_act == 85 ) 1129 fprintf( stderr, "--(end of buffer or a NUL)\n" ); 1130 else 1131 fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); 1132 } 1456 1133 1457 1134 switch ( yy_act ) … … 1466 1143 case 1: 1467 1144 YY_RULE_SETUP 1468 #line 413 "parser.l"1469 push_to(pp_incl);1145 #line 313 "parser.l" 1146 yy_push_state(pp_line); 1470 1147 YY_BREAK 1471 1148 case 2: 1472 1149 YY_RULE_SETUP 1473 #line 414 "parser.l" 1474 do_include(yytext, yyleng); pop_start(); 1475 YY_BREAK 1150 #line 314 "parser.l" 1151 { 1152 int lineno; 1153 char *cptr; 1154 char *fname; 1155 yy_pop_state(); 1156 lineno = (int)strtol(yytext, &cptr, 10); 1157 if(!lineno) 1158 yyerror("Malformed '#...' line-directive; invalid linenumber"); 1159 fname = strchr(cptr, '"'); 1160 if(!fname) 1161 yyerror("Malformed '#...' line-directive; missing filename"); 1162 fname++; 1163 cptr = strchr(fname, '"'); 1164 if(!cptr) 1165 yyerror("Malformed '#...' line-directive; missing terminating \""); 1166 *cptr = '\0'; 1167 line_number = lineno - 1; /* We didn't read the newline */ 1168 input_name = xstrdup(fname); 1169 } 1170 YY_BREAK 1171 /* 1172 * Strip everything until a ';' taking 1173 * into account braces {} for structures, 1174 * classes and enums. 1175 */ 1476 1176 case 3: 1477 1177 YY_RULE_SETUP 1478 #line 415"parser.l"1479 do_include(yytext, yyleng); pop_start();1178 #line 339 "parser.l" 1179 stripslevel++; 1480 1180 YY_BREAK 1481 1181 case 4: 1482 1182 YY_RULE_SETUP 1483 #line 416 "parser.l" 1484 yyerror("Malformed #include"); 1485 YY_BREAK 1486 /* #define handling */ 1183 #line 340 "parser.l" 1184 stripslevel--; 1185 YY_BREAK 1487 1186 case 5: 1488 1187 YY_RULE_SETUP 1489 #line 419"parser.l"1490 push_to(pp_def);1188 #line 341 "parser.l" 1189 if(!stripslevel) yy_pop_state(); 1491 1190 YY_BREAK 1492 1191 case 6: 1493 1192 YY_RULE_SETUP 1494 #line 420 "parser.l" 1193 #line 342 "parser.l" 1194 ; /* To catch comments */ 1195 YY_BREAK 1196 case 7: 1197 YY_RULE_SETUP 1198 #line 343 "parser.l" 1199 ; /* Ignore rest */ 1200 YY_BREAK 1201 case 8: 1202 YY_RULE_SETUP 1203 #line 344 "parser.l" 1204 line_number++; char_number = 1; 1205 YY_BREAK 1206 case 9: 1207 YY_RULE_SETUP 1208 #line 346 "parser.l" 1209 stripplevel++; 1210 YY_BREAK 1211 case 10: 1212 YY_RULE_SETUP 1213 #line 347 "parser.l" 1495 1214 { 1496 set_define(yytext); 1497 push_to(pp_def_s); 1498 } 1499 YY_BREAK 1500 case 7: 1501 YY_RULE_SETUP 1502 #line 424 "parser.l" 1503 push_to(pp_ignore); /* Ignore function-like defines for now*/ 1504 YY_BREAK 1505 case 8: 1506 YY_RULE_SETUP 1507 #line 425 "parser.l" 1508 yyerror("Malformed #define"); 1509 YY_BREAK 1510 case 9: 1511 YY_RULE_SETUP 1512 #line 427 "parser.l" 1513 { 1514 if(YY_START == pp_def_s) 1515 add_to_substtext(yytext, yyleng); 1516 } 1517 YY_BREAK 1518 case 10: 1519 YY_RULE_SETUP 1520 #line 431 "parser.l" 1521 { /* Comment is handled in normal handling */ 1522 if(YY_START == pp_def_s) 1523 add_to_substtext(yytext, yyleng); 1524 } 1525 YY_BREAK 1526 case 11: 1527 YY_RULE_SETUP 1528 #line 435 "parser.l" 1529 line_number++; char_number = 1; /* Line continuation */ 1530 YY_BREAK 1531 case 12: 1532 YY_RULE_SETUP 1533 #line 436 "parser.l" 1534 { 1535 if(YY_START == pp_def_s) 1536 { 1537 add_define(substtext ? substtext : ""); 1538 free(substtext); 1539 substtext = NULL; 1540 } 1541 line_number++; 1542 char_number = 1; 1543 pop_start(); 1544 pop_start(); 1545 } 1546 YY_BREAK 1547 /* #undef handling */ 1548 case 13: 1549 YY_RULE_SETUP 1550 #line 450 "parser.l" 1551 push_to(pp_undef); 1552 YY_BREAK 1553 case 14: 1554 YY_RULE_SETUP 1555 #line 451 "parser.l" 1556 { 1557 del_define(yytext); 1558 pop_start(); 1559 /*push_to(pp_ignore);*/ 1560 } 1561 YY_BREAK 1562 /* Conditional handling */ 1563 case 15: 1564 YY_RULE_SETUP 1565 #line 458 "parser.l" 1566 { 1567 if(YY_START == pp_false) 1568 { 1569 if(yydebug) 1570 printf("(%d)#if ignored\n", line_number); 1571 push_if(0, 0, 1); 1572 push_to(pp_ignore_eol); 1573 } 1574 else 1575 { 1576 push_to(INITIAL); 1577 want_nl = 1; 1578 return tIF; 1579 } 1580 } 1581 YY_BREAK 1582 case 16: 1583 YY_RULE_SETUP 1584 #line 473 "parser.l" 1585 { 1586 if(YY_START == pp_false) 1587 { 1588 if(yydebug) 1589 printf("(%d)#ifdef ignored\n", line_number); 1590 push_if(0, 0, 1); 1591 push_to(pp_ignore_eol); 1592 } 1593 else 1594 { 1595 push_to(INITIAL); 1596 want_nl = 1; 1597 want_ident = 1; 1598 return tIFDEF; 1599 } 1600 } 1601 YY_BREAK 1602 case 17: 1603 YY_RULE_SETUP 1604 #line 489 "parser.l" 1605 { 1606 if(YY_START == pp_false) 1607 { 1608 if(yydebug) 1609 printf("(%d)#ifndef ignored\n", line_number); 1610 push_if(0, 0, 1); 1611 push_to(pp_ignore_eol); 1612 } 1613 else 1614 { 1615 push_to(INITIAL); 1616 want_nl = 1; 1617 want_ident = 1; 1618 return tIFNDEF; 1619 } 1620 } 1621 YY_BREAK 1622 case 18: 1623 YY_RULE_SETUP 1624 #line 505 "parser.l" 1625 { 1626 if(!isnevertrue_if()) 1627 { 1628 push_to(INITIAL); 1629 want_nl = 1; 1630 return tELIF; 1631 } 1632 else if(YY_START == pp_false) 1633 push_to(pp_ignore_eol); 1634 if(yydebug) 1635 printf("(%d)#elif ignored\n", line_number); 1636 } 1637 YY_BREAK 1638 case 19: 1639 YY_RULE_SETUP 1640 #line 517 "parser.l" 1641 { 1642 if(!isnevertrue_if()) 1643 { 1644 push_to(INITIAL); 1645 want_nl = 1; 1646 return tELSE; 1647 } 1648 if(yydebug) 1649 printf("(%d)#else ignored\n", line_number); 1650 } 1651 YY_BREAK 1652 case 20: 1653 YY_RULE_SETUP 1654 #line 527 "parser.l" 1655 { 1656 if(!isnevertrue_if()) 1657 { 1658 want_nl = 1; 1659 return tENDIF; 1660 } 1661 else 1662 { 1663 if(yydebug) 1664 printf("(%d)#endif ignored\n", line_number); 1665 pop_if(); 1666 } 1667 } 1668 YY_BREAK 1669 /* The error directive */ 1670 case 21: 1671 YY_RULE_SETUP 1672 #line 542 "parser.l" 1673 push_to(pp_error); 1674 YY_BREAK 1675 case 22: 1676 YY_RULE_SETUP 1677 #line 543 "parser.l" 1678 yyerror("Error directive: %s", yytext); 1679 YY_BREAK 1680 case 23: 1681 YY_RULE_SETUP 1682 #line 544 "parser.l" 1683 { 1684 if(yydebug) 1685 printf("(%d)#error ignored\n", line_number); 1686 } 1687 YY_BREAK 1688 /* preprocessor junk */ 1689 case 24: 1690 YY_RULE_SETUP 1691 #line 550 "parser.l" 1692 ; /* Ignore #pragma */ 1693 YY_BREAK 1694 case 25: 1695 YY_RULE_SETUP 1696 #line 551 "parser.l" 1697 ; /* Ignore #ident */ 1698 YY_BREAK 1699 case 26: 1700 YY_RULE_SETUP 1701 #line 552 "parser.l" 1702 ; /* Ignore #line */ 1703 YY_BREAK 1704 /* We'll get an error on malformed #xxx statements 1705 * by not recognising '#' at all. This helps tracking 1706 * preprocessor errors. 1707 */ 1708 /*^{ws}*#{ws}* ; Ignore # */ 1709 case 27: 1710 YY_RULE_SETUP 1711 #line 559 "parser.l" 1712 stripslevel++; 1713 YY_BREAK 1714 case 28: 1715 YY_RULE_SETUP 1716 #line 560 "parser.l" 1717 stripslevel--; 1718 YY_BREAK 1719 case 29: 1720 YY_RULE_SETUP 1721 #line 561 "parser.l" 1722 if(!stripslevel) pop_start(); 1723 YY_BREAK 1724 case 30: 1725 YY_RULE_SETUP 1726 #line 562 "parser.l" 1727 ; /* To catch comments */ 1728 YY_BREAK 1729 case 31: 1730 YY_RULE_SETUP 1731 #line 563 "parser.l" 1732 ; /* Ignore rest */ 1733 YY_BREAK 1734 case 32: 1735 YY_RULE_SETUP 1736 #line 565 "parser.l" 1737 stripslevel++; 1738 YY_BREAK 1739 case 33: 1740 YY_RULE_SETUP 1741 #line 566 "parser.l" 1742 { 1743 stripslevel--; 1744 if(!stripslevel) pop_start(); 1745 } 1746 YY_BREAK 1747 case 34: 1748 YY_RULE_SETUP 1749 #line 570 "parser.l" 1750 if(!stripslevel) pop_start(); 1751 YY_BREAK 1752 case 35: 1753 YY_RULE_SETUP 1754 #line 571 "parser.l" 1755 ; /* To catch comments */ 1756 YY_BREAK 1757 case 36: 1758 YY_RULE_SETUP 1759 #line 572 "parser.l" 1760 ; /* Ignore rest */ 1761 YY_BREAK 1762 case 37: 1763 YY_RULE_SETUP 1764 #line 574 "parser.l" 1765 stripplevel++; 1766 YY_BREAK 1767 case 38: 1768 YY_RULE_SETUP 1769 #line 575 "parser.l" 1770 { 1771 stripplevel--; 1772 if(!stripplevel) 1773 { 1774 pop_start(); 1775 push_to(pp_stripp_final); 1776 } 1777 } 1778 YY_BREAK 1779 case 39: 1780 YY_RULE_SETUP 1781 #line 583 "parser.l" 1782 ; /* To catch comments */ 1783 YY_BREAK 1784 case 40: 1785 YY_RULE_SETUP 1786 #line 584 "parser.l" 1787 ; /* Ignore rest */ 1788 YY_BREAK 1789 case 41: 1790 YY_RULE_SETUP 1791 #line 586 "parser.l" 1792 ; /* Ignore */ 1793 YY_BREAK 1794 case 42: 1795 YY_RULE_SETUP 1796 #line 587 "parser.l" 1797 pop_start(); /* Kill the semicolon */ 1798 YY_BREAK 1799 case 43: 1800 YY_RULE_SETUP 1801 #line 588 "parser.l" 1802 line_number++; char_number = 1; pop_start(); 1803 YY_BREAK 1804 case 44: 1805 YY_RULE_SETUP 1806 #line 589 "parser.l" 1807 yyless(0); pop_start(); 1808 YY_BREAK 1809 case 45: 1810 YY_RULE_SETUP 1811 #line 591 "parser.l" 1812 ; /* Ignore everything except #xxx during false #if state */ 1813 YY_BREAK 1814 case 46: 1815 YY_RULE_SETUP 1816 #line 593 "parser.l" 1817 pop_start(); 1818 YY_BREAK 1819 /* These are special cases due to filename scanning */ 1820 case 47: 1821 YY_RULE_SETUP 1822 #line 596 "parser.l" 1823 return DISCARDABLE; 1824 YY_BREAK 1825 case 48: 1826 YY_RULE_SETUP 1827 #line 597 "parser.l" 1828 return tFIXED; 1829 YY_BREAK 1830 case 49: 1831 YY_RULE_SETUP 1832 #line 598 "parser.l" 1833 return IMPURE; 1834 YY_BREAK 1835 case 50: 1836 YY_RULE_SETUP 1837 #line 599 "parser.l" 1838 return MOVEABLE; 1839 YY_BREAK 1840 case 51: 1841 YY_RULE_SETUP 1842 #line 600 "parser.l" 1843 return LOADONCALL; 1844 YY_BREAK 1845 case 52: 1846 YY_RULE_SETUP 1847 #line 601 "parser.l" 1848 return PRELOAD; 1849 YY_BREAK 1850 case 53: 1851 YY_RULE_SETUP 1852 #line 602 "parser.l" 1853 return tPURE; 1854 YY_BREAK 1855 case 54: 1856 YY_RULE_SETUP 1857 #line 604 "parser.l" 1858 return tBEGIN; 1859 YY_BREAK 1860 case 55: 1861 YY_RULE_SETUP 1862 #line 605 "parser.l" 1863 return tEND; 1864 YY_BREAK 1865 case 56: 1866 YY_RULE_SETUP 1867 #line 607 "parser.l" 1868 { yylval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? LNUMBER : NUMBER; } 1869 YY_BREAK 1870 case 57: 1871 YY_RULE_SETUP 1872 #line 608 "parser.l" 1873 { yylval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? LNUMBER : NUMBER; } 1874 YY_BREAK 1875 case 58: 1876 YY_RULE_SETUP 1877 #line 609 "parser.l" 1878 { yylval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? LNUMBER : NUMBER; } 1879 YY_BREAK 1880 case 59: 1881 YY_RULE_SETUP 1882 #line 610 "parser.l" 1883 { 1884 struct keyword *token; 1885 struct pp_entry *ppp; 1886 1887 want_rscname = 0; 1888 1889 if(want_ident) 1890 { 1891 /* Prevent preprocessor subst */ 1892 want_ident = 0; 1893 yylval.str = make_string(yytext); 1894 #ifdef LEX_DEBUG 1895 printf("want IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext); 1896 #endif 1897 return IDENT; 1898 } 1899 else if((ppp = pp_lookup(yytext)) != NULL) 1900 { 1901 /* Do preprocessor substitution, 1902 * but expand only if macro is not 1903 * already expanding. 1904 */ 1905 if(!ppp->expanding) 1215 stripplevel--; 1216 if(!stripplevel) 1906 1217 { 1907 #ifdef LEX_DEBUG 1908 printf("expand IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext); 1909 #endif 1910 push_buffer(YY_CURRENT_BUFFER, ppp, NULL); 1911 yy_scan_string(ppp->subst); 1218 yy_pop_state(); 1219 yy_push_state(pp_stripp_final); 1912 1220 } 1913 1221 } 1914 else if((token = iskeyword(yytext)) != NULL 1915 && !(!token->alwayskeyword && want_rscname)) 1222 YY_BREAK 1223 case 11: 1224 YY_RULE_SETUP 1225 #line 355 "parser.l" 1226 ; /* To catch comments */ 1227 YY_BREAK 1228 case 12: 1229 YY_RULE_SETUP 1230 #line 356 "parser.l" 1231 ; /* Ignore rest */ 1232 YY_BREAK 1233 case 13: 1234 YY_RULE_SETUP 1235 #line 357 "parser.l" 1236 line_number++; char_number = 1; 1237 YY_BREAK 1238 case 14: 1239 YY_RULE_SETUP 1240 #line 359 "parser.l" 1241 ; /* Ignore */ 1242 YY_BREAK 1243 case 15: 1244 YY_RULE_SETUP 1245 #line 360 "parser.l" 1246 yy_pop_state(); /* Kill the semicolon */ 1247 YY_BREAK 1248 case 16: 1249 YY_RULE_SETUP 1250 #line 361 "parser.l" 1251 line_number++; char_number = 1; yy_pop_state(); 1252 YY_BREAK 1253 case 17: 1254 YY_RULE_SETUP 1255 #line 362 "parser.l" 1256 yyless(0); yy_pop_state(); 1257 YY_BREAK 1258 case 18: 1259 YY_RULE_SETUP 1260 #line 364 "parser.l" 1261 return tBEGIN; 1262 YY_BREAK 1263 case 19: 1264 YY_RULE_SETUP 1265 #line 365 "parser.l" 1266 return tEND; 1267 YY_BREAK 1268 case 20: 1269 YY_RULE_SETUP 1270 #line 367 "parser.l" 1271 { yylval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 1272 YY_BREAK 1273 case 21: 1274 YY_RULE_SETUP 1275 #line 368 "parser.l" 1276 { yylval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 1277 YY_BREAK 1278 case 22: 1279 YY_RULE_SETUP 1280 #line 369 "parser.l" 1281 { yylval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 1282 YY_BREAK 1283 /* 1284 * The next two rules scan identifiers and filenames. 1285 * This is achieved by using the priority ruling 1286 * of the scanner where a '.' is valid in a filename 1287 * and *only* in a filename. In this case, the second 1288 * rule will be reduced because it is longer. 1289 */ 1290 case 23: 1291 YY_RULE_SETUP 1292 #line 378 "parser.l" 1293 { 1294 struct keyword *tok = iskeyword(yytext); 1295 1296 if(tok) 1916 1297 { 1917 switch(token->token) 1298 if(tok->token == tCLASS && !strcmp(yytext, "class")) 1299 return tCPPCLASS; 1300 else if(wanted_id && !tok->alwayskw) 1918 1301 { 1919 case tDEFINED: 1920 want_ident = 1; 1921 break; 1922 /*case RCDATA:*/ 1923 case CURSOR: 1924 case tBITMAP: 1925 case MESSAGETABLE: 1926 case DLGINIT: 1927 push_to(yywf); 1928 break; 1929 case FONT: 1930 case ICON: 1931 if(!indialog) 1932 push_to(yywf); 1933 break; 1934 case DIALOG: 1935 case DIALOGEX: 1936 indialog = 1; 1937 break; 1302 yylval.str = make_string(yytext); 1303 return tIDENT; 1938 1304 } 1939 return token->token; 1305 else 1306 return tok->token; 1940 1307 } 1941 1308 else 1942 1309 { 1943 1310 yylval.str = make_string(yytext); 1944 #ifdef LEX_DEBUG 1945 printf("%s IDENT (%s, %d, %d): <%s>\n", 1946 want_rscname ? "rscname" : "just", 1947 input_name, 1948 line_number, 1949 char_number, 1950 yytext); 1951 #endif 1952 return IDENT; 1311 return tIDENT; 1953 1312 } 1954 1313 } 1955 1314 YY_BREAK 1956 case 60: 1957 YY_RULE_SETUP 1958 #line 682 "parser.l" 1959 return LOGOR; 1960 YY_BREAK 1961 case 61: 1962 YY_RULE_SETUP 1963 #line 683 "parser.l" 1964 return LOGAND; 1965 YY_BREAK 1966 case 62: 1967 YY_RULE_SETUP 1968 #line 684 "parser.l" 1969 return EQ; 1970 YY_BREAK 1971 case 63: 1972 YY_RULE_SETUP 1973 #line 685 "parser.l" 1974 return NE; 1975 YY_BREAK 1976 case 64: 1977 YY_RULE_SETUP 1978 #line 686 "parser.l" 1979 return LTE; 1980 YY_BREAK 1981 case 65: 1982 YY_RULE_SETUP 1983 #line 687 "parser.l" 1984 return GTE; 1985 YY_BREAK 1986 case 66: 1987 YY_RULE_SETUP 1988 #line 689 "parser.l" 1989 { pop_start(); yylval.str = make_filename(yytext, yyleng); return FILENAME; } 1990 YY_BREAK 1991 case 67: 1992 YY_RULE_SETUP 1993 #line 690 "parser.l" 1994 push_to(yywf_s); 1995 YY_BREAK 1996 case 68: 1997 YY_RULE_SETUP 1998 #line 691 "parser.l" 1999 { pop_start(); pop_start(); yylval.str = make_filename(yytext, yyleng-1); return FILENAME; } 2000 YY_BREAK 2001 case 69: 2002 YY_RULE_SETUP 2003 #line 692 "parser.l" 2004 yyerror("Newline in filename"); 2005 YY_BREAK 2006 case 70: 2007 YY_RULE_SETUP 2008 #line 694 "parser.l" 1315 case 24: 1316 YY_RULE_SETUP 1317 #line 399 "parser.l" 1318 yylval.str = make_string(yytext); return tFILENAME; 1319 YY_BREAK 1320 /* 1321 * Wide string scanning 1322 */ 1323 case 25: 1324 YY_RULE_SETUP 1325 #line 404 "parser.l" 2009 1326 { 2010 push_to(yylstr);1327 yy_push_state(yylstr); 2011 1328 wbufidx = 0; 2012 1329 if(!win32) … … 2014 1331 } 2015 1332 YY_BREAK 2016 case 71: 2017 YY_RULE_SETUP 2018 #line 700 "parser.l" 1333 case 26: 1334 #line 411 "parser.l" 1335 case 27: 1336 YY_RULE_SETUP 1337 #line 411 "parser.l" 2019 1338 { 2020 pop_start();1339 yy_pop_state(); 2021 1340 yylval.str = get_buffered_wstring(); 2022 1341 return tSTRING; 2023 1342 } 2024 1343 YY_BREAK 2025 case 72: 2026 YY_RULE_SETUP 2027 #line 705 "parser.l" 2028 yyerror("Unterminated string"); 2029 YY_BREAK 2030 case 73: 2031 YY_RULE_SETUP 2032 #line 706 "parser.l" 1344 case 28: 1345 YY_RULE_SETUP 1346 #line 416 "parser.l" 2033 1347 { /* octal escape sequence */ 2034 1348 int result; … … 2039 1353 } 2040 1354 YY_BREAK 2041 case 74:2042 YY_RULE_SETUP 2043 #line 713 "parser.l"1355 case 29: 1356 YY_RULE_SETUP 1357 #line 423 "parser.l" 2044 1358 { /* hex escape sequence */ 2045 1359 int result; … … 2048 1362 } 2049 1363 YY_BREAK 2050 case 75: 2051 YY_RULE_SETUP 2052 #line 718 "parser.l" 1364 case 30: 1365 YY_RULE_SETUP 1366 #line 428 "parser.l" 1367 { yyerror("Invalid hex escape sequence '%s'", yytext); } 1368 YY_BREAK 1369 case 31: 1370 YY_RULE_SETUP 1371 #line 430 "parser.l" 2053 1372 yyerror("Bad escape secuence"); 2054 1373 YY_BREAK 2055 case 76:2056 YY_RULE_SETUP 2057 #line 719"parser.l"1374 case 32: 1375 YY_RULE_SETUP 1376 #line 431 "parser.l" 2058 1377 addwchar('\a'); 2059 1378 YY_BREAK 2060 case 77:2061 YY_RULE_SETUP 2062 #line 720"parser.l"1379 case 33: 1380 YY_RULE_SETUP 1381 #line 432 "parser.l" 2063 1382 addwchar('\b'); 2064 1383 YY_BREAK 2065 case 78:2066 YY_RULE_SETUP 2067 #line 721"parser.l"1384 case 34: 1385 YY_RULE_SETUP 1386 #line 433 "parser.l" 2068 1387 addwchar('\f'); 2069 1388 YY_BREAK 2070 case 79:2071 YY_RULE_SETUP 2072 #line 722"parser.l"1389 case 35: 1390 YY_RULE_SETUP 1391 #line 434 "parser.l" 2073 1392 addwchar('\n'); 2074 1393 YY_BREAK 2075 case 80:2076 YY_RULE_SETUP 2077 #line 723"parser.l"1394 case 36: 1395 YY_RULE_SETUP 1396 #line 435 "parser.l" 2078 1397 addwchar('\r'); 2079 1398 YY_BREAK 2080 case 81:2081 YY_RULE_SETUP 2082 #line 724"parser.l"1399 case 37: 1400 YY_RULE_SETUP 1401 #line 436 "parser.l" 2083 1402 addwchar('\t'); 2084 1403 YY_BREAK 2085 case 82:2086 YY_RULE_SETUP 2087 #line 725"parser.l"1404 case 38: 1405 YY_RULE_SETUP 1406 #line 437 "parser.l" 2088 1407 addwchar('\v'); 2089 1408 YY_BREAK 2090 case 83:2091 YY_RULE_SETUP 2092 #line 726"parser.l"1409 case 39: 1410 YY_RULE_SETUP 1411 #line 438 "parser.l" 2093 1412 addwchar(yytext[1]); 2094 1413 YY_BREAK 2095 case 84: 2096 YY_RULE_SETUP 2097 #line 727 "parser.l" 1414 case 40: 1415 YY_RULE_SETUP 1416 #line 439 "parser.l" 1417 addwchar(yytext[2]); 1418 YY_BREAK 1419 case 41: 1420 YY_RULE_SETUP 1421 #line 440 "parser.l" 2098 1422 addcchar('\"'); /* "bla""bla" -> "bla\"bla" */ 2099 1423 YY_BREAK 2100 case 85:2101 YY_RULE_SETUP 2102 #line 728"parser.l"1424 case 42: 1425 YY_RULE_SETUP 1426 #line 441 "parser.l" 2103 1427 addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */ 2104 1428 YY_BREAK 2105 case 86:2106 YY_RULE_SETUP 2107 #line 729"parser.l"1429 case 43: 1430 YY_RULE_SETUP 1431 #line 442 "parser.l" 2108 1432 ; /* "bla" "bla" -> "blabla" */ 2109 1433 YY_BREAK 2110 case 87:2111 YY_RULE_SETUP 2112 #line 730"parser.l"1434 case 44: 1435 YY_RULE_SETUP 1436 #line 443 "parser.l" 2113 1437 { 2114 1438 char *yptr = yytext; … … 2117 1441 } 2118 1442 YY_BREAK 2119 case 88: 2120 YY_RULE_SETUP 2121 #line 736 "parser.l" 1443 case 45: 1444 YY_RULE_SETUP 1445 #line 448 "parser.l" 1446 yyerror("Unterminated string"); 1447 YY_BREAK 1448 /* 1449 * Normal string scanning 1450 */ 1451 case 46: 1452 YY_RULE_SETUP 1453 #line 453 "parser.l" 1454 yy_push_state(yystr); cbufidx = 0; 1455 YY_BREAK 1456 case 47: 1457 #line 455 "parser.l" 1458 case 48: 1459 YY_RULE_SETUP 1460 #line 455 "parser.l" 2122 1461 { 2123 push_to(yystr); 2124 cbufidx = 0; 2125 } 2126 YY_BREAK 2127 case 89: 2128 YY_RULE_SETUP 2129 #line 740 "parser.l" 2130 { 2131 pop_start(); 1462 yy_pop_state(); 2132 1463 yylval.str = get_buffered_cstring(); 2133 1464 return tSTRING; 2134 1465 } 2135 1466 YY_BREAK 2136 case 90: 2137 YY_RULE_SETUP 2138 #line 745 "parser.l" 2139 yyerror("Unterminated string"); 2140 YY_BREAK 2141 case 91: 2142 YY_RULE_SETUP 2143 #line 746 "parser.l" 1467 case 49: 1468 YY_RULE_SETUP 1469 #line 460 "parser.l" 2144 1470 { /* octal escape sequence */ 2145 1471 int result; … … 2150 1476 } 2151 1477 YY_BREAK 2152 case 92:2153 YY_RULE_SETUP 2154 #line 753"parser.l"1478 case 50: 1479 YY_RULE_SETUP 1480 #line 467 "parser.l" 2155 1481 { /* hex escape sequence */ 2156 1482 int result; … … 2159 1485 } 2160 1486 YY_BREAK 2161 case 93: 2162 YY_RULE_SETUP 2163 #line 758 "parser.l" 1487 case 51: 1488 YY_RULE_SETUP 1489 #line 472 "parser.l" 1490 { yyerror("Invalid hex escape sequence '%s'", yytext); } 1491 YY_BREAK 1492 case 52: 1493 YY_RULE_SETUP 1494 #line 474 "parser.l" 2164 1495 yyerror("Bad escape secuence"); 2165 1496 YY_BREAK 2166 case 94:2167 YY_RULE_SETUP 2168 #line 759"parser.l"1497 case 53: 1498 YY_RULE_SETUP 1499 #line 475 "parser.l" 2169 1500 addcchar('\a'); 2170 1501 YY_BREAK 2171 case 95:2172 YY_RULE_SETUP 2173 #line 760"parser.l"1502 case 54: 1503 YY_RULE_SETUP 1504 #line 476 "parser.l" 2174 1505 addcchar('\b'); 2175 1506 YY_BREAK 2176 case 96:2177 YY_RULE_SETUP 2178 #line 761"parser.l"1507 case 55: 1508 YY_RULE_SETUP 1509 #line 477 "parser.l" 2179 1510 addcchar('\f'); 2180 1511 YY_BREAK 2181 case 97:2182 YY_RULE_SETUP 2183 #line 762"parser.l"1512 case 56: 1513 YY_RULE_SETUP 1514 #line 478 "parser.l" 2184 1515 addcchar('\n'); 2185 1516 YY_BREAK 2186 case 98:2187 YY_RULE_SETUP 2188 #line 763"parser.l"1517 case 57: 1518 YY_RULE_SETUP 1519 #line 479 "parser.l" 2189 1520 addcchar('\r'); 2190 1521 YY_BREAK 2191 case 99:2192 YY_RULE_SETUP 2193 #line 764"parser.l"1522 case 58: 1523 YY_RULE_SETUP 1524 #line 480 "parser.l" 2194 1525 addcchar('\t'); 2195 1526 YY_BREAK 2196 case 100:2197 YY_RULE_SETUP 2198 #line 765"parser.l"1527 case 59: 1528 YY_RULE_SETUP 1529 #line 481 "parser.l" 2199 1530 addcchar('\v'); 2200 1531 YY_BREAK 2201 case 101:2202 YY_RULE_SETUP 2203 #line 766"parser.l"1532 case 60: 1533 YY_RULE_SETUP 1534 #line 482 "parser.l" 2204 1535 addcchar(yytext[1]); 2205 1536 YY_BREAK 2206 case 102: 2207 YY_RULE_SETUP 2208 #line 767 "parser.l" 1537 case 61: 1538 YY_RULE_SETUP 1539 #line 483 "parser.l" 1540 addcchar(yytext[2]); 1541 YY_BREAK 1542 case 62: 1543 YY_RULE_SETUP 1544 #line 484 "parser.l" 2209 1545 { 2210 1546 char *yptr = yytext; … … 2213 1549 } 2214 1550 YY_BREAK 2215 case 103:2216 YY_RULE_SETUP 2217 #line 772"parser.l"1551 case 63: 1552 YY_RULE_SETUP 1553 #line 489 "parser.l" 2218 1554 addcchar('\"'); /* "bla""bla" -> "bla\"bla" */ 2219 1555 YY_BREAK 2220 case 104:2221 YY_RULE_SETUP 2222 #line 773"parser.l"1556 case 64: 1557 YY_RULE_SETUP 1558 #line 490 "parser.l" 2223 1559 addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */ 2224 1560 YY_BREAK 2225 case 105:2226 YY_RULE_SETUP 2227 #line 774"parser.l"1561 case 65: 1562 YY_RULE_SETUP 1563 #line 491 "parser.l" 2228 1564 ; /* "bla" "bla" -> "blabla" */ 2229 1565 YY_BREAK 2230 case 106: 2231 YY_RULE_SETUP 2232 #line 775 "parser.l" 2233 yywarning("Matched %c", *yytext); 2234 YY_BREAK 2235 case 107: 2236 YY_RULE_SETUP 2237 #line 778 "parser.l" 1566 case 66: 1567 YY_RULE_SETUP 1568 #line 492 "parser.l" 1569 yyerror("Unterminated string"); 1570 YY_BREAK 1571 /* 1572 * Raw data scanning 1573 */ 1574 case 67: 1575 YY_RULE_SETUP 1576 #line 497 "parser.l" 1577 yy_push_state(yyrcd); cbufidx = 0; 1578 YY_BREAK 1579 case 68: 1580 YY_RULE_SETUP 1581 #line 498 "parser.l" 2238 1582 { 2239 push_to(yyrcd); 2240 cbufidx = 0; 2241 } 2242 YY_BREAK 2243 case 108: 2244 YY_RULE_SETUP 2245 #line 782 "parser.l" 2246 { 2247 pop_start(); 1583 yy_pop_state(); 2248 1584 yylval.raw = new_raw_data(); 2249 1585 yylval.raw->size = cbufidx; 2250 1586 yylval.raw->data = xmalloc(yylval.raw->size); 2251 1587 memcpy(yylval.raw->data, cbuffer, yylval.raw->size); 2252 return RAWDATA;2253 } 2254 YY_BREAK 2255 case 109:2256 YY_RULE_SETUP 2257 #line 790"parser.l"1588 return tRAWDATA; 1589 } 1590 YY_BREAK 1591 case 69: 1592 YY_RULE_SETUP 1593 #line 506 "parser.l" 2258 1594 { 2259 1595 int result; … … 2262 1598 } 2263 1599 YY_BREAK 2264 case 110:2265 YY_RULE_SETUP 2266 #line 795"parser.l"1600 case 70: 1601 YY_RULE_SETUP 1602 #line 511 "parser.l" 2267 1603 ; /* Ignore space */ 2268 1604 YY_BREAK 2269 case 111:2270 YY_RULE_SETUP 2271 #line 796"parser.l"1605 case 71: 1606 YY_RULE_SETUP 1607 #line 512 "parser.l" 2272 1608 line_number++; char_number = 1; 2273 1609 YY_BREAK 2274 case 112:2275 YY_RULE_SETUP 2276 #line 797"parser.l"1610 case 72: 1611 YY_RULE_SETUP 1612 #line 513 "parser.l" 2277 1613 yyerror("Malformed data-line"); 2278 1614 YY_BREAK 2279 case 113: 2280 YY_RULE_SETUP 2281 #line 799 "parser.l" 2282 push_to(comment); /* Eat comment */ 2283 YY_BREAK 2284 case 114: 2285 YY_RULE_SETUP 2286 #line 800 "parser.l" 1615 /* 1616 * Comment stripping 1617 * Should never occur after preprocessing 1618 */ 1619 case 73: 1620 YY_RULE_SETUP 1621 #line 519 "parser.l" 1622 { 1623 yy_push_state(comment); 1624 save_wanted_id = wanted_id; 1625 if(!no_preprocess) 1626 yywarning("Found comments after preprocessing, please report"); 1627 } 1628 YY_BREAK 1629 case 74: 1630 YY_RULE_SETUP 1631 #line 525 "parser.l" 2287 1632 ; 2288 1633 YY_BREAK 2289 case 115:2290 YY_RULE_SETUP 2291 #line 801"parser.l"1634 case 75: 1635 YY_RULE_SETUP 1636 #line 526 "parser.l" 2292 1637 ; 2293 1638 YY_BREAK 2294 case 116:2295 YY_RULE_SETUP 2296 #line 802"parser.l"1639 case 76: 1640 YY_RULE_SETUP 1641 #line 527 "parser.l" 2297 1642 line_number++; char_number = 1; 2298 1643 YY_BREAK 2299 case 117:2300 YY_RULE_SETUP 2301 #line 803"parser.l"2302 pop_start();2303 YY_BREAK 2304 case 118:2305 YY_RULE_SETUP 2306 #line 805"parser.l"2307 ; /* Eat comment*/2308 YY_BREAK 2309 case 119:2310 YY_RULE_SETUP 2311 #line 806"parser.l"2312 ; /* Eat comment */ 2313 YY_BREAK 2314 case 120:2315 YY_RULE_SETUP 2316 #line 808"parser.l"1644 case 77: 1645 YY_RULE_SETUP 1646 #line 528 "parser.l" 1647 yy_pop_state(); want_id = save_wanted_id; 1648 YY_BREAK 1649 case 78: 1650 YY_RULE_SETUP 1651 #line 530 "parser.l" 1652 want_id = wanted_id; /* not really comment, but left-over c-junk */ 1653 YY_BREAK 1654 case 79: 1655 YY_RULE_SETUP 1656 #line 531 "parser.l" 1657 want_id = wanted_id; if(!no_preprocess) yywarning("Found comments after preprocessing, please report"); 1658 YY_BREAK 1659 case 80: 1660 YY_RULE_SETUP 1661 #line 533 "parser.l" 2317 1662 { 2318 if(YY_START == yywf) 2319 pop_start(); 1663 want_id = wanted_id; 2320 1664 line_number++; 2321 1665 char_number = 1; … … 2327 1671 } 2328 1672 YY_BREAK 2329 case 121:2330 YY_RULE_SETUP 2331 #line 819"parser.l"2332 ; /* Eat whitespace */2333 YY_BREAK 2334 case 122:2335 YY_RULE_SETUP 2336 #line 821"parser.l"1673 case 81: 1674 YY_RULE_SETUP 1675 #line 543 "parser.l" 1676 want_id = wanted_id; /* Eat whitespace */ 1677 YY_BREAK 1678 case 82: 1679 YY_RULE_SETUP 1680 #line 545 "parser.l" 2337 1681 return yytext[0]; 2338 1682 YY_BREAK 2339 1683 case YY_STATE_EOF(INITIAL): 2340 case YY_STATE_EOF(yywf):2341 case YY_STATE_EOF(yywf_s):2342 1684 case YY_STATE_EOF(yystr): 2343 1685 case YY_STATE_EOF(yylstr): 2344 1686 case YY_STATE_EOF(yyrcd): 2345 1687 case YY_STATE_EOF(comment): 2346 case YY_STATE_EOF(pp_incl):2347 case YY_STATE_EOF(pp_def):2348 case YY_STATE_EOF(pp_undef):2349 case YY_STATE_EOF(pp_if):2350 case YY_STATE_EOF(pp_ifdef):2351 case YY_STATE_EOF(pp_ifndef):2352 case YY_STATE_EOF(pp_elif):2353 case YY_STATE_EOF(pp_else):2354 case YY_STATE_EOF(pp_endif):2355 case YY_STATE_EOF(pp_error):2356 case YY_STATE_EOF(pp_def_s):2357 case YY_STATE_EOF(pp_ignore):2358 case YY_STATE_EOF(pp_ignore_eol):2359 case YY_STATE_EOF(pp_false):2360 1688 case YY_STATE_EOF(pp_stripe): 2361 1689 case YY_STATE_EOF(pp_strips): 2362 1690 case YY_STATE_EOF(pp_stripp): 2363 1691 case YY_STATE_EOF(pp_stripp_final): 2364 #line 822 "parser.l" 1692 case YY_STATE_EOF(pp_line): 1693 #line 547 "parser.l" 2365 1694 { 2366 YY_BUFFER_STATE b = YY_CURRENT_BUFFER; 2367 if(!pop_buffer()) 2368 { 2369 if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final) 2370 yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline); 2371 else 2372 yyterminate(); 2373 } 2374 yy_delete_buffer(b); 2375 } 2376 YY_BREAK 2377 case 123: 2378 YY_RULE_SETUP 2379 #line 834 "parser.l" 1695 if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final) 1696 yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline); 1697 else 1698 yyterminate(); 1699 } 1700 YY_BREAK 1701 case 83: 1702 YY_RULE_SETUP 1703 #line 554 "parser.l" 2380 1704 { 2381 1705 /* Catch all rule to find any unmatched text */ … … 2386 1710 } 2387 1711 yywarning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d", 2388 isprint(*yytext ) ? *yytext : '.', *yytext, YY_START,stripslevel);2389 } 2390 YY_BREAK 2391 case 124:2392 YY_RULE_SETUP 2393 #line 845 "parser.l"1712 isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START,stripslevel); 1713 } 1714 YY_BREAK 1715 case 84: 1716 YY_RULE_SETUP 1717 #line 565 "parser.l" 2394 1718 ECHO; 2395 1719 YY_BREAK 2396 #line 2397"lexyy.c"1720 #line 1721 "lexyy.c" 2397 1721 2398 1722 case YY_END_OF_BUFFER: … … 2682 2006 { 2683 2007 yy_current_state = (int) yy_def[yy_current_state]; 2684 if ( yy_current_state >= 369)2008 if ( yy_current_state >= 162 ) 2685 2009 yy_c = yy_meta[(unsigned int) yy_c]; 2686 2010 } … … 2717 2041 { 2718 2042 yy_current_state = (int) yy_def[yy_current_state]; 2719 if ( yy_current_state >= 369)2043 if ( yy_current_state >= 162 ) 2720 2044 yy_c = yy_meta[(unsigned int) yy_c]; 2721 2045 } 2722 2046 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 2723 yy_is_jam = (yy_current_state == 368);2047 yy_is_jam = (yy_current_state == 161); 2724 2048 2725 2049 return yy_is_jam ? 0 : yy_current_state; … … 3254 2578 } 3255 2579 #endif 3256 #line 845 "parser.l"2580 #line 565 "parser.l" 3257 2581 3258 2582 … … 3273 2597 * the resource string. 3274 2598 */ 3275 void addcchar(char c)2599 static void addcchar(char c) 3276 2600 { 3277 2601 if(cbufidx >= cbufalloc) … … 3285 2609 } 3286 2610 3287 void addwchar(short s)2611 static void addwchar(short s) 3288 2612 { 3289 2613 if(wbufidx >= wbufalloc) … … 3306 2630 } 3307 2631 3308 st ring_t *get_buffered_cstring(void)2632 static string_t *get_buffered_cstring(void) 3309 2633 { 3310 2634 string_t *str = new_string(); … … 3314 2638 memcpy(str->str.cstr, cbuffer, cbufidx); 3315 2639 str->str.cstr[cbufidx] = '\0'; 3316 /* printf("got cstring \"%s\"\n", str->str.cstr); */3317 2640 return str; 3318 2641 } 3319 2642 3320 st ring_t *get_buffered_wstring(void)2643 static string_t *get_buffered_wstring(void) 3321 2644 { 3322 2645 string_t *str = new_string(); … … 3329 2652 } 3330 2653 3331 st ring_t *make_string(char *s)2654 static string_t *make_string(char *s) 3332 2655 { 3333 2656 string_t *str = new_string(); … … 3339 2662 } 3340 2663 3341 string_t *make_filename(char *s, int len)3342 {3343 char *cptr;3344 string_t *str = new_string();3345 3346 str->size = len;3347 str->type = str_char;3348 str->str.cstr = (char *)xmalloc(str->size+1);3349 memcpy(str->str.cstr, s, str->size);3350 str->str.cstr[str->size] = '\0';3351 3352 /* Remove escaped backslash and convert to forward */3353 cptr = str->str.cstr;3354 for(cptr = str->str.cstr; (cptr = strchr(cptr, '\\')) != NULL; cptr++)3355 {3356 if(cptr[1] == '\\')3357 {3358 memmove(cptr, cptr+1, strlen(cptr));3359 str->size--;3360 }3361 *cptr = '/';3362 }3363 3364 /* Convert to lower case. Seems to be reasonable to do */3365 for(cptr = str->str.cstr; !leave_case && *cptr; cptr++)3366 {3367 *cptr = tolower(*cptr);3368 }3369 return str;3370 }3371 3372 /* Called from the parser to signal filename request */3373 void set_yywf(void)3374 {3375 push_to(yywf);3376 }3377 3378 /* Called from the parser to signal preprocessor if case */3379 void set_pp_ignore(int state)3380 {3381 if(state)3382 push_to(pp_false);3383 else3384 pop_start();3385 }3386 3387 2664 /* Called from the parser to kill c-junk */ 3388 2665 void strip_extern(void) 3389 2666 { 3390 2667 cjunk_tagline = line_number; 3391 push_to(pp_stripe);2668 yy_push_state(pp_stripe); 3392 2669 } 3393 2670 … … 3395 2672 { 3396 2673 cjunk_tagline = line_number; 3397 push_to(pp_strips);2674 yy_push_state(pp_strips); 3398 2675 } 3399 2676 … … 3402 2679 cjunk_tagline = line_number; 3403 2680 stripplevel = 1; /* One scanned already */ 3404 push_to(pp_stripp);2681 yy_push_state(pp_stripp); 3405 2682 } 3406 2683 -
trunk/tools/wrc/makefile.os2
r4712 r5522 1 # $Id: makefile.os2,v 1.1 2 2000-12-02 23:27:03 birdExp $1 # $Id: makefile.os2,v 1.13 2001-04-16 17:10:52 sandervl Exp $ 2 2 3 3 … … 8 8 9 9 #DEFS = -D__WINE__ -D__WIN32OS2__ -idirafter ../../include/win -idirafter ../../include 10 DEFS = -D__WINE__ -D__ SEMICOLON__ -I. -I../../include/win -I../../include10 DEFS = -D__WINE__ -D__EMX__ -DMASM -D__SEMICOLON__ -I. -I../../include/win -I../../include -g -DDEBUG 11 11 12 12 PROGRAMS = wrc.exe 13 13 MODULE = none 14 15 YACCOPT = #-v 14 16 15 17 OBJS = \ … … 23 25 y.tab.o \ 24 26 lexyy.o \ 25 writeres.o 27 ppy.tab.o \ 28 lex.ppl.o \ 29 writeres.o \ 30 u/string.o \ 31 u/cptable.o \ 32 u/utf8.o \ 33 u/mbtowc.o \ 34 u/wctomb.o \ 35 u/c_869.o \ 36 u/c_775.o \ 37 u/c_865.o \ 38 u/c_857.o \ 39 u/c_10000.o \ 40 u/c_10006.o \ 41 u/c_861.o \ 42 u/c_737.o \ 43 u/c_860.o \ 44 u/c_1253.o \ 45 u/c_28597.o \ 46 u/c_10029.o \ 47 u/c_10081.o \ 48 u/c_1257.o \ 49 u/c_1252.o \ 50 u/c_1254.o \ 51 u/c_28591.o \ 52 u/c_437.o \ 53 u/c_10079.o \ 54 u/c_852.o \ 55 u/c_875.o \ 56 u/c_863.o \ 57 u/c_037.o \ 58 u/c_1258.o \ 59 u/c_1250.o \ 60 u/c_850.o \ 61 u/c_28605.o \ 62 u/c_500.o \ 63 u/c_28599.o \ 64 u/c_28600.o \ 65 u/c_28603.o \ 66 u/c_28604.o \ 67 u/c_28594.o \ 68 u/c_1026.o \ 69 u/c_28592.o \ 70 u/c_28593.o \ 71 u/c_856.o \ 72 u/c_1006.o \ 73 u/c_862.o \ 74 u/c_864.o \ 75 u/c_878.o \ 76 u/c_866.o \ 77 u/c_855.o \ 78 u/c_20866.o \ 79 u/c_874.o \ 80 u/c_424.o \ 81 u/c_1255.o \ 82 u/c_1256.o \ 83 u/c_28596.o \ 84 u/c_28598.o \ 85 u/c_10007.o \ 86 u/c_1251.o \ 87 u/c_28595.o \ 88 u/c_042.o \ 89 u/compose.o \ 90 u/c_932.o \ 91 u/c_950.o \ 92 u/c_936.o \ 93 u/c_949.o \ 94 u/casemap.o \ 95 u/wctype.o 26 96 27 97 EXTRA_SRCS = parser.y parser.l … … 43 113 44 114 wrc.exe: lexyy.c y.tab.c $(OBJS) 45 $(CC) $(CFLAGS) -o $@ $(OBJS) 115 $(CC) $(CFLAGS) -o $@ $(OBJS) -L. -lm 46 116 copy $@ ..\bin 47 117 … … 50 120 51 121 lexyy.c: parser.l 52 $(LEX) -8 parser.l122 $(LEX) -8 -d parser.l 53 123 124 ppy.tab.c ppy.tab.h: ppy.y 125 $(YACC) $(YACCOPT) -bppy -ppp -d -t ppy.y -o ppy.tab.c 126 127 lex.ppl.c: ppl.l 128 $(LEX) $(LEXOPT) -d -Ppp -8 -olex.ppl.c ppl.l 54 129 55 130 dep: -
trunk/tools/wrc/newstruc.c
r3426 r5522 13 13 #include <string.h> 14 14 #include <assert.h> 15 #include <ctype.h> 15 16 16 17 #include "wrc.h" … … 18 19 #include "utils.h" 19 20 #include "parser.h" 21 22 #include "wingdi.h" /* for BITMAPINFOHEADER */ 20 23 21 24 /* Generate new_* functions that have no parameters (NOTE: no ';') */ … … 41 44 __NEW_STRUCT_FUNC(string) 42 45 __NEW_STRUCT_FUNC(toolbar_item) 46 __NEW_STRUCT_FUNC(ani_any) 43 47 44 48 /* New instances for all types of structures */ … … 145 149 } 146 150 else 147 fnt->memopt = WRC_MO_MOVEABLE | WRC_MO_ PURE;151 fnt->memopt = WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE; 148 152 return fnt; 149 153 } 154 155 fontdir_t *new_fontdir(raw_data_t *rd, int *memopt) 156 { 157 fontdir_t *fnd = (fontdir_t *)xmalloc(sizeof(fontdir_t)); 158 fnd->data = rd; 159 if(memopt) 160 { 161 fnd->memopt = *memopt; 162 free(memopt); 163 } 164 else 165 fnd->memopt = WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE; 166 return fnd; 167 } 168 169 170 /* 171 * Convert bitmaps to proper endian 172 */ 173 static void convert_bitmap_swap_v3(BITMAPINFOHEADER *bih) 174 { 175 bih->biSize = BYTESWAP_DWORD(bih->biSize); 176 bih->biWidth = BYTESWAP_DWORD(bih->biWidth); 177 bih->biHeight = BYTESWAP_DWORD(bih->biHeight); 178 bih->biPlanes = BYTESWAP_WORD(bih->biPlanes); 179 bih->biBitCount = BYTESWAP_WORD(bih->biBitCount); 180 bih->biCompression = BYTESWAP_DWORD(bih->biCompression); 181 bih->biSizeImage = BYTESWAP_DWORD(bih->biSizeImage); 182 bih->biXPelsPerMeter = BYTESWAP_DWORD(bih->biXPelsPerMeter); 183 bih->biYPelsPerMeter = BYTESWAP_DWORD(bih->biYPelsPerMeter); 184 bih->biClrUsed = BYTESWAP_DWORD(bih->biClrUsed); 185 bih->biClrImportant = BYTESWAP_DWORD(bih->biClrImportant); 186 } 187 188 static void convert_bitmap_swap_v4(BITMAPV4HEADER *b4h) 189 { 190 convert_bitmap_swap_v3((BITMAPINFOHEADER *)b4h); 191 b4h->bV4RedMask = BYTESWAP_DWORD(b4h->bV4RedMask); 192 b4h->bV4GreenMask = BYTESWAP_DWORD(b4h->bV4GreenMask); 193 b4h->bV4BlueMask = BYTESWAP_DWORD(b4h->bV4BlueMask); 194 b4h->bV4AlphaMask = BYTESWAP_DWORD(b4h->bV4AlphaMask); 195 b4h->bV4CSType = BYTESWAP_DWORD(b4h->bV4CSType); 196 b4h->bV4Endpoints.ciexyzRed.ciexyzX = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzRed.ciexyzX); 197 b4h->bV4Endpoints.ciexyzRed.ciexyzY = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzRed.ciexyzY); 198 b4h->bV4Endpoints.ciexyzRed.ciexyzZ = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzRed.ciexyzZ); 199 b4h->bV4Endpoints.ciexyzGreen.ciexyzX = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzGreen.ciexyzX); 200 b4h->bV4Endpoints.ciexyzGreen.ciexyzY = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzGreen.ciexyzY); 201 b4h->bV4Endpoints.ciexyzGreen.ciexyzZ = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzGreen.ciexyzZ); 202 b4h->bV4Endpoints.ciexyzBlue.ciexyzX = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzBlue.ciexyzX); 203 b4h->bV4Endpoints.ciexyzBlue.ciexyzY = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzBlue.ciexyzY); 204 b4h->bV4Endpoints.ciexyzBlue.ciexyzZ = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzBlue.ciexyzZ); 205 b4h->bV4GammaRed = BYTESWAP_DWORD(b4h->bV4GammaRed); 206 b4h->bV4GammaGreen = BYTESWAP_DWORD(b4h->bV4GammaGreen); 207 b4h->bV4GammaBlue = BYTESWAP_DWORD(b4h->bV4GammaBlue); 208 } 209 210 #define FL_SIGBE 0x01 211 #define FL_SIZEBE 0x02 212 #define FL_V4 0x04 213 static int convert_bitmap(char *data, int size) 214 { 215 BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)data; 216 BITMAPV4HEADER *b4h = (BITMAPV4HEADER *)data; 217 int type = 0; 218 #ifdef WORDS_BIGENDIAN 219 DWORD bisizel = BYTESWAP_DWORD(sizeof(BITMAPINFOHEADER)); 220 DWORD b4sizel = BYTESWAP_DWORD(sizeof(BITMAPV4HEADER)); 221 DWORD bisizeb = sizeof(BITMAPINFOHEADER); 222 DWORD b4sizeb = sizeof(BITMAPV4HEADER); 223 #else 224 DWORD bisizel = sizeof(BITMAPINFOHEADER); 225 DWORD b4sizel = sizeof(BITMAPV4HEADER); 226 DWORD bisizeb = BYTESWAP_DWORD(sizeof(BITMAPINFOHEADER)); 227 DWORD b4sizeb = BYTESWAP_DWORD(sizeof(BITMAPV4HEADER)); 228 #endif 229 230 if(data[0] == 'B' && data[1] == 'M') 231 { 232 /* Little endian signature */ 233 bih = (BITMAPINFOHEADER *)(data + sizeof(BITMAPFILEHEADER)); 234 b4h = (BITMAPV4HEADER *)(data + sizeof(BITMAPFILEHEADER)); 235 } 236 else if(data[0] == 'M' && data[1] == 'B') 237 { 238 type |= FL_SIGBE; /* Big endian signature */ 239 bih = (BITMAPINFOHEADER *)(data + sizeof(BITMAPFILEHEADER)); 240 b4h = (BITMAPV4HEADER *)(data + sizeof(BITMAPFILEHEADER)); 241 } 242 243 if(bih->biSize == bisizel) 244 { 245 /* Little endian */ 246 } 247 else if(bih->biSize == b4sizel) 248 { 249 type |= FL_V4; 250 } 251 else if(bih->biSize == bisizeb) 252 { 253 type |= FL_SIZEBE; 254 } 255 else if(bih->biSize == b4sizeb) 256 { 257 type |= FL_SIZEBE | FL_V4; 258 } 259 #ifdef __EMX__ 260 else if(bih->biSize == sizeof(BITMAPCOREHEADER)) 261 { 262 /* Little endian */ 263 } 264 #endif 265 else 266 type = -1; 267 268 switch(type) 269 { 270 default: 271 break; 272 case FL_SIZEBE: 273 case FL_SIZEBE | FL_V4: 274 yywarning("Bitmap v%c signature little-endian, but size big-endian", type & FL_V4 ? '4' : '3'); 275 break; 276 case FL_SIGBE: 277 case FL_SIGBE | FL_V4: 278 yywarning("Bitmap v%c signature big-endian, but size little-endian", type & FL_V4 ? '4' : '3'); 279 break; 280 case -1: 281 yyerror("Invalid bitmap format"); 282 break; 283 } 284 285 switch(byteorder) 286 { 287 #ifdef WORDS_BIGENDIAN 288 default: 289 #endif 290 case WRC_BO_BIG: 291 if(!(type & FL_SIZEBE)) 292 { 293 if(type & FL_V4) 294 convert_bitmap_swap_v4(b4h); 295 else 296 convert_bitmap_swap_v3(bih); 297 } 298 break; 299 #ifndef WORDS_BIGENDIAN 300 default: 301 #endif 302 case WRC_BO_LITTLE: 303 if(type & FL_SIZEBE) 304 { 305 if(type & FL_V4) 306 convert_bitmap_swap_v4(b4h); 307 else 308 convert_bitmap_swap_v3(bih); 309 } 310 break; 311 } 312 313 if(size && (void *)data != (void *)bih) 314 { 315 /* We have the fileheader still attached, remove it */ 316 memmove(data, data+sizeof(BITMAPFILEHEADER), size - sizeof(BITMAPFILEHEADER)); 317 return sizeof(BITMAPFILEHEADER); 318 } 319 return 0; 320 } 321 #undef FL_SIGBE 322 #undef FL_SIZEBE 323 #undef FL_V4 324 325 /* 326 * Cursor and icon splitter functions used when allocating 327 * cursor- and icon-groups. 328 */ 329 typedef struct { 330 language_t lan; 331 int id; 332 } id_alloc_t; 333 334 static int get_new_id(id_alloc_t **list, int *n, language_t *lan) 335 { 336 int i; 337 assert(lan != NULL); 338 assert(list != NULL); 339 assert(n != NULL); 340 341 if(!*list) 342 { 343 *list = (id_alloc_t *)xmalloc(sizeof(id_alloc_t)); 344 *n = 1; 345 (*list)[0].lan = *lan; 346 (*list)[0].id = 1; 347 return 1; 348 } 349 350 for(i = 0; i < *n; i++) 351 { 352 if((*list)[i].lan.id == lan->id && (*list)[i].lan.sub == lan->sub) 353 return ++((*list)[i].id); 354 } 355 356 *list = (id_alloc_t *)xrealloc(*list, sizeof(id_alloc_t) * (*n+1)); 357 (*list)[*n].lan = *lan; 358 (*list)[*n].id = 1; 359 *n += 1; 360 return 1; 361 } 362 363 static int alloc_icon_id(language_t *lan) 364 { 365 static id_alloc_t *idlist = NULL; 366 static int nid = 0; 367 368 return get_new_id(&idlist, &nid, lan); 369 } 370 371 static int alloc_cursor_id(language_t *lan) 372 { 373 static id_alloc_t *idlist = NULL; 374 static int nid = 0; 375 376 return get_new_id(&idlist, &nid, lan); 377 } 378 379 static void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico) 380 { 381 int cnt; 382 int i; 383 icon_t *ico; 384 icon_t *list = NULL; 385 icon_header_t *ih = (icon_header_t *)rd->data; 386 int swap = 0; 387 388 if(ih->type == 1) 389 swap = 0; 390 else if(BYTESWAP_WORD(ih->type) == 1) 391 swap = 1; 392 else 393 yyerror("Icon resource data has invalid type id %d", ih->type); 394 395 cnt = swap ? BYTESWAP_WORD(ih->count) : ih->count; 396 for(i = 0; i < cnt; i++) 397 { 398 icon_dir_entry_t ide; 399 BITMAPINFOHEADER info; 400 memcpy(&ide, rd->data + sizeof(icon_header_t) 401 + i*sizeof(icon_dir_entry_t), sizeof(ide)); 402 403 ico = new_icon(); 404 ico->id = alloc_icon_id(icog->lvc.language); 405 ico->lvc = icog->lvc; 406 if(swap) 407 { 408 ide.offset = BYTESWAP_DWORD(ide.offset); 409 ide.ressize= BYTESWAP_DWORD(ide.ressize); 410 } 411 if(ide.offset > rd->size 412 || ide.offset + ide.ressize > rd->size) 413 yyerror("Icon resource data corrupt"); 414 ico->width = ide.width; 415 ico->height = ide.height; 416 ico->nclr = ide.nclr; 417 ico->planes = swap ? BYTESWAP_WORD(ide.planes) : ide.planes; 418 ico->bits = swap ? BYTESWAP_WORD(ide.bits) : ide.bits; 419 convert_bitmap((char *)rd->data + ide.offset, 0); 420 memcpy(&info, rd->data + ide.offset, sizeof(info)); 421 if(!ico->planes) 422 { 423 /* Argh! They did not fill out the resdir structure */ 424 /* The bitmap is in destination byteorder. We want native for our structures */ 425 switch(byteorder) 426 { 427 #ifdef WORDS_BIGENDIAN 428 case WRC_BO_LITTLE: 429 #else 430 case WRC_BO_BIG: 431 #endif 432 ico->planes = BYTESWAP_WORD(info.biPlanes); 433 break; 434 default: 435 ico->planes = info.biPlanes; 436 } 437 } 438 if(!ico->bits) 439 { 440 /* Argh! They did not fill out the resdir structure */ 441 /* The bitmap is in destination byteorder. We want native for our structures */ 442 switch(byteorder) 443 { 444 #ifdef WORDS_BIGENDIAN 445 case WRC_BO_LITTLE: 446 #else 447 case WRC_BO_BIG: 448 #endif 449 ico->bits = BYTESWAP_WORD(info.biBitCount); 450 break; 451 default: 452 ico->bits = info.biBitCount; 453 } 454 } 455 ico->data = new_raw_data(); 456 copy_raw_data(ico->data, rd, ide.offset, ide.ressize); 457 if(!list) 458 { 459 list = ico; 460 } 461 else 462 { 463 ico->next = list; 464 list->prev = ico; 465 list = ico; 466 } 467 } 468 icog->iconlist = list; 469 *nico = cnt; 470 } 471 472 static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur) 473 { 474 int cnt; 475 int i; 476 cursor_t *cur; 477 cursor_t *list = NULL; 478 cursor_header_t *ch = (cursor_header_t *)rd->data; 479 int swap = 0; 480 481 if(ch->type == 2) 482 swap = 0; 483 else if(BYTESWAP_WORD(ch->type) == 2) 484 swap = 1; 485 else 486 yyerror("Cursor resource data has invalid type id %d", ch->type); 487 cnt = swap ? BYTESWAP_WORD(ch->count) : ch->count; 488 for(i = 0; i < cnt; i++) 489 { 490 cursor_dir_entry_t cde; 491 BITMAPINFOHEADER info; 492 memcpy(&cde, rd->data + sizeof(cursor_header_t) 493 + i*sizeof(cursor_dir_entry_t), sizeof(cde)); 494 495 cur = new_cursor(); 496 cur->id = alloc_cursor_id(curg->lvc.language); 497 cur->lvc = curg->lvc; 498 if(swap) 499 { 500 cde.offset = BYTESWAP_DWORD(cde.offset); 501 cde.ressize= BYTESWAP_DWORD(cde.ressize); 502 } 503 if(cde.offset > rd->size 504 || cde.offset + cde.ressize > rd->size) 505 yyerror("Cursor resource data corrupt"); 506 cur->width = cde.width; 507 cur->height = cde.height; 508 cur->nclr = cde.nclr; 509 convert_bitmap((char *)rd->data + cde.offset, 0); 510 memcpy(&info, rd->data + cde.offset, sizeof(info)); 511 /* The bitmap is in destination byteorder. We want native for our structures */ 512 switch(byteorder) 513 { 514 #ifdef WORDS_BIGENDIAN 515 case WRC_BO_LITTLE: 516 #else 517 case WRC_BO_BIG: 518 #endif 519 cur->planes = BYTESWAP_WORD(info.biPlanes); 520 cur->bits = BYTESWAP_WORD(info.biBitCount); 521 break; 522 default: 523 cur->planes = info.biPlanes; 524 cur->bits = info.biBitCount; 525 } 526 if(!win32 && (cur->planes != 1 || cur->bits != 1)) 527 yywarning("Win16 cursor contains colors"); 528 cur->xhot = swap ? BYTESWAP_WORD(cde.xhot) : cde.xhot; 529 cur->yhot = swap ? BYTESWAP_WORD(cde.yhot) : cde.yhot; 530 cur->data = new_raw_data(); 531 copy_raw_data(cur->data, rd, cde.offset, cde.ressize); 532 if(!list) 533 { 534 list = cur; 535 } 536 else 537 { 538 cur->next = list; 539 list->prev = cur; 540 list = cur; 541 } 542 } 543 curg->cursorlist = list; 544 *ncur = cnt; 545 } 546 150 547 151 548 icon_group_t *new_icon_group(raw_data_t *rd, int *memopt) … … 159 556 else 160 557 icog->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE; 161 icog->lvc .language = dup_language(currentlanguage);558 icog->lvc = rd->lvc; 162 559 split_icons(rd, icog, &(icog->nicon)); 163 560 free(rd->data); … … 176 573 else 177 574 curg->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE; 178 curg->lvc .language = dup_language(currentlanguage);575 curg->lvc = rd->lvc; 179 576 split_cursors(rd, curg, &(curg->ncursor)); 180 577 free(rd->data); … … 183 580 } 184 581 582 /* 583 * Animated cursors and icons 584 * 585 * The format of animated cursors and icons is yet another example 586 * of bad design by "The Company". The entire RIFF structure is 587 * flawed by design because it is inconsistent and single minded: 588 * - some tags have lengths attached, others don't. The use of these 589 * non-length tags is absolutely unclear; 590 * - the content of "icon" tags can be both icons and cursors; 591 * - tags lack proper alignment constraints. It seems that everything 592 * is 16bit aligned, but I could not find that in any docu. Just be 593 * prepared to eat anything; 594 * - there are no strict constraints on tag-nesting and the organization 595 * is highly illogical; 596 * 597 * Anyhow, here is the basic structure: 598 * "RIFF" { dword taglength } 599 * "ACON" // What does it do? 600 * "LIST" { dword taglength } 601 * "INFO" // And what does this do? 602 * "INAM" { dword taglength } // Icon/cursor name 603 * {inam data} 604 * "IART" { dword taglength } // The artist 605 * {iart data} 606 * "fram" // Is followed by "icon"s 607 * "icon" { dword taglength } // First frame 608 * { icon/cursor data } 609 * "icon" { dword taglength } // Second frame 610 * { icon/cursor data } 611 * ... // ... 612 * "anih" { dword taglength } // Header structure 613 * { aniheader_t structure } 614 * "rate" { dword taglength } // The rate for each frame 615 * { `steps' dwords } 616 * "seq " { dword taglength } // The frame blit-order 617 * { `steps' dwords } 618 * 619 * Tag length are bytelength without the header and length field (i.e. -8). 620 * The "LIST" tag may occur several times and may encapsulate different 621 * tags. The `steps' is the number of "icon" tags found (actually the 622 * number of steps specified in the aniheader_t structure). The "seq "uence 623 * tag can be ommitted, in which case the sequence is equal to the sequence 624 * of "icon"s found in the file. Also "rate" may be ommitted, in which case 625 * the default from the aniheader_t structure is used. 626 * 627 * An animated cursor puts `.cur' formatted files into each "icon" tag, 628 * whereas animated icons contain `.ico' formatted files. 629 * 630 * Note about the code: Yes, it can be shorter/compressed. Some tags can be 631 * dealt with in the same code. However, this version shows what is going on 632 * and is better debug-able. 633 */ 634 static const char riff[4] = "RIFF"; 635 static const char acon[4] = "ACON"; 636 static const char list[4] = "LIST"; 637 static const char info[4] = "INFO"; 638 static const char inam[4] = "INAM"; 639 static const char iart[4] = "IART"; 640 static const char fram[4] = "fram"; 641 static const char icon[4] = "icon"; 642 static const char anih[4] = "anih"; 643 static const char rate[4] = "rate"; 644 static const char seq[4] = "seq "; 645 646 #define NEXT_TAG(p) ((riff_tag_t *)(((char *)p) + (isswapped ? BYTESWAP_DWORD(p->size) : p->size) + sizeof(*p))) 647 648 static void handle_ani_icon(riff_tag_t *rtp, enum res_e type, int isswapped) 649 { 650 cursor_dir_entry_t *cdp; 651 cursor_header_t *chp; 652 int count; 653 int ctype; 654 int i; 655 static int once = 0; /* This will trigger only once per file! */ 656 const char *anistr = type == res_aniico ? "icon" : "cursor"; 657 /* Notes: 658 * Both cursor and icon directories are similar 659 * Both cursor and icon headers are similar 660 */ 661 662 chp = (cursor_header_t *)(rtp+1); 663 cdp = (cursor_dir_entry_t *)(chp+1); 664 count = isswapped ? BYTESWAP_WORD(chp->count) : chp->count; 665 ctype = isswapped ? BYTESWAP_WORD(chp->type) : chp->type; 666 chp->reserved = BYTESWAP_WORD(chp->reserved); 667 chp->type = BYTESWAP_WORD(chp->type); 668 chp->count = BYTESWAP_WORD(chp->count); 669 670 if(type == res_anicur && ctype != 2 && !once) 671 { 672 yywarning("Animated cursor contains invalid \"icon\" tag cursor-file (%d->%s)", 673 ctype, 674 ctype == 1 ? "icontype" : "?"); 675 once++; 676 } 677 else if(type == res_aniico && ctype != 1 && !once) 678 { 679 yywarning("Animated icon contains invalid \"icon\" tag icon-file (%d->%s)", 680 ctype, 681 ctype == 2 ? "cursortype" : "?"); 682 once++; 683 } 684 else if(ctype != 1 && ctype != 2 && !once) 685 { 686 yywarning("Animated %s contains invalid \"icon\" tag file-type (%d; neither icon nor cursor)", anistr, ctype); 687 once++; 688 } 689 690 for(i = 0; i < count; i++) 691 { 692 DWORD ofs = isswapped ? BYTESWAP_DWORD(cdp[i].offset) : cdp[i].offset; 693 DWORD sze = isswapped ? BYTESWAP_DWORD(cdp[i].ressize) : cdp[i].ressize; 694 if(ofs > rtp->size || ofs+sze > rtp->size) 695 yyerror("Animated %s's data corrupt", anistr); 696 convert_bitmap((char *)chp + ofs, 0); 697 cdp[i].xhot = BYTESWAP_WORD(cdp->xhot); 698 cdp[i].yhot = BYTESWAP_WORD(cdp->yhot); 699 cdp[i].ressize = BYTESWAP_DWORD(cdp->ressize); 700 cdp[i].offset = BYTESWAP_DWORD(cdp->offset); 701 } 702 } 703 704 static void handle_ani_list(riff_tag_t *lst, enum res_e type, int isswapped) 705 { 706 riff_tag_t *rtp = lst+1; /* Skip the "LIST" tag */ 707 708 while((char *)rtp < (char *)lst + lst->size + sizeof(*lst)) 709 { 710 if(!memcmp(rtp->tag, info, sizeof(info))) 711 { 712 rtp = (riff_tag_t *)(((char *)rtp) + 4); 713 } 714 else if(!memcmp(rtp->tag, inam, sizeof(inam))) 715 { 716 /* Ignore the icon/cursor name; its a string */ 717 rtp = NEXT_TAG(rtp); 718 } 719 else if(!memcmp(rtp->tag, iart, sizeof(iart))) 720 { 721 /* Ignore the author's name; its a string */ 722 rtp = NEXT_TAG(rtp); 723 } 724 else if(!memcmp(rtp->tag, fram, sizeof(fram))) 725 { 726 /* This should be followed by "icon"s, but we 727 * simply ignore this because it is pure 728 * non-information. 729 */ 730 rtp = (riff_tag_t *)(((char *)rtp) + 4); 731 } 732 else if(!memcmp(rtp->tag, icon, sizeof(icon))) 733 { 734 handle_ani_icon(rtp, type, isswapped); 735 rtp = NEXT_TAG(rtp); 736 } 737 else 738 internal_error(__FILE__, __LINE__, "Unknown tag \"%c%c%c%c\" in RIFF file", 739 isprint(rtp->tag[0]) ? rtp->tag[0] : '.', 740 isprint(rtp->tag[1]) ? rtp->tag[1] : '.', 741 isprint(rtp->tag[2]) ? rtp->tag[2] : '.', 742 isprint(rtp->tag[3]) ? rtp->tag[3] : '.'); 743 744 /* FIXME: This relies in sizeof(DWORD) == sizeof(pointer_type) */ 745 if((DWORD)rtp & 1) 746 ((char *)rtp)++; 747 } 748 } 749 750 ani_curico_t *new_ani_curico(enum res_e type, raw_data_t *rd, int *memopt) 751 { 752 ani_curico_t *ani = (ani_curico_t *)xmalloc(sizeof(ani_curico_t)); 753 riff_tag_t *rtp; 754 int isswapped = 0; 755 int doswap; 756 const char *anistr = type == res_aniico ? "icon" : "cursor"; 757 758 assert(!memcmp(rd->data, riff, sizeof(riff))); 759 assert(type == res_anicur || type == res_aniico); 760 761 rtp = (riff_tag_t *)rd->data; 762 763 if(BYTESWAP_DWORD(rtp->size) + 2*sizeof(DWORD) == rd->size) 764 isswapped = 1; 765 else if(rtp->size + 2*sizeof(DWORD) == rd->size) 766 isswapped = 0; 767 else 768 yyerror("Animated %s has an invalid RIFF length", anistr); 769 770 switch(byteorder) 771 { 772 #ifdef WORDS_BIGENDIAN 773 case WRC_BO_LITTLE: 774 #else 775 case WRC_BO_BIG: 776 #endif 777 doswap = !isswapped; 778 break; 779 default: 780 doswap = isswapped; 781 } 782 783 /* 784 * When to swap what: 785 * isswapped | doswap | 786 * ----------+--------+--------------------------------- 787 * 0 | 0 | read native; don't convert 788 * 1 | 0 | read swapped size; don't convert 789 * 0 | 1 | read native; convert 790 * 1 | 1 | read swapped size; convert 791 * Reading swapped size if necessary to calculate in native 792 * format. E.g. a little-endian source on a big-endian 793 * processor. 794 */ 795 if(doswap) 796 { 797 /* We only go through the RIFF file if we need to swap 798 * bytes in words/dwords. Else we couldn't care less 799 * what the file contains. This is consistent with 800 * MS' rc.exe, which doesn't complain at all, eventhough 801 * the fileformat might not be entirely correct. 802 */ 803 rtp++; /* Skip the "RIFF" tag */ 804 805 while((char *)rtp < (char *)rd->data + rd->size) 806 { 807 if(!memcmp(rtp->tag, acon, sizeof(acon))) 808 { 809 rtp = (riff_tag_t *)(((char *)rtp) + 4); 810 } 811 else if(!memcmp(rtp->tag, list, sizeof(list))) 812 { 813 handle_ani_list(rtp, type, isswapped); 814 rtp = NEXT_TAG(rtp); 815 } 816 else if(!memcmp(rtp->tag, anih, sizeof(anih))) 817 { 818 aniheader_t *ahp = (aniheader_t *)((char *)(rtp+1)); 819 ahp->structsize = BYTESWAP_DWORD(ahp->structsize); 820 ahp->frames = BYTESWAP_DWORD(ahp->frames); 821 ahp->steps = BYTESWAP_DWORD(ahp->steps); 822 ahp->cx = BYTESWAP_DWORD(ahp->cx); 823 ahp->cy = BYTESWAP_DWORD(ahp->cy); 824 ahp->bitcount = BYTESWAP_DWORD(ahp->bitcount); 825 ahp->planes = BYTESWAP_DWORD(ahp->planes); 826 ahp->rate = BYTESWAP_DWORD(ahp->rate); 827 ahp->flags = BYTESWAP_DWORD(ahp->flags); 828 rtp = NEXT_TAG(rtp); 829 } 830 else if(!memcmp(rtp->tag, rate, sizeof(rate))) 831 { 832 int cnt = rtp->size / sizeof(DWORD); 833 DWORD *dwp = (DWORD *)(rtp+1); 834 int i; 835 for(i = 0; i < cnt; i++) 836 dwp[i] = BYTESWAP_DWORD(dwp[i]); 837 rtp = NEXT_TAG(rtp); 838 } 839 else if(!memcmp(rtp->tag, seq, sizeof(seq))) 840 { 841 int cnt = rtp->size / sizeof(DWORD); 842 DWORD *dwp = (DWORD *)(rtp+1); 843 int i; 844 for(i = 0; i < cnt; i++) 845 dwp[i] = BYTESWAP_DWORD(dwp[i]); 846 rtp = NEXT_TAG(rtp); 847 } 848 else 849 internal_error(__FILE__, __LINE__, "Unknown tag \"%c%c%c%c\" in RIFF file", 850 isprint(rtp->tag[0]) ? rtp->tag[0] : '.', 851 isprint(rtp->tag[1]) ? rtp->tag[1] : '.', 852 isprint(rtp->tag[2]) ? rtp->tag[2] : '.', 853 isprint(rtp->tag[3]) ? rtp->tag[3] : '.'); 854 855 /* FIXME: This relies in sizeof(DWORD) == sizeof(pointer_type) */ 856 if((DWORD)rtp & 1) 857 ((char *)rtp)++; 858 } 859 860 /* We must end correctly here */ 861 if((char *)rtp != (char *)rd->data + rd->size) 862 yyerror("Animated %s contains invalid field size(s)", anistr); 863 } 864 865 ani->data = rd; 866 if(memopt) 867 { 868 ani->memopt = *memopt; 869 free(memopt); 870 } 871 else 872 ani->memopt = WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE; 873 return ani; 874 } 875 #undef NEXT_TAG 876 877 /* Bitmaps */ 185 878 bitmap_t *new_bitmap(raw_data_t *rd, int *memopt) 186 879 { 187 880 bitmap_t *bmp = (bitmap_t *)xmalloc(sizeof(bitmap_t)); 881 188 882 bmp->data = rd; 189 883 if(memopt) … … 194 888 else 195 889 bmp->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE; 890 rd->size -= convert_bitmap(rd->data, rd->size); 196 891 return bmp; 197 892 } … … 214 909 } 215 910 216 messagetable_t *new_messagetable(raw_data_t *rd) 911 #define MSGTAB_BAD_PTR(p, b, l, r) (((l) - ((char *)(p) - (char *)(b))) > (r)) 912 messagetable_t *new_messagetable(raw_data_t *rd, int *memopt) 217 913 { 218 914 messagetable_t *msg = (messagetable_t *)xmalloc(sizeof(messagetable_t)); 915 msgtab_block_t *mbp; 916 DWORD nblk; 917 DWORD i; 918 WORD lo; 919 WORD hi; 920 219 921 msg->data = rd; 922 if(memopt) 923 { 924 msg->memopt = *memopt; 925 free(memopt); 926 } 927 else 928 msg->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE; 929 930 if(rd->size < sizeof(DWORD)) 931 yyerror("Invalid messagetable, size too small"); 932 933 nblk = *(DWORD *)rd->data; 934 lo = WRC_LOWORD(nblk); 935 hi = WRC_HIWORD(nblk); 936 937 /* FIXME: 938 * This test will fail for all n*2^16 blocks in the messagetable. 939 * However, no sane person would want to have so many blocks 940 * and have a table of megabytes attached. 941 * So, I will assume that we have less than 2^16 blocks in the table 942 * and all will just work out fine. Otherwise, we would need to test 943 * the ID, offset and length (and flag) fields to be very sure. 944 */ 945 if(hi && lo) 946 internal_error(__FILE__, __LINE__, "Messagetable contains more than 65535 blocks; cannot determine endian"); 947 if(!hi && !lo) 948 yyerror("Invalid messagetable block count 0"); 949 950 if(!hi && lo) /* Messagetable byteorder == native byteorder */ 951 { 952 #ifdef WORDS_BIGENDIAN 953 if(byteorder != WRC_BO_LITTLE) goto out; 954 #else 955 if(byteorder != WRC_BO_BIG) goto out; 956 #endif 957 /* Resource byteorder != native byteorder */ 958 959 mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]); 960 if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp))) 961 yyerror("Messagetable's blocks are outside of defined data"); 962 for(i = 0; i < nblk; i++) 963 { 964 msgtab_entry_t *mep, *next_mep; 965 DWORD id; 966 967 mep = (msgtab_entry_t *)(((char *)rd->data) + mbp[i].offset); 968 969 for(id = mbp[i].idlo; id <= mbp[i].idhi; id++) 970 { 971 if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length)) 972 yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id); 973 if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */ 974 { 975 WORD *wp = (WORD *)&mep[1]; 976 int l = mep->length/2 - 2; /* Length included header */ 977 int n; 978 979 if(mep->length & 1) 980 yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length); 981 for(n = 0; n < l; n++) 982 wp[n] = BYTESWAP_WORD(wp[n]); 983 984 } 985 next_mep = (msgtab_entry_t *)(((char *)mep) + mep->length); 986 mep->length = BYTESWAP_WORD(mep->length); 987 mep->flags = BYTESWAP_WORD(mep->flags); 988 mep = next_mep; 989 } 990 991 mbp[i].idlo = BYTESWAP_DWORD(mbp[i].idlo); 992 mbp[i].idhi = BYTESWAP_DWORD(mbp[i].idhi); 993 mbp[i].offset = BYTESWAP_DWORD(mbp[i].offset); 994 } 995 } 996 if(hi && !lo) /* Messagetable byteorder != native byteorder */ 997 { 998 #ifdef WORDS_BIGENDIAN 999 if(byteorder == WRC_BO_LITTLE) goto out; 1000 #else 1001 if(byteorder == WRC_BO_BIG) goto out; 1002 #endif 1003 /* Resource byteorder == native byteorder */ 1004 1005 mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]); 1006 nblk = BYTESWAP_DWORD(nblk); 1007 if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp))) 1008 yyerror("Messagetable's blocks are outside of defined data"); 1009 for(i = 0; i < nblk; i++) 1010 { 1011 msgtab_entry_t *mep; 1012 DWORD id; 1013 1014 mbp[i].idlo = BYTESWAP_DWORD(mbp[i].idlo); 1015 mbp[i].idhi = BYTESWAP_DWORD(mbp[i].idhi); 1016 mbp[i].offset = BYTESWAP_DWORD(mbp[i].offset); 1017 mep = (msgtab_entry_t *)(((char *)rd->data) + mbp[i].offset); 1018 1019 for(id = mbp[i].idlo; id <= mbp[i].idhi; id++) 1020 { 1021 mep->length = BYTESWAP_WORD(mep->length); 1022 mep->flags = BYTESWAP_WORD(mep->flags); 1023 1024 if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length)) 1025 yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id); 1026 if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */ 1027 { 1028 WORD *wp = (WORD *)&mep[1]; 1029 int l = mep->length/2 - 2; /* Length included header */ 1030 int n; 1031 1032 if(mep->length & 1) 1033 yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length); 1034 for(n = 0; n < l; n++) 1035 wp[n] = BYTESWAP_WORD(wp[n]); 1036 1037 } 1038 mep = (msgtab_entry_t *)(((char *)mep) + mep->length); 1039 } 1040 } 1041 } 1042 1043 out: 220 1044 return msg; 221 1045 } 222 223 void copy_raw_data(raw_data_t *dst, raw_data_t *src, int offs, int len) 1046 #undef MSGTAB_BAD_PTR 1047 1048 void copy_raw_data(raw_data_t *dst, raw_data_t *src, unsigned int offs, int len) 224 1049 { 225 1050 assert(offs <= src->size); … … 294 1119 return st; 295 1120 } 1121 -
trunk/tools/wrc/newstruc.h
r3426 r5522 42 42 __NEW_STRUCT_PROTO(string); 43 43 __NEW_STRUCT_PROTO(toolbar_item); 44 __NEW_STRUCT_PROTO(ani_any); 44 45 45 46 resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan); … … 54 55 user_t *new_user(name_id_t *type, raw_data_t *rd, int *memopt); 55 56 font_t *new_font(raw_data_t *rd, int *memopt); 57 fontdir_t *new_fontdir(raw_data_t *rd, int *memopt); 56 58 icon_group_t *new_icon_group(raw_data_t *rd, int *memopt); 57 59 cursor_group_t *new_cursor_group(raw_data_t *rd, int *memopt); 60 ani_curico_t *new_ani_curico(enum res_e type, raw_data_t *rd, int *memopt); 58 61 bitmap_t *new_bitmap(raw_data_t *rd, int *memopt); 59 62 ver_words_t *new_ver_words(int i); 60 63 ver_words_t *add_ver_words(ver_words_t *w, int i); 61 messagetable_t *new_messagetable(raw_data_t *rd );64 messagetable_t *new_messagetable(raw_data_t *rd, int *memopt); 62 65 dlginit_t *new_dlginit(raw_data_t *rd, int *memopt); 63 void copy_raw_data(raw_data_t *dst, raw_data_t *src, int offs, int len);66 void copy_raw_data(raw_data_t *dst, raw_data_t *src, unsigned int offs, int len); 64 67 int *new_int(int i); 65 68 stringtable_t *new_stringtable(lvc_t *lvc); -
trunk/tools/wrc/parser.h
r3426 r5522 10 10 /* From parser.y */ 11 11 extern int yydebug; 12 extern int indialog; /* Set when parsing dialogs */13 extern int want_ rscname; /* Set when a resource's name is required*/12 extern int want_nl; /* Set when getting line-numers */ 13 extern int want_id; /* Set when getting the resource name */ 14 14 15 15 int yyparse(void); 16 void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico);17 void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur);18 16 19 17 /* From parser.l */ 20 18 extern FILE *yyin; 21 19 extern char *yytext; 22 extern int line_number; 23 extern int char_number; 20 extern int yy_flex_debug; 24 21 25 22 int yylex(void); 26 void set_yywf(void);27 23 void set_pp_ignore(int state); 28 void push_to(int start);29 void pop_start(void);30 void strip_extern(void);31 24 void strip_til_semicolon(void); 32 25 void strip_til_parenthesis(void); -
trunk/tools/wrc/parser.l
r3426 r5522 1 1 /* -*-C-*- 2 2 * 3 * Copyright 1994 Martin von Loewis 4 * Copyright 1998 Bertho A. Stultiens (BS) 3 * Copyright 1998-2000 Bertho A. Stultiens (BS) 5 4 * 5 * 21-May-2000 BS - Fixed the ident requirement of resource names 6 * which can be keywords. 7 * 30-Apr-2000 BS - Reintegration into the wine-tree 8 * 11-Jan-2000 BS - Very drastic cleanup because we don't have a 9 * preprocessor in here anymore. 10 * 02-Jan-2000 BS - Removed the preprocessor code 11 * 23-Dec-1999 BS - Removed the copyright for Martin von Loewis. 12 * There is really nothing left of his code in 13 * this parser. 6 14 * 20-Jun-1998 BS - Changed the filename conversion. Filenames are 7 15 * case-sensitive inder *nix, but not under dos. … … 45 53 */ 46 54 47 /* Exclusive rules when looking for a filename */48 %x yywf49 %x yywf_s50 55 /* Exclusive string handling */ 51 56 %x yystr … … 56 61 /* Exclusive comment eating... */ 57 62 %x comment 58 /* Preprocessor exclusives */59 %x pp_incl60 %x pp_def61 %x pp_undef62 %x pp_if63 %x pp_ifdef64 %x pp_ifndef65 %x pp_elif66 %x pp_else67 %x pp_endif68 %x pp_error69 /* Set when accumulating #define's expansion text */70 %x pp_def_s71 /* Set when processing function type defines */72 %x pp_ignore73 /* Set when need to strip to eol */74 %x pp_ignore_eol75 /* Set when handling a false #if case */76 %x pp_false77 63 /* Set when stripping c-junk */ 78 64 %x pp_stripe … … 80 66 %x pp_stripp 81 67 %x pp_stripp_final 82 83 /*%option stack*/ 68 /* Set when scanning #line style directives */ 69 %x pp_line 70 71 %option stack 84 72 %option never-interactive 85 /*%option noyywrap */ 73 86 74 /* Some shortcut definitions */ 87 75 ws [ \f\t\r] … … 89 77 90 78 %{ 91 92 #if !defined(YY_FLEX_MAJOR_VERSION) || (1000 * YY_FLEX_MAJOR_VERSION + YY_FLEX_MINOR_VERSION < 2005)93 #error Must use flex version 2.5.1 or higher (yy_scan_* routines are required).94 #endif95 79 96 80 /*#define LEX_DEBUG*/ … … 102 86 #include <string.h> 103 87 #include <ctype.h> 88 #include <assert.h> 104 89 105 90 #include "wrc.h" … … 113 98 #define YY_USE_PROTOS 114 99 #define YY_NO_UNPUT 100 #define YY_NO_TOP_STATE 115 101 116 102 /* Always update the current character position within a line */ 117 #define YY_USER_ACTION char_number+=yyleng; 118 119 raw_data_t *new_raw_data(void); 120 121 void addcchar(char c); 122 void addwchar(short s); 123 string_t *get_buffered_cstring(void); 124 string_t *get_buffered_wstring(void); 125 string_t *make_string(char *s); 126 string_t *make_filename(char *s, int len); 127 128 int line_number = 1; /* The current line */ 129 int char_number = 1; /* The current char pos within the line */ 103 #define YY_USER_ACTION char_number+=yyleng; wanted_id = want_id; want_id = 0; 104 105 static void addcchar(char c); 106 static void addwchar(short s); 107 static string_t *get_buffered_cstring(void); 108 static string_t *get_buffered_wstring(void); 109 static string_t *make_string(char *s); 110 130 111 static char *cbuffer; /* Buffers for string collection */ 131 112 static int cbufidx; … … 134 115 static int wbufidx; 135 116 static int wbufalloc = 0; 136 static int want_nl = 0; /* Set when newline needs to go to parser */137 static int want_ident = 0; /* Set is #ifdef, #ifndef or defined is seen */138 117 static int stripslevel = 0; /* Count {} during pp_strips/pp_stripe mode */ 139 118 static int stripplevel = 0; /* Count () during pp_strips mode */ 140 static char *substtext = NULL; /* Holds the substition text while getting a define */141 119 static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */ 142 120 143 #ifdef YY_USE_STACK 144 void push_to(int start) { yy_push_state(start); } 145 void pop_start(void) { yy_pop_state(start); } 146 #else 147 #define MAXSTARTSTACK 32 148 static int startstack[MAXSTARTSTACK]; 149 static int startstackidx = 0; 150 151 void push_to(int start) 152 { 153 if(yydebug) 154 printf("push_to(%d): %d -> %d\n", line_number, YY_START, start); 155 if(startstackidx >= MAXSTARTSTACK-1) 156 internal_error(__FILE__, __LINE__, "Start condition stack overflow"); 157 startstack[startstackidx++] = YY_START; 158 BEGIN(start); 159 } 160 161 void pop_start(void) 162 { 163 if(yydebug) 164 printf("pop_start(%d): %d <- %d\n", line_number, startstack[startstackidx-1], YY_START); 165 if(startstackidx <= 0) 166 internal_error(__FILE__, __LINE__, "Start condition stack underflow"); 167 --startstackidx; 168 BEGIN(startstack[startstackidx]); 169 } 170 #endif 171 172 173 struct bufferstackentry { 174 YY_BUFFER_STATE bufferstate; /* Buffer to switch back to */ 175 struct pp_entry *define; /* Points to expanding define 176 or NULL if handling includes 177 */ 178 int line_number; /* Line that we were handling */ 179 int char_number; /* The current position */ 180 char *filename; /* Filename that we were handling */ 181 }; 182 183 #define MAXBUFFERSTACK 128 184 static struct bufferstackentry bufferstack[MAXBUFFERSTACK]; 185 static int bufferstackidx = 0; 186 187 void push_buffer(YY_BUFFER_STATE buf, struct pp_entry *ppp, char *filename) 188 { 189 if(yydebug) 190 printf("push_buffer: %p %p %p\n", buf, ppp, filename); 191 if(bufferstackidx >= MAXBUFFERSTACK-1) 192 internal_error(__FILE__, __LINE__, "Buffer stack overflow"); 193 memset(&bufferstack[bufferstackidx], 0, sizeof(bufferstack[0])); 194 bufferstack[bufferstackidx].bufferstate = buf; 195 bufferstack[bufferstackidx].define = ppp; 196 if(ppp) 197 ppp->expanding = 1; 198 else if(filename) 199 { 200 /* These will track the yyerror to the correct file and line */ 201 bufferstack[bufferstackidx].line_number = line_number; 202 bufferstack[bufferstackidx].char_number = char_number; 203 line_number = 1; 204 char_number = 1; 205 bufferstack[bufferstackidx].filename = input_name; 206 input_name = filename; 207 } 208 else 209 internal_error(__FILE__, __LINE__, "Pushing buffer without knowing where to go to"); 210 bufferstackidx++; 211 } 212 213 YY_BUFFER_STATE pop_buffer(void) 214 { 215 if(bufferstackidx <= 0) 216 return (YY_BUFFER_STATE)0; 217 bufferstackidx--; 218 if(bufferstack[bufferstackidx].define) 219 bufferstack[bufferstackidx].define->expanding = 0; 220 else 221 { 222 line_number = bufferstack[bufferstackidx].line_number; 223 char_number = bufferstack[bufferstackidx].char_number; 224 input_name = bufferstack[bufferstackidx].filename; 225 fclose(yyin); 226 } 227 if(yydebug) 228 printf("pop_buffer: %p %p (%d, %d) %p\n", 229 bufferstack[bufferstackidx].bufferstate, 230 bufferstack[bufferstackidx].define, 231 bufferstack[bufferstackidx].line_number, 232 bufferstack[bufferstackidx].char_number, 233 bufferstack[bufferstackidx].filename); 234 yy_switch_to_buffer(bufferstack[bufferstackidx].bufferstate); 235 return bufferstack[bufferstackidx].bufferstate; 236 } 237 238 void do_include(char *name, int namelen) 239 { 240 char *cpy = (char *)xmalloc(namelen); 241 strcpy(cpy, name+1); /* strip leading " or < */ 242 cpy[namelen-2] = '\0'; /* strip trailing " or > */ 243 if((yyin = open_include(cpy, name[0] == '"')) == NULL) 244 yyerror("Unable to open include file %s", cpy); 245 push_buffer(YY_CURRENT_BUFFER, NULL, cpy); 246 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); 247 } 248 121 /* 122 * This one is a bit tricky. 123 * We set 'want_id' in the parser to get the first 124 * identifier we get across in the scanner, but we 125 * also want it to be reset at nearly any token we 126 * see. Exceptions are: 127 * - newlines 128 * - comments 129 * - whitespace 130 * 131 * The scanner will automatically reset 'want_id' 132 * after *each* scanner reduction and puts is value 133 * into the var below. In this way we can see the 134 * state after the YY_RULE_SETUP (i.e. the user action; 135 * see above) and don't have to worry too much when 136 * it needs to be reset. 137 */ 138 static int wanted_id = 0; 139 static int save_wanted_id; /* To save across comment reductions */ 249 140 250 141 struct keyword { … … 253 144 int isextension; 254 145 int needcase; 255 int alwaysk eyword;146 int alwayskw; 256 147 }; 257 148 258 149 static struct keyword keywords[] = { 259 { "ACCELERATORS", ACCELERATORS, 0, 0, 0}, 260 { "ALT", ALT, 0, 0, 0}, 261 { "ASCII", ASCII, 0, 0, 0}, 262 { "AUTO3STATE", AUTO3STATE, 1, 0, 0}, 263 { "AUTOCHECKBOX", AUTOCHECKBOX, 1, 0, 0}, 264 { "AUTORADIOBUTTON", AUTORADIOBUTTON, 1, 0, 0}, 265 { "BEGIN", tBEGIN, 0, 0, 1}, 266 { "BITMAP", tBITMAP, 0, 0, 0}, 267 { "BLOCK", BLOCK, 0, 0, 1}, 268 { "BUTTON", BUTTON, 1, 0, 0}, 269 { "CAPTION", CAPTION, 0, 0, 0}, 270 { "CHARACTERISTICS", CHARACTERISTICS, 1, 0, 0}, 271 { "CHECKBOX", CHECKBOX, 0, 0, 0}, 272 { "CHECKED", CHECKED, 0, 0, 0}, 273 { "CLASS", CLASS, 0, 0, 0}, 274 { "COMBOBOX", COMBOBOX, 0, 0, 0}, 275 { "CONTROL", CONTROL, 0, 0, 0}, 276 { "CTEXT", CTEXT, 0, 0, 0}, 277 { "CURSOR", CURSOR, 0, 0, 0}, 278 { "defined", tDEFINED, 0, 1, 1}, 279 { "DEFPUSHBUTTON", DEFPUSHBUTTON, 0, 0, 1}, 280 { "DIALOG", DIALOG, 0, 0, 0}, 281 { "DIALOGEX", DIALOGEX, 1, 0, 0}, 282 { "DISCARDABLE", DISCARDABLE, 0, 0, 0}, 283 { "DLGINIT", DLGINIT, 0, 0, 0}, 284 { "EDITTEXT", EDITTEXT, 0, 0, 0}, 285 { "END", tEND, 0, 0, 1}, 286 { "EXSTYLE", EXSTYLE, 0, 0, 0}, 287 { "extern", tEXTERN, 0, 1, 1}, 288 { "FILEFLAGS", FILEFLAGS, 0, 0, 0}, 289 { "FILEFLAGSMASK", FILEFLAGSMASK, 0, 0, 0}, 290 { "FILEOS", FILEOS, 0, 0, 0}, 291 { "FILESUBTYPE", FILESUBTYPE, 0, 0, 0}, 292 { "FILETYPE", FILETYPE, 0, 0, 0}, 293 { "FILEVERSION", FILEVERSION, 0, 0, 0}, 294 { "FIXED", tFIXED, 0, 0, 0}, 295 { "FONT", FONT, 0, 0, 0}, 296 { "GRAYED", GRAYED, 0, 0, 0}, 297 { "GROUPBOX", GROUPBOX, 0, 0, 0}, 298 { "HELP", HELP, 0, 0, 0}, 299 { "ICON", ICON, 0, 0, 0}, 300 { "IMPURE", IMPURE, 0, 0, 0}, 301 { "INACTIVE", INACTIVE, 0, 0, 0}, 302 { "LANGUAGE", LANGUAGE, 1, 0, 1}, 303 { "LISTBOX", LISTBOX, 0, 0, 0}, 304 { "LOADONCALL", LOADONCALL, 0, 0, 0}, 305 { "LTEXT", LTEXT, 0, 0, 0}, 306 { "MENU", MENU, 0, 0, 0}, 307 { "MENUBARBREAK", MENUBARBREAK, 0, 0, 0}, 308 { "MENUBREAK", MENUBREAK, 0, 0, 0}, 309 { "MENUEX", MENUEX, 1, 0, 0}, 310 { "MENUITEM", MENUITEM, 0, 0, 0}, 311 { "MESSAGETABLE", MESSAGETABLE, 1, 0, 0}, 312 { "MOVEABLE", MOVEABLE, 0, 0, 0}, 313 { "NOINVERT", NOINVERT, 0, 0, 0}, 314 { "NOT", NOT, 0, 0, 0}, 315 { "POPUP", POPUP, 0, 0, 0}, 316 { "PRELOAD", PRELOAD, 0, 0, 0}, 317 { "PRODUCTVERSION", PRODUCTVERSION, 0, 0, 0}, 318 { "PURE", tPURE, 0, 0, 0}, 319 { "PUSHBUTTON", PUSHBUTTON, 0, 0, 0}, 320 { "RADIOBUTTON", RADIOBUTTON, 0, 0, 0}, 321 { "RCDATA", RCDATA, 0, 0, 0}, 322 { "RTEXT", RTEXT, 0, 0, 0}, 323 { "SCROLLBAR", SCROLLBAR, 0, 0, 0}, 324 { "SEPARATOR", SEPARATOR, 0, 0, 0}, 325 { "SHIFT", SHIFT, 0, 0, 0}, 326 { "STATE3", STATE3, 1, 0, 0}, 327 { "STRING", tSTRING, 0, 0, 0}, 328 { "STRINGTABLE", STRINGTABLE, 0, 0, 1}, 329 { "STYLE", STYLE, 0, 0, 0}, 330 { "TOOLBAR", TOOLBAR, 1, 0, 0}, 331 { "typedef", tTYPEDEF, 0, 1, 1}, 332 { "VALUE", VALUE, 0, 0, 0}, 333 { "VERSION", VERSION, 1, 0, 0}, 334 { "VERSIONINFO", VERSIONINFO, 0, 0, 0}, 335 { "VIRTKEY", VIRTKEY, 0, 0, 0} 150 { "ACCELERATORS", tACCELERATORS, 0, 0, 0}, 151 { "ALT", tALT, 0, 0, 0}, 152 { "ASCII", tASCII, 0, 0, 0}, 153 { "AUTO3STATE", tAUTO3STATE, 1, 0, 0}, 154 { "AUTOCHECKBOX", tAUTOCHECKBOX, 1, 0, 0}, 155 { "AUTORADIOBUTTON", tAUTORADIOBUTTON, 1, 0, 0}, 156 { "BEGIN", tBEGIN, 0, 0, 0}, 157 { "BITMAP", tBITMAP, 0, 0, 0}, 158 { "BLOCK", tBLOCK, 0, 0, 0}, 159 { "BUTTON", tBUTTON, 1, 0, 0}, 160 { "CAPTION", tCAPTION, 0, 0, 0}, 161 { "CHARACTERISTICS", tCHARACTERISTICS, 1, 0, 0}, 162 { "CHECKBOX", tCHECKBOX, 0, 0, 0}, 163 { "CHECKED", tCHECKED, 0, 0, 0}, 164 { "CLASS", tCLASS, 0, 0, 0}, 165 { "COMBOBOX", tCOMBOBOX, 0, 0, 0}, 166 { "CONTROL", tCONTROL, 0, 0, 0}, 167 { "CTEXT", tCTEXT, 0, 0, 0}, 168 { "CURSOR", tCURSOR, 0, 0, 0}, 169 { "DEFPUSHBUTTON", tDEFPUSHBUTTON, 0, 0, 0}, 170 { "DIALOG", tDIALOG, 0, 0, 0}, 171 { "DIALOGEX", tDIALOGEX, 1, 0, 0}, 172 { "DISCARDABLE", tDISCARDABLE, 0, 0, 0}, 173 { "DLGINIT", tDLGINIT, 0, 0, 0}, 174 { "EDITTEXT", tEDITTEXT, 0, 0, 0}, 175 { "END", tEND, 0, 0, 0}, 176 { "enum", tENUM, 0, 1, 1}, 177 { "EXSTYLE", tEXSTYLE, 0, 0, 0}, 178 { "extern", tEXTERN, 0, 1, 1}, 179 { "FILEFLAGS", tFILEFLAGS, 0, 0, 0}, 180 { "FILEFLAGSMASK", tFILEFLAGSMASK, 0, 0, 0}, 181 { "FILEOS", tFILEOS, 0, 0, 0}, 182 { "FILESUBTYPE", tFILESUBTYPE, 0, 0, 0}, 183 { "FILETYPE", tFILETYPE, 0, 0, 0}, 184 { "FILEVERSION", tFILEVERSION, 0, 0, 0}, 185 { "FIXED", tFIXED, 0, 0, 0}, 186 { "FONT", tFONT, 0, 0, 0}, 187 { "FONTDIR", tFONTDIR, 0, 0, 0}, /* This is a Borland BRC extension */ 188 { "GRAYED", tGRAYED, 0, 0, 0}, 189 { "GROUPBOX", tGROUPBOX, 0, 0, 0}, 190 { "HELP", tHELP, 0, 0, 0}, 191 { "ICON", tICON, 0, 0, 0}, 192 { "IMPURE", tIMPURE, 0, 0, 0}, 193 { "INACTIVE", tINACTIVE, 0, 0, 0}, 194 { "inline", tINLINE, 0, 1, 1}, 195 { "LANGUAGE", tLANGUAGE, 1, 0, 1}, 196 { "LISTBOX", tLISTBOX, 0, 0, 0}, 197 { "LOADONCALL", tLOADONCALL, 0, 0, 0}, 198 { "LTEXT", tLTEXT, 0, 0, 0}, 199 { "MENU", tMENU, 0, 0, 0}, 200 { "MENUBARBREAK", tMENUBARBREAK, 0, 0, 0}, 201 { "MENUBREAK", tMENUBREAK, 0, 0, 0}, 202 { "MENUEX", tMENUEX, 1, 0, 0}, 203 { "MENUITEM", tMENUITEM, 0, 0, 0}, 204 { "MESSAGETABLE", tMESSAGETABLE, 1, 0, 0}, 205 { "MOVEABLE", tMOVEABLE, 0, 0, 0}, 206 { "NOINVERT", tNOINVERT, 0, 0, 0}, 207 { "NOT", tNOT, 0, 0, 0}, 208 { "POPUP", tPOPUP, 0, 0, 0}, 209 { "PRELOAD", tPRELOAD, 0, 0, 0}, 210 { "PRODUCTVERSION", tPRODUCTVERSION, 0, 0, 0}, 211 { "PURE", tPURE, 0, 0, 0}, 212 { "PUSHBUTTON", tPUSHBUTTON, 0, 0, 0}, 213 { "RADIOBUTTON", tRADIOBUTTON, 0, 0, 0}, 214 { "RCDATA", tRCDATA, 0, 0, 0}, 215 { "RTEXT", tRTEXT, 0, 0, 0}, 216 { "SCROLLBAR", tSCROLLBAR, 0, 0, 0}, 217 { "SEPARATOR", tSEPARATOR, 0, 0, 0}, 218 { "SHIFT", tSHIFT, 0, 0, 0}, 219 { "STATE3", tSTATE3, 1, 0, 0}, 220 { "static", tSTATIC, 0, 1, 1}, 221 { "STRING", tSTRING, 0, 0, 0}, 222 { "STRINGTABLE", tSTRINGTABLE, 0, 0, 1}, 223 { "struct", tSTRUCT, 0, 1, 1}, 224 { "STYLE", tSTYLE, 0, 0, 0}, 225 { "TOOLBAR", tTOOLBAR, 1, 0, 0}, 226 { "typedef", tTYPEDEF, 0, 1, 1}, 227 { "VALUE", tVALUE, 0, 0, 0}, 228 { "VERSION", tVERSION, 1, 0, 0}, 229 { "VERSIONINFO", tVERSIONINFO, 0, 0, 0}, 230 { "VIRTKEY", tVIRTKEY, 0, 0, 0} 336 231 }; 337 232 338 233 #define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0])) 339 234 #define KWP(p) ((struct keyword *)(p)) 340 int kw_cmp_func(const void *s1, const void *s2)235 static int kw_cmp_func(const void *s1, const void *s2) 341 236 { 342 237 int ret; … … 350 245 #define KW_BSEARCH 351 246 #define DO_SORT 352 st ruct keyword *iskeyword(char *kw)247 static struct keyword *iskeyword(char *kw) 353 248 { 354 249 struct keyword *kwp; … … 384 279 #endif 385 280 386 #ifdef LEX_DEBUG387 if(kwp && !strcmp(kwp->keyword, "LANGUAGE"))388 printf("Got Language\n");389 #endif390 281 if(kwp == NULL || (kwp->isextension && !extensions)) 391 282 return NULL; … … 394 285 } 395 286 396 void add_to_substtext(char *text, int len) 397 { 398 if(!substtext) 399 { 400 substtext = xstrdup(text); 287 %} 288 289 /* 290 ************************************************************************** 291 * The flexer starts here 292 ************************************************************************** 293 */ 294 %% 295 /* 296 * Catch the GCC-style line statements here and parse them. 297 * This has the advantage that you can #include at any 298 * stage in the resource file. 299 * The preprocessor generates line directives in the format: 300 * # <linenum> "filename" <codes> 301 * 302 * Codes can be a sequence of: 303 * - 1 start of new file 304 * - 2 returning to previous 305 * - 3 system header 306 * - 4 interpret as C-code 307 * 308 * 4 is not used and 1 mutually excludes 2 309 * Anyhow, we are not really interested in these at all 310 * because we only want to know the linenumber and 311 * filename. 312 */ 313 <INITIAL,pp_strips,pp_stripp>^{ws}*\#{ws}* yy_push_state(pp_line); 314 <pp_line>[^\n]* { 315 int lineno; 316 char *cptr; 317 char *fname; 318 yy_pop_state(); 319 lineno = (int)strtol(yytext, &cptr, 10); 320 if(!lineno) 321 yyerror("Malformed '#...' line-directive; invalid linenumber"); 322 fname = strchr(cptr, '"'); 323 if(!fname) 324 yyerror("Malformed '#...' line-directive; missing filename"); 325 fname++; 326 cptr = strchr(fname, '"'); 327 if(!cptr) 328 yyerror("Malformed '#...' line-directive; missing terminating \""); 329 *cptr = '\0'; 330 line_number = lineno - 1; /* We didn't read the newline */ 331 input_name = xstrdup(fname); 401 332 } 402 else 403 { 404 substtext = (char *)xrealloc(substtext, strlen(substtext)+len+1); 405 strcat(substtext, text); 406 } 407 } 408 409 %} 410 411 %% 412 /* #include handling */ 413 ^{ws}*#{ws}*include{ws}* push_to(pp_incl); 414 <pp_incl>\<[^\n\>]+\> do_include(yytext, yyleng); pop_start(); 415 <pp_incl>\"[^\n\>]+\" do_include(yytext, yyleng); pop_start(); 416 <pp_incl>. yyerror("Malformed #include"); 417 418 /* #define handling */ 419 ^{ws}*#{ws}*define{ws}* push_to(pp_def); 420 <pp_def>{cident} { 421 set_define(yytext); 422 push_to(pp_def_s); 423 } 424 <pp_def>{cident}\( push_to(pp_ignore); /* Ignore function-like defines for now*/ 425 <pp_def>. yyerror("Malformed #define"); 426 427 <pp_ignore,pp_def_s>[^\/\\\n]* { 428 if(YY_START == pp_def_s) 429 add_to_substtext(yytext, yyleng); 430 } 431 <pp_ignore,pp_def_s>\/[^\/\*][^\/\\\n]* { /* Comment is handled in normal handling */ 432 if(YY_START == pp_def_s) 433 add_to_substtext(yytext, yyleng); 434 } 435 <pp_ignore,pp_def_s>\\{ws}*\n line_number++; char_number = 1; /* Line continuation */ 436 <pp_ignore,pp_def_s>\n { 437 if(YY_START == pp_def_s) 438 { 439 add_define(substtext ? substtext : ""); 440 free(substtext); 441 substtext = NULL; 442 } 443 line_number++; 444 char_number = 1; 445 pop_start(); 446 pop_start(); 447 } 448 449 /* #undef handling */ 450 ^{ws}*#{ws}*undef{ws}* push_to(pp_undef); 451 <pp_undef>{cident} { 452 del_define(yytext); 453 pop_start(); 454 /*push_to(pp_ignore);*/ 455 } 456 457 /* Conditional handling */ 458 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*if{ws}* { 459 if(YY_START == pp_false) 460 { 461 if(yydebug) 462 printf("(%d)#if ignored\n", line_number); 463 push_if(0, 0, 1); 464 push_to(pp_ignore_eol); 465 } 466 else 467 { 468 push_to(INITIAL); 469 want_nl = 1; 470 return tIF; 471 } 472 } 473 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*ifdef{ws}* { 474 if(YY_START == pp_false) 475 { 476 if(yydebug) 477 printf("(%d)#ifdef ignored\n", line_number); 478 push_if(0, 0, 1); 479 push_to(pp_ignore_eol); 480 } 481 else 482 { 483 push_to(INITIAL); 484 want_nl = 1; 485 want_ident = 1; 486 return tIFDEF; 487 } 488 } 489 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*ifndef{ws}* { 490 if(YY_START == pp_false) 491 { 492 if(yydebug) 493 printf("(%d)#ifndef ignored\n", line_number); 494 push_if(0, 0, 1); 495 push_to(pp_ignore_eol); 496 } 497 else 498 { 499 push_to(INITIAL); 500 want_nl = 1; 501 want_ident = 1; 502 return tIFNDEF; 503 } 504 } 505 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*elif{ws}* { 506 if(!isnevertrue_if()) 507 { 508 push_to(INITIAL); 509 want_nl = 1; 510 return tELIF; 511 } 512 else if(YY_START == pp_false) 513 push_to(pp_ignore_eol); 514 if(yydebug) 515 printf("(%d)#elif ignored\n", line_number); 516 } 517 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*else{ws}* { 518 if(!isnevertrue_if()) 519 { 520 push_to(INITIAL); 521 want_nl = 1; 522 return tELSE; 523 } 524 if(yydebug) 525 printf("(%d)#else ignored\n", line_number); 526 } 527 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*endif{ws}* { 528 if(!isnevertrue_if()) 529 { 530 want_nl = 1; 531 return tENDIF; 532 } 533 else 534 { 535 if(yydebug) 536 printf("(%d)#endif ignored\n", line_number); 537 pop_if(); 538 } 539 } 540 541 /* The error directive */ 542 <INITIAL,pp_strips,pp_stripe,pp_stripp>^{ws}*#{ws}*error{ws}* push_to(pp_error); 543 <pp_error>[^\n]* yyerror("Error directive: %s", yytext); 544 <pp_false>^{ws}*#{ws}*error[^\n]* { 545 if(yydebug) 546 printf("(%d)#error ignored\n", line_number); 547 } 548 549 /* preprocessor junk */ 550 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*pragma[^\n]* ; /* Ignore #pragma */ 551 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*ident[^\n]* ; /* Ignore #ident */ 552 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*line[^\n]* ; /* Ignore #line */ 553 /* We'll get an error on malformed #xxx statements 554 * by not recognising '#' at all. This helps tracking 555 * preprocessor errors. 556 */ 557 /*^{ws}*#{ws}* ; Ignore # */ 558 559 <pp_strips>\{ stripslevel++; 560 <pp_strips>\} stripslevel--; 561 <pp_strips>; if(!stripslevel) pop_start(); 333 334 /* 335 * Strip everything until a ';' taking 336 * into account braces {} for structures, 337 * classes and enums. 338 */ 339 <pp_strips>\{ stripslevel++; 340 <pp_strips>\} stripslevel--; 341 <pp_strips>; if(!stripslevel) yy_pop_state(); 562 342 <pp_strips>\/[^*\n] ; /* To catch comments */ 563 343 <pp_strips>[^\{\};\n#/]* ; /* Ignore rest */ 564 565 <pp_stripe>\{ stripslevel++; 566 <pp_stripe>\} { 567 stripslevel--; 568 if(!stripslevel) pop_start(); 569 } 570 <pp_stripe>; if(!stripslevel) pop_start(); 571 <pp_stripe>\/[^*\n] ; /* To catch comments */ 572 <pp_stripe>[^\{\};\n#/]* ; /* Ignore rest */ 573 574 <pp_stripp>\( stripplevel++; 575 <pp_stripp>\) { 576 stripplevel--; 577 if(!stripplevel) 578 { 579 pop_start(); 580 push_to(pp_stripp_final); 344 <pp_strips>\n line_number++; char_number = 1; 345 346 <pp_stripp>\( stripplevel++; 347 <pp_stripp>\) { 348 stripplevel--; 349 if(!stripplevel) 350 { 351 yy_pop_state(); 352 yy_push_state(pp_stripp_final); 353 } 581 354 } 582 }583 355 <pp_stripp>\/[^*\n] ; /* To catch comments */ 584 356 <pp_stripp>[^\(\);\n#/]* ; /* Ignore rest */ 585 586 <pp_stripp_final>{ws}* ; /* Ignore */ 587 <pp_stripp_final>; pop_start(); /* Kill the semicolon */ 588 <pp_stripp_final>\n line_number++; char_number = 1; pop_start(); 589 <pp_stripp_final>. yyless(0); pop_start(); 590 591 <pp_false>. ; /* Ignore everything except #xxx during false #if state */ 592 593 <pp_ignore_eol>[^\n]* pop_start(); 594 595 /* These are special cases due to filename scanning */ 596 <yywf>[Dd][Ii][Ss][Cc][Aa][Rr][Dd][Aa][Bb][Ll][Ee] return DISCARDABLE; 597 <yywf>[Ff][Ii][Xx][Ee][Dd] return tFIXED; 598 <yywf>[Ii][Mm][Pp][Uu][Rr][Ee] return IMPURE; 599 <yywf>[Mm][Oo][Vv][Ee][Aa][Bb][Ll][Ee] return MOVEABLE; 600 <yywf>[Ll][Oo][Aa][Dd][Oo][Nn][Cc][Aa][Ll][Ll] return LOADONCALL; 601 <yywf>[Pp][Rr][Ee][Ll][Oo][Aa][Dd] return PRELOAD; 602 <yywf>[Pp][Uu][Rr][Ee] return tPURE; 357 <pp_stripp>\n line_number++; char_number = 1; 358 359 <pp_stripp_final>{ws}* ; /* Ignore */ 360 <pp_stripp_final>; yy_pop_state(); /* Kill the semicolon */ 361 <pp_stripp_final>\n line_number++; char_number = 1; yy_pop_state(); 362 <pp_stripp_final>. yyless(0); yy_pop_state(); 603 363 604 364 \{ return tBEGIN; 605 365 \} return tEND; 606 366 607 [0-9]+[lL]? { yylval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? LNUMBER : NUMBER; } 608 0[xX][0-9A-Fa-f]+[lL]? { yylval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? LNUMBER : NUMBER; } 609 0[oO][0-7]+[lL]? { yylval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? LNUMBER : NUMBER; } 367 [0-9]+[lL]? { yylval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 368 0[xX][0-9A-Fa-f]+[lL]? { yylval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 369 0[oO][0-7]+[lL]? { yylval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 370 371 /* 372 * The next two rules scan identifiers and filenames. 373 * This is achieved by using the priority ruling 374 * of the scanner where a '.' is valid in a filename 375 * and *only* in a filename. In this case, the second 376 * rule will be reduced because it is longer. 377 */ 610 378 [A-Za-z_0-9]+ { 611 struct keyword *token; 612 struct pp_entry *ppp; 613 614 want_rscname = 0; 615 616 if(want_ident) 379 struct keyword *tok = iskeyword(yytext); 380 381 if(tok) 617 382 { 618 /* Prevent preprocessor subst */ 619 want_ident = 0; 620 yylval.str = make_string(yytext); 621 #ifdef LEX_DEBUG 622 printf("want IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext); 623 #endif 624 return IDENT; 625 } 626 else if((ppp = pp_lookup(yytext)) != NULL) 627 { 628 /* Do preprocessor substitution, 629 * but expand only if macro is not 630 * already expanding. 631 */ 632 if(!ppp->expanding) 383 if(tok->token == tCLASS && !strcmp(yytext, "class")) 384 return tCPPCLASS; 385 else if(wanted_id && !tok->alwayskw) 633 386 { 634 #ifdef LEX_DEBUG 635 printf("expand IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext); 636 #endif 637 push_buffer(YY_CURRENT_BUFFER, ppp, NULL); 638 yy_scan_string(ppp->subst); 387 yylval.str = make_string(yytext); 388 return tIDENT; 639 389 } 640 } 641 else if((token = iskeyword(yytext)) != NULL 642 && !(!token->alwayskeyword && want_rscname)) 643 { 644 switch(token->token) 645 { 646 case tDEFINED: 647 want_ident = 1; 648 break; 649 /*case RCDATA:*/ 650 case CURSOR: 651 case tBITMAP: 652 case MESSAGETABLE: 653 case DLGINIT: 654 push_to(yywf); 655 break; 656 case FONT: 657 case ICON: 658 if(!indialog) 659 push_to(yywf); 660 break; 661 case DIALOG: 662 case DIALOGEX: 663 indialog = 1; 664 break; 665 } 666 return token->token; 390 else 391 return tok->token; 667 392 } 668 393 else 669 394 { 670 395 yylval.str = make_string(yytext); 671 #ifdef LEX_DEBUG 672 printf("%s IDENT (%s, %d, %d): <%s>\n", 673 want_rscname ? "rscname" : "just", 674 input_name, 675 line_number, 676 char_number, 677 yytext); 678 #endif 679 return IDENT; 396 return tIDENT; 680 397 } 681 398 } 682 \|\| return LOGOR; 683 \&\& return LOGAND; 684 \=\= return EQ; 685 \!\= return NE; 686 \<\= return LTE; 687 \>\= return GTE; 688 689 <yywf>[^ \f\t\r\n\"]* { pop_start(); yylval.str = make_filename(yytext, yyleng); return FILENAME; } 690 <yywf>\" push_to(yywf_s); 691 <yywf_s>[^\"\n]*\" { pop_start(); pop_start(); yylval.str = make_filename(yytext, yyleng-1); return FILENAME; } 692 <yywf_s>\n yyerror("Newline in filename"); 693 399 [A-Za-z_0-9./\\]+ yylval.str = make_string(yytext); return tFILENAME; 400 401 /* 402 * Wide string scanning 403 */ 694 404 L\" { 695 push_to(yylstr);405 yy_push_state(yylstr); 696 406 wbufidx = 0; 697 407 if(!win32) 698 408 yywarning("16bit resource contains unicode strings\n"); 699 409 } 410 <yylstr>\"{ws}+ | 700 411 <yylstr>\" { 701 pop_start();412 yy_pop_state(); 702 413 yylval.str = get_buffered_wstring(); 703 414 return tSTRING; 704 415 } 705 <yylstr>\n yyerror("Unterminated string");706 416 <yylstr>\\[0-7]{1,6} { /* octal escape sequence */ 707 417 int result; … … 716 426 addwchar((short)result); 717 427 } 428 <yylstr>\\x[0-9a-fA-F]{1,3} { yyerror("Invalid hex escape sequence '%s'", yytext); } 429 718 430 <yylstr>\\[0-9]+ yyerror("Bad escape secuence"); 719 431 <yylstr>\\a addwchar('\a'); … … 724 436 <yylstr>\\t addwchar('\t'); 725 437 <yylstr>\\v addwchar('\v'); 726 <yylstr>\\(.|\n) addwchar(yytext[1]); 438 <yylstr>\\(\n|.) addwchar(yytext[1]); 439 <yylstr>\\\r\n addwchar(yytext[2]); 727 440 <yylstr>\"\" addcchar('\"'); /* "bla""bla" -> "bla\"bla" */ 728 441 <yylstr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */ … … 733 446 addwchar(*yptr++ & 0xff); 734 447 } 735 736 \" { 737 push_to(yystr); 738 cbufidx = 0; 739 } 448 <yylstr>\n yyerror("Unterminated string"); 449 450 /* 451 * Normal string scanning 452 */ 453 \" yy_push_state(yystr); cbufidx = 0; 454 <yystr>\"{ws}+ | 740 455 <yystr>\" { 741 pop_start();456 yy_pop_state(); 742 457 yylval.str = get_buffered_cstring(); 743 458 return tSTRING; 744 459 } 745 <yystr>\n yyerror("Unterminated string");746 460 <yystr>\\[0-7]{1,3} { /* octal escape sequence */ 747 461 int result; … … 756 470 addcchar((char)result); 757 471 } 472 <yystr>\\x[0-9a-fA-F] { yyerror("Invalid hex escape sequence '%s'", yytext); } 473 758 474 <yystr>\\[0-9]+ yyerror("Bad escape secuence"); 759 475 <yystr>\\a addcchar('\a'); … … 764 480 <yystr>\\t addcchar('\t'); 765 481 <yystr>\\v addcchar('\v'); 766 <yystr>\\(.|\n) addcchar(yytext[1]); 482 <yystr>\\(\n|.) addcchar(yytext[1]); 483 <yystr>\\\r\n addcchar(yytext[2]); 767 484 <yystr>[^\\\n\"]+ { 768 485 char *yptr = yytext; … … 773 490 <yystr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */ 774 491 <yystr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */ 775 <yystr>. yywarning("Matched %c", *yytext); 776 777 778 \' { 779 push_to(yyrcd); 780 cbufidx = 0; 781 } 492 <yystr>\n yyerror("Unterminated string"); 493 494 /* 495 * Raw data scanning 496 */ 497 \' yy_push_state(yyrcd); cbufidx = 0; 782 498 <yyrcd>\' { 783 pop_start();499 yy_pop_state(); 784 500 yylval.raw = new_raw_data(); 785 501 yylval.raw->size = cbufidx; 786 502 yylval.raw->data = xmalloc(yylval.raw->size); 787 503 memcpy(yylval.raw->data, cbuffer, yylval.raw->size); 788 return RAWDATA;504 return tRAWDATA; 789 505 } 790 506 <yyrcd>[0-9a-fA-F]{2} { … … 797 513 <yyrcd>. yyerror("Malformed data-line"); 798 514 799 <INITIAL,pp_ignore,pp_def_s,pp_strips,pp_stripe,pp_stripp>"/*" push_to(comment); /* Eat comment */ 515 /* 516 * Comment stripping 517 * Should never occur after preprocessing 518 */ 519 <INITIAL,pp_stripp,pp_strips>"/*" { 520 yy_push_state(comment); 521 save_wanted_id = wanted_id; 522 if(!no_preprocess) 523 yywarning("Found comments after preprocessing, please report"); 524 } 800 525 <comment>[^*\n]* ; 801 526 <comment>"*"+[^*/\n]* ; 802 527 <comment>\n line_number++; char_number = 1; 803 <comment>"*"+"/" pop_start(); 804 805 ;[^\n]* ; /* Eat comment */ 806 <INITIAL,pp_ignore,pp_def_s>"//"[^\n]* ; /* Eat comment */ 807 808 <INITIAL,yywf,pp_false,pp_strips,pp_stripe,pp_stripp>\n { 809 if(YY_START == yywf) 810 pop_start(); 528 <comment>"*"+"/" yy_pop_state(); want_id = save_wanted_id; 529 530 ;[^\n]* want_id = wanted_id; /* not really comment, but left-over c-junk */ 531 "//"[^\n]* want_id = wanted_id; if(!no_preprocess) yywarning("Found comments after preprocessing, please report"); 532 533 \n { 534 want_id = wanted_id; 811 535 line_number++; 812 536 char_number = 1; … … 817 541 } 818 542 } 819 <INITIAL,yywf>{ws}+; /* Eat whitespace */543 {ws}+ want_id = wanted_id; /* Eat whitespace */ 820 544 821 545 <INITIAL>. return yytext[0]; 546 822 547 <<EOF>> { 823 YY_BUFFER_STATE b = YY_CURRENT_BUFFER; 824 if(!pop_buffer()) 825 { 826 if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final) 827 yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline); 828 else 829 yyterminate(); 830 } 831 yy_delete_buffer(b); 548 if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final) 549 yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline); 550 else 551 yyterminate(); 832 552 } 833 553 … … 840 560 } 841 561 yywarning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d", 842 isprint(*yytext ) ? *yytext : '.', *yytext, YY_START,stripslevel);562 isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START,stripslevel); 843 563 } 844 564 … … 861 581 * the resource string. 862 582 */ 863 void addcchar(char c)583 static void addcchar(char c) 864 584 { 865 585 if(cbufidx >= cbufalloc) … … 873 593 } 874 594 875 void addwchar(short s)595 static void addwchar(short s) 876 596 { 877 597 if(wbufidx >= wbufalloc) … … 894 614 } 895 615 896 st ring_t *get_buffered_cstring(void)616 static string_t *get_buffered_cstring(void) 897 617 { 898 618 string_t *str = new_string(); … … 902 622 memcpy(str->str.cstr, cbuffer, cbufidx); 903 623 str->str.cstr[cbufidx] = '\0'; 904 /* printf("got cstring \"%s\"\n", str->str.cstr); */905 624 return str; 906 625 } 907 626 908 st ring_t *get_buffered_wstring(void)627 static string_t *get_buffered_wstring(void) 909 628 { 910 629 string_t *str = new_string(); … … 917 636 } 918 637 919 st ring_t *make_string(char *s)638 static string_t *make_string(char *s) 920 639 { 921 640 string_t *str = new_string(); … … 927 646 } 928 647 929 string_t *make_filename(char *s, int len)930 {931 char *cptr;932 string_t *str = new_string();933 934 str->size = len;935 str->type = str_char;936 str->str.cstr = (char *)xmalloc(str->size+1);937 memcpy(str->str.cstr, s, str->size);938 str->str.cstr[str->size] = '\0';939 940 /* Remove escaped backslash and convert to forward */941 cptr = str->str.cstr;942 for(cptr = str->str.cstr; (cptr = strchr(cptr, '\\')) != NULL; cptr++)943 {944 if(cptr[1] == '\\')945 {946 memmove(cptr, cptr+1, strlen(cptr));947 str->size--;948 }949 *cptr = '/';950 }951 952 /* Convert to lower case. Seems to be reasonable to do */953 for(cptr = str->str.cstr; !leave_case && *cptr; cptr++)954 {955 *cptr = tolower(*cptr);956 }957 return str;958 }959 960 /* Called from the parser to signal filename request */961 void set_yywf(void)962 {963 push_to(yywf);964 }965 966 /* Called from the parser to signal preprocessor if case */967 void set_pp_ignore(int state)968 {969 if(state)970 push_to(pp_false);971 else972 pop_start();973 }974 975 648 /* Called from the parser to kill c-junk */ 976 649 void strip_extern(void) 977 650 { 978 651 cjunk_tagline = line_number; 979 push_to(pp_stripe);652 yy_push_state(pp_stripe); 980 653 } 981 654 … … 983 656 { 984 657 cjunk_tagline = line_number; 985 push_to(pp_strips);658 yy_push_state(pp_strips); 986 659 } 987 660 … … 990 663 cjunk_tagline = line_number; 991 664 stripplevel = 1; /* One scanned already */ 992 push_to(pp_stripp);993 } 994 665 yy_push_state(pp_stripp); 666 } 667 -
trunk/tools/wrc/parser.y
r3426 r5522 1 1 %{ 2 2 /* 3 * Copyright Martin von Loewis, 19944 * Copyright 1998 5 * 1999 3 * Copyright 1994 Martin von Loewis 4 * Copyright 1998-2000 Bertho A. Stultiens (BS) 5 * 1999 Juergen Schmied (JS) 6 6 * 7 * 6-Nov-1999 JS - see CHANGES 7 * 24-Jul-2000 BS - Made a fix for broken Berkeley yacc on 8 * non-terminals (see cjunk rule). 9 * 21-May-2000 BS - Partial implementation of font resources. 10 * - Corrected language propagation for binary 11 * resources such as bitmaps, isons, cursors, 12 * userres and rcdata. The language is now 13 * correct in .res files. 14 * - Fixed reading the resource name as ident, 15 * so that it may overlap keywords. 16 * 20-May-2000 BS - Implemented animated cursors and icons 17 * resource types. 18 * 30-Apr-2000 BS - Reintegration into the wine-tree 19 * 14-Jan-2000 BS - Redid the usertype resources so that they 20 * are compatible. 21 * 02-Jan-2000 BS - Removed the preprocessor from the grammar 22 * expect for the # command (line numbers). 23 * 24 * 06-Nov-1999 JS - see CHANGES 8 25 * 9 26 * 29-Dec-1998 AdH - Grammar and function extensions. … … 108 125 #include "parser.h" 109 126 #include "windef.h" 127 #include "winbase.h" 110 128 #include "wingdi.h" 111 129 #include "winuser.h" 112 130 113 #ifdef __BORLANDC__ 114 #pragma warn -sig 131 #if defined(YYBYACC) 132 /* Berkeley yacc (byacc) doesn't seem to know about these */ 133 /* Some *BSD supplied versions do define these though */ 134 # ifndef YYEMPTY 135 # define YYEMPTY (-1) /* Empty lookahead value of yychar */ 136 # endif 137 # ifndef YYLEX 138 # define YYLEX yylex() 139 # endif 140 141 #elif defined(YYBISON) 142 /* Bison was used for original development */ 143 /* #define YYEMPTY -2 */ 144 /* #define YYLEX yylex() */ 145 146 #else 147 /* No yacc we know yet */ 148 # if !defined(YYEMPTY) || !defined(YYLEX) 149 # error Yacc version/type unknown. This version needs to be verified for settings of YYEMPTY and YYLEX. 150 # elif defined(__GNUC__) /* gcc defines the #warning directive */ 151 # warning Yacc version/type unknown. It defines YYEMPTY and YYLEX, but is not tested 152 /* #else we just take a chance that it works... */ 153 # endif 115 154 #endif 116 155 117 int indialog = 0; /* Signal flex that we're parsing a dialog*/118 int want_ rscname = 0; /* Set when a resource's name is required*/156 int want_nl = 0; /* Signal flex that we need the next newline */ 157 int want_id = 0; /* Signal flex that we need the next identifier */ 119 158 stringtable_t *tagstt; /* Stringtable tag. 120 159 * It is set while parsing a stringtable to one of … … 125 164 * stringtables with different lanuages 126 165 */ 166 static int dont_want_id = 0; /* See language parsing for details */ 167 127 168 /* Set to the current options of the currently scanning stringtable */ 128 169 static int *tagstt_memopt; … … 130 171 static version_t *tagstt_version; 131 172 173 static const char riff[4] = "RIFF"; /* RIFF file magic for animated cursor/icon */ 174 132 175 /* Prototypes of here defined functions */ 133 void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur); 134 void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico); 135 int alloc_cursor_id(language_t *); 136 int alloc_icon_id(language_t *); 137 void ins_stt_entry(stt_entry_t *ste); 138 int check_stt_entry(stringtable_t *tabs, stt_entry_t *ste); 139 event_t *get_event_head(event_t *p); 140 control_t *get_control_head(control_t *p); 141 ver_value_t *get_ver_value_head(ver_value_t *p); 142 ver_block_t *get_ver_block_head(ver_block_t *p); 143 resource_t *get_resource_head(resource_t *p); 144 menuex_item_t *get_itemex_head(menuex_item_t *p); 145 menu_item_t *get_item_head(menu_item_t *p); 146 raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str); 147 raw_data_t *merge_raw_data_int(raw_data_t *r1, int i); 148 raw_data_t *merge_raw_data_long(raw_data_t *r1, int i); 149 raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2); 150 raw_data_t *str2raw_data(string_t *str); 151 raw_data_t *int2raw_data(int i); 152 raw_data_t *long2raw_data(int i); 153 raw_data_t *load_file(string_t *name); 154 itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid); 155 event_t *add_string_event(string_t *key, int id, int flags, event_t *prev); 156 event_t *add_event(int key, int id, int flags, event_t *prev); 157 dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg); 158 dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg); 159 dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg); 160 dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg); 161 dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg); 162 dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg); 163 dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg); 164 dialogex_t *dialogex_exstyle(style_t *st, dialogex_t *dlg); 165 dialogex_t *dialogex_style(style_t *st, dialogex_t *dlg); 166 name_id_t *convert_ctlclass(name_id_t *cls); 167 control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev); 168 dialog_t *dialog_version(version_t *v, dialog_t *dlg); 169 dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg); 170 dialog_t *dialog_language(language_t *l, dialog_t *dlg); 171 dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg); 172 dialog_t *dialog_class(name_id_t *n, dialog_t *dlg); 173 dialog_t *dialog_font(font_id_t *f, dialog_t *dlg); 174 dialog_t *dialog_caption(string_t *s, dialog_t *dlg); 175 dialog_t *dialog_exstyle(style_t * st, dialog_t *dlg); 176 dialog_t *dialog_style(style_t * st, dialog_t *dlg); 177 resource_t *build_stt_resources(stringtable_t *stthead); 178 stringtable_t *find_stringtable(lvc_t *lvc); 179 toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec); 180 toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems); 176 static event_t *get_event_head(event_t *p); 177 static control_t *get_control_head(control_t *p); 178 static ver_value_t *get_ver_value_head(ver_value_t *p); 179 static ver_block_t *get_ver_block_head(ver_block_t *p); 180 static resource_t *get_resource_head(resource_t *p); 181 static menuex_item_t *get_itemex_head(menuex_item_t *p); 182 static menu_item_t *get_item_head(menu_item_t *p); 183 static raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str); 184 static raw_data_t *merge_raw_data_int(raw_data_t *r1, int i); 185 static raw_data_t *merge_raw_data_long(raw_data_t *r1, int i); 186 static raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2); 187 static raw_data_t *str2raw_data(string_t *str); 188 static raw_data_t *int2raw_data(int i); 189 static raw_data_t *long2raw_data(int i); 190 static raw_data_t *load_file(string_t *name); 191 static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid); 192 static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev); 193 static event_t *add_event(int key, int id, int flags, event_t *prev); 194 static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg); 195 static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg); 196 static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg); 197 static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg); 198 static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg); 199 static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg); 200 static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg); 201 static dialogex_t *dialogex_exstyle(style_t *st, dialogex_t *dlg); 202 static dialogex_t *dialogex_style(style_t *st, dialogex_t *dlg); 203 static name_id_t *convert_ctlclass(name_id_t *cls); 204 static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev); 205 static dialog_t *dialog_version(version_t *v, dialog_t *dlg); 206 static dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg); 207 static dialog_t *dialog_language(language_t *l, dialog_t *dlg); 208 static dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg); 209 static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg); 210 static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg); 211 static dialog_t *dialog_caption(string_t *s, dialog_t *dlg); 212 static dialog_t *dialog_exstyle(style_t * st, dialog_t *dlg); 213 static dialog_t *dialog_style(style_t * st, dialog_t *dlg); 214 static resource_t *build_stt_resources(stringtable_t *stthead); 215 static stringtable_t *find_stringtable(lvc_t *lvc); 216 static toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec); 217 static toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems); 218 static string_t *make_filename(string_t *s); 219 static resource_t *build_fontdirs(resource_t *tail); 220 static resource_t *build_fontdir(resource_t **fnt, int nfnt); 221 static int rsrcid_to_token(int lookahead); 181 222 182 223 %} … … 185 226 int num; 186 227 int *iptr; 228 char *cptr; 187 229 resource_t *res; 188 230 accelerator_t *acc; 189 231 bitmap_t *bmp; 190 cursor_t *cur;191 cursor_group_t *curg;192 232 dialog_t *dlg; 193 233 dialogex_t *dlgex; 194 234 font_t *fnt; 195 icon_t *ico; 196 icon_group_t *icog; 235 fontdir_t *fnd; 197 236 menu_t *men; 198 237 menuex_t *menex; … … 223 262 style_pair_t *styles; 224 263 style_t *style; 225 } 226 227 %token tIF tIFDEF tIFNDEF tELSE tELIF tENDIF tDEFINED tNL 228 %token tTYPEDEF tEXTERN 229 %token <num> NUMBERLNUMBER230 %token <str> tSTRING IDENTFILENAME231 %token <raw> RAWDATA232 %token ACCELERATORS tBITMAP CURSOR DIALOG DIALOGEX MENU MENUEXMESSAGETABLE233 %token RCDATA VERSIONINFO STRINGTABLE FONTICON234 %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOXDEFPUSHBUTTON235 %token PUSHBUTTON RADIOBUTTONSTATE3 /* PUSHBOX */236 %token GROUPBOX COMBOBOX LISTBOXSCROLLBAR237 %token CONTROLEDITTEXT238 %token RTEXT CTEXTLTEXT239 %token BLOCKVALUE240 %token SHIFT ALT ASCII VIRTKEY GRAYED CHECKED INACTIVENOINVERT241 %token tPURE IMPURE DISCARDABLE LOADONCALL PRELOAD tFIXEDMOVEABLE242 %token CLASS CAPTION CHARACTERISTICS EXSTYLE STYLE VERSIONLANGUAGE243 %token FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEOS FILETYPE FILEFLAGSFILESUBTYPE244 %token MENUBARBREAK MENUBREAK MENUITEM POPUPSEPARATOR245 %token HELP246 %token tSTRING IDENTRAWDATA247 %token TOOLBARBUTTON264 ani_any_t *ani; 265 } 266 267 %token tTYPEDEF tEXTERN tSTRUCT tENUM tCPPCLASS tINLINE tSTATIC tNL 268 %token <num> tNUMBER tLNUMBER 269 %token <str> tSTRING tIDENT tFILENAME 270 %token <raw> tRAWDATA 271 %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE 272 %token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON 273 %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON 274 %token tPUSHBUTTON tRADIOBUTTON tSTATE3 /* PUSHBOX */ 275 %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR 276 %token tCONTROL tEDITTEXT 277 %token tRTEXT tCTEXT tLTEXT 278 %token tBLOCK tVALUE 279 %token tSHIFT tALT tASCII tVIRTKEY tGRAYED tCHECKED tINACTIVE tNOINVERT 280 %token tPURE tIMPURE tDISCARDABLE tLOADONCALL tPRELOAD tFIXED tMOVEABLE 281 %token tCLASS tCAPTION tCHARACTERISTICS tEXSTYLE tSTYLE tVERSION tLANGUAGE 282 %token tFILEVERSION tPRODUCTVERSION tFILEFLAGSMASK tFILEOS tFILETYPE tFILEFLAGS tFILESUBTYPE 283 %token tMENUBARBREAK tMENUBREAK tMENUITEM tPOPUP tSEPARATOR 284 %token tHELP 285 %token tSTRING tIDENT tRAWDATA 286 %token tTOOLBAR tBUTTON 248 287 %token tBEGIN tEND 249 %token DLGINIT 250 %left LOGOR 251 %left LOGAND 288 %token tDLGINIT 252 289 %left '|' 253 290 %left '^' 254 291 %left '&' 255 %left EQ NE256 %left '<' LTE '>' GTE257 292 %left '+' '-' 258 293 %left '*' '/' 259 %right '~' '!' NOT 294 %right '~' tNOT 295 %left pUPM 260 296 261 297 %type <res> resource_file resource resources resource_definition 262 298 %type <stt> stringtable strings 263 299 %type <fnt> font 264 %type < icog> icon300 %type <fnd> fontdir 265 301 %type <acc> accelerators 266 302 %type <event> events 267 303 %type <bmp> bitmap 268 %type < curg> cursor304 %type <ani> cursor icon 269 305 %type <dlg> dialog dlg_attributes 270 306 %type <ctl> ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo … … 273 309 %type <ctl> exctrls gen_exctrl lab_exctrl exctrl_desc 274 310 %type <rdt> rcdata 275 %type <raw> raw_data raw_elements opt_data 311 %type <raw> raw_data raw_elements opt_data file_raw 276 312 %type <veri> versioninfo fix_version 277 313 %type <verw> ver_words … … 287 323 %type <num> item_options 288 324 %type <nid> nameid nameid_s ctlclass usertype 289 %type <num> acc_opt 325 %type <num> acc_opt acc accs 290 326 %type <iptr> loadmemopts lamo lama 291 327 %type <fntid> opt_font opt_exfont opt_expr … … 296 332 %type <num> expr xpr 297 333 %type <iptr> e_expr 298 %type <iptr> pp_expr pp_constant299 334 %type <tlbar> toolbar 300 335 %type <tlbarItems> toolbar_items … … 304 339 %type <style> optional_style 305 340 %type <style> style 341 %type <str> filename 306 342 307 343 %% … … 321 357 else 322 358 $1 = rsc; 359 /* Find the tail again */ 360 while($1 && $1->next) 361 $1 = $1->next; 362 /* Now add any fontdirecory */ 363 rsc = build_fontdirs($1); 364 /* 'build_fontdir' returns a head and $1 is a tail */ 365 if($1) 366 { 367 $1->next = rsc; 368 if(rsc) 369 rsc->prev = $1; 370 } 371 else 372 $1 = rsc; 323 373 /* Final statement before were done */ 324 374 resource_top = get_resource_head($1); … … 328 378 /* Resources are put into a linked list */ 329 379 resources 330 : /* Empty */ { $$ = NULL; want_ rscname= 1; }380 : /* Empty */ { $$ = NULL; want_id = 1; } 331 381 | resources resource { 332 382 if($2) … … 342 392 $1->next = head; 343 393 $$ = tail; 394 /* Check for duplicate identifiers */ 395 while($1 && head) 396 { 397 resource_t *rsc = $1; 398 while(rsc) 399 { 400 if(rsc->type == head->type 401 && rsc->lan->id == head->lan->id 402 && rsc->lan->sub == head->lan->sub 403 && !compare_name_id(rsc->name, head->name)) 404 { 405 yyerror("Duplicate resource name '%s'", get_nameid_str(rsc->name)); 406 } 407 rsc = rsc->prev; 408 } 409 head = head->next; 410 } 344 411 } 345 412 else if($1) … … 352 419 else 353 420 $$ = NULL; 354 want_rscname = 1; 355 } 356 | resources preprocessor { $$ = $1; want_rscname = 1; } 357 | resources cjunk { $$ = $1; want_rscname = 1; } 358 ; 359 360 /* The buildin preprocessor */ 361 preprocessor 362 : tIF pp_expr tNL { pop_start(); push_if($2 ? *($2) : 0, 0, 0); if($2) free($2);} 363 | tIFDEF IDENT tNL { pop_start(); push_if(pp_lookup($2->str.cstr) != NULL, 0, 0); } 364 | tIFNDEF IDENT tNL { pop_start(); push_if(pp_lookup($2->str.cstr) == NULL, 0, 0); } 365 | tELIF pp_expr tNL { pop_start(); push_if($2 ? *($2) : 0, pop_if(), 0); if($2) free($2); } 366 | tELSE tNL { pop_start(); push_if(1, pop_if(), 0); } 367 | tENDIF tNL { pop_if(); } 368 ; 369 370 pp_expr : pp_constant { $$ = $1; } 371 | pp_expr LOGOR pp_expr { $$ = new_int($1 && $3 ? (*$1 || *$3) : 0); if($1) free($1); if($3) free($3); } 372 | pp_expr LOGAND pp_expr { $$ = new_int($1 && $3 ? (*$1 && *$3) : 0); if($1) free($1); if($3) free($3); } 373 | pp_expr '+' pp_expr { $$ = new_int($1 && $3 ? (*$1 + *$3) : 0); if($1) free($1); if($3) free($3); } 374 | pp_expr '-' pp_expr { $$ = new_int($1 && $3 ? (*$1 - *$3) : 0); if($1) free($1); if($3) free($3); } 375 | pp_expr '^' pp_expr { $$ = new_int($1 && $3 ? (*$1 ^ *$3) : 0); if($1) free($1); if($3) free($3); } 376 | pp_expr EQ pp_expr { $$ = new_int($1 && $3 ? (*$1 == *$3) : 0); if($1) free($1); if($3) free($3); } 377 | pp_expr NE pp_expr { $$ = new_int($1 && $3 ? (*$1 != *$3) : 0); if($1) free($1); if($3) free($3); } 378 | pp_expr '<' pp_expr { $$ = new_int($1 && $3 ? (*$1 < *$3) : 0); if($1) free($1); if($3) free($3); } 379 | pp_expr '>' pp_expr { $$ = new_int($1 && $3 ? (*$1 > *$3) : 0); if($1) free($1); if($3) free($3); } 380 | pp_expr LTE pp_expr { $$ = new_int($1 && $3 ? (*$1 <= *$3) : 0); if($1) free($1); if($3) free($3); } 381 | pp_expr GTE pp_expr { $$ = new_int($1 && $3 ? (*$1 >= *$3) : 0); if($1) free($1); if($3) free($3); } 382 | '~' pp_expr { $$ = $2; if($2) *$2 = ~(*$2); } 383 | '+' pp_expr { $$ = $2; } 384 | '-' pp_expr { $$ = $2; if($2) *$2 = -(*$2); } 385 | '!' pp_expr { $$ = $2; if($2) *$2 = !(*$2); } 386 | '(' pp_expr ')' { $$ = $2; } 387 ; 388 389 pp_constant 390 : any_num { $$ = new_int($1); } 391 | IDENT { $$ = NULL; } 392 | tDEFINED IDENT { $$ = new_int(pp_lookup($2->str.cstr) != NULL); } 393 | tDEFINED '(' IDENT ')' { $$ = new_int(pp_lookup($3->str.cstr) != NULL); } 394 ; 421 422 if(!dont_want_id) /* See comments in language parsing below */ 423 want_id = 1; 424 dont_want_id = 0; 425 } 426 | resources cjunk { $$ = $1; want_id = 1; } 427 ; 428 395 429 396 430 /* C ignore stuff */ 397 431 cjunk : tTYPEDEF { strip_til_semicolon(); } 398 | tEXTERN { strip_extern(); } 399 | IDENT IDENT { strip_til_semicolon(); } 400 | IDENT '(' { strip_til_parenthesis(); } 401 | IDENT '*' { strip_til_semicolon(); } 432 | tSTRUCT { strip_til_semicolon(); } 433 | tEXTERN { strip_til_semicolon(); } 434 | tENUM { strip_til_semicolon(); } 435 | tCPPCLASS { strip_til_semicolon(); } 436 | tSTATIC { strip_til_semicolon(); } 437 | tINLINE { internal_error(__FILE__, __LINE__, "Don't yet know how to strip inline functions\n"); } 438 /* | tIDENT tIDENT { strip_til_semicolon(); } */ 439 /* | tIDENT tIDENT '(' { strip_til_parenthesis(); } See comments in 'resource' below */ 440 /* | tIDENT '(' { strip_til_parenthesis(); } */ 441 | tIDENT '*' { strip_til_semicolon(); } 442 | tNL /* 443 * This newline rule will never get reduced because we never 444 * get the tNL token, unless we explicitely set the 'want_nl' 445 * flag, which we don't. 446 * The *ONLY* reason for this to be here is because Berkeley 447 * yacc (byacc), at least version 1.9, has a bug. 448 * (identified in the generated parser on the second 449 * line with: 450 * static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; 451 * ) 452 * This extra rule fixes it. 453 * The problem is that the expression handling rule "expr: xpr" 454 * is not reduced on non-terminal tokens, defined above in the 455 * %token declarations. Token tNL is the only non-terminal that 456 * can occur. The error becomes visible in the language parsing 457 * rule below, which looks at the look-ahead token and tests it 458 * for tNL. However, byacc already generates an error upon reading 459 * the token instead of keeping it as a lookahead. The reason 460 * lies in the lack of a $default transition in the "expr : xpr . " 461 * state (currently state 25). It is probably ommitted because tNL 462 * is a non-terminal and the state contains 2 s/r conflicts. The 463 * state enumerates all possible transitions instead of using a 464 * $default transition. 465 * All in all, it is a bug in byacc. (period) 466 */ 402 467 ; 403 468 404 469 /* Parse top level resource definitions etc. */ 405 470 resource 406 : nameidresource_definition {407 $$ = $ 2;471 : expr usrcvt resource_definition { 472 $$ = $3; 408 473 if($$) 409 474 { 410 $$->name = $1; 411 if($1->type == name_ord) 412 { 413 chat("Got %s (%d)",get_typename($2),$1->name.i_name); 475 if($1 > 65535 || $1 < -32768) 476 yyerror("Resource's ID out of range (%d)", $1); 477 $$->name = new_name_id(); 478 $$->name->type = name_ord; 479 $$->name->name.i_name = $1; 480 chat("Got %s (%d)", get_typename($3), $$->name->name.i_name); 414 481 } 415 else if($1->type == name_str)416 {417 chat("Got %s (%s)",get_typename($2),$1->name.s_name->str.cstr);418 482 } 419 } 420 } 483 | tIDENT usrcvt resource_definition { 484 $$ = $3; 485 if($$) 486 { 487 $$->name = new_name_id(); 488 $$->name->type = name_str; 489 $$->name->name.s_name = $1; 490 chat("Got %s (%s)", get_typename($3), $$->name->name.s_name->str.cstr); 491 } 492 } 493 | tIDENT usrcvt tIDENT '(' { /* cjunk */ strip_til_parenthesis(); $$ = NULL; } 494 /* The above rule is inserted here with explicit tIDENT 495 * references to avoid a nasty LALR(2) problem when 496 * considering the 'cjunk' rules with respect to the usertype 497 * resources. 498 * A usertype resource can have two leading identifiers before 499 * it qualifies as shift into usertype rules. However, the 500 * cjunk scanner also has a rule of two leading identifiers. 501 * The problem occurs because the second identifier is at the 502 * second lookahead (hence LALR(2)) seen from the recursion 503 * rule 'resources'. 504 * Thus, the scanner will pick *one* of the rules in preference 505 * of the other (in this case it was 'cjunk') and generates a 506 * syntax error if the trailing context wasn't seen. The 507 * correct action would have been to rollback the stack and 508 * decent into the 'userres' rule, but this cannot be done 509 * because yacc only parses LALR(1). 510 * The problem is prevented from happening by making the decent 511 * into the cjunk-scanning obsolete and explicitly force the 512 * scanner to require no more than 1 lookahead. 513 */ 421 514 | stringtable { 422 515 /* Don't do anything, stringtables are converted to … … 427 520 chat("Got STRINGTABLE"); 428 521 } 429 | opt_language { 522 | tLANGUAGE {want_nl = 1; } expr ',' expr { 523 /* We *NEED* the newline to delimit the expression. 524 * Otherwise, we would not be able to set the next 525 * want_id anymore because of the token-lookahead. 526 * 527 * However, we can test the lookahead-token for 528 * being "non-expression" type, in which case we 529 * continue. Fortunately, tNL is the only token that 530 * will break expression parsing and is implicitely 531 * void, so we just remove it. This scheme makes it 532 * possible to do some (not all) fancy preprocessor 533 * stuff. 534 * BTW, we also need to make sure that the next 535 * reduction of 'resources' above will *not* set 536 * want_id because we already have a lookahead that 537 * cannot be undone. 538 */ 539 if(yychar != YYEMPTY && yychar != tNL) 540 dont_want_id = 1; 541 542 if(yychar == tNL) 543 yychar = YYEMPTY; /* Could use 'yyclearin', but we already need the*/ 544 /* direct access to yychar in rule 'usrcvt' below. */ 545 else if(yychar == tIDENT) 546 yywarning("LANGUAGE statement not delimited with newline; next identifier might be wrong"); 547 548 want_nl = 0; /* We don't want it anymore if we didn't get it */ 549 430 550 if(!win32) 431 551 yywarning("LANGUAGE not supported in 16-bit mode"); 432 552 if(currentlanguage) 433 553 free(currentlanguage); 434 currentlanguage = $1;554 currentlanguage = new_language($3, $5); 435 555 $$ = NULL; 436 } 556 chat("Got LANGUAGE %d,%d (0x%04x)", $3, $5, ($5<<10) + $3); 557 } 558 ; 559 560 /* 561 * Remapping of numerical resource types 562 * (see also comment of called function below) 563 */ 564 usrcvt : /* Empty */ { yychar = rsrcid_to_token(yychar); } 437 565 ; 438 566 … … 446 574 $$->type = name_ord; 447 575 $$->name.i_name = $1; 448 want_rscname = 0; 449 } 450 | IDENT { 576 } 577 | tIDENT { 451 578 $$ = new_name_id(); 452 579 $$->type = name_str; 453 580 $$->name.s_name = $1; 454 want_rscname = 0;455 581 } 456 582 ; … … 464 590 $$->type = name_str; 465 591 $$->name.s_name = $1; 466 want_rscname = 0;467 592 } 468 593 ; … … 471 596 resource_definition 472 597 : accelerators { $$ = new_resource(res_acc, $1, $1->memopt, $1->lvc.language); } 473 | bitmap { $$ = new_resource(res_bmp, $1, $1->memopt, dup_language(currentlanguage)); }598 | bitmap { $$ = new_resource(res_bmp, $1, $1->memopt, $1->data->lvc.language); } 474 599 | cursor { 475 600 resource_t *rsc; 476 cursor_t *cur; 477 $$ = rsc = new_resource(res_curg, $1, $1->memopt, dup_language(currentlanguage)); 478 for(cur = $1->cursorlist; cur; cur = cur->next) 479 { 480 rsc->prev = new_resource(res_cur, cur, $1->memopt, dup_language(currentlanguage)); 481 rsc->prev->next = rsc; 482 rsc = rsc->prev; 483 rsc->name = new_name_id(); 484 rsc->name->type = name_ord; 485 rsc->name->name.i_name = cur->id; 486 } 601 if($1->type == res_anicur) 602 { 603 $$ = rsc = new_resource(res_anicur, $1->u.ani, $1->u.ani->memopt, $1->u.ani->data->lvc.language); 604 } 605 else if($1->type == res_curg) 606 { 607 cursor_t *cur; 608 $$ = rsc = new_resource(res_curg, $1->u.curg, $1->u.curg->memopt, $1->u.curg->lvc.language); 609 for(cur = $1->u.curg->cursorlist; cur; cur = cur->next) 610 { 611 rsc->prev = new_resource(res_cur, cur, $1->u.curg->memopt, $1->u.curg->lvc.language); 612 rsc->prev->next = rsc; 613 rsc = rsc->prev; 614 rsc->name = new_name_id(); 615 rsc->name->type = name_ord; 616 rsc->name->name.i_name = cur->id; 617 } 618 } 619 else 620 internal_error(__FILE__, __LINE__, "Invalid top-level type %d in cursor resource", $1->type); 621 free($1); 487 622 } 488 623 | dialog { $$ = new_resource(res_dlg, $1, $1->memopt, $1->lvc.language); } … … 493 628 $$ = NULL; 494 629 } 495 | dlginit { $$ = new_resource(res_dlginit, $1, $1->memopt, $1->lvc.language); } 496 | font { $$ = new_resource(res_fnt, $1, $1->memopt, dup_language(currentlanguage)); } 630 | dlginit { $$ = new_resource(res_dlginit, $1, $1->memopt, $1->data->lvc.language); } 631 | font { $$ = new_resource(res_fnt, $1, $1->memopt, $1->data->lvc.language); } 632 | fontdir { $$ = new_resource(res_fntdir, $1, $1->memopt, $1->data->lvc.language); } 497 633 | icon { 498 634 resource_t *rsc; 499 icon_t *ico; 500 $$ = rsc = new_resource(res_icog, $1, $1->memopt, dup_language(currentlanguage)); 501 for(ico = $1->iconlist; ico; ico = ico->next) 502 { 503 rsc->prev = new_resource(res_ico, ico, $1->memopt, dup_language(currentlanguage)); 504 rsc->prev->next = rsc; 505 rsc = rsc->prev; 506 rsc->name = new_name_id(); 507 rsc->name->type = name_ord; 508 rsc->name->name.i_name = ico->id; 509 } 635 if($1->type == res_aniico) 636 { 637 $$ = rsc = new_resource(res_aniico, $1->u.ani, $1->u.ani->memopt, $1->u.ani->data->lvc.language); 638 } 639 else if($1->type == res_icog) 640 { 641 icon_t *ico; 642 $$ = rsc = new_resource(res_icog, $1->u.icog, $1->u.icog->memopt, $1->u.icog->lvc.language); 643 for(ico = $1->u.icog->iconlist; ico; ico = ico->next) 644 { 645 rsc->prev = new_resource(res_ico, ico, $1->u.icog->memopt, $1->u.icog->lvc.language); 646 rsc->prev->next = rsc; 647 rsc = rsc->prev; 648 rsc->name = new_name_id(); 649 rsc->name->type = name_ord; 650 rsc->name->name.i_name = ico->id; 651 } 652 } 653 else 654 internal_error(__FILE__, __LINE__, "Invalid top-level type %d in icon resource", $1->type); 655 free($1); 510 656 } 511 657 | menu { $$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language); } … … 517 663 } 518 664 | messagetable { $$ = new_resource(res_msg, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, dup_language(currentlanguage)); } 519 | rcdata { $$ = new_resource(res_rdt, $1, $1->memopt, $1-> lvc.language); }665 | rcdata { $$ = new_resource(res_rdt, $1, $1->memopt, $1->data->lvc.language); } 520 666 | toolbar { $$ = new_resource(res_toolbar, $1, $1->memopt, $1->lvc.language); } 521 | userres { $$ = new_resource(res_usr, $1, $1->memopt, dup_language(currentlanguage)); } 522 | versioninfo { $$ = new_resource(res_ver, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, dup_language(currentlanguage)); } 667 | userres { $$ = new_resource(res_usr, $1, $1->memopt, $1->data->lvc.language); } 668 | versioninfo { $$ = new_resource(res_ver, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, $1->lvc.language); } 669 ; 670 671 672 filename: tFILENAME { $$ = make_filename($1); } 673 | tIDENT { $$ = make_filename($1); } 674 | tSTRING { $$ = make_filename($1); } 523 675 ; 524 676 525 677 /* ------------------------------ Bitmap ------------------------------ */ 526 bitmap : tBITMAP loadmemopts FILENAME { $$ = new_bitmap(load_file($3), $2); } 527 | tBITMAP loadmemopts raw_data { $$ = new_bitmap($3, $2); } 678 bitmap : tBITMAP loadmemopts file_raw { $$ = new_bitmap($3, $2); } 528 679 ; 529 680 530 681 /* ------------------------------ Cursor ------------------------------ */ 531 cursor : CURSOR loadmemopts FILENAME { $$ = new_cursor_group(load_file($3), $2); } 532 | CURSOR loadmemopts raw_data { $$ = new_cursor_group($3, $2); } 682 cursor : tCURSOR loadmemopts file_raw { 683 $$ = new_ani_any(); 684 if($3->size > 4 && !memcmp($3->data, riff, sizeof(riff))) 685 { 686 $$->type = res_anicur; 687 $$->u.ani = new_ani_curico(res_anicur, $3, $2); 688 } 689 else 690 { 691 $$->type = res_curg; 692 $$->u.curg = new_cursor_group($3, $2); 693 } 694 } 695 ; 696 697 /* ------------------------------ Icon ------------------------------ */ 698 icon : tICON loadmemopts file_raw { 699 $$ = new_ani_any(); 700 if($3->size > 4 && !memcmp($3->data, riff, sizeof(riff))) 701 { 702 $$->type = res_aniico; 703 $$->u.ani = new_ani_curico(res_aniico, $3, $2); 704 } 705 else 706 { 707 $$->type = res_icog; 708 $$->u.icog = new_icon_group($3, $2); 709 } 710 } 533 711 ; 534 712 535 713 /* ------------------------------ Font ------------------------------ */ 536 /* FIXME: Should we allow raw_data here? */ 537 font : FONT loadmemopts FILENAME { $$ = new_font(load_file($3), $2); } 538 ; 539 540 /* ------------------------------ Icon ------------------------------ */ 541 icon : ICON loadmemopts FILENAME { $$ = new_icon_group(load_file($3), $2); } 542 | ICON loadmemopts raw_data { $$ = new_icon_group($3, $2); } 714 /* 715 * The reading of raw_data for fonts is a Borland BRC 716 * extension. MS generates an error. However, it is 717 * most logical to support this, considering how wine 718 * enters things in CVS (ascii). 719 */ 720 font : tFONT loadmemopts file_raw { $$ = new_font($3, $2); } 721 ; 722 723 /* 724 * The fontdir is a Borland BRC extension which only 725 * reads the data as 'raw_data' from the file. 726 * I don't know whether it is interpreted. 727 * The fontdir is generated if it was not present and 728 * fonts are defined in the source. 729 */ 730 fontdir : tFONTDIR loadmemopts file_raw { $$ = new_fontdir($3, $2); } 543 731 ; 544 732 … … 548 736 */ 549 737 messagetable 550 : MESSAGETABLE FILENAME{738 : tMESSAGETABLE loadmemopts file_raw { 551 739 if(!win32) 552 740 yywarning("MESSAGETABLE not supported in 16-bit mode"); 553 $$ = new_messagetable( load_file($2));741 $$ = new_messagetable($3, $2); 554 742 } 555 743 ; 556 744 557 745 /* ------------------------------ RCData ------------------------------ */ 558 rcdata : RCDATA loadmemopts opt_lvc raw_data { 559 $$ = new_rcdata($4, $2); 560 if($3) 561 { 562 $$->lvc = *($3); 563 free($3); 564 } 565 if(!$$->lvc.language) 566 $$->lvc.language = dup_language(currentlanguage); 567 } 746 rcdata : tRCDATA loadmemopts file_raw { $$ = new_rcdata($3, $2); } 568 747 ; 569 748 570 749 /* ------------------------------ DLGINIT ------------------------------ */ 571 dlginit : DLGINIT loadmemopts opt_lvc raw_data { 572 $$ = new_dlginit($4, $2); 573 if($3) 574 { 575 $$->lvc = *($3); 576 free($3); 577 } 578 if(!$$->lvc.language) 579 $$->lvc.language = dup_language(currentlanguage); 580 } 750 dlginit : tDLGINIT loadmemopts file_raw { $$ = new_dlginit($3, $2); } 581 751 ; 582 752 583 753 /* ------------------------------ UserType ------------------------------ */ 584 userres : usertype loadmemopts FILENAME { $$ = new_user($1, load_file($3), $2); } 585 | usertype loadmemopts raw_data { $$ = new_user($1, $3, $2); } 586 ; 587 588 /* NOTE: This here is an exception where I do not allow an expression. 589 * Reason for this is that it is not possible to set the 'yywf' condition 590 * for flex if loadmemopts is empty. Reading an expression requires a 591 * lookahead to determine its end. In this case here, that would mean that 592 * the filename has been read as IDENT or tSTRING, which is incorrect. 593 * Note also that IDENT cannot be used as a file-name because it is lacking 594 * the '.'. 595 */ 596 597 /* I also allow string identifiers as classtypes. Not MS implemented, but 598 * seems to be reasonable to implement. 599 */ 600 /* Allowing anything else than NUMBER makes it very hard to get rid of 601 * prototypes. So, I remove IDENT to be able to get prototypes out of the 602 * world. 603 */ 604 usertype: NUMBER { 754 userres : usertype loadmemopts file_raw { 755 #ifdef WORDS_BIGENDIAN 756 if(pedantic && byteorder != WRC_BO_LITTLE) 757 #else 758 if(pedantic && byteorder == WRC_BO_BIG) 759 #endif 760 yywarning("Byteordering is not little-endian and type cannot be interpreted"); 761 $$ = new_user($1, $3, $2); 762 } 763 ; 764 765 usertype: tNUMBER { 605 766 $$ = new_name_id(); 606 767 $$->type = name_ord; 607 768 $$->name.i_name = $1; 608 set_yywf(); 609 } 610 /* | IDENT { 769 } 770 | tIDENT { 611 771 $$ = new_name_id(); 612 772 $$->type = name_str; 613 773 $$->name.s_name = $1; 614 set_yywf();615 }616 */ | tSTRING {617 $$ = new_name_id();618 $$->type = name_str;619 $$->name.s_name = $1;620 set_yywf();621 774 } 622 775 ; … … 624 777 /* ------------------------------ Accelerator ------------------------------ */ 625 778 accelerators 626 : ACCELERATORS loadmemopts opt_lvc tBEGIN events tEND {779 : tACCELERATORS loadmemopts opt_lvc tBEGIN events tEND { 627 780 $$ = new_accelerator(); 628 781 if($2) … … 653 806 ; 654 807 655 acc_opt : /* Empty */ { $$=0; } 656 | acc_opt ',' NOINVERT { $$=$1 | WRC_AF_NOINVERT; } 657 | acc_opt ',' SHIFT { $$=$1 | WRC_AF_SHIFT; } 658 | acc_opt ',' CONTROL { $$=$1 | WRC_AF_CONTROL; } 659 | acc_opt ',' ALT { $$=$1 | WRC_AF_ALT; } 660 | acc_opt ',' ASCII { $$=$1 | WRC_AF_ASCII; } 661 | acc_opt ',' VIRTKEY { $$=$1 | WRC_AF_VIRTKEY; } 808 /* 809 * The empty rule generates a s/r conflict because of {bi,u}nary expr 810 * on - and +. It cannot be solved in any way because it is the same as 811 * the if/then/else problem (LALR(1) problem). The conflict is moved 812 * away by forcing it to be in the expression handling below. 813 */ 814 acc_opt : /* Empty */ { $$ = 0; } 815 | ',' accs { $$ = $2; } 816 ; 817 818 accs : acc { $$ = $1; } 819 | accs ',' acc { $$ = $1 | $3; } 820 ; 821 822 acc : tNOINVERT { $$ = WRC_AF_NOINVERT; } 823 | tSHIFT { $$ = WRC_AF_SHIFT; } 824 | tCONTROL { $$ = WRC_AF_CONTROL; } 825 | tALT { $$ = WRC_AF_ALT; } 826 | tASCII { $$ = WRC_AF_ASCII; } 827 | tVIRTKEY { $$ = WRC_AF_VIRTKEY; } 662 828 ; 663 829 664 830 /* ------------------------------ Dialog ------------------------------ */ 665 831 /* FIXME: Support EXSTYLE in the dialog line itself */ 666 dialog : DIALOG loadmemopts expr ',' expr ',' expr ',' expr dlg_attributes832 dialog : tDIALOG loadmemopts expr ',' expr ',' expr ',' expr dlg_attributes 667 833 tBEGIN ctrls tEND { 668 834 if($2) … … 692 858 $$->style->and_mask = 0; 693 859 694 indialog = FALSE;695 860 if(!$$->lvc.language) 696 861 $$->lvc.language = dup_language(currentlanguage); … … 699 864 700 865 dlg_attributes 701 : /* Empty */ { $$=new_dialog(); } 702 | dlg_attributes STYLE style { $$=dialog_style($3,$1); } 703 | dlg_attributes EXSTYLE style { $$=dialog_exstyle($3,$1); } 704 | dlg_attributes CAPTION tSTRING { $$=dialog_caption($3,$1); } 705 | dlg_attributes opt_font { $$=dialog_font($2,$1); } 706 | dlg_attributes CLASS nameid_s { $$=dialog_class($3,$1); } 707 | dlg_attributes MENU nameid { $$=dialog_menu($3,$1); } 708 | dlg_attributes opt_language { $$=dialog_language($2,$1); } 709 | dlg_attributes opt_characts { $$=dialog_characteristics($2,$1); } 710 | dlg_attributes opt_version { $$=dialog_version($2,$1); } 866 : /* Empty */ { $$=new_dialog(); } 867 | dlg_attributes tSTYLE style { $$=dialog_style($3,$1); } 868 | dlg_attributes tEXSTYLE style { $$=dialog_exstyle($3,$1); } 869 | dlg_attributes tCAPTION tSTRING { $$=dialog_caption($3,$1); } 870 | dlg_attributes opt_font { $$=dialog_font($2,$1); } 871 | dlg_attributes tCLASS nameid_s { $$=dialog_class($3,$1); } 872 | dlg_attributes tCPPCLASS nameid_s { $$=dialog_class($3,$1); } 873 | dlg_attributes tMENU nameid { $$=dialog_menu($3,$1); } 874 | dlg_attributes opt_language { $$=dialog_language($2,$1); } 875 | dlg_attributes opt_characts { $$=dialog_characteristics($2,$1); } 876 | dlg_attributes opt_version { $$=dialog_version($2,$1); } 711 877 ; 712 878 713 879 ctrls : /* Empty */ { $$ = NULL; } 714 | ctrls CONTROLgen_ctrl { $$=ins_ctrl(-1, 0, $3, $1); }715 | ctrls EDITTEXT ctrl_desc { $$=ins_ctrl(CT_EDIT, 0, $3, $1); }716 | ctrls LISTBOXctrl_desc { $$=ins_ctrl(CT_LISTBOX, 0, $3, $1); }717 | ctrls COMBOBOX ctrl_desc { $$=ins_ctrl(CT_COMBOBOX, 0, $3, $1); }718 | ctrls SCROLLBAR ctrl_desc { $$=ins_ctrl(CT_SCROLLBAR, 0, $3, $1); }719 | ctrls CHECKBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_CHECKBOX, $3, $1); }720 | ctrls DEFPUSHBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_DEFPUSHBUTTON, $3, $1); }721 | ctrls GROUPBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_GROUPBOX, $3, $1);}722 | ctrls PUSHBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBUTTON, $3, $1); }723 /* | ctrls PUSHBOXlab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */724 | ctrls RADIOBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_RADIOBUTTON, $3, $1); }725 | ctrls AUTO3STATE lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTO3STATE, $3, $1); }726 | ctrls STATE3 lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_3STATE, $3, $1); }727 | ctrls AUTOCHECKBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTOCHECKBOX, $3, $1); }728 | ctrls AUTORADIOBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTORADIOBUTTON, $3, $1); }729 | ctrls LTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_LEFT, $3, $1); }730 | ctrls CTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); }731 | ctrls RTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); }880 | ctrls tCONTROL gen_ctrl { $$=ins_ctrl(-1, 0, $3, $1); } 881 | ctrls tEDITTEXT ctrl_desc { $$=ins_ctrl(CT_EDIT, 0, $3, $1); } 882 | ctrls tLISTBOX ctrl_desc { $$=ins_ctrl(CT_LISTBOX, 0, $3, $1); } 883 | ctrls tCOMBOBOX ctrl_desc { $$=ins_ctrl(CT_COMBOBOX, 0, $3, $1); } 884 | ctrls tSCROLLBAR ctrl_desc { $$=ins_ctrl(CT_SCROLLBAR, 0, $3, $1); } 885 | ctrls tCHECKBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_CHECKBOX, $3, $1); } 886 | ctrls tDEFPUSHBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_DEFPUSHBUTTON, $3, $1); } 887 | ctrls tGROUPBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_GROUPBOX, $3, $1);} 888 | ctrls tPUSHBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBUTTON, $3, $1); } 889 /* | ctrls tPUSHBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */ 890 | ctrls tRADIOBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_RADIOBUTTON, $3, $1); } 891 | ctrls tAUTO3STATE lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTO3STATE, $3, $1); } 892 | ctrls tSTATE3 lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_3STATE, $3, $1); } 893 | ctrls tAUTOCHECKBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTOCHECKBOX, $3, $1); } 894 | ctrls tAUTORADIOBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTORADIOBUTTON, $3, $1); } 895 | ctrls tLTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_LEFT, $3, $1); } 896 | ctrls tCTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); } 897 | ctrls tRTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); } 732 898 /* special treatment for icons, as the extent is optional */ 733 | ctrls ICON nameid_s opt_comma expr ',' expr ',' expr iconinfo {899 | ctrls tICON nameid_s opt_comma expr ',' expr ',' expr iconinfo { 734 900 $10->title = $3; 735 901 $10->id = $5; … … 830 996 831 997 opt_font 832 : FONT expr ',' tSTRING { $$ = new_font_id($2, $4, 0, 0); }998 : tFONT expr ',' tSTRING { $$ = new_font_id($2, $4, 0, 0); } 833 999 ; 834 1000 … … 849 1015 | '(' style ')' { $$ = $2; } 850 1016 | any_num { $$ = new_style($1, 0); } 851 | NOT any_num { $$ = new_style(0, $2); }1017 | tNOT any_num { $$ = new_style(0, $2); } 852 1018 ; 853 1019 … … 866 1032 867 1033 /* ------------------------------ DialogEx ------------------------------ */ 868 dialogex: DIALOGEX loadmemopts expr ',' expr ',' expr ',' expr helpid dlgex_attribs1034 dialogex: tDIALOGEX loadmemopts expr ',' expr ',' expr ',' expr helpid dlgex_attribs 869 1035 tBEGIN exctrls tEND { 870 1036 if(!win32) … … 904 1070 $$->style->and_mask = 0; 905 1071 906 indialog = FALSE;907 1072 if(!$$->lvc.language) 908 1073 $$->lvc.language = dup_language(currentlanguage); … … 911 1076 912 1077 dlgex_attribs 913 : /* Empty */ { $$=new_dialogex(); } 914 | dlgex_attribs STYLE style { $$=dialogex_style($3,$1); } 915 | dlgex_attribs EXSTYLE style { $$=dialogex_exstyle($3,$1); } 916 | dlgex_attribs CAPTION tSTRING { $$=dialogex_caption($3,$1); } 917 | dlgex_attribs opt_font { $$=dialogex_font($2,$1); } 918 | dlgex_attribs opt_exfont { $$=dialogex_font($2,$1); } 919 | dlgex_attribs CLASS nameid_s { $$=dialogex_class($3,$1); } 920 | dlgex_attribs MENU nameid { $$=dialogex_menu($3,$1); } 921 | dlgex_attribs opt_language { $$=dialogex_language($2,$1); } 922 | dlgex_attribs opt_characts { $$=dialogex_characteristics($2,$1); } 923 | dlgex_attribs opt_version { $$=dialogex_version($2,$1); } 1078 : /* Empty */ { $$=new_dialogex(); } 1079 | dlgex_attribs tSTYLE style { $$=dialogex_style($3,$1); } 1080 | dlgex_attribs tEXSTYLE style { $$=dialogex_exstyle($3,$1); } 1081 | dlgex_attribs tCAPTION tSTRING { $$=dialogex_caption($3,$1); } 1082 | dlgex_attribs opt_font { $$=dialogex_font($2,$1); } 1083 | dlgex_attribs opt_exfont { $$=dialogex_font($2,$1); } 1084 | dlgex_attribs tCLASS nameid_s { $$=dialogex_class($3,$1); } 1085 | dlgex_attribs tCPPCLASS nameid_s { $$=dialogex_class($3,$1); } 1086 | dlgex_attribs tMENU nameid { $$=dialogex_menu($3,$1); } 1087 | dlgex_attribs opt_language { $$=dialogex_language($2,$1); } 1088 | dlgex_attribs opt_characts { $$=dialogex_characteristics($2,$1); } 1089 | dlgex_attribs opt_version { $$=dialogex_version($2,$1); } 924 1090 ; 925 1091 926 1092 exctrls : /* Empty */ { $$ = NULL; } 927 | exctrls CONTROL gen_exctrl { $$=ins_ctrl(-1, 0, $3, $1); }928 | exctrls EDITTEXT exctrl_desc { $$=ins_ctrl(CT_EDIT, 0, $3, $1); }929 | exctrls LISTBOX exctrl_desc { $$=ins_ctrl(CT_LISTBOX, 0, $3, $1); }930 | exctrls COMBOBOX exctrl_desc { $$=ins_ctrl(CT_COMBOBOX, 0, $3, $1); }931 | exctrls SCROLLBAR exctrl_desc { $$=ins_ctrl(CT_SCROLLBAR, 0, $3, $1); }932 | exctrls CHECKBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_CHECKBOX, $3, $1); }933 | exctrls DEFPUSHBUTTONlab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_DEFPUSHBUTTON, $3, $1); }934 | exctrls GROUPBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_GROUPBOX, $3, $1);}935 | exctrls PUSHBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBUTTON, $3, $1); }936 /* | exctrls PUSHBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */937 | exctrls RADIOBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_RADIOBUTTON, $3, $1); }938 | exctrls AUTO3STATE lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTO3STATE, $3, $1); }939 | exctrls STATE3 lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_3STATE, $3, $1); }940 | exctrls AUTOCHECKBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTOCHECKBOX, $3, $1); }941 | exctrls AUTORADIOBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTORADIOBUTTON, $3, $1); }942 | exctrls LTEXTlab_exctrl { $$=ins_ctrl(CT_STATIC, SS_LEFT, $3, $1); }943 | exctrls CTEXTlab_exctrl { $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); }944 | exctrls RTEXTlab_exctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); }1093 | exctrls tCONTROL gen_exctrl { $$=ins_ctrl(-1, 0, $3, $1); } 1094 | exctrls tEDITTEXT exctrl_desc { $$=ins_ctrl(CT_EDIT, 0, $3, $1); } 1095 | exctrls tLISTBOX exctrl_desc { $$=ins_ctrl(CT_LISTBOX, 0, $3, $1); } 1096 | exctrls tCOMBOBOX exctrl_desc { $$=ins_ctrl(CT_COMBOBOX, 0, $3, $1); } 1097 | exctrls tSCROLLBAR exctrl_desc { $$=ins_ctrl(CT_SCROLLBAR, 0, $3, $1); } 1098 | exctrls tCHECKBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_CHECKBOX, $3, $1); } 1099 | exctrls tDEFPUSHBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_DEFPUSHBUTTON, $3, $1); } 1100 | exctrls tGROUPBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_GROUPBOX, $3, $1);} 1101 | exctrls tPUSHBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBUTTON, $3, $1); } 1102 /* | exctrls tPUSHBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */ 1103 | exctrls tRADIOBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_RADIOBUTTON, $3, $1); } 1104 | exctrls tAUTO3STATE lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTO3STATE, $3, $1); } 1105 | exctrls tSTATE3 lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_3STATE, $3, $1); } 1106 | exctrls tAUTOCHECKBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTOCHECKBOX, $3, $1); } 1107 | exctrls tAUTORADIOBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTORADIOBUTTON, $3, $1); } 1108 | exctrls tLTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_LEFT, $3, $1); } 1109 | exctrls tCTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); } 1110 | exctrls tRTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); } 945 1111 /* special treatment for icons, as the extent is optional */ 946 | exctrls ICON nameid_s opt_comma expr ',' expr ',' expr iconinfo {1112 | exctrls tICON nameid_s opt_comma expr ',' expr ',' expr iconinfo { 947 1113 $10->title = $3; 948 1114 $10->id = $5; … … 1055 1221 1056 1222 opt_exfont 1057 : FONT expr ',' tSTRING ',' expr ',' expr opt_expr { $$ = new_font_id($2, $4, $6, $8); }1223 : tFONT expr ',' tSTRING ',' expr ',' expr opt_expr { $$ = new_font_id($2, $4, $6, $8); } 1058 1224 ; 1059 1225 … … 1067 1233 1068 1234 /* ------------------------------ Menu ------------------------------ */ 1069 menu : MENU loadmemopts opt_lvc menu_body {1235 menu : tMENU loadmemopts opt_lvc menu_body { 1070 1236 if(!$4) 1071 1237 yyerror("Menu must contain items"); … … 1095 1261 item_definitions 1096 1262 : /* Empty */ {$$ = NULL;} 1097 | item_definitions MENUITEM tSTRING opt_comma expr item_options {1263 | item_definitions tMENUITEM tSTRING opt_comma expr item_options { 1098 1264 $$=new_menu_item(); 1099 1265 $$->prev = $1; … … 1104 1270 $$->name = $3; 1105 1271 } 1106 | item_definitions MENUITEMSEPARATOR {1272 | item_definitions tMENUITEM tSEPARATOR { 1107 1273 $$=new_menu_item(); 1108 1274 $$->prev = $1; … … 1110 1276 $1->next = $$; 1111 1277 } 1112 | item_definitions POPUP tSTRING item_options menu_body {1278 | item_definitions tPOPUP tSTRING item_options menu_body { 1113 1279 $$ = new_menu_item(); 1114 1280 $$->prev = $1; … … 1129 1295 */ 1130 1296 item_options 1131 : /* Empty */ { $$ = 0; }1132 | ',' CHECKEDitem_options { $$ = $3 | MF_CHECKED; }1133 | ',' GRAYEDitem_options { $$ = $3 | MF_GRAYED; }1134 | ',' HELPitem_options { $$ = $3 | MF_HELP; }1135 | ',' INACTIVEitem_options { $$ = $3 | MF_DISABLED; }1136 | ',' MENUBARBREAKitem_options { $$ = $3 | MF_MENUBARBREAK; }1137 | ',' MENUBREAK item_options { $$ = $3 | MF_MENUBREAK; }1297 : /* Empty */ { $$ = 0; } 1298 | ',' tCHECKED item_options { $$ = $3 | MF_CHECKED; } 1299 | ',' tGRAYED item_options { $$ = $3 | MF_GRAYED; } 1300 | ',' tHELP item_options { $$ = $3 | MF_HELP; } 1301 | ',' tINACTIVE item_options { $$ = $3 | MF_DISABLED; } 1302 | ',' tMENUBARBREAK item_options { $$ = $3 | MF_MENUBARBREAK; } 1303 | ',' tMENUBREAK item_options { $$ = $3 | MF_MENUBREAK; } 1138 1304 ; 1139 1305 1140 1306 /* ------------------------------ MenuEx ------------------------------ */ 1141 menuex : MENUEX loadmemopts opt_lvc menuex_body {1307 menuex : tMENUEX loadmemopts opt_lvc menuex_body { 1142 1308 if(!win32) 1143 1309 yywarning("MENUEX not supported in 16-bit mode"); … … 1169 1335 itemex_definitions 1170 1336 : /* Empty */ {$$ = NULL; } 1171 | itemex_definitions MENUITEM tSTRING itemex_options {1337 | itemex_definitions tMENUITEM tSTRING itemex_options { 1172 1338 $$ = new_menuex_item(); 1173 1339 $$->prev = $1; … … 1185 1351 free($4); 1186 1352 } 1187 | itemex_definitions MENUITEMSEPARATOR {1353 | itemex_definitions tMENUITEM tSEPARATOR { 1188 1354 $$ = new_menuex_item(); 1189 1355 $$->prev = $1; … … 1191 1357 $1->next = $$; 1192 1358 } 1193 | itemex_definitions POPUP tSTRING itemex_p_options menuex_body {1359 | itemex_definitions tPOPUP tSTRING itemex_p_options menuex_body { 1194 1360 $$ = new_menuex_item(); 1195 1361 $$->prev = $1; … … 1315 1481 1316 1482 /* This is to get the language of the currently parsed stringtable */ 1317 stt_head: STRINGTABLE loadmemopts opt_lvc {1483 stt_head: tSTRINGTABLE loadmemopts opt_lvc { 1318 1484 if((tagstt = find_stringtable($3)) == NULL) 1319 1485 tagstt = new_stringtable($3); … … 1350 1516 tagstt->entries[tagstt->nentries-1].characts = tagstt_characts; 1351 1517 1518 if(pedantic && !$4->size) 1519 yywarning("Zero length strings make no sense"); 1352 1520 if(!win32 && $4->size > 254) 1353 1521 yyerror("Stringtable entry more than 254 characters"); … … 1365 1533 /* ------------------------------ VersionInfo ------------------------------ */ 1366 1534 versioninfo 1367 : VERSIONINFO fix_version tBEGIN ver_blocks tEND { 1368 $$ = $2; 1369 $2->blocks = get_ver_block_head($4); 1535 : tVERSIONINFO loadmemopts fix_version tBEGIN ver_blocks tEND { 1536 $$ = $3; 1537 if($2) 1538 { 1539 $$->memopt = *($2); 1540 free($2); 1541 } 1542 else 1543 $$->memopt = WRC_MO_MOVEABLE | (win32 ? WRC_MO_PURE : 0); 1544 $$->blocks = get_ver_block_head($5); 1545 /* Set language; there is no version or characteristics */ 1546 $$->lvc.language = dup_language(currentlanguage); 1370 1547 } 1371 1548 ; … … 1373 1550 fix_version 1374 1551 : /* Empty */ { $$ = new_versioninfo(); } 1375 | fix_version FILEVERSION expr ',' expr ',' expr ',' expr {1552 | fix_version tFILEVERSION expr ',' expr ',' expr ',' expr { 1376 1553 if($1->gotit.fv) 1377 1554 yyerror("FILEVERSION already defined"); … … 1383 1560 $$->gotit.fv = 1; 1384 1561 } 1385 | fix_version PRODUCTVERSION expr ',' expr ',' expr ',' expr {1562 | fix_version tPRODUCTVERSION expr ',' expr ',' expr ',' expr { 1386 1563 if($1->gotit.pv) 1387 1564 yyerror("PRODUCTVERSION already defined"); … … 1393 1570 $$->gotit.pv = 1; 1394 1571 } 1395 | fix_version FILEFLAGS expr {1572 | fix_version tFILEFLAGS expr { 1396 1573 if($1->gotit.ff) 1397 1574 yyerror("FILEFLAGS already defined"); … … 1400 1577 $$->gotit.ff = 1; 1401 1578 } 1402 | fix_version FILEFLAGSMASK expr {1579 | fix_version tFILEFLAGSMASK expr { 1403 1580 if($1->gotit.ffm) 1404 1581 yyerror("FILEFLAGSMASK already defined"); … … 1407 1584 $$->gotit.ffm = 1; 1408 1585 } 1409 | fix_version FILEOS expr {1586 | fix_version tFILEOS expr { 1410 1587 if($1->gotit.fo) 1411 1588 yyerror("FILEOS already defined"); … … 1414 1591 $$->gotit.fo = 1; 1415 1592 } 1416 | fix_version FILETYPE expr {1593 | fix_version tFILETYPE expr { 1417 1594 if($1->gotit.ft) 1418 1595 yyerror("FILETYPE already defined"); … … 1421 1598 $$->gotit.ft = 1; 1422 1599 } 1423 | fix_version FILESUBTYPE expr {1600 | fix_version tFILESUBTYPE expr { 1424 1601 if($1->gotit.fst) 1425 1602 yyerror("FILESUBTYPE already defined"); … … 1441 1618 1442 1619 ver_block 1443 : BLOCK tSTRING tBEGIN ver_values tEND {1620 : tBLOCK tSTRING tBEGIN ver_values tEND { 1444 1621 $$ = new_ver_block(); 1445 1622 $$->name = $2; … … 1464 1641 $$->value.block = $1; 1465 1642 } 1466 | VALUE tSTRING ',' tSTRING {1643 | tVALUE tSTRING ',' tSTRING { 1467 1644 $$ = new_ver_value(); 1468 1645 $$->type = val_str; … … 1470 1647 $$->value.str = $4; 1471 1648 } 1472 | VALUE tSTRING ',' ver_words {1649 | tVALUE tSTRING ',' ver_words { 1473 1650 $$ = new_ver_value(); 1474 1651 $$->type = val_words; … … 1484 1661 1485 1662 /* ------------------------------ Toolbar ------------------------------ */ 1486 toolbar: TOOLBAR loadmemopts expr ',' expr opt_lvc tBEGIN toolbar_items tEND {1663 toolbar: tTOOLBAR loadmemopts expr ',' expr opt_lvc tBEGIN toolbar_items tEND { 1487 1664 int nitems; 1488 1665 toolbar_item_t *items = get_tlbr_buttons_head($8, &nitems); … … 1511 1688 toolbar_items 1512 1689 : /* Empty */ { $$ = NULL; } 1513 | toolbar_items BUTTON expr {1690 | toolbar_items tBUTTON expr { 1514 1691 toolbar_item_t *idrec = new_toolbar_item(); 1515 1692 idrec->id = $3; 1516 1693 $$ = ins_tlbr_button($1, idrec); 1517 1694 } 1518 | toolbar_items SEPARATOR {1695 | toolbar_items tSEPARATOR { 1519 1696 toolbar_item_t *idrec = new_toolbar_item(); 1520 1697 idrec->id = 0; … … 1551 1728 ; 1552 1729 1553 lamo : PRELOAD { $$ = new_int(WRC_MO_PRELOAD); }1554 | MOVEABLE { $$ = new_int(WRC_MO_MOVEABLE); }1555 | DISCARDABLE { $$ = new_int(WRC_MO_DISCARDABLE); }1730 lamo : tPRELOAD { $$ = new_int(WRC_MO_PRELOAD); } 1731 | tMOVEABLE { $$ = new_int(WRC_MO_MOVEABLE); } 1732 | tDISCARDABLE { $$ = new_int(WRC_MO_DISCARDABLE); } 1556 1733 | tPURE { $$ = new_int(WRC_MO_PURE); } 1557 1734 ; 1558 1735 1559 lama : LOADONCALL { $$ = new_int(~WRC_MO_PRELOAD); }1736 lama : tLOADONCALL { $$ = new_int(~WRC_MO_PRELOAD); } 1560 1737 | tFIXED { $$ = new_int(~WRC_MO_MOVEABLE); } 1561 | IMPURE { $$ = new_int(~WRC_MO_PURE); }1738 | tIMPURE { $$ = new_int(~WRC_MO_PURE); } 1562 1739 ; 1563 1740 … … 1590 1767 ; 1591 1768 1769 /* 1770 * This here is another s/r conflict on {bi,u}nary + and -. 1771 * It is due to the look-ahead which must determine when the 1772 * rule opt_language ends. It could be solved with adding a 1773 * tNL at the end, but that seems unreasonable to do. 1774 * The conflict is now moved to the expression handling below. 1775 */ 1592 1776 opt_language 1593 : LANGUAGE expr ',' expr { $$ = new_language($2, $4); }1777 : tLANGUAGE expr ',' expr { $$ = new_language($2, $4); } 1594 1778 ; 1595 1779 1596 1780 opt_characts 1597 : CHARACTERISTICS expr { $$ = new_characts($2); }1781 : tCHARACTERISTICS expr { $$ = new_characts($2); } 1598 1782 ; 1599 1783 1600 1784 opt_version 1601 : VERSION expr { $$ = new_version($2); } 1602 ; 1603 1604 /* ------------------------------ Raw data handking ------------------------------ */ 1605 raw_data: tBEGIN raw_elements tEND { $$ = $2; } 1785 : tVERSION expr { $$ = new_version($2); } 1786 ; 1787 1788 /* ------------------------------ Raw data handling ------------------------------ */ 1789 raw_data: opt_lvc tBEGIN raw_elements tEND { 1790 if($1) 1791 { 1792 $3->lvc = *($1); 1793 free($1); 1794 } 1795 1796 if(!$3->lvc.language) 1797 $3->lvc.language = dup_language(currentlanguage); 1798 1799 $$ = $3; 1800 } 1606 1801 ; 1607 1802 1608 1803 raw_elements 1609 : RAWDATA { $$ = $1; }1610 | NUMBER { $$ = int2raw_data($1); }1611 | LNUMBER { $$ = long2raw_data($1); }1804 : tRAWDATA { $$ = $1; } 1805 | tNUMBER { $$ = int2raw_data($1); } 1806 | tLNUMBER { $$ = long2raw_data($1); } 1612 1807 | tSTRING { $$ = str2raw_data($1); } 1613 | raw_elements opt_comma RAWDATA { $$ = merge_raw_data($1, $3); free($3->data); free($3); } 1614 | raw_elements opt_comma NUMBER { $$ = merge_raw_data_int($1, $3); } 1615 | raw_elements opt_comma LNUMBER { $$ = merge_raw_data_long($1, $3); } 1616 | raw_elements opt_comma tSTRING { $$ = merge_raw_data_str($1, $3); } 1808 | raw_elements opt_comma tRAWDATA { $$ = merge_raw_data($1, $3); free($3->data); free($3); } 1809 | raw_elements opt_comma tNUMBER { $$ = merge_raw_data_int($1, $3); } 1810 | raw_elements opt_comma tLNUMBER { $$ = merge_raw_data_long($1, $3); } 1811 | raw_elements opt_comma tSTRING { $$ = merge_raw_data_str($1, $3); } 1812 ; 1813 1814 /* File data or raw data */ 1815 file_raw: filename { 1816 $$ = load_file($1); 1817 $$->lvc.language = dup_language(currentlanguage); 1818 } 1819 | raw_data { $$ = $1; } 1617 1820 ; 1618 1821 … … 1624 1827 | expr { $$ = new_int($1); } 1625 1828 ; 1829 1830 /* This rule moves ALL s/r conflicts on {bi,u}nary - and + to here */ 1626 1831 expr : xpr { $$ = ($1); } 1627 1832 ; … … 1633 1838 | xpr '*' xpr { $$ = ($1) * ($3); } 1634 1839 | xpr '/' xpr { $$ = ($1) / ($3); } 1840 | xpr '^' xpr { $$ = ($1) ^ ($3); } 1635 1841 | '~' xpr { $$ = ~($2); } 1636 | '-' xpr { $$ = -($2); } /* FIXME: shift/reduce conflict */1637 /* | '+' xpr { $$ = $2; } */ 1842 | '-' xpr %prec pUPM { $$ = -($2); } 1843 | '+' xpr %prec pUPM { $$ = $2; } 1638 1844 | '(' xpr ')' { $$ = $2; } 1639 | any_num { $$ = $1; want_rscname = 0;}1640 | NOT any_num { $$ = ~($2); }1641 ; 1642 1643 any_num : NUMBER { $$ = $1; }1644 | LNUMBER { $$ = $1; }1845 | any_num { $$ = $1; } 1846 | tNOT any_num { $$ = ~($2); } 1847 ; 1848 1849 any_num : tNUMBER { $$ = $1; } 1850 | tLNUMBER { $$ = $1; } 1645 1851 ; 1646 1852 1647 1853 %% 1648 1854 /* Dialog specific functions */ 1649 dialog_t *dialog_style(style_t * st, dialog_t *dlg)1855 static dialog_t *dialog_style(style_t * st, dialog_t *dlg) 1650 1856 { 1651 1857 assert(dlg != NULL); … … 1671 1877 } 1672 1878 1673 dialog_t *dialog_exstyle(style_t *st, dialog_t *dlg)1879 static dialog_t *dialog_exstyle(style_t *st, dialog_t *dlg) 1674 1880 { 1675 1881 assert(dlg != NULL); … … 1695 1901 } 1696 1902 1697 dialog_t *dialog_caption(string_t *s, dialog_t *dlg)1903 static dialog_t *dialog_caption(string_t *s, dialog_t *dlg) 1698 1904 { 1699 1905 assert(dlg != NULL); … … 1704 1910 } 1705 1911 1706 dialog_t *dialog_font(font_id_t *f, dialog_t *dlg)1912 static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg) 1707 1913 { 1708 1914 assert(dlg != NULL); … … 1713 1919 } 1714 1920 1715 dialog_t *dialog_class(name_id_t *n, dialog_t *dlg)1921 static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg) 1716 1922 { 1717 1923 assert(dlg != NULL); … … 1722 1928 } 1723 1929 1724 dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg)1930 static dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg) 1725 1931 { 1726 1932 assert(dlg != NULL); … … 1731 1937 } 1732 1938 1733 dialog_t *dialog_language(language_t *l, dialog_t *dlg)1939 static dialog_t *dialog_language(language_t *l, dialog_t *dlg) 1734 1940 { 1735 1941 assert(dlg != NULL); … … 1740 1946 } 1741 1947 1742 dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg)1948 static dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg) 1743 1949 { 1744 1950 assert(dlg != NULL); … … 1749 1955 } 1750 1956 1751 dialog_t *dialog_version(version_t *v, dialog_t *dlg)1957 static dialog_t *dialog_version(version_t *v, dialog_t *dlg) 1752 1958 { 1753 1959 assert(dlg != NULL); … … 1759 1965 1760 1966 /* Controls specific functions */ 1761 control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev)1967 static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev) 1762 1968 { 1763 1969 /* Hm... this seems to be jammed in at all time... */ … … 1883 2089 } 1884 2090 1885 name_id_t *convert_ctlclass(name_id_t *cls)1886 { 1887 char *cc ;2091 static name_id_t *convert_ctlclass(name_id_t *cls) 2092 { 2093 char *cc = NULL; 1888 2094 int iclass; 1889 2095 … … 1921 2127 1922 2128 /* DialogEx specific functions */ 1923 dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg)2129 static dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg) 1924 2130 { 1925 2131 assert(dlg != NULL); … … 1945 2151 } 1946 2152 1947 dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg)2153 static dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg) 1948 2154 { 1949 2155 assert(dlg != NULL); … … 1969 2175 } 1970 2176 1971 dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg)2177 static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg) 1972 2178 { 1973 2179 assert(dlg != NULL); … … 1978 2184 } 1979 2185 1980 dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg)2186 static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg) 1981 2187 { 1982 2188 assert(dlg != NULL); … … 1987 2193 } 1988 2194 1989 dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg)2195 static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg) 1990 2196 { 1991 2197 assert(dlg != NULL); … … 1996 2202 } 1997 2203 1998 dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg)2204 static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg) 1999 2205 { 2000 2206 assert(dlg != NULL); … … 2005 2211 } 2006 2212 2007 dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg)2213 static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg) 2008 2214 { 2009 2215 assert(dlg != NULL); … … 2014 2220 } 2015 2221 2016 dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg)2222 static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg) 2017 2223 { 2018 2224 assert(dlg != NULL); … … 2023 2229 } 2024 2230 2025 dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg)2231 static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg) 2026 2232 { 2027 2233 assert(dlg != NULL); … … 2033 2239 2034 2240 /* Accelerator specific functions */ 2035 event_t *add_event(int key, int id, int flags, event_t *prev)2241 static event_t *add_event(int key, int id, int flags, event_t *prev) 2036 2242 { 2037 2243 event_t *ev = new_event(); … … 2049 2255 } 2050 2256 2051 event_t *add_string_event(string_t *key, int id, int flags, event_t *prev)2257 static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev) 2052 2258 { 2053 2259 int keycode = 0; … … 2057 2263 yyerror("Key code must be an ascii string"); 2058 2264 2059 if((flags & WRC_AF_VIRTKEY) && (!isupper(key->str.cstr[0] ) && !isdigit(key->str.cstr[0])))2265 if((flags & WRC_AF_VIRTKEY) && (!isupper(key->str.cstr[0] & 0xff) && !isdigit(key->str.cstr[0] & 0xff))) 2060 2266 yyerror("VIRTKEY code is not equal to ascii value"); 2061 2267 … … 2082 2288 2083 2289 /* MenuEx specific functions */ 2084 itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid)2290 static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid) 2085 2291 { 2086 2292 itemex_opt_t *opt = (itemex_opt_t *)xmalloc(sizeof(itemex_opt_t)); … … 2093 2299 2094 2300 /* Raw data functions */ 2095 raw_data_t *load_file(string_t *name)2301 static raw_data_t *load_file(string_t *name) 2096 2302 { 2097 2303 FILE *fp; … … 2100 2306 yyerror("Filename must be ASCII string"); 2101 2307 2102 fp = open_include(name->str.cstr, 1 );2308 fp = open_include(name->str.cstr, 1, NULL); 2103 2309 if(!fp) 2104 2310 yyerror("Cannot open file %s", name->str.cstr); … … 2110 2316 fread(rd->data, rd->size, 1, fp); 2111 2317 fclose(fp); 2112 HEAPCHECK();2113 2318 return rd; 2114 2319 } 2115 2320 2116 raw_data_t *int2raw_data(int i)2321 static raw_data_t *int2raw_data(int i) 2117 2322 { 2118 2323 raw_data_t *rd; … … 2124 2329 rd->size = sizeof(short); 2125 2330 rd->data = (char *)xmalloc(rd->size); 2126 *(short *)(rd->data) = (short)i; 2331 switch(byteorder) 2332 { 2333 #ifdef WORDS_BIGENDIAN 2334 default: 2335 #endif 2336 case WRC_BO_BIG: 2337 rd->data[0] = HIBYTE(i); 2338 rd->data[1] = LOBYTE(i); 2339 break; 2340 2341 #ifndef WORDS_BIGENDIAN 2342 default: 2343 #endif 2344 case WRC_BO_LITTLE: 2345 rd->data[1] = HIBYTE(i); 2346 rd->data[0] = LOBYTE(i); 2347 break; 2348 } 2127 2349 return rd; 2128 2350 } 2129 2351 2130 raw_data_t *long2raw_data(int i)2352 static raw_data_t *long2raw_data(int i) 2131 2353 { 2132 2354 raw_data_t *rd; … … 2134 2356 rd->size = sizeof(int); 2135 2357 rd->data = (char *)xmalloc(rd->size); 2136 *(int *)(rd->data) = i; 2358 switch(byteorder) 2359 { 2360 #ifdef WORDS_BIGENDIAN 2361 default: 2362 #endif 2363 case WRC_BO_BIG: 2364 rd->data[0] = HIBYTE(HIWORD(i)); 2365 rd->data[1] = LOBYTE(HIWORD(i)); 2366 rd->data[2] = HIBYTE(LOWORD(i)); 2367 rd->data[3] = LOBYTE(LOWORD(i)); 2368 break; 2369 2370 #ifndef WORDS_BIGENDIAN 2371 default: 2372 #endif 2373 case WRC_BO_LITTLE: 2374 rd->data[3] = HIBYTE(HIWORD(i)); 2375 rd->data[2] = LOBYTE(HIWORD(i)); 2376 rd->data[1] = HIBYTE(LOWORD(i)); 2377 rd->data[0] = LOBYTE(LOWORD(i)); 2378 break; 2379 } 2137 2380 return rd; 2138 2381 } 2139 2382 2140 raw_data_t *str2raw_data(string_t *str)2383 static raw_data_t *str2raw_data(string_t *str) 2141 2384 { 2142 2385 raw_data_t *rd; … … 2144 2387 rd->size = str->size * (str->type == str_char ? 1 : 2); 2145 2388 rd->data = (char *)xmalloc(rd->size); 2146 memcpy(rd->data, str->str.cstr, rd->size); 2389 if(str->type == str_char) 2390 memcpy(rd->data, str->str.cstr, rd->size); 2391 else if(str->type == str_unicode) 2392 { 2393 int i; 2394 switch(byteorder) 2395 { 2396 #ifdef WORDS_BIGENDIAN 2397 default: 2398 #endif 2399 case WRC_BO_BIG: 2400 for(i = 0; i < str->size; i++) 2401 { 2402 rd->data[2*i + 0] = HIBYTE((WORD)str->str.wstr[i]); 2403 rd->data[2*i + 1] = LOBYTE((WORD)str->str.wstr[i]); 2404 } 2405 break; 2406 #ifndef WORDS_BIGENDIAN 2407 default: 2408 #endif 2409 case WRC_BO_LITTLE: 2410 for(i = 0; i < str->size; i++) 2411 { 2412 rd->data[2*i + 1] = HIBYTE((WORD)str->str.wstr[i]); 2413 rd->data[2*i + 0] = LOBYTE((WORD)str->str.wstr[i]); 2414 } 2415 break; 2416 } 2417 } 2418 else 2419 internal_error(__FILE__, __LINE__, "Invalid stringtype"); 2147 2420 return rd; 2148 2421 } 2149 2422 2150 raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2)2423 static raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2) 2151 2424 { 2152 2425 r1->data = xrealloc(r1->data, r1->size + r2->size); … … 2156 2429 } 2157 2430 2158 raw_data_t *merge_raw_data_int(raw_data_t *r1, int i)2431 static raw_data_t *merge_raw_data_int(raw_data_t *r1, int i) 2159 2432 { 2160 2433 raw_data_t *t = int2raw_data(i); … … 2165 2438 } 2166 2439 2167 raw_data_t *merge_raw_data_long(raw_data_t *r1, int i)2440 static raw_data_t *merge_raw_data_long(raw_data_t *r1, int i) 2168 2441 { 2169 2442 raw_data_t *t = long2raw_data(i); … … 2174 2447 } 2175 2448 2176 raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str)2449 static raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str) 2177 2450 { 2178 2451 raw_data_t *t = str2raw_data(str); … … 2184 2457 2185 2458 /* Function the go back in a list to get the head */ 2186 menu_item_t *get_item_head(menu_item_t *p)2459 static menu_item_t *get_item_head(menu_item_t *p) 2187 2460 { 2188 2461 if(!p) … … 2193 2466 } 2194 2467 2195 menuex_item_t *get_itemex_head(menuex_item_t *p)2468 static menuex_item_t *get_itemex_head(menuex_item_t *p) 2196 2469 { 2197 2470 if(!p) … … 2202 2475 } 2203 2476 2204 resource_t *get_resource_head(resource_t *p)2477 static resource_t *get_resource_head(resource_t *p) 2205 2478 { 2206 2479 if(!p) … … 2211 2484 } 2212 2485 2213 ver_block_t *get_ver_block_head(ver_block_t *p)2486 static ver_block_t *get_ver_block_head(ver_block_t *p) 2214 2487 { 2215 2488 if(!p) … … 2220 2493 } 2221 2494 2222 ver_value_t *get_ver_value_head(ver_value_t *p)2495 static ver_value_t *get_ver_value_head(ver_value_t *p) 2223 2496 { 2224 2497 if(!p) … … 2229 2502 } 2230 2503 2231 control_t *get_control_head(control_t *p)2504 static control_t *get_control_head(control_t *p) 2232 2505 { 2233 2506 if(!p) … … 2238 2511 } 2239 2512 2240 event_t *get_event_head(event_t *p)2513 static event_t *get_event_head(event_t *p) 2241 2514 { 2242 2515 if(!p) … … 2248 2521 2249 2522 /* Find a stringtable with given language */ 2250 st ringtable_t *find_stringtable(lvc_t *lvc)2523 static stringtable_t *find_stringtable(lvc_t *lvc) 2251 2524 { 2252 2525 stringtable_t *stt; … … 2260 2533 { 2261 2534 if(stt->lvc.language->id == lvc->language->id 2262 && stt->lvc.language-> id == lvc->language->id)2535 && stt->lvc.language->sub == lvc->language->sub) 2263 2536 { 2264 2537 /* Found a table with the same language */ … … 2284 2557 /* qsort sorting function for string table entries */ 2285 2558 #define STE(p) ((stt_entry_t *)(p)) 2286 int sort_stt_entry(const void *e1, const void *e2)2559 static int sort_stt_entry(const void *e1, const void *e2) 2287 2560 { 2288 2561 return STE(e1)->id - STE(e2)->id; … … 2290 2563 #undef STE 2291 2564 2292 resource_t *build_stt_resources(stringtable_t *stthead)2565 static resource_t *build_stt_resources(stringtable_t *stthead) 2293 2566 { 2294 2567 stringtable_t *stt; … … 2388 2661 } 2389 2662 2390 /* Cursor and icon splitter functions */ 2391 typedef struct { 2392 language_t lan; 2393 int id; 2394 } id_alloc_t; 2395 2396 static int get_new_id(id_alloc_t **list, int *n, language_t *lan) 2397 { 2398 int i; 2399 assert(lan != NULL); 2400 assert(list != NULL); 2401 assert(n != NULL); 2402 2403 if(!*list) 2404 { 2405 *list = (id_alloc_t *)xmalloc(sizeof(id_alloc_t)); 2406 *n = 1; 2407 (*list)[0].lan = *lan; 2408 (*list)[0].id = 1; 2409 return 1; 2410 } 2411 2412 for(i = 0; i < *n; i++) 2413 { 2414 if((*list)[i].lan.id == lan->id && (*list)[i].lan.sub == lan->sub) 2415 return ++((*list)[i].id); 2416 } 2417 2418 *list = (id_alloc_t *)xrealloc(*list, sizeof(id_alloc_t) * (*n+1)); 2419 (*list)[*n].lan = *lan; 2420 (*list)[*n].id = 1; 2421 *n += 1; 2422 return 1; 2423 } 2424 2425 int alloc_icon_id(language_t *lan) 2426 { 2427 static id_alloc_t *idlist = NULL; 2428 static int nid = 0; 2429 2430 return get_new_id(&idlist, &nid, lan); 2431 } 2432 2433 int alloc_cursor_id(language_t *lan) 2434 { 2435 static id_alloc_t *idlist = NULL; 2436 static int nid = 0; 2437 2438 return get_new_id(&idlist, &nid, lan); 2439 } 2440 2441 #define BPTR(base) ((char *)(rd->data + (base))) 2442 #define WPTR(base) ((WORD *)(rd->data + (base))) 2443 #define DPTR(base) ((DWORD *)(rd->data + (base))) 2444 void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico) 2445 { 2446 int cnt; 2447 int i; 2448 icon_dir_entry_t *ide; 2449 icon_t *ico; 2450 icon_t *list = NULL; 2451 2452 /* FIXME: Distinguish between normal and animated icons (RIFF format) */ 2453 if(WPTR(0)[1] != 1) 2454 yyerror("Icon resource data has invalid type id %d", WPTR(0)[1]); 2455 cnt = WPTR(0)[2]; 2456 ide = (icon_dir_entry_t *)&(WPTR(0)[3]); 2457 for(i = 0; i < cnt; i++) 2458 { 2459 ico = new_icon(); 2460 ico->id = alloc_icon_id(icog->lvc.language); 2461 ico->lvc.language = dup_language(icog->lvc.language); 2462 if(ide[i].offset > rd->size 2463 || ide[i].offset + ide[i].ressize > rd->size) 2464 yyerror("Icon resource data corrupt"); 2465 ico->width = ide[i].width; 2466 ico->height = ide[i].height; 2467 ico->nclr = ide[i].nclr; 2468 ico->planes = ide[i].planes; 2469 ico->bits = ide[i].bits; 2470 if(!ico->planes) 2471 { 2472 /* Argh! They did not fill out the resdir structure */ 2473 ico->planes = ((BITMAPINFOHEADER *)BPTR(ide[i].offset))->biPlanes; 2474 } 2475 if(!ico->bits) 2476 { 2477 /* Argh! They did not fill out the resdir structure */ 2478 ico->bits = ((BITMAPINFOHEADER *)BPTR(ide[i].offset))->biBitCount; 2479 } 2480 ico->data = new_raw_data(); 2481 copy_raw_data(ico->data, rd, ide[i].offset, ide[i].ressize); 2482 if(!list) 2483 { 2484 list = ico; 2485 } 2486 else 2487 { 2488 ico->next = list; 2489 list->prev = ico; 2490 list = ico; 2491 } 2492 } 2493 icog->iconlist = list; 2494 *nico = cnt; 2495 } 2496 2497 void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur) 2498 { 2499 int cnt; 2500 int i; 2501 cursor_dir_entry_t *cde; 2502 cursor_t *cur; 2503 cursor_t *list = NULL; 2504 2505 /* FIXME: Distinguish between normal and animated cursors (RIFF format)*/ 2506 if(WPTR(0)[1] != 2) 2507 yyerror("Cursor resource data has invalid type id %d", WPTR(0)[1]); 2508 cnt = WPTR(0)[2]; 2509 cde = (cursor_dir_entry_t *)&(WPTR(0)[3]); 2510 for(i = 0; i < cnt; i++) 2511 { 2512 cur = new_cursor(); 2513 cur->id = alloc_cursor_id(curg->lvc.language); 2514 cur->lvc.language = dup_language(curg->lvc.language); 2515 if(cde[i].offset > rd->size 2516 || cde[i].offset + cde[i].ressize > rd->size) 2517 yyerror("Cursor resource data corrupt"); 2518 cur->width = cde[i].width; 2519 cur->height = cde[i].height; 2520 cur->nclr = cde[i].nclr; 2521 /* The next two are to support color cursors */ 2522 cur->planes = ((BITMAPINFOHEADER *)BPTR(cde[i].offset))->biPlanes; 2523 cur->bits = ((BITMAPINFOHEADER *)BPTR(cde[i].offset))->biBitCount; 2524 if(!win32 && (cur->planes != 1 || cur->bits != 1)) 2525 yywarning("Win16 cursor contains colors"); 2526 cur->xhot = cde[i].xhot; 2527 cur->yhot = cde[i].yhot; 2528 cur->data = new_raw_data(); 2529 copy_raw_data(cur->data, rd, cde[i].offset, cde[i].ressize); 2530 if(!list) 2531 { 2532 list = cur; 2533 } 2534 else 2535 { 2536 cur->next = list; 2537 list->prev = cur; 2538 list = cur; 2539 } 2540 } 2541 curg->cursorlist = list; 2542 *ncur = cnt; 2543 } 2544 2545 #undef BPTR 2546 #undef WPTR 2547 #undef DPTR 2548 2549 2550 toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec) 2663 2664 static toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec) 2551 2665 { 2552 2666 idrec->prev = prev; … … 2557 2671 } 2558 2672 2559 toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems)2673 static toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems) 2560 2674 { 2561 2675 if(!p) … … 2576 2690 } 2577 2691 2692 static string_t *make_filename(string_t *str) 2693 { 2694 char *cptr; 2695 2696 if(str->type != str_char) 2697 yyerror("Cannot handle UNICODE filenames"); 2698 2699 /* Remove escaped backslash and convert to forward */ 2700 cptr = str->str.cstr; 2701 for(cptr = str->str.cstr; (cptr = strchr(cptr, '\\')) != NULL; cptr++) 2702 { 2703 if(cptr[1] == '\\') 2704 { 2705 memmove(cptr, cptr+1, strlen(cptr)); 2706 str->size--; 2707 } 2708 *cptr = '/'; 2709 } 2710 2711 /* Convert to lower case. Seems to be reasonable to do */ 2712 for(cptr = str->str.cstr; !leave_case && *cptr; cptr++) 2713 { 2714 *cptr = tolower(*cptr); 2715 } 2716 return str; 2717 } 2718 2719 /* 2720 * Process all resources to extract fonts and build 2721 * a fontdir resource. 2722 * 2723 * Note: MS' resource compiler (build 1472) does not 2724 * handle font resources with different languages. 2725 * The fontdir is generated in the last active language 2726 * and font identifiers must be unique across the entire 2727 * source. 2728 * This is not logical considering the localization 2729 * constraints of all other resource types. MS has, 2730 * most probably, never testet localized fonts. However, 2731 * using fontresources is rare, so it might not occur 2732 * in normal applications. 2733 * Wine does require better localization because a lot 2734 * of languages are coded into the same executable. 2735 * Therefore, I will generate fontdirs for *each* 2736 * localized set of fonts. 2737 */ 2738 static resource_t *build_fontdir(resource_t **fnt, int nfnt) 2739 { 2740 static int once = 0; 2741 if(!once) 2742 { 2743 warning("Need to parse fonts, not yet implemented (fnt: %p, nfnt: %d)", fnt, nfnt); 2744 once++; 2745 } 2746 return NULL; 2747 } 2748 2749 static resource_t *build_fontdirs(resource_t *tail) 2750 { 2751 resource_t *rsc; 2752 resource_t *lst = NULL; 2753 resource_t **fnt = NULL; /* List of all fonts */ 2754 int nfnt = 0; 2755 resource_t **fnd = NULL; /* List of all fontdirs */ 2756 int nfnd = 0; 2757 resource_t **lanfnt = NULL; 2758 int nlanfnt = 0; 2759 int i; 2760 name_id_t nid; 2761 string_t str; 2762 int fntleft; 2763 2764 nid.type = name_str; 2765 nid.name.s_name = &str; 2766 str.type = str_char; 2767 str.str.cstr = "FONTDIR"; 2768 str.size = 7; 2769 2770 /* Extract all fonts and fontdirs */ 2771 for(rsc = tail; rsc; rsc = rsc->prev) 2772 { 2773 if(rsc->type == res_fnt) 2774 { 2775 nfnt++; 2776 fnt = xrealloc(fnt, nfnt * sizeof(*fnt)); 2777 fnt[nfnt-1] = rsc; 2778 } 2779 else if(rsc->type == res_fntdir) 2780 { 2781 nfnd++; 2782 fnd = xrealloc(fnd, nfnd * sizeof(*fnd)); 2783 fnd[nfnd-1] = rsc; 2784 } 2785 } 2786 2787 /* Verify the name of the present fontdirs */ 2788 for(i = 0; i < nfnd; i++) 2789 { 2790 if(compare_name_id(&nid, fnd[i]->name)) 2791 { 2792 warning("User supplied FONTDIR entry has an invalid name '%s', ignored", 2793 get_nameid_str(fnd[i]->name)); 2794 fnd[i] = NULL; 2795 } 2796 } 2797 2798 /* Sanity check */ 2799 if(nfnt == 0) 2800 { 2801 if(nfnd != 0) 2802 warning("Found %d FONTDIR entries without any fonts present", nfnd); 2803 goto clean; 2804 } 2805 2806 /* Copy space */ 2807 lanfnt = xmalloc(nfnt * sizeof(*lanfnt)); 2808 2809 /* Get all fonts covered by fontdirs */ 2810 for(i = 0; i < nfnd; i++) 2811 { 2812 int j; 2813 WORD cnt; 2814 int isswapped = 0; 2815 2816 if(!fnd[i]) 2817 continue; 2818 for(j = 0; j < nfnt; j++) 2819 { 2820 if(!fnt[j]) 2821 continue; 2822 if(fnt[j]->lan->id == fnd[i]->lan->id && fnt[j]->lan->sub == fnd[i]->lan->sub) 2823 { 2824 lanfnt[nlanfnt] = fnt[j]; 2825 nlanfnt++; 2826 fnt[j] = NULL; 2827 } 2828 } 2829 2830 cnt = *(WORD *)fnd[i]->res.fnd->data->data; 2831 if(nlanfnt == cnt) 2832 isswapped = 0; 2833 else if(nlanfnt == BYTESWAP_WORD(cnt)) 2834 isswapped = 1; 2835 else 2836 error("FONTDIR for language %d,%d has wrong count (%d, expected %d)", 2837 fnd[i]->lan->id, fnd[i]->lan->sub, cnt, nlanfnt); 2838 #ifdef WORDS_BIGENDIAN 2839 if((byteorder == WRC_BO_LITTLE && !isswapped) || (byteorder != WRC_BO_LITTLE && isswapped)) 2840 #else 2841 if((byteorder == WRC_BO_BIG && !isswapped) || (byteorder != WRC_BO_BIG && isswapped)) 2842 #endif 2843 { 2844 internal_error(__FILE__, __LINE__, "User supplied FONTDIR needs byteswapping"); 2845 } 2846 } 2847 2848 /* We now have fonts left where we need to make a fontdir resource */ 2849 for(i = fntleft = 0; i < nfnt; i++) 2850 { 2851 if(fnt[i]) 2852 fntleft++; 2853 } 2854 while(fntleft) 2855 { 2856 /* Get fonts of same language in lanfnt[] */ 2857 for(i = nlanfnt = 0; i < nfnt; i++) 2858 { 2859 if(fnt[i]) 2860 { 2861 if(!nlanfnt) 2862 { 2863 addlanfnt: 2864 lanfnt[nlanfnt] = fnt[i]; 2865 nlanfnt++; 2866 fnt[i] = NULL; 2867 fntleft--; 2868 } 2869 else if(fnt[i]->lan->id == lanfnt[0]->lan->id && fnt[i]->lan->sub == lanfnt[0]->lan->sub) 2870 goto addlanfnt; 2871 } 2872 } 2873 /* and build a fontdir */ 2874 rsc = build_fontdir(lanfnt, nlanfnt); 2875 if(rsc) 2876 { 2877 if(lst) 2878 { 2879 lst->next = rsc; 2880 rsc->prev = lst; 2881 } 2882 lst = rsc; 2883 } 2884 } 2885 2886 free(lanfnt); 2887 clean: 2888 if(fnt) 2889 free(fnt); 2890 if(fnd) 2891 free(fnd); 2892 return lst; 2893 } 2894 2895 /* 2896 * This gets invoked to determine whether the next resource 2897 * is to be of a standard-type (e.g. bitmaps etc.), or should 2898 * be a user-type resource. This function is required because 2899 * there is the _possibility_ of a lookahead token in the 2900 * parser, which is generated from the "expr" state in the 2901 * "nameid" parsing. 2902 * 2903 * The general resource format is: 2904 * <identifier> <type> <flags> <resourcebody> 2905 * 2906 * The <identifier> can either be tIDENT or "expr". The latter 2907 * will always generate a lookahead, which is the <type> of the 2908 * resource to parse. Otherwise, we need to get a new token from 2909 * the scanner to determine the next step. 2910 * 2911 * The problem arrises when <type> is numerical. This case should 2912 * map onto default resource-types and be parsed as such instead 2913 * of being mapped onto user-type resources. 2914 * 2915 * The trick lies in the fact that yacc (bison) doesn't care about 2916 * intermediate changes of the lookahead while reducing a rule. We 2917 * simply replace the lookahead with a token that will result in 2918 * a shift to the appropriate rule for the specific resource-type. 2919 */ 2920 static int rsrcid_to_token(int lookahead) 2921 { 2922 int token; 2923 char *type = "?"; 2924 2925 /* Get a token if we don't have one yet */ 2926 if(lookahead == YYEMPTY) 2927 lookahead = YYLEX; 2928 2929 /* Only numbers are possibly interesting */ 2930 switch(lookahead) 2931 { 2932 case tNUMBER: 2933 case tLNUMBER: 2934 break; 2935 default: 2936 return lookahead; 2937 } 2938 2939 token = lookahead; 2940 2941 switch(yylval.num) 2942 { 2943 case WRC_RT_CURSOR: 2944 type = "CURSOR"; 2945 token = tCURSOR; 2946 break; 2947 case WRC_RT_ICON: 2948 type = "ICON"; 2949 token = tICON; 2950 break; 2951 case WRC_RT_BITMAP: 2952 type = "BITMAP"; 2953 token = tBITMAP; 2954 break; 2955 case WRC_RT_FONT: 2956 type = "FONT"; 2957 token = tFONT; 2958 break; 2959 case WRC_RT_FONTDIR: 2960 type = "FONTDIR"; 2961 token = tFONTDIR; 2962 break; 2963 case WRC_RT_RCDATA: 2964 type = "RCDATA"; 2965 token = tRCDATA; 2966 break; 2967 case WRC_RT_MESSAGETABLE: 2968 type = "MESSAGETABLE"; 2969 token = tMESSAGETABLE; 2970 break; 2971 case WRC_RT_DLGINIT: 2972 type = "DLGINIT"; 2973 token = tDLGINIT; 2974 break; 2975 case WRC_RT_ACCELERATOR: 2976 type = "ACCELERATOR"; 2977 token = tACCELERATORS; 2978 break; 2979 case WRC_RT_MENU: 2980 type = "MENU"; 2981 token = tMENU; 2982 break; 2983 case WRC_RT_DIALOG: 2984 type = "DIALOG"; 2985 token = tDIALOG; 2986 break; 2987 case WRC_RT_VERSION: 2988 type = "VERSION"; 2989 token = tVERSIONINFO; 2990 break; 2991 case WRC_RT_TOOLBAR: 2992 type = "TOOLBAR"; 2993 token = tTOOLBAR; 2994 break; 2995 2996 case WRC_RT_STRING: 2997 type = "STRINGTABLE"; 2998 break; 2999 3000 case WRC_RT_ANICURSOR: 3001 case WRC_RT_ANIICON: 3002 case WRC_RT_GROUP_CURSOR: 3003 case WRC_RT_GROUP_ICON: 3004 yywarning("Usertype uses reserved type-ID %d, which is auto-generated", yylval.num); 3005 return lookahead; 3006 3007 case WRC_RT_DLGINCLUDE: 3008 case WRC_RT_PLUGPLAY: 3009 case WRC_RT_VXD: 3010 case WRC_RT_HTML: 3011 yywarning("Usertype uses reserved type-ID %d, which is not supported by wrc", yylval.num); 3012 default: 3013 return lookahead; 3014 } 3015 3016 if(remap) 3017 return token; 3018 else 3019 yywarning("Usertype uses reserved type-ID %d, which is used by %s", yylval.num, type); 3020 return lookahead; 3021 } 3022 -
trunk/tools/wrc/preproc.c
r3476 r5522 9 9 #include <stdlib.h> 10 10 #include <string.h> 11 #include <assert.h> 11 12 12 13 #include "wrc.h" 13 14 #include "utils.h" 14 15 #include "preproc.h" 15 #include "parser.h"16 16 17 17 18 18 extern void set_pp_ignore(int); /* From parser.l */ 19 19 20 static char *current_define;21 22 20 #define HASHKEY 2039 23 static struct pp_entry*pp_defines[HASHKEY];21 static pp_entry_t *pp_defines[HASHKEY]; 24 22 25 23 #define MAXIFSTACK 64 26 static struct if_state ifstack[MAXIFSTACK];27 static int if stackidx = 0;24 static if_state_t if_stack[MAXIFSTACK]; 25 static int if_stack_idx = 0; 28 26 29 27 #if 0 28 void pp_status(void) __attribute__((destructor)); 30 29 void pp_status(void) 31 30 { … … 33 32 int sum; 34 33 int total = 0; 35 struct pp_entry*ppp;36 37 printf("Defines statistics:\n");34 pp_entry_t *ppp; 35 36 fprintf(stderr, "Defines statistics:\n"); 38 37 for(i = 0; i < HASHKEY; i++) 39 38 { … … 42 41 sum++; 43 42 total += sum; 44 printf("%4d, %3d\n", i, sum); 45 } 46 printf("Total defines: %d\n", total); 47 } 48 #pragma exit pp_status 43 fprintf(stderr, "%4d, %3d\n", i, sum); 44 } 45 fprintf(stderr, "Total defines: %d\n", total); 46 } 49 47 #endif 50 48 51 49 /* Don't comment on the hash, its primitive but functional... */ 52 int pp _hash(char *str)50 int pphash(char *str) 53 51 { 54 52 int sum = 0; … … 58 56 } 59 57 60 struct pp_entry *pp_lookup(char *ident) 61 { 62 int index = pp_hash(ident); 63 struct pp_entry *ppp; 64 for(ppp = pp_defines[index]; ppp; ppp = ppp->next) 58 pp_entry_t *pplookup(char *ident) 59 { 60 int idx = pphash(ident); 61 pp_entry_t *ppp; 62 63 for(ppp = pp_defines[idx]; ppp; ppp = ppp->next) 65 64 { 66 65 if(!strcmp(ident, ppp->ident)) … … 70 69 } 71 70 72 void set_define(char *name)73 {74 current_define = xstrdup(name);75 }76 77 71 void del_define(char *name) 78 72 { 79 int i ndex;80 struct pp_entry*ppp;81 82 if((ppp = pp _lookup(name)) == NULL)73 int idx; 74 pp_entry_t *ppp; 75 76 if((ppp = pplookup(name)) == NULL) 83 77 { 84 78 if(pedantic) … … 87 81 } 88 82 89 index = pp_hash(name); 90 if(pp_defines[index] == ppp) 91 { 92 pp_defines[index] = ppp->next; 93 if(pp_defines[index]) 94 pp_defines[index]->prev = NULL; 83 if(ppp->iep) 84 { 85 if(debuglevel & DEBUGLEVEL_PPMSG) 86 fprintf(stderr, "del_define: %s:%d: includelogic removed, include_ppp='%s', file=%s\n", input_name, line_number, name, ppp->iep->filename); 87 if(ppp->iep == includelogiclist) 88 { 89 includelogiclist = ppp->iep->next; 90 if(includelogiclist) 91 includelogiclist->prev = NULL; 92 } 93 else 94 { 95 ppp->iep->prev->next = ppp->iep->next; 96 if(ppp->iep->next) 97 ppp->iep->next->prev = ppp->iep->prev; 98 } 99 free(ppp->iep->filename); 100 free(ppp->iep); 101 } 102 103 idx = pphash(name); 104 if(pp_defines[idx] == ppp) 105 { 106 pp_defines[idx] = ppp->next; 107 if(pp_defines[idx]) 108 pp_defines[idx]->prev = NULL; 95 109 } 96 110 else … … 100 114 ppp->next->prev = ppp->prev; 101 115 } 116 102 117 free(ppp); 103 } 104 105 void add_define(char *text) 118 119 if(debuglevel & DEBUGLEVEL_PPMSG) 120 printf("Deleted (%s, %d) <%s>\n", input_name, line_number, name); 121 } 122 123 pp_entry_t *add_define(char *def, char *text) 106 124 { 107 125 int len; 108 126 char *cptr; 109 int index = pp_hash(current_define); 110 struct pp_entry *ppp; 111 if(pp_lookup(current_define) != NULL) 127 int idx = pphash(def); 128 pp_entry_t *ppp; 129 130 if((ppp = pplookup(def)) != NULL) 112 131 { 113 132 if(pedantic) 114 yywarning("Redefinition of %s", current_define); 115 del_define(current_define); 116 } 117 ppp = (struct pp_entry *)xmalloc(sizeof(struct pp_entry)); 118 ppp->ident = current_define; 119 ppp->subst = xstrdup(text); 120 ppp->next = pp_defines[index]; 121 pp_defines[index] = ppp; 133 yywarning("Redefinition of %s\n\tPrevious definition: %s:%d", def, ppp->filename, ppp->linenumber); 134 del_define(def); 135 } 136 ppp = (pp_entry_t *)xmalloc(sizeof(pp_entry_t)); 137 ppp->ident = def; 138 ppp->type = def_define; 139 ppp->subst.text = text; 140 ppp->filename = input_name ? xstrdup(input_name) : "<internal or cmdline>"; 141 ppp->linenumber = input_name ? line_number : 0; 142 ppp->next = pp_defines[idx]; 143 pp_defines[idx] = ppp; 122 144 if(ppp->next) 123 145 ppp->next->prev = ppp; 124 /* Strip trailing white space from subst text */ 125 len = strlen(ppp->subst); 126 while(len && strchr(" \t\r\n", ppp->subst[len-1])) 127 { 128 ppp->subst[--len] = '\0'; 129 } 130 /* Strip leading white space from subst text */ 131 for(cptr = ppp->subst; *cptr && strchr(" \t\r", *cptr); cptr++) 146 if(text) 147 { 148 /* Strip trailing white space from subst text */ 149 len = strlen(text); 150 while(len && strchr(" \t\r\n", text[len-1])) 151 { 152 text[--len] = '\0'; 153 } 154 /* Strip leading white space from subst text */ 155 for(cptr = text; *cptr && strchr(" \t\r", *cptr); cptr++) 132 156 ; 133 if(ppp->subst != cptr) 134 memmove(ppp->subst, cptr, strlen(cptr)+1); 135 if(yydebug) 136 printf("Added (%s, %d) <%s> to <%s>\n", input_name, line_number, ppp->ident, ppp->subst); 137 } 138 139 void add_cmdline_define(char *set) 157 if(text != cptr) 158 memmove(text, cptr, strlen(cptr)+1); 159 } 160 if(debuglevel & DEBUGLEVEL_PPMSG) 161 printf("Added define (%s, %d) <%s> to <%s>\n", input_name, line_number, ppp->ident, text ? text : "(null)"); 162 163 return ppp; 164 } 165 166 pp_entry_t *add_cmdline_define(char *set) 140 167 { 141 168 char *cpy = xstrdup(set); /* Because gcc passes a R/O string */ … … 143 170 if(cptr) 144 171 *cptr = '\0'; 145 set_define(cpy); 146 add_define(cptr ? cptr+1 : ""); 147 free(cpy); 148 } 149 150 /*kso added test for __SEMICOLON__ since __WIN32OS2__ isn't defined! */ 151 #if defined(__SEMICOLON__) || defined(_Windows) || defined(__MSDOS__) || defined(__WIN32OS2__) 172 return add_define(cpy, xstrdup(cptr ? cptr+1 : "")); 173 } 174 175 pp_entry_t *add_special_define(char *id) 176 { 177 pp_entry_t *ppp = add_define(xstrdup(id), xstrdup("")); 178 ppp->type = def_special; 179 return ppp; 180 } 181 182 pp_entry_t *add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp) 183 { 184 int idx = pphash(id); 185 pp_entry_t *ppp; 186 187 if((ppp = pplookup(id)) != NULL) 188 { 189 if(pedantic) 190 yywarning("Redefinition of %s\n\tPrevious definition: %s:%d", id, ppp->filename, ppp->linenumber); 191 del_define(id); 192 } 193 ppp = (pp_entry_t *)xmalloc(sizeof(pp_entry_t)); 194 ppp->ident = id; 195 ppp->type = def_macro; 196 ppp->margs = args; 197 ppp->nargs = nargs; 198 ppp->subst.mtext= exp; 199 ppp->filename = input_name ? xstrdup(input_name) : "<internal or cmdline>"; 200 ppp->linenumber = input_name ? line_number : 0; 201 ppp->next = pp_defines[idx]; 202 pp_defines[idx] = ppp; 203 if(ppp->next) 204 ppp->next->prev = ppp; 205 206 if(debuglevel & DEBUGLEVEL_PPMSG) 207 { 208 fprintf(stderr, "Added macro (%s, %d) <%s(%d)> to <", input_name, line_number, ppp->ident, nargs); 209 for(; exp; exp = exp->next) 210 { 211 switch(exp->type) 212 { 213 case exp_text: 214 fprintf(stderr, " \"%s\" ", exp->subst.text); 215 break; 216 case exp_stringize: 217 fprintf(stderr, " #(%d) ", exp->subst.argidx); 218 break; 219 case exp_concat: 220 fprintf(stderr, "##"); 221 break; 222 case exp_subst: 223 fprintf(stderr, " <%d> ", exp->subst.argidx); 224 break; 225 } 226 } 227 fprintf(stderr, ">\n"); 228 } 229 return ppp; 230 } 231 232 233 /* 234 *------------------------------------------------------------------------- 235 * Include management 236 *------------------------------------------------------------------------- 237 */ 238 #if defined(_Windows) || defined(__MSDOS__) 152 239 #define INCLUDESEPARATOR ";" 153 #warning "Using ; as include separator"154 240 #else 155 #warning "Using : as include separator"156 241 #define INCLUDESEPARATOR ":" 157 242 #endif … … 192 277 } 193 278 194 FILE *open_include(const char *name, int search )279 FILE *open_include(const char *name, int search, char **newpath) 195 280 { 196 281 char *cpy = xstrdup(name); … … 212 297 { 213 298 /* Search current dir and then -I path */ 214 fp = fopen( name, "rt");299 fp = fopen(cpy, "rb"); 215 300 if(fp) 216 301 { 217 if( yydebug)302 if(debuglevel & DEBUGLEVEL_PPMSG) 218 303 printf("Going to include <%s>\n", name); 219 free(cpy); 304 if(newpath) 305 *newpath = cpy; 306 else 307 free(cpy); 220 308 return fp; 221 309 } … … 229 317 strcat(path, "/"); 230 318 strcat(path, cpy); 231 fp = fopen(path, "r t");232 if(fp && yydebug)319 fp = fopen(path, "rb"); 320 if(fp && (debuglevel & DEBUGLEVEL_PPMSG)) 233 321 printf("Going to include <%s>\n", path); 234 free(path);235 322 if(fp) 236 323 { 324 if(newpath) 325 *newpath = path; 326 else 327 free(path); 237 328 free(cpy); 238 329 return fp; 239 330 } 240 331 free(path); 241 332 } 242 333 free(cpy); 334 if(newpath) 335 *newpath = NULL; 243 336 return NULL; 244 337 } 245 338 246 void push_if(int truecase, int wastrue, int nevertrue) 247 { 248 if(ifstackidx >= MAXIFSTACK-1) 249 internal_error(__FILE__, __LINE__, "#if stack overflow"); 250 ifstack[ifstackidx].current = truecase && !wastrue; 251 ifstack[ifstackidx].hasbeentrue = wastrue; 252 ifstack[ifstackidx].nevertrue = nevertrue; 253 if(nevertrue || !(truecase && !wastrue)) 254 set_pp_ignore(1); 255 if(yydebug) 256 printf("push_if: %d %d %d (%d %d %d)\n", 257 truecase, 258 wastrue, 259 nevertrue, 260 ifstack[ifstackidx].current, 261 ifstack[ifstackidx].hasbeentrue, 262 ifstack[ifstackidx].nevertrue); 263 ifstackidx++; 264 } 265 266 int pop_if(void) 267 { 268 if(ifstackidx <= 0) 269 yyerror("#endif without #if|#ifdef|#ifndef (#if stack underflow)"); 270 ifstackidx--; 271 if(yydebug) 272 printf("pop_if: %d %d %d\n", 273 ifstack[ifstackidx].current, 274 ifstack[ifstackidx].hasbeentrue, 275 ifstack[ifstackidx].nevertrue); 276 if(ifstack[ifstackidx].nevertrue || !ifstack[ifstackidx].current) 277 set_pp_ignore(0); 278 return ifstack[ifstackidx].hasbeentrue || ifstack[ifstackidx].current; 279 } 280 281 int isnevertrue_if(void) 282 { 283 return ifstackidx > 0 && ifstack[ifstackidx-1].nevertrue; 284 } 285 339 /* 340 *------------------------------------------------------------------------- 341 * #if, #ifdef, #ifndef, #else, #elif and #endif state management 342 * 343 * #if state transitions are made on basis of the current TOS and the next 344 * required state. The state transitions are required to housekeep because 345 * #if:s can be nested. The ignore case is activated to prevent output from 346 * within a false clause. 347 * Some special cases come from the fact that the #elif cases are not 348 * binary, but three-state. The problem is that all other elif-cases must 349 * be false when one true one has been found. A second problem is that the 350 * #else clause is a final clause. No extra #else:s may follow. 351 * 352 * The states mean: 353 * if_true Process input to output 354 * if_false Process input but no output 355 * if_ignore Process input but no output 356 * if_elif Process input but no output 357 * if_elsefalse Process input but no output 358 * if_elsettrue Process input to output 359 * 360 * The possible state-sequences are [state(stack depth)] (rest can be deduced): 361 * TOS #if 1 #else #endif 362 * if_true(n) if_true(n+1) if_elsefalse(n+1) 363 * if_false(n) if_ignore(n+1) if_ignore(n+1) 364 * if_elsetrue(n) if_true(n+1) if_elsefalse(n+1) 365 * if_elsefalse(n) if_ignore(n+1) if_ignore(n+1) 366 * if_elif(n) if_ignore(n+1) if_ignore(n+1) 367 * if_ignore(n) if_ignore(n+1) if_ignore(n+1) 368 * 369 * TOS #if 1 #elif 0 #else #endif 370 * if_true(n) if_true(n+1) if_elif(n+1) if_elif(n+1) 371 * if_false(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 372 * if_elsetrue(n) if_true(n+1) if_elif(n+1) if_elif(n+1) 373 * if_elsefalse(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 374 * if_elif(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 375 * if_ignore(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 376 * 377 * TOS #if 0 #elif 1 #else #endif 378 * if_true(n) if_false(n+1) if_true(n+1) if_elsefalse(n+1) 379 * if_false(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 380 * if_elsetrue(n) if_false(n+1) if_true(n+1) if_elsefalse(n+1) 381 * if_elsefalse(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 382 * if_elif(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 383 * if_ignore(n) if_ignore(n+1) if_ignore(n+1) if_ignore(n+1) 384 * 385 *------------------------------------------------------------------------- 386 */ 387 static char *if_state_str[] = { 388 "if_false", 389 "if_true", 390 "if_elif", 391 "if_elsefalse", 392 "if_elsetrue", 393 "if_ignore" 394 }; 395 396 void push_if(if_state_t s) 397 { 398 if(if_stack_idx >= MAXIFSTACK) 399 internal_error(__FILE__, __LINE__, "#if-stack overflow; #{if,ifdef,ifndef} nested too deeply (> %d)", MAXIFSTACK); 400 401 if(debuglevel & DEBUGLEVEL_PPLEX) 402 fprintf(stderr, "Push if %s:%d: %s(%d) -> %s(%d)\n", input_name, line_number, if_state_str[if_state()], if_stack_idx, if_state_str[s], if_stack_idx+1); 403 404 if_stack[if_stack_idx++] = s; 405 406 switch(s) 407 { 408 case if_true: 409 case if_elsetrue: 410 break; 411 case if_false: 412 case if_elsefalse: 413 case if_elif: 414 case if_ignore: 415 push_ignore_state(); 416 break; 417 } 418 } 419 420 if_state_t pop_if(void) 421 { 422 if(if_stack_idx <= 0) 423 yyerror("#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)"); 424 425 switch(if_state()) 426 { 427 case if_true: 428 case if_elsetrue: 429 break; 430 case if_false: 431 case if_elsefalse: 432 case if_elif: 433 case if_ignore: 434 pop_ignore_state(); 435 break; 436 } 437 438 if(debuglevel & DEBUGLEVEL_PPLEX) 439 fprintf(stderr, "Pop if %s:%d: %s(%d) -> %s(%d)\n", 440 input_name, 441 line_number, 442 if_state_str[if_state()], 443 if_stack_idx, 444 if_state_str[if_stack[if_stack_idx <= 1 ? if_true : if_stack_idx-2]], 445 if_stack_idx-1); 446 447 return if_stack[--if_stack_idx]; 448 } 449 450 if_state_t if_state(void) 451 { 452 if(!if_stack_idx) 453 return if_true; 454 else 455 return if_stack[if_stack_idx-1]; 456 } 457 458 459 void next_if_state(int i) 460 { 461 switch(if_state()) 462 { 463 case if_true: 464 case if_elsetrue: 465 push_if(i ? if_true : if_false); 466 break; 467 case if_false: 468 case if_elsefalse: 469 case if_elif: 470 case if_ignore: 471 push_if(if_ignore); 472 break; 473 default: 474 internal_error(__FILE__, __LINE__, "Invalid if_state (%d) in #{if,ifdef,ifndef} directive", (int)if_state()); 475 } 476 } 477 478 int get_if_depth(void) 479 { 480 return if_stack_idx; 481 } 482 -
trunk/tools/wrc/preproc.h
r882 r5522 7 7 #define __WRC_PREPROC_H 8 8 9 struct pp_entry { 9 struct pp_entry; /* forward */ 10 /* 11 * Include logic 12 * A stack of files which are already included and 13 * are protected in the #ifndef/#endif way. 14 */ 15 typedef struct includelogicentry { 16 struct includelogicentry *next; 17 struct includelogicentry *prev; 18 struct pp_entry *ppp; /* The define which protects the file */ 19 char *filename; /* The filename of the include */ 20 } includelogicentry_t; 21 22 /* 23 * The arguments of a macrodefinition 24 */ 25 typedef enum { 26 arg_single, 27 arg_list 28 } def_arg_t; 29 30 typedef struct marg { 31 def_arg_t type; /* Normal or ... argument */ 32 char *arg; /* The textual argument */ 33 int nnl; /* Number of newlines in the text to subst */ 34 } marg_t; 35 36 /* 37 * The expansiontext of a macro 38 */ 39 typedef enum { 40 exp_text, /* Simple text substitution */ 41 exp_concat, /* Concat (##) operator requested */ 42 exp_stringize, /* Stringize (#) operator requested */ 43 exp_subst /* Substitute argument */ 44 } def_exp_t; 45 46 typedef struct mtext { 47 struct mtext *next; 48 struct mtext *prev; 49 def_exp_t type; 50 union { 51 char *text; 52 int argidx; /* For exp_subst and exp_stringize reference */ 53 } subst; 54 } mtext_t; 55 56 /* 57 * The define descriptor 58 */ 59 typedef enum { 60 def_none, /* Not-a-define; used as return value */ 61 def_define, /* Simple defines */ 62 def_macro, /* Macro defines */ 63 def_special /* Special expansions like __LINE__ and __FILE__ */ 64 } def_type_t; 65 66 typedef struct pp_entry { 10 67 struct pp_entry *next; 11 68 struct pp_entry *prev; 12 char *ident; 13 char *subst; 14 int expanding; 15 }; 69 def_type_t type; /* Define or macro */ 70 char *ident; /* The key */ 71 marg_t **margs; /* Macro arguments array or NULL if none */ 72 int nargs; 73 union { 74 mtext_t *mtext; /* The substitution sequence or NULL if none */ 75 char *text; 76 } subst; 77 int expanding; /* Set when feeding substitution into the input */ 78 char *filename; /* Filename where it was defined */ 79 int linenumber; /* Linenumber where it was defined */ 80 includelogicentry_t *iep; /* Points to the include it protects */ 81 } pp_entry_t; 16 82 17 struct if_state {18 int current;19 int hasbeentrue;20 int nevertrue;21 };22 83 23 struct pp_entry *pp_lookup(char *ident); 24 void set_define(char *name); 84 /* 85 * If logic 86 */ 87 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */ 88 89 typedef enum { 90 if_false, 91 if_true, 92 if_elif, 93 if_elsefalse, 94 if_elsetrue, 95 if_ignore 96 } if_state_t; 97 98 /* 99 * I assume that 'long long' exists in the compiler when it has a size 100 * of 8 or bigger. If not, then we revert to a simple 'long' for now. 101 * This should prevent most unexpected things with other compilers than 102 * gcc and egcs for now. 103 * In the future it should be possible to use another way, like a 104 * structure, so that we can emulate the MS compiler. 105 */ 106 #if defined(SIZEOF_LONGLONG) && SIZEOF_LONGLONG >= 8 107 typedef long long wrc_sll_t; 108 typedef unsigned long long wrc_ull_t; 109 #else 110 typedef long wrc_sll_t; 111 typedef unsigned long wrc_ull_t; 112 #endif 113 114 #define SIZE_CHAR 1 115 #define SIZE_SHORT 2 116 #define SIZE_INT 3 117 #define SIZE_LONG 4 118 #define SIZE_LONGLONG 5 119 #define SIZE_MASK 0x00ff 120 #define FLAG_SIGNED 0x0100 121 122 typedef enum { 123 #if 0 124 cv_schar = SIZE_CHAR + FLAG_SIGNED, 125 cv_uchar = SIZE_CHAR, 126 cv_sshort = SIZE_SHORT + FLAG_SIGNED, 127 cv_ushort = SIZE_SHORT, 128 #endif 129 cv_sint = SIZE_INT + FLAG_SIGNED, 130 cv_uint = SIZE_INT, 131 cv_slong = SIZE_LONG + FLAG_SIGNED, 132 cv_ulong = SIZE_LONG, 133 cv_sll = SIZE_LONGLONG + FLAG_SIGNED, 134 cv_ull = SIZE_LONGLONG 135 } ctype_t; 136 137 typedef struct cval { 138 ctype_t type; 139 union { 140 #if 0 141 signed char sc; /* Explicitely signed because compilers are stupid */ 142 unsigned char uc; 143 short ss; 144 unsigned short us; 145 #endif 146 int si; 147 unsigned int ui; 148 long sl; 149 unsigned long ul; 150 wrc_sll_t sll; 151 wrc_ull_t ull; 152 } val; 153 } cval_t; 154 155 156 157 pp_entry_t *pplookup(char *ident); 158 pp_entry_t *add_define(char *def, char *text); 159 pp_entry_t *add_cmdline_define(char *set); 160 pp_entry_t *add_special_define(char *id); 161 pp_entry_t *add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp); 25 162 void del_define(char *name); 26 void add_define(char *text); 27 void add_cmdline_define(char *set); 28 FILE *open_include(const char *name, int search); 163 FILE *open_include(const char *name, int search, char **newpath); 29 164 void add_include_path(char *path); 30 void push_if(int truecase, int wastrue, int nevertrue); 31 int pop_if(void); 32 int isnevertrue_if(void); 165 void push_if(if_state_t s); 166 void next_if_state(int); 167 if_state_t pop_if(void); 168 if_state_t if_state(void); 169 int get_if_depth(void); 170 171 /* 172 * From ppl.l 173 */ 174 extern FILE *ppin; 175 extern FILE *ppout; 176 extern char *pptext; 177 extern int pp_flex_debug; 178 int pplex(void); 179 180 void do_include(char *fname, int type); 181 void push_ignore_state(void); 182 void pop_ignore_state(void); 183 184 extern int include_state; 185 extern char *include_ppp; 186 extern char *include_filename; 187 extern int include_ifdepth; 188 extern int seen_junk; 189 extern includelogicentry_t *includelogiclist; 190 191 /* 192 * From ppy.y 193 */ 194 int ppparse(void); 195 extern int ppdebug; 33 196 34 197 #endif -
trunk/tools/wrc/readres.c
r882 r5522 31 31 DWORD version; /* 0 */ 32 32 DWORD characts; /* 0 */ 33 } emptyheader = {0, 0x20, 0xffff, 0, 0xffff, 0, 0, 0, 0, 0, 0}; 33 } emptyheader = {0, 0x20, 0xffff, 0, 0xffff, 0, 0, 0, 0, 0, 0}, 34 emptyheaderSWAPPED = {0, BYTESWAP_DWORD(0x20), 0xffff, 0, 0xffff, 0, 0, 0, 0, 0, 0}; 34 35 35 36 /* … … 65 66 int read_data(FILE *fp, size_t size, void *buf) 66 67 { 67 int r;68 unsigned int r; 68 69 int pos = ftell(fp); 69 70 r = fread(buf, 1, size, fp); … … 136 137 #define get_dword(idx) (*((DWORD *)(&res->data[idx]))) 137 138 138 resource_t *read_res32(FILE *fp)139 static resource_t *read_res32(FILE *fp) 139 140 { 140 141 static char wrong_format[] = "Wrong resfile format (32bit)"; … … 312 313 ***************************************************************************** 313 314 */ 314 resource_t *read_res16(FILE *fp)315 static resource_t *read_res16(FILE *fp) 315 316 { 316 317 internal_error(__FILE__, __LINE__, "Can't yet read 16 bit .res files"); … … 332 333 FILE *fp; 333 334 struct resheader32 rh; 334 int is32bit ;335 int is32bit = 1; 335 336 resource_t *top; 336 337 … … 346 347 if(!memcmp(&emptyheader, &rh, sizeof(rh))) 347 348 is32bit = 1; 349 else if(!memcmp(&emptyheaderSWAPPED, &rh, sizeof(rh))) 350 error("Binary .res-file has its byteorder swapped"); 348 351 else 349 352 is32bit = 0;
Note:
See TracChangeset
for help on using the changeset viewer.