- Update WPP and fix the resulting bugs because wpp_find_include has changed.

- Add notes to wpp.mak about how to build lex.yy.c, ppy.tab.c and ppy.tab.h manually.

svn path=/trunk/; revision=26822
This commit is contained in:
Eric Kohl 2007-05-17 14:47:37 +00:00
parent 0935620f31
commit 15242938e7
16 changed files with 1906 additions and 1723 deletions

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_WPP_H
@ -29,7 +29,7 @@ extern void wpp_add_cmdline_define( const char *value );
extern void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug );
extern void wpp_set_pedantic( int on );
extern void wpp_add_include_path( const char *path );
char *wpp_find_include( const char *name, const char *parent_name, int type );
extern char *wpp_find_include( const char *name, const char *parent_name );
extern int wpp_parse( const char *input, FILE *output );
extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name );

View file

@ -1,5 +1,14 @@
ChangeLog
2007-05-17 ekohl
tools/widl/lex.yy.c
tools/widl/parser.l
tools/widl/typelib.c
- Update wpp and fix the wpp_find_include issue!
2006-07-30 ekohl
- Synchronized with WINE widl 20060729.

View file

@ -5052,7 +5052,7 @@ int do_import(char *fname)
import->next = first_import;
first_import = import;
if (!(path = wpp_find_include( fname, input_name, 1 )))
if (!(path = wpp_find_include( fname, input_name )))
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;

View file

@ -413,7 +413,7 @@ int do_import(char *fname)
import->next = first_import;
first_import = import;
if (!(path = wpp_find_include( fname, input_name, 1 )))
if (!(path = wpp_find_include( fname, input_name )))
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;

View file

