summaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-17 06:17:44 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-17 06:17:44 +0000
commitf7fdd7a16eaaf894ba417c0a9279843c14643fee (patch)
treeaba39e5edc2926935bd59dd4f66f9b3d59447d19 /gcc/cpplex.c
parent1443120075ac9113770189749d39ca2e28fd2b82 (diff)
downloadgcc-f7fdd7a16eaaf894ba417c0a9279843c14643fee.tar.gz
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c * cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to ISO C: new-style function declarations, no need for PARAMS, no special punctuation on indirect function calls, use string constant concatenation where convenient. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68070 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c214
1 files changed, 70 insertions, 144 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index c63574383d8..6933e75035b 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -52,24 +52,23 @@ static const struct token_spelling token_spellings[N_TTYPES] = { TTYPE_TABLE };
#define TOKEN_SPELL(token) (token_spellings[(token)->type].category)
#define TOKEN_NAME(token) (token_spellings[(token)->type].name)
-static void add_line_note PARAMS ((cpp_buffer *, const uchar *, unsigned int));
-static int skip_line_comment PARAMS ((cpp_reader *));
-static void skip_whitespace PARAMS ((cpp_reader *, cppchar_t));
-static cpp_hashnode *lex_identifier PARAMS ((cpp_reader *, const uchar *));
-static void lex_number PARAMS ((cpp_reader *, cpp_string *));
-static bool forms_identifier_p PARAMS ((cpp_reader *, int));
-static void lex_string PARAMS ((cpp_reader *, cpp_token *, const uchar *));
-static void save_comment PARAMS ((cpp_reader *, cpp_token *, const uchar *,
- cppchar_t));
-static void create_literal PARAMS ((cpp_reader *, cpp_token *, const uchar *,
- unsigned int, enum cpp_ttype));
-static bool warn_in_comment PARAMS ((cpp_reader *, _cpp_line_note *));
-static int name_p PARAMS ((cpp_reader *, const cpp_string *));
-static cppchar_t maybe_read_ucn PARAMS ((cpp_reader *, const uchar **));
-static tokenrun *next_tokenrun PARAMS ((tokenrun *));
-
-static unsigned int hex_digit_value PARAMS ((unsigned int));
-static _cpp_buff *new_buff PARAMS ((size_t));
+static void add_line_note (cpp_buffer *, const uchar *, unsigned int);
+static int skip_line_comment (cpp_reader *);
+static void skip_whitespace (cpp_reader *, cppchar_t);
+static cpp_hashnode *lex_identifier (cpp_reader *, const uchar *);
+static void lex_number (cpp_reader *, cpp_string *);
+static bool forms_identifier_p (cpp_reader *, int);
+static void lex_string (cpp_reader *, cpp_token *, const uchar *);
+static void save_comment (cpp_reader *, cpp_token *, const uchar *, cppchar_t);
+static void create_literal (cpp_reader *, cpp_token *, const uchar *,
+ unsigned int, enum cpp_ttype);
+static bool warn_in_comment (cpp_reader *, _cpp_line_note *);
+static int name_p (cpp_reader *, const cpp_string *);
+static cppchar_t maybe_read_ucn (cpp_reader *, const uchar **);
+static tokenrun *next_tokenrun (tokenrun *);
+
+static unsigned int hex_digit_value (unsigned int);
+static _cpp_buff *new_buff (size_t);
/* Utility routine:
@@ -77,9 +76,7 @@ static _cpp_buff *new_buff PARAMS ((size_t));
Compares, the token TOKEN to the NUL-terminated string STRING.
TOKEN must be a CPP_NAME. Returns 1 for equal, 0 for unequal. */
int
-cpp_ideq (token, string)
- const cpp_token *token;
- const char *string;
+cpp_ideq (const cpp_token *token, const char *string)
{
if (token->type != CPP_NAME)
return 0;
@@ -90,10 +87,7 @@ cpp_ideq (token, string)
/* Record a note TYPE at byte POS into the current cleaned logical
line. */
static void
-add_line_note (buffer, pos, type)
- cpp_buffer *buffer;
- const uchar *pos;
- unsigned int type;
+add_line_note (cpp_buffer *buffer, const uchar *pos, unsigned int type)
{
if (buffer->notes_used == buffer->notes_cap)
{
@@ -110,8 +104,7 @@ add_line_note (buffer, pos, type)
/* Returns with a logical line that contains no escaped newlines or
trigraphs. This is a time-critical inner loop. */
void
-_cpp_clean_line (pfile)
- cpp_reader *pfile;
+_cpp_clean_line (cpp_reader *pfile)
{
cpp_buffer *buffer;
const uchar *s;
@@ -184,9 +177,7 @@ _cpp_clean_line (pfile)
/* Return true if the trigraph indicated by NOTE should be warned
about in a comment. */
static bool
-warn_in_comment (pfile, note)
- cpp_reader *pfile;
- _cpp_line_note *note;
+warn_in_comment (cpp_reader *pfile, _cpp_line_note *note)
{
const uchar *p;
@@ -214,9 +205,7 @@ warn_in_comment (pfile, note)
/* Process the notes created by add_line_note as far as the current
location. */
void
-_cpp_process_line_notes (pfile, in_comment)
- cpp_reader *pfile;
- int in_comment;
+_cpp_process_line_notes (cpp_reader *pfile, int in_comment)
{
cpp_buffer *buffer = pfile->buffer;
@@ -275,8 +264,7 @@ _cpp_process_line_notes (pfile, in_comment)
Buffer->cur points to the initial asterisk of the comment. */
bool
-_cpp_skip_block_comment (pfile)
- cpp_reader *pfile;
+_cpp_skip_block_comment (cpp_reader *pfile)
{
cpp_buffer *buffer = pfile->buffer;
cppchar_t c;
@@ -324,8 +312,7 @@ _cpp_skip_block_comment (pfile)
terminating newline. Handles escaped newlines. Returns nonzero
if a multiline comment. */
static int
-skip_line_comment (pfile)
- cpp_reader *pfile;
+skip_line_comment (cpp_reader *pfile)
{
cpp_buffer *buffer = pfile->buffer;
unsigned int orig_line = pfile->line;
@@ -339,9 +326,7 @@ skip_line_comment (pfile)
/* Skips whitespace, saving the next non-whitespace character. */
static void
-skip_whitespace (pfile, c)
- cpp_reader *pfile;
- cppchar_t c;
+skip_whitespace (cpp_reader *pfile, cppchar_t c)
{
cpp_buffer *buffer = pfile->buffer;
bool saw_NUL = false;
@@ -374,9 +359,7 @@ skip_whitespace (pfile, c)
/* See if the characters of a number token are valid in a name (no
'.', '+' or '-'). */
static int
-name_p (pfile, string)
- cpp_reader *pfile;
- const cpp_string *string;
+name_p (cpp_reader *pfile, const cpp_string *string)
{
unsigned int i;
@@ -390,9 +373,7 @@ name_p (pfile, string)
/* Returns TRUE if the sequence starting at buffer->cur is invalid in
an identifier. FIRST is TRUE if this starts an identifier. */
static bool
-forms_identifier_p (pfile, first)
- cpp_reader *pfile;
- int first;
+forms_identifier_p (cpp_reader *pfile, int first)
{
cpp_buffer *buffer = pfile->buffer;
@@ -426,9 +407,7 @@ forms_identifier_p (pfile, first)
/* Lex an identifier starting at BUFFER->CUR - 1. */
static cpp_hashnode *
-lex_identifier (pfile, base)
- cpp_reader *pfile;
- const uchar *base;
+lex_identifier (cpp_reader *pfile, const uchar *base)
{
cpp_hashnode *result;
const uchar *cur;
@@ -462,7 +441,8 @@ lex_identifier (pfile, base)
if (result == pfile->spec_nodes.n__VA_ARGS__
&& !pfile->state.va_args_ok)
cpp_error (pfile, DL_PEDWARN,
- "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro");
+ "__VA_ARGS__ can only appear in the expansion"
+ " of a C99 variadic macro");
}
return result;
@@ -470,9 +450,7 @@ lex_identifier (pfile, base)
/* Lex a number to NUMBER starting at BUFFER->CUR - 1. */
static void
-lex_number (pfile, number)
- cpp_reader *pfile;
- cpp_string *number;
+lex_number (cpp_reader *pfile, cpp_string *number)
{
const uchar *cur;
const uchar *base;
@@ -500,12 +478,8 @@ lex_number (pfile, number)
/* Create a token of type TYPE with a literal spelling. */
static void
-create_literal (pfile, token, base, len, type)
- cpp_reader *pfile;
- cpp_token *token;
- const uchar *base;
- unsigned int len;
- enum cpp_ttype type;
+create_literal (cpp_reader *pfile, cpp_token *token, const uchar *base,
+ unsigned int len, enum cpp_ttype type)
{
uchar *dest = _cpp_unaligned_alloc (pfile, len + 1);
@@ -524,10 +498,7 @@ create_literal (pfile, token, base, len, type)
The spelling is NUL-terminated, but it is not guaranteed that this
is the first NUL since embedded NULs are preserved. */
static void
-lex_string (pfile, token, base)
- cpp_reader *pfile;
- cpp_token *token;
- const uchar *base;
+lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
{
bool saw_NUL = false;
const uchar *cur;
@@ -573,11 +544,8 @@ lex_string (pfile, token, base)
/* The stored comment includes the comment start and any terminator. */
static void
-save_comment (pfile, token, from, type)
- cpp_reader *pfile;
- cpp_token *token;
- const unsigned char *from;
- cppchar_t type;
+save_comment (cpp_reader *pfile, cpp_token *token, const unsigned char *from,
+ cppchar_t type)
{
unsigned char *buffer;
unsigned int len, clen;
@@ -617,9 +585,7 @@ save_comment (pfile, token, from, type)
/* Allocate COUNT tokens for RUN. */
void
-_cpp_init_tokenrun (run, count)
- tokenrun *run;
- unsigned int count;
+_cpp_init_tokenrun (tokenrun *run, unsigned int count)
{
run->base = xnewvec (cpp_token, count);
run->limit = run->base + count;
@@ -628,8 +594,7 @@ _cpp_init_tokenrun (run, count)
/* Returns the next tokenrun, or creates one if there is none. */
static tokenrun *
-next_tokenrun (run)
- tokenrun *run;
+next_tokenrun (tokenrun *run)
{
if (run->next == NULL)
{
@@ -646,8 +611,7 @@ next_tokenrun (run)
same as the last lexed token, so that diagnostics appear in the
right place. */
cpp_token *
-_cpp_temp_token (pfile)
- cpp_reader *pfile;
+_cpp_temp_token (cpp_reader *pfile)
{
cpp_token *old, *result;
@@ -668,8 +632,7 @@ _cpp_temp_token (pfile)
like directive handling, token lookahead, multiple include
optimization and skipping. */
const cpp_token *
-_cpp_lex_token (pfile)
- cpp_reader *pfile;
+_cpp_lex_token (cpp_reader *pfile)
{
cpp_token *result;
@@ -701,7 +664,7 @@ _cpp_lex_token (pfile)
&& _cpp_handle_directive (pfile, result->flags & PREV_WHITE))
continue;
if (pfile->cb.line_change && !pfile->state.skipping)
- (*pfile->cb.line_change)(pfile, result, pfile->state.parsing_args);
+ pfile->cb.line_change (pfile, result, pfile->state.parsing_args);
}
/* We don't skip tokens in directives. */
@@ -722,8 +685,7 @@ _cpp_lex_token (pfile)
/* Returns true if a fresh line has been loaded. */
bool
-_cpp_get_fresh_line (pfile)
- cpp_reader *pfile;
+_cpp_get_fresh_line (cpp_reader *pfile)
{
/* We can't get a new line until we leave the current directive. */
if (pfile->state.in_directive)
@@ -792,8 +754,7 @@ _cpp_get_fresh_line (pfile)
otherwise returns to the start of the token buffer if permissible.
Returns the location of the lexed token. */
cpp_token *
-_cpp_lex_direct (pfile)
- cpp_reader *pfile;
+_cpp_lex_direct (cpp_reader *pfile)
{
cppchar_t c;
cpp_buffer *buffer;
@@ -1128,8 +1089,7 @@ _cpp_lex_direct (pfile)
/* An upper bound on the number of bytes needed to spell TOKEN.
Does not include preceding whitespace. */
unsigned int
-cpp_token_len (token)
- const cpp_token *token;
+cpp_token_len (const cpp_token *token)
{
unsigned int len;
@@ -1145,13 +1105,11 @@ cpp_token_len (token)
/* Write the spelling of a token TOKEN to BUFFER. The buffer must
already contain the enough space to hold the token's spelling.
- Returns a pointer to the character after the last character
- written. */
+ Returns a pointer to the character after the last character written.
+ FIXME: Would be nice if we didn't need the PFILE argument. */
unsigned char *
-cpp_spell_token (pfile, token, buffer)
- cpp_reader *pfile; /* Would be nice to be rid of this... */
- const cpp_token *token;
- unsigned char *buffer;
+cpp_spell_token (cpp_reader *pfile, const cpp_token *token,
+ unsigned char *buffer)
{
switch (TOKEN_SPELL (token))
{
@@ -1195,9 +1153,7 @@ cpp_spell_token (pfile, token, buffer)
/* Returns TOKEN spelt as a null-terminated string. The string is
freed when the reader is destroyed. Useful for diagnostics. */
unsigned char *
-cpp_token_as_text (pfile, token)
- cpp_reader *pfile;
- const cpp_token *token;
+cpp_token_as_text (cpp_reader *pfile, const cpp_token *token)
{
unsigned int len = cpp_token_len (token) + 1;
unsigned char *start = _cpp_unaligned_alloc (pfile, len), *end;
@@ -1211,8 +1167,7 @@ cpp_token_as_text (pfile, token)
/* Used by C front ends, which really should move to using
cpp_token_as_text. */
const char *
-cpp_type2name (type)
- enum cpp_ttype type;
+cpp_type2name (enum cpp_ttype type)
{
return (const char *) token_spellings[type].name;
}
@@ -1221,9 +1176,7 @@ cpp_type2name (type)
Separated from cpp_spell_token for efficiency - to avoid stdio
double-buffering. */
void
-cpp_output_token (token, fp)
- const cpp_token *token;
- FILE *fp;
+cpp_output_token (const cpp_token *token, FILE *fp)
{
switch (TOKEN_SPELL (token))
{
@@ -1264,8 +1217,7 @@ cpp_output_token (token, fp)
/* Compare two tokens. */
int
-_cpp_equiv_tokens (a, b)
- const cpp_token *a, *b;
+_cpp_equiv_tokens (const cpp_token *a, const cpp_token *b)
{
if (a->type == b->type && a->flags == b->flags)
switch (TOKEN_SPELL (a))
@@ -1291,9 +1243,8 @@ _cpp_equiv_tokens (a, b)
conservative, and occasionally advises a space where one is not
needed, e.g. "." and ".2". */
int
-cpp_avoid_paste (pfile, token1, token2)
- cpp_reader *pfile;
- const cpp_token *token1, *token2;
+cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1,
+ const cpp_token *token2)
{
enum cpp_ttype a = token1->type, b = token2->type;
cppchar_t c;
@@ -1349,9 +1300,7 @@ cpp_avoid_paste (pfile, token1, token2)
character, to FP. Leading whitespace is removed. If there are
macros, special token padding is not performed. */
void
-cpp_output_line (pfile, fp)
- cpp_reader *pfile;
- FILE *fp;
+cpp_output_line (cpp_reader *pfile, FILE *fp)
{
const cpp_token *token;
@@ -1369,8 +1318,7 @@ cpp_output_line (pfile, fp)
/* Returns the value of a hexadecimal digit. */
static unsigned int
-hex_digit_value (c)
- unsigned int c;
+hex_digit_value (unsigned int c)
{
if (hex_p (c))
return hex_value (c);
@@ -1380,9 +1328,7 @@ hex_digit_value (c)
/* Read a possible universal character name starting at *PSTR. */
static cppchar_t
-maybe_read_ucn (pfile, pstr)
- cpp_reader *pfile;
- const uchar **pstr;
+maybe_read_ucn (cpp_reader *pfile, const uchar **pstr)
{
cppchar_t result, c = (*pstr)[-1];
@@ -1411,11 +1357,8 @@ maybe_read_ucn (pfile, pstr)
if the escape sequence is part of a wide character constant or
string literal. Handles all relevant diagnostics. */
cppchar_t
-cpp_parse_escape (pfile, pstr, limit, wide)
- cpp_reader *pfile;
- const unsigned char **pstr;
- const unsigned char *limit;
- int wide;
+cpp_parse_escape (cpp_reader *pfile, const unsigned char **pstr,
+ const unsigned char *limit, int wide)
{
/* Values of \a \b \e \f \n \r \t \v respectively. */
static const uchar ascii[] = { 7, 8, 27, 12, 10, 13, 9, 11 };
@@ -1555,7 +1498,8 @@ cpp_parse_escape (pfile, pstr, limit, wide)
if (c > mask)
{
- cpp_error (pfile, DL_PEDWARN, "escape sequence out of range for its type");
+ cpp_error (pfile, DL_PEDWARN,
+ "escape sequence out of range for its type");
c &= mask;
}
@@ -1569,11 +1513,8 @@ cpp_parse_escape (pfile, pstr, limit, wide)
characters seen, and UNSIGNEDP to a variable that indicates whether
the result has signed type. */
cppchar_t
-cpp_interpret_charconst (pfile, token, pchars_seen, unsignedp)
- cpp_reader *pfile;
- const cpp_token *token;
- unsigned int *pchars_seen;
- int *unsignedp;
+cpp_interpret_charconst (cpp_reader *pfile, const cpp_token *token,
+ unsigned int *pchars_seen, int *unsignedp)
{
const unsigned char *str, *limit;
unsigned int chars_seen = 0;
@@ -1678,8 +1619,7 @@ cpp_interpret_charconst (pfile, token, pchars_seen, unsignedp)
/* 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 *
-new_buff (len)
- size_t len;
+new_buff (size_t len)
{
_cpp_buff *result;
unsigned char *base;
@@ -1699,9 +1639,7 @@ new_buff (len)
/* Place a chain of unwanted allocation buffers on the free list. */
void
-_cpp_release_buff (pfile, buff)
- cpp_reader *pfile;
- _cpp_buff *buff;
+_cpp_release_buff (cpp_reader *pfile, _cpp_buff *buff)
{
_cpp_buff *end = buff;
@@ -1713,9 +1651,7 @@ _cpp_release_buff (pfile, buff)
/* Return a free buffer of size at least MIN_SIZE. */
_cpp_buff *
-_cpp_get_buff (pfile, min_size)
- cpp_reader *pfile;
- size_t min_size;
+_cpp_get_buff (cpp_reader *pfile, size_t min_size)
{
_cpp_buff *result, **p;
@@ -1744,10 +1680,7 @@ _cpp_get_buff (pfile, min_size)
the excess bytes to the new buffer. Chains the new buffer after
BUFF, and returns the new buffer. */
_cpp_buff *
-_cpp_append_extend_buff (pfile, buff, min_extra)
- cpp_reader *pfile;
- _cpp_buff *buff;
- size_t min_extra;
+_cpp_append_extend_buff (cpp_reader *pfile, _cpp_buff *buff, size_t min_extra)
{
size_t size = EXTENDED_BUFF_SIZE (buff, min_extra);
_cpp_buff *new_buff = _cpp_get_buff (pfile, size);
@@ -1763,10 +1696,7 @@ _cpp_append_extend_buff (pfile, buff, min_extra)
Chains the new buffer before the buffer pointed to by BUFF, and
updates the pointer to point to the new buffer. */
void
-_cpp_extend_buff (pfile, pbuff, min_extra)
- cpp_reader *pfile;
- _cpp_buff **pbuff;
- size_t min_extra;
+_cpp_extend_buff (cpp_reader *pfile, _cpp_buff **pbuff, size_t min_extra)
{
_cpp_buff *new_buff, *old_buff = *pbuff;
size_t size = EXTENDED_BUFF_SIZE (old_buff, min_extra);
@@ -1793,9 +1723,7 @@ _cpp_free_buff (buff)
/* Allocate permanent, unaligned storage of length LEN. */
unsigned char *
-_cpp_unaligned_alloc (pfile, len)
- cpp_reader *pfile;
- size_t len;
+_cpp_unaligned_alloc (cpp_reader *pfile, size_t len)
{
_cpp_buff *buff = pfile->u_buff;
unsigned char *result = buff->cur;
@@ -1823,9 +1751,7 @@ _cpp_unaligned_alloc (pfile, len)
All existing other uses clearly fit this restriction: storing
registered pragmas during initialization. */
unsigned char *
-_cpp_aligned_alloc (pfile, len)
- cpp_reader *pfile;
- size_t len;
+_cpp_aligned_alloc (cpp_reader *pfile, size_t len)
{
_cpp_buff *buff = pfile->a_buff;
unsigned char *result = buff->cur;