PATCH: cast argument to isdigit/isalnum
Alex Samuel
samuel@codesourcery.com
Mon Jun 5 11:23:00 GMT 2000
This patch adds missing casts in arguments to isdigit and isalnum that
could cause sign extension problems on systems with signed chars.
Committing on approval by Mark Mitchell.
* cp-demangle.c (demangle_prefix): Cast argument to isdigit to
unsigned char.
(demangle_unqualified_name): Likewise.
(demangle_number_literally): Likewise.
(demangle_type): Likewise.
(demangle_substitution): Likewise.
(is_mangled_char): Likewise, for isalnum.
Index: cp-demangle.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/cp-demangle.c,v
retrieving revision 1.1
diff -c -p -r1.1 cp-demangle.c
*** cp-demangle.c 2000/06/05 02:28:41 1.1
--- cp-demangle.c 2000/06/05 18:17:41
*************** demangle_prefix (dm, template_p)
*** 1042,1048 ****
peek = peek_char (dm);
! if (isdigit (peek)
|| (peek >= 'a' && peek <= 'z')
|| peek == 'C' || peek == 'D'
|| peek == 'S')
--- 1042,1048 ----
peek = peek_char (dm);
! if (isdigit ((unsigned char) peek)
|| (peek >= 'a' && peek <= 'z')
|| peek == 'C' || peek == 'D'
|| peek == 'S')
*************** demangle_unqualified_name (dm)
*** 1103,1109 ****
DEMANGLE_TRACE ("unqualified-name", dm);
! if (isdigit (peek))
RETURN_IF_ERROR (demangle_source_name (dm));
else if (peek >= 'a' && peek <= 'z')
{
--- 1103,1109 ----
DEMANGLE_TRACE ("unqualified-name", dm);
! if (isdigit ((unsigned char) peek))
RETURN_IF_ERROR (demangle_source_name (dm));
else if (peek >= 'a' && peek <= 'z')
{
*************** demangle_number_literally (dm, str, base
*** 1207,1213 ****
while (1)
{
char peek = peek_char (dm);
! if (isdigit (peek)
|| (base == 36 && peek >= 'A' && peek <= 'Z'))
/* Accumulate digits. */
dyn_string_append_char (str, next_char (dm));
--- 1207,1213 ----
while (1)
{
char peek = peek_char (dm);
! if (isdigit ((unsigned char) peek)
|| (base == 36 && peek >= 'A' && peek <= 'Z'))
/* Accumulate digits. */
dyn_string_append_char (str, next_char (dm));
*************** demangle_type (dm)
*** 1792,1798 ****
/* A <class-enum-type> can start with a digit (a <source-name>), an
N (a <nested-name>), or a Z (a <local-name>). */
! if (isdigit (peek) || peek == 'N' || peek == 'Z')
RETURN_IF_ERROR (demangle_class_enum_type (dm, &template_p));
else if (peek >= 'a' && peek <= 'z')
{
--- 1792,1798 ----
/* A <class-enum-type> can start with a digit (a <source-name>), an
N (a <nested-name>), or a Z (a <local-name>). */
! if (isdigit ((unsigned char) peek) || peek == 'N' || peek == 'Z')
RETURN_IF_ERROR (demangle_class_enum_type (dm, &template_p));
else if (peek >= 'a' && peek <= 'z')
{
*************** demangle_substitution (dm, template_p, s
*** 2555,2561 ****
/* If the following character is 0-9 or a capital letter, interpret
the sequence up to the next underscore as a base-36 substitution
index. */
! else if (isdigit (peek)
|| (peek >= 'A' && peek <= 'Z'))
RETURN_IF_ERROR (demangle_number (dm, &seq_id, 36, 0));
else
--- 2555,2561 ----
/* If the following character is 0-9 or a capital letter, interpret
the sequence up to the next underscore as a base-36 substitution
index. */
! else if (isdigit ((unsigned char) peek)
|| (peek >= 'A' && peek <= 'Z'))
RETURN_IF_ERROR (demangle_number (dm, &seq_id, 36, 0));
else
*************** demangle_discriminator (dm, suppress_fir
*** 2710,2716 ****
if (flag_verbose)
result_append (dm, " [#");
/* Check if there's a number following the underscore. */
! if (isdigit (peek_char (dm)))
{
int discriminator;
/* Demangle the number. */
--- 2710,2716 ----
if (flag_verbose)
result_append (dm, " [#");
/* Check if there's a number following the underscore. */
! if (isdigit ((unsigned char) peek_char (dm)))
{
int discriminator;
/* Demangle the number. */
*************** static void print_usage
*** 2821,2827 ****
PARAMS ((FILE* fp, int exit_value));
/* Non-zero if CHAR is a character than can occur in a mangled name. */
! #define is_mangled_char(CHAR) (isalnum (CHAR) || (CHAR) == '_')
/* The name of this program, as invoked. */
const char* program_name;
--- 2821,2828 ----
PARAMS ((FILE* fp, int exit_value));
/* Non-zero if CHAR is a character than can occur in a mangled name. */
! #define is_mangled_char(CHAR) \
! (isalnum ((unsigned char) (CHAR)) || (CHAR) == '_')
/* The name of this program, as invoked. */
const char* program_name;
More information about the Gcc-patches
mailing list