@ -370,7 +370,7 @@ static void read_importlib(importlib_t *importlib)
INT magic;
char *file_name;
file_name = wpp_find_include(importlib->name, NULL, 1);
file_name = wpp_find_include(importlib->name, NULL);
if(file_name) {
fd = open(file_name, O_RDONLY);
free(file_name);

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* History:
* 24-Apr-2000 BS - Started from scratch to restructure everything
@ -38,8 +38,6 @@
* | {ws} # {ws} endif {ws} \n
* | {ws} # {ws} include {ws} < {anytext} > \n
* | {ws} # {ws} include {ws} " {anytext} " \n
* | {ws} # {ws} include_next {ws} < {anytext} > \n
* | {ws} # {ws} include_next {ws} " {anytext} " \n
* | {ws} # {ws} define {ws} {anytext} \n
* | {ws} # {ws} define( {arglist} ) {ws} {expansion} \n
* | {ws} # {ws} pragma {ws} {anytext} \n
@ -129,7 +127,7 @@
%option stack
%option 8bit never-interactive
%option nounput
%option prefix="pp"
%option prefix="ppy_"
%x pp_pp
%x pp_eol
@ -158,6 +156,7 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
%{
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -182,7 +181,7 @@ ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
/*
* Always update the current character position within a line
*/
#define YY_USER_ACTION pp_status.char_number+=ppleng;
#define YY_USER_ACTION pp_status.char_number+=ppy_leng;
/*
* Buffer management for includes and expansions
@ -315,7 +314,6 @@ includelogicentry_t *pp_includelogiclist = NULL;
* Scan for the preprocessor directives
*/
<pp_pp>{ws}*include{ws}* if(yy_top_state() != pp_ignore) {yy_pp_state(pp_inc); return tINCLUDE;} else {yy_pp_state(pp_eol);}
<pp_pp>{ws}*include_next{ws}* if(yy_top_state() != pp_ignore) {yy_pp_state(pp_inc); return tINCLUDE_NEXT;} else {yy_pp_state(pp_eol);}
<pp_pp>{ws}*define{ws}* yy_pp_state(yy_current_state() != pp_ignore ? pp_def : pp_eol);
<pp_pp>{ws}*error{ws}* yy_pp_state(pp_eol); if(yy_top_state() != pp_ignore) return tERROR;
<pp_pp>{ws}*warning{ws}* yy_pp_state(pp_eol); if(yy_top_state() != pp_ignore) return tWARNING;
@ -330,22 +328,22 @@ includelogicentry_t *pp_includelogiclist = NULL;
<pp_pp>{ws}*endif{ws}* yy_pp_state(pp_endif); return tENDIF;
<pp_pp>{ws}*line{ws}* if(yy_top_state() != pp_ignore) {yy_pp_state(pp_line); return tLINE;} else {yy_pp_state(pp_eol);}
<pp_pp>{ws}+ if(yy_top_state() != pp_ignore) {yy_pp_state(pp_line); return tGCCLINE;} else {yy_pp_state(pp_eol);}
<pp_pp>{ws}*[a-z]+ pperror("Invalid preprocessor token '%s'", pptext);
<pp_pp>{ws}*[a-z]+ ppy_error("Invalid preprocessor token '%s'", ppy_text);
<pp_pp>\r?\n newline(1); yy_pop_state(); return tNL; /* This could be the null-token */
<pp_pp>\\\r?\n newline(0);
<pp_pp>\\\r? pperror("Preprocessor junk '%s'", pptext);
<pp_pp>. return *pptext;
<pp_pp>\\\r? ppy_error("Preprocessor junk '%s'", ppy_text);
<pp_pp>. return *ppy_text;
/*
* Handle #include and #line
*/
<pp_line>[0-9]+ return make_number(10, &pplval, pptext, ppleng);
<pp_inc>\< new_string(); add_string(pptext, ppleng); yy_push_state(pp_iqs);
<pp_inc,pp_line>\" new_string(); add_string(pptext, ppleng); yy_push_state(pp_dqs);
<pp_line>[0-9]+ return make_number(10, &ppy_lval, ppy_text, ppy_leng);
<pp_inc>\< new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_iqs);
<pp_inc,pp_line>\" new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs);
<pp_inc,pp_line>{ws}+ ;
<pp_inc,pp_line>\n newline(1); yy_pop_state(); return tNL;
<pp_inc,pp_line>\\\r?\n newline(0);
<pp_inc,pp_line>(\\\r?)|(.) pperror(yy_current_state() == pp_inc ? "Trailing junk in #include" : "Trailing junk in #line");
<pp_inc,pp_line>(\\\r?)|(.) ppy_error(yy_current_state() == pp_inc ? "Trailing junk in #include" : "Trailing junk in #line");
/*
* Ignore all input when a false clause is parsed
@ -362,11 +360,11 @@ includelogicentry_t *pp_includelogiclist = NULL;
* Note: tIDENT is handled below.
*/
<pp_if>0[0-7]*{ul}? return make_number(8, &pplval, pptext, ppleng);
<pp_if>0[0-7]*[8-9]+{ul}? pperror("Invalid octal digit");
<pp_if>[1-9][0-9]*{ul}? return make_number(10, &pplval, pptext, ppleng);
<pp_if>0[xX][0-9a-fA-F]+{ul}? return make_number(16, &pplval, pptext, ppleng);
<pp_if>0[xX] pperror("Invalid hex number");
<pp_if>0[0-7]*{ul}? return make_number(8, &ppy_lval, ppy_text, ppy_leng);
<pp_if>0[0-7]*[8-9]+{ul}? ppy_error("Invalid octal digit");
<pp_if>[1-9][0-9]*{ul}? return make_number(10, &ppy_lval, ppy_text, ppy_leng);
<pp_if>0[xX][0-9a-fA-F]+{ul}? return make_number(16, &ppy_lval, ppy_text, ppy_leng);
<pp_if>0[xX] ppy_error("Invalid hex number");
<pp_if>defined yy_push_state(pp_defined); return tDEFINED;
<pp_if>"<<" return tLSHIFT;
<pp_if>">>" return tRSHIFT;
@ -378,21 +376,21 @@ includelogicentry_t *pp_includelogiclist = NULL;
<pp_if>">=" return tGTE;
<pp_if>\n newline(1); yy_pop_state(); return tNL;
<pp_if>\\\r?\n newline(0);
<pp_if>\\\r? pperror("Junk in conditional expression");
<pp_if>\\\r? ppy_error("Junk in conditional expression");
<pp_if>{ws}+ ;
<pp_if>\' new_string(); add_string(pptext, ppleng); yy_push_state(pp_sqs);
<pp_if>\" pperror("String constants not allowed in conditionals");
<pp_if>. return *pptext;
<pp_if>\' new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs);
<pp_if>\" ppy_error("String constants not allowed in conditionals");
<pp_if>. return *ppy_text;
/*
* Handle #ifdef, #ifndef and #undef
* to get only an untranslated/unexpanded identifier
*/
<pp_ifd>{cident} pplval.cptr = pp_xstrdup(pptext); return tIDENT;
<pp_ifd>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); return tIDENT;
<pp_ifd>{ws}+ ;
<pp_ifd>\n newline(1); yy_pop_state(); return tNL;
<pp_ifd>\\\r?\n newline(0);
<pp_ifd>(\\\r?)|(.) pperror("Identifier expected");
<pp_ifd>(\\\r?)|(.) ppy_error("Identifier expected");
/*
* Handle #else and #endif.
@ -400,18 +398,18 @@ includelogicentry_t *pp_includelogiclist = NULL;
<pp_endif>{ws}+ ;
<pp_endif>\n newline(1); yy_pop_state(); return tNL;
<pp_endif>\\\r?\n newline(0);
<pp_endif>. pperror("Garbage after #else or #endif.");
<pp_endif>. ppy_error("Garbage after #else or #endif.");
/*
* Handle the special 'defined' keyword.
* This is necessary to get the identifier prior to any
* substitutions.
*/
<pp_defined>{cident} yy_pop_state(); pplval.cptr = pp_xstrdup(pptext); return tIDENT;
<pp_defined>{cident} yy_pop_state(); ppy_lval.cptr = pp_xstrdup(ppy_text); return tIDENT;
<pp_defined>{ws}+ ;
<pp_defined>(\()|(\)) return *pptext;
<pp_defined>(\()|(\)) return *ppy_text;
<pp_defined>\\\r?\n newline(0);
<pp_defined>(\\.)|(\n)|(.) pperror("Identifier expected");
<pp_defined>(\\.)|(\n)|(.) ppy_error("Identifier expected");
/*
* Handle #error, #warning, #pragma and #ident.
@ -419,17 +417,17 @@ includelogicentry_t *pp_includelogiclist = NULL;
* will act appropriately.
* Comments are stripped from the literal text.
*/
<pp_eol>[^/\\\n]+ if(yy_top_state() != pp_ignore) { pplval.cptr = pp_xstrdup(pptext); return tLITERAL; }
<pp_eol>\/[^/\\\n*]* if(yy_top_state() != pp_ignore) { pplval.cptr = pp_xstrdup(pptext); return tLITERAL; }
<pp_eol>(\\\r?)|(\/[^/*]) if(yy_top_state() != pp_ignore) { pplval.cptr = pp_xstrdup(pptext); return tLITERAL; }
<pp_eol>[^/\\\n]+ if(yy_top_state() != pp_ignore) { ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL; }
<pp_eol>\/[^/\\\n*]* if(yy_top_state() != pp_ignore) { ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL; }
<pp_eol>(\\\r?)|(\/[^/*]) if(yy_top_state() != pp_ignore) { ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL; }
<pp_eol>\n newline(1); yy_pop_state(); if(yy_current_state() != pp_ignore) { return tNL; }
<pp_eol>\\\r?\n newline(0);
/*
* Handle left side of #define
*/
<pp_def>{cident}\( pplval.cptr = pp_xstrdup(pptext); pplval.cptr[ppleng-1] = '\0'; yy_pp_state(pp_macro); return tMACRO;
<pp_def>{cident} pplval.cptr = pp_xstrdup(pptext); yy_pp_state(pp_define); return tDEFINE;
<pp_def>{cident}\( ppy_lval.cptr = pp_xstrdup(ppy_text); ppy_lval.cptr[ppy_leng-1] = '\0'; yy_pp_state(pp_macro); return tMACRO;
<pp_def>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); yy_pp_state(pp_define); return tDEFINE;
<pp_def>{ws}+ ;
<pp_def>\\\r?\n newline(0);
<pp_def>(\\\r?)|(\n)|(.) perror("Identifier expected");
@ -437,39 +435,39 @@ includelogicentry_t *pp_includelogiclist = NULL;
/*
* Scan the substitution of a define
*/
<pp_define>[^'"/\\\n]+ pplval.cptr = pp_xstrdup(pptext); return tLITERAL;
<pp_define>(\\\r?)|(\/[^/*]) pplval.cptr = pp_xstrdup(pptext); return tLITERAL;
<pp_define>\\\r?\n{ws}+ newline(0); pplval.cptr = pp_xstrdup(" "); return tLITERAL;
<pp_define>[^'"/\\\n]+ ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
<pp_define>(\\\r?)|(\/[^/*]) ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
<pp_define>\\\r?\n{ws}+ newline(0); ppy_lval.cptr = pp_xstrdup(" "); return tLITERAL;
<pp_define>\\\r?\n newline(0);
<pp_define>\n newline(1); yy_pop_state(); return tNL;
<pp_define>\' new_string(); add_string(pptext, ppleng); yy_push_state(pp_sqs);
<pp_define>\" new_string(); add_string(pptext, ppleng); yy_push_state(pp_dqs);
<pp_define>\' new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs);
<pp_define>\" new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs);
/*
* Scan the definition macro arguments
*/
<pp_macro>\){ws}* yy_pp_state(pp_mbody); return tMACROEND;
<pp_macro>{ws}+ ;
<pp_macro>{cident} pplval.cptr = pp_xstrdup(pptext); return tIDENT;
<pp_macro>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); return tIDENT;
<pp_macro>, return ',';
<pp_macro>"..." return tELIPSIS;
<pp_macro>(\\\r?)|(\n)|(.)|(\.\.?) pperror("Argument identifier expected");
<pp_macro>(\\\r?)|(\n)|(.)|(\.\.?) ppy_error("Argument identifier expected");
<pp_macro>\\\r?\n newline(0);
/*
* Scan the substitution of a macro
*/
<pp_mbody>[^a-zA-Z0-9'"#/\\\n]+ pplval.cptr = pp_xstrdup(pptext); return tLITERAL;
<pp_mbody>{cident} pplval.cptr = pp_xstrdup(pptext); return tIDENT;
<pp_mbody>[^a-zA-Z0-9'"#/\\\n]+ ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
<pp_mbody>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); return tIDENT;
<pp_mbody>\#\# return tCONCAT;
<pp_mbody>\# return tSTRINGIZE;
<pp_mbody>[0-9][^'"#/\\\n]* pplval.cptr = pp_xstrdup(pptext); return tLITERAL;
<pp_mbody>(\\\r?)|(\/[^/*'"#\\\n]*) pplval.cptr = pp_xstrdup(pptext); return tLITERAL;
<pp_mbody>\\\r?\n{ws}+ newline(0); pplval.cptr = pp_xstrdup(" "); return tLITERAL;
<pp_mbody>[0-9][^'"#/\\\n]* ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
<pp_mbody>(\\\r?)|(\/[^/*'"#\\\n]*) ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
<pp_mbody>\\\r?\n{ws}+ newline(0); ppy_lval.cptr = pp_xstrdup(" "); return tLITERAL;
<pp_mbody>\\\r?\n newline(0);
<pp_mbody>\n newline(1); yy_pop_state(); return tNL;
<pp_mbody>\' new_string(); add_string(pptext, ppleng); yy_push_state(pp_sqs);
<pp_mbody>\" new_string(); add_string(pptext, ppleng); yy_push_state(pp_dqs);
<pp_mbody>\' new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs);
<pp_mbody>\" new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs);
/*
* Macro expansion text scanning.
@ -490,7 +488,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
macexpstackentry_t *mac = pop_macro();
yy_pop_state();
put_buffer(mac->ppp->ident, strlen(mac->ppp->ident));
put_buffer(pptext, ppleng);
put_buffer(ppy_text, ppy_leng);
free_macro(mac);
}
@ -500,7 +498,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
*/
<pp_macscan>\( {
if(++MACROPARENTHESES() > 1)
add_text_to_macro(pptext, ppleng);
add_text_to_macro(ppy_text, ppy_leng);
}
<pp_macscan>\) {
if(--MACROPARENTHESES() == 0)
@ -509,19 +507,19 @@ includelogicentry_t *pp_includelogiclist = NULL;
macro_add_arg(1);
}
else
add_text_to_macro(pptext, ppleng);
add_text_to_macro(ppy_text, ppy_leng);
}
<pp_macscan>, {
if(MACROPARENTHESES() > 1)
add_text_to_macro(pptext, ppleng);
add_text_to_macro(ppy_text, ppy_leng);
else
macro_add_arg(0);
}
<pp_macscan>\" new_string(); add_string(pptext, ppleng); yy_push_state(pp_dqs);
<pp_macscan>\' new_string(); add_string(pptext, ppleng); yy_push_state(pp_sqs);
<pp_macscan>\" new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs);
<pp_macscan>\' new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs);
<pp_macscan>"/*" yy_push_state(pp_comment); add_text_to_macro(" ", 1);
<pp_macscan>\n pp_status.line_number++; pp_status.char_number = 1; add_text_to_macro(pptext, ppleng);
<pp_macscan>([^/(),\\\n"']+)|(\/[^/*(),\\\n'"]*)|(\\\r?)|(.) add_text_to_macro(pptext, ppleng);
<pp_macscan>\n pp_status.line_number++; pp_status.char_number = 1; add_text_to_macro(ppy_text, ppy_leng);
<pp_macscan>([^/(),\\\n"']+)|(\/[^/*(),\\\n'"]*)|(\\\r?)|(.) add_text_to_macro(ppy_text, ppy_leng);
<pp_macscan>\\\r?\n newline(0);
/*
@ -536,18 +534,18 @@ includelogicentry_t *pp_includelogiclist = NULL;
* Remove C++ style comment (almost all start-conditions)
*/
<INITIAL,pp_pp,pp_ignore,pp_eol,pp_inc,pp_if,pp_ifd,pp_endif,pp_defined,pp_def,pp_define,pp_macro,pp_mbody,pp_macscan,RCINCL>"//"[^\n]* {
if(pptext[ppleng-1] == '\\')
ppwarning("C++ style comment ends with an escaped newline (escape ignored)");
if(ppy_text[ppy_leng-1] == '\\')
ppy_warning("C++ style comment ends with an escaped newline (escape ignored)");
}
/*
* Single, double and <> quoted constants
*/
<INITIAL,pp_macexp>\" pp_incl_state.seen_junk++; new_string(); add_string(pptext, ppleng); yy_push_state(pp_dqs);
<INITIAL,pp_macexp>\' pp_incl_state.seen_junk++; new_string(); add_string(pptext, ppleng); yy_push_state(pp_sqs);
<pp_dqs>[^"\\\n]+ add_string(pptext, ppleng);
<INITIAL,pp_macexp>\" pp_incl_state.seen_junk++; new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs);
<INITIAL,pp_macexp>\' pp_incl_state.seen_junk++; new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs);
<pp_dqs>[^"\\\n]+ add_string(ppy_text, ppy_leng);
<pp_dqs>\" {
add_string(pptext, ppleng);
add_string(ppy_text, ppy_leng);
yy_pop_state();
switch(yy_current_state())
{
@ -557,37 +555,37 @@ includelogicentry_t *pp_includelogiclist = NULL;
case pp_inc:
case RCINCL:
if (yy_current_state()==RCINCL) yy_pop_state();
pplval.cptr = get_string();
ppy_lval.cptr = get_string();
return tDQSTRING;
case pp_line:
pplval.cptr = get_string();
if (is_c_h_include(pplval.cptr, 1)) pass_data=0;
ppy_lval.cptr = get_string();
if (is_c_h_include(ppy_lval.cptr, 1)) pass_data=0;
else pass_data=1;
return tDQSTRING;
default:
put_string();
}
}
<pp_sqs>[^'\\\n]+ add_string(pptext, ppleng);
<pp_sqs>[^'\\\n]+ add_string(ppy_text, ppy_leng);
<pp_sqs>\' {
add_string(pptext, ppleng);
add_string(ppy_text, ppy_leng);
yy_pop_state();
switch(yy_current_state())
{
case pp_if:
case pp_define:
case pp_mbody:
pplval.cptr = get_string();
ppy_lval.cptr = get_string();
return tSQSTRING;
default:
put_string();
}
}
<pp_iqs>[^\>\\\n]+ add_string(pptext, ppleng);
<pp_iqs>[^\>\\\n]+ add_string(ppy_text, ppy_leng);
<pp_iqs>\> {
add_string(pptext, ppleng);
add_string(ppy_text, ppy_leng);
yy_pop_state();
pplval.cptr = get_string();
ppy_lval.cptr = get_string();
return tIQSTRING;
}
<pp_dqs>\\\r?\n {
@ -610,15 +608,15 @@ includelogicentry_t *pp_includelogiclist = NULL;
newline(0);
break;
default:
add_string(pptext, ppleng);
add_string(ppy_text, ppy_leng);
newline(-1);
}
}
<pp_iqs,pp_dqs,pp_sqs>\\. add_string(pptext, ppleng);
<pp_iqs,pp_dqs,pp_sqs>\\. add_string(ppy_text, ppy_leng);
<pp_iqs,pp_dqs,pp_sqs>\n {
newline(1);
add_string(pptext, ppleng);
ppwarning("Newline in string constant encounterd (started line %d)", string_start());
add_string(ppy_text, ppy_leng);
ppy_warning("Newline in string constant encounterd (started line %d)", string_start());
}
/*
@ -627,22 +625,22 @@ includelogicentry_t *pp_includelogiclist = NULL;
<INITIAL,pp_if,pp_inc,pp_macexp>{cident} {
pp_entry_t *ppp;
pp_incl_state.seen_junk++;
if(!(ppp = pplookup(pptext)))
if(!(ppp = pplookup(ppy_text)))
{
if(yy_current_state() == pp_inc)
pperror("Expected include filename");
ppy_error("Expected include filename");
if(yy_current_state() == pp_if)
{
pplval.cptr = pp_xstrdup(pptext);
ppy_lval.cptr = pp_xstrdup(ppy_text);
return tIDENT;
}
else {
if((yy_current_state()==INITIAL) && (strcasecmp(pptext,"RCINCLUDE")==0)){
if((yy_current_state()==INITIAL) && (strcasecmp(ppy_text,"RCINCLUDE")==0)){
yy_push_state(RCINCL);
return tRCINCLUDE;
}
else put_buffer(pptext, ppleng);
else put_buffer(ppy_text, ppy_leng);
}
}
else if(!ppp->expanding)
@ -663,26 +661,27 @@ includelogicentry_t *pp_includelogiclist = NULL;
pp_internal_error(__FILE__, __LINE__, "Invalid define type %d\n", ppp->type);
}
}
else put_buffer(ppy_text, ppy_leng);
}
/*
* Everything else that needs to be passed and
* newline and continuation handling
*/
<INITIAL,pp_macexp>[^a-zA-Z_#'"/\\\n \r\t\f\v]+|(\/|\\)[^a-zA-Z_/*'"\\\n \r\t\v\f]* pp_incl_state.seen_junk++; put_buffer(pptext, ppleng);
<INITIAL,pp_macexp>{ws}+ put_buffer(pptext, ppleng);
<INITIAL,pp_macexp>[^a-zA-Z_#'"/\\\n \r\t\f\v]+|(\/|\\)[^a-zA-Z_/*'"\\\n \r\t\v\f]* pp_incl_state.seen_junk++; put_buffer(ppy_text, ppy_leng);
<INITIAL,pp_macexp>{ws}+ put_buffer(ppy_text, ppy_leng);
<INITIAL>\n newline(1);
<INITIAL>\\\r?\n newline(0);
<INITIAL>\\\r? pp_incl_state.seen_junk++; put_buffer(pptext, ppleng);
<INITIAL>\\\r? pp_incl_state.seen_junk++; put_buffer(ppy_text, ppy_leng);
/*
* Special catcher for macro argmument expansion to prevent
* newlines to propagate to the output or admin.
*/
<pp_macexp>(\n)|(.)|(\\\r?(\n|.)) put_buffer(pptext, ppleng);
<pp_macexp>(\n)|(.)|(\\\r?(\n|.)) put_buffer(ppy_text, ppy_leng);
<RCINCL>[A-Za-z0-9_\.\\/]+ {
pplval.cptr=pp_xstrdup(pptext);
ppy_lval.cptr=pp_xstrdup(ppy_text);
yy_pop_state();
return tRCINCLUDEPATH;
}
@ -690,26 +689,26 @@ includelogicentry_t *pp_includelogiclist = NULL;
<RCINCL>{ws}+ ;
<RCINCL>\" {
new_string(); add_string(pptext,ppleng);yy_push_state(pp_dqs);
new_string(); add_string(ppy_text,ppy_leng);yy_push_state(pp_dqs);
}
/*
* This is a 'catch-all' rule to discover errors in the scanner
* in an orderly manner.
*/
<*>. pp_incl_state.seen_junk++; ppwarning("Unmatched text '%c' (0x%02x); please report\n", isprint(*pptext & 0xff) ? *pptext : ' ', *pptext);
<*>. pp_incl_state.seen_junk++; ppy_warning("Unmatched text '%c' (0x%02x); please report\n", isprint(*ppy_text & 0xff) ? *ppy_text : ' ', *ppy_text);
<<EOF>> {
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
bufferstackentry_t *bep = pop_buffer();
if((!bep && pp_get_if_depth()) || (bep && pp_get_if_depth() != bep->if_depth))
ppwarning("Unmatched #if/#endif at end of file");
ppy_warning("Unmatched #if/#endif at end of file");
if(!bep)
{
if(YY_START != INITIAL)
pperror("Unexpected end of file during preprocessing");
ppy_error("Unexpected end of file during preprocessing");
yyterminate();
}
else if(bep->should_pop == 2)
@ -718,7 +717,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
mac = pop_macro();
expand_macro(mac);
}
pp_delete_buffer(b);
ppy__delete_buffer(b);
}
%%
@ -728,8 +727,8 @@ includelogicentry_t *pp_includelogiclist = NULL;
**************************************************************************
*/
#ifndef ppwrap
int ppwrap(void)
#ifndef ppy_wrap
int ppy_wrap(void)
{
return 1;
}
@ -799,7 +798,7 @@ static int make_number(int radix, YYSTYPE *val, const char *str, int len)
ext[0] = len > 2 ? toupper(str[len-3]) : ' ';
if(!strcmp(ext, "LUL"))
pperror("Invalid constant suffix");
ppy_error("Invalid constant suffix");
else if(!strcmp(ext, "LLU") || !strcmp(ext, "ULL"))
{
is_ll++;
@ -824,9 +823,24 @@ static int make_number(int radix, YYSTYPE *val, const char *str, int len)
}
if(is_ll)
pp_internal_error(__FILE__, __LINE__, "long long constants not implemented yet");
if(is_u && is_l)
{
/* Assume as in the declaration of wrc_ull_t and wrc_sll_t */
#ifdef HAVE_LONG_LONG
if (is_u)
{
val->ull = strtoull(str, NULL, radix);
return tULONGLONG;
}
else
{
val->sll = strtoll(str, NULL, radix);
return tSLONGLONG;
}
#else
pp_internal_error(__FILE__, __LINE__, "long long constants not supported on this platform");
#endif
}
else if(is_u && is_l)
{
val->ulong = strtoul(str, NULL, radix);
return tULONG;
@ -923,7 +937,7 @@ static void add_text(const char *str, int len)
curdef_alloc += (len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1);
curdef_text = pp_xrealloc(curdef_text, curdef_alloc * sizeof(curdef_text[0]));
if(curdef_alloc > 65536)
ppwarning("Reallocating macro-expansion buffer larger than 64kB");
ppy_warning("Reallocating macro-expansion buffer larger than 64kB");
}
memcpy(&curdef_text[curdef_idx], str, len);
curdef_idx += len;
@ -1039,7 +1053,7 @@ static void expand_macro(macexpstackentry_t *mep)
assert(ppp->expanding == 0);
if((ppp->nargs >= 0 && nargs != ppp->nargs) || (ppp->nargs < 0 && nargs < -ppp->nargs))
pperror("Too %s macro arguments (%d)", nargs < abs(ppp->nargs) ? "few" : "many", nargs);
ppy_error("Too %s macro arguments (%d)", nargs < abs(ppp->nargs) ? "few" : "many", nargs);
for(n = 0; n < nargs; n++)
nnl += mep->nnls[n];
@ -1108,7 +1122,7 @@ static void new_string(void)
{
#ifdef DEBUG
if(strbuf_idx)
ppwarning("new_string: strbuf_idx != 0");
ppy_warning("new_string: strbuf_idx != 0");
#endif
strbuf_idx = 0;
str_startline = pp_status.line_number;
@ -1123,7 +1137,7 @@ static void add_string(const char *str, int len)
strbuf_alloc += (len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1);
strbuffer = pp_xrealloc(strbuffer, strbuf_alloc * sizeof(strbuffer[0]));
if(strbuf_alloc > 65536)
ppwarning("Reallocating string buffer larger than 64kB");
ppy_warning("Reallocating string buffer larger than 64kB");
}
memcpy(&strbuffer[strbuf_idx], str, len);
strbuf_idx += len;
@ -1161,7 +1175,7 @@ static int string_start(void)
*/
static void push_buffer(pp_entry_t *ppp, char *filename, char *incname, int pop)
{
if(ppdebug)
if(ppy_debug)
printf("push_buffer(%d): %p %p %p %d\n", bufferstackidx, ppp, filename, incname, pop);
if(bufferstackidx >= MAXBUFFERSTACK)
pp_internal_error(__FILE__, __LINE__, "Buffer stack overflow");
@ -1183,7 +1197,7 @@ static void push_buffer(pp_entry_t *ppp, char *filename, char *incname, int pop)
ppp->expanding = 1;
else if(filename)
{
/* These will track the pperror to the correct file and line */
/* These will track the ppy_error to the correct file and line */
pp_status.line_number = 1;
pp_status.char_number = 1;
pp_status.input = filename;
@ -1214,8 +1228,8 @@ static bufferstackentry_t *pop_buffer(void)
ncontinuations = bufferstack[bufferstackidx].ncontinuations;
if(!bufferstack[bufferstackidx].should_pop)
{
fclose(ppin);
fprintf(ppout, "# %d \"%s\" 2\n", pp_status.line_number, pp_status.input);
fclose(ppy_in);
fprintf(ppy_out, "# %d \"%s\" 2\n", pp_status.line_number, pp_status.input);
/* We have EOF, check the include logic */
if(pp_incl_state.state == 2 && !pp_incl_state.seen_junk && pp_incl_state.ppp)
@ -1235,18 +1249,17 @@ static bufferstackentry_t *pop_buffer(void)
if(pp_status.debug)
fprintf(stderr, "pop_buffer: %s:%d: includelogic added, include_ppp='%s', file='%s'\n", pp_status.input, pp_status.line_number, pp_incl_state.ppp, iep->filename);
}
else if(bufferstack[bufferstackidx].include_filename)
else
free(bufferstack[bufferstackidx].include_filename);
}
if(pp_incl_state.ppp)
free(pp_incl_state.ppp);
free(pp_incl_state.ppp);
pp_incl_state = bufferstack[bufferstackidx].incl;
pass_data = bufferstack[bufferstackidx].pass_data;
}
}
if(ppdebug)
if(ppy_debug)
printf("pop_buffer(%d): %p %p (%d, %d, %d) %p %d\n",
bufferstackidx,
bufferstack[bufferstackidx].bufferstate,
@ -1257,7 +1270,7 @@ static bufferstackentry_t *pop_buffer(void)
bufferstack[bufferstackidx].filename,
bufferstack[bufferstackidx].should_pop);
pp_switch_to_buffer(bufferstack[bufferstackidx].bufferstate);
ppy__switch_to_buffer(bufferstack[bufferstackidx].bufferstate);
if(bufferstack[bufferstackidx].should_pop)
{
@ -1280,7 +1293,7 @@ static bufferstackentry_t *pop_buffer(void)
static void push_macro(pp_entry_t *ppp)
{
if(macexpstackidx >= MAXMACEXPSTACK)
pperror("Too many nested macros");
ppy_error("Too many nested macros");
macexpstack[macexpstackidx] = pp_xmalloc(sizeof(macexpstack[0][0]));
memset( macexpstack[macexpstackidx], 0, sizeof(macexpstack[0][0]));
@ -1306,12 +1319,9 @@ static void free_macro(macexpstackentry_t *mep)
for(i = 0; i < mep->nargs; i++)
free(mep->args[i]);
if(mep->args)
free(mep->args);
if(mep->nnls)
free(mep->nnls);
if(mep->curarg)
free(mep->curarg);
free(mep->args);
free(mep->nnls);
free(mep->curarg);
free(mep);
}
@ -1402,7 +1412,7 @@ static void put_buffer(const char *s, int len)
add_text_to_macro(s, len);
else {
if(pass_data)
fwrite(s, 1, len, ppout);
fwrite(s, 1, len, ppy_out);
}
}
@ -1443,13 +1453,13 @@ void pp_do_include(char *fname, int type)
n = strlen(fname);
if(n <= 2)
pperror("Empty include filename");
ppy_error("Empty include filename");
/* Undo the effect of the quotation */
fname[n-1] = '\0';
if((ppin = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath, type)) == NULL)
pperror("Unable to open include file %s", fname+1);
if((ppy_in = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
ppy_error("Unable to open include file %s", fname+1);
fname[n-1] = *fname; /* Redo the quotes */
push_buffer(NULL, newpath, fname, 0);
@ -1462,9 +1472,9 @@ void pp_do_include(char *fname, int type)
if(pp_status.debug)
fprintf(stderr, "pp_do_include: %s:%d: include_state=%d, include_ppp='%s', include_ifdepth=%d ,pass_data=%d\n",
pp_status.input, pp_status.line_number, pp_incl_state.state, pp_incl_state.ppp, pp_incl_state.ifdepth, pass_data);
pp_switch_to_buffer(pp_create_buffer(ppin, YY_BUF_SIZE));
ppy__switch_to_buffer(ppy__create_buffer(ppy_in, YY_BUF_SIZE));
fprintf(ppout, "# 1 \"%s\" 1%s\n", newpath, type ? "" : " 3");
fprintf(ppy_out, "# 1 \"%s\" 1%s\n", newpath, type ? "" : " 3");
}
/*

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/* A Bison parser, made by GNU Bison 1.875b. */
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@ -39,42 +39,42 @@
tDEFINED = 265,
tNL = 266,
tINCLUDE = 267,
tINCLUDE_NEXT = 268,
tLINE = 269,
tGCCLINE = 270,
tERROR = 271,
tWARNING = 272,
tPRAGMA = 273,
tPPIDENT = 274,
tUNDEF = 275,
tMACROEND = 276,
tCONCAT = 277,
tELIPSIS = 278,
tSTRINGIZE = 279,
tIDENT = 280,
tLITERAL = 281,
tMACRO = 282,
tDEFINE = 283,
tDQSTRING = 284,
tSQSTRING = 285,
tIQSTRING = 286,
tUINT = 287,
tSINT = 288,
tULONG = 289,
tSLONG = 290,
tULONGLONG = 291,
tSLONGLONG = 292,
tRCINCLUDEPATH = 293,
tLOGOR = 294,
tLOGAND = 295,
tNE = 296,
tEQ = 297,
tGTE = 298,
tLTE = 299,
tRSHIFT = 300,
tLSHIFT = 301
tLINE = 268,
tGCCLINE = 269,
tERROR = 270,
tWARNING = 271,
tPRAGMA = 272,
tPPIDENT = 273,
tUNDEF = 274,
tMACROEND = 275,
tCONCAT = 276,
tELIPSIS = 277,
tSTRINGIZE = 278,
tIDENT = 279,
tLITERAL = 280,
tMACRO = 281,
tDEFINE = 282,
tDQSTRING = 283,
tSQSTRING = 284,
tIQSTRING = 285,
tUINT = 286,
tSINT = 287,
tULONG = 288,
tSLONG = 289,
tULONGLONG = 290,
tSLONGLONG = 291,
tRCINCLUDEPATH = 292,
tLOGOR = 293,
tLOGAND = 294,
tNE = 295,
tEQ = 296,
tGTE = 297,
tLTE = 298,
tRSHIFT = 299,
tLSHIFT = 300
};
#endif
/* Tokens. */
#define tRCINCLUDE 258
#define tIF 259
#define tIFDEF 260
@ -85,46 +85,45 @@
#define tDEFINED 265
#define tNL 266
#define tINCLUDE 267
#define tINCLUDE_NEXT 268
#define tLINE 269
#define tGCCLINE 270
#define tERROR 271
#define tWARNING 272
#define tPRAGMA 273
#define tPPIDENT 274
#define tUNDEF 275
#define tMACROEND 276
#define tCONCAT 277
#define tELIPSIS 278
#define tSTRINGIZE 279
#define tIDENT 280
#define tLITERAL 281
#define tMACRO 282
#define tDEFINE 283
#define tDQSTRING 284
#define tSQSTRING 285
#define tIQSTRING 286
#define tUINT 287
#define tSINT 288
#define tULONG 289
#define tSLONG 290
#define tULONGLONG 291
#define tSLONGLONG 292
#define tRCINCLUDEPATH 293
#define tLOGOR 294
#define tLOGAND 295
#define tNE 296
#define tEQ 297
#define tGTE 298
#define tLTE 299
#define tRSHIFT 300
#define tLSHIFT 301
#define tLINE 268
#define tGCCLINE 269
#define tERROR 270
#define tWARNING 271
#define tPRAGMA 272
#define tPPIDENT 273
#define tUNDEF 274
#define tMACROEND 275
#define tCONCAT 276
#define tELIPSIS 277
#define tSTRINGIZE 278
#define tIDENT 279
#define tLITERAL 280
#define tMACRO 281
#define tDEFINE 282
#define tDQSTRING 283
#define tSQSTRING 284
#define tIQSTRING 285
#define tUINT 286
#define tSINT 287
#define tULONG 288
#define tSLONG 289
#define tULONGLONG 290
#define tSLONGLONG 291
#define tRCINCLUDEPATH 292
#define tLOGOR 293
#define tLOGAND 294
#define tNE 295
#define tEQ 296
#define tGTE 297
#define tLTE 298
#define tRSHIFT 299
#define tLSHIFT 300
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 126 "wpp/ppy.y"
#line 126 "tools\\wpp_new\\ppy.y"
typedef union YYSTYPE {
int sint;
unsigned int uint;
@ -138,14 +137,14 @@ typedef union YYSTYPE {
marg_t *marg;
mtext_t *mtext;
} YYSTYPE;
/* Line 1252 of yacc.c. */
#line 143 "wpp/ppy.tab.h"
/* Line 1447 of yacc.c. */
#line 142 "tools\\wpp_new\\ppy.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE pplval;
extern YYSTYPE ppy_lval;

View file

@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* History:
* 24-Apr-2000 BS Restructured the lot to fit the new scanner
@ -29,6 +29,7 @@
%{
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
@ -138,7 +139,7 @@ static int nmacro_args;
%token tRCINCLUDE
%token tIF tIFDEF tIFNDEF tELSE tELIF tENDIF tDEFINED tNL
%token tINCLUDE tINCLUDE_NEXT tLINE tGCCLINE tERROR tWARNING tPRAGMA tPPIDENT
%token tINCLUDE tLINE tGCCLINE tERROR tWARNING tPRAGMA tPPIDENT
%token tUNDEF tMACROEND tCONCAT tELIPSIS tSTRINGIZE
%token <cptr> tIDENT tLITERAL tMACRO tDEFINE
%token <cptr> tDQSTRING tSQSTRING tIQSTRING
@ -182,10 +183,8 @@ pp_file : /* Empty */
;
preprocessor
: tINCLUDE tDQSTRING tNL { pp_do_include($2, LOCAL_INCLUDE); }
| tINCLUDE tIQSTRING tNL { pp_do_include($2, GLOBAL_INCLUDE); }
| tINCLUDE_NEXT tDQSTRING tNL { pp_do_include($2, INCLUDE_NEXT); }
| tINCLUDE_NEXT tIQSTRING tNL { pp_do_include($2, INCLUDE_NEXT); }
: tINCLUDE tDQSTRING tNL { pp_do_include($2, 1); }
| tINCLUDE tIQSTRING tNL { pp_do_include($2, 0); }
| tIF pp_expr tNL { pp_next_if_state(boolean(&$2)); }
| tIFDEF tIDENT tNL { pp_next_if_state(pplookup($2) != NULL); free($2); }
| tIFNDEF tIDENT tNL {
@ -224,7 +223,7 @@ preprocessor
break;
case if_elsetrue:
case if_elsefalse:
pperror("#elif cannot follow #else");
ppy_error("#elif cannot follow #else");
default:
pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d) in #elif directive", s);
}
@ -247,7 +246,7 @@ preprocessor
break;
case if_elsetrue:
case if_elsefalse:
pperror("#else clause already defined");
ppy_error("#else clause already defined");
default:
pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d) in #else directive", s);
}
@ -272,30 +271,30 @@ preprocessor
| tMACRO res_arg allmargs tMACROEND opt_mtexts tNL {
pp_add_macro($1, macro_args, nmacro_args, $5);
}
| tLINE tSINT tDQSTRING tNL { fprintf(ppout, "# %d %s\n", $2 , $3); free($3); }
| tGCCLINE tSINT tDQSTRING tNL { fprintf(ppout, "# %d %s\n", $2 , $3); free($3); }
| tLINE tSINT tDQSTRING tNL { fprintf(ppy_out, "# %d %s\n", $2 , $3); free($3); }
| tGCCLINE tSINT tDQSTRING tNL { fprintf(ppy_out, "# %d %s\n", $2 , $3); free($3); }
| tGCCLINE tSINT tDQSTRING tSINT tNL
{ fprintf(ppout, "# %d %s %d\n", $2, $3, $4); free($3); }
{ fprintf(ppy_out, "# %d %s %d\n", $2, $3, $4); free($3); }
| tGCCLINE tSINT tDQSTRING tSINT tSINT tNL
{ fprintf(ppout, "# %d %s %d %d\n", $2 ,$3, $4, $5); free($3); }
{ fprintf(ppy_out, "# %d %s %d %d\n", $2 ,$3, $4, $5); free($3); }
| tGCCLINE tSINT tDQSTRING tSINT tSINT tSINT tNL
{ fprintf(ppout, "# %d %s %d %d %d\n", $2 ,$3 ,$4 ,$5, $6); free($3); }
{ fprintf(ppy_out, "# %d %s %d %d %d\n", $2 ,$3 ,$4 ,$5, $6); free($3); }
| tGCCLINE tSINT tDQSTRING tSINT tSINT tSINT tSINT tNL
{ fprintf(ppout, "# %d %s %d %d %d %d\n", $2 ,$3 ,$4 ,$5, $6, $7); free($3); }
{ fprintf(ppy_out, "# %d %s %d %d %d %d\n", $2 ,$3 ,$4 ,$5, $6, $7); free($3); }
| tGCCLINE tNL /* The null-token */
| tERROR opt_text tNL { pperror("#error directive: '%s'", $2); if($2) free($2); }
| tWARNING opt_text tNL { ppwarning("#warning directive: '%s'", $2); if($2) free($2); }
| tPRAGMA opt_text tNL { fprintf(ppout, "#pragma %s\n", $2 ? $2 : ""); if ($2) free($2); }
| tPPIDENT opt_text tNL { if(pp_status.pedantic) ppwarning("#ident ignored (arg: '%s')", $2); if($2) free($2); }
| tERROR opt_text tNL { ppy_error("#error directive: '%s'", $2); if($2) free($2); }
| tWARNING opt_text tNL { ppy_warning("#warning directive: '%s'", $2); if($2) free($2); }
| tPRAGMA opt_text tNL { fprintf(ppy_out, "#pragma %s\n", $2 ? $2 : ""); if ($2) free($2); }
| tPPIDENT opt_text tNL { if(pp_status.pedantic) ppy_warning("#ident ignored (arg: '%s')", $2); if($2) free($2); }
| tRCINCLUDE tRCINCLUDEPATH {
int nl=strlen($2) +3;
char *fn=pp_xmalloc(nl);
sprintf(fn,"\"%s\"",$2);
free($2);
pp_do_include(fn,LOCAL_INCLUDE);
pp_do_include(fn,1);
}
| tRCINCLUDE tDQSTRING {
pp_do_include($2,LOCAL_INCLUDE);
pp_do_include($2,1);
}
/*| tNL*/
;
@ -346,7 +345,7 @@ mtext : tLITERAL { $$ = new_mtext($1, 0, exp_text); }
| tSTRINGIZE tIDENT {
int mat = marg_index($2);
if(mat < 0)
pperror("Stringification identifier must be an argument parameter");
ppy_error("Stringification identifier must be an argument parameter");
$$ = new_mtext(NULL, mat, exp_stringize);
}
| tIDENT {
@ -362,8 +361,8 @@ pp_expr : tSINT { $$.type = cv_sint; $$.val.si = $1; }
| tUINT { $$.type = cv_uint; $$.val.ui = $1; }
| tSLONG { $$.type = cv_slong; $$.val.sl = $1; }
| tULONG { $$.type = cv_ulong; $$.val.ul = $1; }
| tSLONGLONG { $$.type = cv_sll; $$.val.sl = $1; }
| tULONGLONG { $$.type = cv_ull; $$.val.ul = $1; }
| tSLONGLONG { $$.type = cv_sll; $$.val.sll = $1; }
| tULONGLONG { $$.type = cv_ull; $$.val.ull = $1; }
| tDEFINED tIDENT { $$.type = cv_sint; $$.val.si = pplookup($2) != NULL; }
| tDEFINED '(' tIDENT ')' { $$.type = cv_sint; $$.val.si = pplookup($3) != NULL; }
| tIDENT { $$.type = cv_sint; $$.val.si = 0; }

View file

@ -13,10 +13,11 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <fcntl.h>
@ -202,7 +203,7 @@ void pp_del_define(const char *name)
if((ppp = pplookup(name)) == NULL)
{
if(pp_status.pedantic)
ppwarning("%s was not defined", name);
ppy_warning("%s was not defined", name);
return;
}
@ -222,7 +223,7 @@ pp_entry_t *pp_add_define(char *def, char *text)
if((ppp = pplookup(def)) != NULL)
{
if(pp_status.pedantic)
ppwarning("Redefinition of %s\n\tPrevious definition: %s:%d", def, ppp->filename, ppp->linenumber);
ppy_warning("Redefinition of %s\n\tPrevious definition: %s:%d", def, ppp->filename, ppp->linenumber);
pp_del_define(def);
}
ppp = pp_xmalloc(sizeof(pp_entry_t));
@ -264,7 +265,7 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
if((ppp = pplookup(id)) != NULL)
{
if(pp_status.pedantic)
ppwarning("Redefinition of %s\n\tPrevious definition: %s:%d", id, ppp->filename, ppp->linenumber);
ppy_warning("Redefinition of %s\n\tPrevious definition: %s:%d", id, ppp->filename, ppp->linenumber);
pp_del_define(id);
}
ppp = pp_xmalloc(sizeof(pp_entry_t));
@ -313,7 +314,7 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
* Include management
*-------------------------------------------------------------------------
*/
#if defined(_WIN32) || defined(__MSDOS__)
#if defined(_Windows) || defined(__MSDOS__)
#define INCLUDESEPARATOR ";"
#else
#define INCLUDESEPARATOR ":"
@ -354,7 +355,7 @@ void wpp_add_include_path(const char *path)
free(cpy);
}
char *wpp_find_include(const char *name, const char *parent_name, int type)
char *wpp_find_include(const char *name, const char *parent_name)
{
char *cpy;
char *cptr;
@ -380,7 +381,7 @@ char *wpp_find_include(const char *name, const char *parent_name, int type)
}
*cptr = '\0';
if(type == LOCAL_INCLUDE && parent_name)
if(parent_name)
{
/* Search directory of parent include and then -I path */
const char *p;
@ -399,32 +400,8 @@ char *wpp_find_include(const char *name, const char *parent_name, int type)
}
free( path );
}
/* Skip all directories till the current include file for #include_next. */
if(type == INCLUDE_NEXT)
{
for(i = 1; i < nincludepath; i++)
{
char *path;
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
strcpy(path, includepath[i - 1]);
strcat(path, "/");
strcat(path, cpy);
if(!strcmp(pp_status.input, path))
{
free( path );
break;
}
free( path );
}
}
else
{
i = 0;
}
/* Search -I path */
for(; i < nincludepath; i++)
for(i = 0; i < nincludepath; i++)
{
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
strcpy(path, includepath[i]);
@ -443,12 +420,12 @@ char *wpp_find_include(const char *name, const char *parent_name, int type)
return NULL;
}
FILE *pp_open_include(const char *name, const char *parent_name, char **newpath, int type)
FILE *pp_open_include(const char *name, const char *parent_name, char **newpath)
{
char *path;
FILE *fp;
if (!(path = wpp_find_include( name, parent_name, type ))) return NULL;
if (!(path = wpp_find_include( name, parent_name ))) return NULL;
fp = fopen(path, "rt");
if (fp)
@ -547,7 +524,7 @@ void pp_push_if(pp_if_state_t s)
pp_if_state_t pp_pop_if(void)
{
if(if_stack_idx <= 0)
pperror("#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
ppy_error("#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
switch(pp_if_state())
{
@ -629,21 +606,21 @@ static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
fprintf(stderr, "\n");
}
int pperror(const char *s, ...)
int ppy_error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Error", pptext, ap);
generic_msg(s, "Error", ppy_text, ap);
va_end(ap);
exit(1);
return 1;
}
int ppwarning(const char *s, ...)
int ppy_warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Warning", pptext, ap);
generic_msg(s, "Warning", ppy_text, ap);
va_end(ap);
return 0;
}

View file

@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -28,7 +28,7 @@
#include "wpp_private.h"
#include "wine/wpp.h"
int ppdebug, pp_flex_debug;
int ppy_debug, pp_flex_debug;
struct define
{
@ -80,7 +80,7 @@ void wpp_add_define( const char *name, const char *value )
{
if (!strcmp( def->name, name ))
{
if (def->value) free( def->value );
free( def->value );
def->value = pp_xstrdup(value);
return;
}
@ -103,7 +103,7 @@ void wpp_del_define( const char *name )
{
if (!strcmp( def->name, name ))
{
if (def->value) free( def->value );
free( def->value );
def->value = NULL;
return;
}
@ -126,7 +126,7 @@ void wpp_add_cmdline_define( const char *value )
void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug )
{
pp_flex_debug = lex_debug;
ppdebug = parser_debug;
ppy_debug = parser_debug;
pp_status.debug = msg_debug;
}
@ -149,8 +149,8 @@ int wpp_parse( const char *input, FILE *output )
add_cmdline_defines();
add_special_defines();
if (!input) ppin = stdin;
else if (!(ppin = fopen(input, "rt")))
if (!input) ppy_in = stdin;
else if (!(ppy_in = fopen(input, "rt")))
{
fprintf(stderr,"Could not open %s\n", input);
exit(2);
@ -158,12 +158,12 @@ int wpp_parse( const char *input, FILE *output )
pp_status.input = input;
ppout = output;
fprintf(ppout, "# 1 \"%s\" 1\n", input ? input : "");
ppy_out = output;
fprintf(ppy_out, "# 1 \"%s\" 1\n", input ? input : "");
ret = ppparse();
ret = ppy_parse();
if (input) fclose(ppin);
if (input) fclose(ppy_in);
pp_pop_define_state();
return ret;
}

View file

@ -53,6 +53,16 @@ $(WPP_INT_)ppy.tab.o: $(WPP_BASE_)ppy.tab.c | $(WPP_INT)
$(ECHO_CC)
${host_gcc} $(WPP_HOST_CFLAGS) -c $< -o $@
#
#$(WPP_BASE_)ppy.tab.c: $(WPP_BASE_)ppy.y
# bison -p ppy_ -d -o tools\wpp\ppy.tab.c tools\wpp\ppy.y
#
#
#$(WPP_BASE_)lex.yy.c: $(WPP_BASE_)ppl.l
# flex -otools\wpp\lex.yy.c tools\wpp\ppl.l
#
.PHONY: wpp_clean
wpp_clean:
-@$(rm) $(WPP_TARGET) $(WPP_OBJECTS) 2>$(NUL)

View file

@ -14,12 +14,16 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_WPP_PRIVATE_H
#define __WINE_WPP_PRIVATE_H
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#include <stdio.h>
#include <string.h>
@ -36,10 +40,6 @@ typedef struct includelogicentry {
char *filename; /* The filename of the include */
} includelogicentry_t;
#define GLOBAL_INCLUDE 0 /* #include <foo.h> */
#define LOCAL_INCLUDE 1 /* #include "foo.h" */
#define INCLUDE_NEXT 2 /* #include_next <foo.h> */
/*
* The arguments of a macrodefinition
*/
@ -137,14 +137,16 @@ typedef struct
/*
* I assume that 'long long' exists in the compiler when it has a size
* of 8 or bigger. If not, then we revert to a simple 'long' for now.
* If the configure says we have long long then we can use it. Presumably
* if we have long long then we have strtoull and strtoll too. If that is
* not the case we will need to add to the configure tests.
* If we do not have long long , then we revert to a simple 'long' for now.
* This should prevent most unexpected things with other compilers than
* gcc and egcs for now.
* In the future it should be possible to use another way, like a
* structure, so that we can emulate the MS compiler.
*/
#if defined(SIZEOF_LONGLONG) && SIZEOF_LONGLONG >= 8
#ifdef HAVE_LONG_LONG
typedef long long wrc_sll_t;
typedef unsigned long long wrc_ull_t;
#else
@ -204,7 +206,7 @@ void pp_pop_define_state(void);
pp_entry_t *pp_add_define(char *def, char *text);
pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
void pp_del_define(const char *name);
FILE *pp_open_include(const char *name, const char *parent_name, char **newpath, int type);
FILE *pp_open_include(const char *name, const char *parent_name, char **newpath);
void pp_push_if(pp_if_state_t s);
void pp_next_if_state(int);
pp_if_state_t pp_pop_if(void);
@ -215,8 +217,8 @@ int pp_get_if_depth(void);
#define __attribute__(x) /*nothing*/
#endif
int pperror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int ppwarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
/* current preprocessor state */
@ -237,11 +239,11 @@ extern includelogicentry_t *pp_includelogiclist;
/*
* From ppl.l
*/
extern FILE *ppin;
extern FILE *ppout;
extern char *pptext;
extern FILE *ppy_in;
extern FILE *ppy_out;
extern char *ppy_text;
extern int pp_flex_debug;
int pplex(void);
int ppy_lex(void);
void pp_do_include(char *fname, int type);
void pp_push_ignore_state(void);
@ -251,7 +253,7 @@ void pp_pop_ignore_state(void);
/*
* From ppy.y
*/
int ppparse(void);
extern int ppdebug;
int ppy_parse(void);
extern int ppy_debug;
#endif /* __WINE_WPP_PRIVATE_H */

View file

@ -4859,7 +4859,7 @@ static raw_data_t *load_file(string_t *filename, language_t *lang)
if (codepage <= 0 && filename->type != str_char)
yyerror("Cannot convert filename to ASCII string");
name = convert_string( filename, str_char, codepage );
if (!(path = wpp_find_include(name->str.cstr, input_name, 1)))
if (!(path = wpp_find_include(name->str.cstr, input_name)))
yyerror("Cannot open file %s", name->str.cstr);
if (!(fp = fopen( path, "rb" )))
yyerror("Cannot open file %s", name->str.cstr);

View file

@ -2320,7 +2320,7 @@ static raw_data_t *load_file(string_t *filename, language_t *lang)
if (codepage <= 0 && filename->type != str_char)
yyerror("Cannot convert filename to ASCII string");
name = convert_string( filename, str_char, codepage );
if (!(path = wpp_find_include(name->str.cstr, input_name, 1)))
if (!(path = wpp_find_include(name->str.cstr, input_name)))
yyerror("Cannot open file %s", name->str.cstr);
if (!(fp = fopen( path, "rb" )))
yyerror("Cannot open file %s", name->str.cstr);