3 * Copyright 1994 Martin von Loewis
4 * Copyright 1998 Bertho A. Stultiens (BS)
6 * 20-Jun-1998 BS - Changed the filename conversion. Filenames are
7 * case-sensitive inder *nix, but not under dos.
8 * default behaviour is to convert to lower case.
9 * - All backslashes are converted to forward and
10 * both single and double slash is recognized as
12 * - Fixed a bug in 'yywf' case that prevented
13 * double quoted names to be scanned propperly.
15 * 19-May-1998 BS - Started to build a preprocessor.
16 * - Changed keyword processing completely to
19 * 20-Apr-1998 BS - Added ';' comment stripping
21 * 17-Apr-1998 BS - Made the win32 keywords optional when compiling in
24 * 15-Apr-1998 BS - Changed string handling to include escapes
25 * - Added unicode string handling (no codepage
26 * translation though).
27 * - 'Borrowed' the main idea of string scanning from
28 * the flex manual pages.
29 * - Added conditional handling of scanning depending
30 * on the state of the parser. This was mainly required
31 * to distinguish a file to load or raw data that
32 * follows. MS's definition of filenames is rather
33 * complex... It can be unquoted or double quoted. If
34 * double quoted, then the '\\' char is not automatically
35 * escaped according to Borland's rc compiler, but it
36 * accepts both "\\path\\file.rc" and "\path\file.rc".
37 * This makes life very hard! I go for the escaped
38 * version, as this seems to be the documented way...
39 * - Single quoted strings are now parsed and converted
41 * - Added comment stripping. The implementation is
42 * 'borrowed' from the flex manpages.
43 * - Rebuild string processing so that it may contain
47 /* Exclusive rules when looking for a filename */
50 /* Exclusive string handling */
52 /* Exclusive unicode string handling */
54 /* Exclusive rcdata single quoted data handling */
56 /* Exclusive comment eating... */
58 /* Preprocessor exclusives */
69 /* Set when accumulating #define's expansion text */
71 /* Set when processing function type defines */
73 /* Set when need to strip to eol */
75 /* Set when handling a false #if case */
77 /* Set when stripping c-junk */
83 %option never-interactive
85 /* Some shortcut definitions */
87 cident [a-zA-Z_][0-9a-zA-Z_]*
91 #if !defined(YY_FLEX_MAJOR_VERSION) || (1000 * YY_FLEX_MAJOR_VERSION + YY_FLEX_MINOR_VERSION < 2005)
92 #error Must use flex version 2.5.1 or higher (yy_scan_* routines are required).
107 #include "newstruc.h"
111 #define YY_USE_PROTOS
114 /* Always update the current character position within a line */
115 #define YY_USER_ACTION char_number+=yyleng;
117 raw_data_t *new_raw_data(void);
119 void addcchar(char c);
120 void addwchar(short s);
121 string_t *get_buffered_cstring(void);
122 string_t *get_buffered_wstring(void);
123 string_t *make_string(char *s);
124 string_t *make_filename(char *s, int len);
126 int line_number = 1; /* The current line */
127 int char_number = 1; /* The current char pos within the line */
128 static char cbuffer[1024]; /* Buffers for string collection */
130 static short wbuffer[1024];
132 static int want_nl = 0; /* Set when newline needs to go to parser */
133 static int want_ident = 0; /* Set is #ifdef, #ifndef or defined is seen */
134 static int stripslevel = 0; /* Count {} during pp_strips mode */
135 static int stripplevel = 0; /* Count () during pp_strips mode */
136 static char *substtext = NULL; /* Holds the substition text while getting a define */
137 static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */
140 void push_to(int start) { yy_push_state(start); }
141 void pop_start(void) { yy_pop_state(start); }
143 #define MAXSTARTSTACK 32
144 static int startstack[MAXSTARTSTACK];
145 static int startstackidx = 0;
147 void push_to(int start)
150 printf("push_to(%d): %d -> %d\n", line_number, YY_START, start);
151 if(startstackidx >= MAXSTARTSTACK-1)
152 internal_error(__FILE__, __LINE__, "Start condition stack overflow");
153 startstack[startstackidx++] = YY_START;
160 printf("pop_start(%d): %d <- %d\n", line_number, startstack[startstackidx-1], YY_START);
161 if(startstackidx <= 0)
162 internal_error(__FILE__, __LINE__, "Start condition stack underflow");
164 BEGIN(startstack[startstackidx]);
169 struct bufferstackentry {
170 YY_BUFFER_STATE bufferstate; /* Buffer to switch back to */
171 struct pp_entry *define; /* Points to expanding define
172 or NULL if handling includes
174 int line_number; /* Line that we were handling */
175 int char_number; /* The current position */
176 char *filename; /* Filename that we were handling */
179 #define MAXBUFFERSTACK 128
180 static struct bufferstackentry bufferstack[MAXBUFFERSTACK];
181 static int bufferstackidx = 0;
183 void push_buffer(YY_BUFFER_STATE buf, struct pp_entry *ppp, char *filename)
186 printf("push_buffer: %p %p %p\n", buf, ppp, filename);
187 if(bufferstackidx >= MAXBUFFERSTACK-1)
188 internal_error(__FILE__, __LINE__, "Buffer stack overflow");
189 memset(&bufferstack[bufferstackidx], 0, sizeof(bufferstack[0]));
190 bufferstack[bufferstackidx].bufferstate = buf;
191 bufferstack[bufferstackidx].define = ppp;
196 /* These will track the yyerror to the correct file and line */
197 bufferstack[bufferstackidx].line_number = line_number;
198 bufferstack[bufferstackidx].char_number = char_number;
201 bufferstack[bufferstackidx].filename = input_name;
202 input_name = filename;
205 internal_error(__FILE__, __LINE__, "Pushing buffer without knowing where to go to");
209 YY_BUFFER_STATE pop_buffer(void)
211 if(bufferstackidx <= 0)
212 return (YY_BUFFER_STATE)0;
214 if(bufferstack[bufferstackidx].define)
215 bufferstack[bufferstackidx].define->expanding = 0;
218 line_number = bufferstack[bufferstackidx].line_number;
219 char_number = bufferstack[bufferstackidx].char_number;
220 input_name = bufferstack[bufferstackidx].filename;
224 printf("pop_buffer: %p %p (%d, %d) %p\n",
225 bufferstack[bufferstackidx].bufferstate,
226 bufferstack[bufferstackidx].define,
227 bufferstack[bufferstackidx].line_number,
228 bufferstack[bufferstackidx].char_number,
229 bufferstack[bufferstackidx].filename);
230 yy_switch_to_buffer(bufferstack[bufferstackidx].bufferstate);
231 return bufferstack[bufferstackidx].bufferstate;
234 void do_include(char *name, int namelen)
236 char *cpy = (char *)xmalloc(namelen);
237 strcpy(cpy, name+1); /* strip leading " or < */
238 cpy[namelen-2] = '\0'; /* strip trailing " or > */
239 if((yyin = open_include(cpy, name[0] == '"')) == NULL)
240 yyerror("Unable to open include file %s", cpy);
241 push_buffer(YY_CURRENT_BUFFER, NULL, cpy);
242 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
254 static struct keyword keywords[] = {
255 { "ACCELERATORS", ACCELERATORS, 0, 0, 0},
256 { "ALT", ALT, 0, 0, 0},
257 { "ASCII", ASCII, 0, 0, 0},
258 { "AUTO3STATE", AUTO3STATE, 1, 0, 0},
259 { "AUTOCHECKBOX", AUTOCHECKBOX, 1, 0, 0},
260 { "AUTORADIOBUTTON", AUTORADIOBUTTON, 1, 0, 0},
261 { "BEGIN", tBEGIN, 0, 0, 1},
262 { "BITMAP", tBITMAP, 0, 0, 0},
263 { "BLOCK", BLOCK, 0, 0, 1},
264 { "CAPTION", CAPTION, 0, 0, 0},
265 { "CHARACTERISTICS", CHARACTERISTICS, 1, 0, 0},
266 { "CHECKBOX", CHECKBOX, 0, 0, 0},
267 { "CHECKED", CHECKED, 0, 0, 0},
268 { "CLASS", CLASS, 0, 0, 0},
269 { "COMBOBOX", COMBOBOX, 0, 0, 0},
270 { "CONTROL", CONTROL, 0, 0, 0},
271 { "CTEXT", CTEXT, 0, 0, 0},
272 { "CURSOR", CURSOR, 0, 0, 0},
273 { "defined", tDEFINED, 0, 1, 1},
274 { "DEFPUSHBUTTON", DEFPUSHBUTTON, 0, 0, 1},
275 { "DIALOG", DIALOG, 0, 0, 0},
276 { "DIALOGEX", DIALOGEX, 1, 0, 0},
277 { "DISCARDABLE", DISCARDABLE, 0, 0, 0},
278 { "EDITTEXT", EDITTEXT, 0, 0, 0},
279 { "END", tEND, 0, 0, 1},
280 { "EXSTYLE", EXSTYLE, 0, 0, 0},
281 { "extern", tEXTERN, 0, 1, 1},
282 { "FILEFLAGS", FILEFLAGS, 0, 0, 0},
283 { "FILEFLAGSMASK", FILEFLAGSMASK, 0, 0, 0},
284 { "FILEOS", FILEOS, 0, 0, 0},
285 { "FILESUBTYPE", FILESUBTYPE, 0, 0, 0},
286 { "FILETYPE", FILETYPE, 0, 0, 0},
287 { "FILEVERSION", FILEVERSION, 0, 0, 0},
288 { "FIXED", tFIXED, 0, 0, 0},
289 { "FONT", FONT, 0, 0, 0},
290 { "GRAYED", GRAYED, 0, 0, 0},
291 { "GROUPBOX", GROUPBOX, 0, 0, 0},
292 { "HELP", HELP, 0, 0, 0},
293 { "ICON", ICON, 0, 0, 0},
294 { "IMPURE", IMPURE, 0, 0, 0},
295 { "INACTIVE", INACTIVE, 0, 0, 0},
296 { "LANGUAGE", LANGUAGE, 1, 0, 1},
297 { "LISTBOX", LISTBOX, 0, 0, 0},
298 { "LOADONCALL", LOADONCALL, 0, 0, 0},
299 { "LTEXT", LTEXT, 0, 0, 0},
300 { "MENU", MENU, 0, 0, 0},
301 { "MENUBARBREAK", MENUBARBREAK, 0, 0, 0},
302 { "MENUBREAK", MENUBREAK, 0, 0, 0},
303 { "MENUEX", MENUEX, 1, 0, 0},
304 { "MENUITEM", MENUITEM, 0, 0, 0},
305 { "MESSAGETABLE", MESSAGETABLE, 1, 0, 0},
306 { "MOVEABLE", MOVEABLE, 0, 0, 0},
307 { "NOINVERT", NOINVERT, 0, 0, 0},
308 { "NOT", NOT, 0, 0, 0},
309 { "POPUP", POPUP, 0, 0, 0},
310 { "PRELOAD", PRELOAD, 0, 0, 0},
311 { "PRODUCTVERSION", PRODUCTVERSION, 0, 0, 0},
312 { "PURE", tPURE, 0, 0, 0},
313 { "PUSHBUTTON", PUSHBUTTON, 0, 0, 0},
314 { "RADIOBUTTON", RADIOBUTTON, 0, 0, 0},
315 { "RCDATA", RCDATA, 0, 0, 0},
316 { "RTEXT", RTEXT, 0, 0, 0},
317 { "SCROLLBAR", SCROLLBAR, 0, 0, 0},
318 { "SEPARATOR", SEPARATOR, 0, 0, 0},
319 { "SHIFT", SHIFT, 0, 0, 0},
320 { "STATE3", STATE3, 1, 0, 0},
321 { "STRING", tSTRING, 0, 0, 0},
322 { "STRINGTABLE", STRINGTABLE, 0, 0, 1},
323 { "STYLE", STYLE, 0, 0, 0},
324 { "typedef", tTYPEDEF, 0, 1, 1},
325 { "VALUE", VALUE, 0, 0, 0},
326 { "VERSION", VERSION, 1, 0, 0},
327 { "VERSIONINFO", VERSIONINFO, 0, 0, 0},
328 { "VIRTKEY", VIRTKEY, 0, 0, 0}
331 #define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
332 #define KWP(p) ((struct keyword *)(p))
333 int kw_cmp_func(const void *s1, const void *s2)
336 ret = stricmp(KWP(s1)->keyword, KWP(s2)->keyword);
337 if(!ret && (KWP(s1)->needcase || KWP(s2)->needcase))
338 return strcmp(KWP(s1)->keyword, KWP(s2)->keyword);
345 struct keyword *iskeyword(char *kw)
353 /* Make sure that it is sorted for bsearsh */
354 static int sorted = 0;
357 qsort(keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
363 kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
367 for(i = 0; i < NKEYWORDS; i++)
369 if(!kw_cmp_func(&key, &keywords[i]))
380 if(kwp && !strcmp(kwp->keyword, "LANGUAGE"))
381 printf("Got Language\n");
383 if(kwp == NULL || (kwp->isextension && !extensions))
389 void add_to_substtext(char *text, int len)
393 substtext = xstrdup(text);
397 substtext = (char *)xrealloc(substtext, strlen(substtext)+len+1);
398 strcat(substtext, text);
405 /* #include handling */
406 ^{ws}*#{ws}*include{ws}* push_to(pp_incl);
407 <pp_incl>\<[^\n\>]+\> do_include(yytext, yyleng); pop_start();
408 <pp_incl>\"[^\n\>]+\" do_include(yytext, yyleng); pop_start();
409 <pp_incl>. yyerror("Malformed #include");
411 /* #define handling */
412 ^{ws}*#{ws}*define{ws}* push_to(pp_def);
417 <pp_def>{cident}\( push_to(pp_ignore); /* Ignore function-like defines for now*/
418 <pp_def>. yyerror("Malformed #define");
420 <pp_ignore,pp_def_s>[^\/\\\n]* {
421 if(YY_START == pp_def_s)
422 add_to_substtext(yytext, yyleng);
424 <pp_ignore,pp_def_s>\/[^\/\*][^\/\\\n]* { /* Comment is handled in normal handling */
425 if(YY_START == pp_def_s)
426 add_to_substtext(yytext, yyleng);
428 <pp_ignore,pp_def_s>\\{ws}*\n line_number++; char_number = 1; /* Line continuation */
429 <pp_ignore,pp_def_s>\n {
430 if(YY_START == pp_def_s)
432 add_define(substtext ? substtext : "");
442 /* #undef handling */
443 ^{ws}*#{ws}*undef{ws}* push_to(pp_undef);
447 /*push_to(pp_ignore);*/
450 /* Conditional handling */
451 <INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*if{ws}* {
452 if(YY_START == pp_false)
455 printf("(%d)#if ignored\n", line_number);
457 push_to(pp_ignore_eol);
466 <INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*ifdef{ws}* {
467 if(YY_START == pp_false)
470 printf("(%d)#ifdef ignored\n", line_number);
472 push_to(pp_ignore_eol);
482 <INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*ifndef{ws}* {
483 if(YY_START == pp_false)
486 printf("(%d)#ifndef ignored\n", line_number);
488 push_to(pp_ignore_eol);
498 <INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*elif{ws}* {
499 if(!isnevertrue_if())
505 else if(YY_START == pp_false)
506 push_to(pp_ignore_eol);
508 printf("(%d)#elif ignored\n", line_number);
510 <INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*else{ws}* {
511 if(!isnevertrue_if())
518 printf("(%d)#else ignored\n", line_number);
520 <INITIAL,pp_strips,pp_stripp,pp_false>^{ws}*#{ws}*endif{ws}* {
521 if(!isnevertrue_if())
529 printf("(%d)#endif ignored\n", line_number);
534 /* The error directive */
535 ^{ws}*#{ws}*error{ws}* push_to(pp_error);
536 <pp_error>[^\n]* yyerror("Error directive: %s", yytext);
538 /* preprocessor junk */
539 ^{ws}*#{ws}*pragma[^\n]* ; /* Ignore #pragma */
540 ^{ws}*#{ws}*line[^\n]* ; /* Ignore #line */
541 /* We'll get an error on malformed #xxx statements
542 * by not recognising '#' at all. This helps tracking
543 * preprocessor errors.
545 /*^{ws}*#{ws}* ; Ignore # */
547 <pp_strips>\{ stripslevel++;
548 <pp_strips>\} stripslevel--;
549 <pp_strips>; if(!stripslevel) pop_start();
550 <pp_strips>[^\{\};\n#]* ; /* Ignore rest */
552 <pp_stripp>\( stripplevel++;
558 push_to(pp_stripp_final);
561 <pp_stripp>[^\(\);\n#]* ; /* Ignore rest */
563 <pp_stripp_final>{ws}* ; /* Ignore */
564 <pp_stripp_final>; pop_start(); /* Kill the semicolon */
565 <pp_stripp_final>\n line_number++; char_number = 1; pop_start();
566 <pp_stripp_final>. yyless(0); pop_start();
568 <pp_false>. ; /* Ignore everything except #xxx during false #if state */
570 <pp_ignore_eol>[^\n]* pop_start();
572 /* These are special cases due to filename scanning */
573 <yywf>[Dd][Ii][Ss][Cc][Aa][Rr][Dd][Aa][Bb][Ll][Ee] return DISCARDABLE;
574 <yywf>[Ff][Ii][Xx][Ee][Dd] return tFIXED;
575 <yywf>[Ii][Mm][Pp][Uu][Rr][Ee] return IMPURE;
576 <yywf>[Mm][Oo][Vv][Ee][Aa][Bb][Ll][Ee] return MOVEABLE;
577 <yywf>[Ll][Oo][Aa][Dd][Oo][Nn][Cc][Aa][Ll][Ll] return LOADONCALL;
578 <yywf>[Pp][Rr][Ee][Ll][Oo][Aa][Dd] return PRELOAD;
579 <yywf>[Pp][Uu][Rr][Ee] return tPURE;
584 [0-9]+[lL]? { yylval.num = atoi(yytext); return NUMBER; }
585 0[xX][0-9A-Fa-f]+[lL]? { yylval.num = strtoul(yytext,0,16); return NUMBER; }
586 0[oO][0-7]+ { yylval.num = strtoul(yytext+2,0,8); return NUMBER; }
588 struct keyword *token;
589 struct pp_entry *ppp;
595 /* Prevent preprocessor subst */
597 yylval.str = make_string(yytext);
599 printf("want IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext);
603 else if((ppp = pp_lookup(yytext)) != NULL)
605 /* Do preprocessor substitution,
606 * but expand only if macro is not
612 printf("expand IDENT (%s, %d, %d): <%s>\n", input_name, line_number, char_number, yytext);
614 push_buffer(YY_CURRENT_BUFFER, ppp, NULL);
615 yy_scan_string(ppp->subst);
618 else if((token = iskeyword(yytext)) != NULL
619 && !(!token->alwayskeyword && want_rscname))
646 yylval.str = make_string(yytext);
648 printf("%s IDENT (%s, %d, %d): <%s>\n",
649 want_rscname ? "rscname" : "just",
665 <yywf>[^ \f\t\r\n\"]* { pop_start(); yylval.str = make_filename(yytext, yyleng); return FILENAME; }
666 <yywf>\" push_to(yywf_s);
667 <yywf_s>[^\"\n]*\" { pop_start(); pop_start(); yylval.str = make_filename(yytext, yyleng-1); return FILENAME; }
668 <yywf_s>\n yyerror("Newline in filename");
674 yywarning("16bit resource contains unicode strings\n");
678 yylval.str = get_buffered_wstring();
681 <yylstr>\n yyerror("Unterminated string");
682 <yylstr>\\[0-7]{1,6} { /* octal escape sequence */
684 result = strtol(yytext+1, 0, 8);
685 if ( result > 0xffff )
686 yyerror("Character constant out of range");
687 addwchar((short)result);
689 <yylstr>\\x[0-9a-fA-F]{4} { /* hex escape sequence */
691 result = strtol(yytext+2, 0, 16);
692 addwchar((short)result);
694 <yylstr>\\[0-9]+ yyerror("Bad escape secuence");
695 <yylstr>\\a addwchar('\a');
696 <yylstr>\\b addwchar('\b');
697 <yylstr>\\f addwchar('\f');
698 <yylstr>\\n addwchar('\n');
699 <yylstr>\\r addwchar('\r');
700 <yylstr>\\t addwchar('\t');
701 <yylstr>\\v addwchar('\v');
702 <yylstr>\\(.|\n) addwchar(yytext[1]);
705 while(*yptr) /* FIXME: codepage translation */
706 addwchar(*yptr++ & 0xff);
715 yylval.str = get_buffered_cstring();
718 <yystr>\n yyerror("Unterminated string");
719 <yystr>\\[0-7]{1,3} { /* octal escape sequence */
721 result = strtol(yytext+1, 0, 8);
723 yyerror("Character constant out of range");
724 addcchar((char)result);
726 <yystr>\\x[0-9a-fA-F]{2} { /* hex escape sequence */
728 result = strtol(yytext+2, 0, 16);
729 addcchar((char)result);
731 <yystr>\\[0-9]+ yyerror("Bad escape secuence");
732 <yystr>\\a addcchar('\a');
733 <yystr>\\b addcchar('\b');
734 <yystr>\\f addcchar('\f');
735 <yystr>\\n addcchar('\n');
736 <yystr>\\r addcchar('\r');
737 <yystr>\\t addcchar('\t');
738 <yystr>\\v addcchar('\v');
739 <yystr>\\(.|\n) addcchar(yytext[1]);
754 yylval.raw = new_raw_data();
755 yylval.raw->size = cbufidx;
756 yylval.raw->data = xmalloc(yylval.raw->size);
757 memcpy(yylval.raw->data, cbuffer, yylval.raw->size);
760 <yyrcd>[0-9a-fA-F]{2} {
762 result = strtol(yytext, 0, 16);
763 addcchar((char)result);
765 <yyrcd>{ws}+ ; /* Ignore space */
766 <yyrcd>. yyerror("Malformed data-line");
768 <INITIAL,pp_ignore,pp_def_s>"/*" push_to(comment); /* Eat comment */
770 <comment>"*"+[^*/\n]* ;
771 <comment>\n line_number++; char_number = 1;
772 <comment>"*"+"/" pop_start();
774 ;[^\n]* ; /* Eat comment */
775 <INITIAL,pp_ignore,pp_def_s>"//"[^\n]* ; /* Eat comment */
777 <INITIAL,yywf,pp_false,pp_strips,pp_stripp>\n {
788 <INITIAL,yywf>{ws}+ ; /* Eat whitespace */
790 <INITIAL>. return yytext[0];
792 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
794 if(YY_START == pp_strips || YY_START == pp_stripp || YY_START == pp_stripp_final)
795 yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline);
805 // if(bufferstackidx > 0)
813 /* These dup functions copy the enclosed '\0' from
814 * the resource string.
816 void addcchar(char c)
818 if(cbufidx >= sizeof(cbuffer))
819 internal_error(__FILE__, __LINE__, "Character buffer overflow");
820 cbuffer[cbufidx++] = c;
823 void addwchar(short s)
825 if(wbufidx >= sizeof(wbuffer))
826 internal_error(__FILE__, __LINE__, "Wide character buffer overflow");
827 wbuffer[wbufidx++] = (short)(s & 0xff);
830 string_t *get_buffered_cstring(void)
832 string_t *str = new_string();
834 str->type = str_char;
835 str->str.cstr = (char *)xmalloc(cbufidx+1);
836 memcpy(str->str.cstr, cbuffer, cbufidx);
837 str->str.cstr[cbufidx] = '\0';
838 /* printf("got cstring \"%s\"\n", str->str.cstr); */
842 string_t *get_buffered_wstring(void)
844 string_t *str = new_string();
846 str->type = str_unicode;
847 str->str.wstr = (short *)xmalloc(2*(wbufidx+1));
848 memcpy(str->str.wstr, wbuffer, wbufidx);
849 str->str.wstr[wbufidx] = 0;
853 string_t *make_string(char *s)
855 string_t *str = new_string();
856 str->size = strlen(s);
857 str->type = str_char;
858 str->str.cstr = (char *)xmalloc(str->size+1);
859 memcpy(str->str.cstr, s, str->size+1);
863 string_t *make_filename(char *s, int len)
866 string_t *str = new_string();
869 str->type = str_char;
870 str->str.cstr = (char *)xmalloc(str->size+1);
871 memcpy(str->str.cstr, s, str->size);
872 str->str.cstr[str->size] = '\0';
874 /* Remove escaped backslash and convert to forward */
875 cptr = str->str.cstr;
876 for(cptr = str->str.cstr; (cptr = strchr(cptr, '\\')) != NULL; cptr++)
880 memmove(cptr, cptr+1, strlen(cptr));
886 /* Convert to lower case. Seems to be reasonable to do */
887 for(cptr = str->str.cstr; !leave_case && *cptr; cptr++)
889 *cptr = tolower(*cptr);
894 /* Called from the parser to signal filename request */
900 /* Called from the parser to signal preprocessor if case */
901 void set_pp_ignore(int state)
909 /* Called from the parser to kill c-junk */
910 void strip_til_semicolon(void)
912 cjunk_tagline = line_number;
916 void strip_til_parenthesis(void)
918 cjunk_tagline = line_number;
919 stripplevel = 1; /* One scanned already */