mirror of
https://github.com/reactos/wine.git
synced 2025-04-01 07:31:34 +00:00

Sun Jun 28 18:37:02 1998 Alexandre Julliard <julliard@lrc.epfl.ch> * [if1632/signal.c] [miscemu/instr.c] [memory/virtual.c] Moved page-fault handling to INSTR_EmulateInstruction. * [scheduler/thread.c] Added locking and check for own thread in Suspend/ResumeThread. Sat Jun 27 21:25:21 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de> * [objects/dib.c] [objects/bitmap.c] [objects/oembitmap.c] [graphics/x11drv/bitblt.c] [include/bitmap.h] Improved DIB section handling using page fault handlers. (Note: This patch includes code contributed by Matthew J. Francis.) * [memory/virtual.c] [if1632/signal.c] [include/global.h] Page Fault handler support added. * [if1632/signal.c] [loader/signal.c] [tools/build.c] [misc/system.c] [misc/winsock_dns.c] [include/sig_context.h] [include/thread.h] 16-bit %fs handling improved: Always preserve 16-bit %fs value, always restore 32-bit %fs value for signal handlers. * [if1632/thunk.c] [loader/module.c] [misc/callback.c] [windows/user.c] [loader/ne/resource.c] [include/callback.h] [include/module.h] [if1632/kernel.spec] [if1632/wprocs.spec] Resource Handler function pointer stored as 16-bit SEGPTR. * [loader/task.c] [windows/win.c] [windows/winpos.c] [if1632/user.spec] [if1632/kernel.spec] [loader/ne/module.c] Some minor incompatibilities fixed (Win32s relies on those): GetExePtr, IsWindow16 should set ES on return; WINPOS_SendNCCalcSize should cope with having the WINDOWPOS structure trashed; the OFSTRUCT in the NE module image should be placed *last*. * [include/windows.h] Missing prototype for FlushViewOfFile. * [loader/task.c] Bugfix: Command line should *not* start with a blank. * [loader/ne/segment.c] Bugfix: Fixups to offset 0 were never applied. * [misc/lstr.c] Use debugstr_a in OutputDebugString16. * [msdos/dpmi.c] Stub for int 31 BL=2f AX=7a20 (NetWare: Get VLM Call Address) added. * [msdos/int21.c] Stub for int 21 AX=440d CL=6f (get drive map information) added. Fri Jun 26 18:08:30 1998 Rein Klazes <rklazes@casema.net> * [windows/winpos.c] Fix small buglet that mixed up maximized and minimized windows. * [include/x11drv.h] [objects/dc.c] [graphics/x11drv/pen.c] [graphics/x11drv/graphics.c] Fix some bugs with lines joining styles. Draws rectangles with thick pens now correctly. Fri Jun 26 16:22:23 1998 James Juran <jrj120@psu.edu> * [misc/shell.c] Fixed bug I introduced last release in InternalExtractIcon. * [win32/file.c] Added documentation for CreateFile32A. * [documentation/wine.man] Updated manpage. * [ChangeLog] Added my entry from last release. Fri Jun 26 13:33:30 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk> * [graphics/psdrv/*] [if1632/wineps.spec] [include/psdrv.h] [include/print.h] [objects/gdiobj.c] First stages of an internal Postscript driver. See graphics/psdrv/README . Should print text (badly) from win3.1 notepad, write and winword6. * [documentation/printing] Some notes on printing. * [controls/edit.c] Strip off WS_BORDER in WM_NCREATE, edit draws its own rectangle. EC_USEFONTINFO seems to be used as a left/right value for EM_SETMARGINS and not as an action as the docs say. This actually makes more sense. Scroll the caret back to zero after a WM_SETTEXT. Fri Jun 26 10:56:25 1998 Marcus Meissner <marcus@jet.franken.de> * [if1632/snoop.c] Added win16 inter-dll snooping. * [win32/ordinals.c] KERNEL_485 is GetProcessDword. * [include/xmalloc.h][include/bitmap.h][misc/xmalloc.c] Added xcalloc so we 0 initialize XImages. Fixes/Hides the 'junk around MOPYFish'. * [misc/ntdll.c] Some stubs added. Thu Jun 25 15:22:43 1998 Adrian Harvey <adrian@select.com.au> * [scheduler/thread.c] Implemented SuspendThread and ResumeThread. Thu Jun 25 00:55:03 1998 Peter Hunnisett <hunnise@nortel.ca> * [include/debug.h,dplay.h,dsound.h][multimedia/dsound.c,dplay.c] [relay32/dplayx.spec,dplay.spec][multimedia/Makefile.in] [documentation/status/directplay] Added preliminary support for DirectPlay & DirectPlayLobby. Moved the preliminary stubs put in the dsound files into two new files dplay.h and dplay.c. Added new debug channel (dplay) for this. Created new document to keep track of implementation. * [include/winioctl.h][win32/device.c] Added some framework in DeviceIoControl to, in the future, support the "builtin" windows dwIoControlCodes. Added new header file winioctl.h . * [multimedia/mmsystem.c] Added slightly improved debugging information for PlaySound. Wed Jun 24 12:00:00 1998 Juergen Schmied <juergen.schmied@metronet.de> * [files/profile.c][graphics/x11drv/xfont.c][loader/module.c] Changed lstrcmpi32A to strcasecmp, lstrncmpi32A to strncasecmp, lstrcpy32A to strcpy, lstrlen32A to strlen, lstrcmp32A to strcmp because it's not necessary to support locale on such places. It causes a huge overhead and even fails sometimes * [include/oleauto.h][include/winerror.h] Added some ole-related constants. * [misc/shell.c] SHELL32_DllGetClassObject, SHGetSpecialFolderLocation, SHGetPathFromIDList improved the stubs * [ole/folders.c] IShellFolder* functions rewrote the stubs so don't crash and give something sensible back, started implementation of. * [ole/typelib.c][relay32/oleaut32.spec] LoadTypeLib32, RegisterTypeLib stub. * [ole/ole2nls.c] Fixed a buffer overrun in CompareString32A. Test for a bad pointer in LCMapString32A (happens in winhlp32 while building a index for searching). * [relay32/oleaut32.spec] [ole/typelib.c] Added stub for LoadTypeLib (ole32) to make excel95 happy. Tue Jun 23 22:47:09 1998 Alex Priem <alexp@sci.kun.nl> * [files/profile.c] [relay32/kernel32.spec] Added WritePrivateProfileStructA, GetPrivateProfileStructA, GetPrivateProfileSectionNames16. Tue Jun 23 01:34:43 1998 Pascal Cuoq <pcuoq@ens-lyon.fr> * [ole/ole2nls.c] GetStringTypeEx32A: Implemented CT_CTYPE2 and CT_CTYPE3 cases. LCMapString32A: Map final '\0' for '\0'-terminated strings. * [misc/shellord.c] [files/profile.c] [graphics/driver.c] [loader/module.c] [msdos/int21.c] [windows/driver.c] [files/drive.c] Changed lstrcmpi32A -> strcasecmp. Should be OK in these places. Sat Jun 20 23:40:00 1998 Bertho Stultiens <bertho@akhphd.au.dk> * [tools/wrc/] Wrc version 1.0.2 (20-Jun-1998). Please revert to the file tools/wrc/CHANGES for details. Sat Jun 20 14:58:00 1998 Marcel Baur <mbaur@g26.ethz.ch> * [ole/ole2nls.c] [ole/nls/*] Added the first 57 nls files, most are not yet complete. Wed Jun 17 11:16:54 1998 David Luyer <luyer@ucs.uwa.edu.au> * [relay32/relay386.c] [if1632/relay.c] Move debug_relay_(include|exclude)_list handling into seperate function RELAY_ShowDebugmsgsRelay(). Include checking of this for 16 bit calls (originally only 32-bit calls). * [relay32/snoop.c] [misc/main.c] Add debug_snoop_(include|exclude)_list as per the relay stuff. Fix typo and add information on -debugmsg +/-relay=... in help on -debugmsg. Refer to availability of snoop too. Tue Jun 10 22:00:18 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * [controls/header.c][include/header.h][include/commctrl.h] Added owner draw support. * [windows/nonclient.c][windows/sysmetics.c] Fixed menu bar height for Win95 look. Split NC_AdjustRect95() into NC_AdjustRectOuter95() and NC_AdjustRectInner95 to fix a menu bar bug. Improved Win95 look. * [controls/progress.c] Improved drawing code. Borders will be drawn by non-client code. * [controls/updown.c] Changed memory allocation and fixed some bugs. * [controls/toolbar.c] Fixed TB_BUTTONSTRUCTSIZE bug in MFC programs. Several improvements. * [misc/shell.c] Added stub for BrowseForFoldersA(). * [misc/shellord.c] Added stub for SHELL32_147(). * [controls/comctl32undoc.c] Minor changes. * [documentation/common_controls] New File: Documentation about development status, undocumented features and functions of the common controls.
924 lines
23 KiB
C
924 lines
23 KiB
C
/* -*-C-*-
|
|
*
|
|
* Copyright 1994 Martin von Loewis
|
|
* Copyright 1998 Bertho A. Stultiens (BS)
|
|
*
|
|
* 20-Jun-1998 BS - Changed the filename conversion. Filenames are
|
|
* case-sensitive inder *nix, but not under dos.
|
|
* default behaviour is to convert to lower case.
|
|
* - All backslashes are converted to forward and
|
|
* both single and double slash is recognized as
|
|
* MS/Borland does.
|
|
* - Fixed a bug in 'yywf' case that prevented
|
|
* double quoted names to be scanned propperly.
|
|
*
|
|
* 19-May-1998 BS - Started to build a preprocessor.
|
|
* - Changed keyword processing completely to
|
|
* table-lookups.
|
|
*
|
|
* 20-Apr-1998 BS - Added ';' comment stripping
|
|
*
|
|
* 17-Apr-1998 BS - Made the win32 keywords optional when compiling in
|
|
* 16bit mode
|
|
*
|
|
* 15-Apr-1998 BS - Changed string handling to include escapes
|
|
* - Added unicode string handling (no codepage
|
|
* translation though).
|
|
* - 'Borrowed' the main idea of string scanning from
|
|
* the flex manual pages.
|
|
* - Added conditional handling of scanning depending
|
|
* on the state of the parser. This was mainly required
|
|
* to distinguish a file to load or raw data that
|
|
* follows. MS's definition of filenames is rather
|
|
* complex... It can be unquoted or double quoted. If
|
|
* double quoted, then the '\\' char is not automatically
|
|
* escaped according to Borland's rc compiler, but it
|
|
* accepts both "\\path\\file.rc" and "\path\file.rc".
|
|
* This makes life very hard! I go for the escaped
|
|
* version, as this seems to be the documented way...
|
|
* - Single quoted strings are now parsed and converted
|
|
* here.
|
|
* - Added comment stripping. The implementation is
|
|
* 'borrowed' from the flex manpages.
|
|
* - Rebuild string processing so that it may contain
|
|
* escaped '\0'.
|
|
*/
|
|
|
|
/* Exclusive rules when looking for a filename */
|
|
%x yywf
|
|
%x yywf_s
|
|
/* Exclusive string handling */
|
|
%x yystr
|
|
/* Exclusive unicode string handling */
|
|
%x yylstr
|
|
/* Exclusive rcdata single quoted data handling */
|
|
%x yyrcd
|
|
/* Exclusive comment eating... */
|
|
%x comment
|
|
/* Preprocessor exclusives */
|
|
%x pp_incl
|
|
%x pp_def
|
|
%x pp_undef
|
|
%x pp_if
|
|
%x pp_ifdef
|
|
%x pp_ifndef
|
|
%x pp_elif
|
|
%x pp_else
|
|
%x pp_endif
|
|
%x pp_error
|
|
/* Set when accumulating #define's expansion text */
|
|
%x pp_def_s
|
|
/* Set when processing function type defines */
|
|
%x pp_ignore
|
|
/* Set when need to strip to eol */
|
|
%x pp_ignore_eol
|
|
/* Set when handling a false #if case */
|
|
%x pp_false
|
|
/* Set when stripping c-junk */
|
|
%x pp_strips
|
|
%x pp_stripp
|
|
%x pp_stripp_final
|
|
|
|
/*%option stack*/
|
|
%option never-interactive
|
|
/*%option noyywrap */
|
|
/* Some shortcut definitions */
|
|
ws [ \f\t\r]
|
|
cident [a-zA-Z_][0-9a-zA-Z_]*
|
|
|
|
%{
|
|
|
|
#if !defined(YY_FLEX_MAJOR_VERSION) || (1000 * YY_FLEX_MAJOR_VERSION + YY_FLEX_MINOR_VERSION < 2005)
|
|
#error Must use flex version 2.5.1 or higher (yy_scan_* routines are required).
|
|
#endif
|
|
|
|
/*#define LEX_DEBUG*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
#include <config.h>
|
|
#include "wrc.h"
|
|
#include "utils.h"
|
|
#include "preproc.h"
|
|
#include "parser.h"
|
|
#include "newstruc.h"
|
|
|
|
#include "y.tab.h"
|
|
|
|
#define YY_USE_PROTOS
|
|
#define YY_NO_UNPUT
|
|
|
|
/* Always update the current character position within a line */
|
|
#define YY_USER_ACTION char_number+=yyleng;
|
|
|
|
raw_data_t *new_raw_data(void);
|
|
|
|
void addcchar(char c);
|
|
void addwchar(short s);
|
|
string_t *get_buffered_cstring(void);
|
|
string_t *get_buffered_wstring(void);
|
|
string_t *make_string(char *s);
|
|
string_t *make_filename(char *s, int len);
|
|
|
|
int line_number = 1; /* The current line */
|
|
int char_number = 1; /* The current char pos within the line */
|
|
static char cbuffer[1024]; /* Buffers for string collection */
|
|
static int cbufidx;
|
|
static short wbuffer[1024];
|
|
static int wbufidx;
|
|
static int want_nl = 0; /* Set when newline needs to go to parser */
|
|
static int want_ident = 0; /* Set is #ifdef, #ifndef or defined is seen */
|
|
static int stripslevel = 0; /* Count {} during pp_strips mode */
|
|
static int stripplevel = 0; /* Count () during pp_strips mode */
|
|
static char *substtext = NULL; /* Holds the substition text while getting a define */
|
|
static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */
|
|
|
|
#ifdef YY_USE_STACK
|
|
void push_to(int start) { yy_push_state(start); }
|
|
void pop_start(void) { yy_pop_state(start); }
|
|
#else
|
|
#define MAXSTARTSTACK 32
|
|
static int startstack[MAXSTARTSTACK];
|
|
static int startstackidx = 0;
|
|
|
|
void push_to(int start)
|
|
{
|
|
if(yydebug)
|
|
printf("push_to(%d): %d -> %d\n", line_number, YY_START, start);
|
|
if(startstackidx >= MAXSTARTSTACK-1)
|
|
internal_error(__FILE__, __LINE__, "Start condition stack overflow");
|
|
startstack[startstackidx++] = YY_START;
|
|
BEGIN(start);
|
|
}
|
|
|
|
void pop_start(void)
|
|
{
|
|
if(yydebug)
|
|
printf("pop_start(%d): %d <- %d\n", line_number, startstack[startstackidx-1], YY_START);
|
|
if(startstackidx <= 0)
|
|
internal_error(__FILE__, __LINE__, "Start condition stack underflow");
|
|
--startstackidx;
|
|
BEGIN(startstack[startstackidx]);
|
|
}
|
|
#endif
|
|
|
|
|
|
struct bufferstackentry {
|
|
YY_BUFFER_STATE bufferstate; /* Buffer to switch back to */
|
|
struct pp_entry *define; /* Points to expanding define
|
|
or NULL if handling includes
|
|
*/
|
|
int line_number; /* Line that we were handling */
|
|
int char_number; /* The current position */
|
|
char *filename; /* Filename that we were handling */
|
|
};
|
|
|
|
#define MAXBUFFERSTACK 128
|
|
static struct bufferstackentry bufferstack[MAXBUFFERSTACK];
|
|
static int bufferstackidx = 0;
|
|
|
|
void push_buffer(YY_BUFFER_STATE buf, struct pp_entry *ppp, char *filename)
|
|
{
|
|
if(yydebug)
|
|
printf("push_buffer: %p %p %p\n", buf, ppp, filename);
|
|
if(bufferstackidx >= MAXBUFFERSTACK-1)
|
|
internal_error(__FILE__, __LINE__, "Buffer stack overflow");
|
|
memset(&bufferstack[bufferstackidx], 0, sizeof(bufferstack[0]));
|
|
bufferstack[bufferstackidx].bufferstate = buf;
|
|
bufferstack[bufferstackidx].define = ppp;
|
|
if(ppp)
|
|
ppp->expanding = 1;
|
|
else if(filename)
|
|
{
|
|
/* These will track the yyerror to the correct file and line */
|
|
bufferstack[bufferstackidx].line_number = line_number;
|
|
bufferstack[bufferstackidx].char_number = char_number;
|
|
line_number = 1;
|
|
char_number = 1;
|
|
bufferstack[bufferstackidx].filename = input_name;
|
|
input_name = filename;
|
|
}
|
|
else
|
|
internal_error(__FILE__, __LINE__, "Pushing buffer without knowing where to go to");
|
|
bufferstackidx++;
|
|
}
|
|
|
|
YY_BUFFER_STATE pop_buffer(void)
|
|
{
|
|
if(bufferstackidx <= 0)
|
|
return (YY_BUFFER_STATE)0;
|
|
bufferstackidx--;
|
|
if(bufferstack[bufferstackidx].define)
|
|
bufferstack[bufferstackidx].define->expanding = 0;
|
|
else
|
|
{
|
|
line_number = bufferstack[bufferstackidx].line_number;
|
|
char_number = bufferstack[bufferstackidx].char_number;
|
|
input_name = bufferstack[bufferstackidx].filename;
|
|
fclose(yyin);
|
|
}
|
|
if(yydebug)
|
|
printf("pop_buffer: %p %p (%d, %d) %p\n",
|
|
bufferstack[bufferstackidx].bufferstate,
|
|
bufferstack[bufferstackidx].define,
|
|
bufferstack[bufferstackidx].line_number,
|
|
bufferstack[bufferstackidx].char_number,
|
|
bufferstack[bufferstackidx].filename);
|
|
yy_switch_to_buffer(bufferstack[bufferstackidx].bufferstate);
|
|
return bufferstack[bufferstackidx].bufferstate;
|
|
}
|
|
|
|
void do_include(char *name, int namelen)
|
|
{
|
|
char *cpy = (char *)xmalloc(namelen);
|
|
strcpy(cpy, name+1); /* strip leading " or < */
|
|
cpy[namelen-2] = '\0'; /* strip trailing " or > */
|
|
if((yyin = open_include(cpy, name[0] == '"')) == NULL)
|
|
yyerror("Unable to open include file %s", cpy);
|
|
push_buffer(YY_CURRENT_BUFFER, NULL, cpy);
|
|
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
|
}
|
|
|
|
|
|
struct keyword {
|
|
char *keyword;
|
|
int token;
|
|
int isextension;
|
|
int needcase;
|
|
int alwayskeyword;
|
|
};
|
|
|
|
static struct keyword keywords[] = {
|
|
{ "ACCELERATORS", ACCELERATORS, 0, 0, 0},
|
|
{ "ALT", ALT, 0, 0, 0},
|
|
{ "ASCII", ASCII, 0, 0, 0},
|
|
{ "AUTO3STATE", AUTO3STATE, 1, 0, 0},
|
|
{ "AUTOCHECKBOX", AUTOCHECKBOX, 1, 0, 0},
|
|
{ "AUTORADIOBUTTON", AUTORADIOBUTTON, 1, 0, 0},
|
|
{ "BEGIN", tBEGIN, 0, 0, 1},
|
|
{ "BITMAP", tBITMAP, 0, 0, 0},
|
|
{ "BLOCK", BLOCK, 0, 0, 1},
|
|
{ "CAPTION", CAPTION, 0, 0, 0},
|
|
{ "CHARACTERISTICS", CHARACTERISTICS, 1, 0, 0},
|
|
{ "CHECKBOX", CHECKBOX, 0, 0, 0},
|
|
{ "CHECKED", CHECKED, 0, 0, 0},
|
|
{ "CLASS", CLASS, 0, 0, 0},
|
|
{ "COMBOBOX", COMBOBOX, 0, 0, 0},
|
|
{ "CONTROL", CONTROL, 0, 0, 0},
|
|
{ "CTEXT", CTEXT, 0, 0, 0},
|
|
{ "CURSOR", CURSOR, 0, 0, 0},
|
|
{ "defined", tDEFINED, 0, 1, 1},
|
|
{ "DEFPUSHBUTTON", DEFPUSHBUTTON, 0, 0, 1},
|
|
{ "DIALOG", DIALOG, 0, 0, 0},
|
|
{ "DIALOGEX", DIALOGEX, 1, 0, 0},
|
|
{ "DISCARDABLE", DISCARDABLE, 0, 0, 0},
|
|
{ "EDITTEXT", EDITTEXT, 0, 0, 0},
|
|
{ "END", tEND, 0, 0, 1},
|
|
{ "EXSTYLE", EXSTYLE, 0, 0, 0},
|
|
{ "extern", tEXTERN, 0, 1, 1},
|
|
{ "FILEFLAGS", FILEFLAGS, 0, 0, 0},
|
|
{ "FILEFLAGSMASK", FILEFLAGSMASK, 0, 0, 0},
|
|
{ "FILEOS", FILEOS, 0, 0, 0},
|
|
{ "FILESUBTYPE", FILESUBTYPE, 0, 0, 0},
|
|
{ "FILETYPE", FILETYPE, 0, 0, 0},
|
|
{ "FILEVERSION", FILEVERSION, 0, 0, 0},
|
|
{ "FIXED", tFIXED, 0, 0, 0},
|
|
{ "FONT", FONT, 0, 0, 0},
|
|
{ "GRAYED", GRAYED, 0, 0, 0},
|
|
{ "GROUPBOX", GROUPBOX, 0, 0, 0},
|
|
{ "HELP", HELP, 0, 0, 0},
|
|
{ "ICON", ICON, 0, 0, 0},
|
|
{ "IMPURE", IMPURE, 0, 0, 0},
|
|
{ "INACTIVE", INACTIVE, 0, 0, 0},
|
|
{ "LANGUAGE", LANGUAGE, 1, 0, 1},
|
|
{ "LISTBOX", LISTBOX, 0, 0, 0},
|
|
{ "LOADONCALL", LOADONCALL, 0, 0, 0},
|
|
{ "LTEXT", LTEXT, 0, 0, 0},
|
|
{ "MENU", MENU, 0, 0, 0},
|
|
{ "MENUBARBREAK", MENUBARBREAK, 0, 0, 0},
|
|
{ "MENUBREAK", MENUBREAK, 0, 0, 0},
|
|
{ "MENUEX", MENUEX, 1, 0, 0},
|
|
{ "MENUITEM", MENUITEM, 0, 0, 0},
|
|
{ "MESSAGETABLE", MESSAGETABLE, 1, 0, 0},
|
|
{ "MOVEABLE", MOVEABLE, 0, 0, 0},
|
|
{ "NOINVERT", NOINVERT, 0, 0, 0},
|
|
{ "NOT", NOT, 0, 0, 0},
|
|
{ "POPUP", POPUP, 0, 0, 0},
|
|
{ "PRELOAD", PRELOAD, 0, 0, 0},
|
|
{ "PRODUCTVERSION", PRODUCTVERSION, 0, 0, 0},
|
|
{ "PURE", tPURE, 0, 0, 0},
|
|
{ "PUSHBUTTON", PUSHBUTTON, 0, 0, 0},
|
|
{ "RADIOBUTTON", RADIOBUTTON, 0, 0, 0},
|
|
{ "RCDATA", RCDATA, 0, 0, 0},
|
|
{ "RTEXT", RTEXT, 0, 0, 0},
|
|
{ "SCROLLBAR", SCROLLBAR, 0, 0, 0},
|
|
{ "SEPARATOR", SEPARATOR, 0, 0, 0},
|
|
{ "SHIFT", SHIFT, 0, 0, 0},
|
|
{ "STATE3", STATE3, 1, 0, 0},
|
|
{ "STRING", tSTRING, 0, 0, 0},
|
|
{ "STRINGTABLE", STRINGTABLE, 0, 0, 1},
|
|
{ "STYLE", STYLE, 0, 0, 0},
|
|
{ "typedef", tTYPEDEF, 0, 1, 1},
|
|
{ "VALUE", VALUE, 0, 0, 0},
|
|
{ "VERSION", VERSION, 1, 0, 0},
|
|
{ "VERSIONINFO", VERSIONINFO, 0, 0, 0},
|
|
{ "VIRTKEY", VIRTKEY, 0, 0, 0}
|
|
};
|
|
|
|
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
|
#define KWP(p) ((struct keyword *)(p))
|
|
int kw_cmp_func(const void *s1, const void *s2)
|
|
{
|
|
int ret;
|
|
ret = stricmp(KWP(s1)->keyword, KWP(s2)->keyword);
|
|
if(!ret && (KWP(s1)->needcase || KWP(s2)->needcase))
|
|
return strcmp(KWP(s1)->keyword, KWP(s2)->keyword);
|
|
else
|
|
return ret;
|
|
}
|
|
|
|
#define KW_BSEARCH
|
|
#define DO_SORT
|
|
struct keyword *iskeyword(char *kw)
|
|
{
|
|
struct keyword *kwp;
|
|
struct keyword key;
|
|
key.keyword = kw;
|
|
key.needcase = 0;
|
|
#ifdef DO_SORT
|
|
{
|
|
/* Make sure that it is sorted for bsearsh */
|
|
static int sorted = 0;
|
|
if(!sorted)
|
|
{
|
|
qsort(keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
|
|
sorted = 1;
|
|
}
|
|
}
|
|
#endif
|
|
#ifdef KW_BSEARCH
|
|
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
|
|
#else
|
|
{
|
|
int i;
|
|
for(i = 0; i < NKEYWORDS; i++)
|
|
{
|
|
if(!kw_cmp_func(&key, &keywords[i]))
|
|
break;
|
|
}
|
|
if(i < NKEYWORDS)
|
|
kwp = &keywords[i];
|
|
else
|
|
kwp = NULL;
|
|
}
|
|
#endif
|
|
|
|
#ifdef LEX_DEBUG
|
|
if(kwp && !strcmp(kwp->keyword, "LANGUAGE"))
|
|
printf("Got Language\n");
|
|
#endif
|
|
if(kwp == NULL || (kwp->isextension && !extensions))
|
|
return NULL;
|
|
else
|
|
return kwp;
|
|
}
|
|
|
|
void add_to_substtext(char *text, int len)
|
|
{
|
|
if(!substtext)
|
|
{
|
|
substtext = xstrdup(text);
|
|
}
|
|
else
|
|
{
|
|
substtext = (char *)xrealloc(substtext, strlen(substtext)+len+1);
|
|
strcat(substtext, text);
|
|
}
|
|
}
|
|
|
|
%}
|
|
|
|
%%
|
|
/* #include handling */
|
|
^{ws}*#{ws}*include{ws}* push_to(pp_incl);
|
|
<pp_incl>\<[^\n\>]+\> do_include(yytext, yyleng); pop_start();
|
|
<pp_incl>\"[^\n\>]+\" do_include(yytext, yyleng); pop_start();
|
|
<pp_incl>. yyerror("Malformed #include");
|
|
|
|
/* #define handling */
|
|
^{ws}*#{ws}*define{ws}* push_to(pp_def);
|
|
<pp_def>{cident} {
|
|
set_define(yytext);
|
|
push_to(pp_def_s);
|
|
}
|
|
<pp_def>{cident}\( push_to(pp_ignore); /* Ignore function-like defines for now*/
|
|
<pp_def>. yyerror("Malformed #define");
|
|
|
|
<pp_ignore,pp_def_s>[^\/\\\n]* {
|
|
if(YY_START == pp_def_s)
|
|
add_to_substtext(yytext, yyleng);
|
|
}
|
|
<pp_ignore,pp_def_s>\/[^\/\*][^\/\\\n]* { /* Comment is handled in normal handling */
|
|
if(YY_START == pp_def_s)
|
|
add_to_substtext(yytext, yyleng);
|
|
}
|
|
<pp_ignore,pp_def_s>\\{ws}*\n line_number++; char_number = 1; /* Line continuation */
|
|
<pp_ignore,pp_def_s>\n {
|
|
if(YY_START == pp_def_s)
|
|
{
|
|
add_define(substtext ? substtext : "");
|
|
free(substtext);
|
|
substtext = NULL;
|
|
}
|
|
line_number++;
|
|
char_number = 1;
|
|
pop_start();
|
|
pop_start();
|
|
}
|
|
|
|
/* #undef handling */
|
|
^{ws}*#{ws}*undef{ws}* push_to(pp_undef);
|
|
<pp_undef>{cident} {
|
|
del_define(yytext);
|
|
pop_start();
|
|
/*push_to(pp_ignore);*/
|
|
}
|
|
|
|
/* Conditional handling */
|
|
<INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*if{ws}* {
|
|
if(YY_START == pp_false)
|
|
{
|
|
if(yydebug)
|
|
printf("(%d)#if ignored\n", line_number);
|
|
push_if(0, 0, 1);
|
|
push_to(pp_ignore_eol);
|
|
}
|
|
else
|
|
{
|
|
push_to(INITIAL);
|
|
want_nl = 1;
|
|
return tIF;
|
|
}
|
|
}
|
|
<INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*ifdef{ws}* {
|
|
if(YY_START == pp_false)
|
|
{
|
|
if(yydebug)
|
|
printf("(%d)#ifdef ignored\n", line_number);
|
|
push_if(0, 0, 1);
|
|
push_to(pp_ignore_eol);
|
|
}
|
|
else
|
|
{
|
|
push_to(INITIAL);
|
|
want_nl = 1;
|
|
want_ident = 1;
|
|
return tIFDEF;
|
|
}
|
|
}
|
|
<INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*ifndef{ws}* {
|
|
if(YY_START == pp_false)
|
|
{
|
|
if(yydebug)
|
|
printf("(%d)#ifndef ignored\n", line_number);
|
|
push_if(0, 0, 1);
|
|
push_to(pp_ignore_eol);
|
|
}
|
|
else
|
|
{
|
|
push_to(INITIAL);
|
|
want_nl = 1;
|
|
want_ident = 1;
|
|
return tIFNDEF;
|
|
}
|
|
}
|
|
<INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*elif{ws}* {
|
|
if(!isnevertrue_if())
|
|
{
|
|
push_to(INITIAL);
|
|
want_nl = 1;
|
|
return tELIF;
|
|
}
|
|
else if(YY_START == pp_false)
|
|
push_to(pp_ignore_eol);
|
|
if(yydebug)
|
|
printf("(%d)#elif ignored\n", line_number);
|
|
}
|
|
<INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*else{ws}* {
|
|
if(!isnevertrue_if())
|
|
{
|
|
push_to(INITIAL);
|
|
want_nl = 1;
|
|
return tELSE;
|
|
}
|
|
if(yydebug)
|
|
printf("(%d)#else ignored\n", line_number);
|
|
}
|
|
<INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*endif{ws}* {
|
|
if(!isnevertrue_if())
|
|
{
|
|
want_nl = 1;
|
|
return tENDIF;
|
|
}
|
|
else
|
|
{
|
|
if(yydebug)
|
|
printf("(%d)#endif ignored\n", line_number);
|
|
pop_if();
|
|
}
|
|
}
|
|
|
|
/* The error directive */
|
|
^{ws}*#{ws}*error{ws}* push_to(pp_error);
|
|
<pp_error>[^\n]* yyerror("Error directive: %s", yytext);
|
|
|
|
/* preprocessor junk */
|
|
^{ws}*#{ws}*pragma[^\n]* ; /* Ignore #pragma */
|
|
^{ws}*#{ws}*line[^\n]* ; /* Ignore #line */
|
|
/* We'll get an error on malformed #xxx statements
|
|
* by not recognising '#' at all. This helps tracking
|
|
* preprocessor errors.
|
|
*/
|
|
/*^{ws}*#{ws}* ; Ignore # */
|
|
|
|
<pp_strips>\{ stripslevel++;
|
|
<pp_strips>\} stripslevel--;
|
|
<pp_strips>; if(!stripslevel) pop_start();
|
|
<pp_strips>[^\{\};\n#]* ; /* Ignore rest */
|
|
|
|
<pp_stripp>\( stripplevel++;
|
|
<pp_stripp>\) {
|
|
stripplevel--;
|
|
if(!stripplevel)
|
|
{
|
|
pop_start();
|
|
push_to(pp_stripp_final);
|
|
}
|
|
}
|
|
<pp_stripp>[^\(\);\n#]* ; /* Ignore rest */
|
|
|
|
<pp_stripp_final>{ws}* ; /* Ignore */
|
|
<pp_stripp_final>; pop_start(); /* Kill the semicolon */
|
|
<pp_stripp_final>\n line_number++; char_number = 1; pop_start();
|
|
<pp_stripp_final>. yyless(0); pop_start();
|
|
|
|
<pp_false>. ; /* Ignore everything except #xxx during false #if state */
|
|
|
|
<pp_ignore_eol>[^\n]* pop_start();
|
|
|
|
/* These are special cases due to filename scanning */
|
|
<yywf>[Dd][Ii][Ss][Cc][Aa][Rr][Dd][Aa][Bb][Ll][Ee] return DISCARDABLE;
|
|
<yywf>[Ff][Ii][Xx][Ee][Dd] return tFIXED;
|
|
<yywf>[Ii][Mm][Pp][Uu][Rr][Ee] return IMPURE;
|
|
<yywf>[Mm][Oo][Vv][Ee][Aa][Bb][Ll][Ee] return MOVEABLE;
|
|
<yywf>[Ll][Oo][Aa][Dd][Oo][Nn][Cc][Aa][Ll][Ll] return LOADONCALL;
|
|
<yywf>[Pp][Rr][Ee][Ll][Oo][Aa][Dd] return PRELOAD;
|
|
<yywf>[Pp][Uu][Rr][Ee] return tPURE;
|
|
|
|
\{ return tBEGIN;
|
|
\} return tEND;
|
|
|
|
[0-9]+[lL]? { yylval.num = atoi(yytext); return NUMBER; }
|
|
0[xX][0-9A-Fa-f]+[lL]? { yylval.num = strtoul(yytext,0,16); return NUMBER; }
|
|
0[oO][0-7]+ { yylval.num = strtoul(yytext+2,0,8); return NUMBER; }
|
|
[A-Za-z_0-9]+ {
|
|
struct keyword *token;
|
|
struct pp_entry *ppp;
|
|
|
|
want_rscname = 0;
|
|
|
|
if(want_ident)
|
|
{
|
|
/* Prevent preprocessor subst */
|
|
want_ident = 0;
|
|
yylval.str = make_string(yytext);
|
|
#ifdef LEX_DEBUG
|
|
printf("want IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext);
|
|
#endif
|
|
return IDENT;
|
|
}
|
|
else if((ppp = pp_lookup(yytext)) != NULL)
|
|
{
|
|
/* Do preprocessor substitution,
|
|
* but expand only if macro is not
|
|
* already expanding.
|
|
*/
|
|
if(!ppp->expanding)
|
|
{
|
|
#ifdef LEX_DEBUG
|
|
printf("expand IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext);
|
|
#endif
|
|
push_buffer(YY_CURRENT_BUFFER, ppp, NULL);
|
|
yy_scan_string(ppp->subst);
|
|
}
|
|
}
|
|
else if((token = iskeyword(yytext)) != NULL
|
|
&& !(!token->alwayskeyword && want_rscname))
|
|
{
|
|
switch(token->token)
|
|
{
|
|
case tDEFINED:
|
|
want_ident = 1;
|
|
break;
|
|
/*case RCDATA:*/
|
|
case CURSOR:
|
|
case tBITMAP:
|
|
case MESSAGETABLE:
|
|
push_to(yywf);
|
|
break;
|
|
case FONT:
|
|
case ICON:
|
|
if(!indialog)
|
|
push_to(yywf);
|
|
break;
|
|
case DIALOG:
|
|
case DIALOGEX:
|
|
indialog = 1;
|
|
break;
|
|
}
|
|
return token->token;
|
|
}
|
|
else
|
|
{
|
|
yylval.str = make_string(yytext);
|
|
#ifdef LEX_DEBUG
|
|
printf("%s IDENT (%s, %d, %d): <%s>\n",
|
|
want_rscname ? "rscname" : "just",
|
|
input_name,
|
|
line_number,
|
|
char_number,
|
|
yytext);
|
|
#endif
|
|
return IDENT;
|
|
}
|
|
}
|
|
\|\| return LOGOR;
|
|
\&\& return LOGAND;
|
|
\=\= return EQ;
|
|
\!\= return NE;
|
|
\<\= return LTE;
|
|
\>\= return GTE;
|
|
|
|
<yywf>[^ \f\t\r\n\"]* { pop_start(); yylval.str = make_filename(yytext, yyleng); return FILENAME; }
|
|
<yywf>\" push_to(yywf_s);
|
|
<yywf_s>[^\"\n]*\" { pop_start(); pop_start(); yylval.str = make_filename(yytext, yyleng-1); return FILENAME; }
|
|
<yywf_s>\n yyerror("Newline in filename");
|
|
|
|
L\" {
|
|
push_to(yylstr);
|
|
wbufidx = 0;
|
|
if(!win32)
|
|
yywarning("16bit resource contains unicode strings\n");
|
|
}
|
|
<yylstr>\" {
|
|
pop_start();
|
|
yylval.str = get_buffered_wstring();
|
|
return tSTRING;
|
|
}
|
|
<yylstr>\n yyerror("Unterminated string");
|
|
<yylstr>\\[0-7]{1,6} { /* octal escape sequence */
|
|
int result;
|
|
result = strtol(yytext+1, 0, 8);
|
|
if ( result > 0xffff )
|
|
yyerror("Character constant out of range");
|
|
addwchar((short)result);
|
|
}
|
|
<yylstr>\\x[0-9a-fA-F]{4} { /* hex escape sequence */
|
|
int result;
|
|
result = strtol(yytext+2, 0, 16);
|
|
addwchar((short)result);
|
|
}
|
|
<yylstr>\\[0-9]+ yyerror("Bad escape secuence");
|
|
<yylstr>\\a addwchar('\a');
|
|
<yylstr>\\b addwchar('\b');
|
|
<yylstr>\\f addwchar('\f');
|
|
<yylstr>\\n addwchar('\n');
|
|
<yylstr>\\r addwchar('\r');
|
|
<yylstr>\\t addwchar('\t');
|
|
<yylstr>\\v addwchar('\v');
|
|
<yylstr>\\(.|\n) addwchar(yytext[1]);
|
|
<yylstr>[^\\\n\"]+ {
|
|
char *yptr = yytext;
|
|
while(*yptr) /* FIXME: codepage translation */
|
|
addwchar(*yptr++ & 0xff);
|
|
}
|
|
|
|
\" {
|
|
push_to(yystr);
|
|
cbufidx = 0;
|
|
}
|
|
<yystr>\" {
|
|
pop_start();
|
|
yylval.str = get_buffered_cstring();
|
|
return tSTRING;
|
|
}
|
|
<yystr>\n yyerror("Unterminated string");
|
|
<yystr>\\[0-7]{1,3} { /* octal escape sequence */
|
|
int result;
|
|
result = strtol(yytext+1, 0, 8);
|
|
if ( result > 0xff )
|
|
yyerror("Character constant out of range");
|
|
addcchar((char)result);
|
|
}
|
|
<yystr>\\x[0-9a-fA-F]{2} { /* hex escape sequence */
|
|
int result;
|
|
result = strtol(yytext+2, 0, 16);
|
|
addcchar((char)result);
|
|
}
|
|
<yystr>\\[0-9]+ yyerror("Bad escape secuence");
|
|
<yystr>\\a addcchar('\a');
|
|
<yystr>\\b addcchar('\b');
|
|
<yystr>\\f addcchar('\f');
|
|
<yystr>\\n addcchar('\n');
|
|
<yystr>\\r addcchar('\r');
|
|
<yystr>\\t addcchar('\t');
|
|
<yystr>\\v addcchar('\v');
|
|
<yystr>\\(.|\n) addcchar(yytext[1]);
|
|
<yystr>[^\\\n\"]+ {
|
|
char *yptr = yytext;
|
|
while(*yptr)
|
|
addcchar(*yptr++);
|
|
}
|
|
|
|
|
|
|
|
\' {
|
|
push_to(yyrcd);
|
|
cbufidx = 0;
|
|
}
|
|
<yyrcd>\' {
|
|
pop_start();
|
|
yylval.raw = new_raw_data();
|
|
yylval.raw->size = cbufidx;
|
|
yylval.raw->data = xmalloc(yylval.raw->size);
|
|
memcpy(yylval.raw->data, cbuffer, yylval.raw->size);
|
|
return RAWDATA;
|
|
}
|
|
<yyrcd>[0-9a-fA-F]{2} {
|
|
int result;
|
|
result = strtol(yytext, 0, 16);
|
|
addcchar((char)result);
|
|
}
|
|
<yyrcd>{ws}+ ; /* Ignore space */
|
|
<yyrcd>. yyerror("Malformed data-line");
|
|
|
|
<INITIAL,pp_ignore,pp_def_s>"/*" push_to(comment); /* Eat comment */
|
|
<comment>[^*\n]* ;
|
|
<comment>"*"+[^*/\n]* ;
|
|
<comment>\n line_number++; char_number = 1;
|
|
<comment>"*"+"/" pop_start();
|
|
|
|
;[^\n]* ; /* Eat comment */
|
|
<INITIAL,pp_ignore,pp_def_s>"//"[^\n]* ; /* Eat comment */
|
|
|
|
<INITIAL,yywf,pp_false,pp_strips,pp_stripp>\n {
|
|
if(YY_START == yywf)
|
|
pop_start();
|
|
line_number++;
|
|
char_number = 1;
|
|
if(want_nl)
|
|
{
|
|
want_nl = 0;
|
|
return tNL;
|
|
}
|
|
}
|
|
<INITIAL,yywf>{ws}+ ; /* Eat whitespace */
|
|
|
|
<INITIAL>. return yytext[0];
|
|
<<EOF>> {
|
|
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
|
|
if(!pop_buffer())
|
|
if(YY_START == pp_strips || YY_START == pp_stripp || YY_START == pp_stripp_final)
|
|
yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline);
|
|
else
|
|
yyterminate();
|
|
yy_delete_buffer(b);
|
|
}
|
|
%%
|
|
|
|
#ifndef yywrap
|
|
int yywrap(void)
|
|
{
|
|
// if(bufferstackidx > 0)
|
|
// {
|
|
// return 0;
|
|
// }
|
|
return 1;
|
|
}
|
|
#endif
|
|
|
|
/* These dup functions copy the enclosed '\0' from
|
|
* the resource string.
|
|
*/
|
|
void addcchar(char c)
|
|
{
|
|
if(cbufidx >= sizeof(cbuffer))
|
|
internal_error(__FILE__, __LINE__, "Character buffer overflow");
|
|
cbuffer[cbufidx++] = c;
|
|
}
|
|
|
|
void addwchar(short s)
|
|
{
|
|
if(wbufidx >= sizeof(wbuffer))
|
|
internal_error(__FILE__, __LINE__, "Wide character buffer overflow");
|
|
wbuffer[wbufidx++] = (short)(s & 0xff);
|
|
}
|
|
|
|
string_t *get_buffered_cstring(void)
|
|
{
|
|
string_t *str = new_string();
|
|
str->size = cbufidx;
|
|
str->type = str_char;
|
|
str->str.cstr = (char *)xmalloc(cbufidx+1);
|
|
memcpy(str->str.cstr, cbuffer, cbufidx);
|
|
str->str.cstr[cbufidx] = '\0';
|
|
/* printf("got cstring \"%s\"\n", str->str.cstr); */
|
|
return str;
|
|
}
|
|
|
|
string_t *get_buffered_wstring(void)
|
|
{
|
|
string_t *str = new_string();
|
|
str->size = wbufidx;
|
|
str->type = str_unicode;
|
|
str->str.wstr = (short *)xmalloc(2*(wbufidx+1));
|
|
memcpy(str->str.wstr, wbuffer, wbufidx);
|
|
str->str.wstr[wbufidx] = 0;
|
|
return str;
|
|
}
|
|
|
|
string_t *make_string(char *s)
|
|
{
|
|
string_t *str = new_string();
|
|
str->size = strlen(s);
|
|
str->type = str_char;
|
|
str->str.cstr = (char *)xmalloc(str->size+1);
|
|
memcpy(str->str.cstr, s, str->size+1);
|
|
return str;
|
|
}
|
|
|
|
string_t *make_filename(char *s, int len)
|
|
{
|
|
char *cptr;
|
|
string_t *str = new_string();
|
|
|
|
str->size = len;
|
|
str->type = str_char;
|
|
str->str.cstr = (char *)xmalloc(str->size+1);
|
|
memcpy(str->str.cstr, s, str->size);
|
|
str->str.cstr[str->size] = '\0';
|
|
|
|
/* Remove escaped backslash and convert to forward */
|
|
cptr = str->str.cstr;
|
|
for(cptr = str->str.cstr; (cptr = strchr(cptr, '\\')) != NULL; cptr++)
|
|
{
|
|
if(cptr[1] == '\\')
|
|
{
|
|
memmove(cptr, cptr+1, strlen(cptr));
|
|
str->size--;
|
|
}
|
|
*cptr = '/';
|
|
}
|
|
|
|
/* Convert to lower case. Seems to be reasonable to do */
|
|
for(cptr = str->str.cstr; !leave_case && *cptr; cptr++)
|
|
{
|
|
*cptr = tolower(*cptr);
|
|
}
|
|
return str;
|
|
}
|
|
|
|
/* Called from the parser to signal filename request */
|
|
void set_yywf(void)
|
|
{
|
|
push_to(yywf);
|
|
}
|
|
|
|
/* Called from the parser to signal preprocessor if case */
|
|
void set_pp_ignore(int state)
|
|
{
|
|
if(state)
|
|
push_to(pp_false);
|
|
else
|
|
pop_start();
|
|
}
|
|
|
|
/* Called from the parser to kill c-junk */
|
|
void strip_til_semicolon(void)
|
|
{
|
|
cjunk_tagline = line_number;
|
|
push_to(pp_strips);
|
|
}
|
|
|
|
void strip_til_parenthesis(void)
|
|
{
|
|
cjunk_tagline = line_number;
|
|
stripplevel = 1; /* One scanned already */
|
|
push_to(pp_stripp);
|
|
}
|
|
|
|
|