From 4d9a1b48f98e8580eeec9f7f006a6c6a6deef4bd Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Mon, 15 Feb 1999 14:04:21 +0000 Subject: c-common.c (UNGETC [USE_CPPLIB=1]): Do nothing if c is EOF. 1999-02-15 16:59 -0500 Zack Weinberg * c-common.c (UNGETC [USE_CPPLIB=1]): Do nothing if c is EOF. * c-lex.c: Likewise. * cpplib.c (cpp_push_buffer, cpp_pop_buffer): Use a linked list in malloced memory for the buffer stack. (cpp_get_token): Don't pop the last buffer off the stack. Calls after CPP_EOF has been returned produce CPP_EOF with no state change. (cpp_finish): Pop last buffer here. (do_line): Don't free ip->last_nominal_fname if it is equal to ip->fname. (special_symbol): If a T_CONST is the empty string, push a single `@ ' escape instead. (macroexpand): Special symbol buffers have escapes too. * cpplib.h (struct cpp_buffer): Remove unused fields, add prev buffer pointer. (struct cpp_reader): Remove buffer_stack. Add buffer_stack_depth. (CPP_PREV_BUFFER, CPP_NULL_BUFFER): Buffer stack is now a linked list. From-SVN: r25218 --- gcc/cpplib.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'gcc/cpplib.h') diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 9572bb8..8a33eed 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -98,13 +98,16 @@ extern void cpp_cleanup PARAMS ((cpp_reader *PFILE)); /* If we have a huge buffer, may need to cache more recent counts */ #define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base) -struct cpp_buffer { - unsigned char *buf; - unsigned char *cur; +struct cpp_buffer +{ + unsigned char *cur; /* current position */ unsigned char *rlimit; /* end of valid data */ + unsigned char *buf; /* entire buffer */ unsigned char *alimit; /* end of allocated buffer */ - unsigned char *prev; /* start of current token */ + struct cpp_buffer *prev; + + /* Real filename. (Alias to ->ihash->fname, obsolete). */ char *fname; /* Filename specified with #line command. */ char *nominal_fname; @@ -114,8 +117,7 @@ struct cpp_buffer { struct file_name_list *actual_dir; /* Pointer into the include hash table. Used for include_next and - to record control macros. - ->fname is an alias to ->ihash->fname. */ + to record control macros. */ struct include_hash *ihash; long line_base; @@ -176,6 +178,9 @@ struct cpp_reader /* Current depth in #include directives that use <...>. */ int system_include_depth; + /* Current depth of buffer stack. */ + int buffer_stack_depth; + /* Hash table of other included files. See cppfiles.c */ #define ALL_INCLUDE_HASHSIZE 71 struct include_hash *all_include_files[ALL_INCLUDE_HASHSIZE]; @@ -244,8 +249,6 @@ struct cpp_reader #ifdef __cplusplus ~cpp_reader () { cpp_cleanup (this); } #endif - - cpp_buffer buffer_stack[CPP_STACK_MAX]; }; #define CPP_FATAL_LIMIT 1000 @@ -290,9 +293,9 @@ struct cpp_reader #define CPP_OPTIONS(PFILE) ((PFILE)->opts) #define CPP_BUFFER(PFILE) ((PFILE)->buffer) -#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1) +#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev) /* The bottom of the buffer stack. */ -#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX]) +#define CPP_NULL_BUFFER(PFILE) NULL /* Pointed to by cpp_reader.opts. */ struct cpp_options { -- cgit v1.1