extern "C" {
#endif
-#define STATIC_BUFFERS
-
typedef unsigned char U_CHAR;
struct parse_file;
extern void cpp_skip_hspace 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. */
long line_base;
long lineno; /* Line 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_cleanup_t cleanup;
void *data;
char seen_eof;
/* 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 a token-separator. This turns into " " in final output
if not stringizing and needed to separate tokens; otherwise nothing.
typedef struct assertion_hashnode ASSERTION_HASHNODE;
#define ASSERTION_HASHSIZE 37
-#ifdef STATIC_BUFFERS
/* Maximum nesting of cpp_buffers. We use a static limit, partly for
efficiency, and partly to limit runaway recursion. */
#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 {
- unsigned char *limit;
parse_underflow_t get_token;
cpp_buffer *buffer;
-#ifdef STATIC_BUFFERS
cpp_buffer buffer_stack[CPP_STACK_MAX];
-#endif
int errors; /* Error counter for exit code */
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;
+ /* End of the written part of token_buffer. */
+ unsigned char *limit;
/* Line where a newline was first seen in a string constant. */
int multiline_string_line;
/* Number of bytes since the last newline. */
int deps_column;
+
+#ifdef __cplusplus
+ ~cpp_reader () { cpp_cleanup (this); }
+#endif
};
#define CPP_BUF_PEEK(BUFFER) \
#define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data)
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
-#ifdef STATIC_BUFFERS
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1)
#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 {
char *in_fname;
struct macrodef
{
struct definition *defn;
- U_CHAR *symnam;
+ unsigned char *symnam;
int symlen;
};
int length; /* length of expansion string */
int predefined; /* True if the macro was builtin or */
/* came from the command line */
- U_CHAR *expansion;
+ unsigned char *expansion;
int line; /* Line number of definition */
char *file; /* File of definition */
char rest_args; /* Nonzero if last arg. absorbs the rest */
with comma-space between them.
The only use of this is that we warn on redefinition
if this differs between the old and new definitions. */
- U_CHAR *argnames;
+ unsigned char *argnames;
} args;
};
-extern U_CHAR is_idchar[256];
+extern unsigned char is_idchar[256];
/* Stack of conditionals currently in progress
(including both successful and failing conditionals). */
int lineno; /* similarly */
int if_succeeded; /* true if a leg of this if-group
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. */
enum node_type type; /* type of last directive seen in this group */
};
extern void cpp_buf_line_and_col PARAMS((cpp_buffer*, long*, long*));
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_warning ();
extern void cpp_grow_buffer PARAMS ((cpp_reader*, long));
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_hashnode* cpp_lookup PARAMS ((cpp_reader*, const U_CHAR*,
+extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const unsigned char*,
int, int));
#ifdef __cplusplus