1 /* Part of CPP library.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
3 2008, 2009, 2010 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 3, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING3. If not see
17 <http://www.gnu.org/licenses/>. */
19 /* This header defines all the internal data structures and functions
20 that need to be visible across files. It should not be used outside
23 #ifndef LIBCPP_INTERNAL_H
24 #define LIBCPP_INTERNAL_H
27 #include "cpp-id-data.h"
33 typedef int iconv_t
; /* dummy */
40 struct directive
; /* Deliberately incomplete. */
41 struct pending_option
;
45 typedef bool (*convert_f
) (iconv_t
, const unsigned char *, size_t,
46 struct _cpp_strbuf
*);
54 #define BITS_PER_CPPCHAR_T (CHAR_BIT * sizeof (cppchar_t))
56 /* Test if a sign is valid within a preprocessing number. */
57 #define VALID_SIGN(c, prevc) \
58 (((c) == '+' || (c) == '-') && \
59 ((prevc) == 'e' || (prevc) == 'E' \
60 || (((prevc) == 'p' || (prevc) == 'P') \
61 && CPP_OPTION (pfile, extended_numbers))))
63 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
64 #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
65 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base)
66 #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur)
68 #define CPP_INCREMENT_LINE(PFILE, COLS_HINT) do { \
69 const struct line_maps *line_table = PFILE->line_table; \
70 const struct line_map *map = &line_table->maps[line_table->used-1]; \
71 linenum_type line = SOURCE_LINE (map, line_table->highest_line); \
72 linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \
75 /* Maximum nesting of cpp_buffers. We use a static limit, partly for
76 efficiency, and partly to limit runaway recursion. */
77 #define CPP_STACK_MAX 200
79 /* Host alignment handling. */
90 #define DEFAULT_ALIGNMENT offsetof (struct dummy, u)
91 #define CPP_ALIGN2(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
92 #define CPP_ALIGN(size) CPP_ALIGN2 (size, DEFAULT_ALIGNMENT)
94 #define _cpp_mark_macro_used(NODE) do { \
95 if ((NODE)->type == NT_MACRO && !((NODE)->flags & NODE_BUILTIN)) \
96 (NODE)->value.macro->used = 1; } while (0)
98 /* A generic memory buffer, and operations on it. */
99 typedef struct _cpp_buff _cpp_buff
;
102 struct _cpp_buff
*next
;
103 unsigned char *base
, *cur
, *limit
;
106 extern _cpp_buff
*_cpp_get_buff (cpp_reader
*, size_t);
107 extern void _cpp_release_buff (cpp_reader
*, _cpp_buff
*);
108 extern void _cpp_extend_buff (cpp_reader
*, _cpp_buff
**, size_t);
109 extern _cpp_buff
*_cpp_append_extend_buff (cpp_reader
*, _cpp_buff
*, size_t);
110 extern void _cpp_free_buff (_cpp_buff
*);
111 extern unsigned char *_cpp_aligned_alloc (cpp_reader
*, size_t);
112 extern unsigned char *_cpp_unaligned_alloc (cpp_reader
*, size_t);
114 #define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur)
115 #define BUFF_FRONT(BUFF) ((BUFF)->cur)
116 #define BUFF_LIMIT(BUFF) ((BUFF)->limit)
120 const cpp_token
*token
;
121 const cpp_token
**ptoken
;
124 /* A "run" of tokens; part of a chain of runs. */
125 typedef struct tokenrun tokenrun
;
128 tokenrun
*next
, *prev
;
129 cpp_token
*base
, *limit
;
132 /* Accessor macros for struct cpp_context. */
133 #define FIRST(c) ((c)->u.iso.first)
134 #define LAST(c) ((c)->u.iso.last)
135 #define CUR(c) ((c)->u.trad.cur)
136 #define RLIMIT(c) ((c)->u.trad.rlimit)
138 typedef struct cpp_context cpp_context
;
141 /* Doubly-linked list. */
142 cpp_context
*next
, *prev
;
146 /* For ISO macro expansion. Contexts other than the base context
147 are contiguous tokens. e.g. macro expansions, expanded
155 /* For traditional macro expansion. */
158 const unsigned char *cur
;
159 const unsigned char *rlimit
;
163 /* If non-NULL, a buffer used for storage related to this context.
164 When the context is popped, the buffer is released. */
167 /* For a macro context, the macro node, otherwise NULL. */
170 /* True if utoken element is token, else ptoken. */
176 /* Nonzero if first token on line is CPP_HASH. */
177 unsigned char in_directive
;
179 /* Nonzero if in a directive that will handle padding tokens itself.
180 #include needs this to avoid problems with computed include and
181 spacing between tokens. */
182 unsigned char directive_wants_padding
;
184 /* True if we are skipping a failed conditional group. */
185 unsigned char skipping
;
187 /* Nonzero if in a directive that takes angle-bracketed headers. */
188 unsigned char angled_headers
;
190 /* Nonzero if in a #if or #elif directive. */
191 unsigned char in_expression
;
193 /* Nonzero to save comments. Turned off if discard_comments, and in
194 all directives apart from #define. */
195 unsigned char save_comments
;
197 /* Nonzero if lexing __VA_ARGS__ is valid. */
198 unsigned char va_args_ok
;
200 /* Nonzero if lexing poisoned identifiers is valid. */
201 unsigned char poisoned_ok
;
203 /* Nonzero to prevent macro expansion. */
204 unsigned char prevent_expansion
;
206 /* Nonzero when parsing arguments to a function-like macro. */
207 unsigned char parsing_args
;
209 /* Nonzero if prevent_expansion is true only because output is
211 unsigned char discarding_output
;
213 /* Nonzero to skip evaluating part of an expression. */
214 unsigned int skip_eval
;
216 /* Nonzero when handling a deferred pragma. */
217 unsigned char in_deferred_pragma
;
219 /* Nonzero if the deferred pragma being handled allows macro expansion. */
220 unsigned char pragma_allow_expansion
;
223 /* Special nodes - identifiers with predefined significance. */
226 cpp_hashnode
*n_defined
; /* defined operator */
227 cpp_hashnode
*n_true
; /* C++ keyword true */
228 cpp_hashnode
*n_false
; /* C++ keyword false */
229 cpp_hashnode
*n__VA_ARGS__
; /* C99 vararg macros */
232 typedef struct _cpp_line_note _cpp_line_note
;
233 struct _cpp_line_note
235 /* Location in the clean line the note refers to. */
236 const unsigned char *pos
;
238 /* Type of note. The 9 'from' trigraph characters represent those
239 trigraphs, '\\' an escaped newline, ' ' an escaped newline with
240 intervening space, 0 represents a note that has already been handled,
241 and anything else is invalid. */
245 /* Represents the contents of a file cpplib has read in. */
248 const unsigned char *cur
; /* Current location. */
249 const unsigned char *line_base
; /* Start of current physical line. */
250 const unsigned char *next_line
; /* Start of to-be-cleaned logical line. */
252 const unsigned char *buf
; /* Entire character buffer. */
253 const unsigned char *rlimit
; /* Writable byte at end of file. */
255 _cpp_line_note
*notes
; /* Array of notes. */
256 unsigned int cur_note
; /* Next note to process. */
257 unsigned int notes_used
; /* Number of notes. */
258 unsigned int notes_cap
; /* Size of allocated array. */
260 struct cpp_buffer
*prev
;
262 /* Pointer into the file table; non-NULL if this is a file buffer.
263 Used for include_next and to record control macros. */
264 struct _cpp_file
*file
;
266 /* Saved value of __TIMESTAMP__ macro - date and time of last modification
267 of the assotiated file. */
268 const unsigned char *timestamp
;
270 /* Value of if_stack at start of this file.
271 Used to prohibit unmatched #endif (etc) in an include file. */
272 struct if_stack
*if_stack
;
274 /* True if we need to get the next clean line. */
277 /* True if we have already warned about C++ comments in this file.
278 The warning happens only for C89 extended mode with -pedantic on,
279 or for -Wtraditional, and only once per file (otherwise it would
280 be far too noisy). */
281 unsigned int warned_cplusplus_comments
: 1;
283 /* True if we don't process trigraphs and escaped newlines. True
284 for preprocessed input, command line directives, and _Pragma
286 unsigned int from_stage3
: 1;
288 /* At EOF, a buffer is automatically popped. If RETURN_AT_EOF is
289 true, a CPP_EOF token is then returned. Otherwise, the next
290 token from the enclosing buffer is returned. */
291 unsigned int return_at_eof
: 1;
293 /* One for a system header, two for a C system header file that therefore
294 needs to be extern "C" protected in C++, and zero otherwise. */
297 /* The directory of the this buffer's file. Its NAME member is not
298 allocated, so we don't need to worry about freeing it. */
301 /* Descriptor for converting from the input character set to the
302 source character set. */
303 struct cset_converter input_cset_desc
;
306 /* The list of saved macros by push_macro pragma. */
307 struct def_pragma_macro
{
308 /* Chain element to previous saved macro. */
309 struct def_pragma_macro
*next
;
310 /* Name of the macro. */
312 /* The stored macro content. */
313 unsigned char *definition
;
315 /* Definition line number. */
316 source_location line
;
317 /* If macro defined in system header. */
318 unsigned int syshdr
: 1;
319 /* Nonzero if it has been expanded or had its existence tested. */
320 unsigned int used
: 1;
322 /* Mark if we save an undefined macro. */
323 unsigned int is_undef
: 1;
327 /* A lookaside identifier table for subsets of the token stream. */
329 /* The lookaside entry. */
331 hashnode node
; /* The entry in hash_table. */
332 unsigned int hash
; /* Hash value. */
333 unsigned int length
; /* Macro value length. */
334 const char *value
; /* Macro value string. */
337 /* The lookaside table. */
338 struct cpp_lookaside
{
339 struct lae
*entries
; /* The entry storage. */
340 unsigned int order
; /* 2^order slots in the entries array. */
341 unsigned int sticky_order
; /* For resizing when capturing the entries. */
342 unsigned int active
; /* Number of active entries. */
343 struct obstack
*strings
; /* For macro value storage. */
344 unsigned int max_ident_len
; /* Largest identifier encountered. */
345 unsigned int max_value_len
; /* Largest macro value encountered. */
347 /* Table usage statistics. */
348 unsigned long long searches
; /* Number of calls to lt_lookup. */
349 unsigned long long comparisons
; /* Key comparisons. */
350 unsigned long long strcmps
; /* Key comparisons using strcmp. */
351 unsigned long long collisions
; /* Found unwanted hash or key. */
352 unsigned long long misses
; /* Searches not found in table. */
353 unsigned long long insertions
; /* Number insertions in table. */
354 unsigned long long macrovalue
; /* Number of macro values computed. */
355 unsigned long long resizes
; /* Had to resize (grow) the table. */
356 unsigned long long bumps
; /* Collisions in the resize process. */
357 unsigned long long iterations
; /* Cells iterated over table. */
358 unsigned long long empties
; /* Number of table empty/capture. */
360 /* Table debugging. */
361 unsigned int pth_debug_level
;
364 /* Lookup an identifer in the lookaside table,
365 and failing that, lookup in the main hash table.
366 The return will always be non-null. */
368 lt_lookup (cpp_reader
*pfile
,
369 const unsigned char *identifier
,
373 /* The hash parameter is obtained with the following function,
374 or with the HT_... macros in include/symtab.h. */
376 ht_calc_hash (const unsigned char *str
, size_t len
);
379 /* A cpp_reader encapsulates the "state" of a pre-processor run.
380 Applying cpp_get_token repeatedly yields a stream of pre-processor
381 tokens. Usually, there is only one cpp_reader object active. */
384 /* Top of buffer stack. */
387 /* Overlaid buffer (can be different after processing #include). */
388 cpp_buffer
*overlaid_buffer
;
391 struct lexer_state state
;
393 /* Source line tracking. */
394 struct line_maps
*line_table
;
396 /* The line of the '#' of the current directive. */
397 source_location directive_line
;
399 /* Memory buffers. */
400 _cpp_buff
*a_buff
; /* Aligned permanent storage. */
401 _cpp_buff
*u_buff
; /* Unaligned permanent storage. */
402 _cpp_buff
*free_buffs
; /* Free buffer chain. */
405 struct cpp_context base_context
;
406 struct cpp_context
*context
;
408 /* If in_directive, the directive if known. */
409 const struct directive
*directive
;
411 /* Token generated while handling a directive, if any. */
412 cpp_token directive_result
;
414 /* When expanding a macro at top-level, this is the location of the
416 source_location invocation_location
;
418 /* True if this call to cpp_get_token should consider setting
419 invocation_location. */
420 bool set_invocation_location
;
422 /* Search paths for include files. */
423 struct cpp_dir
*quote_include
; /* "" */
424 struct cpp_dir
*bracket_include
; /* <> */
425 struct cpp_dir no_search_path
; /* No path. */
427 /* Chain of all hashed _cpp_file instances. */
428 struct _cpp_file
*all_files
;
430 struct _cpp_file
*main_file
;
432 /* File and directory hash table. */
433 struct htab
*file_hash
;
434 struct htab
*dir_hash
;
435 struct file_hash_entry_pool
*file_hash_entries
;
437 /* Negative path lookup hash table. */
438 struct htab
*nonexistent_file_hash
;
439 struct obstack nonexistent_file_ob
;
441 /* Nonzero means don't look for #include "foo" the source-file
443 bool quote_ignores_source_dir
;
445 /* Nonzero if any file has contained #pragma once or #import has
449 /* Multiple include optimization. */
450 const cpp_hashnode
*mi_cmacro
;
451 const cpp_hashnode
*mi_ind_cmacro
;
455 cpp_token
*cur_token
;
456 tokenrun base_run
, *cur_run
;
457 unsigned int lookaheads
;
459 /* Nonzero prevents the lexer from re-using the token runs. */
460 unsigned int keep_tokens
;
462 /* Buffer to hold macro definition string. */
463 unsigned char *macro_buffer
;
464 unsigned int macro_buffer_len
;
466 /* Buffer to save parameter values during macro parameter processing. */
467 union _cpp_hashnode_value
*param_buffer
;
468 unsigned int param_buffer_len
;
470 /* Descriptor for converting from the source character set to the
471 execution character set. */
472 struct cset_converter narrow_cset_desc
;
474 /* Descriptor for converting from the source character set to the
475 UTF-8 execution character set. */
476 struct cset_converter utf8_cset_desc
;
478 /* Descriptor for converting from the source character set to the
479 UTF-16 execution character set. */
480 struct cset_converter char16_cset_desc
;
482 /* Descriptor for converting from the source character set to the
483 UTF-32 execution character set. */
484 struct cset_converter char32_cset_desc
;
486 /* Descriptor for converting from the source character set to the
487 wide execution character set. */
488 struct cset_converter wide_cset_desc
;
490 /* Date and time text. Calculated together if either is requested. */
491 const unsigned char *date
;
492 const unsigned char *time
;
494 /* EOF token, and a token forcing paste avoidance. */
495 cpp_token avoid_paste
;
498 /* Opaque handle to the dependencies of mkdeps.c. */
501 /* Obstack holding all macro hash nodes. This never shrinks.
503 struct obstack hash_ob
;
505 /* Obstack holding buffer and conditional structures. This is a
506 real stack. See directives.c. */
507 struct obstack buffer_ob
;
509 /* Pragma table - dynamic, because a library user can add to the
510 list of recognized pragmas. */
511 struct pragma_entry
*pragmas
;
513 /* Call backs to cpplib client. */
514 struct cpp_callbacks cb
;
516 /* Identifier hash table. */
517 struct ht
*hash_table
;
518 cpp_lookaside
*lookaside_table
;
520 /* Expression parser stack. */
521 struct op
*op_stack
, *op_limit
;
523 /* User visible options. */
524 struct cpp_options opts
;
526 /* Special nodes - identifiers with predefined significance to the
528 struct spec_nodes spec_nodes
;
530 /* Whether cpplib owns the hashtable. */
533 /* Traditional preprocessing output buffer (a logical line). */
537 unsigned char *limit
;
539 source_location first_line
;
542 /* Used for buffer overlays by traditional.c. */
543 const unsigned char *saved_cur
, *saved_rlimit
, *saved_line_base
;
545 /* A saved list of the defined macros, for dependency checking
546 of precompiled headers. */
547 struct cpp_savedstate
*savedstate
;
549 /* Next value of __COUNTER__ macro. */
550 unsigned int counter
;
552 /* Table of comments, when state.save_comments is true. */
553 cpp_comment_table comments
;
555 /* List of saved macros by push_macro. */
556 struct def_pragma_macro
*pushed_macros
;
559 /* Character classes. Based on the more primitive macros in safe-ctype.h.
560 If the definition of `numchar' looks odd to you, please look up the
561 definition of a pp-number in the C standard [section 6.4.8 of C99].
563 In the unlikely event that characters other than \r and \n enter
564 the set is_vspace, the macro handle_newline() in lex.c must be
566 #define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
568 #define is_idchar(x) (ISIDNUM(x) || _dollar_ok(x))
569 #define is_numchar(x) ISIDNUM(x)
570 #define is_idstart(x) (ISIDST(x) || _dollar_ok(x))
571 #define is_numstart(x) ISDIGIT(x)
572 #define is_hspace(x) ISBLANK(x)
573 #define is_vspace(x) IS_VSPACE(x)
574 #define is_nvspace(x) IS_NVSPACE(x)
575 #define is_space(x) IS_SPACE_OR_NUL(x)
577 /* This table is constant if it can be initialized at compile time,
578 which is the case if cpp was compiled with GCC >=2.7, or another
579 compiler that supports C99. */
580 #if HAVE_DESIGNATED_INITIALIZERS
581 extern const unsigned char _cpp_trigraph_map
[UCHAR_MAX
+ 1];
583 extern unsigned char _cpp_trigraph_map
[UCHAR_MAX
+ 1];
588 static inline int cpp_in_system_header (cpp_reader
*);
590 cpp_in_system_header (cpp_reader
*pfile
)
592 return pfile
->buffer
? pfile
->buffer
->sysp
: 0;
594 #define CPP_PEDANTIC(PF) CPP_OPTION (PF, cpp_pedantic)
595 #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, cpp_warn_traditional)
597 static inline int cpp_in_primary_file (cpp_reader
*);
599 cpp_in_primary_file (cpp_reader
*pfile
)
601 return pfile
->line_table
->depth
== 1;
605 extern void _cpp_free_definition (cpp_hashnode
*);
606 extern bool _cpp_create_definition (cpp_reader
*, cpp_hashnode
*);
607 extern void _cpp_pop_context (cpp_reader
*);
608 extern void _cpp_push_text_context (cpp_reader
*, cpp_hashnode
*,
609 const unsigned char *, size_t);
610 extern bool _cpp_save_parameter (cpp_reader
*, cpp_macro
*, cpp_hashnode
*);
611 extern bool _cpp_arguments_ok (cpp_reader
*, cpp_macro
*, const cpp_hashnode
*,
613 extern const unsigned char *_cpp_builtin_macro_text (cpp_reader
*,
615 extern int _cpp_warn_if_unused_macro (cpp_reader
*, cpp_hashnode
*, void *);
616 extern void _cpp_push_token_context (cpp_reader
*, cpp_hashnode
*,
617 const cpp_token
*, unsigned int);
618 extern void _cpp_backup_tokens_direct (cpp_reader
*, unsigned int);
620 /* In identifiers.c */
621 extern void _cpp_init_hashtable (cpp_reader
*, hash_table
*);
622 extern void _cpp_destroy_hashtable (cpp_reader
*);
625 typedef struct _cpp_file _cpp_file
;
626 extern _cpp_file
*_cpp_find_file (cpp_reader
*, const char *, cpp_dir
*,
628 extern bool _cpp_find_failed (_cpp_file
*);
629 extern void _cpp_mark_file_once_only (cpp_reader
*, struct _cpp_file
*);
630 extern void _cpp_fake_include (cpp_reader
*, const char *);
631 extern bool _cpp_stack_file (cpp_reader
*, _cpp_file
*, bool);
632 extern bool _cpp_stack_include (cpp_reader
*, const char *, const char *, int,
634 extern int _cpp_compare_file_date (cpp_reader
*, const char *, int);
635 extern void _cpp_report_missing_guards (cpp_reader
*);
636 extern void _cpp_init_files (cpp_reader
*);
637 extern void _cpp_cleanup_files (cpp_reader
*);
638 extern void _cpp_pop_file_buffer (cpp_reader
*, struct _cpp_file
*);
639 extern bool _cpp_save_file_entries (cpp_reader
*pfile
, FILE *f
);
640 extern bool _cpp_read_file_entries (cpp_reader
*, FILE *);
641 extern struct stat
*_cpp_get_file_stat (_cpp_file
*);
644 extern bool _cpp_parse_expr (cpp_reader
*, bool);
645 extern struct op
*_cpp_expand_op_stack (cpp_reader
*);
648 extern void _cpp_process_line_notes (cpp_reader
*, int);
649 extern void _cpp_clean_line (cpp_reader
*);
650 extern bool _cpp_get_fresh_line (cpp_reader
*);
651 extern bool _cpp_skip_block_comment (cpp_reader
*);
652 extern cpp_token
*_cpp_temp_token (cpp_reader
*);
653 extern const cpp_token
*_cpp_lex_token (cpp_reader
*);
654 extern cpp_token
*_cpp_lex_direct (cpp_reader
*);
655 extern int _cpp_equiv_tokens (const cpp_token
*, const cpp_token
*);
656 extern void _cpp_init_tokenrun (tokenrun
*, unsigned int);
657 extern cpp_hashnode
*_cpp_lex_identifier (cpp_reader
*, const char *);
660 extern void _cpp_maybe_push_include_file (cpp_reader
*);
661 extern const char *cpp_named_operator2name (enum cpp_ttype type
);
663 /* In directives.c */
664 extern int _cpp_test_assertion (cpp_reader
*, unsigned int *);
665 extern int _cpp_handle_directive (cpp_reader
*, int);
666 extern void _cpp_define_builtin (cpp_reader
*, const char *);
667 extern char ** _cpp_save_pragma_names (cpp_reader
*);
668 extern void _cpp_restore_pragma_names (cpp_reader
*, char **);
669 extern int _cpp_do__Pragma (cpp_reader
*);
670 extern void _cpp_init_directives (cpp_reader
*);
671 extern void _cpp_init_internal_pragmas (cpp_reader
*);
672 extern void _cpp_do_file_change (cpp_reader
*, enum lc_reason
, const char *,
673 linenum_type
, unsigned int);
674 extern void _cpp_pop_buffer (cpp_reader
*);
676 /* In directives.c */
677 struct _cpp_dir_only_callbacks
679 /* Called to print a block of lines. */
680 void (*print_lines
) (int, const void *, size_t);
681 void (*maybe_print_line
) (source_location
);
684 extern void _cpp_preprocess_dir_only (cpp_reader
*,
685 const struct _cpp_dir_only_callbacks
*);
687 /* In traditional.c. */
688 extern bool _cpp_scan_out_logical_line (cpp_reader
*, cpp_macro
*);
689 extern bool _cpp_read_logical_line_trad (cpp_reader
*);
690 extern void _cpp_overlay_buffer (cpp_reader
*pfile
, const unsigned char *,
692 extern void _cpp_remove_overlay (cpp_reader
*);
693 extern bool _cpp_create_trad_definition (cpp_reader
*, cpp_macro
*);
694 extern bool _cpp_expansions_different_trad (const cpp_macro
*,
696 extern unsigned char *_cpp_copy_replacement_text (const cpp_macro
*,
698 extern size_t _cpp_replacement_text_len (const cpp_macro
*);
702 /* The normalization state at this point in the sequence.
703 It starts initialized to all zeros, and at the end
704 'level' is the normalization level of the sequence. */
706 struct normalize_state
708 /* The previous character. */
710 /* The combining class of the previous character. */
711 unsigned char prev_class
;
712 /* The lowest normalization level so far. */
713 enum cpp_normalize_level level
;
715 #define INITIAL_NORMALIZE_STATE { 0, 0, normalized_KC }
716 #define NORMALIZE_STATE_RESULT(st) ((st)->level)
718 /* We saw a character that matches ISIDNUM(), update a
719 normalize_state appropriately. */
720 #define NORMALIZE_STATE_UPDATE_IDNUM(st) \
721 ((st)->previous = 0, (st)->prev_class = 0)
723 extern cppchar_t
_cpp_valid_ucn (cpp_reader
*, const unsigned char **,
724 const unsigned char *, int,
725 struct normalize_state
*state
);
726 extern void _cpp_destroy_iconv (cpp_reader
*);
727 extern unsigned char *_cpp_convert_input (cpp_reader
*, const char *,
728 unsigned char *, size_t, size_t,
729 const unsigned char **, off_t
*);
730 extern const char *_cpp_default_encoding (void);
731 extern cpp_hashnode
* _cpp_interpret_identifier (cpp_reader
*pfile
,
732 const unsigned char *id
,
735 /* Utility routines and macros. */
736 #define DSC(str) (const unsigned char *)str, sizeof str - 1
738 /* These are inline functions instead of macros so we can get type
740 static inline int ustrcmp (const unsigned char *, const unsigned char *);
741 static inline int ustrncmp (const unsigned char *, const unsigned char *,
743 static inline size_t ustrlen (const unsigned char *);
744 static inline unsigned char *uxstrdup (const unsigned char *);
745 static inline unsigned char *ustrchr (const unsigned char *, int);
746 static inline int ufputs (const unsigned char *, FILE *);
748 /* Use a const char for the second parameter since it is usually a literal. */
749 static inline int ustrcspn (const unsigned char *, const char *);
752 ustrcmp (const unsigned char *s1
, const unsigned char *s2
)
754 return strcmp ((const char *)s1
, (const char *)s2
);
758 ustrncmp (const unsigned char *s1
, const unsigned char *s2
, size_t n
)
760 return strncmp ((const char *)s1
, (const char *)s2
, n
);
764 ustrcspn (const unsigned char *s1
, const char *s2
)
766 return strcspn ((const char *)s1
, s2
);
770 ustrlen (const unsigned char *s1
)
772 return strlen ((const char *)s1
);
775 static inline unsigned char *
776 uxstrdup (const unsigned char *s1
)
778 return (unsigned char *) xstrdup ((const char *)s1
);
781 static inline unsigned char *
782 ustrchr (const unsigned char *s1
, int c
)
784 return (unsigned char *) strchr ((const char *)s1
, c
);
788 ufputs (const unsigned char *s
, FILE *f
)
790 return fputs ((const char *)s
, f
);
797 #endif /* ! LIBCPP_INTERNAL_H */