mirror of
https://github.com/reactos/reactos.git
synced 2024-09-13 22:31:34 +00:00
Sync to Wine-0_9:
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
This commit is contained in:
parent
49d6f75f30
commit
d68c7aaf71
|
@ -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_debug( int lex_debug, int parser_debug, int msg_debug );
|
||||||
extern void wpp_set_pedantic( int on );
|
extern void wpp_set_pedantic( int on );
|
||||||
extern void wpp_add_include_path( const char *path );
|
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( const char *input, FILE *output );
|
||||||
extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name );
|
extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name );
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#line 2 "lex.yy.c"
|
|
||||||
/* A lexical scanner generated by flex */
|
/* A lexical scanner generated by flex */
|
||||||
|
|
||||||
/* Scanner skeleton version:
|
/* Scanner skeleton version:
|
||||||
|
@ -10,6 +9,7 @@
|
||||||
#define YY_FLEX_MINOR_VERSION 5
|
#define YY_FLEX_MINOR_VERSION 5
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
|
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/* Use prototypes in function declarations. */
|
/* Use prototypes in function declarations. */
|
||||||
#define YY_USE_PROTOS
|
#define YY_USE_PROTOS
|
||||||
|
@ -3186,7 +3185,7 @@ static UUID* parse_uuid(const char*u)
|
||||||
* The flexer starts here
|
* The flexer starts here
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
*/
|
*/
|
||||||
#line 3190 "lex.yy.c"
|
#line 3189 "lex.yy.c"
|
||||||
|
|
||||||
/* Macros after this point can all be overridden by user definitions in
|
/* Macros after this point can all be overridden by user definitions in
|
||||||
* section 1.
|
* section 1.
|
||||||
|
@ -3337,12 +3336,12 @@ YY_MALLOC_DECL
|
||||||
YY_DECL
|
YY_DECL
|
||||||
{
|
{
|
||||||
register yy_state_type yy_current_state;
|
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;
|
register int yy_act;
|
||||||
|
|
||||||
#line 108 "parser.l"
|
#line 108 "parser.l"
|
||||||
|
|
||||||
#line 3346 "lex.yy.c"
|
#line 3345 "lex.yy.c"
|
||||||
|
|
||||||
if ( yy_init )
|
if ( yy_init )
|
||||||
{
|
{
|
||||||
|
@ -3559,7 +3558,7 @@ YY_RULE_SETUP
|
||||||
#line 164 "parser.l"
|
#line 164 "parser.l"
|
||||||
ECHO;
|
ECHO;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
#line 3563 "lex.yy.c"
|
#line 3562 "lex.yy.c"
|
||||||
|
|
||||||
case YY_END_OF_BUFFER:
|
case YY_END_OF_BUFFER:
|
||||||
{
|
{
|
||||||
|
@ -3935,6 +3934,7 @@ register char *yy_bp;
|
||||||
#endif /* ifndef YY_NO_UNPUT */
|
#endif /* ifndef YY_NO_UNPUT */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef YY_NO_INPUT
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
static int yyinput()
|
static int yyinput()
|
||||||
#else
|
#else
|
||||||
|
@ -4007,7 +4007,7 @@ static int input()
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
#endif /* YY_NO_INPUT */
|
||||||
|
|
||||||
#ifdef YY_USE_PROTOS
|
#ifdef YY_USE_PROTOS
|
||||||
void yyrestart( FILE *input_file )
|
void yyrestart( FILE *input_file )
|
||||||
|
@ -4118,11 +4118,6 @@ YY_BUFFER_STATE b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef YY_ALWAYS_INTERACTIVE
|
|
||||||
#ifndef YY_NEVER_INTERACTIVE
|
|
||||||
extern int isatty YY_PROTO(( int ));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef YY_USE_PROTOS
|
#ifdef YY_USE_PROTOS
|
||||||
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
|
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
|
||||||
|
@ -4696,7 +4691,7 @@ int do_import(char *fname)
|
||||||
import->next = first_import;
|
import->next = first_import;
|
||||||
first_import = 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);
|
yyerror("Unable to open include file %s", fname);
|
||||||
|
|
||||||
import_stack[ptr].temp_name = temp_name;
|
import_stack[ptr].temp_name = temp_name;
|
||||||
|
|
|
@ -416,7 +416,7 @@ int do_import(char *fname)
|
||||||
import->next = first_import;
|
import->next = first_import;
|
||||||
first_import = 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);
|
yyerror("Unable to open include file %s", fname);
|
||||||
|
|
||||||
import_stack[ptr].temp_name = temp_name;
|
import_stack[ptr].temp_name = temp_name;
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#define YY_FLEX_MINOR_VERSION 5
|
#define YY_FLEX_MINOR_VERSION 5
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
|
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
|
||||||
#ifdef c_plusplus
|
#ifdef c_plusplus
|
||||||
|
@ -41,9 +42,6 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifndef _WIN32
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use prototypes in function declarations. */
|
/* Use prototypes in function declarations. */
|
||||||
#define YY_USE_PROTOS
|
#define YY_USE_PROTOS
|
||||||
|
@ -83,7 +81,6 @@
|
||||||
#define YY_PROTO(proto) ()
|
#define YY_PROTO(proto) ()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Returned upon end-of-file. */
|
/* Returned upon end-of-file. */
|
||||||
#define YY_NULL 0
|
#define YY_NULL 0
|
||||||
|
|
||||||
|
@ -14031,7 +14028,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
|
||||||
* The scanner starts here
|
* The scanner starts here
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
*/
|
*/
|
||||||
#line 14035 "lex.yy.c"
|
#line 14032 "lex.yy.c"
|
||||||
|
|
||||||
/* Macros after this point can all be overridden by user definitions in
|
/* Macros after this point can all be overridden by user definitions in
|
||||||
* section 1.
|
* section 1.
|
||||||
|
@ -14131,20 +14128,9 @@ YY_MALLOC_DECL
|
||||||
YY_FATAL_ERROR( "input in flex scanner failed" ); \
|
YY_FATAL_ERROR( "input in flex scanner failed" ); \
|
||||||
result = n; \
|
result = n; \
|
||||||
} \
|
} \
|
||||||
else \
|
else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
|
||||||
{ \
|
&& ferror( yyin ) ) \
|
||||||
errno=0; \
|
YY_FATAL_ERROR( "input in flex scanner failed" );
|
||||||
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); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* No semi-colon after return; correct usage is to write "yyterminate();" -
|
/* No semi-colon after return; correct usage is to write "yyterminate();" -
|
||||||
|
@ -14193,7 +14179,7 @@ YY_MALLOC_DECL
|
||||||
YY_DECL
|
YY_DECL
|
||||||
{
|
{
|
||||||
register yy_state_type yy_current_state;
|
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;
|
register int yy_act;
|
||||||
|
|
||||||
#line 299 "ppl.l"
|
#line 299 "ppl.l"
|
||||||
|
@ -14210,7 +14196,7 @@ YY_DECL
|
||||||
/*
|
/*
|
||||||
* Detect the leading # of a preprocessor directive.
|
* Detect the leading # of a preprocessor directive.
|
||||||
*/
|
*/
|
||||||
#line 14214 "lex.yy.c"
|
#line 14200 "lex.yy.c"
|
||||||
|
|
||||||
if ( yy_init )
|
if ( yy_init )
|
||||||
{
|
{
|
||||||
|
@ -15286,7 +15272,7 @@ YY_RULE_SETUP
|
||||||
#line 724 "ppl.l"
|
#line 724 "ppl.l"
|
||||||
ECHO;
|
ECHO;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
#line 15290 "lex.yy.c"
|
#line 15276 "lex.yy.c"
|
||||||
|
|
||||||
case YY_END_OF_BUFFER:
|
case YY_END_OF_BUFFER:
|
||||||
{
|
{
|
||||||
|
@ -15662,6 +15648,7 @@ register char *yy_bp;
|
||||||
#endif /* ifndef YY_NO_UNPUT */
|
#endif /* ifndef YY_NO_UNPUT */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef YY_NO_INPUT
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
static int yyinput()
|
static int yyinput()
|
||||||
#else
|
#else
|
||||||
|
@ -15734,7 +15721,7 @@ static int input()
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
#endif /* YY_NO_INPUT */
|
||||||
|
|
||||||
#ifdef YY_USE_PROTOS
|
#ifdef YY_USE_PROTOS
|
||||||
void yyrestart( FILE *input_file )
|
void yyrestart( FILE *input_file )
|
||||||
|
@ -15845,15 +15832,6 @@ YY_BUFFER_STATE b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#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
|
#ifdef YY_USE_PROTOS
|
||||||
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
|
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
|
||||||
|
@ -16899,7 +16877,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((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);
|
pperror("Unable to open include file %s", fname+1);
|
||||||
|
|
||||||
fname[n-1] = *fname; /* Redo the quotes */
|
fname[n-1] = *fname; /* Redo the quotes */
|
||||||
|
|
|
@ -1448,7 +1448,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((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);
|
pperror("Unable to open include file %s", fname+1);
|
||||||
|
|
||||||
fname[n-1] = *fname; /* Redo the quotes */
|
fname[n-1] = *fname; /* Redo the quotes */
|
||||||
|
|
|
@ -354,10 +354,11 @@ void wpp_add_include_path(const char *path)
|
||||||
free(cpy);
|
free(cpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *wpp_find_include(const char *name, int type)
|
char *wpp_find_include(const char *name, const char *parent_name, int type)
|
||||||
{
|
{
|
||||||
char *cpy;
|
char *cpy;
|
||||||
char *cptr;
|
char *cptr;
|
||||||
|
char *path;
|
||||||
const char *ccptr;
|
const char *ccptr;
|
||||||
int i, fd;
|
int i, fd;
|
||||||
|
|
||||||
|
@ -379,15 +380,24 @@ char *wpp_find_include(const char *name, int type)
|
||||||
}
|
}
|
||||||
*cptr = '\0';
|
*cptr = '\0';
|
||||||
|
|
||||||
if(type == LOCAL_INCLUDE)
|
if(type == LOCAL_INCLUDE && parent_name)
|
||||||
{
|
{
|
||||||
/* Search current dir and then -I path */
|
/* Search directory of parent include and then -I path */
|
||||||
fd = open( cpy, O_RDONLY );
|
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)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
close( fd );
|
close( fd );
|
||||||
return cpy;
|
free( cpy );
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
free( path );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip all directories till the current include file for #include_next. */
|
/* Skip all directories till the current include file for #include_next. */
|
||||||
|
@ -416,7 +426,6 @@ char *wpp_find_include(const char *name, int type)
|
||||||
/* Search -I path */
|
/* Search -I path */
|
||||||
for(; i < nincludepath; i++)
|
for(; i < nincludepath; i++)
|
||||||
{
|
{
|
||||||
char *path;
|
|
||||||
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
|
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
|
||||||
strcpy(path, includepath[i]);
|
strcpy(path, includepath[i]);
|
||||||
strcat(path, "/");
|
strcat(path, "/");
|
||||||
|
@ -434,12 +443,12 @@ char *wpp_find_include(const char *name, int type)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (!(path = wpp_find_include( name, type ))) return NULL;
|
if (!(path = wpp_find_include( name, parent_name, type ))) return NULL;
|
||||||
fp = fopen(path, "rt");
|
fp = fopen(path, "rt");
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
|
|
@ -204,7 +204,7 @@ void pp_pop_define_state(void);
|
||||||
pp_entry_t *pp_add_define(char *def, char *text);
|
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);
|
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);
|
||||||
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_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…
Reference in a new issue