mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:15:59 +00:00
[WPP]
* Sync with Wine 1.7.1. svn path=/trunk/; revision=60092
This commit is contained in:
parent
ab785e9440
commit
dd79f09da8
11 changed files with 626 additions and 554 deletions
|
@ -29,12 +29,12 @@ struct wpp_callbacks
|
||||||
/* I/O callbacks */
|
/* I/O callbacks */
|
||||||
|
|
||||||
/* Looks for a file to include, returning the path where it is found */
|
/* Looks for a file to include, returning the path where it is found */
|
||||||
/* parent_name is the directory of the parent source file (for local
|
/* The type param is true for local (#include "filename.h") includes */
|
||||||
* includes), includepath is an array of additional include paths */
|
/* parent_name is the directory of the parent source file, includepath
|
||||||
char *(*lookup)( const char *filename, const char *parent_name,
|
* is an array of additional include paths */
|
||||||
|
char *(*lookup)( const char *filename, int type, const char *parent_name,
|
||||||
char **include_path, int include_path_count );
|
char **include_path, int include_path_count );
|
||||||
/* Opens an include file */
|
/* Opens an include file */
|
||||||
/* The type param is true if it is a local ("...") include */
|
|
||||||
void *(*open)( const char *filename, int type );
|
void *(*open)( const char *filename, int type );
|
||||||
/* Closes a previously opened file */
|
/* Closes a previously opened file */
|
||||||
void (*close)( void *file );
|
void (*close)( void *file );
|
||||||
|
|
|
@ -23,7 +23,7 @@ The following build tools are shared with Wine.
|
||||||
|
|
||||||
reactos/tools/unicode # Synced to Wine-1.5.19
|
reactos/tools/unicode # Synced to Wine-1.5.19
|
||||||
reactos/tools/widl # Synced to Wine-1.5.11
|
reactos/tools/widl # Synced to Wine-1.5.11
|
||||||
reactos/tools/wpp # Synced to Wine-1.3.26
|
reactos/tools/wpp # Synced to Wine-1.7.1
|
||||||
|
|
||||||
The following libraries are shared with Wine.
|
The following libraries are shared with Wine.
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ if(MSVC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
lex.yy.c
|
|
||||||
preproc.c
|
preproc.c
|
||||||
wpp.c
|
wpp.c
|
||||||
|
ppl.yy.c
|
||||||
ppy.tab.c)
|
ppy.tab.c)
|
||||||
|
|
||||||
add_library(wpp ${SOURCE})
|
add_library(wpp ${SOURCE})
|
||||||
|
|
|
@ -329,6 +329,7 @@ void pp_writestring(const char *format, ...)
|
||||||
va_start(valist, format);
|
va_start(valist, format);
|
||||||
len = vsnprintf(buffer, buffercapacity,
|
len = vsnprintf(buffer, buffercapacity,
|
||||||
format, valist);
|
format, valist);
|
||||||
|
va_end(valist);
|
||||||
/* If the string is longer than buffersize, vsnprintf returns
|
/* If the string is longer than buffersize, vsnprintf returns
|
||||||
* the string length with glibc >= 2.1, -1 with glibc < 2.1 */
|
* the string length with glibc >= 2.1, -1 with glibc < 2.1 */
|
||||||
while(len > buffercapacity || len < 0)
|
while(len > buffercapacity || len < 0)
|
||||||
|
@ -345,10 +346,11 @@ void pp_writestring(const char *format, ...)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer = new_buffer;
|
buffer = new_buffer;
|
||||||
|
va_start(valist, format);
|
||||||
len = vsnprintf(buffer, buffercapacity,
|
len = vsnprintf(buffer, buffercapacity,
|
||||||
format, valist);
|
format, valist);
|
||||||
|
va_end(valist);
|
||||||
}
|
}
|
||||||
va_end(valist);
|
|
||||||
|
|
||||||
wpp_callbacks->write(buffer, len);
|
wpp_callbacks->write(buffer, len);
|
||||||
}
|
}
|
||||||
|
@ -772,7 +774,10 @@ void pp_writestring(const char *format, ...)
|
||||||
if(!bep)
|
if(!bep)
|
||||||
{
|
{
|
||||||
if(YY_START != INITIAL)
|
if(YY_START != INITIAL)
|
||||||
|
{
|
||||||
ppy_error("Unexpected end of file during preprocessing");
|
ppy_error("Unexpected end of file during preprocessing");
|
||||||
|
BEGIN(INITIAL);
|
||||||
|
}
|
||||||
yyterminate();
|
yyterminate();
|
||||||
}
|
}
|
||||||
else if(bep->should_pop == 2)
|
else if(bep->should_pop == 2)
|
||||||
|
@ -1596,7 +1601,7 @@ void pp_do_include(char *fname, int type)
|
||||||
/* Undo the effect of the quotation */
|
/* Undo the effect of the quotation */
|
||||||
fname[n-1] = '\0';
|
fname[n-1] = '\0';
|
||||||
|
|
||||||
if((fp = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
|
if((fp = pp_open_include(fname+1, type, pp_status.input, &newpath)) == NULL)
|
||||||
{
|
{
|
||||||
ppy_error("Unable to open include file %s", fname+1);
|
ppy_error("Unable to open include file %s", fname+1);
|
||||||
return;
|
return;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,8 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
/* A Bison parser, made by GNU Bison 2.5. */
|
||||||
|
|
||||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||||
Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -90,7 +89,7 @@
|
||||||
typedef union YYSTYPE
|
typedef union YYSTYPE
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Line 1685 of yacc.c */
|
/* Line 2068 of yacc.c */
|
||||||
#line 126 "ppy.y"
|
#line 126 "ppy.y"
|
||||||
|
|
||||||
int sint;
|
int sint;
|
||||||
|
@ -107,8 +106,8 @@ typedef union YYSTYPE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 1685 of yacc.c */
|
/* Line 2068 of yacc.c */
|
||||||
#line 112 "ppy.tab.h"
|
#line 111 "ppy.tab.h"
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
|
|
|
@ -383,24 +383,24 @@ pp_expr : tSINT { $$.type = cv_sint; $$.val.si = $1; }
|
||||||
| tIDENT { $$.type = cv_sint; $$.val.si = 0; }
|
| tIDENT { $$.type = cv_sint; $$.val.si = 0; }
|
||||||
| pp_expr tLOGOR pp_expr { $$.type = cv_sint; $$.val.si = boolean(&$1) || boolean(&$3); }
|
| pp_expr tLOGOR pp_expr { $$.type = cv_sint; $$.val.si = boolean(&$1) || boolean(&$3); }
|
||||||
| pp_expr tLOGAND pp_expr { $$.type = cv_sint; $$.val.si = boolean(&$1) && boolean(&$3); }
|
| pp_expr tLOGAND pp_expr { $$.type = cv_sint; $$.val.si = boolean(&$1) && boolean(&$3); }
|
||||||
| pp_expr tEQ pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, ==) }
|
| pp_expr tEQ pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, ==); }
|
||||||
| pp_expr tNE pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, !=) }
|
| pp_expr tNE pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, !=); }
|
||||||
| pp_expr '<' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, <) }
|
| pp_expr '<' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, <); }
|
||||||
| pp_expr '>' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, >) }
|
| pp_expr '>' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, >); }
|
||||||
| pp_expr tLTE pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, <=) }
|
| pp_expr tLTE pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, <=); }
|
||||||
| pp_expr tGTE pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, >=) }
|
| pp_expr tGTE pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, >=); }
|
||||||
| pp_expr '+' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, +) }
|
| pp_expr '+' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, +); }
|
||||||
| pp_expr '-' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, -) }
|
| pp_expr '-' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, -); }
|
||||||
| pp_expr '^' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, ^) }
|
| pp_expr '^' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, ^); }
|
||||||
| pp_expr '&' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, &) }
|
| pp_expr '&' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, &); }
|
||||||
| pp_expr '|' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, |) }
|
| pp_expr '|' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, |); }
|
||||||
| pp_expr '*' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, *) }
|
| pp_expr '*' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, *); }
|
||||||
| pp_expr '/' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, /) }
|
| pp_expr '/' pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, /); }
|
||||||
| pp_expr tLSHIFT pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, <<) }
|
| pp_expr tLSHIFT pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, <<); }
|
||||||
| pp_expr tRSHIFT pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, >>) }
|
| pp_expr tRSHIFT pp_expr { promote_equal_size(&$1, &$3); BIN_OP($$, $1, $3, >>); }
|
||||||
| '+' pp_expr { $$ = $2; }
|
| '+' pp_expr { $$ = $2; }
|
||||||
| '-' pp_expr { UNARY_OP($$, $2, -) }
|
| '-' pp_expr { UNARY_OP($$, $2, -); }
|
||||||
| '~' pp_expr { UNARY_OP($$, $2, ~) }
|
| '~' pp_expr { UNARY_OP($$, $2, ~); }
|
||||||
| '!' pp_expr { $$.type = cv_sint; $$.val.si = !boolean(&$2); }
|
| '!' pp_expr { $$.type = cv_sint; $$.val.si = !boolean(&$2); }
|
||||||
| '(' pp_expr ')' { $$ = $2; }
|
| '(' pp_expr ')' { $$ = $2; }
|
||||||
| pp_expr '?' pp_expr ':' pp_expr { $$ = boolean(&$1) ? $3 : $5; }
|
| pp_expr '?' pp_expr ':' pp_expr { $$ = boolean(&$1) ? $3 : $5; }
|
||||||
|
|
|
@ -115,7 +115,7 @@ char *pp_xstrdup(const char *str)
|
||||||
return memcpy(s, str, len);
|
return memcpy(s, str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *wpp_default_lookup(const char *name, const char *parent_name,
|
static char *wpp_default_lookup(const char *name, int type, const char *parent_name,
|
||||||
char **include_path, int include_path_count)
|
char **include_path, int include_path_count)
|
||||||
{
|
{
|
||||||
char *cpy;
|
char *cpy;
|
||||||
|
@ -144,7 +144,7 @@ static char *wpp_default_lookup(const char *name, const char *parent_name,
|
||||||
}
|
}
|
||||||
*cptr = '\0';
|
*cptr = '\0';
|
||||||
|
|
||||||
if(parent_name)
|
if(type && parent_name)
|
||||||
{
|
{
|
||||||
/* Search directory of parent include and then -I path */
|
/* Search directory of parent include and then -I path */
|
||||||
const char *p;
|
const char *p;
|
||||||
|
@ -507,17 +507,17 @@ int wpp_add_include_path(const char *path)
|
||||||
|
|
||||||
char *wpp_find_include(const char *name, const char *parent_name)
|
char *wpp_find_include(const char *name, const char *parent_name)
|
||||||
{
|
{
|
||||||
return wpp_default_lookup(name, parent_name, includepath, nincludepath);
|
return wpp_default_lookup(name, !!parent_name, parent_name, includepath, nincludepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pp_open_include(const char *name, const char *parent_name, char **newpath)
|
void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
void *fp;
|
void *fp;
|
||||||
|
|
||||||
if (!(path = wpp_callbacks->lookup(name, parent_name, includepath,
|
if (!(path = wpp_callbacks->lookup(name, type, parent_name, includepath,
|
||||||
nincludepath))) return NULL;
|
nincludepath))) return NULL;
|
||||||
fp = wpp_callbacks->open(path, parent_name == NULL ? 1 : 0);
|
fp = wpp_callbacks->open(path, type);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,16 @@ static void add_cmdline_defines(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void del_cmdline_defines(void)
|
||||||
|
{
|
||||||
|
struct define *def;
|
||||||
|
|
||||||
|
for (def = cmdline_defines; def; def = def->next)
|
||||||
|
{
|
||||||
|
if (def->value) pp_del_define( def->name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void add_special_defines(void)
|
static void add_special_defines(void)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
@ -70,6 +80,14 @@ static void add_special_defines(void)
|
||||||
ppp->type = def_special;
|
ppp->type = def_special;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void del_special_defines(void)
|
||||||
|
{
|
||||||
|
pp_del_define( "__DATE__" );
|
||||||
|
pp_del_define( "__TIME__" );
|
||||||
|
pp_del_define( "__FILE__" );
|
||||||
|
pp_del_define( "__LINE__" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* add a define to the preprocessor list */
|
/* add a define to the preprocessor list */
|
||||||
int wpp_add_define( const char *name, const char *value )
|
int wpp_add_define( const char *name, const char *value )
|
||||||
|
@ -182,6 +200,8 @@ int wpp_parse( const char *input, FILE *output )
|
||||||
else if (!(pp_status.file = wpp_callbacks->open(input, 1)))
|
else if (!(pp_status.file = wpp_callbacks->open(input, 1)))
|
||||||
{
|
{
|
||||||
ppy_error("Could not open %s\n", input);
|
ppy_error("Could not open %s\n", input);
|
||||||
|
del_special_defines();
|
||||||
|
del_cmdline_defines();
|
||||||
pp_pop_define_state();
|
pp_pop_define_state();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -198,6 +218,8 @@ int wpp_parse( const char *input, FILE *output )
|
||||||
if (input) wpp_callbacks->close(pp_status.file);
|
if (input) wpp_callbacks->close(pp_status.file);
|
||||||
/* Clean if_stack, it could remain dirty on errors */
|
/* Clean if_stack, it could remain dirty on errors */
|
||||||
while (pp_get_if_depth()) pp_pop_if();
|
while (pp_get_if_depth()) pp_pop_if();
|
||||||
|
del_special_defines();
|
||||||
|
del_cmdline_defines();
|
||||||
pp_pop_define_state();
|
pp_pop_define_state();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ void pp_pop_define_state(void);
|
||||||
pp_entry_t *pp_add_define(const char *def, const char *text);
|
pp_entry_t *pp_add_define(const char *def, const char *text);
|
||||||
pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
|
pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
|
||||||
void pp_del_define(const char *name);
|
void pp_del_define(const char *name);
|
||||||
void *pp_open_include(const char *name, const char *parent_name, char **newpath);
|
void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
|
||||||
void pp_push_if(pp_if_state_t s);
|
void pp_push_if(pp_if_state_t s);
|
||||||
void pp_next_if_state(int);
|
void pp_next_if_state(int);
|
||||||
pp_if_state_t pp_pop_if(void);
|
pp_if_state_t pp_pop_if(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue