Commit af453bb0 by Per Bothner

cpplib.h, cpplib.c: Remove support for !STATIC_BUFFERS.

* cpplib.h, cpplib.c:  Remove support for !STATIC_BUFFERS.
* cpplib.h:  Use unsigned char rather than U_CHAR.
* cpplib.h (cpp_reader):  Add destructor #ifdef __cplusplus.
(cpp_cleanup):  New prototype.

From-SVN: r12169
parent c003beca
...@@ -27,8 +27,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -27,8 +27,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern "C" { extern "C" {
#endif #endif
#define STATIC_BUFFERS
typedef unsigned char U_CHAR; typedef unsigned char U_CHAR;
struct parse_file; struct parse_file;
...@@ -101,6 +99,8 @@ extern enum cpp_token cpp_get_token PARAMS ((struct parse_marker*)); ...@@ -101,6 +99,8 @@ extern enum cpp_token cpp_get_token PARAMS ((struct parse_marker*));
extern void cpp_skip_hspace PARAMS((cpp_reader*)); extern void cpp_skip_hspace PARAMS((cpp_reader*));
extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *)); extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *));
/* This frees resources used by PFILE. */
extern void cpp_cleanup PARAMS ((cpp_reader* PFILE));
/* Maintain and search list of included files, for #import. */ /* Maintain and search list of included files, for #import. */
...@@ -134,9 +134,6 @@ struct cpp_buffer { ...@@ -134,9 +134,6 @@ struct cpp_buffer {
long line_base; long line_base;
long lineno; /* Line number at CPP_LINE_BASE. */ long lineno; /* Line number at CPP_LINE_BASE. */
long colno; /* Column number at CPP_LINE_BASE. */ long colno; /* Column number at CPP_LINE_BASE. */
#ifndef STATIC_BUFFERS
cpp_buffer *chain;
#endif
parse_underflow_t underflow; parse_underflow_t underflow;
parse_cleanup_t cleanup; parse_cleanup_t cleanup;
void *data; void *data;
...@@ -150,7 +147,7 @@ struct cpp_buffer { ...@@ -150,7 +147,7 @@ struct cpp_buffer {
char seen_eof; char seen_eof;
/* True if buffer contains escape sequences. /* True if buffer contains escape sequences.
Currently there are are only two kind: Currently there are three kinds:
"@-" means following identifier should not be macro-expanded. "@-" means following identifier should not be macro-expanded.
"@ " means a token-separator. This turns into " " in final output "@ " means a token-separator. This turns into " " in final output
if not stringizing and needed to separate tokens; otherwise nothing. if not stringizing and needed to separate tokens; otherwise nothing.
...@@ -165,25 +162,28 @@ struct file_name_map_list; ...@@ -165,25 +162,28 @@ struct file_name_map_list;
typedef struct assertion_hashnode ASSERTION_HASHNODE; typedef struct assertion_hashnode ASSERTION_HASHNODE;
#define ASSERTION_HASHSIZE 37 #define ASSERTION_HASHSIZE 37
#ifdef STATIC_BUFFERS
/* Maximum nesting of cpp_buffers. We use a static limit, partly for /* Maximum nesting of cpp_buffers. We use a static limit, partly for
efficiency, and partly to limit runaway recursion. */ efficiency, and partly to limit runaway recursion. */
#define CPP_STACK_MAX 200 #define CPP_STACK_MAX 200
#endif
/* A cpp_reader encapsulates the "state" of a pre-processor run.
Applying cpp_get_token repeatedly yields a stream of pre-processor
tokens. Usually, there is only one cpp_reader object active. */
struct cpp_reader { struct cpp_reader {
unsigned char *limit;
parse_underflow_t get_token; parse_underflow_t get_token;
cpp_buffer *buffer; cpp_buffer *buffer;
#ifdef STATIC_BUFFERS
cpp_buffer buffer_stack[CPP_STACK_MAX]; cpp_buffer buffer_stack[CPP_STACK_MAX];
#endif
int errors; /* Error counter for exit code */ int errors; /* Error counter for exit code */
void *data; void *data;
U_CHAR *token_buffer; /* A buffer used for both for cpp_get_token's output, and also internally. */
unsigned char *token_buffer;
/* Alocated size of token_buffer. CPP_RESERVE allocates space. */
int token_buffer_size; int token_buffer_size;
/* End of the written part of token_buffer. */
unsigned char *limit;
/* Line where a newline was first seen in a string constant. */ /* Line where a newline was first seen in a string constant. */
int multiline_string_line; int multiline_string_line;
...@@ -260,6 +260,10 @@ struct cpp_reader { ...@@ -260,6 +260,10 @@ struct cpp_reader {
/* Number of bytes since the last newline. */ /* Number of bytes since the last newline. */
int deps_column; int deps_column;
#ifdef __cplusplus
~cpp_reader () { cpp_cleanup (this); }
#endif
}; };
#define CPP_BUF_PEEK(BUFFER) \ #define CPP_BUF_PEEK(BUFFER) \
...@@ -295,15 +299,10 @@ struct cpp_reader { ...@@ -295,15 +299,10 @@ struct cpp_reader {
#define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data) #define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data)
#define CPP_BUFFER(PFILE) ((PFILE)->buffer) #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
#ifdef STATIC_BUFFERS
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1) #define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1)
#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX]) #define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX])
#else
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->chain)
#define CPP_NULL_BUFFER(PFILE) ((cpp_buffer*)0)
#endif
/* Pointed to by parse_file::data. */ /* Pointed to by cpp_reader::data. */
struct cpp_options { struct cpp_options {
char *in_fname; char *in_fname;
...@@ -551,7 +550,7 @@ typedef struct macrodef MACRODEF; ...@@ -551,7 +550,7 @@ typedef struct macrodef MACRODEF;
struct macrodef struct macrodef
{ {
struct definition *defn; struct definition *defn;
U_CHAR *symnam; unsigned char *symnam;
int symlen; int symlen;
}; };
...@@ -582,7 +581,7 @@ struct definition { ...@@ -582,7 +581,7 @@ struct definition {
int length; /* length of expansion string */ int length; /* length of expansion string */
int predefined; /* True if the macro was builtin or */ int predefined; /* True if the macro was builtin or */
/* came from the command line */ /* came from the command line */
U_CHAR *expansion; unsigned char *expansion;
int line; /* Line number of definition */ int line; /* Line number of definition */
char *file; /* File of definition */ char *file; /* File of definition */
char rest_args; /* Nonzero if last arg. absorbs the rest */ char rest_args; /* Nonzero if last arg. absorbs the rest */
...@@ -602,11 +601,11 @@ struct definition { ...@@ -602,11 +601,11 @@ struct definition {
with comma-space between them. with comma-space between them.
The only use of this is that we warn on redefinition The only use of this is that we warn on redefinition
if this differs between the old and new definitions. */ if this differs between the old and new definitions. */
U_CHAR *argnames; unsigned char *argnames;
} args; } args;
}; };
extern U_CHAR is_idchar[256]; extern unsigned char is_idchar[256];
/* Stack of conditionals currently in progress /* Stack of conditionals currently in progress
(including both successful and failing conditionals). */ (including both successful and failing conditionals). */
...@@ -617,7 +616,7 @@ struct if_stack { ...@@ -617,7 +616,7 @@ struct if_stack {
int lineno; /* similarly */ int lineno; /* similarly */
int if_succeeded; /* true if a leg of this if-group int if_succeeded; /* true if a leg of this if-group
has been passed through rescan */ has been passed through rescan */
U_CHAR *control_macro; /* For #ifndef at start of file, unsigned char *control_macro; /* For #ifndef at start of file,
this is the macro name tested. */ this is the macro name tested. */
enum node_type type; /* type of last directive seen in this group */ enum node_type type; /* type of last directive seen in this group */
}; };
...@@ -625,7 +624,7 @@ typedef struct if_stack IF_STACK_FRAME; ...@@ -625,7 +624,7 @@ typedef struct if_stack IF_STACK_FRAME;
extern void cpp_buf_line_and_col PARAMS((cpp_buffer*, long*, long*)); extern void cpp_buf_line_and_col PARAMS((cpp_buffer*, long*, long*));
extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader*)); extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader*));
extern void cpp_define PARAMS ((cpp_reader*, U_CHAR*)); extern void cpp_define PARAMS ((cpp_reader*, unsigned char*));
extern void cpp_error (); extern void cpp_error ();
extern void cpp_warning (); extern void cpp_warning ();
...@@ -640,10 +639,11 @@ extern void cpp_pfatal_with_name (); ...@@ -640,10 +639,11 @@ extern void cpp_pfatal_with_name ();
extern void cpp_grow_buffer PARAMS ((cpp_reader*, long)); extern void cpp_grow_buffer PARAMS ((cpp_reader*, long));
extern int cpp_parse_escape PARAMS ((cpp_reader*, char**)); extern int cpp_parse_escape PARAMS ((cpp_reader*, char**));
extern cpp_buffer* cpp_push_buffer PARAMS ((cpp_reader *, U_CHAR*, long)); extern cpp_buffer* cpp_push_buffer PARAMS ((cpp_reader *,
unsigned char*, long));
extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *)); extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *));
extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const U_CHAR*, extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const unsigned char*,
int, int)); int, int));
#ifdef __cplusplus #ifdef __cplusplus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment