Alexandre Julliard <julliard@winehq.org>
- Default search path for an include file should be based on the path of
the parent source file, not the current directory.
svn path=/trunk/; revision=18788
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 );
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 );
-extern char *wpp_find_include( const char *name, int search );
+char *wpp_find_include( const char *name, const char *parent_name, int type );
extern int wpp_parse( const char *input, FILE *output );
extern int wpp_parse_temp( const char *input, const char *output_base, char **output_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 );
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef __cplusplus
#include <stdlib.h>
#ifdef __cplusplus
#include <stdlib.h>
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
* The flexer starts here
**************************************************************************
*/
* The flexer starts here
**************************************************************************
*/
/* Macros after this point can all be overridden by user definitions in
* section 1.
/* Macros after this point can all be overridden by user definitions in
* section 1.
YY_DECL
{
register yy_state_type yy_current_state;
YY_DECL
{
register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
+ register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act;
#line 108 "parser.l"
register int yy_act;
#line 108 "parser.l"
#line 164 "parser.l"
ECHO;
YY_BREAK
#line 164 "parser.l"
ECHO;
YY_BREAK
#endif /* ifndef YY_NO_UNPUT */
#endif /* ifndef YY_NO_UNPUT */
#ifdef __cplusplus
static int yyinput()
#else
#ifdef __cplusplus
static int yyinput()
#else
+#endif /* YY_NO_INPUT */
#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
import->next = first_import;
first_import = import;
import->next = first_import;
first_import = import;
- if (!(path = wpp_find_include( fname, 1 )))
+ if (!(path = wpp_find_include( fname, input_name, 1 )))
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;
import->next = first_import;
first_import = import;
import->next = first_import;
first_import = import;
- if (!(path = wpp_find_include( fname, 1 )))
+ if (!(path = wpp_find_include( fname, input_name, 1 )))
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifdef __cplusplus
#include <stdlib.h>
#ifdef __cplusplus
#include <stdlib.h>
-#ifndef _WIN32
-#include <unistd.h>
-#endif
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
#define YY_PROTO(proto) ()
#endif
#define YY_PROTO(proto) ()
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Returned upon end-of-file. */
#define YY_NULL 0
* The scanner starts here
**************************************************************************
*/
* The scanner starts here
**************************************************************************
*/
/* Macros after this point can all be overridden by user definitions in
* section 1.
/* Macros after this point can all be overridden by user definitions in
* section 1.
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }
+ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+ && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
YY_DECL
{
register yy_state_type yy_current_state;
YY_DECL
{
register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
+ register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act;
#line 299 "ppl.l"
register int yy_act;
#line 299 "ppl.l"
/*
* Detect the leading # of a preprocessor directive.
*/
/*
* Detect the leading # of a preprocessor directive.
*/
#line 724 "ppl.l"
ECHO;
YY_BREAK
#line 724 "ppl.l"
ECHO;
YY_BREAK
#endif /* ifndef YY_NO_UNPUT */
#endif /* ifndef YY_NO_UNPUT */
#ifdef __cplusplus
static int yyinput()
#else
#ifdef __cplusplus
static int yyinput()
#else
+#endif /* YY_NO_INPUT */
#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
-#ifndef _WIN32
-#include <unistd.h>
-#else
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-#endif
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
/* Undo the effect of the quotation */
fname[n-1] = '\0';
/* Undo the effect of the quotation */
fname[n-1] = '\0';
- if((ppin = pp_open_include(fname+1, type, &newpath)) == NULL)
+ if((ppin = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
pperror("Unable to open include file %s", fname+1);
fname[n-1] = *fname; /* Redo the quotes */
pperror("Unable to open include file %s", fname+1);
fname[n-1] = *fname; /* Redo the quotes */
/* Undo the effect of the quotation */
fname[n-1] = '\0';
/* Undo the effect of the quotation */
fname[n-1] = '\0';
- if((ppin = pp_open_include(fname+1, type, &newpath)) == NULL)
+ if((ppin = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
pperror("Unable to open include file %s", fname+1);
fname[n-1] = *fname; /* Redo the quotes */
pperror("Unable to open include file %s", fname+1);
fname[n-1] = *fname; /* Redo the quotes */
-char *wpp_find_include(const char *name, int type)
+char *wpp_find_include(const char *name, const char *parent_name, int type)
const char *ccptr;
int i, fd;
const char *ccptr;
int i, fd;
- if(type == LOCAL_INCLUDE)
+ if(type == LOCAL_INCLUDE && parent_name)
- /* Search current dir and then -I path */
- fd = open( cpy, O_RDONLY );
+ /* Search directory of parent include and then -I path */
+ const char *p;
+
+ if ((p = strrchr( parent_name, '/' ))) p++;
+ else p = parent_name;
+ path = pp_xmalloc( (p - parent_name) + strlen(cpy) + 1 );
+ memcpy( path, parent_name, p - parent_name );
+ strcpy( path + (p - parent_name), cpy );
+ fd = open( path, O_RDONLY );
if (fd != -1)
{
close( fd );
if (fd != -1)
{
close( fd );
+ free( cpy );
+ return path;
}
/* Skip all directories till the current include file for #include_next. */
}
/* Skip all directories till the current include file for #include_next. */
/* Search -I path */
for(; i < nincludepath; i++)
{
/* Search -I path */
for(; i < nincludepath; i++)
{
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
strcpy(path, includepath[i]);
strcat(path, "/");
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
strcpy(path, includepath[i]);
strcat(path, "/");
-FILE *pp_open_include(const char *name, int type, char **newpath)
+FILE *pp_open_include(const char *name, const char *parent_name, char **newpath, int type)
- if (!(path = wpp_find_include( name, type ))) return NULL;
+ if (!(path = wpp_find_include( name, parent_name, type ))) return NULL;
fp = fopen(path, "rt");
if (fp)
fp = fopen(path, "rt");
if (fp)
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);
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, int search, char **newpath);
+FILE *pp_open_include(const char *name, const char *parent_name, char **newpath, int type);
void pp_push_if(pp_if_state_t s);
void pp_next_if_state(int);
pp_if_state_t pp_pop_if(void);
void pp_push_if(pp_if_state_t s);
void pp_next_if_state(int);
pp_if_state_t pp_pop_if(void);