Commit e23c0ba3 by Zack Weinberg

[multiple changes]

2000-03-07  Neil Booth  <NeilB@earthling.net>

	* cppexp.c (struct operation, left_shift, right_shift,
	cpp_parse_expr): Change some "char"s to "U_CHAR"s, and some
	"int"s to "unsigned int"s.
	* cpplib.c (detect_if_not_defined, do_assert, do_unassert):
	Similarly.
	* cpplib.h: Update for above.
	* mkdeps.c (deps_init, deps_calc_target): Cast pointers
	returned from allocations.

	* cppinit.c (opt_comp, parse_options): New functions.
	(handle_option): Use parse_option to parse a single command
	line option, that possibly takes an argument.
	(cpp_handle_options): Sort the array of command line options on
	first invocation (non-ASCII hosts only).
	(print_help): Update.

2000-03-07  Zack Weinberg  <zack@wolery.cumb.org>

	* mkdeps.c (munge): Fix off-by-one bug and inconsistencies in
	backslash counting loops.  Problem noted by Matt Kraai <kraai@ghs.com>.

From-SVN: r32394
parent 28c231d6
2000-03-07 Neil Booth <NeilB@earthling.net>
* cppexp.c (struct operation, left_shift, right_shift,
cpp_parse_expr): Change some "char"s to "U_CHAR"s, and some
"int"s to "unsigned int"s.
* cpplib.c (detect_if_not_defined, do_assert, do_unassert):
Similarly.
* cpplib.h: Update for above.
* mkdeps.c (deps_init, deps_calc_target): Cast pointers
returned from allocations.
* cppinit.c (opt_comp, parse_options): New functions.
(handle_option): Use parse_option to parse a single command
line option, that possibly takes an argument.
(cpp_handle_options): Sort the array of command line options on
first invocation (non-ASCII hosts only).
(print_help): Update.
2000-03-07 Zack Weinberg <zack@wolery.cumb.org> 2000-03-07 Zack Weinberg <zack@wolery.cumb.org>
* mkdeps.c (munge): Fix off-by-one bug and inconsistencies in
backslash counting loops. Problem noted by Matt Kraai <kraai@ghs.com>.
* cppfiles.c (_cpp_find_include_file): Make sure ih->name is * cppfiles.c (_cpp_find_include_file): Make sure ih->name is
initialized. initialized.
* cppinit.c (cpp_cleanup): Free imp->nshort also. * cppinit.c (cpp_cleanup): Free imp->nshort also.
......
...@@ -78,9 +78,11 @@ Written by Per Bothner 1994. */ ...@@ -78,9 +78,11 @@ Written by Per Bothner 1994. */
static void integer_overflow PARAMS ((cpp_reader *)); static void integer_overflow PARAMS ((cpp_reader *));
static HOST_WIDEST_INT left_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT, static HOST_WIDEST_INT left_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT,
int, unsigned HOST_WIDEST_INT)); unsigned int,
unsigned HOST_WIDEST_INT));
static HOST_WIDEST_INT right_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT, static HOST_WIDEST_INT right_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT,
int, unsigned HOST_WIDEST_INT)); unsigned int,
unsigned HOST_WIDEST_INT));
static struct operation parse_number PARAMS ((cpp_reader *, U_CHAR *, static struct operation parse_number PARAMS ((cpp_reader *, U_CHAR *,
U_CHAR *)); U_CHAR *));
static struct operation parse_charconst PARAMS ((cpp_reader *, U_CHAR *, static struct operation parse_charconst PARAMS ((cpp_reader *, U_CHAR *,
...@@ -110,14 +112,13 @@ static struct operation lex PARAMS ((cpp_reader *, int)); ...@@ -110,14 +112,13 @@ static struct operation lex PARAMS ((cpp_reader *, int));
/* SKIP_OPERAND is set for '&&' '||' '?' and ':' when the /* SKIP_OPERAND is set for '&&' '||' '?' and ':' when the
following operand should be short-circuited instead of evaluated. */ following operand should be short-circuited instead of evaluated. */
#define SKIP_OPERAND 8 #define SKIP_OPERAND 8
/*#define UNSIGNEDP 16*/
struct operation struct operation
{ {
short op; short op;
char rprio; /* Priority of op (relative to it right operand). */ U_CHAR rprio; /* Priority of op (relative to it right operand). */
char flags; U_CHAR flags;
char unsignedp; /* true if value should be treated as unsigned */ U_CHAR unsignedp; /* true if value should be treated as unsigned */
HOST_WIDEST_INT value; /* The value logically "right" of op. */ HOST_WIDEST_INT value; /* The value logically "right" of op. */
}; };
...@@ -610,7 +611,7 @@ static HOST_WIDEST_INT ...@@ -610,7 +611,7 @@ static HOST_WIDEST_INT
left_shift (pfile, a, unsignedp, b) left_shift (pfile, a, unsignedp, b)
cpp_reader *pfile; cpp_reader *pfile;
HOST_WIDEST_INT a; HOST_WIDEST_INT a;
int unsignedp; unsigned int unsignedp;
unsigned HOST_WIDEST_INT b; unsigned HOST_WIDEST_INT b;
{ {
if (b >= HOST_BITS_PER_WIDEST_INT) if (b >= HOST_BITS_PER_WIDEST_INT)
...@@ -634,7 +635,7 @@ static HOST_WIDEST_INT ...@@ -634,7 +635,7 @@ static HOST_WIDEST_INT
right_shift (pfile, a, unsignedp, b) right_shift (pfile, a, unsignedp, b)
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_reader *pfile ATTRIBUTE_UNUSED;
HOST_WIDEST_INT a; HOST_WIDEST_INT a;
int unsignedp; unsigned int unsignedp;
unsigned HOST_WIDEST_INT b; unsigned HOST_WIDEST_INT b;
{ {
if (b >= HOST_BITS_PER_WIDEST_INT) if (b >= HOST_BITS_PER_WIDEST_INT)
...@@ -689,7 +690,7 @@ _cpp_parse_expr (pfile) ...@@ -689,7 +690,7 @@ _cpp_parse_expr (pfile)
struct operation *stack = init_stack; struct operation *stack = init_stack;
struct operation *limit = stack + INIT_STACK_SIZE; struct operation *limit = stack + INIT_STACK_SIZE;
register struct operation *top = stack; register struct operation *top = stack;
int lprio, rprio = 0; unsigned int lprio, rprio = 0;
int skip_evaluation = 0; int skip_evaluation = 0;
top->rprio = 0; top->rprio = 0;
...@@ -697,7 +698,7 @@ _cpp_parse_expr (pfile) ...@@ -697,7 +698,7 @@ _cpp_parse_expr (pfile)
for (;;) for (;;)
{ {
struct operation op; struct operation op;
char flags = 0; U_CHAR flags = 0;
/* Read a token */ /* Read a token */
op = lex (pfile, skip_evaluation); op = lex (pfile, skip_evaluation);
...@@ -780,7 +781,8 @@ _cpp_parse_expr (pfile) ...@@ -780,7 +781,8 @@ _cpp_parse_expr (pfile)
while (top->rprio > lprio) while (top->rprio > lprio)
{ {
HOST_WIDEST_INT v1 = top[-1].value, v2 = top[0].value; HOST_WIDEST_INT v1 = top[-1].value, v2 = top[0].value;
int unsigned1 = top[-1].unsignedp, unsigned2 = top[0].unsignedp; unsigned int unsigned1 = top[-1].unsignedp;
unsigned int unsigned2 = top[0].unsignedp;
top--; top--;
if ((top[1].flags & LEFT_OPERAND_REQUIRED) if ((top[1].flags & LEFT_OPERAND_REQUIRED)
&& ! (top[0].flags & HAVE_VALUE)) && ! (top[0].flags & HAVE_VALUE))
......
...@@ -183,6 +183,10 @@ static void initialize_dependency_output PARAMS ((cpp_reader *)); ...@@ -183,6 +183,10 @@ static void initialize_dependency_output PARAMS ((cpp_reader *));
static void initialize_standard_includes PARAMS ((cpp_reader *)); static void initialize_standard_includes PARAMS ((cpp_reader *));
static void new_pending_define PARAMS ((struct cpp_options *, static void new_pending_define PARAMS ((struct cpp_options *,
const char *)); const char *));
#ifdef HOST_EBCDIC
static int opt_comp PARAMS ((const void *, const void *));
#endif
static int parse_option PARAMS ((const char *));
static int handle_option PARAMS ((cpp_reader *, int, char **)); static int handle_option PARAMS ((cpp_reader *, int, char **));
/* Fourth argument to append_include_chain: chain to use */ /* Fourth argument to append_include_chain: chain to use */
...@@ -900,6 +904,185 @@ new_pending_define (opts, text) ...@@ -900,6 +904,185 @@ new_pending_define (opts, text)
APPEND (opts->pending, define, o); APPEND (opts->pending, define, o);
} }
enum opt_code
{
OPT_stdin_stdout = 0, OPT_dollar, OPT_plus,
OPT__help, OPT__version,
OPT_A, OPT_C, OPT_D, OPT_H, OPT_I, OPT_M,
OPT_MD, OPT_MG, OPT_MM, OPT_MMD,
OPT_P, OPT_U, OPT_W,
OPT_d,
OPT_fleading_underscore, OPT_fno_leading_underscore,
OPT_fpreprocessed, OPT_fno_preprocessed,
OPT_g, OPT_h,
OPT_idirafter, OPT_imacros, OPT_include,
OPT_iprefix, OPT_isystem, OPT_iwithprefix, OPT_iwithprefixbefore,
OPT_lang_asm, OPT_lang_c, OPT_lang_cplusplus, OPT_lang_c89,
OPT_lang_chill, OPT_lang_fortran, OPT_lang_objc, OPT_lang_objcplusplus,
OPT_nostdinc, OPT_nostdincplusplus,
OPT_o,
OPT_pedantic, OPT_pedantic_errors, OPT_remap,
OPT_std_c89, OPT_std_c99, OPT_std_c9x, OPT_std_gnu89, OPT_std_gnu99,
OPT_std_gnu9x, OPT_std_iso9899_1990, OPT_std_iso9899_199409,
OPT_std_iso9899_1999, OPT_std_iso9899_199x,
OPT_traditional, OPT_trigraphs,
OPT_v, OPT_w,
N_OPTS
};
struct cl_option
{
const char *opt_text;
const char *msg;
size_t opt_len;
enum opt_code opt_code;
};
static const char no_arg[] = N_("Argument missing after `%s' option");
static const char no_ass[] = N_("Assertion missing after `%s' option");
static const char no_dir[] = N_("Directory name missing after `%s' option");
static const char no_fil[] = N_("File name missing after `%s' option");
static const char no_mac[] = N_("Macro name missing after `%s' option");
static const char no_pth[] = N_("Path name missing after `%s' option");
/* This list must be ASCII sorted. Make enum order above match this. */
#define DEF_OPT(text, msg, code) {text, msg, sizeof(text) - 1, code}
#ifdef HOST_EBCDIC
static struct cl_option cl_options[] =
#else
static const struct cl_option cl_options[] =
#endif
{
DEF_OPT("", 0, OPT_stdin_stdout),
DEF_OPT("$", 0, OPT_dollar),
DEF_OPT("+", 0, OPT_plus),
DEF_OPT("-help", 0, OPT__help),
DEF_OPT("-version", 0, OPT__version),
DEF_OPT("A", no_ass, OPT_A),
DEF_OPT("C", 0, OPT_C),
DEF_OPT("D", no_mac, OPT_D),
DEF_OPT("H", 0, OPT_H),
DEF_OPT("I", no_dir, OPT_I),
DEF_OPT("M", 0, OPT_M),
DEF_OPT("MD", no_fil, OPT_MD),
DEF_OPT("MG", 0, OPT_MG),
DEF_OPT("MM", 0, OPT_MM),
DEF_OPT("MMD", no_fil, OPT_MMD),
DEF_OPT("P", 0, OPT_P),
DEF_OPT("U", no_mac, OPT_U),
/* NB: Immed arg only, and not reqd */
DEF_OPT("W", no_arg, OPT_W),
DEF_OPT("d", no_arg, OPT_d),
DEF_OPT("fleading-underscore", 0, OPT_fleading_underscore),
DEF_OPT("fno-leading-underscore", 0, OPT_fno_leading_underscore),
DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed),
DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed),
/* NB: Immed arg only, and not reqd */
DEF_OPT("g", no_arg, OPT_g),
DEF_OPT("h", 0, OPT_h),
DEF_OPT("idirafter", no_dir, OPT_idirafter),
DEF_OPT("imacros", no_fil, OPT_imacros),
DEF_OPT("include", no_fil, OPT_include),
DEF_OPT("iprefix", no_pth, OPT_iprefix),
DEF_OPT("isystem", no_dir, OPT_isystem),
DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix),
DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore),
DEF_OPT("lang-asm", 0, OPT_lang_asm),
DEF_OPT("lang-c", 0, OPT_lang_c),
DEF_OPT("lang-c++", 0, OPT_lang_cplusplus),
DEF_OPT("lang-c89", 0, OPT_lang_c89),
DEF_OPT("lang-chill", 0, OPT_lang_chill),
DEF_OPT("lang-fortran", 0, OPT_lang_fortran),
DEF_OPT("lang-objc", 0, OPT_lang_objc),
DEF_OPT("lang-objc++", 0, OPT_lang_objcplusplus),
DEF_OPT("nostdinc", 0, OPT_nostdinc),
DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus),
DEF_OPT("o", no_fil, OPT_o),
DEF_OPT("pedantic", 0, OPT_pedantic),
DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors),
DEF_OPT("remap", 0, OPT_remap),
DEF_OPT("std=c89", 0, OPT_std_c89),
DEF_OPT("std=c99", 0, OPT_std_c99),
DEF_OPT("std=c9x", 0, OPT_std_c9x),
DEF_OPT("std=gnu89", 0, OPT_std_gnu89),
DEF_OPT("std=gnu99", 0, OPT_std_gnu99),
DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x),
DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990),
DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409),
DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999),
DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x),
DEF_OPT("traditional", 0, OPT_traditional),
DEF_OPT("trigraphs", 0, OPT_trigraphs),
DEF_OPT("v", 0, OPT_v),
DEF_OPT("w", 0, OPT_w)
};
#undef DEF_OPT
/* Perform a binary search to find which, if any, option the given
command-line matches. Returns its index in the option array,
negative on failure. Complications arise since some options can be
suffixed with an argument, and multiple complete matches can occur,
e.g. -iwithprefix and -iwithprefixbefore. Moreover, we want to
accept options beginning with -g and -W that we do not recognise,
but not to swallow any subsequent command line argument; these are
handled as special cases in cpp_handle_option */
static int
parse_option (input)
const char *input;
{
unsigned int md, mn, mx;
size_t opt_len;
int comp;
mn = 0;
mx = N_OPTS;
while (mx > mn)
{
md = (mn + mx) / 2;
opt_len = cl_options[md].opt_len;
comp = strncmp (input, cl_options[md].opt_text, opt_len);
if (comp > 0)
mn = md + 1;
else if (comp < 0)
mx = md;
else
{
if (input[opt_len] == '\0')
return md;
/* We were passed more text. If the option takes an argument,
we may match a later option or we may have been passed the
argument. The longest possible option match succeeds.
If the option takes no arguments we have not matched and
continue the search (e.g. input="stdc++" match was "stdc") */
mn = md + 1;
if (cl_options[md].msg)
{
/* Scan forwards. If we get an exact match, return it.
Otherwise, return the longest option-accepting match.
This loops no more than twice with current options */
mx = md;
for (; mn < N_OPTS; mn++)
{
opt_len = cl_options[mn].opt_len;
if (strncmp (input, cl_options[mn].opt_text, opt_len))
break;
if (input[opt_len] == '\0')
return mn;
if (cl_options[mn].msg)
mx = mn;
}
return mx;
}
}
}
return -1;
}
/* Handle one command-line option in (argc, argv). /* Handle one command-line option in (argc, argv).
Can be called multiple times, to handle multiple sets of options. Can be called multiple times, to handle multiple sets of options.
Returns number of strings consumed. */ Returns number of strings consumed. */
...@@ -926,374 +1109,213 @@ handle_option (pfile, argc, argv) ...@@ -926,374 +1109,213 @@ handle_option (pfile, argc, argv)
opts->in_fname = argv[i]; opts->in_fname = argv[i];
} }
else else
switch (argv[i][1]) {
{ enum opt_code opt_code;
case 'f': int opt_index;
if (!strcmp (argv[i], "-fleading-underscore")) char *arg = 0;
/* Skip over '-' */
opt_index = parse_option (&argv[i][1]);
if (opt_index < 0)
return i;
opt_code = cl_options[opt_index].opt_code;
if (cl_options[opt_index].msg)
{
arg = &argv[i][cl_options[opt_index].opt_len + 1];
/* Yuk. Special case for -g and -W as they must not swallow
up any following argument. If this becomes common, add
another field to the cl_options table */
if (arg[0] == '\0' && !(opt_code == OPT_g || opt_code == OPT_W))
{
arg = argv[++i];
if (!arg)
{
cpp_fatal (pfile, _(cl_options[opt_index].msg), argv[i - 1]);
return argc;
}
}
}
switch (opt_code)
{
case N_OPTS: /* shut GCC up */
break;
case OPT_fleading_underscore:
user_label_prefix = "_"; user_label_prefix = "_";
else if (!strcmp (argv[i], "-fno-leading-underscore")) break;
case OPT_fno_leading_underscore:
user_label_prefix = ""; user_label_prefix = "";
else if (!strcmp (argv[i], "-fpreprocessed")) break;
case OPT_fpreprocessed:
opts->preprocessed = 1; opts->preprocessed = 1;
else if (!strcmp (argv[i], "-fno-preprocessed")) break;
case OPT_fno_preprocessed:
opts->preprocessed = 0; opts->preprocessed = 0;
else break;
{ case OPT_w:
return i; opts->inhibit_warnings = 1;
} break;
break; case OPT_g: /* Silently ignore anything but -g3 */
if (!strcmp(&argv[i][2], "3"))
case 'I': /* Add directory to path for includes. */ opts->debug_output = 1;
if (!strcmp (argv[i] + 2, "-")) break;
{ case OPT_h:
/* -I- means: case OPT__help:
Use the preceding -I directories for #include "..." print_help ();
but not #include <...>. exit (0); /* XXX */
Don't search the directory of the present file break;
for #include "...". (Note that -I. -I- is not the same as case OPT__version:
the default setup; -I. uses the compiler's working dir.) */ fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
if (! opts->ignore_srcdir) exit (0); /* XXX */
{ break;
opts->ignore_srcdir = 1; case OPT_C:
opts->pending->quote_head = opts->pending->brack_head; opts->discard_comments = 0;
opts->pending->quote_tail = opts->pending->brack_tail; break;
opts->pending->brack_head = 0; case OPT_P:
opts->pending->brack_tail = 0; opts->no_line_commands = 1;
} break;
else case OPT_dollar: /* Don't include $ in identifiers. */
{ opts->dollars_in_ident = 0;
cpp_fatal (pfile, "-I- specified twice"); break;
return argc; case OPT_H:
} opts->print_include_names = 1;
} break;
else case OPT_D:
{ new_pending_define (opts, arg);
char *fname; break;
if (argv[i][2] != 0) case OPT_pedantic_errors:
fname = argv[i] + 2; opts->pedantic_errors = 1;
else if (i + 1 == argc) /* fall through */
goto missing_dirname; case OPT_pedantic:
else opts->pedantic = 1;
fname = argv[++i]; break;
append_include_chain (pfile, opts->pending, case OPT_traditional:
xstrdup (fname), BRACKET, 0); opts->traditional = 1;
} opts->cplusplus_comments = 0;
break; opts->trigraphs = 0;
case 'i':
/* Add directory to beginning of system include path, as a system
include directory. */
if (!strcmp (argv[i], "-isystem"))
{
if (i + 1 == argc)
goto missing_filename;
append_include_chain (pfile, opts->pending,
xstrdup (argv[++i]), SYSTEM, 0);
}
else if (!strcmp (argv[i], "-include"))
{
if (i + 1 == argc)
goto missing_filename;
else
{
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option));
o->arg = argv[++i];
/* This list has to be built in reverse order so that
when cpp_start_read pushes all the -include files onto
the buffer stack, they will be scanned in forward order. */
o->next = opts->pending->include_head;
opts->pending->include_head = o;
}
}
else if (!strcmp (argv[i], "-imacros"))
{
if (i + 1 == argc)
goto missing_filename;
else
{
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option));
o->arg = argv[++i];
o->next = NULL;
APPEND (opts->pending, imacros, o);
}
}
/* Add directory to end of path for includes,
with the default prefix at the front of its name. */
else if (!strcmp (argv[i], "-iwithprefix"))
{
char *fname;
int len;
if (i + 1 == argc)
goto missing_dirname;
++i;
len = strlen (argv[i]);
if (opts->include_prefix != 0)
{
fname = xmalloc (opts->include_prefix_len + len + 1);
memcpy (fname, opts->include_prefix, opts->include_prefix_len);
memcpy (fname + opts->include_prefix_len, argv[i], len + 1);
}
else
{
fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, argv[i], len + 1);
}
append_include_chain (pfile, opts->pending, fname, SYSTEM, 0);
}
/* Add directory to main path for includes,
with the default prefix at the front of its name. */
else if (!strcmp (argv[i], "-iwithprefixbefore"))
{
char *fname;
int len;
if (i + 1 == argc)
goto missing_dirname;
++i;
len = strlen (argv[i]);
if (opts->include_prefix != 0)
{
fname = xmalloc (opts->include_prefix_len + len + 1);
memcpy (fname, opts->include_prefix, opts->include_prefix_len);
memcpy (fname + opts->include_prefix_len, argv[i], len + 1);
}
else
{
fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, argv[i], len + 1);
}
append_include_chain (pfile, opts->pending, fname, BRACKET, 0);
}
/* Add directory to end of path for includes. */
else if (!strcmp (argv[i], "-idirafter"))
{
if (i + 1 == argc)
goto missing_dirname;
append_include_chain (pfile, opts->pending,
xstrdup (argv[++i]), AFTER, 0);
}
else if (!strcmp (argv[i], "-iprefix"))
{
if (i + 1 == argc)
goto missing_filename;
else
{
opts->include_prefix = argv[++i];
opts->include_prefix_len = strlen (argv[i]);
}
}
break;
case 'o':
if (opts->out_fname != NULL)
{
cpp_fatal (pfile, "Output filename specified twice");
return argc;
}
if (i + 1 == argc)
goto missing_filename;
opts->out_fname = argv[++i];
if (!strcmp (opts->out_fname, "-"))
opts->out_fname = "";
break;
case 'p':
if (!strcmp (argv[i], "-pedantic"))
opts->pedantic = 1;
else if (!strcmp (argv[i], "-pedantic-errors"))
{
opts->pedantic = 1;
opts->pedantic_errors = 1;
}
break;
case 't':
if (!strcmp (argv[i], "-traditional"))
{
opts->traditional = 1;
opts->cplusplus_comments = 0;
opts->trigraphs = 0;
opts->warn_trigraphs = 0;
}
else if (!strcmp (argv[i], "-trigraphs"))
opts->trigraphs = 1;
break;
case 'l':
if (! strcmp (argv[i], "-lang-c"))
opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
opts->c99 = 1, opts->objc = 0;
if (! strcmp (argv[i], "-lang-c89"))
{
opts->cplusplus = 0, opts->cplusplus_comments = 0;
opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
opts->trigraphs = 1;
new_pending_define (opts, "__STRICT_ANSI__");
}
if (! strcmp (argv[i], "-lang-c++"))
opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0,
opts->c99 = 0, opts->objc = 0;
if (! strcmp (argv[i], "-lang-objc"))
opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
opts->c99 = 0, opts->objc = 1;
if (! strcmp (argv[i], "-lang-objc++"))
opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0,
opts->c99 = 0, opts->objc = 1;
if (! strcmp (argv[i], "-lang-asm"))
opts->lang_asm = 1;
if (! strcmp (argv[i], "-lang-fortran"))
opts->lang_fortran = 1, opts->cplusplus_comments = 0;
if (! strcmp (argv[i], "-lang-chill"))
opts->objc = 0, opts->cplusplus = 0, opts->chill = 1,
opts->traditional = 1;
break;
case '+':
opts->cplusplus = 1, opts->cplusplus_comments = 1;
break;
case 's':
if (!strcmp (argv[i], "-std=gnu89"))
{
opts->cplusplus = 0, opts->cplusplus_comments = 1;
opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
}
else if (!strcmp (argv[i], "-std=gnu9x")
|| !strcmp (argv[i], "-std=gnu99"))
{
opts->cplusplus = 0, opts->cplusplus_comments = 1;
opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
new_pending_define (opts, "__STDC_VERSION__=199901L");
}
else if (!strcmp (argv[i], "-std=iso9899:1990")
|| !strcmp (argv[i], "-std=c89"))
{
opts->cplusplus = 0, opts->cplusplus_comments = 0;
opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
opts->trigraphs = 1;
new_pending_define (opts, "__STRICT_ANSI__");
}
else if (!strcmp (argv[i], "-std=iso9899:199409"))
{
opts->cplusplus = 0, opts->cplusplus_comments = 0;
opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
opts->trigraphs = 1;
new_pending_define (opts, "__STRICT_ANSI__");
new_pending_define (opts, "__STDC_VERSION__=199409L");
}
else if (!strcmp (argv[i], "-std=iso9899:199x")
|| !strcmp (argv[i], "-std=iso9899:1999")
|| !strcmp (argv[i], "-std=c9x")
|| !strcmp (argv[i], "-std=c99"))
{
opts->cplusplus = 0, opts->cplusplus_comments = 1;
opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
opts->trigraphs = 1;
new_pending_define (opts, "__STRICT_ANSI__");
new_pending_define (opts, "__STDC_VERSION__=199901L");
}
break;
case 'w':
opts->inhibit_warnings = 1;
break;
case 'W':
if (!strcmp (argv[i], "-Wtrigraphs"))
opts->warn_trigraphs = 1;
else if (!strcmp (argv[i], "-Wno-trigraphs"))
opts->warn_trigraphs = 0; opts->warn_trigraphs = 0;
else if (!strcmp (argv[i], "-Wcomment")) break;
opts->warn_comments = 1; case OPT_trigraphs:
else if (!strcmp (argv[i], "-Wno-comment")) opts->trigraphs = 1;
opts->warn_comments = 0; break;
else if (!strcmp (argv[i], "-Wcomments")) case OPT_plus:
opts->warn_comments = 1; opts->cplusplus = 1;
else if (!strcmp (argv[i], "-Wno-comments")) opts->cplusplus_comments = 1;
opts->warn_comments = 0; break;
else if (!strcmp (argv[i], "-Wtraditional")) case OPT_remap:
opts->warn_stringify = 1; opts->remap = 1;
else if (!strcmp (argv[i], "-Wno-traditional")) break;
opts->warn_stringify = 0; case OPT_iprefix:
else if (!strcmp (argv[i], "-Wundef")) opts->include_prefix = arg;
opts->warn_undef = 1; opts->include_prefix_len = strlen (arg);
else if (!strcmp (argv[i], "-Wno-undef")) break;
opts->warn_undef = 0; case OPT_lang_c:
else if (!strcmp (argv[i], "-Wimport")) opts->cplusplus = 0, opts->cplusplus_comments = 1;
opts->warn_import = 1; opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
else if (!strcmp (argv[i], "-Wno-import")) break;
opts->warn_import = 0; case OPT_lang_c89:
else if (!strcmp (argv[i], "-Werror")) opts->cplusplus = 0, opts->cplusplus_comments = 0;
opts->warnings_are_errors = 1; opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
else if (!strcmp (argv[i], "-Wno-error")) opts->trigraphs = 1;
opts->warnings_are_errors = 0; new_pending_define (opts, "__STRICT_ANSI__");
else if (!strcmp (argv[i], "-Wall")) break;
{ case OPT_lang_cplusplus:
opts->warn_trigraphs = 1; opts->cplusplus = 1, opts->cplusplus_comments = 1;
opts->warn_comments = 1; opts->c89 = 0, opts->c99 = 0, opts->objc = 0;
} break;
break; case OPT_lang_objc:
case OPT_lang_objcplusplus:
case 'M': opts->cplusplus = opt_code == OPT_lang_objcplusplus;
/* The style of the choices here is a bit mixed. opts->cplusplus_comments = 1;
The chosen scheme is a hybrid of keeping all options in one string opts->c89 = 0, opts->c99 = 0, opts->objc = 1;
and specifying each option in a separate argument: break;
-M|-MM|-MD file|-MMD file [-MG]. An alternative is: case OPT_lang_asm:
-M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely: opts->lang_asm = 1;
-M[M][G][D file]. This is awkward to handle in specs, and is not break;
as extensible. */ case OPT_lang_fortran:
/* ??? -MG must be specified in addition to one of -M or -MM. opts->lang_fortran = 1, opts->cplusplus_comments = 0;
This can be relaxed in the future without breaking anything. break;
The converse isn't true. */ case OPT_lang_chill:
opts->objc = 0, opts->cplusplus = 0;
/* -MG isn't valid with -MD or -MMD. This is checked for later. */ opts->chill = 1, opts->traditional = 1;
if (!strcmp (argv[i], "-MG")) break;
{ case OPT_nostdinc:
opts->print_deps_missing_files = 1; /* -nostdinc causes no default include directories.
break; You must specify all include-file directories with -I. */
} opts->no_standard_includes = 1;
if (!strcmp (argv[i], "-M")) break;
opts->print_deps = 2; case OPT_nostdincplusplus:
else if (!strcmp (argv[i], "-MM")) /* -nostdinc++ causes no default C++-specific include directories. */
opts->print_deps = 1; opts->no_standard_cplusplus_includes = 1;
else if (!strcmp (argv[i], "-MD")) break;
opts->print_deps = 2; case OPT_std_gnu89:
else if (!strcmp (argv[i], "-MMD")) opts->cplusplus = 0, opts->cplusplus_comments = 1;
opts->print_deps = 1; opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
/* For -MD and -MMD options, write deps on file named by next arg. */ break;
if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD")) case OPT_std_gnu9x:
{ case OPT_std_gnu99:
if (i+1 == argc) opts->cplusplus = 0, opts->cplusplus_comments = 1;
goto missing_filename; opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
opts->deps_file = argv[++i]; new_pending_define (opts, "__STDC_VERSION__=199901L");
} break;
else case OPT_std_iso9899_199409:
{ new_pending_define (opts, "__STDC_VERSION__=199409L");
/* For -M and -MM, write deps on standard output /* Fall through */
and suppress the usual output. */ case OPT_std_iso9899_1990:
opts->no_output = 1; case OPT_std_c89:
} opts->cplusplus = 0, opts->cplusplus_comments = 0;
break; opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
opts->trigraphs = 1;
case 'd': new_pending_define (opts, "__STRICT_ANSI__");
{ break;
char *p = argv[i] + 2; case OPT_std_iso9899_199x:
char c; case OPT_std_iso9899_1999:
while ((c = *p++) != 0) case OPT_std_c9x:
case OPT_std_c99:
opts->cplusplus = 0, opts->cplusplus_comments = 1;
opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
opts->trigraphs = 1;
new_pending_define (opts, "__STRICT_ANSI__");
new_pending_define (opts, "__STDC_VERSION__=199901L");
break;
case OPT_o:
if (opts->out_fname != NULL)
{ {
/* Arg to -d specifies what parts of macros to dump */ cpp_fatal (pfile, "Output filename specified twice");
switch (c) return argc;
{ }
case 'M': opts->out_fname = arg;
if (!strcmp (opts->out_fname, "-"))
opts->out_fname = "";
break;
case OPT_v:
fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
#ifdef TARGET_VERSION
TARGET_VERSION;
#endif
fputc ('\n', stderr);
opts->verbose = 1;
break;
case OPT_stdin_stdout:
/* JF handle '-' as file name meaning stdin or stdout */
if (opts->in_fname == NULL)
opts->in_fname = "";
else if (opts->out_fname == NULL)
opts->out_fname = "";
break;
case OPT_d:
/* Args to -d specify what parts of macros to dump.
Silently ignore unrecognised options; they may
be aimed at the compiler proper. */
{
char c;
while ((c = *arg++) != '\0')
switch (c)
{
case 'M':
opts->dump_macros = dump_only; opts->dump_macros = dump_only;
opts->no_output = 1; opts->no_output = 1;
break; break;
...@@ -1307,75 +1329,50 @@ handle_option (pfile, argc, argv) ...@@ -1307,75 +1329,50 @@ handle_option (pfile, argc, argv)
opts->dump_includes = 1; opts->dump_includes = 1;
break; break;
} }
} }
} break;
break; /* The style of the choices here is a bit mixed.
The chosen scheme is a hybrid of keeping all options in one string
case 'g': and specifying each option in a separate argument:
if (argv[i][2] == '3') -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
opts->debug_output = 1; -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
break; -M[M][G][D file]. This is awkward to handle in specs, and is not
as extensible. */
case '-': /* ??? -MG must be specified in addition to one of -M or -MM.
if (!strcmp (argv[i], "--help")) This can be relaxed in the future without breaking anything.
print_help (); The converse isn't true. */
else if (!strcmp (argv[i], "--version"))
fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string); /* -MG isn't valid with -MD or -MMD. This is checked for later. */
exit (0); /* XXX */ case OPT_MG:
break; opts->print_deps_missing_files = 1;
break;
case 'v': case OPT_M:
fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string); case OPT_MD:
#ifdef TARGET_VERSION case OPT_MM:
TARGET_VERSION; case OPT_MMD:
#endif if (opt_code == OPT_M || opt_code == OPT_MD)
fputc ('\n', stderr); opts->print_deps = 2;
opts->verbose = 1; else
break; opts->print_deps = 1;
case 'H': /* For -MD and -MMD options, write deps on file named by next arg */
opts->print_include_names = 1; /* For -M and -MM, write deps on standard output
break; and suppress the usual output. */
if (opt_code == OPT_MD || opt_code == OPT_MMD)
case 'D': opts->deps_file = arg;
{ else
const char *text; opts->no_output = 1;
if (argv[i][2] != 0) break;
text = argv[i] + 2; case OPT_A:
else if (i + 1 == argc) if (strcmp (arg, "-"))
{ {
cpp_fatal (pfile, "Macro name missing after -D option"); struct pending_option *o = (struct pending_option *)
return argc; xmalloc (sizeof (struct pending_option));
}
else o->arg = arg;
text = argv[++i]; o->next = NULL;
new_pending_define (opts, text); o->undef = 0;
} APPEND (opts->pending, assert, o);
break;
case 'A':
{
char *p;
if (argv[i][2] != 0)
p = argv[i] + 2;
else if (i + 1 == argc)
{
cpp_fatal (pfile, "Assertion missing after -A option");
return argc;
}
else
p = argv[++i];
if (strcmp (p, "-"))
{
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option));
o->arg = p;
o->next = NULL;
o->undef = 0;
APPEND (opts->pending, assert, o);
} }
else else
{ {
...@@ -1404,88 +1401,163 @@ handle_option (pfile, argc, argv) ...@@ -1404,88 +1401,163 @@ handle_option (pfile, argc, argv)
opts->pending->define_head = NULL; opts->pending->define_head = NULL;
opts->pending->define_tail = NULL; opts->pending->define_tail = NULL;
} }
} break;
break; case OPT_U:
{
case 'U': struct pending_option *o = (struct pending_option *)
{ xmalloc (sizeof (struct pending_option));
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option)); o->arg = arg;
o->next = NULL;
if (argv[i][2] != 0) o->undef = 1;
o->arg = argv[i] + 2; APPEND (opts->pending, define, o);
else if (i + 1 == argc) }
break;
case OPT_I: /* Add directory to path for includes. */
if (!strcmp (arg, "-"))
{
/* -I- means:
Use the preceding -I directories for #include "..."
but not #include <...>.
Don't search the directory of the present file
for #include "...". (Note that -I. -I- is not the same as
the default setup; -I. uses the compiler's working dir.) */
if (! opts->ignore_srcdir)
{
opts->ignore_srcdir = 1;
opts->pending->quote_head = opts->pending->brack_head;
opts->pending->quote_tail = opts->pending->brack_tail;
opts->pending->brack_head = 0;
opts->pending->brack_tail = 0;
}
else
{
cpp_fatal (pfile, "-I- specified twice");
return argc;
}
}
else
append_include_chain (pfile, opts->pending,
xstrdup (arg), BRACKET, 0);
break;
case OPT_isystem:
/* Add directory to beginning of system include path, as a system
include directory. */
append_include_chain (pfile, opts->pending,
xstrdup (arg), SYSTEM, 0);
break;
case OPT_include:
{
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option));
o->arg = arg;
/* This list has to be built in reverse order so that
when cpp_start_read pushes all the -include files onto
the buffer stack, they will be scanned in forward order. */
o->next = opts->pending->include_head;
opts->pending->include_head = o;
}
break;
case OPT_imacros:
{
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option));
o->arg = arg;
o->next = NULL;
APPEND (opts->pending, imacros, o);
}
break;
case OPT_iwithprefix:
/* Add directory to end of path for includes,
with the default prefix at the front of its name. */
/* fall through */
case OPT_iwithprefixbefore:
/* Add directory to main path for includes,
with the default prefix at the front of its name. */
{
char *fname;
int len;
len = strlen (arg);
if (opts->include_prefix != 0)
{
fname = xmalloc (opts->include_prefix_len + len + 1);
memcpy (fname, opts->include_prefix, opts->include_prefix_len);
memcpy (fname + opts->include_prefix_len, arg, len + 1);
}
else
{
fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, arg, len + 1);
}
append_include_chain (pfile, opts->pending, fname,
opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
}
break;
case OPT_idirafter:
/* Add directory to end of path for includes. */
append_include_chain (pfile, opts->pending,
xstrdup (arg), AFTER, 0);
break;
case OPT_W:
/* Silently ignore unrecognised options */
if (!strcmp (argv[i], "-Wall"))
{ {
cpp_fatal (pfile, "Macro name missing after -U option"); opts->warn_trigraphs = 1;
return argc; opts->warn_comments = 1;
} }
else else if (!strcmp (argv[i], "-Wtraditional"))
o->arg = argv[++i]; opts->warn_stringify = 1;
else if (!strcmp (argv[i], "-Wtrigraphs"))
o->next = NULL; opts->warn_trigraphs = 1;
o->undef = 1; else if (!strcmp (argv[i], "-Wcomment"))
APPEND (opts->pending, define, o); opts->warn_comments = 1;
} else if (!strcmp (argv[i], "-Wcomments"))
break; opts->warn_comments = 1;
else if (!strcmp (argv[i], "-Wundef"))
case 'C': opts->warn_undef = 1;
opts->discard_comments = 0; else if (!strcmp (argv[i], "-Wimport"))
break; opts->warn_import = 1;
else if (!strcmp (argv[i], "-Werror"))
case 'E': /* -E comes from cc -E; ignore it. */ opts->warnings_are_errors = 1;
break; else if (!strcmp (argv[i], "-Wno-traditional"))
opts->warn_stringify = 0;
case 'P': else if (!strcmp (argv[i], "-Wno-trigraphs"))
opts->no_line_commands = 1; opts->warn_trigraphs = 0;
break; else if (!strcmp (argv[i], "-Wno-comment"))
opts->warn_comments = 0;
case '$': /* Don't include $ in identifiers. */ else if (!strcmp (argv[i], "-Wno-comments"))
opts->dollars_in_ident = 0; opts->warn_comments = 0;
break; else if (!strcmp (argv[i], "-Wno-undef"))
opts->warn_undef = 0;
case 'n': else if (!strcmp (argv[i], "-Wno-import"))
if (!strcmp (argv[i], "-nostdinc")) opts->warn_import = 0;
/* -nostdinc causes no default include directories. else if (!strcmp (argv[i], "-Wno-error"))
You must specify all include-file directories with -I. */ opts->warnings_are_errors = 0;
opts->no_standard_includes = 1; break;
else if (!strcmp (argv[i], "-nostdinc++")) }
/* -nostdinc++ causes no default C++-specific include directories. */ }
opts->no_standard_cplusplus_includes = 1;
break;
case 'r':
if (!strcmp (argv[i], "-remap"))
opts->remap = 1;
break;
case '\0': /* JF handle '-' as file name meaning stdin or stdout */
if (opts->in_fname == NULL)
opts->in_fname = "";
else if (opts->out_fname == NULL)
opts->out_fname = "";
else
return i; /* error */
break;
default:
return i;
}
return i + 1; return i + 1;
}
missing_filename: #ifdef HOST_EBCDIC
cpp_fatal (pfile, "Filename missing after `%s' option", argv[i]); static int
return argc; opt_comp (const void *p1, const void *p2)
missing_dirname: {
cpp_fatal (pfile, "Directory name missing after `%s' option", argv[i]); return strcmp (((struct cl_option *)p1)->opt_text,
return argc; ((struct cl_option *)p2)->opt_text);
} }
#endif
/* Handle command-line options in (argc, argv). /* Handle command-line options in (argc, argv).
Can be called multiple times, to handle multiple sets of options. Can be called multiple times, to handle multiple sets of options.
Returns if an unrecognized option is seen. Returns if an unrecognized option is seen.
Returns number of strings consumed. */ Returns number of strings consumed. */
int int
cpp_handle_options (pfile, argc, argv) cpp_handle_options (pfile, argc, argv)
cpp_reader *pfile; cpp_reader *pfile;
...@@ -1494,6 +1566,18 @@ cpp_handle_options (pfile, argc, argv) ...@@ -1494,6 +1566,18 @@ cpp_handle_options (pfile, argc, argv)
{ {
int i; int i;
int strings_processed; int strings_processed;
#ifdef HOST_EBCDIC
static int opts_sorted = 0;
if (!opts_sorted)
{
opts_sorted = 1;
/* For non-ASCII hosts, the array needs to be sorted at runtime */
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
}
#endif
for (i = 0; i < argc; i += strings_processed) for (i = 0; i < argc; i += strings_processed)
{ {
strings_processed = handle_option (pfile, argc - i, argv + i); strings_processed = handle_option (pfile, argc - i, argv + i);
...@@ -1517,11 +1601,13 @@ Switches:\n\ ...@@ -1517,11 +1601,13 @@ Switches:\n\
-isystem <dir> Add <dir> to the start of the system include path\n\ -isystem <dir> Add <dir> to the start of the system include path\n\
-idirafter <dir> Add <dir> to the end of the system include path\n\ -idirafter <dir> Add <dir> to the end of the system include path\n\
-I <dir> Add <dir> to the end of the main include path\n\ -I <dir> Add <dir> to the end of the main include path\n\
-I- Fine-grained include path control; see info docs\n\
-nostdinc Do not search system include directories\n\ -nostdinc Do not search system include directories\n\
(dirs specified with -isystem will still be used)\n\ (dirs specified with -isystem will still be used)\n\
-nostdinc++ Do not search system include directories for C++\n\ -nostdinc++ Do not search system include directories for C++\n\
-o <file> Put output into <file>\n\ -o <file> Put output into <file>\n\
-pedantic Issue all warnings demanded by strict ANSI C\n\ -pedantic Issue all warnings demanded by strict ANSI C\n\
-pedantic-errors Issue -pedantic warnings as errors instead\n\
-traditional Follow K&R pre-processor behaviour\n\ -traditional Follow K&R pre-processor behaviour\n\
-trigraphs Support ANSI C trigraphs\n\ -trigraphs Support ANSI C trigraphs\n\
-lang-c Assume that the input sources are in C\n\ -lang-c Assume that the input sources are in C\n\
...@@ -1556,7 +1642,7 @@ Switches:\n\ ...@@ -1556,7 +1642,7 @@ Switches:\n\
-MD As -M, but put output in a .d file\n\ -MD As -M, but put output in a .d file\n\
-MMD As -MD, but ignore system header files\n\ -MMD As -MD, but ignore system header files\n\
-MG Treat missing header file as generated files\n\ -MG Treat missing header file as generated files\n\
-g Include #define and #undef directives in the output\n\ -g3 Include #define and #undef directives in the output\n\
-D<macro> Define a <macro> with string '1' as its value\n\ -D<macro> Define a <macro> with string '1' as its value\n\
-D<macro>=<val> Define a <macro> with <val> as its value\n\ -D<macro>=<val> Define a <macro> with <val> as its value\n\
-A<question> (<answer>) Assert the <answer> to <question>\n\ -A<question> (<answer>) Assert the <answer> to <question>\n\
...@@ -1571,6 +1657,7 @@ Switches:\n\ ...@@ -1571,6 +1657,7 @@ Switches:\n\
-P Do not generate #line directives\n\ -P Do not generate #line directives\n\
-$ Do not allow '$' in identifiers\n\ -$ Do not allow '$' in identifiers\n\
-remap Remap file names when including files.\n\ -remap Remap file names when including files.\n\
--version Display version information\n\
-h or --help Display this information\n\ -h or --help Display this information\n\
"), stdout); "), stdout);
} }
...@@ -1809,7 +1809,7 @@ detect_if_not_defined (pfile) ...@@ -1809,7 +1809,7 @@ detect_if_not_defined (pfile)
if (pfile->only_seen_white == 2) if (pfile->only_seen_white == 2)
{ {
char *ident; U_CHAR *ident;
enum cpp_token token; enum cpp_token token;
int base_offset; int base_offset;
int token_offset; int token_offset;
...@@ -2270,7 +2270,7 @@ do_endif (pfile, keyword) ...@@ -2270,7 +2270,7 @@ do_endif (pfile, keyword)
for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip)) for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip))
if (ip->fname != NULL) if (ip->fname != NULL)
break; break;
ip->ihash->control_macro = (char *) temp->control_macro; ip->ihash->control_macro = temp->control_macro;
} }
} }
free (temp); free (temp);
...@@ -3051,7 +3051,7 @@ do_assert (pfile, keyword) ...@@ -3051,7 +3051,7 @@ do_assert (pfile, keyword)
cpp_reader *pfile; cpp_reader *pfile;
const struct directive *keyword ATTRIBUTE_UNUSED; const struct directive *keyword ATTRIBUTE_UNUSED;
{ {
char *sym; U_CHAR *sym;
int ret, c; int ret, c;
HASHNODE *base, *this; HASHNODE *base, *this;
int baselen, thislen; int baselen, thislen;
...@@ -3060,7 +3060,7 @@ do_assert (pfile, keyword) ...@@ -3060,7 +3060,7 @@ do_assert (pfile, keyword)
cpp_pedwarn (pfile, "ANSI C does not allow `#assert'"); cpp_pedwarn (pfile, "ANSI C does not allow `#assert'");
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
sym = (char *) CPP_PWRITTEN (pfile); /* remember where it starts */ sym = CPP_PWRITTEN (pfile); /* remember where it starts */
ret = parse_assertion (pfile); ret = parse_assertion (pfile);
if (ret == 0) if (ret == 0)
goto error; goto error;
...@@ -3079,7 +3079,7 @@ do_assert (pfile, keyword) ...@@ -3079,7 +3079,7 @@ do_assert (pfile, keyword)
} }
thislen = strlen (sym); thislen = strlen (sym);
baselen = index (sym, '(') - sym; baselen = (U_CHAR *) index (sym, '(') - sym;
this = _cpp_lookup (pfile, sym, thislen); this = _cpp_lookup (pfile, sym, thislen);
if (this) if (this)
{ {
...@@ -3101,12 +3101,12 @@ do_assert (pfile, keyword) ...@@ -3101,12 +3101,12 @@ do_assert (pfile, keyword)
(char *)base->value.aschain); (char *)base->value.aschain);
base->value.aschain = this; base->value.aschain = this;
pfile->limit = (unsigned char *) sym; /* Pop */ pfile->limit = sym; /* Pop */
return 0; return 0;
error: error:
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
pfile->limit = (unsigned char *) sym; /* Pop */ pfile->limit = sym; /* Pop */
return 0; return 0;
} }
...@@ -3116,7 +3116,7 @@ do_unassert (pfile, keyword) ...@@ -3116,7 +3116,7 @@ do_unassert (pfile, keyword)
const struct directive *keyword ATTRIBUTE_UNUSED; const struct directive *keyword ATTRIBUTE_UNUSED;
{ {
int c, ret; int c, ret;
char *sym; U_CHAR *sym;
long baselen, thislen; long baselen, thislen;
HASHNODE *base, *this, *next; HASHNODE *base, *this, *next;
...@@ -3125,7 +3125,7 @@ do_unassert (pfile, keyword) ...@@ -3125,7 +3125,7 @@ do_unassert (pfile, keyword)
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
sym = (char *) CPP_PWRITTEN (pfile); /* remember where it starts */ sym = CPP_PWRITTEN (pfile); /* remember where it starts */
ret = parse_assertion (pfile); ret = parse_assertion (pfile);
if (ret == 0) if (ret == 0)
goto error; goto error;
...@@ -3153,7 +3153,7 @@ do_unassert (pfile, keyword) ...@@ -3153,7 +3153,7 @@ do_unassert (pfile, keyword)
} }
else else
{ {
baselen = index (sym, '(') - sym; baselen = (U_CHAR *) index (sym, '(') - sym;
base = _cpp_lookup (pfile, sym, baselen); base = _cpp_lookup (pfile, sym, baselen);
if (! base) goto error; if (! base) goto error;
this = _cpp_lookup (pfile, sym, thislen); this = _cpp_lookup (pfile, sym, thislen);
...@@ -3170,11 +3170,11 @@ do_unassert (pfile, keyword) ...@@ -3170,11 +3170,11 @@ do_unassert (pfile, keyword)
_cpp_delete_macro (base); /* Last answer for this predicate deleted. */ _cpp_delete_macro (base); /* Last answer for this predicate deleted. */
} }
pfile->limit = (unsigned char *) sym; /* Pop */ pfile->limit = sym; /* Pop */
return 0; return 0;
error: error:
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
pfile->limit = (unsigned char *) sym; /* Pop */ pfile->limit = sym; /* Pop */
return 0; return 0;
} }
......
...@@ -540,7 +540,7 @@ struct include_hash ...@@ -540,7 +540,7 @@ struct include_hash
struct file_name_list *foundhere; struct file_name_list *foundhere;
const char *name; /* (partial) pathname of file */ const char *name; /* (partial) pathname of file */
const char *nshort; /* name of file as referenced in #include */ const char *nshort; /* name of file as referenced in #include */
const char *control_macro; /* macro, if any, preventing reinclusion - const U_CHAR *control_macro; /* macro, if any, preventing reinclusion -
see redundant_include_p */ see redundant_include_p */
char *buf, *limit; /* for file content cache, char *buf, *limit; /* for file content cache,
not yet implemented */ not yet implemented */
...@@ -629,14 +629,14 @@ struct if_stack { ...@@ -629,14 +629,14 @@ struct if_stack {
int lineno; /* similarly */ int lineno; /* similarly */
int if_succeeded; /* true if a leg of this if-group int if_succeeded; /* true if a leg of this if-group
has been passed through rescan */ has been passed through rescan */
unsigned char *control_macro; /* For #ifndef at start of file, U_CHAR *control_macro; /* For #ifndef at start of file,
this is the macro name tested. */ this is the macro name tested. */
enum node_type type; /* type of last directive seen in this group */ enum node_type type; /* type of last directive seen in this group */
}; };
typedef struct if_stack IF_STACK_FRAME; typedef struct if_stack IF_STACK_FRAME;
extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *)); extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *));
extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader *)); extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
extern void cpp_define PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_define PARAMS ((cpp_reader *, unsigned char *));
extern void cpp_assert PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_assert PARAMS ((cpp_reader *, unsigned char *));
extern void cpp_undef PARAMS ((cpp_reader *, unsigned char *)); extern void cpp_undef PARAMS ((cpp_reader *, unsigned char *));
......
...@@ -58,7 +58,7 @@ munge (filename) ...@@ -58,7 +58,7 @@ munge (filename)
preceded by 2N backslashes represents N backslashes at preceded by 2N backslashes represents N backslashes at
the end of a file name; and backslashes in other the end of a file name; and backslashes in other
contexts should not be doubled. */ contexts should not be doubled. */
for (q = p - 1; q < filename && q[-1] == '\\'; q--) for (q = p - 1; filename <= q && *q == '\\'; q--)
len++; len++;
len++; len++;
break; break;
...@@ -80,7 +80,7 @@ munge (filename) ...@@ -80,7 +80,7 @@ munge (filename)
{ {
case ' ': case ' ':
case '\t': case '\t':
for (q = p - 1; filename < q && q[-1] == '\\'; q--) for (q = p - 1; filename <= q && *q == '\\'; q--)
*dst++ = '\\'; *dst++ = '\\';
*dst++ = '\\'; *dst++ = '\\';
break; break;
...@@ -135,8 +135,8 @@ deps_init () ...@@ -135,8 +135,8 @@ deps_init ()
/* Allocate space for the vectors now. */ /* Allocate space for the vectors now. */
d->targetv = xmalloc (2 * sizeof (const char *)); d->targetv = (const char **) xmalloc (2 * sizeof (const char *));
d->depv = xmalloc (8 * sizeof (const char *)); d->depv = (const char **) xmalloc (8 * sizeof (const char *));
d->ntargets = 0; d->ntargets = 0;
d->targets_size = 2; d->targets_size = 2;
...@@ -188,7 +188,7 @@ deps_calc_target (d, t) ...@@ -188,7 +188,7 @@ deps_calc_target (d, t)
char *o, *suffix; char *o, *suffix;
t = base_name (t); t = base_name (t);
o = alloca (strlen (t) + 8); o = (char *) alloca (strlen (t) + 8);
strcpy (o, t); strcpy (o, t);
suffix = strrchr (o, '.'); suffix = strrchr (o, '.');
......
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