Commit 6cf87ca4 by Zack Weinberg

* 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.

From-SVN: r68070
parent 82620aaf
2003-06-16 Zack Weinberg <zack@codesourcery.com>
* 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.
2003-06-17 Andreas Jaeger <aj@suse.de> 2003-06-17 Andreas Jaeger <aj@suse.de>
* rtl.h: Remove declarations from coverage.h. * rtl.h: Remove declarations from coverage.h.
...@@ -16,11 +25,11 @@ ...@@ -16,11 +25,11 @@
* config/sparc/aout.h, config/sparc/biarch64.h, config/sparc/elf.h, * config/sparc/aout.h, config/sparc/biarch64.h, config/sparc/elf.h,
config/sparc/freebsd.h, config/sparc/linux.h, config/sparc/linux64.h, config/sparc/freebsd.h, config/sparc/linux.h, config/sparc/linux64.h,
config/sparc/lite.h, config/sparc/litecoff.h, config/sparc/liteelf.h, config/sparc/lite.h, config/sparc/litecoff.h, config/sparc/liteelf.h,
config/sparc/netbsd-elf.h, config/sparc/openbsd.h, config/sparc/netbsd-elf.h, config/sparc/openbsd.h,
config/sparc/rtemself.h, config/sparc/sol2-64.h, config/sparc/rtemself.h, config/sparc/sol2-64.h,
config/sparc/sol2-bi.h, config/sparc/sol2-gas-bi.h, config/sparc/sol2-bi.h, config/sparc/sol2-gas-bi.h,
config/sparc/sol2-gld-bi.h, config/sparc/sol2-gld.h, config/sparc/sol2-gld-bi.h, config/sparc/sol2-gld.h,
config/sparc/sol2.h, config/sparc/sp64-aout.h, config/sparc/sol2.h, config/sparc/sp64-aout.h,
config/sparc/sp64-elf.h, config/sparc/sp86x-elf.h, config/sparc/sp64-elf.h, config/sparc/sp86x-elf.h,
config/sparc/sparc-protos.h, config/sparc/sysv4-only.h: Replace config/sparc/sparc-protos.h, config/sparc/sysv4-only.h: Replace
"GNU compiler", "GNU CC" with "GCC". "GNU compiler", "GNU CC" with "GCC".
...@@ -82,7 +91,7 @@ ...@@ -82,7 +91,7 @@
* builtin-attrs.def, builtin-attrs.def, builtins.c, cpplex.c, * builtin-attrs.def, builtin-attrs.def, builtins.c, cpplex.c,
cpplib.c, gencheck.c, gengenrtl.c, machmode.def, protoize.c: Don't cpplib.c, gencheck.c, gengenrtl.c, machmode.def, protoize.c: Don't
use macros from "symcat.h", instead rely on ISO C. use macros from "symcat.h", instead rely on ISO C.
* system.h: Don't include "symcat.h". * system.h: Don't include "symcat.h".
* configure.in (AC_C_STRINGIZE): Delete. * configure.in (AC_C_STRINGIZE): Delete.
* config.in, configure: Regenerate. * config.in, configure: Regenerate.
......
...@@ -25,7 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -25,7 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpplib.h" #include "cpplib.h"
#include "cpphash.h" #include "cpphash.h"
static int ucn_valid_in_identifier PARAMS ((cpp_reader *, cppchar_t)); static int ucn_valid_in_identifier (cpp_reader *, cppchar_t);
/* [lex.charset]: The character designated by the universal character /* [lex.charset]: The character designated by the universal character
name \UNNNNNNNN is that character whose character short name in name \UNNNNNNNN is that character whose character short name in
...@@ -52,10 +52,7 @@ static int ucn_valid_in_identifier PARAMS ((cpp_reader *, cppchar_t)); ...@@ -52,10 +52,7 @@ static int ucn_valid_in_identifier PARAMS ((cpp_reader *, cppchar_t));
*/ */
cppchar_t cppchar_t
_cpp_valid_ucn (pfile, pstr, identifier_pos) _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr, int identifier_pos)
cpp_reader *pfile;
const uchar **pstr;
int identifier_pos;
{ {
cppchar_t result, c; cppchar_t result, c;
unsigned int length; unsigned int length;
...@@ -128,9 +125,7 @@ _cpp_valid_ucn (pfile, pstr, identifier_pos) ...@@ -128,9 +125,7 @@ _cpp_valid_ucn (pfile, pstr, identifier_pos)
identifier. We assume C has already gone through the checks of identifier. We assume C has already gone through the checks of
_cpp_valid_ucn. */ _cpp_valid_ucn. */
static int static int
ucn_valid_in_identifier (pfile, c) ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c)
cpp_reader *pfile;
cppchar_t c;
{ {
/* None of the valid chars are outside the Basic Multilingual Plane (the /* None of the valid chars are outside the Basic Multilingual Plane (the
low 16 bits). */ low 16 bits). */
......
...@@ -31,16 +31,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -31,16 +31,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpphash.h" #include "cpphash.h"
#include "intl.h" #include "intl.h"
static void print_location PARAMS ((cpp_reader *, unsigned int, unsigned int)); static void print_location (cpp_reader *, unsigned int, unsigned int);
/* Print the logical file location (LINE, COL) in preparation for a /* Print the logical file location (LINE, COL) in preparation for a
diagnostic. Outputs the #include chain if it has changed. A line diagnostic. Outputs the #include chain if it has changed. A line
of zero suppresses the include stack, and outputs the program name of zero suppresses the include stack, and outputs the program name
instead. */ instead. */
static void static void
print_location (pfile, line, col) print_location (cpp_reader *pfile, unsigned int line, unsigned int col)
cpp_reader *pfile;
unsigned int line, col;
{ {
if (!pfile->buffer || line == 0) if (!pfile->buffer || line == 0)
fprintf (stderr, "%s: ", progname); fprintf (stderr, "%s: ", progname);
...@@ -72,10 +70,8 @@ print_location (pfile, line, col) ...@@ -72,10 +70,8 @@ print_location (pfile, line, col)
the correct place by default. Returns 0 if the error has been the correct place by default. Returns 0 if the error has been
suppressed. */ suppressed. */
int int
_cpp_begin_message (pfile, code, line, column) _cpp_begin_message (cpp_reader *pfile, int code, unsigned int line,
cpp_reader *pfile; unsigned int column)
int code;
unsigned int line, column;
{ {
int level = DL_EXTRACT (code); int level = DL_EXTRACT (code);
...@@ -177,10 +173,7 @@ cpp_error_with_line (cpp_reader *pfile, int level, ...@@ -177,10 +173,7 @@ cpp_error_with_line (cpp_reader *pfile, int level,
} }
void void
cpp_errno (pfile, level, msgid) cpp_errno (cpp_reader *pfile, int level, const char *msgid)
cpp_reader *pfile;
int level;
const char *msgid;
{ {
if (msgid[0] == '\0') if (msgid[0] == '\0')
msgid = _("stdout"); msgid = _("stdout");
......
...@@ -40,34 +40,31 @@ struct op ...@@ -40,34 +40,31 @@ struct op
/* Some simple utility routines on double integers. */ /* Some simple utility routines on double integers. */
#define num_zerop(num) ((num.low | num.high) == 0) #define num_zerop(num) ((num.low | num.high) == 0)
#define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high) #define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high)
static bool num_positive PARAMS ((cpp_num, size_t)); static bool num_positive (cpp_num, size_t);
static bool num_greater_eq PARAMS ((cpp_num, cpp_num, size_t)); static bool num_greater_eq (cpp_num, cpp_num, size_t);
static cpp_num num_trim PARAMS ((cpp_num, size_t)); static cpp_num num_trim (cpp_num, size_t);
static cpp_num num_part_mul PARAMS ((cpp_num_part, cpp_num_part)); static cpp_num num_part_mul (cpp_num_part, cpp_num_part);
static cpp_num num_unary_op PARAMS ((cpp_reader *, cpp_num, enum cpp_ttype)); static cpp_num num_unary_op (cpp_reader *, cpp_num, enum cpp_ttype);
static cpp_num num_binary_op PARAMS ((cpp_reader *, cpp_num, cpp_num, static cpp_num num_binary_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype);
enum cpp_ttype)); static cpp_num num_negate (cpp_num, size_t);
static cpp_num num_negate PARAMS ((cpp_num, size_t)); static cpp_num num_bitwise_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype);
static cpp_num num_bitwise_op PARAMS ((cpp_reader *, cpp_num, cpp_num, static cpp_num num_inequality_op (cpp_reader *, cpp_num, cpp_num,
enum cpp_ttype)); enum cpp_ttype);
static cpp_num num_inequality_op PARAMS ((cpp_reader *, cpp_num, cpp_num, static cpp_num num_equality_op (cpp_reader *, cpp_num, cpp_num,
enum cpp_ttype)); enum cpp_ttype);
static cpp_num num_equality_op PARAMS ((cpp_reader *, cpp_num, cpp_num, static cpp_num num_mul (cpp_reader *, cpp_num, cpp_num);
enum cpp_ttype)); static cpp_num num_div_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype);
static cpp_num num_mul PARAMS ((cpp_reader *, cpp_num, cpp_num)); static cpp_num num_lshift (cpp_num, size_t, size_t);
static cpp_num num_div_op PARAMS ((cpp_reader *, cpp_num, cpp_num, static cpp_num num_rshift (cpp_num, size_t, size_t);
enum cpp_ttype));
static cpp_num num_lshift PARAMS ((cpp_num, size_t, size_t)); static cpp_num append_digit (cpp_num, int, int, size_t);
static cpp_num num_rshift PARAMS ((cpp_num, size_t, size_t)); static cpp_num parse_defined (cpp_reader *);
static cpp_num eval_token (cpp_reader *, const cpp_token *);
static cpp_num append_digit PARAMS ((cpp_num, int, int, size_t)); static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype);
static cpp_num parse_defined PARAMS ((cpp_reader *)); static unsigned int interpret_float_suffix (const uchar *, size_t);
static cpp_num eval_token PARAMS ((cpp_reader *, const cpp_token *)); static unsigned int interpret_int_suffix (const uchar *, size_t);
static struct op *reduce PARAMS ((cpp_reader *, struct op *, enum cpp_ttype)); static void check_promotion (cpp_reader *, const struct op *);
static unsigned int interpret_float_suffix PARAMS ((const uchar *, size_t));
static unsigned int interpret_int_suffix PARAMS ((const uchar *, size_t));
static void check_promotion PARAMS ((cpp_reader *, const struct op *));
/* Token type abuse to create unary plus and minus operators. */ /* Token type abuse to create unary plus and minus operators. */
#define CPP_UPLUS (CPP_LAST_CPP_OP + 1) #define CPP_UPLUS (CPP_LAST_CPP_OP + 1)
...@@ -84,9 +81,7 @@ static void check_promotion PARAMS ((cpp_reader *, const struct op *)); ...@@ -84,9 +81,7 @@ static void check_promotion PARAMS ((cpp_reader *, const struct op *));
length LEN, possibly zero. Returns 0 for an invalid suffix, or a length LEN, possibly zero. Returns 0 for an invalid suffix, or a
flag vector describing the suffix. */ flag vector describing the suffix. */
static unsigned int static unsigned int
interpret_float_suffix (s, len) interpret_float_suffix (const uchar *s, size_t len)
const uchar *s;
size_t len;
{ {
size_t f = 0, l = 0, i = 0; size_t f = 0, l = 0, i = 0;
...@@ -113,9 +108,7 @@ interpret_float_suffix (s, len) ...@@ -113,9 +108,7 @@ interpret_float_suffix (s, len)
of length LEN, possibly zero. Returns 0 for an invalid suffix, or a of length LEN, possibly zero. Returns 0 for an invalid suffix, or a
flag vector describing the suffix. */ flag vector describing the suffix. */
static unsigned int static unsigned int
interpret_int_suffix (s, len) interpret_int_suffix (const uchar *s, size_t len)
const uchar *s;
size_t len;
{ {
size_t u, l, i; size_t u, l, i;
...@@ -149,9 +142,7 @@ interpret_int_suffix (s, len) ...@@ -149,9 +142,7 @@ interpret_int_suffix (s, len)
floating point, or invalid), radix (decimal, octal, hexadecimal), floating point, or invalid), radix (decimal, octal, hexadecimal),
and type suffixes. */ and type suffixes. */
unsigned int unsigned int
cpp_classify_number (pfile, token) cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
cpp_reader *pfile;
const cpp_token *token;
{ {
const uchar *str = token->val.str.text; const uchar *str = token->val.str.text;
const uchar *limit; const uchar *limit;
...@@ -314,13 +305,11 @@ cpp_classify_number (pfile, token) ...@@ -314,13 +305,11 @@ cpp_classify_number (pfile, token)
of precision options->precision. of precision options->precision.
We do not provide any interface for decimal->float conversion, We do not provide any interface for decimal->float conversion,
because the preprocessor doesn't need it and the floating point because the preprocessor doesn't need it and we don't want to
handling in GCC proper is too ugly to speak of. */ drag in GCC's floating point emulator. */
cpp_num cpp_num
cpp_interpret_integer (pfile, token, type) cpp_interpret_integer (cpp_reader *pfile, const cpp_token *token,
cpp_reader *pfile; unsigned int type)
const cpp_token *token;
unsigned int type;
{ {
const uchar *p, *end; const uchar *p, *end;
cpp_num result; cpp_num result;
...@@ -403,13 +392,9 @@ cpp_interpret_integer (pfile, token, type) ...@@ -403,13 +392,9 @@ cpp_interpret_integer (pfile, token, type)
return result; return result;
} }
/* Append DIGIT to NUM, a number of PRECISION bits being read in base /* Append DIGIT to NUM, a number of PRECISION bits being read in base BASE. */
BASE. */
static cpp_num static cpp_num
append_digit (num, digit, base, precision) append_digit (cpp_num num, int digit, int base, size_t precision)
cpp_num num;
int digit, base;
size_t precision;
{ {
cpp_num result; cpp_num result;
unsigned int shift = 3 + (base == 16); unsigned int shift = 3 + (base == 16);
...@@ -458,8 +443,7 @@ append_digit (num, digit, base, precision) ...@@ -458,8 +443,7 @@ append_digit (num, digit, base, precision)
/* Handle meeting "defined" in a preprocessor expression. */ /* Handle meeting "defined" in a preprocessor expression. */
static cpp_num static cpp_num
parse_defined (pfile) parse_defined (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_num result; cpp_num result;
int paren = 0; int paren = 0;
...@@ -529,9 +513,7 @@ parse_defined (pfile) ...@@ -529,9 +513,7 @@ parse_defined (pfile)
number or character constant, or the result of the "defined" or "#" number or character constant, or the result of the "defined" or "#"
operators). */ operators). */
static cpp_num static cpp_num
eval_token (pfile, token) eval_token (cpp_reader *pfile, const cpp_token *token)
cpp_reader *pfile;
const cpp_token *token;
{ {
cpp_num result; cpp_num result;
unsigned int temp; unsigned int temp;
...@@ -695,8 +677,7 @@ static const struct operator ...@@ -695,8 +677,7 @@ static const struct operator
stored in the 'value' field of the stack element of the operator stored in the 'value' field of the stack element of the operator
that precedes it. */ that precedes it. */
bool bool
_cpp_parse_expr (pfile) _cpp_parse_expr (cpp_reader *pfile)
cpp_reader *pfile;
{ {
struct op *top = pfile->op_stack; struct op *top = pfile->op_stack;
unsigned int lex_count; unsigned int lex_count;
...@@ -838,10 +819,7 @@ _cpp_parse_expr (pfile) ...@@ -838,10 +819,7 @@ _cpp_parse_expr (pfile)
pushing operator OP. Returns NULL on error, otherwise the top of pushing operator OP. Returns NULL on error, otherwise the top of
the stack. */ the stack. */
static struct op * static struct op *
reduce (pfile, top, op) reduce (cpp_reader *pfile, struct op *top, enum cpp_ttype op)
cpp_reader *pfile;
struct op *top;
enum cpp_ttype op;
{ {
unsigned int prio; unsigned int prio;
...@@ -985,8 +963,7 @@ reduce (pfile, top, op) ...@@ -985,8 +963,7 @@ reduce (pfile, top, op)
/* Returns the position of the old top of stack after expansion. */ /* Returns the position of the old top of stack after expansion. */
struct op * struct op *
_cpp_expand_op_stack (pfile) _cpp_expand_op_stack (cpp_reader *pfile)
cpp_reader *pfile;
{ {
size_t old_size = (size_t) (pfile->op_limit - pfile->op_stack); size_t old_size = (size_t) (pfile->op_limit - pfile->op_stack);
size_t new_size = old_size * 2 + 20; size_t new_size = old_size * 2 + 20;
...@@ -1001,9 +978,7 @@ _cpp_expand_op_stack (pfile) ...@@ -1001,9 +978,7 @@ _cpp_expand_op_stack (pfile)
/* Emits a warning if the effective sign of either operand of OP /* Emits a warning if the effective sign of either operand of OP
changes because of integer promotions. */ changes because of integer promotions. */
static void static void
check_promotion (pfile, op) check_promotion (cpp_reader *pfile, const struct op *op)
cpp_reader *pfile;
const struct op *op;
{ {
if (op->value.unsignedp == op[-1].value.unsignedp) if (op->value.unsignedp == op[-1].value.unsignedp)
return; return;
...@@ -1023,9 +998,7 @@ check_promotion (pfile, op) ...@@ -1023,9 +998,7 @@ check_promotion (pfile, op)
/* Clears the unused high order bits of the number pointed to by PNUM. */ /* Clears the unused high order bits of the number pointed to by PNUM. */
static cpp_num static cpp_num
num_trim (num, precision) num_trim (cpp_num num, size_t precision)
cpp_num num;
size_t precision;
{ {
if (precision > PART_PRECISION) if (precision > PART_PRECISION)
{ {
...@@ -1045,9 +1018,7 @@ num_trim (num, precision) ...@@ -1045,9 +1018,7 @@ num_trim (num, precision)
/* True iff A (presumed signed) >= 0. */ /* True iff A (presumed signed) >= 0. */
static bool static bool
num_positive (num, precision) num_positive (cpp_num num, size_t precision)
cpp_num num;
size_t precision;
{ {
if (precision > PART_PRECISION) if (precision > PART_PRECISION)
{ {
...@@ -1061,9 +1032,7 @@ num_positive (num, precision) ...@@ -1061,9 +1032,7 @@ num_positive (num, precision)
/* Sign extend a number, with PRECISION significant bits and all /* Sign extend a number, with PRECISION significant bits and all
others assumed clear, to fill out a cpp_num structure. */ others assumed clear, to fill out a cpp_num structure. */
cpp_num cpp_num
cpp_num_sign_extend (num, precision) cpp_num_sign_extend (cpp_num num, size_t precision)
cpp_num num;
size_t precision;
{ {
if (!num.unsignedp) if (!num.unsignedp)
{ {
...@@ -1087,9 +1056,7 @@ cpp_num_sign_extend (num, precision) ...@@ -1087,9 +1056,7 @@ cpp_num_sign_extend (num, precision)
/* Returns the negative of NUM. */ /* Returns the negative of NUM. */
static cpp_num static cpp_num
num_negate (num, precision) num_negate (cpp_num num, size_t precision)
cpp_num num;
size_t precision;
{ {
cpp_num copy; cpp_num copy;
...@@ -1106,9 +1073,7 @@ num_negate (num, precision) ...@@ -1106,9 +1073,7 @@ num_negate (num, precision)
/* Returns true if A >= B. */ /* Returns true if A >= B. */
static bool static bool
num_greater_eq (pa, pb, precision) num_greater_eq (cpp_num pa, cpp_num pb, size_t precision)
cpp_num pa, pb;
size_t precision;
{ {
bool unsignedp; bool unsignedp;
...@@ -1131,10 +1096,8 @@ num_greater_eq (pa, pb, precision) ...@@ -1131,10 +1096,8 @@ num_greater_eq (pa, pb, precision)
/* Returns LHS OP RHS, where OP is a bit-wise operation. */ /* Returns LHS OP RHS, where OP is a bit-wise operation. */
static cpp_num static cpp_num
num_bitwise_op (pfile, lhs, rhs, op) num_bitwise_op (cpp_reader *pfile ATTRIBUTE_UNUSED,
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
cpp_num lhs, rhs;
enum cpp_ttype op;
{ {
lhs.overflow = false; lhs.overflow = false;
lhs.unsignedp = lhs.unsignedp || rhs.unsignedp; lhs.unsignedp = lhs.unsignedp || rhs.unsignedp;
...@@ -1162,10 +1125,8 @@ num_bitwise_op (pfile, lhs, rhs, op) ...@@ -1162,10 +1125,8 @@ num_bitwise_op (pfile, lhs, rhs, op)
/* Returns LHS OP RHS, where OP is an inequality. */ /* Returns LHS OP RHS, where OP is an inequality. */
static cpp_num static cpp_num
num_inequality_op (pfile, lhs, rhs, op) num_inequality_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs,
cpp_reader *pfile; enum cpp_ttype op)
cpp_num lhs, rhs;
enum cpp_ttype op;
{ {
bool gte = num_greater_eq (lhs, rhs, CPP_OPTION (pfile, precision)); bool gte = num_greater_eq (lhs, rhs, CPP_OPTION (pfile, precision));
...@@ -1186,10 +1147,8 @@ num_inequality_op (pfile, lhs, rhs, op) ...@@ -1186,10 +1147,8 @@ num_inequality_op (pfile, lhs, rhs, op)
/* Returns LHS OP RHS, where OP is == or !=. */ /* Returns LHS OP RHS, where OP is == or !=. */
static cpp_num static cpp_num
num_equality_op (pfile, lhs, rhs, op) num_equality_op (cpp_reader *pfile ATTRIBUTE_UNUSED,
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
cpp_num lhs, rhs;
enum cpp_ttype op;
{ {
/* Work around a 3.0.4 bug; see PR 6950. */ /* Work around a 3.0.4 bug; see PR 6950. */
bool eq = num_eq (lhs, rhs); bool eq = num_eq (lhs, rhs);
...@@ -1204,9 +1163,7 @@ num_equality_op (pfile, lhs, rhs, op) ...@@ -1204,9 +1163,7 @@ num_equality_op (pfile, lhs, rhs, op)
/* Shift NUM, of width PRECISION, right by N bits. */ /* Shift NUM, of width PRECISION, right by N bits. */
static cpp_num static cpp_num
num_rshift (num, precision, n) num_rshift (cpp_num num, size_t precision, size_t n)
cpp_num num;
size_t precision, n;
{ {
cpp_num_part sign_mask; cpp_num_part sign_mask;
...@@ -1246,9 +1203,7 @@ num_rshift (num, precision, n) ...@@ -1246,9 +1203,7 @@ num_rshift (num, precision, n)
/* Shift NUM, of width PRECISION, left by N bits. */ /* Shift NUM, of width PRECISION, left by N bits. */
static cpp_num static cpp_num
num_lshift (num, precision, n) num_lshift (cpp_num num, size_t precision, size_t n)
cpp_num num;
size_t precision, n;
{ {
if (n >= precision) if (n >= precision)
{ {
...@@ -1288,10 +1243,7 @@ num_lshift (num, precision, n) ...@@ -1288,10 +1243,7 @@ num_lshift (num, precision, n)
/* The four unary operators: +, -, ! and ~. */ /* The four unary operators: +, -, ! and ~. */
static cpp_num static cpp_num
num_unary_op (pfile, num, op) num_unary_op (cpp_reader *pfile, cpp_num num, enum cpp_ttype op)
cpp_reader *pfile;
cpp_num num;
enum cpp_ttype op;
{ {
switch (op) switch (op)
{ {
...@@ -1326,10 +1278,7 @@ num_unary_op (pfile, num, op) ...@@ -1326,10 +1278,7 @@ num_unary_op (pfile, num, op)
/* The various binary operators. */ /* The various binary operators. */
static cpp_num static cpp_num
num_binary_op (pfile, lhs, rhs, op) num_binary_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
cpp_reader *pfile;
cpp_num lhs, rhs;
enum cpp_ttype op;
{ {
cpp_num result; cpp_num result;
size_t precision = CPP_OPTION (pfile, precision); size_t precision = CPP_OPTION (pfile, precision);
...@@ -1411,8 +1360,7 @@ num_binary_op (pfile, lhs, rhs, op) ...@@ -1411,8 +1360,7 @@ num_binary_op (pfile, lhs, rhs, op)
/* Multiplies two unsigned cpp_num_parts to give a cpp_num. This /* Multiplies two unsigned cpp_num_parts to give a cpp_num. This
cannot overflow. */ cannot overflow. */
static cpp_num static cpp_num
num_part_mul (lhs, rhs) num_part_mul (cpp_num_part lhs, cpp_num_part rhs)
cpp_num_part lhs, rhs;
{ {
cpp_num result; cpp_num result;
cpp_num_part middle[2], temp; cpp_num_part middle[2], temp;
...@@ -1442,9 +1390,7 @@ num_part_mul (lhs, rhs) ...@@ -1442,9 +1390,7 @@ num_part_mul (lhs, rhs)
/* Multiply two preprocessing numbers. */ /* Multiply two preprocessing numbers. */
static cpp_num static cpp_num
num_mul (pfile, lhs, rhs) num_mul (cpp_reader *pfile, cpp_num lhs, cpp_num rhs)
cpp_reader *pfile;
cpp_num lhs, rhs;
{ {
cpp_num result, temp; cpp_num result, temp;
bool unsignedp = lhs.unsignedp || rhs.unsignedp; bool unsignedp = lhs.unsignedp || rhs.unsignedp;
...@@ -1494,10 +1440,7 @@ num_mul (pfile, lhs, rhs) ...@@ -1494,10 +1440,7 @@ num_mul (pfile, lhs, rhs)
/* Divide two preprocessing numbers, returning the answer or the /* Divide two preprocessing numbers, returning the answer or the
remainder depending upon OP. */ remainder depending upon OP. */
static cpp_num static cpp_num
num_div_op (pfile, lhs, rhs, op) num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
cpp_reader *pfile;
cpp_num lhs, rhs;
enum cpp_ttype op;
{ {
cpp_num result, sub; cpp_num result, sub;
cpp_num_part mask; cpp_num_part mask;
......
...@@ -86,31 +86,24 @@ struct include_file { ...@@ -86,31 +86,24 @@ struct include_file {
#define NO_INCLUDE_PATH ((struct include_file *) -1) #define NO_INCLUDE_PATH ((struct include_file *) -1)
#define INCLUDE_PCH_P(F) (((F)->pch & 1) != 0) #define INCLUDE_PCH_P(F) (((F)->pch & 1) != 0)
static struct file_name_map *read_name_map static struct file_name_map *read_name_map (cpp_reader *, const char *);
PARAMS ((cpp_reader *, const char *)); static char *read_filename_string (int, FILE *);
static char *read_filename_string PARAMS ((int, FILE *)); static char *remap_filename (cpp_reader *, char *, struct cpp_path *);
static char *remap_filename PARAMS ((cpp_reader *, char *, static struct cpp_path *search_from (cpp_reader *, enum include_type);
struct cpp_path *)); static struct include_file *find_include_file (cpp_reader *, const char *,
static struct cpp_path *search_from PARAMS ((cpp_reader *, int, enum include_type);
enum include_type)); static struct include_file *open_file (cpp_reader *, const char *);
static struct include_file * static struct include_file *validate_pch (cpp_reader *, const char *,
find_include_file PARAMS ((cpp_reader *, const char *, int, const char *);
enum include_type)); static struct include_file *open_file_pch (cpp_reader *, const char *);
static struct include_file *open_file PARAMS ((cpp_reader *, const char *)); static int read_include_file (cpp_reader *, struct include_file *);
static struct include_file *validate_pch PARAMS ((cpp_reader *, static bool stack_include_file (cpp_reader *, struct include_file *);
const char *, static void purge_cache (struct include_file *);
const char *)); static void destroy_node (splay_tree_value);
static struct include_file *open_file_pch PARAMS ((cpp_reader *, static int report_missing_guard (splay_tree_node, void *);
const char *)); static splay_tree_node find_or_create_entry (cpp_reader *, const char *);
static int read_include_file PARAMS ((cpp_reader *, struct include_file *)); static void handle_missing_header (cpp_reader *, const char *, int);
static bool stack_include_file PARAMS ((cpp_reader *, struct include_file *)); static int remove_component_p (const char *);
static void purge_cache PARAMS ((struct include_file *));
static void destroy_node PARAMS ((splay_tree_value));
static int report_missing_guard PARAMS ((splay_tree_node, void *));
static splay_tree_node find_or_create_entry PARAMS ((cpp_reader *,
const char *));
static void handle_missing_header PARAMS ((cpp_reader *, const char *, int));
static int remove_component_p PARAMS ((const char *));
/* Set up the splay tree we use to store information about all the /* Set up the splay tree we use to store information about all the
file names seen in this compilation. We also have entries for each file names seen in this compilation. We also have entries for each
...@@ -125,8 +118,7 @@ static int remove_component_p PARAMS ((const char *)); ...@@ -125,8 +118,7 @@ static int remove_component_p PARAMS ((const char *));
A node's value is a pointer to a struct include_file, and is never A node's value is a pointer to a struct include_file, and is never
NULL. */ NULL. */
void void
_cpp_init_includes (pfile) _cpp_init_includes (cpp_reader *pfile)
cpp_reader *pfile;
{ {
pfile->all_include_files pfile->all_include_files
= splay_tree_new ((splay_tree_compare_fn) strcmp, = splay_tree_new ((splay_tree_compare_fn) strcmp,
...@@ -136,16 +128,14 @@ _cpp_init_includes (pfile) ...@@ -136,16 +128,14 @@ _cpp_init_includes (pfile)
/* Tear down the splay tree. */ /* Tear down the splay tree. */
void void
_cpp_cleanup_includes (pfile) _cpp_cleanup_includes (cpp_reader *pfile)
cpp_reader *pfile;
{ {
splay_tree_delete (pfile->all_include_files); splay_tree_delete (pfile->all_include_files);
} }
/* Free a node. The path string is automatically freed. */ /* Free a node. The path string is automatically freed. */
static void static void
destroy_node (v) destroy_node (splay_tree_value v)
splay_tree_value v;
{ {
struct include_file *f = (struct include_file *) v; struct include_file *f = (struct include_file *) v;
...@@ -158,8 +148,7 @@ destroy_node (v) ...@@ -158,8 +148,7 @@ destroy_node (v)
/* Mark a file to not be reread (e.g. #import, read failure). */ /* Mark a file to not be reread (e.g. #import, read failure). */
void void
_cpp_never_reread (file) _cpp_never_reread (struct include_file *file)
struct include_file *file;
{ {
file->cmacro = NEVER_REREAD; file->cmacro = NEVER_REREAD;
} }
...@@ -167,9 +156,7 @@ _cpp_never_reread (file) ...@@ -167,9 +156,7 @@ _cpp_never_reread (file)
/* Lookup a filename, which is simplified after making a copy, and /* Lookup a filename, which is simplified after making a copy, and
create an entry if none exists. */ create an entry if none exists. */
static splay_tree_node static splay_tree_node
find_or_create_entry (pfile, fname) find_or_create_entry (cpp_reader *pfile, const char *fname)
cpp_reader *pfile;
const char *fname;
{ {
splay_tree_node node; splay_tree_node node;
struct include_file *file; struct include_file *file;
...@@ -197,9 +184,7 @@ find_or_create_entry (pfile, fname) ...@@ -197,9 +184,7 @@ find_or_create_entry (pfile, fname)
/* Enter a file name in the splay tree, for the sake of cpp_included. */ /* Enter a file name in the splay tree, for the sake of cpp_included. */
void void
_cpp_fake_include (pfile, fname) _cpp_fake_include (cpp_reader *pfile, const char *fname)
cpp_reader *pfile;
const char *fname;
{ {
find_or_create_entry (pfile, fname); find_or_create_entry (pfile, fname);
} }
...@@ -214,9 +199,7 @@ _cpp_fake_include (pfile, fname) ...@@ -214,9 +199,7 @@ _cpp_fake_include (pfile, fname)
Returns an include_file structure with an open file descriptor on Returns an include_file structure with an open file descriptor on
success, or NULL on failure. */ success, or NULL on failure. */
static struct include_file * static struct include_file *
open_file (pfile, filename) open_file (cpp_reader *pfile, const char *filename)
cpp_reader *pfile;
const char *filename;
{ {
splay_tree_node nd = find_or_create_entry (pfile, filename); splay_tree_node nd = find_or_create_entry (pfile, filename);
struct include_file *file = (struct include_file *) nd->value; struct include_file *file = (struct include_file *) nd->value;
...@@ -281,10 +264,7 @@ open_file (pfile, filename) ...@@ -281,10 +264,7 @@ open_file (pfile, filename)
} }
static struct include_file * static struct include_file *
validate_pch (pfile, filename, pchname) validate_pch (cpp_reader *pfile, const char *filename, const char *pchname)
cpp_reader *pfile;
const char *filename;
const char *pchname;
{ {
struct include_file * file; struct include_file * file;
...@@ -316,9 +296,7 @@ validate_pch (pfile, filename, pchname) ...@@ -316,9 +296,7 @@ validate_pch (pfile, filename, pchname)
/* Like open_file, but also look for a precompiled header if (a) one exists /* Like open_file, but also look for a precompiled header if (a) one exists
and (b) it is valid. */ and (b) it is valid. */
static struct include_file * static struct include_file *
open_file_pch (pfile, filename) open_file_pch (cpp_reader *pfile, const char *filename)
cpp_reader *pfile;
const char *filename;
{ {
if (filename[0] != '\0' if (filename[0] != '\0'
&& pfile->cb.valid_pch != NULL) && pfile->cb.valid_pch != NULL)
...@@ -377,9 +355,7 @@ open_file_pch (pfile, filename) ...@@ -377,9 +355,7 @@ open_file_pch (pfile, filename)
because of e.g. multiple-include guards. Returns true if a buffer because of e.g. multiple-include guards. Returns true if a buffer
is stacked. */ is stacked. */
static bool static bool
stack_include_file (pfile, inc) stack_include_file (cpp_reader *pfile, struct include_file *inc)
cpp_reader *pfile;
struct include_file *inc;
{ {
cpp_buffer *fp; cpp_buffer *fp;
int sysp; int sysp;
...@@ -462,9 +438,7 @@ stack_include_file (pfile, inc) ...@@ -462,9 +438,7 @@ stack_include_file (pfile, inc)
FIXME: Flush file cache and try again if we run out of memory. */ FIXME: Flush file cache and try again if we run out of memory. */
static int static int
read_include_file (pfile, inc) read_include_file (cpp_reader *pfile, struct include_file *inc)
cpp_reader *pfile;
struct include_file *inc;
{ {
ssize_t size, offset, count; ssize_t size, offset, count;
uchar *buf; uchar *buf;
...@@ -555,8 +529,7 @@ read_include_file (pfile, inc) ...@@ -555,8 +529,7 @@ read_include_file (pfile, inc)
/* Drop INC's buffer from memory. */ /* Drop INC's buffer from memory. */
static void static void
purge_cache (inc) purge_cache (struct include_file *inc)
struct include_file *inc;
{ {
if (inc->buffer) if (inc->buffer)
{ {
...@@ -568,9 +541,7 @@ purge_cache (inc) ...@@ -568,9 +541,7 @@ purge_cache (inc)
/* Return 1 if the file named by FNAME has been included before in /* Return 1 if the file named by FNAME has been included before in
any context, 0 otherwise. */ any context, 0 otherwise. */
int int
cpp_included (pfile, fname) cpp_included (cpp_reader *pfile, const char *fname)
cpp_reader *pfile;
const char *fname;
{ {
struct cpp_path *path; struct cpp_path *path;
char *name, *n; char *name, *n;
...@@ -608,11 +579,8 @@ cpp_included (pfile, fname) ...@@ -608,11 +579,8 @@ cpp_included (pfile, fname)
otherwise an include_file structure. If this request originates otherwise an include_file structure. If this request originates
from a directive of TYPE #include_next, set INCLUDE_NEXT to true. */ from a directive of TYPE #include_next, set INCLUDE_NEXT to true. */
static struct include_file * static struct include_file *
find_include_file (pfile, fname, angle_brackets, type) find_include_file (cpp_reader *pfile, const char *fname, int angle_brackets,
cpp_reader *pfile; enum include_type type)
const char *fname;
int angle_brackets;
enum include_type type;
{ {
struct cpp_path *path; struct cpp_path *path;
struct include_file *file; struct include_file *file;
...@@ -676,9 +644,7 @@ find_include_file (pfile, fname, angle_brackets, type) ...@@ -676,9 +644,7 @@ find_include_file (pfile, fname, angle_brackets, type)
see the details of a buffer. This is an exported interface because see the details of a buffer. This is an exported interface because
fix-header needs it. */ fix-header needs it. */
void void
cpp_make_system_header (pfile, syshdr, externc) cpp_make_system_header (cpp_reader *pfile, int syshdr, int externc)
cpp_reader *pfile;
int syshdr, externc;
{ {
int flags = 0; int flags = 0;
...@@ -693,10 +659,8 @@ cpp_make_system_header (pfile, syshdr, externc) ...@@ -693,10 +659,8 @@ cpp_make_system_header (pfile, syshdr, externc)
to achieve pseudo-file names like <built-in>. to achieve pseudo-file names like <built-in>.
If REASON is LC_LEAVE, then NEW_NAME must be NULL. */ If REASON is LC_LEAVE, then NEW_NAME must be NULL. */
void void
cpp_change_file (pfile, reason, new_name) cpp_change_file (cpp_reader *pfile, enum lc_reason reason,
cpp_reader *pfile; const char *new_name)
enum lc_reason reason;
const char *new_name;
{ {
_cpp_do_file_change (pfile, reason, new_name, 1, 0); _cpp_do_file_change (pfile, reason, new_name, 1, 0);
} }
...@@ -704,8 +668,7 @@ cpp_change_file (pfile, reason, new_name) ...@@ -704,8 +668,7 @@ cpp_change_file (pfile, reason, new_name)
/* Report on all files that might benefit from a multiple include guard. /* Report on all files that might benefit from a multiple include guard.
Triggered by -H. */ Triggered by -H. */
void void
_cpp_report_missing_guards (pfile) _cpp_report_missing_guards (cpp_reader *pfile)
cpp_reader *pfile;
{ {
int banner = 0; int banner = 0;
splay_tree_foreach (pfile->all_include_files, report_missing_guard, &banner); splay_tree_foreach (pfile->all_include_files, report_missing_guard, &banner);
...@@ -713,9 +676,7 @@ _cpp_report_missing_guards (pfile) ...@@ -713,9 +676,7 @@ _cpp_report_missing_guards (pfile)
/* Callback function for splay_tree_foreach(). */ /* Callback function for splay_tree_foreach(). */
static int static int
report_missing_guard (n, b) report_missing_guard (splay_tree_node n, void *b)
splay_tree_node n;
void *b;
{ {
struct include_file *f = (struct include_file *) n->value; struct include_file *f = (struct include_file *) n->value;
int *bannerp = (int *) b; int *bannerp = (int *) b;
...@@ -737,10 +698,8 @@ report_missing_guard (n, b) ...@@ -737,10 +698,8 @@ report_missing_guard (n, b)
appropriate. ANGLE_BRACKETS is nonzero if the file was bracketed appropriate. ANGLE_BRACKETS is nonzero if the file was bracketed
like <..>. */ like <..>. */
static void static void
handle_missing_header (pfile, fname, angle_brackets) handle_missing_header (cpp_reader *pfile, const char *fname,
cpp_reader *pfile; int angle_brackets)
const char *fname;
int angle_brackets;
{ {
bool print_dep bool print_dep
= CPP_OPTION (pfile, deps.style) > (angle_brackets || pfile->map->sysp); = CPP_OPTION (pfile, deps.style) > (angle_brackets || pfile->map->sysp);
...@@ -761,11 +720,8 @@ handle_missing_header (pfile, fname, angle_brackets) ...@@ -761,11 +720,8 @@ handle_missing_header (pfile, fname, angle_brackets)
including HEADER, and the command line -imacros and -include. including HEADER, and the command line -imacros and -include.
Returns true if a buffer was stacked. */ Returns true if a buffer was stacked. */
bool bool
_cpp_execute_include (pfile, fname, angle_brackets, type) _cpp_execute_include (cpp_reader *pfile, const char *fname, int angle_brackets,
cpp_reader *pfile; enum include_type type)
const char *fname;
int angle_brackets;
enum include_type type;
{ {
bool stacked = false; bool stacked = false;
struct include_file *inc; struct include_file *inc;
...@@ -788,10 +744,8 @@ _cpp_execute_include (pfile, fname, angle_brackets, type) ...@@ -788,10 +744,8 @@ _cpp_execute_include (pfile, fname, angle_brackets, type)
file. If it cannot be located or dated, return -1, if it is newer file. If it cannot be located or dated, return -1, if it is newer
newer, return 1, otherwise 0. */ newer, return 1, otherwise 0. */
int int
_cpp_compare_file_date (pfile, fname, angle_brackets) _cpp_compare_file_date (cpp_reader *pfile, const char *fname,
cpp_reader *pfile; int angle_brackets)
const char *fname;
int angle_brackets;
{ {
struct include_file *inc; struct include_file *inc;
...@@ -813,9 +767,7 @@ _cpp_compare_file_date (pfile, fname, angle_brackets) ...@@ -813,9 +767,7 @@ _cpp_compare_file_date (pfile, fname, angle_brackets)
FNAME is "", read standard input. Return true if a buffer was FNAME is "", read standard input. Return true if a buffer was
stacked. */ stacked. */
bool bool
_cpp_read_file (pfile, fname) _cpp_read_file (cpp_reader *pfile, const char *fname)
cpp_reader *pfile;
const char *fname;
{ {
/* This uses open_file, because we don't allow a PCH to be used as /* This uses open_file, because we don't allow a PCH to be used as
the toplevel compilation (that would prevent re-compiling an the toplevel compilation (that would prevent re-compiling an
...@@ -834,9 +786,7 @@ _cpp_read_file (pfile, fname) ...@@ -834,9 +786,7 @@ _cpp_read_file (pfile, fname)
/* Pushes the given file onto the buffer stack. Returns nonzero if /* Pushes the given file onto the buffer stack. Returns nonzero if
successful. */ successful. */
bool bool
cpp_push_include (pfile, filename) cpp_push_include (cpp_reader *pfile, const char *filename)
cpp_reader *pfile;
const char *filename;
{ {
/* Make the command line directive take up a line. */ /* Make the command line directive take up a line. */
pfile->line++; pfile->line++;
...@@ -846,9 +796,7 @@ cpp_push_include (pfile, filename) ...@@ -846,9 +796,7 @@ cpp_push_include (pfile, filename)
/* Do appropriate cleanup when a file INC's buffer is popped off the /* Do appropriate cleanup when a file INC's buffer is popped off the
input stack. */ input stack. */
void void
_cpp_pop_file_buffer (pfile, inc) _cpp_pop_file_buffer (cpp_reader *pfile, struct include_file *inc)
cpp_reader *pfile;
struct include_file *inc;
{ {
/* Record the inclusion-preventing macro, which could be NULL /* Record the inclusion-preventing macro, which could be NULL
meaning no controlling macro. */ meaning no controlling macro. */
...@@ -868,9 +816,7 @@ _cpp_pop_file_buffer (pfile, inc) ...@@ -868,9 +816,7 @@ _cpp_pop_file_buffer (pfile, inc)
If we're handling -include or -imacros, use the "" chain, but with If we're handling -include or -imacros, use the "" chain, but with
the preprocessor's cwd prepended. */ the preprocessor's cwd prepended. */
static struct cpp_path * static struct cpp_path *
search_from (pfile, type) search_from (cpp_reader *pfile, enum include_type type)
cpp_reader *pfile;
enum include_type type;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
unsigned int dlen; unsigned int dlen;
...@@ -933,9 +879,7 @@ struct file_name_map { ...@@ -933,9 +879,7 @@ struct file_name_map {
/* Read a space delimited string of unlimited length from a stdio /* Read a space delimited string of unlimited length from a stdio
file F. */ file F. */
static char * static char *
read_filename_string (ch, f) read_filename_string (int ch, FILE *f)
int ch;
FILE *f;
{ {
char *alloc, *set; char *alloc, *set;
int len; int len;
...@@ -970,9 +914,7 @@ struct file_name_map_list { ...@@ -970,9 +914,7 @@ struct file_name_map_list {
/* Read the file name map file for DIRNAME. */ /* Read the file name map file for DIRNAME. */
static struct file_name_map * static struct file_name_map *
read_name_map (pfile, dirname) read_name_map (cpp_reader *pfile, const char *dirname)
cpp_reader *pfile;
const char *dirname;
{ {
struct file_name_map_list *map_list_ptr; struct file_name_map_list *map_list_ptr;
char *name; char *name;
...@@ -1048,10 +990,7 @@ read_name_map (pfile, dirname) ...@@ -1048,10 +990,7 @@ read_name_map (pfile, dirname)
/* Remap an unsimplified path NAME based on the file_name_map (if any) /* Remap an unsimplified path NAME based on the file_name_map (if any)
for LOC. */ for LOC. */
static char * static char *
remap_filename (pfile, name, loc) remap_filename (cpp_reader *pfile, char *name, struct cpp_path *loc)
cpp_reader *pfile;
char *name;
struct cpp_path *loc;
{ {
struct file_name_map *map; struct file_name_map *map;
const char *from, *p; const char *from, *p;
...@@ -1106,10 +1045,8 @@ remap_filename (pfile, name, loc) ...@@ -1106,10 +1045,8 @@ remap_filename (pfile, name, loc)
If BRACKET does not lie in the QUOTE chain, it is set to QUOTE. */ If BRACKET does not lie in the QUOTE chain, it is set to QUOTE. */
void void
cpp_set_include_chains (pfile, quote, bracket, quote_ignores_source_dir) cpp_set_include_chains (cpp_reader *pfile, cpp_path *quote, cpp_path *bracket,
cpp_reader *pfile; int quote_ignores_source_dir)
cpp_path *quote, *bracket;
int quote_ignores_source_dir;
{ {
pfile->quote_include = quote; pfile->quote_include = quote;
pfile->bracket_include = quote; pfile->bracket_include = quote;
...@@ -1132,8 +1069,7 @@ cpp_set_include_chains (pfile, quote, bracket, quote_ignores_source_dir) ...@@ -1132,8 +1069,7 @@ cpp_set_include_chains (pfile, quote, bracket, quote_ignores_source_dir)
symlinks if we have it. If not, we can still catch errors with symlinks if we have it. If not, we can still catch errors with
stat (). */ stat (). */
static int static int
remove_component_p (path) remove_component_p (const char *path)
const char *path;
{ {
struct stat s; struct stat s;
int result; int result;
...@@ -1168,8 +1104,7 @@ remove_component_p (path) ...@@ -1168,8 +1104,7 @@ remove_component_p (path)
of the string. Returns PATH. errno is 0 if no error occurred; of the string. Returns PATH. errno is 0 if no error occurred;
nonzero if an error occurred when using stat () or lstat (). */ nonzero if an error occurred when using stat () or lstat (). */
void void
cpp_simplify_path (path) cpp_simplify_path (char *path ATTRIBUTE_UNUSED)
char *path ATTRIBUTE_UNUSED;
{ {
#ifndef VMS #ifndef VMS
char *from, *to; char *from, *to;
......
...@@ -30,13 +30,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -30,13 +30,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpplib.h" #include "cpplib.h"
#include "cpphash.h" #include "cpphash.h"
static cpp_hashnode *alloc_node PARAMS ((hash_table *)); static cpp_hashnode *alloc_node (hash_table *);
/* Return an identifier node for hashtable.c. Used by cpplib except /* Return an identifier node for hashtable.c. Used by cpplib except
when integrated with the C front ends. */ when integrated with the C front ends. */
static cpp_hashnode * static cpp_hashnode *
alloc_node (table) alloc_node (hash_table *table)
hash_table *table;
{ {
cpp_hashnode *node; cpp_hashnode *node;
...@@ -49,9 +48,7 @@ alloc_node (table) ...@@ -49,9 +48,7 @@ alloc_node (table)
/* Set up the identifier hash table. Use TABLE if non-null, otherwise /* Set up the identifier hash table. Use TABLE if non-null, otherwise
create our own. */ create our own. */
void void
_cpp_init_hashtable (pfile, table) _cpp_init_hashtable (cpp_reader *pfile, hash_table *table)
cpp_reader *pfile;
hash_table *table;
{ {
struct spec_nodes *s; struct spec_nodes *s;
...@@ -59,7 +56,7 @@ _cpp_init_hashtable (pfile, table) ...@@ -59,7 +56,7 @@ _cpp_init_hashtable (pfile, table)
{ {
pfile->our_hashtable = 1; pfile->our_hashtable = 1;
table = ht_create (13); /* 8K (=2^13) entries. */ table = ht_create (13); /* 8K (=2^13) entries. */
table->alloc_node = (hashnode (*) PARAMS ((hash_table *))) alloc_node; table->alloc_node = (hashnode (*) (hash_table *)) alloc_node;
gcc_obstack_init (&pfile->hash_ob); gcc_obstack_init (&pfile->hash_ob);
} }
...@@ -80,8 +77,7 @@ _cpp_init_hashtable (pfile, table) ...@@ -80,8 +77,7 @@ _cpp_init_hashtable (pfile, table)
/* Tear down the identifier hash table. */ /* Tear down the identifier hash table. */
void void
_cpp_destroy_hashtable (pfile) _cpp_destroy_hashtable (cpp_reader *pfile)
cpp_reader *pfile;
{ {
if (pfile->our_hashtable) if (pfile->our_hashtable)
{ {
...@@ -93,10 +89,7 @@ _cpp_destroy_hashtable (pfile) ...@@ -93,10 +89,7 @@ _cpp_destroy_hashtable (pfile)
/* Returns the hash entry for the STR of length LEN, creating one /* Returns the hash entry for the STR of length LEN, creating one
if necessary. */ if necessary. */
cpp_hashnode * cpp_hashnode *
cpp_lookup (pfile, str, len) cpp_lookup (cpp_reader *pfile, const unsigned char *str, unsigned int len)
cpp_reader *pfile;
const unsigned char *str;
unsigned int len;
{ {
/* ht_lookup cannot return NULL. */ /* ht_lookup cannot return NULL. */
return CPP_HASHNODE (ht_lookup (pfile->hash_table, str, len, HT_ALLOC)); return CPP_HASHNODE (ht_lookup (pfile->hash_table, str, len, HT_ALLOC));
...@@ -104,10 +97,7 @@ cpp_lookup (pfile, str, len) ...@@ -104,10 +97,7 @@ cpp_lookup (pfile, str, len)
/* Determine whether the str STR, of length LEN, is a defined macro. */ /* Determine whether the str STR, of length LEN, is a defined macro. */
int int
cpp_defined (pfile, str, len) cpp_defined (cpp_reader *pfile, const unsigned char *str, int len)
cpp_reader *pfile;
const unsigned char *str;
int len;
{ {
cpp_hashnode *node; cpp_hashnode *node;
...@@ -120,10 +110,7 @@ cpp_defined (pfile, str, len) ...@@ -120,10 +110,7 @@ cpp_defined (pfile, str, len)
/* For all nodes in the hashtable, callback CB with parameters PFILE, /* For all nodes in the hashtable, callback CB with parameters PFILE,
the node, and V. */ the node, and V. */
void void
cpp_forall_identifiers (pfile, cb, v) cpp_forall_identifiers (cpp_reader *pfile, cpp_cb cb, void *v)
cpp_reader *pfile;
cpp_cb cb;
void *v;
{ {
/* We don't need a proxy since the hash table's identifier comes /* We don't need a proxy since the hash table's identifier comes
first in cpp_hashnode. */ first in cpp_hashnode. */
......
...@@ -117,14 +117,13 @@ struct _cpp_buff ...@@ -117,14 +117,13 @@ struct _cpp_buff
unsigned char *base, *cur, *limit; unsigned char *base, *cur, *limit;
}; };
extern _cpp_buff *_cpp_get_buff PARAMS ((cpp_reader *, size_t)); extern _cpp_buff *_cpp_get_buff (cpp_reader *, size_t);
extern void _cpp_release_buff PARAMS ((cpp_reader *, _cpp_buff *)); extern void _cpp_release_buff (cpp_reader *, _cpp_buff *);
extern void _cpp_extend_buff PARAMS ((cpp_reader *, _cpp_buff **, size_t)); extern void _cpp_extend_buff (cpp_reader *, _cpp_buff **, size_t);
extern _cpp_buff *_cpp_append_extend_buff PARAMS ((cpp_reader *, _cpp_buff *, extern _cpp_buff *_cpp_append_extend_buff (cpp_reader *, _cpp_buff *, size_t);
size_t)); extern void _cpp_free_buff (_cpp_buff *);
extern void _cpp_free_buff PARAMS ((_cpp_buff *)); extern unsigned char *_cpp_aligned_alloc (cpp_reader *, size_t);
extern unsigned char *_cpp_aligned_alloc PARAMS ((cpp_reader *, size_t)); extern unsigned char *_cpp_unaligned_alloc (cpp_reader *, size_t);
extern unsigned char *_cpp_unaligned_alloc PARAMS ((cpp_reader *, size_t));
#define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur) #define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur)
#define BUFF_FRONT(BUFF) ((BUFF)->cur) #define BUFF_FRONT(BUFF) ((BUFF)->cur)
...@@ -468,90 +467,79 @@ extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1]; ...@@ -468,90 +467,79 @@ extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
#define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional) #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
/* In cpperror.c */ /* In cpperror.c */
extern int _cpp_begin_message PARAMS ((cpp_reader *, int, extern int _cpp_begin_message (cpp_reader *, int, unsigned int, unsigned int);
unsigned int, unsigned int));
/* In cppmacro.c */ /* In cppmacro.c */
extern void _cpp_free_definition PARAMS ((cpp_hashnode *)); extern void _cpp_free_definition (cpp_hashnode *);
extern bool _cpp_create_definition PARAMS ((cpp_reader *, cpp_hashnode *)); extern bool _cpp_create_definition (cpp_reader *, cpp_hashnode *);
extern void _cpp_pop_context PARAMS ((cpp_reader *)); extern void _cpp_pop_context (cpp_reader *);
extern void _cpp_push_text_context PARAMS ((cpp_reader *, cpp_hashnode *, extern void _cpp_push_text_context (cpp_reader *, cpp_hashnode *,
const uchar *, size_t)); const uchar *, size_t);
extern bool _cpp_save_parameter PARAMS ((cpp_reader *, cpp_macro *, extern bool _cpp_save_parameter (cpp_reader *, cpp_macro *, cpp_hashnode *);
cpp_hashnode *)); extern bool _cpp_arguments_ok (cpp_reader *, cpp_macro *, const cpp_hashnode *,
extern bool _cpp_arguments_ok PARAMS ((cpp_reader *, cpp_macro *, unsigned int);
const cpp_hashnode *, extern const uchar *_cpp_builtin_macro_text (cpp_reader *, cpp_hashnode *);
unsigned int)); int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *);
extern const uchar *_cpp_builtin_macro_text PARAMS ((cpp_reader *,
cpp_hashnode *));
int _cpp_warn_if_unused_macro PARAMS ((cpp_reader *, cpp_hashnode *,
void *));
/* In cpphash.c */ /* In cpphash.c */
extern void _cpp_init_hashtable PARAMS ((cpp_reader *, hash_table *)); extern void _cpp_init_hashtable (cpp_reader *, hash_table *);
extern void _cpp_destroy_hashtable PARAMS ((cpp_reader *)); extern void _cpp_destroy_hashtable (cpp_reader *);
/* In cppfiles.c */ /* In cppfiles.c */
extern void _cpp_fake_include PARAMS ((cpp_reader *, const char *)); extern void _cpp_fake_include (cpp_reader *, const char *);
extern void _cpp_never_reread PARAMS ((struct include_file *)); extern void _cpp_never_reread (struct include_file *);
extern bool _cpp_read_file PARAMS ((cpp_reader *, const char *)); extern bool _cpp_read_file (cpp_reader *, const char *);
extern bool _cpp_execute_include PARAMS ((cpp_reader *, const char *, extern bool _cpp_execute_include (cpp_reader *, const char *, int,
int, enum include_type)); enum include_type);
extern int _cpp_compare_file_date PARAMS ((cpp_reader *, const char *, extern int _cpp_compare_file_date (cpp_reader *, const char *, int);
int)); extern void _cpp_report_missing_guards (cpp_reader *);
extern void _cpp_report_missing_guards PARAMS ((cpp_reader *)); extern void _cpp_init_includes (cpp_reader *);
extern void _cpp_init_includes PARAMS ((cpp_reader *)); extern void _cpp_cleanup_includes (cpp_reader *);
extern void _cpp_cleanup_includes PARAMS ((cpp_reader *)); extern void _cpp_pop_file_buffer (cpp_reader *, struct include_file *);
extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *,
struct include_file *));
/* In cppexp.c */ /* In cppexp.c */
extern bool _cpp_parse_expr PARAMS ((cpp_reader *)); extern bool _cpp_parse_expr (cpp_reader *);
extern struct op *_cpp_expand_op_stack PARAMS ((cpp_reader *)); extern struct op *_cpp_expand_op_stack (cpp_reader *);
/* In cpplex.c */ /* In cpplex.c */
extern void _cpp_process_line_notes PARAMS ((cpp_reader *, int)); extern void _cpp_process_line_notes (cpp_reader *, int);
extern void _cpp_clean_line PARAMS ((cpp_reader *)); extern void _cpp_clean_line (cpp_reader *);
extern bool _cpp_get_fresh_line PARAMS ((cpp_reader *)); extern bool _cpp_get_fresh_line (cpp_reader *);
extern bool _cpp_skip_block_comment PARAMS ((cpp_reader *)); extern bool _cpp_skip_block_comment (cpp_reader *);
extern cpp_token *_cpp_temp_token PARAMS ((cpp_reader *)); extern cpp_token *_cpp_temp_token (cpp_reader *);
extern const cpp_token *_cpp_lex_token PARAMS ((cpp_reader *)); extern const cpp_token *_cpp_lex_token (cpp_reader *);
extern cpp_token *_cpp_lex_direct PARAMS ((cpp_reader *)); extern cpp_token *_cpp_lex_direct (cpp_reader *);
extern int _cpp_equiv_tokens PARAMS ((const cpp_token *, extern int _cpp_equiv_tokens (const cpp_token *, const cpp_token *);
const cpp_token *)); extern void _cpp_init_tokenrun (tokenrun *, unsigned int);
extern void _cpp_init_tokenrun PARAMS ((tokenrun *, unsigned int));
/* In cppinit.c. */ /* In cppinit.c. */
extern void _cpp_maybe_push_include_file PARAMS ((cpp_reader *)); extern void _cpp_maybe_push_include_file (cpp_reader *);
/* In cpplib.c */ /* In cpplib.c */
extern int _cpp_test_assertion PARAMS ((cpp_reader *, unsigned int *)); extern int _cpp_test_assertion (cpp_reader *, unsigned int *);
extern int _cpp_handle_directive PARAMS ((cpp_reader *, int)); extern int _cpp_handle_directive (cpp_reader *, int);
extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *)); extern void _cpp_define_builtin (cpp_reader *, const char *);
extern char ** _cpp_save_pragma_names PARAMS ((cpp_reader *)); extern char ** _cpp_save_pragma_names (cpp_reader *);
extern void _cpp_restore_pragma_names PARAMS ((cpp_reader *, char **)); extern void _cpp_restore_pragma_names (cpp_reader *, char **);
extern void _cpp_do__Pragma PARAMS ((cpp_reader *)); extern void _cpp_do__Pragma (cpp_reader *);
extern void _cpp_init_directives PARAMS ((cpp_reader *)); extern void _cpp_init_directives (cpp_reader *);
extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *)); extern void _cpp_init_internal_pragmas (cpp_reader *);
extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason, extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
const char *, unsigned int, unsigned int);
unsigned int, unsigned int)); extern void _cpp_pop_buffer (cpp_reader *);
extern void _cpp_pop_buffer PARAMS ((cpp_reader *));
/* In cpptrad.c. */ /* In cpptrad.c. */
extern bool scan_out_logical_line PARAMS ((cpp_reader *, cpp_macro *)); extern bool scan_out_logical_line (cpp_reader *, cpp_macro *);
extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *)); extern bool _cpp_read_logical_line_trad (cpp_reader *);
extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *, extern void _cpp_overlay_buffer (cpp_reader *pfile, const uchar *, size_t);
size_t)); extern void _cpp_remove_overlay (cpp_reader *);
extern void _cpp_remove_overlay PARAMS ((cpp_reader *)); extern bool _cpp_create_trad_definition (cpp_reader *, cpp_macro *);
extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *)); extern bool _cpp_expansions_different_trad (const cpp_macro *,
extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *, const cpp_macro *);
const cpp_macro *)); extern uchar *_cpp_copy_replacement_text (const cpp_macro *, uchar *);
extern uchar *_cpp_copy_replacement_text PARAMS ((const cpp_macro *, uchar *)); extern size_t _cpp_replacement_text_len (const cpp_macro *);
extern size_t _cpp_replacement_text_len PARAMS ((const cpp_macro *));
/* In cppcharset.c. */ /* In cppcharset.c. */
cppchar_t _cpp_valid_ucn PARAMS ((cpp_reader *, const uchar **, cppchar_t _cpp_valid_ucn (cpp_reader *, const uchar **, int identifer_p);
int identifer_p));
/* Utility routines and macros. */ /* Utility routines and macros. */
#define DSC(str) (const uchar *)str, sizeof str - 1 #define DSC(str) (const uchar *)str, sizeof str - 1
...@@ -563,55 +551,45 @@ cppchar_t _cpp_valid_ucn PARAMS ((cpp_reader *, const uchar **, ...@@ -563,55 +551,45 @@ cppchar_t _cpp_valid_ucn PARAMS ((cpp_reader *, const uchar **,
/* These are inline functions instead of macros so we can get type /* These are inline functions instead of macros so we can get type
checking. */ checking. */
static inline int ustrcmp PARAMS ((const uchar *, const uchar *)); static inline int ustrcmp (const uchar *, const uchar *);
static inline int ustrncmp PARAMS ((const uchar *, const uchar *, static inline int ustrncmp (const uchar *, const uchar *, size_t);
size_t)); static inline size_t ustrlen (const uchar *);
static inline size_t ustrlen PARAMS ((const uchar *)); static inline uchar *uxstrdup (const uchar *);
static inline uchar *uxstrdup PARAMS ((const uchar *)); static inline uchar *ustrchr (const uchar *, int);
static inline uchar *ustrchr PARAMS ((const uchar *, int)); static inline int ufputs (const uchar *, FILE *);
static inline int ufputs PARAMS ((const uchar *, FILE *));
static inline int static inline int
ustrcmp (s1, s2) ustrcmp (const uchar *s1, const uchar *s2)
const uchar *s1, *s2;
{ {
return strcmp ((const char *)s1, (const char *)s2); return strcmp ((const char *)s1, (const char *)s2);
} }
static inline int static inline int
ustrncmp (s1, s2, n) ustrncmp (const uchar *s1, const uchar *s2, size_t n)
const uchar *s1, *s2;
size_t n;
{ {
return strncmp ((const char *)s1, (const char *)s2, n); return strncmp ((const char *)s1, (const char *)s2, n);
} }
static inline size_t static inline size_t
ustrlen (s1) ustrlen (const uchar *s1)
const uchar *s1;
{ {
return strlen ((const char *)s1); return strlen ((const char *)s1);
} }
static inline uchar * static inline uchar *
uxstrdup (s1) uxstrdup (const uchar *s1)
const uchar *s1;
{ {
return (uchar *) xstrdup ((const char *)s1); return (uchar *) xstrdup ((const char *)s1);
} }
static inline uchar * static inline uchar *
ustrchr (s1, c) ustrchr (const uchar *s1, int c)
const uchar *s1;
int c;
{ {
return (uchar *) strchr ((const char *)s1, c); return (uchar *) strchr ((const char *)s1, c);
} }
static inline int static inline int
ufputs (s, f) ufputs (const uchar *s, FILE *f)
const uchar *s;
FILE *f;
{ {
return fputs ((const char *)s, f); return fputs ((const char *)s, f);
} }
......
...@@ -27,10 +27,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -27,10 +27,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpphash.h" #include "cpphash.h"
#include "mkdeps.h" #include "mkdeps.h"
static void init_library PARAMS ((void)); static void init_library (void);
static void mark_named_operators PARAMS ((cpp_reader *)); static void mark_named_operators (cpp_reader *);
static void read_original_filename PARAMS ((cpp_reader *)); static void read_original_filename (cpp_reader *);
static void post_options PARAMS ((cpp_reader *)); static void post_options (cpp_reader *);
/* If we have designated initializers (GCC >2.7) these tables can be /* If we have designated initializers (GCC >2.7) these tables can be
initialized, constant data. Otherwise, they have to be filled in at initialized, constant data. Otherwise, they have to be filled in at
...@@ -47,7 +47,7 @@ __extension__ const uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { ...@@ -47,7 +47,7 @@ __extension__ const uchar _cpp_trigraph_map[UCHAR_MAX + 1] = {
#else #else
#define TRIGRAPH_MAP uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \ #define TRIGRAPH_MAP uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
static void init_trigraph_map PARAMS ((void)) { \ static void init_trigraph_map (void) { \
unsigned char *x = _cpp_trigraph_map; unsigned char *x = _cpp_trigraph_map;
#define END } #define END }
...@@ -91,9 +91,7 @@ static const struct lang_flags lang_defaults[] = ...@@ -91,9 +91,7 @@ static const struct lang_flags lang_defaults[] =
/* Sets internal flags correctly for a given language. */ /* Sets internal flags correctly for a given language. */
void void
cpp_set_lang (pfile, lang) cpp_set_lang (cpp_reader *pfile, enum c_lang lang)
cpp_reader *pfile;
enum c_lang lang;
{ {
const struct lang_flags *l = &lang_defaults[(int) lang]; const struct lang_flags *l = &lang_defaults[(int) lang];
...@@ -110,7 +108,7 @@ cpp_set_lang (pfile, lang) ...@@ -110,7 +108,7 @@ cpp_set_lang (pfile, lang)
/* Initialize library global state. */ /* Initialize library global state. */
static void static void
init_library () init_library (void)
{ {
static int initialized = 0; static int initialized = 0;
...@@ -127,9 +125,7 @@ init_library () ...@@ -127,9 +125,7 @@ init_library ()
/* Initialize a cpp_reader structure. */ /* Initialize a cpp_reader structure. */
cpp_reader * cpp_reader *
cpp_create_reader (lang, table) cpp_create_reader (enum c_lang lang, hash_table *table)
enum c_lang lang;
hash_table *table;
{ {
cpp_reader *pfile; cpp_reader *pfile;
...@@ -205,8 +201,7 @@ cpp_create_reader (lang, table) ...@@ -205,8 +201,7 @@ cpp_create_reader (lang, table)
/* Free resources used by PFILE. Accessing PFILE after this function /* Free resources used by PFILE. Accessing PFILE after this function
returns leads to undefined behavior. Returns the error count. */ returns leads to undefined behavior. Returns the error count. */
void void
cpp_destroy (pfile) cpp_destroy (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_context *context, *contextn; cpp_context *context, *contextn;
tokenrun *run, *runn; tokenrun *run, *runn;
...@@ -309,8 +304,7 @@ static const struct builtin operator_array[] = ...@@ -309,8 +304,7 @@ static const struct builtin operator_array[] =
/* Mark the C++ named operators in the hash table. */ /* Mark the C++ named operators in the hash table. */
static void static void
mark_named_operators (pfile) mark_named_operators (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const struct builtin *b; const struct builtin *b;
...@@ -329,9 +323,7 @@ mark_named_operators (pfile) ...@@ -329,9 +323,7 @@ mark_named_operators (pfile)
macros, into the hash table. HOSTED is true if this is a hosted macros, into the hash table. HOSTED is true if this is a hosted
environment. */ environment. */
void void
cpp_init_builtins (pfile, hosted) cpp_init_builtins (cpp_reader *pfile, int hosted)
cpp_reader *pfile;
int hosted;
{ {
const struct builtin *b; const struct builtin *b;
size_t n = ARRAY_SIZE (builtin_array); size_t n = ARRAY_SIZE (builtin_array);
...@@ -368,9 +360,8 @@ cpp_init_builtins (pfile, hosted) ...@@ -368,9 +360,8 @@ cpp_init_builtins (pfile, hosted)
/* Sanity-checks are dependent on command-line options, so it is /* Sanity-checks are dependent on command-line options, so it is
called as a subroutine of cpp_read_main_file (). */ called as a subroutine of cpp_read_main_file (). */
#if ENABLE_CHECKING #if ENABLE_CHECKING
static void sanity_checks PARAMS ((cpp_reader *)); static void sanity_checks (cpp_reader *);
static void sanity_checks (pfile) static void sanity_checks (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cppchar_t test = 0; cppchar_t test = 0;
size_t max_precision = 2 * CHAR_BIT * sizeof (cpp_num_part); size_t max_precision = 2 * CHAR_BIT * sizeof (cpp_num_part);
...@@ -383,7 +374,8 @@ static void sanity_checks (pfile) ...@@ -383,7 +374,8 @@ static void sanity_checks (pfile)
if (CPP_OPTION (pfile, precision) > max_precision) if (CPP_OPTION (pfile, precision) > max_precision)
cpp_error (pfile, DL_ICE, cpp_error (pfile, DL_ICE,
"preprocessor arithmetic has maximum precision of %lu bits; target requires %lu bits", "preprocessor arithmetic has maximum precision of %lu bits;"
" target requires %lu bits",
(unsigned long) max_precision, (unsigned long) max_precision,
(unsigned long) CPP_OPTION (pfile, precision)); (unsigned long) CPP_OPTION (pfile, precision));
...@@ -408,7 +400,8 @@ static void sanity_checks (pfile) ...@@ -408,7 +400,8 @@ static void sanity_checks (pfile)
if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T) if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T)
cpp_error (pfile, DL_ICE, cpp_error (pfile, DL_ICE,
"CPP on this host cannot handle wide character constants over %lu bits, but the target requires %lu bits", "CPP on this host cannot handle wide character constants over"
" %lu bits, but the target requires %lu bits",
(unsigned long) BITS_PER_CPPCHAR_T, (unsigned long) BITS_PER_CPPCHAR_T,
(unsigned long) CPP_OPTION (pfile, wchar_precision)); (unsigned long) CPP_OPTION (pfile, wchar_precision));
} }
...@@ -420,10 +413,7 @@ static void sanity_checks (pfile) ...@@ -420,10 +413,7 @@ static void sanity_checks (pfile)
cpp_read_main_file(). If no targets have been added before cpp_read_main_file(). If no targets have been added before
cpp_read_main_file(), then the default target is used. */ cpp_read_main_file(), then the default target is used. */
void void
cpp_add_dependency_target (pfile, target, quote) cpp_add_dependency_target (cpp_reader *pfile, const char *target, int quote)
cpp_reader *pfile;
const char *target;
int quote;
{ {
if (!pfile->deps) if (!pfile->deps)
pfile->deps = deps_init (); pfile->deps = deps_init ();
...@@ -436,9 +426,7 @@ cpp_add_dependency_target (pfile, target, quote) ...@@ -436,9 +426,7 @@ cpp_add_dependency_target (pfile, target, quote)
or stdin if it is the empty string. Return the original filename or stdin if it is the empty string. Return the original filename
on success (e.g. foo.i->foo.c), or NULL on failure. */ on success (e.g. foo.i->foo.c), or NULL on failure. */
const char * const char *
cpp_read_main_file (pfile, fname) cpp_read_main_file (cpp_reader *pfile, const char *fname)
cpp_reader *pfile;
const char *fname;
{ {
sanity_checks (pfile); sanity_checks (pfile);
...@@ -480,8 +468,7 @@ cpp_read_main_file (pfile, fname) ...@@ -480,8 +468,7 @@ cpp_read_main_file (pfile, fname)
generate file_change callbacks, which the front ends must handle generate file_change callbacks, which the front ends must handle
appropriately given their state of initialization. */ appropriately given their state of initialization. */
static void static void
read_original_filename (pfile) read_original_filename (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *token, *token1; const cpp_token *token, *token1;
...@@ -512,9 +499,7 @@ read_original_filename (pfile) ...@@ -512,9 +499,7 @@ read_original_filename (pfile)
Maybe it should also reset state, such that you could call Maybe it should also reset state, such that you could call
cpp_start_read with a new filename to restart processing. */ cpp_start_read with a new filename to restart processing. */
int int
cpp_finish (pfile, deps_stream) cpp_finish (cpp_reader *pfile, FILE *deps_stream)
cpp_reader *pfile;
FILE *deps_stream;
{ {
/* Warn about unused macros before popping the final buffer. */ /* Warn about unused macros before popping the final buffer. */
if (CPP_OPTION (pfile, warn_unused_macros)) if (CPP_OPTION (pfile, warn_unused_macros))
...@@ -546,8 +531,7 @@ cpp_finish (pfile, deps_stream) ...@@ -546,8 +531,7 @@ cpp_finish (pfile, deps_stream)
} }
static void static void
post_options (pfile) post_options (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* -Wtraditional is not useful in C++ mode. */ /* -Wtraditional is not useful in C++ mode. */
if (CPP_OPTION (pfile, cplusplus)) if (CPP_OPTION (pfile, cplusplus))
......
...@@ -52,24 +52,23 @@ static const struct token_spelling token_spellings[N_TTYPES] = { TTYPE_TABLE }; ...@@ -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_SPELL(token) (token_spellings[(token)->type].category)
#define TOKEN_NAME(token) (token_spellings[(token)->type].name) #define TOKEN_NAME(token) (token_spellings[(token)->type].name)
static void add_line_note PARAMS ((cpp_buffer *, const uchar *, unsigned int)); static void add_line_note (cpp_buffer *, const uchar *, unsigned int);
static int skip_line_comment PARAMS ((cpp_reader *)); static int skip_line_comment (cpp_reader *);
static void skip_whitespace PARAMS ((cpp_reader *, cppchar_t)); static void skip_whitespace (cpp_reader *, cppchar_t);
static cpp_hashnode *lex_identifier PARAMS ((cpp_reader *, const uchar *)); static cpp_hashnode *lex_identifier (cpp_reader *, const uchar *);
static void lex_number PARAMS ((cpp_reader *, cpp_string *)); static void lex_number (cpp_reader *, cpp_string *);
static bool forms_identifier_p PARAMS ((cpp_reader *, int)); static bool forms_identifier_p (cpp_reader *, int);
static void lex_string PARAMS ((cpp_reader *, cpp_token *, const uchar *)); static void lex_string (cpp_reader *, cpp_token *, const uchar *);
static void save_comment PARAMS ((cpp_reader *, cpp_token *, const uchar *, static void save_comment (cpp_reader *, cpp_token *, const uchar *, cppchar_t);
cppchar_t)); static void create_literal (cpp_reader *, cpp_token *, const uchar *,
static void create_literal PARAMS ((cpp_reader *, cpp_token *, const uchar *, unsigned int, enum cpp_ttype);
unsigned int, enum cpp_ttype)); static bool warn_in_comment (cpp_reader *, _cpp_line_note *);
static bool warn_in_comment PARAMS ((cpp_reader *, _cpp_line_note *)); static int name_p (cpp_reader *, const cpp_string *);
static int name_p PARAMS ((cpp_reader *, const cpp_string *)); static cppchar_t maybe_read_ucn (cpp_reader *, const uchar **);
static cppchar_t maybe_read_ucn PARAMS ((cpp_reader *, const uchar **)); static tokenrun *next_tokenrun (tokenrun *);
static tokenrun *next_tokenrun PARAMS ((tokenrun *));
static unsigned int hex_digit_value (unsigned int);
static unsigned int hex_digit_value PARAMS ((unsigned int)); static _cpp_buff *new_buff (size_t);
static _cpp_buff *new_buff PARAMS ((size_t));
/* Utility routine: /* Utility routine:
...@@ -77,9 +76,7 @@ static _cpp_buff *new_buff PARAMS ((size_t)); ...@@ -77,9 +76,7 @@ static _cpp_buff *new_buff PARAMS ((size_t));
Compares, the token TOKEN to the NUL-terminated string STRING. Compares, the token TOKEN to the NUL-terminated string STRING.
TOKEN must be a CPP_NAME. Returns 1 for equal, 0 for unequal. */ TOKEN must be a CPP_NAME. Returns 1 for equal, 0 for unequal. */
int int
cpp_ideq (token, string) cpp_ideq (const cpp_token *token, const char *string)
const cpp_token *token;
const char *string;
{ {
if (token->type != CPP_NAME) if (token->type != CPP_NAME)
return 0; return 0;
...@@ -90,10 +87,7 @@ cpp_ideq (token, string) ...@@ -90,10 +87,7 @@ cpp_ideq (token, string)
/* Record a note TYPE at byte POS into the current cleaned logical /* Record a note TYPE at byte POS into the current cleaned logical
line. */ line. */
static void static void
add_line_note (buffer, pos, type) add_line_note (cpp_buffer *buffer, const uchar *pos, unsigned int type)
cpp_buffer *buffer;
const uchar *pos;
unsigned int type;
{ {
if (buffer->notes_used == buffer->notes_cap) if (buffer->notes_used == buffer->notes_cap)
{ {
...@@ -110,8 +104,7 @@ add_line_note (buffer, pos, type) ...@@ -110,8 +104,7 @@ add_line_note (buffer, pos, type)
/* Returns with a logical line that contains no escaped newlines or /* Returns with a logical line that contains no escaped newlines or
trigraphs. This is a time-critical inner loop. */ trigraphs. This is a time-critical inner loop. */
void void
_cpp_clean_line (pfile) _cpp_clean_line (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer; cpp_buffer *buffer;
const uchar *s; const uchar *s;
...@@ -184,9 +177,7 @@ _cpp_clean_line (pfile) ...@@ -184,9 +177,7 @@ _cpp_clean_line (pfile)
/* Return true if the trigraph indicated by NOTE should be warned /* Return true if the trigraph indicated by NOTE should be warned
about in a comment. */ about in a comment. */
static bool static bool
warn_in_comment (pfile, note) warn_in_comment (cpp_reader *pfile, _cpp_line_note *note)
cpp_reader *pfile;
_cpp_line_note *note;
{ {
const uchar *p; const uchar *p;
...@@ -214,9 +205,7 @@ warn_in_comment (pfile, note) ...@@ -214,9 +205,7 @@ warn_in_comment (pfile, note)
/* Process the notes created by add_line_note as far as the current /* Process the notes created by add_line_note as far as the current
location. */ location. */
void void
_cpp_process_line_notes (pfile, in_comment) _cpp_process_line_notes (cpp_reader *pfile, int in_comment)
cpp_reader *pfile;
int in_comment;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
...@@ -275,8 +264,7 @@ _cpp_process_line_notes (pfile, in_comment) ...@@ -275,8 +264,7 @@ _cpp_process_line_notes (pfile, in_comment)
Buffer->cur points to the initial asterisk of the comment. */ Buffer->cur points to the initial asterisk of the comment. */
bool bool
_cpp_skip_block_comment (pfile) _cpp_skip_block_comment (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
cppchar_t c; cppchar_t c;
...@@ -324,8 +312,7 @@ _cpp_skip_block_comment (pfile) ...@@ -324,8 +312,7 @@ _cpp_skip_block_comment (pfile)
terminating newline. Handles escaped newlines. Returns nonzero terminating newline. Handles escaped newlines. Returns nonzero
if a multiline comment. */ if a multiline comment. */
static int static int
skip_line_comment (pfile) skip_line_comment (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
unsigned int orig_line = pfile->line; unsigned int orig_line = pfile->line;
...@@ -339,9 +326,7 @@ skip_line_comment (pfile) ...@@ -339,9 +326,7 @@ skip_line_comment (pfile)
/* Skips whitespace, saving the next non-whitespace character. */ /* Skips whitespace, saving the next non-whitespace character. */
static void static void
skip_whitespace (pfile, c) skip_whitespace (cpp_reader *pfile, cppchar_t c)
cpp_reader *pfile;
cppchar_t c;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
bool saw_NUL = false; bool saw_NUL = false;
...@@ -374,9 +359,7 @@ skip_whitespace (pfile, c) ...@@ -374,9 +359,7 @@ skip_whitespace (pfile, c)
/* See if the characters of a number token are valid in a name (no /* See if the characters of a number token are valid in a name (no
'.', '+' or '-'). */ '.', '+' or '-'). */
static int static int
name_p (pfile, string) name_p (cpp_reader *pfile, const cpp_string *string)
cpp_reader *pfile;
const cpp_string *string;
{ {
unsigned int i; unsigned int i;
...@@ -390,9 +373,7 @@ name_p (pfile, string) ...@@ -390,9 +373,7 @@ name_p (pfile, string)
/* Returns TRUE if the sequence starting at buffer->cur is invalid in /* Returns TRUE if the sequence starting at buffer->cur is invalid in
an identifier. FIRST is TRUE if this starts an identifier. */ an identifier. FIRST is TRUE if this starts an identifier. */
static bool static bool
forms_identifier_p (pfile, first) forms_identifier_p (cpp_reader *pfile, int first)
cpp_reader *pfile;
int first;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
...@@ -426,9 +407,7 @@ forms_identifier_p (pfile, first) ...@@ -426,9 +407,7 @@ forms_identifier_p (pfile, first)
/* Lex an identifier starting at BUFFER->CUR - 1. */ /* Lex an identifier starting at BUFFER->CUR - 1. */
static cpp_hashnode * static cpp_hashnode *
lex_identifier (pfile, base) lex_identifier (cpp_reader *pfile, const uchar *base)
cpp_reader *pfile;
const uchar *base;
{ {
cpp_hashnode *result; cpp_hashnode *result;
const uchar *cur; const uchar *cur;
...@@ -462,7 +441,8 @@ lex_identifier (pfile, base) ...@@ -462,7 +441,8 @@ lex_identifier (pfile, base)
if (result == pfile->spec_nodes.n__VA_ARGS__ if (result == pfile->spec_nodes.n__VA_ARGS__
&& !pfile->state.va_args_ok) && !pfile->state.va_args_ok)
cpp_error (pfile, DL_PEDWARN, 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; return result;
...@@ -470,9 +450,7 @@ lex_identifier (pfile, base) ...@@ -470,9 +450,7 @@ lex_identifier (pfile, base)
/* Lex a number to NUMBER starting at BUFFER->CUR - 1. */ /* Lex a number to NUMBER starting at BUFFER->CUR - 1. */
static void static void
lex_number (pfile, number) lex_number (cpp_reader *pfile, cpp_string *number)
cpp_reader *pfile;
cpp_string *number;
{ {
const uchar *cur; const uchar *cur;
const uchar *base; const uchar *base;
...@@ -500,12 +478,8 @@ lex_number (pfile, number) ...@@ -500,12 +478,8 @@ lex_number (pfile, number)
/* Create a token of type TYPE with a literal spelling. */ /* Create a token of type TYPE with a literal spelling. */
static void static void
create_literal (pfile, token, base, len, type) create_literal (cpp_reader *pfile, cpp_token *token, const uchar *base,
cpp_reader *pfile; unsigned int len, enum cpp_ttype type)
cpp_token *token;
const uchar *base;
unsigned int len;
enum cpp_ttype type;
{ {
uchar *dest = _cpp_unaligned_alloc (pfile, len + 1); uchar *dest = _cpp_unaligned_alloc (pfile, len + 1);
...@@ -524,10 +498,7 @@ create_literal (pfile, token, base, len, type) ...@@ -524,10 +498,7 @@ create_literal (pfile, token, base, len, type)
The spelling is NUL-terminated, but it is not guaranteed that this The spelling is NUL-terminated, but it is not guaranteed that this
is the first NUL since embedded NULs are preserved. */ is the first NUL since embedded NULs are preserved. */
static void static void
lex_string (pfile, token, base) lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
cpp_reader *pfile;
cpp_token *token;
const uchar *base;
{ {
bool saw_NUL = false; bool saw_NUL = false;
const uchar *cur; const uchar *cur;
...@@ -573,11 +544,8 @@ lex_string (pfile, token, base) ...@@ -573,11 +544,8 @@ lex_string (pfile, token, base)
/* The stored comment includes the comment start and any terminator. */ /* The stored comment includes the comment start and any terminator. */
static void static void
save_comment (pfile, token, from, type) save_comment (cpp_reader *pfile, cpp_token *token, const unsigned char *from,
cpp_reader *pfile; cppchar_t type)
cpp_token *token;
const unsigned char *from;
cppchar_t type;
{ {
unsigned char *buffer; unsigned char *buffer;
unsigned int len, clen; unsigned int len, clen;
...@@ -617,9 +585,7 @@ save_comment (pfile, token, from, type) ...@@ -617,9 +585,7 @@ save_comment (pfile, token, from, type)
/* Allocate COUNT tokens for RUN. */ /* Allocate COUNT tokens for RUN. */
void void
_cpp_init_tokenrun (run, count) _cpp_init_tokenrun (tokenrun *run, unsigned int count)
tokenrun *run;
unsigned int count;
{ {
run->base = xnewvec (cpp_token, count); run->base = xnewvec (cpp_token, count);
run->limit = run->base + count; run->limit = run->base + count;
...@@ -628,8 +594,7 @@ _cpp_init_tokenrun (run, count) ...@@ -628,8 +594,7 @@ _cpp_init_tokenrun (run, count)
/* Returns the next tokenrun, or creates one if there is none. */ /* Returns the next tokenrun, or creates one if there is none. */
static tokenrun * static tokenrun *
next_tokenrun (run) next_tokenrun (tokenrun *run)
tokenrun *run;
{ {
if (run->next == NULL) if (run->next == NULL)
{ {
...@@ -646,8 +611,7 @@ next_tokenrun (run) ...@@ -646,8 +611,7 @@ next_tokenrun (run)
same as the last lexed token, so that diagnostics appear in the same as the last lexed token, so that diagnostics appear in the
right place. */ right place. */
cpp_token * cpp_token *
_cpp_temp_token (pfile) _cpp_temp_token (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_token *old, *result; cpp_token *old, *result;
...@@ -668,8 +632,7 @@ _cpp_temp_token (pfile) ...@@ -668,8 +632,7 @@ _cpp_temp_token (pfile)
like directive handling, token lookahead, multiple include like directive handling, token lookahead, multiple include
optimization and skipping. */ optimization and skipping. */
const cpp_token * const cpp_token *
_cpp_lex_token (pfile) _cpp_lex_token (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_token *result; cpp_token *result;
...@@ -701,7 +664,7 @@ _cpp_lex_token (pfile) ...@@ -701,7 +664,7 @@ _cpp_lex_token (pfile)
&& _cpp_handle_directive (pfile, result->flags & PREV_WHITE)) && _cpp_handle_directive (pfile, result->flags & PREV_WHITE))
continue; continue;
if (pfile->cb.line_change && !pfile->state.skipping) 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. */ /* We don't skip tokens in directives. */
...@@ -722,8 +685,7 @@ _cpp_lex_token (pfile) ...@@ -722,8 +685,7 @@ _cpp_lex_token (pfile)
/* Returns true if a fresh line has been loaded. */ /* Returns true if a fresh line has been loaded. */
bool bool
_cpp_get_fresh_line (pfile) _cpp_get_fresh_line (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* We can't get a new line until we leave the current directive. */ /* We can't get a new line until we leave the current directive. */
if (pfile->state.in_directive) if (pfile->state.in_directive)
...@@ -792,8 +754,7 @@ _cpp_get_fresh_line (pfile) ...@@ -792,8 +754,7 @@ _cpp_get_fresh_line (pfile)
otherwise returns to the start of the token buffer if permissible. otherwise returns to the start of the token buffer if permissible.
Returns the location of the lexed token. */ Returns the location of the lexed token. */
cpp_token * cpp_token *
_cpp_lex_direct (pfile) _cpp_lex_direct (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cppchar_t c; cppchar_t c;
cpp_buffer *buffer; cpp_buffer *buffer;
...@@ -1128,8 +1089,7 @@ _cpp_lex_direct (pfile) ...@@ -1128,8 +1089,7 @@ _cpp_lex_direct (pfile)
/* An upper bound on the number of bytes needed to spell TOKEN. /* An upper bound on the number of bytes needed to spell TOKEN.
Does not include preceding whitespace. */ Does not include preceding whitespace. */
unsigned int unsigned int
cpp_token_len (token) cpp_token_len (const cpp_token *token)
const cpp_token *token;
{ {
unsigned int len; unsigned int len;
...@@ -1145,13 +1105,11 @@ cpp_token_len (token) ...@@ -1145,13 +1105,11 @@ cpp_token_len (token)
/* Write the spelling of a token TOKEN to BUFFER. The buffer must /* Write the spelling of a token TOKEN to BUFFER. The buffer must
already contain the enough space to hold the token's spelling. already contain the enough space to hold the token's spelling.
Returns a pointer to the character after the last character Returns a pointer to the character after the last character written.
written. */ FIXME: Would be nice if we didn't need the PFILE argument. */
unsigned char * unsigned char *
cpp_spell_token (pfile, token, buffer) cpp_spell_token (cpp_reader *pfile, const cpp_token *token,
cpp_reader *pfile; /* Would be nice to be rid of this... */ unsigned char *buffer)
const cpp_token *token;
unsigned char *buffer;
{ {
switch (TOKEN_SPELL (token)) switch (TOKEN_SPELL (token))
{ {
...@@ -1195,9 +1153,7 @@ cpp_spell_token (pfile, token, buffer) ...@@ -1195,9 +1153,7 @@ cpp_spell_token (pfile, token, buffer)
/* Returns TOKEN spelt as a null-terminated string. The string is /* Returns TOKEN spelt as a null-terminated string. The string is
freed when the reader is destroyed. Useful for diagnostics. */ freed when the reader is destroyed. Useful for diagnostics. */
unsigned char * unsigned char *
cpp_token_as_text (pfile, token) cpp_token_as_text (cpp_reader *pfile, const cpp_token *token)
cpp_reader *pfile;
const cpp_token *token;
{ {
unsigned int len = cpp_token_len (token) + 1; unsigned int len = cpp_token_len (token) + 1;
unsigned char *start = _cpp_unaligned_alloc (pfile, len), *end; unsigned char *start = _cpp_unaligned_alloc (pfile, len), *end;
...@@ -1211,8 +1167,7 @@ cpp_token_as_text (pfile, token) ...@@ -1211,8 +1167,7 @@ cpp_token_as_text (pfile, token)
/* Used by C front ends, which really should move to using /* Used by C front ends, which really should move to using
cpp_token_as_text. */ cpp_token_as_text. */
const char * const char *
cpp_type2name (type) cpp_type2name (enum cpp_ttype type)
enum cpp_ttype type;
{ {
return (const char *) token_spellings[type].name; return (const char *) token_spellings[type].name;
} }
...@@ -1221,9 +1176,7 @@ cpp_type2name (type) ...@@ -1221,9 +1176,7 @@ cpp_type2name (type)
Separated from cpp_spell_token for efficiency - to avoid stdio Separated from cpp_spell_token for efficiency - to avoid stdio
double-buffering. */ double-buffering. */
void void
cpp_output_token (token, fp) cpp_output_token (const cpp_token *token, FILE *fp)
const cpp_token *token;
FILE *fp;
{ {
switch (TOKEN_SPELL (token)) switch (TOKEN_SPELL (token))
{ {
...@@ -1264,8 +1217,7 @@ cpp_output_token (token, fp) ...@@ -1264,8 +1217,7 @@ cpp_output_token (token, fp)
/* Compare two tokens. */ /* Compare two tokens. */
int int
_cpp_equiv_tokens (a, b) _cpp_equiv_tokens (const cpp_token *a, const cpp_token *b)
const cpp_token *a, *b;
{ {
if (a->type == b->type && a->flags == b->flags) if (a->type == b->type && a->flags == b->flags)
switch (TOKEN_SPELL (a)) switch (TOKEN_SPELL (a))
...@@ -1291,9 +1243,8 @@ _cpp_equiv_tokens (a, b) ...@@ -1291,9 +1243,8 @@ _cpp_equiv_tokens (a, b)
conservative, and occasionally advises a space where one is not conservative, and occasionally advises a space where one is not
needed, e.g. "." and ".2". */ needed, e.g. "." and ".2". */
int int
cpp_avoid_paste (pfile, token1, token2) cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1,
cpp_reader *pfile; const cpp_token *token2)
const cpp_token *token1, *token2;
{ {
enum cpp_ttype a = token1->type, b = token2->type; enum cpp_ttype a = token1->type, b = token2->type;
cppchar_t c; cppchar_t c;
...@@ -1349,9 +1300,7 @@ cpp_avoid_paste (pfile, token1, token2) ...@@ -1349,9 +1300,7 @@ cpp_avoid_paste (pfile, token1, token2)
character, to FP. Leading whitespace is removed. If there are character, to FP. Leading whitespace is removed. If there are
macros, special token padding is not performed. */ macros, special token padding is not performed. */
void void
cpp_output_line (pfile, fp) cpp_output_line (cpp_reader *pfile, FILE *fp)
cpp_reader *pfile;
FILE *fp;
{ {
const cpp_token *token; const cpp_token *token;
...@@ -1369,8 +1318,7 @@ cpp_output_line (pfile, fp) ...@@ -1369,8 +1318,7 @@ cpp_output_line (pfile, fp)
/* Returns the value of a hexadecimal digit. */ /* Returns the value of a hexadecimal digit. */
static unsigned int static unsigned int
hex_digit_value (c) hex_digit_value (unsigned int c)
unsigned int c;
{ {
if (hex_p (c)) if (hex_p (c))
return hex_value (c); return hex_value (c);
...@@ -1380,9 +1328,7 @@ hex_digit_value (c) ...@@ -1380,9 +1328,7 @@ hex_digit_value (c)
/* Read a possible universal character name starting at *PSTR. */ /* Read a possible universal character name starting at *PSTR. */
static cppchar_t static cppchar_t
maybe_read_ucn (pfile, pstr) maybe_read_ucn (cpp_reader *pfile, const uchar **pstr)
cpp_reader *pfile;
const uchar **pstr;
{ {
cppchar_t result, c = (*pstr)[-1]; cppchar_t result, c = (*pstr)[-1];
...@@ -1411,11 +1357,8 @@ maybe_read_ucn (pfile, pstr) ...@@ -1411,11 +1357,8 @@ maybe_read_ucn (pfile, pstr)
if the escape sequence is part of a wide character constant or if the escape sequence is part of a wide character constant or
string literal. Handles all relevant diagnostics. */ string literal. Handles all relevant diagnostics. */
cppchar_t cppchar_t
cpp_parse_escape (pfile, pstr, limit, wide) cpp_parse_escape (cpp_reader *pfile, const unsigned char **pstr,
cpp_reader *pfile; const unsigned char *limit, int wide)
const unsigned char **pstr;
const unsigned char *limit;
int wide;
{ {
/* Values of \a \b \e \f \n \r \t \v respectively. */ /* Values of \a \b \e \f \n \r \t \v respectively. */
static const uchar ascii[] = { 7, 8, 27, 12, 10, 13, 9, 11 }; static const uchar ascii[] = { 7, 8, 27, 12, 10, 13, 9, 11 };
...@@ -1555,7 +1498,8 @@ cpp_parse_escape (pfile, pstr, limit, wide) ...@@ -1555,7 +1498,8 @@ cpp_parse_escape (pfile, pstr, limit, wide)
if (c > mask) 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; c &= mask;
} }
...@@ -1569,11 +1513,8 @@ cpp_parse_escape (pfile, pstr, limit, wide) ...@@ -1569,11 +1513,8 @@ cpp_parse_escape (pfile, pstr, limit, wide)
characters seen, and UNSIGNEDP to a variable that indicates whether characters seen, and UNSIGNEDP to a variable that indicates whether
the result has signed type. */ the result has signed type. */
cppchar_t cppchar_t
cpp_interpret_charconst (pfile, token, pchars_seen, unsignedp) cpp_interpret_charconst (cpp_reader *pfile, const cpp_token *token,
cpp_reader *pfile; unsigned int *pchars_seen, int *unsignedp)
const cpp_token *token;
unsigned int *pchars_seen;
int *unsignedp;
{ {
const unsigned char *str, *limit; const unsigned char *str, *limit;
unsigned int chars_seen = 0; unsigned int chars_seen = 0;
...@@ -1678,8 +1619,7 @@ cpp_interpret_charconst (pfile, token, pchars_seen, unsignedp) ...@@ -1678,8 +1619,7 @@ cpp_interpret_charconst (pfile, token, pchars_seen, unsignedp)
/* Create a new allocation buffer. Place the control block at the end /* Create a new allocation buffer. Place the control block at the end
of the buffer, so that buffer overflows will cause immediate chaos. */ of the buffer, so that buffer overflows will cause immediate chaos. */
static _cpp_buff * static _cpp_buff *
new_buff (len) new_buff (size_t len)
size_t len;
{ {
_cpp_buff *result; _cpp_buff *result;
unsigned char *base; unsigned char *base;
...@@ -1699,9 +1639,7 @@ new_buff (len) ...@@ -1699,9 +1639,7 @@ new_buff (len)
/* Place a chain of unwanted allocation buffers on the free list. */ /* Place a chain of unwanted allocation buffers on the free list. */
void void
_cpp_release_buff (pfile, buff) _cpp_release_buff (cpp_reader *pfile, _cpp_buff *buff)
cpp_reader *pfile;
_cpp_buff *buff;
{ {
_cpp_buff *end = buff; _cpp_buff *end = buff;
...@@ -1713,9 +1651,7 @@ _cpp_release_buff (pfile, buff) ...@@ -1713,9 +1651,7 @@ _cpp_release_buff (pfile, buff)
/* Return a free buffer of size at least MIN_SIZE. */ /* Return a free buffer of size at least MIN_SIZE. */
_cpp_buff * _cpp_buff *
_cpp_get_buff (pfile, min_size) _cpp_get_buff (cpp_reader *pfile, size_t min_size)
cpp_reader *pfile;
size_t min_size;
{ {
_cpp_buff *result, **p; _cpp_buff *result, **p;
...@@ -1744,10 +1680,7 @@ _cpp_get_buff (pfile, min_size) ...@@ -1744,10 +1680,7 @@ _cpp_get_buff (pfile, min_size)
the excess bytes to the new buffer. Chains the new buffer after the excess bytes to the new buffer. Chains the new buffer after
BUFF, and returns the new buffer. */ BUFF, and returns the new buffer. */
_cpp_buff * _cpp_buff *
_cpp_append_extend_buff (pfile, buff, min_extra) _cpp_append_extend_buff (cpp_reader *pfile, _cpp_buff *buff, size_t min_extra)
cpp_reader *pfile;
_cpp_buff *buff;
size_t min_extra;
{ {
size_t size = EXTENDED_BUFF_SIZE (buff, min_extra); size_t size = EXTENDED_BUFF_SIZE (buff, min_extra);
_cpp_buff *new_buff = _cpp_get_buff (pfile, size); _cpp_buff *new_buff = _cpp_get_buff (pfile, size);
...@@ -1763,10 +1696,7 @@ _cpp_append_extend_buff (pfile, buff, min_extra) ...@@ -1763,10 +1696,7 @@ _cpp_append_extend_buff (pfile, buff, min_extra)
Chains the new buffer before the buffer pointed to by BUFF, and Chains the new buffer before the buffer pointed to by BUFF, and
updates the pointer to point to the new buffer. */ updates the pointer to point to the new buffer. */
void void
_cpp_extend_buff (pfile, pbuff, min_extra) _cpp_extend_buff (cpp_reader *pfile, _cpp_buff **pbuff, size_t min_extra)
cpp_reader *pfile;
_cpp_buff **pbuff;
size_t min_extra;
{ {
_cpp_buff *new_buff, *old_buff = *pbuff; _cpp_buff *new_buff, *old_buff = *pbuff;
size_t size = EXTENDED_BUFF_SIZE (old_buff, min_extra); size_t size = EXTENDED_BUFF_SIZE (old_buff, min_extra);
...@@ -1793,9 +1723,7 @@ _cpp_free_buff (buff) ...@@ -1793,9 +1723,7 @@ _cpp_free_buff (buff)
/* Allocate permanent, unaligned storage of length LEN. */ /* Allocate permanent, unaligned storage of length LEN. */
unsigned char * unsigned char *
_cpp_unaligned_alloc (pfile, len) _cpp_unaligned_alloc (cpp_reader *pfile, size_t len)
cpp_reader *pfile;
size_t len;
{ {
_cpp_buff *buff = pfile->u_buff; _cpp_buff *buff = pfile->u_buff;
unsigned char *result = buff->cur; unsigned char *result = buff->cur;
...@@ -1823,9 +1751,7 @@ _cpp_unaligned_alloc (pfile, len) ...@@ -1823,9 +1751,7 @@ _cpp_unaligned_alloc (pfile, len)
All existing other uses clearly fit this restriction: storing All existing other uses clearly fit this restriction: storing
registered pragmas during initialization. */ registered pragmas during initialization. */
unsigned char * unsigned char *
_cpp_aligned_alloc (pfile, len) _cpp_aligned_alloc (cpp_reader *pfile, size_t len)
cpp_reader *pfile;
size_t len;
{ {
_cpp_buff *buff = pfile->a_buff; _cpp_buff *buff = pfile->a_buff;
unsigned char *result = buff->cur; unsigned char *result = buff->cur;
......
...@@ -45,11 +45,11 @@ struct if_stack ...@@ -45,11 +45,11 @@ struct if_stack
const cpp_hashnode *mi_cmacro;/* macro name for #ifndef around entire file */ const cpp_hashnode *mi_cmacro;/* macro name for #ifndef around entire file */
bool skip_elses; /* Can future #else / #elif be skipped? */ bool skip_elses; /* Can future #else / #elif be skipped? */
bool was_skipping; /* If were skipping on entry. */ bool was_skipping; /* If were skipping on entry. */
int type; /* Most recent conditional, for diagnostics. */ int type; /* Most recent conditional for diagnostics. */
}; };
/* Contains a registered pragma or pragma namespace. */ /* Contains a registered pragma or pragma namespace. */
typedef void (*pragma_cb) PARAMS ((cpp_reader *)); typedef void (*pragma_cb) (cpp_reader *);
struct pragma_entry struct pragma_entry
{ {
struct pragma_entry *next; struct pragma_entry *next;
...@@ -82,7 +82,7 @@ struct pragma_entry ...@@ -82,7 +82,7 @@ struct pragma_entry
#define EXPAND (1 << 4) #define EXPAND (1 << 4)
/* Defines one #-directive, including how to handle it. */ /* Defines one #-directive, including how to handle it. */
typedef void (*directive_handler) PARAMS ((cpp_reader *)); typedef void (*directive_handler) (cpp_reader *);
typedef struct directive directive; typedef struct directive directive;
struct directive struct directive
{ {
...@@ -95,51 +95,44 @@ struct directive ...@@ -95,51 +95,44 @@ struct directive
/* Forward declarations. */ /* Forward declarations. */
static void skip_rest_of_line PARAMS ((cpp_reader *)); static void skip_rest_of_line (cpp_reader *);
static void check_eol PARAMS ((cpp_reader *)); static void check_eol (cpp_reader *);
static void start_directive PARAMS ((cpp_reader *)); static void start_directive (cpp_reader *);
static void prepare_directive_trad PARAMS ((cpp_reader *)); static void prepare_directive_trad (cpp_reader *);
static void end_directive PARAMS ((cpp_reader *, int)); static void end_directive (cpp_reader *, int);
static void directive_diagnostics static void directive_diagnostics (cpp_reader *, const directive *, int);
PARAMS ((cpp_reader *, const directive *, int)); static void run_directive (cpp_reader *, int, const char *, size_t);
static void run_directive PARAMS ((cpp_reader *, int, static char *glue_header_name (cpp_reader *);
const char *, size_t)); static const char *parse_include (cpp_reader *, int *);
static char *glue_header_name PARAMS ((cpp_reader *)); static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *);
static const char *parse_include PARAMS ((cpp_reader *, int *)); static unsigned int read_flag (cpp_reader *, unsigned int);
static void push_conditional PARAMS ((cpp_reader *, int, int, static uchar *dequote_string (cpp_reader *, const uchar *, unsigned int);
const cpp_hashnode *)); static int strtoul_for_line (const uchar *, unsigned int, unsigned long *);
static unsigned int read_flag PARAMS ((cpp_reader *, unsigned int)); static void do_diagnostic (cpp_reader *, int, int);
static uchar *dequote_string PARAMS ((cpp_reader *, const uchar *, static cpp_hashnode *lex_macro_node (cpp_reader *);
unsigned int)); static void do_include_common (cpp_reader *, enum include_type);
static int strtoul_for_line PARAMS ((const uchar *, unsigned int, static struct pragma_entry *lookup_pragma_entry (struct pragma_entry *,
unsigned long *)); const cpp_hashnode *);
static void do_diagnostic PARAMS ((cpp_reader *, int, int)); static struct pragma_entry *insert_pragma_entry (cpp_reader *,
static cpp_hashnode *lex_macro_node PARAMS ((cpp_reader *)); struct pragma_entry **,
static void do_include_common PARAMS ((cpp_reader *, enum include_type)); const cpp_hashnode *,
static struct pragma_entry *lookup_pragma_entry pragma_cb);
PARAMS ((struct pragma_entry *, const cpp_hashnode *pragma)); static int count_registered_pragmas (struct pragma_entry *);
static struct pragma_entry *insert_pragma_entry static char ** save_registered_pragmas (struct pragma_entry *, char **);
PARAMS ((cpp_reader *, struct pragma_entry **, const cpp_hashnode *, static char ** restore_registered_pragmas (cpp_reader *, struct pragma_entry *,
pragma_cb)); char **);
static int count_registered_pragmas PARAMS ((struct pragma_entry *)); static void do_pragma_once (cpp_reader *);
static char ** save_registered_pragmas static void do_pragma_poison (cpp_reader *);
PARAMS ((struct pragma_entry *, char **)); static void do_pragma_system_header (cpp_reader *);
static char ** restore_registered_pragmas static void do_pragma_dependency (cpp_reader *);
PARAMS ((cpp_reader *, struct pragma_entry *, char **)); static void do_linemarker (cpp_reader *);
static void do_pragma_once PARAMS ((cpp_reader *)); static const cpp_token *get_token_no_padding (cpp_reader *);
static void do_pragma_poison PARAMS ((cpp_reader *)); static const cpp_token *get__Pragma_string (cpp_reader *);
static void do_pragma_system_header PARAMS ((cpp_reader *)); static void destringize_and_run (cpp_reader *, const cpp_string *);
static void do_pragma_dependency PARAMS ((cpp_reader *)); static int parse_answer (cpp_reader *, struct answer **, int);
static void do_linemarker PARAMS ((cpp_reader *)); static cpp_hashnode *parse_assertion (cpp_reader *, struct answer **, int);
static const cpp_token *get_token_no_padding PARAMS ((cpp_reader *)); static struct answer ** find_answer (cpp_hashnode *, const struct answer *);
static const cpp_token *get__Pragma_string PARAMS ((cpp_reader *)); static void handle_assertion (cpp_reader *, const char *, int);
static void destringize_and_run PARAMS ((cpp_reader *, const cpp_string *));
static int parse_answer PARAMS ((cpp_reader *, struct answer **, int));
static cpp_hashnode *parse_assertion PARAMS ((cpp_reader *, struct answer **,
int));
static struct answer ** find_answer PARAMS ((cpp_hashnode *,
const struct answer *));
static void handle_assertion PARAMS ((cpp_reader *, const char *, int));
/* This is the table of directive handlers. It is ordered by /* This is the table of directive handlers. It is ordered by
frequency of occurrence; the numbers at the end are directive frequency of occurrence; the numbers at the end are directive
...@@ -174,7 +167,7 @@ D(sccs, T_SCCS, EXTENSION, 0) /* 0 SVR4? */ ...@@ -174,7 +167,7 @@ D(sccs, T_SCCS, EXTENSION, 0) /* 0 SVR4? */
/* Use the table to generate a series of prototypes, an enum for the /* Use the table to generate a series of prototypes, an enum for the
directive names, and an array of directive handlers. */ directive names, and an array of directive handlers. */
#define D(name, t, o, f) static void do_##name PARAMS ((cpp_reader *)); #define D(name, t, o, f) static void do_##name (cpp_reader *);
DIRECTIVE_TABLE DIRECTIVE_TABLE
#undef D #undef D
...@@ -208,8 +201,7 @@ static const directive linemarker_dir = ...@@ -208,8 +201,7 @@ static const directive linemarker_dir =
/* Skip any remaining tokens in a directive. */ /* Skip any remaining tokens in a directive. */
static void static void
skip_rest_of_line (pfile) skip_rest_of_line (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* Discard all stacked contexts. */ /* Discard all stacked contexts. */
while (pfile->context->prev) while (pfile->context->prev)
...@@ -223,8 +215,7 @@ skip_rest_of_line (pfile) ...@@ -223,8 +215,7 @@ skip_rest_of_line (pfile)
/* Ensure there are no stray tokens at the end of a directive. */ /* Ensure there are no stray tokens at the end of a directive. */
static void static void
check_eol (pfile) check_eol (cpp_reader *pfile)
cpp_reader *pfile;
{ {
if (! SEEN_EOL () && _cpp_lex_token (pfile)->type != CPP_EOF) if (! SEEN_EOL () && _cpp_lex_token (pfile)->type != CPP_EOF)
cpp_error (pfile, DL_PEDWARN, "extra tokens at end of #%s directive", cpp_error (pfile, DL_PEDWARN, "extra tokens at end of #%s directive",
...@@ -233,8 +224,7 @@ check_eol (pfile) ...@@ -233,8 +224,7 @@ check_eol (pfile)
/* Called when entering a directive, _Pragma or command-line directive. */ /* Called when entering a directive, _Pragma or command-line directive. */
static void static void
start_directive (pfile) start_directive (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* Setup in-directive state. */ /* Setup in-directive state. */
pfile->state.in_directive = 1; pfile->state.in_directive = 1;
...@@ -246,9 +236,7 @@ start_directive (pfile) ...@@ -246,9 +236,7 @@ start_directive (pfile)
/* Called when leaving a directive, _Pragma or command-line directive. */ /* Called when leaving a directive, _Pragma or command-line directive. */
static void static void
end_directive (pfile, skip_line) end_directive (cpp_reader *pfile, int skip_line)
cpp_reader *pfile;
int skip_line;
{ {
if (CPP_OPTION (pfile, traditional)) if (CPP_OPTION (pfile, traditional))
{ {
...@@ -279,8 +267,7 @@ end_directive (pfile, skip_line) ...@@ -279,8 +267,7 @@ end_directive (pfile, skip_line)
/* Prepare to handle the directive in pfile->directive. */ /* Prepare to handle the directive in pfile->directive. */
static void static void
prepare_directive_trad (pfile) prepare_directive_trad (cpp_reader *pfile)
cpp_reader *pfile;
{ {
if (pfile->directive != &dtable[T_DEFINE]) if (pfile->directive != &dtable[T_DEFINE])
{ {
...@@ -308,10 +295,7 @@ prepare_directive_trad (pfile) ...@@ -308,10 +295,7 @@ prepare_directive_trad (pfile)
/* Output diagnostics for a directive DIR. INDENTED is nonzero if /* Output diagnostics for a directive DIR. INDENTED is nonzero if
the '#' was indented. */ the '#' was indented. */
static void static void
directive_diagnostics (pfile, dir, indented) directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
cpp_reader *pfile;
const directive *dir;
int indented;
{ {
/* Issue -pedantic warnings for extensions. */ /* Issue -pedantic warnings for extensions. */
if (CPP_PEDANTIC (pfile) if (CPP_PEDANTIC (pfile)
...@@ -347,9 +331,7 @@ directive_diagnostics (pfile, dir, indented) ...@@ -347,9 +331,7 @@ directive_diagnostics (pfile, dir, indented)
nonzero if the line of tokens has been handled, zero if we should nonzero if the line of tokens has been handled, zero if we should
continue processing the line. */ continue processing the line. */
int int
_cpp_handle_directive (pfile, indented) _cpp_handle_directive (cpp_reader *pfile, int indented)
cpp_reader *pfile;
int indented;
{ {
const directive *dir = 0; const directive *dir = 0;
const cpp_token *dname; const cpp_token *dname;
...@@ -439,7 +421,7 @@ _cpp_handle_directive (pfile, indented) ...@@ -439,7 +421,7 @@ _cpp_handle_directive (pfile, indented)
prepare_directive_trad (pfile); prepare_directive_trad (pfile);
if (dir) if (dir)
(*pfile->directive->handler) (pfile); pfile->directive->handler (pfile);
else if (skip == 0) else if (skip == 0)
_cpp_backup_tokens (pfile, 1); _cpp_backup_tokens (pfile, 1);
...@@ -456,11 +438,7 @@ _cpp_handle_directive (pfile, indented) ...@@ -456,11 +438,7 @@ _cpp_handle_directive (pfile, indented)
/* Directive handler wrapper used by the command line option /* Directive handler wrapper used by the command line option
processor. BUF is \n terminated. */ processor. BUF is \n terminated. */
static void static void
run_directive (pfile, dir_no, buf, count) run_directive (cpp_reader *pfile, int dir_no, const char *buf, size_t count)
cpp_reader *pfile;
int dir_no;
const char *buf;
size_t count;
{ {
cpp_push_buffer (pfile, (const uchar *) buf, count, cpp_push_buffer (pfile, (const uchar *) buf, count,
/* from_stage3 */ true, 1); /* from_stage3 */ true, 1);
...@@ -476,7 +454,7 @@ run_directive (pfile, dir_no, buf, count) ...@@ -476,7 +454,7 @@ run_directive (pfile, dir_no, buf, count)
pfile->directive = &dtable[dir_no]; pfile->directive = &dtable[dir_no];
if (CPP_OPTION (pfile, traditional)) if (CPP_OPTION (pfile, traditional))
prepare_directive_trad (pfile); prepare_directive_trad (pfile);
(void) (*pfile->directive->handler) (pfile); pfile->directive->handler (pfile);
end_directive (pfile, 1); end_directive (pfile, 1);
if (dir_no == T_PRAGMA) if (dir_no == T_PRAGMA)
pfile->buffer->inc = NULL; pfile->buffer->inc = NULL;
...@@ -486,8 +464,7 @@ run_directive (pfile, dir_no, buf, count) ...@@ -486,8 +464,7 @@ run_directive (pfile, dir_no, buf, count)
/* Checks for validity the macro name in #define, #undef, #ifdef and /* Checks for validity the macro name in #define, #undef, #ifdef and
#ifndef directives. */ #ifndef directives. */
static cpp_hashnode * static cpp_hashnode *
lex_macro_node (pfile) lex_macro_node (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *token = _cpp_lex_token (pfile); const cpp_token *token = _cpp_lex_token (pfile);
...@@ -523,8 +500,7 @@ lex_macro_node (pfile) ...@@ -523,8 +500,7 @@ lex_macro_node (pfile)
/* Process a #define directive. Most work is done in cppmacro.c. */ /* Process a #define directive. Most work is done in cppmacro.c. */
static void static void
do_define (pfile) do_define (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_hashnode *node = lex_macro_node (pfile); cpp_hashnode *node = lex_macro_node (pfile);
...@@ -537,14 +513,13 @@ do_define (pfile) ...@@ -537,14 +513,13 @@ do_define (pfile)
if (_cpp_create_definition (pfile, node)) if (_cpp_create_definition (pfile, node))
if (pfile->cb.define) if (pfile->cb.define)
(*pfile->cb.define) (pfile, pfile->directive_line, node); pfile->cb.define (pfile, pfile->directive_line, node);
} }
} }
/* Handle #undef. Mark the identifier NT_VOID in the hash table. */ /* Handle #undef. Mark the identifier NT_VOID in the hash table. */
static void static void
do_undef (pfile) do_undef (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_hashnode *node = lex_macro_node (pfile); cpp_hashnode *node = lex_macro_node (pfile);
...@@ -553,7 +528,7 @@ do_undef (pfile) ...@@ -553,7 +528,7 @@ do_undef (pfile)
if (node && node->type == NT_MACRO) if (node && node->type == NT_MACRO)
{ {
if (pfile->cb.undef) if (pfile->cb.undef)
(*pfile->cb.undef) (pfile, pfile->directive_line, node); pfile->cb.undef (pfile, pfile->directive_line, node);
if (node->flags & NODE_WARN) if (node->flags & NODE_WARN)
cpp_error (pfile, DL_WARNING, "undefining \"%s\"", NODE_NAME (node)); cpp_error (pfile, DL_WARNING, "undefining \"%s\"", NODE_NAME (node));
...@@ -570,8 +545,7 @@ do_undef (pfile) ...@@ -570,8 +545,7 @@ do_undef (pfile)
as an h-char-sequence (< ... >); we are looking at the first token as an h-char-sequence (< ... >); we are looking at the first token
after the <. Returns a malloced filename. */ after the <. Returns a malloced filename. */
static char * static char *
glue_header_name (pfile) glue_header_name (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *token; const cpp_token *token;
char *buffer; char *buffer;
...@@ -614,9 +588,7 @@ glue_header_name (pfile) ...@@ -614,9 +588,7 @@ glue_header_name (pfile)
#pragma dependency. The string is malloced and the caller should #pragma dependency. The string is malloced and the caller should
free it. Returns NULL on error. */ free it. Returns NULL on error. */
static const char * static const char *
parse_include (pfile, pangle_brackets) parse_include (cpp_reader *pfile, int *pangle_brackets)
cpp_reader *pfile;
int *pangle_brackets;
{ {
char *fname; char *fname;
const cpp_token *header; const cpp_token *header;
...@@ -655,9 +627,7 @@ parse_include (pfile, pangle_brackets) ...@@ -655,9 +627,7 @@ parse_include (pfile, pangle_brackets)
/* Handle #include, #include_next and #import. */ /* Handle #include, #include_next and #import. */
static void static void
do_include_common (pfile, type) do_include_common (cpp_reader *pfile, enum include_type type)
cpp_reader *pfile;
enum include_type type;
{ {
const char *fname; const char *fname;
int angle_brackets; int angle_brackets;
...@@ -675,8 +645,8 @@ do_include_common (pfile, type) ...@@ -675,8 +645,8 @@ do_include_common (pfile, type)
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
if (pfile->cb.include) if (pfile->cb.include)
(*pfile->cb.include) (pfile, pfile->directive_line, pfile->cb.include (pfile, pfile->directive_line,
pfile->directive->name, fname, angle_brackets); pfile->directive->name, fname, angle_brackets);
_cpp_execute_include (pfile, fname, angle_brackets, type); _cpp_execute_include (pfile, fname, angle_brackets, type);
} }
...@@ -685,15 +655,13 @@ do_include_common (pfile, type) ...@@ -685,15 +655,13 @@ do_include_common (pfile, type)
} }
static void static void
do_include (pfile) do_include (cpp_reader *pfile)
cpp_reader *pfile;
{ {
do_include_common (pfile, IT_INCLUDE); do_include_common (pfile, IT_INCLUDE);
} }
static void static void
do_import (pfile) do_import (cpp_reader *pfile)
cpp_reader *pfile;
{ {
if (CPP_OPTION (pfile, warn_import)) if (CPP_OPTION (pfile, warn_import))
{ {
...@@ -706,8 +674,7 @@ do_import (pfile) ...@@ -706,8 +674,7 @@ do_import (pfile)
} }
static void static void
do_include_next (pfile) do_include_next (cpp_reader *pfile)
cpp_reader *pfile;
{ {
enum include_type type = IT_INCLUDE_NEXT; enum include_type type = IT_INCLUDE_NEXT;
...@@ -727,9 +694,7 @@ do_include_next (pfile) ...@@ -727,9 +694,7 @@ do_include_next (pfile)
flag if it is valid, 0 at the end of the directive. Otherwise flag if it is valid, 0 at the end of the directive. Otherwise
complain. */ complain. */
static unsigned int static unsigned int
read_flag (pfile, last) read_flag (cpp_reader *pfile, unsigned int last)
cpp_reader *pfile;
unsigned int last;
{ {
const cpp_token *token = _cpp_lex_token (pfile); const cpp_token *token = _cpp_lex_token (pfile);
...@@ -753,10 +718,7 @@ read_flag (pfile, last) ...@@ -753,10 +718,7 @@ read_flag (pfile, last)
which has a NUL terminator and all escape sequences converted to which has a NUL terminator and all escape sequences converted to
their equivalents. Temporary, hopefully. */ their equivalents. Temporary, hopefully. */
static uchar * static uchar *
dequote_string (pfile, str, len) dequote_string (cpp_reader *pfile, const uchar *str, unsigned int len)
cpp_reader *pfile;
const uchar *str;
unsigned int len;
{ {
uchar *result = _cpp_unaligned_alloc (pfile, len + 1); uchar *result = _cpp_unaligned_alloc (pfile, len + 1);
uchar *dst = result; uchar *dst = result;
...@@ -779,10 +741,7 @@ dequote_string (pfile, str, len) ...@@ -779,10 +741,7 @@ dequote_string (pfile, str, len)
of length LEN, to binary; store it in NUMP, and return 0 if the of length LEN, to binary; store it in NUMP, and return 0 if the
number was well-formed, 1 if not. Temporary, hopefully. */ number was well-formed, 1 if not. Temporary, hopefully. */
static int static int
strtoul_for_line (str, len, nump) strtoul_for_line (const uchar *str, unsigned int len, long unsigned int *nump)
const uchar *str;
unsigned int len;
unsigned long *nump;
{ {
unsigned long reg = 0; unsigned long reg = 0;
uchar c; uchar c;
...@@ -802,8 +761,7 @@ strtoul_for_line (str, len, nump) ...@@ -802,8 +761,7 @@ strtoul_for_line (str, len, nump)
Note that the filename string (if any) is a true string constant Note that the filename string (if any) is a true string constant
(escapes are interpreted), unlike in #line. */ (escapes are interpreted), unlike in #line. */
static void static void
do_line (pfile) do_line (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *token; const cpp_token *token;
const char *new_file = pfile->map->to_file; const char *new_file = pfile->map->to_file;
...@@ -850,8 +808,7 @@ do_line (pfile) ...@@ -850,8 +808,7 @@ do_line (pfile)
different syntax and semantics from #line: Flags are allowed, different syntax and semantics from #line: Flags are allowed,
and we never complain about the line number being too big. */ and we never complain about the line number being too big. */
static void static void
do_linemarker (pfile) do_linemarker (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *token; const cpp_token *token;
const char *new_file = pfile->map->to_file; const char *new_file = pfile->map->to_file;
...@@ -921,27 +878,21 @@ do_linemarker (pfile) ...@@ -921,27 +878,21 @@ do_linemarker (pfile)
header, 2 for a system header that needs to be extern "C" protected, header, 2 for a system header that needs to be extern "C" protected,
and zero otherwise. */ and zero otherwise. */
void void
_cpp_do_file_change (pfile, reason, to_file, file_line, sysp) _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
cpp_reader *pfile; const char *to_file, unsigned int file_line,
enum lc_reason reason; unsigned int sysp)
const char *to_file;
unsigned int file_line;
unsigned int sysp;
{ {
pfile->map = add_line_map (&pfile->line_maps, reason, sysp, pfile->map = add_line_map (&pfile->line_maps, reason, sysp,
pfile->line, to_file, file_line); pfile->line, to_file, file_line);
if (pfile->cb.file_change) if (pfile->cb.file_change)
(*pfile->cb.file_change) (pfile, pfile->map); pfile->cb.file_change (pfile, pfile->map);
} }
/* Report a warning or error detected by the program we are /* Report a warning or error detected by the program we are
processing. Use the directive's tokens in the error message. */ processing. Use the directive's tokens in the error message. */
static void static void
do_diagnostic (pfile, code, print_dir) do_diagnostic (cpp_reader *pfile, int code, int print_dir)
cpp_reader *pfile;
int code;
int print_dir;
{ {
if (_cpp_begin_message (pfile, code, if (_cpp_begin_message (pfile, code,
pfile->cur_token[-1].line, pfile->cur_token[-1].line,
...@@ -956,15 +907,13 @@ do_diagnostic (pfile, code, print_dir) ...@@ -956,15 +907,13 @@ do_diagnostic (pfile, code, print_dir)
} }
static void static void
do_error (pfile) do_error (cpp_reader *pfile)
cpp_reader *pfile;
{ {
do_diagnostic (pfile, DL_ERROR, 1); do_diagnostic (pfile, DL_ERROR, 1);
} }
static void static void
do_warning (pfile) do_warning (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* We want #warning diagnostics to be emitted in system headers too. */ /* We want #warning diagnostics to be emitted in system headers too. */
do_diagnostic (pfile, DL_WARNING_SYSHDR, 1); do_diagnostic (pfile, DL_WARNING_SYSHDR, 1);
...@@ -972,15 +921,14 @@ do_warning (pfile) ...@@ -972,15 +921,14 @@ do_warning (pfile)
/* Report program identification. */ /* Report program identification. */
static void static void
do_ident (pfile) do_ident (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *str = cpp_get_token (pfile); const cpp_token *str = cpp_get_token (pfile);
if (str->type != CPP_STRING) if (str->type != CPP_STRING)
cpp_error (pfile, DL_ERROR, "invalid #ident directive"); cpp_error (pfile, DL_ERROR, "invalid #ident directive");
else if (pfile->cb.ident) else if (pfile->cb.ident)
(*pfile->cb.ident) (pfile, pfile->directive_line, &str->val.str); pfile->cb.ident (pfile, pfile->directive_line, &str->val.str);
check_eol (pfile); check_eol (pfile);
} }
...@@ -989,9 +937,7 @@ do_ident (pfile) ...@@ -989,9 +937,7 @@ do_ident (pfile)
matching entry, or NULL if none is found. The returned entry could matching entry, or NULL if none is found. The returned entry could
be the start of a namespace chain, or a pragma. */ be the start of a namespace chain, or a pragma. */
static struct pragma_entry * static struct pragma_entry *
lookup_pragma_entry (chain, pragma) lookup_pragma_entry (struct pragma_entry *chain, const cpp_hashnode *pragma)
struct pragma_entry *chain;
const cpp_hashnode *pragma;
{ {
while (chain && chain->pragma != pragma) while (chain && chain->pragma != pragma)
chain = chain->next; chain = chain->next;
...@@ -1003,11 +949,8 @@ lookup_pragma_entry (chain, pragma) ...@@ -1003,11 +949,8 @@ lookup_pragma_entry (chain, pragma)
singly-linked CHAIN. If handler is NULL, it is a namespace, singly-linked CHAIN. If handler is NULL, it is a namespace,
otherwise it is a pragma and its handler. */ otherwise it is a pragma and its handler. */
static struct pragma_entry * static struct pragma_entry *
insert_pragma_entry (pfile, chain, pragma, handler) insert_pragma_entry (cpp_reader *pfile, struct pragma_entry **chain,
cpp_reader *pfile; const cpp_hashnode *pragma, pragma_cb handler)
struct pragma_entry **chain;
const cpp_hashnode *pragma;
pragma_cb handler;
{ {
struct pragma_entry *new; struct pragma_entry *new;
...@@ -1034,11 +977,8 @@ insert_pragma_entry (pfile, chain, pragma, handler) ...@@ -1034,11 +977,8 @@ insert_pragma_entry (pfile, chain, pragma, handler)
goes in the global namespace. HANDLER is the handler it will call, goes in the global namespace. HANDLER is the handler it will call,
which must be non-NULL. */ which must be non-NULL. */
void void
cpp_register_pragma (pfile, space, name, handler) cpp_register_pragma (cpp_reader *pfile, const char *space, const char *name,
cpp_reader *pfile; pragma_cb handler)
const char *space;
const char *name;
pragma_cb handler;
{ {
struct pragma_entry **chain = &pfile->pragmas; struct pragma_entry **chain = &pfile->pragmas;
struct pragma_entry *entry; struct pragma_entry *entry;
...@@ -1080,8 +1020,7 @@ cpp_register_pragma (pfile, space, name, handler) ...@@ -1080,8 +1020,7 @@ cpp_register_pragma (pfile, space, name, handler)
/* Register the pragmas the preprocessor itself handles. */ /* Register the pragmas the preprocessor itself handles. */
void void
_cpp_init_internal_pragmas (pfile) _cpp_init_internal_pragmas (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* Pragmas in the global namespace. */ /* Pragmas in the global namespace. */
cpp_register_pragma (pfile, 0, "once", do_pragma_once); cpp_register_pragma (pfile, 0, "once", do_pragma_once);
...@@ -1095,8 +1034,7 @@ _cpp_init_internal_pragmas (pfile) ...@@ -1095,8 +1034,7 @@ _cpp_init_internal_pragmas (pfile)
/* Return the number of registered pragmas in PE. */ /* Return the number of registered pragmas in PE. */
static int static int
count_registered_pragmas (pe) count_registered_pragmas (struct pragma_entry *pe)
struct pragma_entry *pe;
{ {
int ct = 0; int ct = 0;
for (; pe != NULL; pe = pe->next) for (; pe != NULL; pe = pe->next)
...@@ -1112,9 +1050,7 @@ count_registered_pragmas (pe) ...@@ -1112,9 +1050,7 @@ count_registered_pragmas (pe)
and return a pointer to the next free space in SD. */ and return a pointer to the next free space in SD. */
static char ** static char **
save_registered_pragmas (pe, sd) save_registered_pragmas (struct pragma_entry *pe, char **sd)
struct pragma_entry *pe;
char **sd;
{ {
for (; pe != NULL; pe = pe->next) for (; pe != NULL; pe = pe->next)
{ {
...@@ -1131,8 +1067,7 @@ save_registered_pragmas (pe, sd) ...@@ -1131,8 +1067,7 @@ save_registered_pragmas (pe, sd)
registered pragmas. */ registered pragmas. */
char ** char **
_cpp_save_pragma_names (pfile) _cpp_save_pragma_names (cpp_reader *pfile)
cpp_reader *pfile;
{ {
int ct = count_registered_pragmas (pfile->pragmas); int ct = count_registered_pragmas (pfile->pragmas);
char **result = xnewvec (char *, ct); char **result = xnewvec (char *, ct);
...@@ -1144,10 +1079,8 @@ _cpp_save_pragma_names (pfile) ...@@ -1144,10 +1079,8 @@ _cpp_save_pragma_names (pfile)
and return a pointer to the next unused name in SD. */ and return a pointer to the next unused name in SD. */
static char ** static char **
restore_registered_pragmas (pfile, pe, sd) restore_registered_pragmas (cpp_reader *pfile, struct pragma_entry *pe,
cpp_reader *pfile; char **sd)
struct pragma_entry *pe;
char **sd;
{ {
for (; pe != NULL; pe = pe->next) for (; pe != NULL; pe = pe->next)
{ {
...@@ -1163,9 +1096,7 @@ restore_registered_pragmas (pfile, pe, sd) ...@@ -1163,9 +1096,7 @@ restore_registered_pragmas (pfile, pe, sd)
/* Restore the names of the registered pragmas from SAVED. */ /* Restore the names of the registered pragmas from SAVED. */
void void
_cpp_restore_pragma_names (pfile, saved) _cpp_restore_pragma_names (cpp_reader *pfile, char **saved)
cpp_reader *pfile;
char **saved;
{ {
(void) restore_registered_pragmas (pfile, pfile->pragmas, saved); (void) restore_registered_pragmas (pfile, pfile->pragmas, saved);
free (saved); free (saved);
...@@ -1177,8 +1108,7 @@ _cpp_restore_pragma_names (pfile, saved) ...@@ -1177,8 +1108,7 @@ _cpp_restore_pragma_names (pfile, saved)
expansion happens for other pragmas is implementation defined. expansion happens for other pragmas is implementation defined.
This implementation never macro-expands the text after #pragma. */ This implementation never macro-expands the text after #pragma. */
static void static void
do_pragma (pfile) do_pragma (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const struct pragma_entry *p = NULL; const struct pragma_entry *p = NULL;
const cpp_token *token; const cpp_token *token;
...@@ -1207,14 +1137,14 @@ do_pragma (pfile) ...@@ -1207,14 +1137,14 @@ do_pragma (pfile)
themselves. Stand-alone CPP must ignore us, otherwise it will themselves. Stand-alone CPP must ignore us, otherwise it will
prefix the directive with spaces, hence the 1. Ugh. */ prefix the directive with spaces, hence the 1. Ugh. */
if (pfile->cb.line_change) if (pfile->cb.line_change)
(*pfile->cb.line_change)(pfile, token, 1); pfile->cb.line_change (pfile, token, 1);
if (p) if (p)
(*p->u.handler) (pfile); p->u.handler (pfile);
else if (pfile->cb.def_pragma) else if (pfile->cb.def_pragma)
{ {
_cpp_backup_tokens (pfile, count); _cpp_backup_tokens (pfile, count);
(*pfile->cb.def_pragma) (pfile, pfile->directive_line); pfile->cb.def_pragma (pfile, pfile->directive_line);
} }
pfile->state.prevent_expansion--; pfile->state.prevent_expansion--;
...@@ -1222,8 +1152,7 @@ do_pragma (pfile) ...@@ -1222,8 +1152,7 @@ do_pragma (pfile)
/* Handle #pragma once. */ /* Handle #pragma once. */
static void static void
do_pragma_once (pfile) do_pragma_once (cpp_reader *pfile)
cpp_reader *pfile;
{ {
if (CPP_OPTION (pfile, warn_deprecated)) if (CPP_OPTION (pfile, warn_deprecated))
cpp_error (pfile, DL_WARNING, "#pragma once is obsolete"); cpp_error (pfile, DL_WARNING, "#pragma once is obsolete");
...@@ -1239,8 +1168,7 @@ do_pragma_once (pfile) ...@@ -1239,8 +1168,7 @@ do_pragma_once (pfile)
/* Handle #pragma GCC poison, to poison one or more identifiers so /* Handle #pragma GCC poison, to poison one or more identifiers so
that the lexer produces a hard error for each subsequent usage. */ that the lexer produces a hard error for each subsequent usage. */
static void static void
do_pragma_poison (pfile) do_pragma_poison (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *tok; const cpp_token *tok;
cpp_hashnode *hp; cpp_hashnode *hp;
...@@ -1277,8 +1205,7 @@ do_pragma_poison (pfile) ...@@ -1277,8 +1205,7 @@ do_pragma_poison (pfile)
system include directory. To prevent abuse, it is rejected in the system include directory. To prevent abuse, it is rejected in the
primary source file. */ primary source file. */
static void static void
do_pragma_system_header (pfile) do_pragma_system_header (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
...@@ -1297,8 +1224,7 @@ do_pragma_system_header (pfile) ...@@ -1297,8 +1224,7 @@ do_pragma_system_header (pfile)
file. Issue a diagnostic, if the specified file is newer. We use this to file. Issue a diagnostic, if the specified file is newer. We use this to
determine if a fixed header should be refixed. */ determine if a fixed header should be refixed. */
static void static void
do_pragma_dependency (pfile) do_pragma_dependency (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const char *fname; const char *fname;
int angle_brackets, ordering; int angle_brackets, ordering;
...@@ -1325,8 +1251,7 @@ do_pragma_dependency (pfile) ...@@ -1325,8 +1251,7 @@ do_pragma_dependency (pfile)
/* Get a token but skip padding. */ /* Get a token but skip padding. */
static const cpp_token * static const cpp_token *
get_token_no_padding (pfile) get_token_no_padding (cpp_reader *pfile)
cpp_reader *pfile;
{ {
for (;;) for (;;)
{ {
...@@ -1339,8 +1264,7 @@ get_token_no_padding (pfile) ...@@ -1339,8 +1264,7 @@ get_token_no_padding (pfile)
/* Check syntax is "(string-literal)". Returns the string on success, /* Check syntax is "(string-literal)". Returns the string on success,
or NULL on failure. */ or NULL on failure. */
static const cpp_token * static const cpp_token *
get__Pragma_string (pfile) get__Pragma_string (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *string; const cpp_token *string;
...@@ -1360,9 +1284,7 @@ get__Pragma_string (pfile) ...@@ -1360,9 +1284,7 @@ get__Pragma_string (pfile)
/* Destringize IN into a temporary buffer, by removing the first \ of /* Destringize IN into a temporary buffer, by removing the first \ of
\" and \\ sequences, and process the result as a #pragma directive. */ \" and \\ sequences, and process the result as a #pragma directive. */
static void static void
destringize_and_run (pfile, in) destringize_and_run (cpp_reader *pfile, const cpp_string *in)
cpp_reader *pfile;
const cpp_string *in;
{ {
const unsigned char *src, *limit; const unsigned char *src, *limit;
char *dest, *result; char *dest, *result;
...@@ -1417,13 +1339,12 @@ destringize_and_run (pfile, in) ...@@ -1417,13 +1339,12 @@ destringize_and_run (pfile, in)
Getting the line markers is a little tricky. */ Getting the line markers is a little tricky. */
if (pfile->cb.line_change) if (pfile->cb.line_change)
(*pfile->cb.line_change) (pfile, pfile->cur_token, false); pfile->cb.line_change (pfile, pfile->cur_token, false);
} }
/* Handle the _Pragma operator. */ /* Handle the _Pragma operator. */
void void
_cpp_do__Pragma (pfile) _cpp_do__Pragma (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *string = get__Pragma_string (pfile); const cpp_token *string = get__Pragma_string (pfile);
...@@ -1434,17 +1355,15 @@ _cpp_do__Pragma (pfile) ...@@ -1434,17 +1355,15 @@ _cpp_do__Pragma (pfile)
"_Pragma takes a parenthesized string literal"); "_Pragma takes a parenthesized string literal");
} }
/* Just ignore #sccs on all systems. */ /* Ignore #sccs on all systems. */
static void static void
do_sccs (pfile) do_sccs (cpp_reader *pfile ATTRIBUTE_UNUSED)
cpp_reader *pfile ATTRIBUTE_UNUSED;
{ {
} }
/* Handle #ifdef. */ /* Handle #ifdef. */
static void static void
do_ifdef (pfile) do_ifdef (cpp_reader *pfile)
cpp_reader *pfile;
{ {
int skip = 1; int skip = 1;
...@@ -1465,8 +1384,7 @@ do_ifdef (pfile) ...@@ -1465,8 +1384,7 @@ do_ifdef (pfile)
/* Handle #ifndef. */ /* Handle #ifndef. */
static void static void
do_ifndef (pfile) do_ifndef (cpp_reader *pfile)
cpp_reader *pfile;
{ {
int skip = 1; int skip = 1;
const cpp_hashnode *node = 0; const cpp_hashnode *node = 0;
...@@ -1492,8 +1410,7 @@ do_ifndef (pfile) ...@@ -1492,8 +1410,7 @@ do_ifndef (pfile)
cannot treat it as a controlling conditional, since the expansion cannot treat it as a controlling conditional, since the expansion
could change in the future. That is handled by cpp_get_token. */ could change in the future. That is handled by cpp_get_token. */
static void static void
do_if (pfile) do_if (cpp_reader *pfile)
cpp_reader *pfile;
{ {
int skip = 1; int skip = 1;
...@@ -1507,8 +1424,7 @@ do_if (pfile) ...@@ -1507,8 +1424,7 @@ do_if (pfile)
if_stack; this is so that the error message for missing #endif's if_stack; this is so that the error message for missing #endif's
etc. will point to the original #if. */ etc. will point to the original #if. */
static void static void
do_else (pfile) do_else (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
struct if_stack *ifs = buffer->if_stack; struct if_stack *ifs = buffer->if_stack;
...@@ -1541,8 +1457,7 @@ do_else (pfile) ...@@ -1541,8 +1457,7 @@ do_else (pfile)
/* Handle a #elif directive by not changing if_stack either. See the /* Handle a #elif directive by not changing if_stack either. See the
comment above do_else. */ comment above do_else. */
static void static void
do_elif (pfile) do_elif (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
struct if_stack *ifs = buffer->if_stack; struct if_stack *ifs = buffer->if_stack;
...@@ -1577,8 +1492,7 @@ do_elif (pfile) ...@@ -1577,8 +1492,7 @@ do_elif (pfile)
/* #endif pops the if stack and resets pfile->state.skipping. */ /* #endif pops the if stack and resets pfile->state.skipping. */
static void static void
do_endif (pfile) do_endif (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
struct if_stack *ifs = buffer->if_stack; struct if_stack *ifs = buffer->if_stack;
...@@ -1609,11 +1523,8 @@ do_endif (pfile) ...@@ -1609,11 +1523,8 @@ do_endif (pfile)
is #if or #ifndef, CMACRO is a potentially controlling macro, and is #if or #ifndef, CMACRO is a potentially controlling macro, and
we need to check here that we are at the top of the file. */ we need to check here that we are at the top of the file. */
static void static void
push_conditional (pfile, skip, type, cmacro) push_conditional (cpp_reader *pfile, int skip, int type,
cpp_reader *pfile; const cpp_hashnode *cmacro)
int skip;
int type;
const cpp_hashnode *cmacro;
{ {
struct if_stack *ifs; struct if_stack *ifs;
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
...@@ -1639,10 +1550,7 @@ push_conditional (pfile, skip, type, cmacro) ...@@ -1639,10 +1550,7 @@ push_conditional (pfile, skip, type, cmacro)
storage, i.e. the #assert case. Returns 0 on success, and sets storage, i.e. the #assert case. Returns 0 on success, and sets
ANSWERP to point to the answer. */ ANSWERP to point to the answer. */
static int static int
parse_answer (pfile, answerp, type) parse_answer (cpp_reader *pfile, struct answer **answerp, int type)
cpp_reader *pfile;
struct answer **answerp;
int type;
{ {
const cpp_token *paren; const cpp_token *paren;
struct answer *answer; struct answer *answer;
...@@ -1718,10 +1626,7 @@ parse_answer (pfile, answerp, type) ...@@ -1718,10 +1626,7 @@ parse_answer (pfile, answerp, type)
the hash node of the predicate, or 0 on error. If an answer was the hash node of the predicate, or 0 on error. If an answer was
supplied, it is placed in ANSWERP, otherwise it is set to 0. */ supplied, it is placed in ANSWERP, otherwise it is set to 0. */
static cpp_hashnode * static cpp_hashnode *
parse_assertion (pfile, answerp, type) parse_assertion (cpp_reader *pfile, struct answer **answerp, int type)
cpp_reader *pfile;
struct answer **answerp;
int type;
{ {
cpp_hashnode *result = 0; cpp_hashnode *result = 0;
const cpp_token *predicate; const cpp_token *predicate;
...@@ -1753,9 +1658,7 @@ parse_assertion (pfile, answerp, type) ...@@ -1753,9 +1658,7 @@ parse_assertion (pfile, answerp, type)
/* Returns a pointer to the pointer to CANDIDATE in the answer chain, /* Returns a pointer to the pointer to CANDIDATE in the answer chain,
or a pointer to NULL if the answer is not in the chain. */ or a pointer to NULL if the answer is not in the chain. */
static struct answer ** static struct answer **
find_answer (node, candidate) find_answer (cpp_hashnode *node, const struct answer *candidate)
cpp_hashnode *node;
const struct answer *candidate;
{ {
unsigned int i; unsigned int i;
struct answer **result; struct answer **result;
...@@ -1782,9 +1685,7 @@ find_answer (node, candidate) ...@@ -1782,9 +1685,7 @@ find_answer (node, candidate)
nonzero on failure, zero on success. On success, the result of nonzero on failure, zero on success. On success, the result of
the test is written into VALUE, otherwise the value 0. */ the test is written into VALUE, otherwise the value 0. */
int int
_cpp_test_assertion (pfile, value) _cpp_test_assertion (cpp_reader *pfile, unsigned int *value)
cpp_reader *pfile;
unsigned int *value;
{ {
struct answer *answer; struct answer *answer;
cpp_hashnode *node; cpp_hashnode *node;
...@@ -1807,8 +1708,7 @@ _cpp_test_assertion (pfile, value) ...@@ -1807,8 +1708,7 @@ _cpp_test_assertion (pfile, value)
/* Handle #assert. */ /* Handle #assert. */
static void static void
do_assert (pfile) do_assert (cpp_reader *pfile)
cpp_reader *pfile;
{ {
struct answer *new_answer; struct answer *new_answer;
cpp_hashnode *node; cpp_hashnode *node;
...@@ -1841,8 +1741,7 @@ do_assert (pfile) ...@@ -1841,8 +1741,7 @@ do_assert (pfile)
/* Handle #unassert. */ /* Handle #unassert. */
static void static void
do_unassert (pfile) do_unassert (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_hashnode *node; cpp_hashnode *node;
struct answer *answer; struct answer *answer;
...@@ -1880,9 +1779,7 @@ do_unassert (pfile) ...@@ -1880,9 +1779,7 @@ do_unassert (pfile)
If STR has anything after the identifier, then it should If STR has anything after the identifier, then it should
be identifier=definition. */ be identifier=definition. */
void void
cpp_define (pfile, str) cpp_define (cpp_reader *pfile, const char *str)
cpp_reader *pfile;
const char *str;
{ {
char *buf, *p; char *buf, *p;
size_t count; size_t count;
...@@ -1910,9 +1807,7 @@ cpp_define (pfile, str) ...@@ -1910,9 +1807,7 @@ cpp_define (pfile, str)
/* Slight variant of the above for use by initialize_builtins. */ /* Slight variant of the above for use by initialize_builtins. */
void void
_cpp_define_builtin (pfile, str) _cpp_define_builtin (cpp_reader *pfile, const char *str)
cpp_reader *pfile;
const char *str;
{ {
size_t len = strlen (str); size_t len = strlen (str);
char *buf = alloca (len + 1); char *buf = alloca (len + 1);
...@@ -1923,9 +1818,7 @@ _cpp_define_builtin (pfile, str) ...@@ -1923,9 +1818,7 @@ _cpp_define_builtin (pfile, str)
/* Process MACRO as if it appeared as the body of an #undef. */ /* Process MACRO as if it appeared as the body of an #undef. */
void void
cpp_undef (pfile, macro) cpp_undef (cpp_reader *pfile, const char *macro)
cpp_reader *pfile;
const char *macro;
{ {
size_t len = strlen (macro); size_t len = strlen (macro);
char *buf = alloca (len + 1); char *buf = alloca (len + 1);
...@@ -1936,28 +1829,21 @@ cpp_undef (pfile, macro) ...@@ -1936,28 +1829,21 @@ cpp_undef (pfile, macro)
/* Process the string STR as if it appeared as the body of a #assert. */ /* Process the string STR as if it appeared as the body of a #assert. */
void void
cpp_assert (pfile, str) cpp_assert (cpp_reader *pfile, const char *str)
cpp_reader *pfile;
const char *str;
{ {
handle_assertion (pfile, str, T_ASSERT); handle_assertion (pfile, str, T_ASSERT);
} }
/* Process STR as if it appeared as the body of an #unassert. */ /* Process STR as if it appeared as the body of an #unassert. */
void void
cpp_unassert (pfile, str) cpp_unassert (cpp_reader *pfile, const char *str)
cpp_reader *pfile;
const char *str;
{ {
handle_assertion (pfile, str, T_UNASSERT); handle_assertion (pfile, str, T_UNASSERT);
} }
/* Common code for cpp_assert (-A) and cpp_unassert (-A-). */ /* Common code for cpp_assert (-A) and cpp_unassert (-A-). */
static void static void
handle_assertion (pfile, str, type) handle_assertion (cpp_reader *pfile, const char *str, int type)
cpp_reader *pfile;
const char *str;
int type;
{ {
size_t count = strlen (str); size_t count = strlen (str);
const char *p = strchr (str, '='); const char *p = strchr (str, '=');
...@@ -1980,41 +1866,35 @@ handle_assertion (pfile, str, type) ...@@ -1980,41 +1866,35 @@ handle_assertion (pfile, str, type)
/* The number of errors for a given reader. */ /* The number of errors for a given reader. */
unsigned int unsigned int
cpp_errors (pfile) cpp_errors (cpp_reader *pfile)
cpp_reader *pfile;
{ {
return pfile->errors; return pfile->errors;
} }
/* The options structure. */ /* The options structure. */
cpp_options * cpp_options *
cpp_get_options (pfile) cpp_get_options (cpp_reader *pfile)
cpp_reader *pfile;
{ {
return &pfile->opts; return &pfile->opts;
} }
/* The callbacks structure. */ /* The callbacks structure. */
cpp_callbacks * cpp_callbacks *
cpp_get_callbacks (pfile) cpp_get_callbacks (cpp_reader *pfile)
cpp_reader *pfile;
{ {
return &pfile->cb; return &pfile->cb;
} }
/* The line map set. */ /* The line map set. */
const struct line_maps * const struct line_maps *
cpp_get_line_maps (pfile) cpp_get_line_maps (cpp_reader *pfile)
cpp_reader *pfile;
{ {
return &pfile->line_maps; return &pfile->line_maps;
} }
/* Copy the given callbacks structure to our own. */ /* Copy the given callbacks structure to our own. */
void void
cpp_set_callbacks (pfile, cb) cpp_set_callbacks (cpp_reader *pfile, cpp_callbacks *cb)
cpp_reader *pfile;
cpp_callbacks *cb;
{ {
pfile->cb = *cb; pfile->cb = *cb;
} }
...@@ -2023,12 +1903,8 @@ cpp_set_callbacks (pfile, cb) ...@@ -2023,12 +1903,8 @@ cpp_set_callbacks (pfile, cb)
doesn't fail. It does not generate a file change call back; that doesn't fail. It does not generate a file change call back; that
is the responsibility of the caller. */ is the responsibility of the caller. */
cpp_buffer * cpp_buffer *
cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof) cpp_push_buffer (cpp_reader *pfile, const uchar *buffer, size_t len,
cpp_reader *pfile; int from_stage3, int return_at_eof)
const uchar *buffer;
size_t len;
int from_stage3;
int return_at_eof;
{ {
cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer); cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer);
...@@ -2049,8 +1925,7 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof) ...@@ -2049,8 +1925,7 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
/* Pops a single buffer, with a file change call-back if appropriate. /* Pops a single buffer, with a file change call-back if appropriate.
Then pushes the next -include file, if any remain. */ Then pushes the next -include file, if any remain. */
void void
_cpp_pop_buffer (pfile) _cpp_pop_buffer (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
struct include_file *inc = buffer->inc; struct include_file *inc = buffer->inc;
...@@ -2086,8 +1961,7 @@ _cpp_pop_buffer (pfile) ...@@ -2086,8 +1961,7 @@ _cpp_pop_buffer (pfile)
/* Enter all recognized directives in the hash table. */ /* Enter all recognized directives in the hash table. */
void void
_cpp_init_directives (pfile) _cpp_init_directives (cpp_reader *pfile)
cpp_reader *pfile;
{ {
unsigned int i; unsigned int i;
cpp_hashnode *node; cpp_hashnode *node;
......
...@@ -375,16 +375,16 @@ struct cpp_options ...@@ -375,16 +375,16 @@ struct cpp_options
struct cpp_callbacks struct cpp_callbacks
{ {
/* Called when a new line of preprocessed output is started. */ /* Called when a new line of preprocessed output is started. */
void (*line_change) PARAMS ((cpp_reader *, const cpp_token *, int)); void (*line_change) (cpp_reader *, const cpp_token *, int);
void (*file_change) PARAMS ((cpp_reader *, const struct line_map *)); void (*file_change) (cpp_reader *, const struct line_map *);
void (*include) PARAMS ((cpp_reader *, unsigned int, void (*include) (cpp_reader *, unsigned int, const unsigned char *,
const unsigned char *, const char *, int)); const char *, int);
void (*define) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *)); void (*define) (cpp_reader *, unsigned int, cpp_hashnode *);
void (*undef) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *)); void (*undef) (cpp_reader *, unsigned int, cpp_hashnode *);
void (*ident) PARAMS ((cpp_reader *, unsigned int, const cpp_string *)); void (*ident) (cpp_reader *, unsigned int, const cpp_string *);
void (*def_pragma) PARAMS ((cpp_reader *, unsigned int)); void (*def_pragma) (cpp_reader *, unsigned int);
int (*valid_pch) PARAMS ((cpp_reader *, const char *, int)); int (*valid_pch) (cpp_reader *, const char *, int);
void (*read_pch) PARAMS ((cpp_reader *, const char *, int, const char *)); void (*read_pch) (cpp_reader *, const char *, int, const char *);
}; };
/* Chain of directories to look for include files in. */ /* Chain of directories to look for include files in. */
...@@ -494,91 +494,83 @@ struct cpp_hashnode GTY(()) ...@@ -494,91 +494,83 @@ struct cpp_hashnode GTY(())
pointer. Otherwise you should pass in an initialized hash table pointer. Otherwise you should pass in an initialized hash table
that cpplib will share; this technique is used by the C front that cpplib will share; this technique is used by the C front
ends. */ ends. */
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang, struct ht *)); extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *);
/* Call this to change the selected language standard (e.g. because of /* Call this to change the selected language standard (e.g. because of
command line options). */ command line options). */
extern void cpp_set_lang PARAMS ((cpp_reader *, enum c_lang)); extern void cpp_set_lang (cpp_reader *, enum c_lang);
/* Add a dependency TARGET. Quote it for "make" if QUOTE. Can be /* Add a dependency TARGET. Quote it for "make" if QUOTE. Can be
called any number of times before cpp_read_main_file(). If no called any number of times before cpp_read_main_file(). If no
targets have been added before cpp_read_main_file(), then the targets have been added before cpp_read_main_file(), then the
default target is used. */ default target is used. */
extern void cpp_add_dependency_target PARAMS ((cpp_reader *, extern void cpp_add_dependency_target (cpp_reader *, const char *, int);
const char * target,
int quote));
/* Set the include paths. */ /* Set the include paths. */
extern void cpp_set_include_chains PARAMS ((cpp_reader *, cpp_path *, extern void cpp_set_include_chains (cpp_reader *, cpp_path *, cpp_path *, int);
cpp_path *, int));
/* Call these to get pointers to the options and callback structures /* Call these to get pointers to the options and callback structures
for a given reader. These pointers are good until you call for a given reader. These pointers are good until you call
cpp_finish on that reader. You can either edit the callbacks cpp_finish on that reader. You can either edit the callbacks
through the pointer returned from cpp_get_callbacks, or set them through the pointer returned from cpp_get_callbacks, or set them
with cpp_set_callbacks. */ with cpp_set_callbacks. */
extern cpp_options *cpp_get_options PARAMS ((cpp_reader *)); extern cpp_options *cpp_get_options (cpp_reader *);
extern const struct line_maps *cpp_get_line_maps PARAMS ((cpp_reader *)); extern const struct line_maps *cpp_get_line_maps (cpp_reader *);
extern cpp_callbacks *cpp_get_callbacks PARAMS ((cpp_reader *)); extern cpp_callbacks *cpp_get_callbacks (cpp_reader *);
extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *)); extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
/* This function reads the file, but does not start preprocessing. It /* This function reads the file, but does not start preprocessing. It
returns the name of the original file; this is the same as the returns the name of the original file; this is the same as the
input file, except for preprocessed input. This will generate at input file, except for preprocessed input. This will generate at
least one file change callback, and possibly a line change callback least one file change callback, and possibly a line change callback
too. If there was an error opening the file, it returns NULL. */ too. If there was an error opening the file, it returns NULL. */
extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *)); extern const char *cpp_read_main_file (cpp_reader *, const char *);
/* Set up built-ins like __FILE__. */ /* Set up built-ins like __FILE__. */
extern void cpp_init_builtins PARAMS ((cpp_reader *, int)); extern void cpp_init_builtins (cpp_reader *, int);
/* Call this to finish preprocessing. If you requested dependency /* Call this to finish preprocessing. If you requested dependency
generation, pass an open stream to write the information to, generation, pass an open stream to write the information to,
otherwise NULL. It is your responsibility to close the stream. otherwise NULL. It is your responsibility to close the stream.
Returns cpp_errors (pfile). */ Returns cpp_errors (pfile). */
extern int cpp_finish PARAMS ((cpp_reader *, FILE *deps_stream)); extern int cpp_finish (cpp_reader *, FILE *deps_stream);
/* Call this to release the handle at the end of preprocessing. Any /* Call this to release the handle at the end of preprocessing. Any
use of the handle after this function returns is invalid. Returns use of the handle after this function returns is invalid. Returns
cpp_errors (pfile). */ cpp_errors (pfile). */
extern void cpp_destroy PARAMS ((cpp_reader *)); extern void cpp_destroy (cpp_reader *);
/* Error count. */ /* Error count. */
extern unsigned int cpp_errors PARAMS ((cpp_reader *)); extern unsigned int cpp_errors (cpp_reader *);
extern unsigned int cpp_token_len PARAMS ((const cpp_token *)); extern unsigned int cpp_token_len (const cpp_token *);
extern unsigned char *cpp_token_as_text PARAMS ((cpp_reader *, extern unsigned char *cpp_token_as_text (cpp_reader *, const cpp_token *);
const cpp_token *)); extern unsigned char *cpp_spell_token (cpp_reader *, const cpp_token *,
extern unsigned char *cpp_spell_token PARAMS ((cpp_reader *, const cpp_token *, unsigned char *);
unsigned char *)); extern void cpp_register_pragma (cpp_reader *, const char *, const char *,
extern void cpp_register_pragma PARAMS ((cpp_reader *, void (*) (cpp_reader *));
const char *, const char *, extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
void (*) PARAMS ((cpp_reader *)))); const cpp_token *);
extern const cpp_token *cpp_get_token (cpp_reader *);
extern int cpp_avoid_paste PARAMS ((cpp_reader *, const cpp_token *, extern const unsigned char *cpp_macro_definition (cpp_reader *,
const cpp_token *)); const cpp_hashnode *);
extern const cpp_token *cpp_get_token PARAMS ((cpp_reader *)); extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
extern const unsigned char *cpp_macro_definition PARAMS ((cpp_reader *,
const cpp_hashnode *));
extern void _cpp_backup_tokens PARAMS ((cpp_reader *, unsigned int));
/* Evaluate a CPP_CHAR or CPP_WCHAR token. */ /* Evaluate a CPP_CHAR or CPP_WCHAR token. */
extern cppchar_t extern cppchar_t cpp_interpret_charconst (cpp_reader *, const cpp_token *,
cpp_interpret_charconst PARAMS ((cpp_reader *, const cpp_token *, unsigned int *, int *);
unsigned int *, int *));
/* Used to register macros and assertions, perhaps from the command line. /* Used to register macros and assertions, perhaps from the command line.
The text is the same as the command line argument. */ The text is the same as the command line argument. */
extern void cpp_define PARAMS ((cpp_reader *, const char *)); extern void cpp_define (cpp_reader *, const char *);
extern void cpp_assert PARAMS ((cpp_reader *, const char *)); extern void cpp_assert (cpp_reader *, const char *);
extern void cpp_undef PARAMS ((cpp_reader *, const char *)); extern void cpp_undef (cpp_reader *, const char *);
extern void cpp_unassert PARAMS ((cpp_reader *, const char *)); extern void cpp_unassert (cpp_reader *, const char *);
extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, extern cpp_buffer *cpp_push_buffer (cpp_reader *, const unsigned char *,
const unsigned char *, size_t, size_t, int, int);
int, int)); extern int cpp_defined (cpp_reader *, const unsigned char *, int);
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
/* A preprocessing number. Code assumes that any unused high bits of /* A preprocessing number. Code assumes that any unused high bits of
the double integer are set to zero. */ the double integer are set to zero. */
...@@ -619,15 +611,15 @@ struct cpp_num ...@@ -619,15 +611,15 @@ struct cpp_num
/* Classify a CPP_NUMBER token. The return value is a combination of /* Classify a CPP_NUMBER token. The return value is a combination of
the flags from the above sets. */ the flags from the above sets. */
extern unsigned cpp_classify_number PARAMS ((cpp_reader *, const cpp_token *)); extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *);
/* Evaluate a token classified as category CPP_N_INTEGER. */ /* Evaluate a token classified as category CPP_N_INTEGER. */
extern cpp_num cpp_interpret_integer PARAMS ((cpp_reader *, const cpp_token *, extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
unsigned int type)); unsigned int type);
/* Sign extend a number, with PRECISION significant bits and all /* Sign extend a number, with PRECISION significant bits and all
others assumed clear, to fill out a cpp_num structure. */ others assumed clear, to fill out a cpp_num structure. */
cpp_num cpp_num_sign_extend PARAMS ((cpp_num, size_t)); cpp_num cpp_num_sign_extend (cpp_num, size_t);
/* Diagnostic levels. To get a diagnostic without associating a /* Diagnostic levels. To get a diagnostic without associating a
position in the translation unit with it, use cpp_error_with_line position in the translation unit with it, use cpp_error_with_line
...@@ -657,72 +649,64 @@ cpp_num cpp_num_sign_extend PARAMS ((cpp_num, size_t)); ...@@ -657,72 +649,64 @@ cpp_num cpp_num_sign_extend PARAMS ((cpp_num, size_t));
getting ridiculously oversized. */ getting ridiculously oversized. */
/* Output a diagnostic of some kind. */ /* Output a diagnostic of some kind. */
extern void cpp_error PARAMS ((cpp_reader *, int, const char *msgid, ...)) extern void cpp_error (cpp_reader *, int, const char *msgid, ...)
ATTRIBUTE_PRINTF_3; ATTRIBUTE_PRINTF_3;
/* Output a diagnostic of severity LEVEL, with "MSG: " preceding the /* Output a diagnostic with "MSGID: " preceding the
error string of errno. No location is printed. */ error string of errno. No location is printed. */
extern void cpp_errno PARAMS ((cpp_reader *, int level, const char *msg)); extern void cpp_errno (cpp_reader *, int, const char *msgid);
/* Same as cpp_error, except additionally specifies a position as a /* Same as cpp_error, except additionally specifies a position as a
(translation unit) physical line and physical column. If the line is (translation unit) physical line and physical column. If the line is
zero, then no location is printed. */ zero, then no location is printed. */
extern void cpp_error_with_line PARAMS ((cpp_reader *, int, unsigned, unsigned, const char *msgid, ...)) extern void cpp_error_with_line (cpp_reader *, int, unsigned, unsigned, const char *msgid, ...)
ATTRIBUTE_PRINTF_5; ATTRIBUTE_PRINTF_5;
/* In cpplex.c */ /* In cpplex.c */
extern int cpp_ideq PARAMS ((const cpp_token *, extern int cpp_ideq (const cpp_token *, const char *);
const char *)); extern void cpp_output_line (cpp_reader *, FILE *);
extern void cpp_output_line PARAMS ((cpp_reader *, FILE *)); extern void cpp_output_token (const cpp_token *, FILE *);
extern void cpp_output_token PARAMS ((const cpp_token *, FILE *)); extern const char *cpp_type2name (enum cpp_ttype);
extern const char *cpp_type2name PARAMS ((enum cpp_ttype));
/* Returns the value of an escape sequence, truncated to the correct /* Returns the value of an escape sequence, truncated to the correct
target precision. PSTR points to the input pointer, which is just target precision. PSTR points to the input pointer, which is just
after the backslash. LIMIT is how much text we have. WIDE is true after the backslash. LIMIT is how much text we have. WIDE is true
if the escape sequence is part of a wide character constant or if the escape sequence is part of a wide character constant or
string literal. Handles all relevant diagnostics. */ string literal. Handles all relevant diagnostics. */
extern cppchar_t cpp_parse_escape PARAMS ((cpp_reader *, extern cppchar_t cpp_parse_escape (cpp_reader *, const unsigned char ** pstr,
const unsigned char ** pstr, const unsigned char *limit, int wide);
const unsigned char *limit,
int wide));
/* In cpphash.c */ /* In cpphash.c */
/* Lookup an identifier in the hashtable. Puts the identifier in the /* Lookup an identifier in the hashtable. Puts the identifier in the
table if it is not already there. */ table if it is not already there. */
extern cpp_hashnode *cpp_lookup PARAMS ((cpp_reader *, extern cpp_hashnode *cpp_lookup (cpp_reader *, const unsigned char *,
const unsigned char *, unsigned int);
unsigned int));
typedef int (*cpp_cb) PARAMS ((cpp_reader *, cpp_hashnode *, void *)); typedef int (*cpp_cb) (cpp_reader *, cpp_hashnode *, void *);
extern void cpp_forall_identifiers PARAMS ((cpp_reader *, extern void cpp_forall_identifiers (cpp_reader *, cpp_cb, void *);
cpp_cb, void *));
/* In cppmacro.c */ /* In cppmacro.c */
extern void cpp_scan_nooutput PARAMS ((cpp_reader *)); extern void cpp_scan_nooutput (cpp_reader *);
extern int cpp_sys_macro_p PARAMS ((cpp_reader *)); extern int cpp_sys_macro_p (cpp_reader *);
extern unsigned char *cpp_quote_string PARAMS ((unsigned char *, extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
const unsigned char *, unsigned int);
unsigned int));
/* In cppfiles.c */ /* In cppfiles.c */
extern int cpp_included PARAMS ((cpp_reader *, const char *)); extern int cpp_included (cpp_reader *, const char *);
extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int)); extern void cpp_make_system_header (cpp_reader *, int, int);
extern void cpp_simplify_path PARAMS ((char *)); extern void cpp_simplify_path (char *);
extern bool cpp_push_include PARAMS ((cpp_reader *, const char *)); extern bool cpp_push_include (cpp_reader *, const char *);
extern void cpp_change_file PARAMS ((cpp_reader *, enum lc_reason, extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
const char *));
/* In cpppch.c */ /* In cpppch.c */
struct save_macro_data; struct save_macro_data;
extern int cpp_save_state PARAMS ((cpp_reader *, FILE *)); extern int cpp_save_state (cpp_reader *, FILE *);
extern int cpp_write_pch_deps PARAMS ((cpp_reader *, FILE *)); extern int cpp_write_pch_deps (cpp_reader *, FILE *);
extern int cpp_write_pch_state PARAMS ((cpp_reader *, FILE *)); extern int cpp_write_pch_state (cpp_reader *, FILE *);
extern int cpp_valid_state PARAMS ((cpp_reader *, const char *, int)); extern int cpp_valid_state (cpp_reader *, const char *, int);
extern void cpp_prepare_state PARAMS ((cpp_reader *, extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **);
struct save_macro_data **)); extern int cpp_read_state (cpp_reader *, const char *, FILE *,
extern int cpp_read_state PARAMS ((cpp_reader *, const char *, FILE *, struct save_macro_data *);
struct save_macro_data *));
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -42,47 +42,40 @@ struct macro_arg ...@@ -42,47 +42,40 @@ struct macro_arg
/* Macro expansion. */ /* Macro expansion. */
static int enter_macro_context PARAMS ((cpp_reader *, cpp_hashnode *)); static int enter_macro_context (cpp_reader *, cpp_hashnode *);
static int builtin_macro PARAMS ((cpp_reader *, cpp_hashnode *)); static int builtin_macro (cpp_reader *, cpp_hashnode *);
static void push_token_context static void push_token_context (cpp_reader *, cpp_hashnode *,
PARAMS ((cpp_reader *, cpp_hashnode *, const cpp_token *, unsigned int)); const cpp_token *, unsigned int);
static void push_ptoken_context static void push_ptoken_context (cpp_reader *, cpp_hashnode *, _cpp_buff *,
PARAMS ((cpp_reader *, cpp_hashnode *, _cpp_buff *, const cpp_token **, unsigned int);
const cpp_token **, unsigned int)); static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *);
static _cpp_buff *collect_args PARAMS ((cpp_reader *, const cpp_hashnode *)); static cpp_context *next_context (cpp_reader *);
static cpp_context *next_context PARAMS ((cpp_reader *)); static const cpp_token *padding_token (cpp_reader *, const cpp_token *);
static const cpp_token *padding_token static void expand_arg (cpp_reader *, macro_arg *);
PARAMS ((cpp_reader *, const cpp_token *)); static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int);
static void expand_arg PARAMS ((cpp_reader *, macro_arg *)); static const cpp_token *stringify_arg (cpp_reader *, macro_arg *);
static const cpp_token *new_string_token PARAMS ((cpp_reader *, uchar *, static void paste_all_tokens (cpp_reader *, const cpp_token *);
unsigned int)); static bool paste_tokens (cpp_reader *, const cpp_token **, const cpp_token *);
static const cpp_token *stringify_arg PARAMS ((cpp_reader *, macro_arg *)); static void replace_args (cpp_reader *, cpp_hashnode *, cpp_macro *,
static void paste_all_tokens PARAMS ((cpp_reader *, const cpp_token *)); macro_arg *);
static bool paste_tokens PARAMS ((cpp_reader *, const cpp_token **, static _cpp_buff *funlike_invocation_p (cpp_reader *, cpp_hashnode *);
const cpp_token *)); static bool create_iso_definition (cpp_reader *, cpp_macro *);
static void replace_args PARAMS ((cpp_reader *, cpp_hashnode *, cpp_macro *,
macro_arg *));
static _cpp_buff *funlike_invocation_p PARAMS ((cpp_reader *, cpp_hashnode *));
static bool create_iso_definition PARAMS ((cpp_reader *, cpp_macro *));
/* #define directive parsing and handling. */ /* #define directive parsing and handling. */
static cpp_token *alloc_expansion_token PARAMS ((cpp_reader *, cpp_macro *)); static cpp_token *alloc_expansion_token (cpp_reader *, cpp_macro *);
static cpp_token *lex_expansion_token PARAMS ((cpp_reader *, cpp_macro *)); static cpp_token *lex_expansion_token (cpp_reader *, cpp_macro *);
static bool warn_of_redefinition PARAMS ((cpp_reader *, const cpp_hashnode *, static bool warn_of_redefinition (cpp_reader *, const cpp_hashnode *,
const cpp_macro *)); const cpp_macro *);
static bool parse_params PARAMS ((cpp_reader *, cpp_macro *)); static bool parse_params (cpp_reader *, cpp_macro *);
static void check_trad_stringification PARAMS ((cpp_reader *, static void check_trad_stringification (cpp_reader *, const cpp_macro *,
const cpp_macro *, const cpp_string *);
const cpp_string *));
/* Emits a warning if NODE is a macro defined in the main file that /* Emits a warning if NODE is a macro defined in the main file that
has not been used. */ has not been used. */
int int
_cpp_warn_if_unused_macro (pfile, node, v) _cpp_warn_if_unused_macro (cpp_reader *pfile, cpp_hashnode *node,
cpp_reader *pfile; void *v ATTRIBUTE_UNUSED)
cpp_hashnode *node;
void *v ATTRIBUTE_UNUSED;
{ {
if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN)) if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
{ {
...@@ -100,10 +93,7 @@ _cpp_warn_if_unused_macro (pfile, node, v) ...@@ -100,10 +93,7 @@ _cpp_warn_if_unused_macro (pfile, node, v)
/* Allocates and returns a CPP_STRING token, containing TEXT of length /* Allocates and returns a CPP_STRING token, containing TEXT of length
LEN, after null-terminating it. TEXT must be in permanent storage. */ LEN, after null-terminating it. TEXT must be in permanent storage. */
static const cpp_token * static const cpp_token *
new_string_token (pfile, text, len) new_string_token (cpp_reader *pfile, unsigned char *text, unsigned int len)
cpp_reader *pfile;
unsigned char *text;
unsigned int len;
{ {
cpp_token *token = _cpp_temp_token (pfile); cpp_token *token = _cpp_temp_token (pfile);
...@@ -126,9 +116,7 @@ static const char * const monthnames[] = ...@@ -126,9 +116,7 @@ static const char * const monthnames[] =
is created. Returns 1 if it generates a new token context, 0 to is created. Returns 1 if it generates a new token context, 0 to
return the token to the caller. */ return the token to the caller. */
const uchar * const uchar *
_cpp_builtin_macro_text (pfile, node) _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
const uchar *result = NULL; const uchar *result = NULL;
unsigned int number = 1; unsigned int number = 1;
...@@ -221,7 +209,8 @@ _cpp_builtin_macro_text (pfile, node) ...@@ -221,7 +209,8 @@ _cpp_builtin_macro_text (pfile, node)
pfile->date = _cpp_unaligned_alloc (pfile, pfile->date = _cpp_unaligned_alloc (pfile,
sizeof ("\"Oct 11 1347\"")); sizeof ("\"Oct 11 1347\""));
sprintf ((char *) pfile->date, "\"%s %2d %4d\"", sprintf ((char *) pfile->date, "\"%s %2d %4d\"",
monthnames[tb->tm_mon], tb->tm_mday, tb->tm_year + 1900); monthnames[tb->tm_mon], tb->tm_mday,
tb->tm_year + 1900);
pfile->time = _cpp_unaligned_alloc (pfile, pfile->time = _cpp_unaligned_alloc (pfile,
sizeof ("\"12:34:56\"")); sizeof ("\"12:34:56\""));
...@@ -260,9 +249,7 @@ _cpp_builtin_macro_text (pfile, node) ...@@ -260,9 +249,7 @@ _cpp_builtin_macro_text (pfile, node)
created. Returns 1 if it generates a new token context, 0 to created. Returns 1 if it generates a new token context, 0 to
return the token to the caller. */ return the token to the caller. */
static int static int
builtin_macro (pfile, node) builtin_macro (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
const uchar *buf; const uchar *buf;
size_t len; size_t len;
...@@ -304,10 +291,7 @@ builtin_macro (pfile, node) ...@@ -304,10 +291,7 @@ builtin_macro (pfile, node)
converted to octal. DEST must be of sufficient size. Returns converted to octal. DEST must be of sufficient size. Returns
a pointer to the end of the string. */ a pointer to the end of the string. */
uchar * uchar *
cpp_quote_string (dest, src, len) cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
uchar *dest;
const uchar *src;
unsigned int len;
{ {
while (len--) while (len--)
{ {
...@@ -336,9 +320,7 @@ cpp_quote_string (dest, src, len) ...@@ -336,9 +320,7 @@ cpp_quote_string (dest, src, len)
/* Convert a token sequence ARG to a single string token according to /* Convert a token sequence ARG to a single string token according to
the rules of the ISO C #-operator. */ the rules of the ISO C #-operator. */
static const cpp_token * static const cpp_token *
stringify_arg (pfile, arg) stringify_arg (cpp_reader *pfile, macro_arg *arg)
cpp_reader *pfile;
macro_arg *arg;
{ {
unsigned char *dest; unsigned char *dest;
unsigned int i, escape_it, backslash_count = 0; unsigned int i, escape_it, backslash_count = 0;
...@@ -425,9 +407,7 @@ stringify_arg (pfile, arg) ...@@ -425,9 +407,7 @@ stringify_arg (pfile, arg)
case, PLHS is updated to point to the pasted token, which is case, PLHS is updated to point to the pasted token, which is
guaranteed to not have the PASTE_LEFT flag set. */ guaranteed to not have the PASTE_LEFT flag set. */
static bool static bool
paste_tokens (pfile, plhs, rhs) paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs)
cpp_reader *pfile;
const cpp_token **plhs, *rhs;
{ {
unsigned char *buf, *end; unsigned char *buf, *end;
const cpp_token *lhs; const cpp_token *lhs;
...@@ -468,9 +448,7 @@ paste_tokens (pfile, plhs, rhs) ...@@ -468,9 +448,7 @@ paste_tokens (pfile, plhs, rhs)
successful pastes, with the effect that the RHS appears in the successful pastes, with the effect that the RHS appears in the
output stream after the pasted LHS normally. */ output stream after the pasted LHS normally. */
static void static void
paste_all_tokens (pfile, lhs) paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs)
cpp_reader *pfile;
const cpp_token *lhs;
{ {
const cpp_token *rhs; const cpp_token *rhs;
cpp_context *context = pfile->context; cpp_context *context = pfile->context;
...@@ -516,11 +494,7 @@ paste_all_tokens (pfile, lhs) ...@@ -516,11 +494,7 @@ paste_all_tokens (pfile, lhs)
Note that MACRO cannot necessarily be deduced from NODE, in case Note that MACRO cannot necessarily be deduced from NODE, in case
NODE was redefined whilst collecting arguments. */ NODE was redefined whilst collecting arguments. */
bool bool
_cpp_arguments_ok (pfile, macro, node, argc) _cpp_arguments_ok (cpp_reader *pfile, cpp_macro *macro, const cpp_hashnode *node, unsigned int argc)
cpp_reader *pfile;
cpp_macro *macro;
const cpp_hashnode *node;
unsigned int argc;
{ {
if (argc == macro->paramc) if (argc == macro->paramc)
return true; return true;
...@@ -561,9 +535,7 @@ _cpp_arguments_ok (pfile, macro, node, argc) ...@@ -561,9 +535,7 @@ _cpp_arguments_ok (pfile, macro, node, argc)
NULL. Each argument is terminated by a CPP_EOF token, for the NULL. Each argument is terminated by a CPP_EOF token, for the
future benefit of expand_arg(). */ future benefit of expand_arg(). */
static _cpp_buff * static _cpp_buff *
collect_args (pfile, node) collect_args (cpp_reader *pfile, const cpp_hashnode *node)
cpp_reader *pfile;
const cpp_hashnode *node;
{ {
_cpp_buff *buff, *base_buff; _cpp_buff *buff, *base_buff;
cpp_macro *macro; cpp_macro *macro;
...@@ -697,9 +669,7 @@ collect_args (pfile, node) ...@@ -697,9 +669,7 @@ collect_args (pfile, node)
intervening padding tokens. If we find the parenthesis, collect intervening padding tokens. If we find the parenthesis, collect
the arguments and return the buffer containing them. */ the arguments and return the buffer containing them. */
static _cpp_buff * static _cpp_buff *
funlike_invocation_p (pfile, node) funlike_invocation_p (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
const cpp_token *token, *padding = NULL; const cpp_token *token, *padding = NULL;
...@@ -739,9 +709,7 @@ funlike_invocation_p (pfile, node) ...@@ -739,9 +709,7 @@ funlike_invocation_p (pfile, node)
containing its yet-to-be-rescanned replacement list and return one. containing its yet-to-be-rescanned replacement list and return one.
Otherwise, we don't push a context and return zero. */ Otherwise, we don't push a context and return zero. */
static int static int
enter_macro_context (pfile, node) enter_macro_context (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
/* The presence of a macro invalidates a file's controlling macro. */ /* The presence of a macro invalidates a file's controlling macro. */
pfile->mi_valid = false; pfile->mi_valid = false;
...@@ -800,11 +768,7 @@ enter_macro_context (pfile, node) ...@@ -800,11 +768,7 @@ enter_macro_context (pfile, node)
Expand each argument before replacing, unless it is operated upon Expand each argument before replacing, unless it is operated upon
by the # or ## operators. */ by the # or ## operators. */
static void static void
replace_args (pfile, node, macro, args) replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg *args)
cpp_reader *pfile;
cpp_hashnode *node;
cpp_macro *macro;
macro_arg *args;
{ {
unsigned int i, total; unsigned int i, total;
const cpp_token *src, *limit; const cpp_token *src, *limit;
...@@ -936,9 +900,7 @@ replace_args (pfile, node, macro, args) ...@@ -936,9 +900,7 @@ replace_args (pfile, node, macro, args)
/* Return a special padding token, with padding inherited from SOURCE. */ /* Return a special padding token, with padding inherited from SOURCE. */
static const cpp_token * static const cpp_token *
padding_token (pfile, source) padding_token (cpp_reader *pfile, const cpp_token *source)
cpp_reader *pfile;
const cpp_token *source;
{ {
cpp_token *result = _cpp_temp_token (pfile); cpp_token *result = _cpp_temp_token (pfile);
...@@ -951,8 +913,7 @@ padding_token (pfile, source) ...@@ -951,8 +913,7 @@ padding_token (pfile, source)
/* Get a new uninitialized context. Create a new one if we cannot /* Get a new uninitialized context. Create a new one if we cannot
re-use an old one. */ re-use an old one. */
static cpp_context * static cpp_context *
next_context (pfile) next_context (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_context *result = pfile->context->next; cpp_context *result = pfile->context->next;
...@@ -970,12 +931,8 @@ next_context (pfile) ...@@ -970,12 +931,8 @@ next_context (pfile)
/* Push a list of pointers to tokens. */ /* Push a list of pointers to tokens. */
static void static void
push_ptoken_context (pfile, macro, buff, first, count) push_ptoken_context (cpp_reader *pfile, cpp_hashnode *macro, _cpp_buff *buff,
cpp_reader *pfile; const cpp_token **first, unsigned int count)
cpp_hashnode *macro;
_cpp_buff *buff;
const cpp_token **first;
unsigned int count;
{ {
cpp_context *context = next_context (pfile); cpp_context *context = next_context (pfile);
...@@ -988,11 +945,8 @@ push_ptoken_context (pfile, macro, buff, first, count) ...@@ -988,11 +945,8 @@ push_ptoken_context (pfile, macro, buff, first, count)
/* Push a list of tokens. */ /* Push a list of tokens. */
static void static void
push_token_context (pfile, macro, first, count) push_token_context (cpp_reader *pfile, cpp_hashnode *macro,
cpp_reader *pfile; const cpp_token *first, unsigned int count)
cpp_hashnode *macro;
const cpp_token *first;
unsigned int count;
{ {
cpp_context *context = next_context (pfile); cpp_context *context = next_context (pfile);
...@@ -1005,11 +959,8 @@ push_token_context (pfile, macro, first, count) ...@@ -1005,11 +959,8 @@ push_token_context (pfile, macro, first, count)
/* Push a traditional macro's replacement text. */ /* Push a traditional macro's replacement text. */
void void
_cpp_push_text_context (pfile, macro, start, len) _cpp_push_text_context (cpp_reader *pfile, cpp_hashnode *macro,
cpp_reader *pfile; const uchar *start, size_t len)
cpp_hashnode *macro;
const uchar *start;
size_t len;
{ {
cpp_context *context = next_context (pfile); cpp_context *context = next_context (pfile);
...@@ -1028,9 +979,7 @@ _cpp_push_text_context (pfile, macro, start, len) ...@@ -1028,9 +979,7 @@ _cpp_push_text_context (pfile, macro, start, len)
has terminated the argument's tokens with a CPP_EOF so that we know has terminated the argument's tokens with a CPP_EOF so that we know
when we have fully expanded the argument. */ when we have fully expanded the argument. */
static void static void
expand_arg (pfile, arg) expand_arg (cpp_reader *pfile, macro_arg *arg)
cpp_reader *pfile;
macro_arg *arg;
{ {
unsigned int capacity; unsigned int capacity;
bool saved_warn_trad; bool saved_warn_trad;
...@@ -1076,8 +1025,7 @@ expand_arg (pfile, arg) ...@@ -1076,8 +1025,7 @@ expand_arg (pfile, arg)
context represented a macro's replacement list. The context context represented a macro's replacement list. The context
structure is not freed so that we can re-use it later. */ structure is not freed so that we can re-use it later. */
void void
_cpp_pop_context (pfile) _cpp_pop_context (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_context *context = pfile->context; cpp_context *context = pfile->context;
...@@ -1102,8 +1050,7 @@ _cpp_pop_context (pfile) ...@@ -1102,8 +1050,7 @@ _cpp_pop_context (pfile)
state.in_directive is still 1, and at the end of argument state.in_directive is still 1, and at the end of argument
pre-expansion. */ pre-expansion. */
const cpp_token * const cpp_token *
cpp_get_token (pfile) cpp_get_token (cpp_reader *pfile)
cpp_reader *pfile;
{ {
const cpp_token *result; const cpp_token *result;
...@@ -1180,8 +1127,7 @@ cpp_get_token (pfile) ...@@ -1180,8 +1127,7 @@ cpp_get_token (pfile)
defined in a system header. Just checks the macro at the top of defined in a system header. Just checks the macro at the top of
the stack. Used for diagnostic suppression. */ the stack. Used for diagnostic suppression. */
int int
cpp_sys_macro_p (pfile) cpp_sys_macro_p (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_hashnode *node = pfile->context->macro; cpp_hashnode *node = pfile->context->macro;
...@@ -1191,8 +1137,7 @@ cpp_sys_macro_p (pfile) ...@@ -1191,8 +1137,7 @@ cpp_sys_macro_p (pfile)
/* Read each token in, until end of the current file. Directives are /* Read each token in, until end of the current file. Directives are
transparently processed. */ transparently processed. */
void void
cpp_scan_nooutput (pfile) cpp_scan_nooutput (cpp_reader *pfile)
cpp_reader *pfile;
{ {
/* Request a CPP_EOF token at the end of this file, rather than /* Request a CPP_EOF token at the end of this file, rather than
transparently continuing with the including file. */ transparently continuing with the including file. */
...@@ -1209,9 +1154,7 @@ cpp_scan_nooutput (pfile) ...@@ -1209,9 +1154,7 @@ cpp_scan_nooutput (pfile)
/* Step back one (or more) tokens. Can only step mack more than 1 if /* Step back one (or more) tokens. Can only step mack more than 1 if
they are from the lexer, and not from macro expansion. */ they are from the lexer, and not from macro expansion. */
void void
_cpp_backup_tokens (pfile, count) _cpp_backup_tokens (cpp_reader *pfile, unsigned int count)
cpp_reader *pfile;
unsigned int count;
{ {
if (pfile->context->prev == NULL) if (pfile->context->prev == NULL)
{ {
...@@ -1243,10 +1186,8 @@ _cpp_backup_tokens (pfile, count) ...@@ -1243,10 +1186,8 @@ _cpp_backup_tokens (pfile, count)
/* Returns nonzero if a macro redefinition warning is required. */ /* Returns nonzero if a macro redefinition warning is required. */
static bool static bool
warn_of_redefinition (pfile, node, macro2) warn_of_redefinition (cpp_reader *pfile, const cpp_hashnode *node,
cpp_reader *pfile; const cpp_macro *macro2)
const cpp_hashnode *node;
const cpp_macro *macro2;
{ {
const cpp_macro *macro1; const cpp_macro *macro1;
unsigned int i; unsigned int i;
...@@ -1287,8 +1228,7 @@ warn_of_redefinition (pfile, node, macro2) ...@@ -1287,8 +1228,7 @@ warn_of_redefinition (pfile, node, macro2)
/* Free the definition of hashnode H. */ /* Free the definition of hashnode H. */
void void
_cpp_free_definition (h) _cpp_free_definition (cpp_hashnode *h)
cpp_hashnode *h;
{ {
/* Macros and assertions no longer have anything to free. */ /* Macros and assertions no longer have anything to free. */
h->type = NT_VOID; h->type = NT_VOID;
...@@ -1299,10 +1239,7 @@ _cpp_free_definition (h) ...@@ -1299,10 +1239,7 @@ _cpp_free_definition (h)
/* Save parameter NODE to the parameter list of macro MACRO. Returns /* Save parameter NODE to the parameter list of macro MACRO. Returns
zero on success, nonzero if the parameter is a duplicate. */ zero on success, nonzero if the parameter is a duplicate. */
bool bool
_cpp_save_parameter (pfile, macro, node) _cpp_save_parameter (cpp_reader *pfile, cpp_macro *macro, cpp_hashnode *node)
cpp_reader *pfile;
cpp_macro *macro;
cpp_hashnode *node;
{ {
unsigned int len; unsigned int len;
/* Constraint 6.10.3.6 - duplicate parameter names. */ /* Constraint 6.10.3.6 - duplicate parameter names. */
...@@ -1335,9 +1272,7 @@ _cpp_save_parameter (pfile, macro, node) ...@@ -1335,9 +1272,7 @@ _cpp_save_parameter (pfile, macro, node)
/* Check the syntax of the parameters in a MACRO definition. Returns /* Check the syntax of the parameters in a MACRO definition. Returns
false if an error occurs. */ false if an error occurs. */
static bool static bool
parse_params (pfile, macro) parse_params (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
unsigned int prev_ident = 0; unsigned int prev_ident = 0;
...@@ -1416,9 +1351,7 @@ parse_params (pfile, macro) ...@@ -1416,9 +1351,7 @@ parse_params (pfile, macro)
/* Allocate room for a token from a macro's replacement list. */ /* Allocate room for a token from a macro's replacement list. */
static cpp_token * static cpp_token *
alloc_expansion_token (pfile, macro) alloc_expansion_token (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
if (BUFF_ROOM (pfile->a_buff) < (macro->count + 1) * sizeof (cpp_token)) if (BUFF_ROOM (pfile->a_buff) < (macro->count + 1) * sizeof (cpp_token))
_cpp_extend_buff (pfile, &pfile->a_buff, sizeof (cpp_token)); _cpp_extend_buff (pfile, &pfile->a_buff, sizeof (cpp_token));
...@@ -1429,9 +1362,7 @@ alloc_expansion_token (pfile, macro) ...@@ -1429,9 +1362,7 @@ alloc_expansion_token (pfile, macro)
/* Lex a token from the expansion of MACRO, but mark parameters as we /* Lex a token from the expansion of MACRO, but mark parameters as we
find them and warn of traditional stringification. */ find them and warn of traditional stringification. */
static cpp_token * static cpp_token *
lex_expansion_token (pfile, macro) lex_expansion_token (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
cpp_token *token; cpp_token *token;
...@@ -1453,9 +1384,7 @@ lex_expansion_token (pfile, macro) ...@@ -1453,9 +1384,7 @@ lex_expansion_token (pfile, macro)
} }
static bool static bool
create_iso_definition (pfile, macro) create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
cpp_token *token; cpp_token *token;
const cpp_token *ctoken; const cpp_token *ctoken;
...@@ -1524,7 +1453,7 @@ create_iso_definition (pfile, macro) ...@@ -1524,7 +1453,7 @@ create_iso_definition (pfile, macro)
if (macro->count == 0 || token->type == CPP_EOF) if (macro->count == 0 || token->type == CPP_EOF)
{ {
cpp_error (pfile, DL_ERROR, cpp_error (pfile, DL_ERROR,
"'##' cannot appear at either end of a macro expansion"); "'##' cannot appear at either end of a macro expansion");
return false; return false;
} }
...@@ -1551,9 +1480,7 @@ create_iso_definition (pfile, macro) ...@@ -1551,9 +1480,7 @@ create_iso_definition (pfile, macro)
/* Parse a macro and save its expansion. Returns nonzero on success. */ /* Parse a macro and save its expansion. Returns nonzero on success. */
bool bool
_cpp_create_definition (pfile, node) _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
cpp_macro *macro; cpp_macro *macro;
unsigned int i; unsigned int i;
...@@ -1634,10 +1561,8 @@ _cpp_create_definition (pfile, node) ...@@ -1634,10 +1561,8 @@ _cpp_create_definition (pfile, node)
/* Warn if a token in STRING matches one of a function-like MACRO's /* Warn if a token in STRING matches one of a function-like MACRO's
parameters. */ parameters. */
static void static void
check_trad_stringification (pfile, macro, string) check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro,
cpp_reader *pfile; const cpp_string *string)
const cpp_macro *macro;
const cpp_string *string;
{ {
unsigned int i, len; unsigned int i, len;
const uchar *p, *q, *limit; const uchar *p, *q, *limit;
...@@ -1681,9 +1606,7 @@ check_trad_stringification (pfile, macro, string) ...@@ -1681,9 +1606,7 @@ check_trad_stringification (pfile, macro, string)
Caller is expected to generate the "#define" bit if needed. The Caller is expected to generate the "#define" bit if needed. The
returned text is temporary, and automatically freed later. */ returned text is temporary, and automatically freed later. */
const unsigned char * const unsigned char *
cpp_macro_definition (pfile, node) cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node)
cpp_reader *pfile;
const cpp_hashnode *node;
{ {
unsigned int i, len; unsigned int i, len;
const cpp_macro *macro = node->value.macro; const cpp_macro *macro = node->value.macro;
......
...@@ -24,16 +24,16 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -24,16 +24,16 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "hashtab.h" #include "hashtab.h"
#include "mkdeps.h" #include "mkdeps.h"
static int write_macdef PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int write_macdef (cpp_reader *, cpp_hashnode *, void *);
static int save_idents PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int save_idents (cpp_reader *, cpp_hashnode *, void *);
static hashval_t hashmem PARAMS ((const void *, size_t)); static hashval_t hashmem (const void *, size_t);
static hashval_t cpp_string_hash PARAMS ((const void *)); static hashval_t cpp_string_hash (const void *);
static int cpp_string_eq PARAMS ((const void *, const void *)); static int cpp_string_eq (const void *, const void *);
static int count_defs PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int count_defs (cpp_reader *, cpp_hashnode *, void *);
static int comp_hashnodes PARAMS ((const void *, const void *)); static int comp_hashnodes (const void *, const void *);
static int collect_ht_nodes PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int collect_ht_nodes (cpp_reader *, cpp_hashnode *, void *);
static int write_defs PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int write_defs (cpp_reader *, cpp_hashnode *, void *);
static int save_macros PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int save_macros (cpp_reader *, cpp_hashnode *, void *);
/* This structure represents a macro definition on disk. */ /* This structure represents a macro definition on disk. */
struct macrodef_struct struct macrodef_struct
...@@ -47,10 +47,7 @@ struct macrodef_struct ...@@ -47,10 +47,7 @@ struct macrodef_struct
Suitable for being called by cpp_forall_identifiers. */ Suitable for being called by cpp_forall_identifiers. */
static int static int
write_macdef (pfile, hn, file_p) write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
cpp_reader *pfile;
cpp_hashnode *hn;
void *file_p;
{ {
FILE *f = (FILE *) file_p; FILE *f = (FILE *) file_p;
switch (hn->type) switch (hn->type)
...@@ -123,10 +120,7 @@ struct cpp_savedstate ...@@ -123,10 +120,7 @@ struct cpp_savedstate
put the definition in 'definedstrs'. */ put the definition in 'definedstrs'. */
static int static int
save_idents (pfile, hn, ss_p) save_idents (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p)
cpp_reader *pfile ATTRIBUTE_UNUSED;
cpp_hashnode *hn;
void *ss_p;
{ {
struct cpp_savedstate *const ss = (struct cpp_savedstate *)ss_p; struct cpp_savedstate *const ss = (struct cpp_savedstate *)ss_p;
...@@ -158,9 +152,7 @@ save_idents (pfile, hn, ss_p) ...@@ -158,9 +152,7 @@ save_idents (pfile, hn, ss_p)
/* Hash some memory in a generic way. */ /* Hash some memory in a generic way. */
static hashval_t static hashval_t
hashmem (p_p, sz) hashmem (const void *p_p, size_t sz)
const void *p_p;
size_t sz;
{ {
const unsigned char *p = (const unsigned char *)p_p; const unsigned char *p = (const unsigned char *)p_p;
size_t i; size_t i;
...@@ -175,8 +167,7 @@ hashmem (p_p, sz) ...@@ -175,8 +167,7 @@ hashmem (p_p, sz)
/* Hash a cpp string for the hashtable machinery. */ /* Hash a cpp string for the hashtable machinery. */
static hashval_t static hashval_t
cpp_string_hash (a_p) cpp_string_hash (const void *a_p)
const void *a_p;
{ {
const struct cpp_string *a = (const struct cpp_string *) a_p; const struct cpp_string *a = (const struct cpp_string *) a_p;
return hashmem (a->text, a->len); return hashmem (a->text, a->len);
...@@ -185,9 +176,7 @@ cpp_string_hash (a_p) ...@@ -185,9 +176,7 @@ cpp_string_hash (a_p)
/* Compare two cpp strings for the hashtable machinery. */ /* Compare two cpp strings for the hashtable machinery. */
static int static int
cpp_string_eq (a_p, b_p) cpp_string_eq (const void *a_p, const void *b_p)
const void *a_p;
const void *b_p;
{ {
const struct cpp_string *a = (const struct cpp_string *) a_p; const struct cpp_string *a = (const struct cpp_string *) a_p;
const struct cpp_string *b = (const struct cpp_string *) b_p; const struct cpp_string *b = (const struct cpp_string *) b_p;
...@@ -201,9 +190,7 @@ cpp_string_eq (a_p, b_p) ...@@ -201,9 +190,7 @@ cpp_string_eq (a_p, b_p)
would be called when reading the precompiled header back in. */ would be called when reading the precompiled header back in. */
int int
cpp_save_state (r, f) cpp_save_state (cpp_reader *r, FILE *f)
cpp_reader *r;
FILE *f;
{ {
/* Save the list of non-void identifiers for the dependency checking. */ /* Save the list of non-void identifiers for the dependency checking. */
r->savedstate = xmalloc (sizeof (struct cpp_savedstate)); r->savedstate = xmalloc (sizeof (struct cpp_savedstate));
...@@ -220,10 +207,7 @@ cpp_save_state (r, f) ...@@ -220,10 +207,7 @@ cpp_save_state (r, f)
/* Calculate the 'hashsize' field of the saved state. */ /* Calculate the 'hashsize' field of the saved state. */
static int static int
count_defs (pfile, hn, ss_p) count_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p)
cpp_reader *pfile ATTRIBUTE_UNUSED;
cpp_hashnode *hn;
void *ss_p;
{ {
struct cpp_savedstate *const ss = (struct cpp_savedstate *)ss_p; struct cpp_savedstate *const ss = (struct cpp_savedstate *)ss_p;
...@@ -262,10 +246,7 @@ count_defs (pfile, hn, ss_p) ...@@ -262,10 +246,7 @@ count_defs (pfile, hn, ss_p)
/* Collect the identifiers into the state's string table. */ /* Collect the identifiers into the state's string table. */
static int static int
write_defs (pfile, hn, ss_p) write_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p)
cpp_reader *pfile ATTRIBUTE_UNUSED;
cpp_hashnode *hn;
void *ss_p;
{ {
struct cpp_savedstate *const ss = (struct cpp_savedstate *)ss_p; struct cpp_savedstate *const ss = (struct cpp_savedstate *)ss_p;
...@@ -305,9 +286,7 @@ write_defs (pfile, hn, ss_p) ...@@ -305,9 +286,7 @@ write_defs (pfile, hn, ss_p)
/* Comparison function for qsort. The arguments point to pointers of /* Comparison function for qsort. The arguments point to pointers of
type ht_hashnode *. */ type ht_hashnode *. */
static int static int
comp_hashnodes (px, py) comp_hashnodes (const void *px, const void *py)
const void *px;
const void *py;
{ {
cpp_hashnode *x = *(cpp_hashnode **) px; cpp_hashnode *x = *(cpp_hashnode **) px;
cpp_hashnode *y = *(cpp_hashnode **) py; cpp_hashnode *y = *(cpp_hashnode **) py;
...@@ -318,9 +297,7 @@ comp_hashnodes (px, py) ...@@ -318,9 +297,7 @@ comp_hashnodes (px, py)
called after the PCH is ready to be saved. */ called after the PCH is ready to be saved. */
int int
cpp_write_pch_deps (r, f) cpp_write_pch_deps (cpp_reader *r, FILE *f)
cpp_reader *r;
FILE *f;
{ {
struct macrodef_struct z; struct macrodef_struct z;
struct cpp_savedstate *const ss = r->savedstate; struct cpp_savedstate *const ss = r->savedstate;
...@@ -367,9 +344,7 @@ cpp_write_pch_deps (r, f) ...@@ -367,9 +344,7 @@ cpp_write_pch_deps (r, f)
cpp_read_state. */ cpp_read_state. */
int int
cpp_write_pch_state (r, f) cpp_write_pch_state (cpp_reader *r, FILE *f)
cpp_reader *r;
FILE *f;
{ {
struct macrodef_struct z; struct macrodef_struct z;
...@@ -410,10 +385,8 @@ struct ht_node_list ...@@ -410,10 +385,8 @@ struct ht_node_list
/* Callback for collecting identifiers from hash table */ /* Callback for collecting identifiers from hash table */
static int static int
collect_ht_nodes (pfile, hn, nl_p) collect_ht_nodes (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn,
cpp_reader *pfile ATTRIBUTE_UNUSED; void *nl_p)
cpp_hashnode *hn;
void *nl_p;
{ {
struct ht_node_list *const nl = (struct ht_node_list *)nl_p; struct ht_node_list *const nl = (struct ht_node_list *)nl_p;
...@@ -446,10 +419,7 @@ collect_ht_nodes (pfile, hn, nl_p) ...@@ -446,10 +419,7 @@ collect_ht_nodes (pfile, hn, nl_p)
*/ */
int int
cpp_valid_state (r, name, fd) cpp_valid_state (cpp_reader *r, const char *name, int fd)
cpp_reader *r;
const char *name;
int fd;
{ {
struct macrodef_struct m; struct macrodef_struct m;
size_t namebufsz = 256; size_t namebufsz = 256;
...@@ -583,10 +553,7 @@ struct save_macro_data ...@@ -583,10 +553,7 @@ struct save_macro_data
a PCH restore. */ a PCH restore. */
static int static int
save_macros (r, h, data_p) save_macros (cpp_reader *r ATTRIBUTE_UNUSED, cpp_hashnode *h, void *data_p)
cpp_reader *r ATTRIBUTE_UNUSED;
cpp_hashnode *h;
void *data_p;
{ {
struct save_macro_data *data = (struct save_macro_data *)data_p; struct save_macro_data *data = (struct save_macro_data *)data_p;
if (h->type != NT_VOID if (h->type != NT_VOID
...@@ -614,9 +581,7 @@ save_macros (r, h, data_p) ...@@ -614,9 +581,7 @@ save_macros (r, h, data_p)
macros in 'data'. */ macros in 'data'. */
void void
cpp_prepare_state (r, data) cpp_prepare_state (cpp_reader *r, struct save_macro_data **data)
cpp_reader *r;
struct save_macro_data **data;
{ {
struct save_macro_data *d = xmalloc (sizeof (struct save_macro_data)); struct save_macro_data *d = xmalloc (sizeof (struct save_macro_data));
...@@ -632,11 +597,8 @@ cpp_prepare_state (r, data) ...@@ -632,11 +597,8 @@ cpp_prepare_state (r, data)
DEPNAME is passed to deps_restore. */ DEPNAME is passed to deps_restore. */
int int
cpp_read_state (r, name, f, data) cpp_read_state (cpp_reader *r, const char *name, FILE *f,
cpp_reader *r; struct save_macro_data *data)
const char *name;
FILE *f;
struct save_macro_data *data;
{ {
struct macrodef_struct m; struct macrodef_struct m;
size_t defnlen = 256; size_t defnlen = 256;
......
...@@ -51,10 +51,8 @@ static const char *const known_suffixes[] = ...@@ -51,10 +51,8 @@ static const char *const known_suffixes[] =
/* Filter argc and argv before processing by the gcc driver proper. */ /* Filter argc and argv before processing by the gcc driver proper. */
void void
lang_specific_driver (in_argc, in_argv, in_added_libraries) lang_specific_driver (int *in_argc, const char *const **in_argv,
int *in_argc; int *in_added_libraries ATTRIBUTE_UNUSED)
const char *const **in_argv;
int *in_added_libraries ATTRIBUTE_UNUSED;
{ {
int argc = *in_argc; int argc = *in_argc;
const char *const *argv = *in_argv; const char *const *argv = *in_argv;
...@@ -203,7 +201,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) ...@@ -203,7 +201,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
} }
/* Called before linking. Returns 0 on success and -1 on failure. */ /* Called before linking. Returns 0 on success and -1 on failure. */
int lang_specific_pre_link () int lang_specific_pre_link (void)
{ {
return 0; /* Not used for cpp. */ return 0; /* Not used for cpp. */
} }
......
...@@ -81,29 +81,24 @@ enum ls {ls_none = 0, /* Normal state. */ ...@@ -81,29 +81,24 @@ enum ls {ls_none = 0, /* Normal state. */
/* Lexing TODO: Maybe handle space in escaped newlines. Stop cpplex.c /* Lexing TODO: Maybe handle space in escaped newlines. Stop cpplex.c
from recognizing comments and directives during its lexing pass. */ from recognizing comments and directives during its lexing pass. */
static const uchar *skip_whitespace PARAMS ((cpp_reader *, const uchar *, static const uchar *skip_whitespace (cpp_reader *, const uchar *, int);
int)); static cpp_hashnode *lex_identifier (cpp_reader *, const uchar *);
static cpp_hashnode *lex_identifier PARAMS ((cpp_reader *, const uchar *)); static const uchar *copy_comment (cpp_reader *, const uchar *, int);
static const uchar *copy_comment PARAMS ((cpp_reader *, const uchar *, int)); static void check_output_buffer (cpp_reader *, size_t);
static void check_output_buffer PARAMS ((cpp_reader *, size_t)); static void push_replacement_text (cpp_reader *, cpp_hashnode *);
static void push_replacement_text PARAMS ((cpp_reader *, cpp_hashnode *)); static bool scan_parameters (cpp_reader *, cpp_macro *);
static bool scan_parameters PARAMS ((cpp_reader *, cpp_macro *)); static bool recursive_macro (cpp_reader *, cpp_hashnode *);
static bool recursive_macro PARAMS ((cpp_reader *, cpp_hashnode *)); static void save_replacement_text (cpp_reader *, cpp_macro *, unsigned int);
static void save_replacement_text PARAMS ((cpp_reader *, cpp_macro *, static void maybe_start_funlike (cpp_reader *, cpp_hashnode *, const uchar *,
unsigned int)); struct fun_macro *);
static void maybe_start_funlike PARAMS ((cpp_reader *, cpp_hashnode *, static void save_argument (struct fun_macro *, size_t);
const uchar *, struct fun_macro *)); static void replace_args_and_push (cpp_reader *, struct fun_macro *);
static void save_argument PARAMS ((struct fun_macro *, size_t)); static size_t canonicalize_text (uchar *, const uchar *, size_t, uchar *);
static void replace_args_and_push PARAMS ((cpp_reader *, struct fun_macro *));
static size_t canonicalize_text PARAMS ((uchar *, const uchar *, size_t,
uchar *));
/* Ensures we have N bytes' space in the output buffer, and /* Ensures we have N bytes' space in the output buffer, and
reallocates it if not. */ reallocates it if not. */
static void static void
check_output_buffer (pfile, n) check_output_buffer (cpp_reader *pfile, size_t n)
cpp_reader *pfile;
size_t n;
{ {
/* We might need two bytes to terminate an unterminated comment, and /* We might need two bytes to terminate an unterminated comment, and
one more to terminate the line with a NUL. */ one more to terminate the line with a NUL. */
...@@ -134,10 +129,7 @@ check_output_buffer (pfile, n) ...@@ -134,10 +129,7 @@ check_output_buffer (pfile, n)
Returns a pointer to the first character after the comment in the Returns a pointer to the first character after the comment in the
input buffer. */ input buffer. */
static const uchar * static const uchar *
copy_comment (pfile, cur, in_define) copy_comment (cpp_reader *pfile, const uchar *cur, int in_define)
cpp_reader *pfile;
const uchar *cur;
int in_define;
{ {
bool unterminated, copy = false; bool unterminated, copy = false;
unsigned int from_line = pfile->line; unsigned int from_line = pfile->line;
...@@ -197,10 +189,7 @@ copy_comment (pfile, cur, in_define) ...@@ -197,10 +189,7 @@ copy_comment (pfile, cur, in_define)
Returns a pointer to the first character after the whitespace in Returns a pointer to the first character after the whitespace in
the input buffer. */ the input buffer. */
static const uchar * static const uchar *
skip_whitespace (pfile, cur, skip_comments) skip_whitespace (cpp_reader *pfile, const uchar *cur, int skip_comments)
cpp_reader *pfile;
const uchar *cur;
int skip_comments;
{ {
uchar *out = pfile->out.cur; uchar *out = pfile->out.cur;
...@@ -232,9 +221,7 @@ skip_whitespace (pfile, cur, skip_comments) ...@@ -232,9 +221,7 @@ skip_whitespace (pfile, cur, skip_comments)
to point to a valid first character of an identifier. Returns to point to a valid first character of an identifier. Returns
the hashnode, and updates out.cur. */ the hashnode, and updates out.cur. */
static cpp_hashnode * static cpp_hashnode *
lex_identifier (pfile, cur) lex_identifier (cpp_reader *pfile, const uchar *cur)
cpp_reader *pfile;
const uchar *cur;
{ {
size_t len; size_t len;
uchar *out = pfile->out.cur; uchar *out = pfile->out.cur;
...@@ -256,10 +243,7 @@ lex_identifier (pfile, cur) ...@@ -256,10 +243,7 @@ lex_identifier (pfile, cur)
starting at START. The true buffer is restored upon calling starting at START. The true buffer is restored upon calling
restore_buff(). */ restore_buff(). */
void void
_cpp_overlay_buffer (pfile, start, len) _cpp_overlay_buffer (cpp_reader *pfile, const uchar *start, size_t len)
cpp_reader *pfile;
const uchar *start;
size_t len;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
...@@ -276,8 +260,7 @@ _cpp_overlay_buffer (pfile, start, len) ...@@ -276,8 +260,7 @@ _cpp_overlay_buffer (pfile, start, len)
/* Restores a buffer overlaid by _cpp_overlay_buffer(). */ /* Restores a buffer overlaid by _cpp_overlay_buffer(). */
void void
_cpp_remove_overlay (pfile) _cpp_remove_overlay (cpp_reader *pfile)
cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->overlaid_buffer; cpp_buffer *buffer = pfile->overlaid_buffer;
...@@ -292,8 +275,7 @@ _cpp_remove_overlay (pfile) ...@@ -292,8 +275,7 @@ _cpp_remove_overlay (pfile)
/* Reads a logical line into the output buffer. Returns TRUE if there /* Reads a logical line into the output buffer. Returns TRUE if there
is more text left in the buffer. */ is more text left in the buffer. */
bool bool
_cpp_read_logical_line_trad (pfile) _cpp_read_logical_line_trad (cpp_reader *pfile)
cpp_reader *pfile;
{ {
do do
{ {
...@@ -308,11 +290,7 @@ _cpp_read_logical_line_trad (pfile) ...@@ -308,11 +290,7 @@ _cpp_read_logical_line_trad (pfile)
/* Set up state for finding the opening '(' of a function-like /* Set up state for finding the opening '(' of a function-like
macro. */ macro. */
static void static void
maybe_start_funlike (pfile, node, start, macro) maybe_start_funlike (cpp_reader *pfile, cpp_hashnode *node, const uchar *start, struct fun_macro *macro)
cpp_reader *pfile;
cpp_hashnode *node;
const uchar *start;
struct fun_macro *macro;
{ {
unsigned int n = node->value.macro->paramc + 1; unsigned int n = node->value.macro->paramc + 1;
...@@ -327,9 +305,7 @@ maybe_start_funlike (pfile, node, start, macro) ...@@ -327,9 +305,7 @@ maybe_start_funlike (pfile, node, start, macro)
/* Save the OFFSET of the start of the next argument to MACRO. */ /* Save the OFFSET of the start of the next argument to MACRO. */
static void static void
save_argument (macro, offset) save_argument (struct fun_macro *macro, size_t offset)
struct fun_macro *macro;
size_t offset;
{ {
macro->argc++; macro->argc++;
if (macro->argc <= macro->node->value.macro->paramc) if (macro->argc <= macro->node->value.macro->paramc)
...@@ -344,9 +320,7 @@ save_argument (macro, offset) ...@@ -344,9 +320,7 @@ save_argument (macro, offset)
MACRO, and we call save_replacement_text() every time we meet an MACRO, and we call save_replacement_text() every time we meet an
argument. */ argument. */
bool bool
scan_out_logical_line (pfile, macro) scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
bool result = true; bool result = true;
cpp_context *context; cpp_context *context;
...@@ -683,9 +657,7 @@ scan_out_logical_line (pfile, macro) ...@@ -683,9 +657,7 @@ scan_out_logical_line (pfile, macro)
the context stack. NODE is either object-like, or a function-like the context stack. NODE is either object-like, or a function-like
macro with no arguments. */ macro with no arguments. */
static void static void
push_replacement_text (pfile, node) push_replacement_text (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
size_t len; size_t len;
const uchar *text; const uchar *text;
...@@ -713,9 +685,7 @@ push_replacement_text (pfile, node) ...@@ -713,9 +685,7 @@ push_replacement_text (pfile, node)
/* Returns TRUE if traditional macro recursion is detected. */ /* Returns TRUE if traditional macro recursion is detected. */
static bool static bool
recursive_macro (pfile, node) recursive_macro (cpp_reader *pfile, cpp_hashnode *node)
cpp_reader *pfile;
cpp_hashnode *node;
{ {
bool recursing = !!(node->flags & NODE_DISABLED); bool recursing = !!(node->flags & NODE_DISABLED);
...@@ -756,8 +726,7 @@ recursive_macro (pfile, node) ...@@ -756,8 +726,7 @@ recursive_macro (pfile, node)
/* Return the length of the replacement text of a function-like or /* Return the length of the replacement text of a function-like or
object-like non-builtin macro. */ object-like non-builtin macro. */
size_t size_t
_cpp_replacement_text_len (macro) _cpp_replacement_text_len (const cpp_macro *macro)
const cpp_macro *macro;
{ {
size_t len; size_t len;
...@@ -787,9 +756,7 @@ _cpp_replacement_text_len (macro) ...@@ -787,9 +756,7 @@ _cpp_replacement_text_len (macro)
sufficient size. It is not NUL-terminated. The next character is sufficient size. It is not NUL-terminated. The next character is
returned. */ returned. */
uchar * uchar *
_cpp_copy_replacement_text (macro, dest) _cpp_copy_replacement_text (const cpp_macro *macro, uchar *dest)
const cpp_macro *macro;
uchar *dest;
{ {
if (macro->fun_like && (macro->paramc != 0)) if (macro->fun_like && (macro->paramc != 0))
{ {
...@@ -823,9 +790,7 @@ _cpp_copy_replacement_text (macro, dest) ...@@ -823,9 +790,7 @@ _cpp_copy_replacement_text (macro, dest)
the context stack. NODE is either object-like, or a function-like the context stack. NODE is either object-like, or a function-like
macro with no arguments. */ macro with no arguments. */
static void static void
replace_args_and_push (pfile, fmacro) replace_args_and_push (cpp_reader *pfile, struct fun_macro *fmacro)
cpp_reader *pfile;
struct fun_macro *fmacro;
{ {
cpp_macro *macro = fmacro->node->value.macro; cpp_macro *macro = fmacro->node->value.macro;
...@@ -889,9 +854,7 @@ replace_args_and_push (pfile, fmacro) ...@@ -889,9 +854,7 @@ replace_args_and_push (pfile, fmacro)
duplicate parameter). On success, CUR (pfile->context) is just duplicate parameter). On success, CUR (pfile->context) is just
past the closing parenthesis. */ past the closing parenthesis. */
static bool static bool
scan_parameters (pfile, macro) scan_parameters (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
const uchar *cur = CUR (pfile->context) + 1; const uchar *cur = CUR (pfile->context) + 1;
bool ok; bool ok;
...@@ -930,10 +893,8 @@ scan_parameters (pfile, macro) ...@@ -930,10 +893,8 @@ scan_parameters (pfile, macro)
ARG_INDEX, with zero indicating the end of the replacement ARG_INDEX, with zero indicating the end of the replacement
text. */ text. */
static void static void
save_replacement_text (pfile, macro, arg_index) save_replacement_text (cpp_reader *pfile, cpp_macro *macro,
cpp_reader *pfile; unsigned int arg_index)
cpp_macro *macro;
unsigned int arg_index;
{ {
size_t len = pfile->out.cur - pfile->out.base; size_t len = pfile->out.cur - pfile->out.base;
uchar *exp; uchar *exp;
...@@ -981,9 +942,7 @@ save_replacement_text (pfile, macro, arg_index) ...@@ -981,9 +942,7 @@ save_replacement_text (pfile, macro, arg_index)
/* Analyze and save the replacement text of a macro. Returns true on /* Analyze and save the replacement text of a macro. Returns true on
success. */ success. */
bool bool
_cpp_create_trad_definition (pfile, macro) _cpp_create_trad_definition (cpp_reader *pfile, cpp_macro *macro)
cpp_reader *pfile;
cpp_macro *macro;
{ {
const uchar *cur; const uchar *cur;
uchar *limit; uchar *limit;
...@@ -1040,11 +999,7 @@ _cpp_create_trad_definition (pfile, macro) ...@@ -1040,11 +999,7 @@ _cpp_create_trad_definition (pfile, macro)
quote currently in effect is pointed to by PQUOTE, and is updated quote currently in effect is pointed to by PQUOTE, and is updated
by the function. Returns the number of bytes copied. */ by the function. Returns the number of bytes copied. */
static size_t static size_t
canonicalize_text (dest, src, len, pquote) canonicalize_text (uchar *dest, const uchar *src, size_t len, uchar *pquote)
uchar *dest;
const uchar *src;
size_t len;
uchar *pquote;
{ {
uchar *orig_dest = dest; uchar *orig_dest = dest;
uchar quote = *pquote; uchar quote = *pquote;
...@@ -1078,8 +1033,8 @@ canonicalize_text (dest, src, len, pquote) ...@@ -1078,8 +1033,8 @@ canonicalize_text (dest, src, len, pquote)
/* Returns true if MACRO1 and MACRO2 have expansions different other /* Returns true if MACRO1 and MACRO2 have expansions different other
than in the form of their whitespace. */ than in the form of their whitespace. */
bool bool
_cpp_expansions_different_trad (macro1, macro2) _cpp_expansions_different_trad (const cpp_macro *macro1,
const cpp_macro *macro1, *macro2; const cpp_macro *macro2)
{ {
uchar *p1 = xmalloc (macro1->count + macro2->count); uchar *p1 = xmalloc (macro1->count + macro2->count);
uchar *p2 = p1 + macro1->count; uchar *p2 = p1 + macro1->count;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment