+2001-01-13 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cppinit.c (cpp_handle_option): help_only is now part of the
+ cpp_options structure.
+ * cpplib.c (cpp_errors, cpp_get_options, cpp_get_callbacks,
+ cpp_set_callbacks): New functions.
+ * cpplib.h (cpp_callbacks): Break out as a named structure.
+ (cpp_options): Move help_only here from cpp_reader.
+ (CPP_FATAL_ERRORS): Update to use cpp_errors.
+ (cpp_errors, cpp_get_options, cpp_get_callbacks,
+ cpp_set_callbacks): New prototypes.
+ * cppmain.c (main): Update for help_only.
+
2001-01-13 Joseph S. Myers <jsm28@cam.ac.uk>
* Makefile.in (info, maintainer-clean, install-info, uninstall):
typedef struct cpp_macro cpp_macro;
typedef struct cpp_lexer_pos cpp_lexer_pos;
typedef struct cpp_lookahead cpp_lookahead;
+typedef struct cpp_callbacks cpp_callbacks;
struct directive; /* These are deliberately incomplete. */
struct answer;
/* Treat C++ alternate operator names special. */
unsigned char operator_names;
+
+ /* True if --help, --version or --target-help appeared in the
+ options. Stand-alone CPP should then bail out after option
+ parsing; drivers might want to continue printing help. */
+ unsigned char help_only;
};
struct lexer_state
unsigned char externc; /* Nonzero if wrapper needed. */
};
+/* Call backs. */
+struct cpp_callbacks
+{
+ void (*file_change) PARAMS ((cpp_reader *, const cpp_file_change *));
+ void (*include) PARAMS ((cpp_reader *, const unsigned char *,
+ const cpp_token *));
+ void (*define) PARAMS ((cpp_reader *, cpp_hashnode *));
+ void (*undef) PARAMS ((cpp_reader *, cpp_hashnode *));
+ void (*poison) PARAMS ((cpp_reader *));
+ void (*ident) PARAMS ((cpp_reader *, const cpp_string *));
+ void (*def_pragma) PARAMS ((cpp_reader *));
+};
+
/* 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 pragma_entry *pragmas;
/* Call backs. */
- struct {
- void (*file_change) PARAMS ((cpp_reader *, const cpp_file_change *));
- void (*include) PARAMS ((cpp_reader *, const unsigned char *,
- const cpp_token *));
- void (*define) PARAMS ((cpp_reader *, cpp_hashnode *));
- void (*undef) PARAMS ((cpp_reader *, cpp_hashnode *));
- void (*poison) PARAMS ((cpp_reader *));
- void (*ident) PARAMS ((cpp_reader *, const cpp_string *));
- void (*def_pragma) PARAMS ((cpp_reader *));
- } cb;
+ struct cpp_callbacks cb;
/* User visible options. */
struct cpp_options opts;
/* True if we are skipping a failed conditional group. */
unsigned char skipping;
-
- /* True if --help appeared in the options. Caller should then bail
- out after option parsing and printing its own help. See cppmain.c. */
- unsigned char help_only;
};
#define CPP_FATAL_LIMIT 1000
/* True if we have seen a "fatal" error. */
-#define CPP_FATAL_ERRORS(READER) ((READER)->errors >= CPP_FATAL_LIMIT)
+#define CPP_FATAL_ERRORS(PFILE) (cpp_errors (PFILE) >= CPP_FATAL_LIMIT)
#define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
/* Call this first to get a handle to pass to other functions. */
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
+/* Call these to get pointers to the options and callback structures
+ for a given reader. These pointers are good until you call
+ cpp_finish on that reader. You can either edit the callbacks
+ through the pointer returned from cpp_get_callbacks, or set them
+ with cpp_set_callbacks. */
+extern cpp_options *cpp_get_options PARAMS ((cpp_reader *));
+extern cpp_callbacks *cpp_get_callbacks PARAMS ((cpp_reader *));
+extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
+
/* Now call cpp_handle_option[s] to handle 1[or more] switches. The
return value is the number of arguments used. If
cpp_handle_options returns without using all arguments, it couldn't
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_post_options PARAMS ((cpp_reader *));
+/* Error count. */
+extern unsigned int cpp_errors PARAMS ((cpp_reader *));
+
extern unsigned int cpp_token_len PARAMS ((const cpp_token *));
extern unsigned char *cpp_token_as_text PARAMS ((cpp_reader *,
const cpp_token *));