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))
......
...@@ -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