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>
* 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
initialized.
* cppinit.c (cpp_cleanup): Free imp->nshort also.
......
......@@ -78,9 +78,11 @@ Written by Per Bothner 1994. */
static void integer_overflow PARAMS ((cpp_reader *));
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,
int, unsigned HOST_WIDEST_INT));
unsigned int,
unsigned HOST_WIDEST_INT));
static struct operation parse_number PARAMS ((cpp_reader *, U_CHAR *,
U_CHAR *));
static struct operation parse_charconst PARAMS ((cpp_reader *, U_CHAR *,
......@@ -110,14 +112,13 @@ static struct operation lex PARAMS ((cpp_reader *, int));
/* SKIP_OPERAND is set for '&&' '||' '?' and ':' when the
following operand should be short-circuited instead of evaluated. */
#define SKIP_OPERAND 8
/*#define UNSIGNEDP 16*/
struct operation
{
short op;
char rprio; /* Priority of op (relative to it right operand). */
char flags;
char unsignedp; /* true if value should be treated as unsigned */
U_CHAR rprio; /* Priority of op (relative to it right operand). */
U_CHAR flags;
U_CHAR unsignedp; /* true if value should be treated as unsigned */
HOST_WIDEST_INT value; /* The value logically "right" of op. */
};
......@@ -610,7 +611,7 @@ static HOST_WIDEST_INT
left_shift (pfile, a, unsignedp, b)
cpp_reader *pfile;
HOST_WIDEST_INT a;
int unsignedp;
unsigned int unsignedp;
unsigned HOST_WIDEST_INT b;
{
if (b >= HOST_BITS_PER_WIDEST_INT)
......@@ -634,7 +635,7 @@ static HOST_WIDEST_INT
right_shift (pfile, a, unsignedp, b)
cpp_reader *pfile ATTRIBUTE_UNUSED;
HOST_WIDEST_INT a;
int unsignedp;
unsigned int unsignedp;
unsigned HOST_WIDEST_INT b;
{
if (b >= HOST_BITS_PER_WIDEST_INT)
......@@ -689,7 +690,7 @@ _cpp_parse_expr (pfile)
struct operation *stack = init_stack;
struct operation *limit = stack + INIT_STACK_SIZE;
register struct operation *top = stack;
int lprio, rprio = 0;
unsigned int lprio, rprio = 0;
int skip_evaluation = 0;
top->rprio = 0;
......@@ -697,7 +698,7 @@ _cpp_parse_expr (pfile)
for (;;)
{
struct operation op;
char flags = 0;
U_CHAR flags = 0;
/* Read a token */
op = lex (pfile, skip_evaluation);
......@@ -780,7 +781,8 @@ _cpp_parse_expr (pfile)
while (top->rprio > lprio)
{
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--;
if ((top[1].flags & LEFT_OPERAND_REQUIRED)
&& ! (top[0].flags & HAVE_VALUE))
......
......@@ -1809,7 +1809,7 @@ detect_if_not_defined (pfile)
if (pfile->only_seen_white == 2)
{
char *ident;
U_CHAR *ident;
enum cpp_token token;
int base_offset;
int token_offset;
......@@ -2270,7 +2270,7 @@ do_endif (pfile, keyword)
for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip))
if (ip->fname != NULL)
break;
ip->ihash->control_macro = (char *) temp->control_macro;
ip->ihash->control_macro = temp->control_macro;
}
}
free (temp);
......@@ -3051,7 +3051,7 @@ do_assert (pfile, keyword)
cpp_reader *pfile;
const struct directive *keyword ATTRIBUTE_UNUSED;
{
char *sym;
U_CHAR *sym;
int ret, c;
HASHNODE *base, *this;
int baselen, thislen;
......@@ -3060,7 +3060,7 @@ do_assert (pfile, keyword)
cpp_pedwarn (pfile, "ANSI C does not allow `#assert'");
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);
if (ret == 0)
goto error;
......@@ -3079,7 +3079,7 @@ do_assert (pfile, keyword)
}
thislen = strlen (sym);
baselen = index (sym, '(') - sym;
baselen = (U_CHAR *) index (sym, '(') - sym;
this = _cpp_lookup (pfile, sym, thislen);
if (this)
{
......@@ -3101,12 +3101,12 @@ do_assert (pfile, keyword)
(char *)base->value.aschain);
base->value.aschain = this;
pfile->limit = (unsigned char *) sym; /* Pop */
pfile->limit = sym; /* Pop */
return 0;
error:
skip_rest_of_line (pfile);
pfile->limit = (unsigned char *) sym; /* Pop */
pfile->limit = sym; /* Pop */
return 0;
}
......@@ -3116,7 +3116,7 @@ do_unassert (pfile, keyword)
const struct directive *keyword ATTRIBUTE_UNUSED;
{
int c, ret;
char *sym;
U_CHAR *sym;
long baselen, thislen;
HASHNODE *base, *this, *next;
......@@ -3125,7 +3125,7 @@ do_unassert (pfile, keyword)
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);
if (ret == 0)
goto error;
......@@ -3153,7 +3153,7 @@ do_unassert (pfile, keyword)
}
else
{
baselen = index (sym, '(') - sym;
baselen = (U_CHAR *) index (sym, '(') - sym;
base = _cpp_lookup (pfile, sym, baselen);
if (! base) goto error;
this = _cpp_lookup (pfile, sym, thislen);
......@@ -3170,11 +3170,11 @@ do_unassert (pfile, keyword)
_cpp_delete_macro (base); /* Last answer for this predicate deleted. */
}
pfile->limit = (unsigned char *) sym; /* Pop */
pfile->limit = sym; /* Pop */
return 0;
error:
skip_rest_of_line (pfile);
pfile->limit = (unsigned char *) sym; /* Pop */
pfile->limit = sym; /* Pop */
return 0;
}
......
......@@ -540,7 +540,7 @@ struct include_hash
struct file_name_list *foundhere;
const char *name; /* (partial) pathname of file */
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 */
char *buf, *limit; /* for file content cache,
not yet implemented */
......@@ -629,14 +629,14 @@ struct if_stack {
int lineno; /* similarly */
int if_succeeded; /* true if a leg of this if-group
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. */
enum node_type type; /* type of last directive seen in this group */
};
typedef struct if_stack IF_STACK_FRAME;
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_assert PARAMS ((cpp_reader *, unsigned char *));
extern void cpp_undef PARAMS ((cpp_reader *, unsigned char *));
......
......@@ -58,7 +58,7 @@ munge (filename)
preceded by 2N backslashes represents N backslashes at
the end of a file name; and backslashes in other
contexts should not be doubled. */
for (q = p - 1; q < filename && q[-1] == '\\'; q--)
for (q = p - 1; filename <= q && *q == '\\'; q--)
len++;
len++;
break;
......@@ -80,7 +80,7 @@ munge (filename)
{
case ' ':
case '\t':
for (q = p - 1; filename < q && q[-1] == '\\'; q--)
for (q = p - 1; filename <= q && *q == '\\'; q--)
*dst++ = '\\';
*dst++ = '\\';
break;
......@@ -135,8 +135,8 @@ deps_init ()
/* Allocate space for the vectors now. */
d->targetv = xmalloc (2 * sizeof (const char *));
d->depv = xmalloc (8 * sizeof (const char *));
d->targetv = (const char **) xmalloc (2 * sizeof (const char *));
d->depv = (const char **) xmalloc (8 * sizeof (const char *));
d->ntargets = 0;
d->targets_size = 2;
......@@ -188,7 +188,7 @@ deps_calc_target (d, t)
char *o, *suffix;
t = base_name (t);
o = alloca (strlen (t) + 8);
o = (char *) alloca (strlen (t) + 8);
strcpy (o, t);
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