#include "config.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
static int skip_whitespace PARAMS ((cpp_reader *, cppchar_t));
static cpp_hashnode *parse_identifier PARAMS ((cpp_reader *));
static uchar *parse_slow PARAMS ((cpp_reader *, const uchar *, int,
- unsigned int *));
+ unsigned int *));
static void parse_number PARAMS ((cpp_reader *, cpp_string *, int));
static int unescaped_terminator_p PARAMS ((cpp_reader *, const uchar *));
static void parse_string PARAMS ((cpp_reader *, cpp_token *, cppchar_t));
cpp_buffer *buffer = pfile->buffer;
/* Handle CR-LF and LF-CR. Most other implementations (e.g. java)
- only accept CR-LF; maybe we should fall back to that behaviour? */
+ only accept CR-LF; maybe we should fall back to that behavior? */
if (buffer->cur[-1] + buffer->cur[0] == '\r' + '\n')
buffer->cur++;
the second '?'.
Warn if necessary, and returns true if the sequence forms a
- trigraph and the trigraph should be honoured. */
+ trigraph and the trigraph should be honored. */
static bool
trigraph_p (pfile)
cpp_reader *pfile;
if (__builtin_expect (next == '?' || next == '\\', 0))
next = skip_escaped_newlines (pfile);
- return next;
+ return next;
}
/* Skip a C-style block comment. We find the end of the comment by
seeing if an asterisk is before every '/' we encounter. Returns
- non-zero if comment terminated by EOF, zero otherwise. */
+ nonzero if comment terminated by EOF, zero otherwise. */
static int
skip_block_comment (pfile)
cpp_reader *pfile;
}
/* Skip a C++ line comment, leaving buffer->cur pointing to the
- terminating newline. Handles escaped newlines. Returns non-zero
+ terminating newline. Handles escaped newlines. Returns nonzero
if a multiline comment. */
static int
skip_line_comment (pfile)
if (!is_idchar (string->text[i]))
return 0;
- return 1;
+ return 1;
}
/* Parse an identifier, skipping embedded backslash-newlines. This is
/* Handle normal identifier characters in this loop. */
do
- {
+ {
prevc = c;
- obstack_1grow (stack, c);
+ obstack_1grow (stack, c);
- if (c == '$')
- saw_dollar++;
+ if (c == '$')
+ saw_dollar++;
- c = *buffer->cur++;
- }
+ c = *buffer->cur++;
+ }
while (is_idchar (c));
}
}
/* Parse a number, beginning with character C, skipping embedded
- backslash-newlines. LEADING_PERIOD is non-zero if there was a "."
+ backslash-newlines. LEADING_PERIOD is nonzero if there was a "."
before C. Place the result in NUMBER. */
static void
parse_number (pfile, number, leading_period)
if (char_len == -1)
{
cpp_error (pfile, DL_WARNING,
- "ignoring invalid multibyte character");
+ "ignoring invalid multibyte character");
char_len = 1;
c = *buffer->cur++;
}
{
unsigned char *buffer;
unsigned int len, clen;
-
+
len = pfile->buffer->cur - from + 1; /* + 1 for the initial '/'. */
/* C++ comments probably (not definitely) have moved past a new
clen = (pfile->state.in_directive && type == '/') ? len + 2 : len;
buffer = _cpp_unaligned_alloc (pfile, clen);
-
+
token->type = CPP_COMMENT;
token->val.str.len = clen;
token->val.str.text = buffer;
{
cpp_buffer *buffer = pfile->buffer;
bool more = false;
-
+
buffer->saved_flags = BOL;
if (CPP_OPTION (pfile, traditional))
- more = _cpp_read_logical_line_trad (pfile);
+ {
+ if (pfile->state.in_directive)
+ return false;
+
+ _cpp_remove_overlay (pfile);
+ more = _cpp_read_logical_line_trad (pfile);
+ _cpp_overlay_buffer (pfile, pfile->out.base,
+ pfile->out.cur - pfile->out.base);
+ pfile->line = pfile->out.first_line;
+ }
else
{
/* Stop parsing arguments with a CPP_EOF. When we finally come
case 'L':
/* 'L' may introduce wide characters or strings. */
- {
- const unsigned char *pos = buffer->cur;
+ {
+ const unsigned char *pos = buffer->cur;
- c = get_effective_char (pfile);
- if (c == '\'' || c == '"')
- {
- result->type = (c == '"' ? CPP_WSTRING: CPP_WCHAR);
- parse_string (pfile, result, c);
- break;
- }
- buffer->cur = pos;
- }
- /* Fall through. */
+ c = get_effective_char (pfile);
+ if (c == '\'' || c == '"')
+ {
+ result->type = (c == '"' ? CPP_WSTRING: CPP_WCHAR);
+ parse_string (pfile, result, c);
+ break;
+ }
+ buffer->cur = pos;
+ }
+ /* Fall through. */
start_ident:
case '_':
if (result->val.node->flags & NODE_OPERATOR)
{
result->flags |= NAMED_OP;
- result->type = result->val.node->value.operator;
+ result->type = result->val.node->directive_index;
}
break;
&& ! buffer->warned_cplusplus_comments)
{
cpp_error (pfile, DL_PEDWARN,
- "C++ style comments are not allowed in ISO C89");
+ "C++ style comments are not allowed in ISO C90");
cpp_error (pfile, DL_PEDWARN,
"(this will be reported only once per input file)");
buffer->warned_cplusplus_comments = 1;
result->type = CPP_AND;
}
break;
-
+
case '|':
c = get_effective_char (pfile);
if (c == '|')
case '}': result->type = CPP_CLOSE_BRACE; break;
case ';': result->type = CPP_SEMICOLON; break;
- /* @ is a punctuator in Objective C. */
+ /* @ is a punctuator in Objective-C. */
case '@': result->type = CPP_ATSIGN; break;
case '$':
goto spell_ident;
else
spelling = TOKEN_NAME (token);
-
+
while ((c = *spelling++) != '\0')
*buffer++ = c;
}
"non-ISO-standard escape sequence, '\\%c'", (int) c);
c = TARGET_ESC;
break;
-
+
case 'u': case 'U':
unknown = maybe_read_ucs (pfile, &str, limit, &c);
break;
cpp_error (pfile, DL_WARNING,
"the meaning of '\\x' is different in traditional C");
- {
- cppchar_t i = 0, overflow = 0;
- int digits_found = 0;
+ {
+ cppchar_t i = 0, overflow = 0;
+ int digits_found = 0;
- while (str < limit)
- {
- c = *str;
- if (! ISXDIGIT (c))
- break;
- str++;
- overflow |= i ^ (i << 4 >> 4);
- i = (i << 4) + hex_digit_value (c);
- digits_found = 1;
- }
+ while (str < limit)
+ {
+ c = *str;
+ if (! ISXDIGIT (c))
+ break;
+ str++;
+ overflow |= i ^ (i << 4 >> 4);
+ i = (i << 4) + hex_digit_value (c);
+ digits_found = 1;
+ }
- if (!digits_found)
- cpp_error (pfile, DL_ERROR,
+ if (!digits_found)
+ cpp_error (pfile, DL_ERROR,
"\\x used with no following hex digits");
- if (overflow | (i != (i & mask)))
- {
- cpp_error (pfile, DL_PEDWARN,
- "hex escape sequence out of range");
- i &= mask;
- }
- c = i;
- }
+ if (overflow | (i != (i & mask)))
+ {
+ cpp_error (pfile, DL_PEDWARN,
+ "hex escape sequence out of range");
+ i &= mask;
+ }
+ c = i;
+ }
break;
case '0': case '1': case '2': case '3':
if (ISPRINT (c))
c = MAP_CHARACTER (c);
#endif
-
+
chars_seen++;
/* Truncate the character, scale the result and merge the two. */
#error BUFF_SIZE_UPPER_BOUND must be at least as large as MIN_BUFF_SIZE!
#endif
-struct dummy
-{
- char c;
- union
- {
- double d;
- int *p;
- } u;
-};
-
-#define DEFAULT_ALIGNMENT (offsetof (struct dummy, u))
-#define CPP_ALIGN(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
-
/* Create a new allocation buffer. Place the control block at the end
of the buffer, so that buffer overflows will cause immediate chaos. */
static _cpp_buff *
if (len < MIN_BUFF_SIZE)
len = MIN_BUFF_SIZE;
- len = CPP_ALIGN (len, DEFAULT_ALIGNMENT);
+ len = CPP_ALIGN (len);
base = xmalloc (len + sizeof (_cpp_buff));
result = (_cpp_buff *) (base + len);