aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog42
-rw-r--r--gcc/cccp.c4
-rw-r--r--gcc/cexp.c4
-rw-r--r--gcc/cexp.y4
-rw-r--r--gcc/ch/ChangeLog5
-rw-r--r--gcc/ch/lex.c12
-rw-r--r--gcc/config/c4x/c4x.c8
-rw-r--r--gcc/config/i370/i370.c4
-rw-r--r--gcc/config/i370/i370.h4
-rw-r--r--gcc/config/v850/v850.c8
-rw-r--r--gcc/doprint.c4
-rw-r--r--gcc/f/ChangeLog12
-rw-r--r--gcc/f/bad.c2
-rw-r--r--gcc/f/fini.c4
-rw-r--r--gcc/f/intrin.c2
-rw-r--r--gcc/f/lex.c7
-rw-r--r--gcc/f/src.c14
-rw-r--r--gcc/fixinc/fixincl.c11
-rw-r--r--gcc/fixinc/server.c2
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/genattr.c13
-rw-r--r--gcc/genattrtab.c19
-rw-r--r--gcc/genemit.c7
-rw-r--r--gcc/genopinit.c8
-rw-r--r--gcc/genpeep.c7
-rw-r--r--gcc/genrecog.c7
-rw-r--r--gcc/optabs.c2
-rw-r--r--gcc/system.h55
28 files changed, 168 insertions, 105 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 716ea42..3b9615e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,45 @@
+Thu Sep 16 18:06:35 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * system.h (CTYPE_CONV, TOUPPER, TOLOWER): New macros. Use
+ CTYPE_CONV in all ctype macros.
+
+ * cccp.c (initialize_char_syntax): Use uppercase ctype macro
+ from system.h.
+
+ * cexp.y (initialize_random_junk): Likewise.
+
+ * c4x.c (c4x_interrupt_function_p, c4x_handle_pragma): Likewise.
+
+ * i370.c (handle_pragma): Likewise.
+
+ * i370.h (ASM_OUTPUT_LABELREF, ASM_OUTPUT_ASCII): Likewise.
+
+ * v850.c (override_options): Likewise.
+
+ * doprint.c (_doprnt): Likewise.
+
+ * fixinc/fixincl.c (main, quoted_file_exists, extract_quoted_files):
+ Likewise.
+
+ * fixinc/server.c (load_data): Likewise.
+
+ * fold-const.c (real_hex_to_f): Likewise.
+
+ * genattr.c (write_upcase, gen_attr): Likewise.
+
+ * genattrtab.c (convert_const_symbol_ref, evaluate_eq_attr,
+ write_upcase): Likewise.
+
+ * genemit.c (print_code): Likewise.
+
+ * genopinit.c (gen_insn): Likewise.
+
+ * genpeep.c (print_code): Likewise.
+
+ * genrecog.c (print_code): Likewise.
+
+ * optabs.c (init_libfuncs): Likewise.
+
Thu Sep 16 14:03:32 1999 Mark Mitchell <mark@codesourcery.com>
* haifa-sched.c (sched_analyze): Keep the list of notes organized
diff --git a/gcc/cccp.c b/gcc/cccp.c
index 16def7a..4a90648 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -10131,9 +10131,9 @@ initialize_char_syntax ()
* refer to them.
*/
for (i = 'a'; i <= 'z'; i++) {
- is_idchar[toupper(i)] = 1;
+ is_idchar[TOUPPER(i)] = 1;
is_idchar[i] = 1;
- is_idstart[toupper(i)] = 1;
+ is_idstart[TOUPPER(i)] = 1;
is_idstart[i] = 1;
}
for (i = '0'; i <= '9'; i++)
diff --git a/gcc/cexp.c b/gcc/cexp.c
index 82fcc79..fc4d7fc 100644
--- a/gcc/cexp.c
+++ b/gcc/cexp.c
@@ -2029,9 +2029,9 @@ initialize_random_junk ()
* refer to them.
*/
for (i = 'a'; i <= 'z'; i++) {
- ++is_idchar[toupper(i)];
+ ++is_idchar[TOUPPER(i)];
++is_idchar[i];
- ++is_idstart[toupper(i)];
+ ++is_idstart[TOUPPER(i)];
++is_idstart[i];
}
for (i = '0'; i <= '9'; i++)
diff --git a/gcc/cexp.y b/gcc/cexp.y
index e7372aa..410f671 100644
--- a/gcc/cexp.y
+++ b/gcc/cexp.y
@@ -1113,9 +1113,9 @@ initialize_random_junk ()
* refer to them.
*/
for (i = 'a'; i <= 'z'; i++) {
- ++is_idchar[toupper(i)];
+ ++is_idchar[TOUPPER(i)];
++is_idchar[i];
- ++is_idstart[toupper(i)];
+ ++is_idstart[TOUPPER(i)];
++is_idstart[i];
}
for (i = '0'; i <= '9'; i++)
diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog
index a39ab98..8ab5497 100644
--- a/gcc/ch/ChangeLog
+++ b/gcc/ch/ChangeLog
@@ -1,3 +1,8 @@
+1999-09-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * lex.c (maybe_downcase, getlc, handle_generic_pragma,
+ check_newline): Use uppercase ctype macro from system.h.
+
1999-09-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* actions.c (warn_unhandled): Use xstrdup, not xmalloc/strcpy.
diff --git a/gcc/ch/lex.c b/gcc/ch/lex.c
index b7fe5f4..44029b9 100644
--- a/gcc/ch/lex.c
+++ b/gcc/ch/lex.c
@@ -888,7 +888,7 @@ maybe_downcase (str)
while (*str)
{
if (ISUPPER ((unsigned char) *str))
- *str = tolower ((unsigned char)*str);
+ *str = TOLOWER (*str);
str++;
}
}
@@ -1470,8 +1470,8 @@ getlc (file)
register int c;
c = getc (file);
- if (ISUPPER (c) && ignore_case)
- c = tolower (c);
+ if (ignore_case)
+ c = TOLOWER (c);
return c;
}
@@ -1524,7 +1524,7 @@ handle_generic_pragma (buffer)
* buff ++ = c;
c = getc (finput);
}
- while (c != EOF && isascii (c) && ! isspace (c) && c != '\n'
+ while (c != EOF && isascii (c) && ! ISSPACE (c) && c != '\n'
&& buff < buffer + 128); /* XXX shared knowledge about size of buffer. */
ungetc (c, finput);
@@ -1577,8 +1577,8 @@ check_newline ()
it and ignore it; otherwise, ignore the line, with an error
if the word isn't `pragma', `ident', `define', or `undef'. */
- if (ISUPPER (c) && ignore_case)
- c = tolower (c);
+ if (ignore_case)
+ c = TOLOWER (c);
if (c >= 'a' && c <= 'z')
{
diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c
index 517ba0f..dafcb19 100644
--- a/gcc/config/c4x/c4x.c
+++ b/gcc/config/c4x/c4x.c
@@ -682,8 +682,8 @@ c4x_interrupt_function_p ()
&& current_function_name[2] == 'i'
&& current_function_name[3] == 'n'
&& current_function_name[4] == 't'
- && isdigit (current_function_name[5])
- && isdigit (current_function_name[6]);
+ && ISDIGIT (current_function_name[5])
+ && ISDIGIT (current_function_name[6]);
}
@@ -4193,13 +4193,13 @@ c4x_handle_pragma (p_getc, p_ungetc, pname)
c = p_getc ();
while (c == ' ' || c == '\t') c = p_getc ();
- if (! (isalpha(c) || c == '_' || c == '$' || c == '@'))
+ if (! (ISALPHA(c) || c == '_' || c == '$' || c == '@'))
return 0;
i = 0;
namesize = 16;
name = xmalloc (namesize);
- while (isalnum (c) || c == '_' || c == '$' || c == '@')
+ while (ISALNUM (c) || c == '_' || c == '$' || c == '@')
{
if (i >= namesize-1)
{
diff --git a/gcc/config/i370/i370.c b/gcc/config/i370/i370.c
index c999b58..e683027 100644
--- a/gcc/config/i370/i370.c
+++ b/gcc/config/i370/i370.c
@@ -976,7 +976,7 @@ handle_pragma (finput, node)
do {
*s++ = c;
c = getc (finput);
- } while (isalnum(c) || c == '_');
+ } while (ISALNUM(c) || c == '_');
if (c == '\n')
goto PRAGMA_WARNING;
*s = 0;
@@ -1014,7 +1014,7 @@ handle_pragma (finput, node)
}
*s++ = c;
c = getc (finput);
- if (isspace(c) || c == ')')
+ if (ISSPACE(c) || c == ')')
goto PRAGMA_WARNING;
} while (c != '"');
*s = 0;
diff --git a/gcc/config/i370/i370.h b/gcc/config/i370/i370.h
index d87369b..45da9fa 100644
--- a/gcc/config/i370/i370.h
+++ b/gcc/config/i370/i370.h
@@ -1138,7 +1138,7 @@ enum reg_class
ch = '@'; \
for (bp = temp; *bp; bp++) \
{ \
- if (islower (*bp)) *bp = toupper (*bp); \
+ *bp = TOUPPER (*bp); \
else if (*bp == '_') *bp = ch; \
} \
fprintf (FILE, "%s", temp); \
@@ -1256,7 +1256,7 @@ enum reg_class
for (j = 0, i = 0; i < LEN; j++, i++) \
{ \
c = PTR[i]; \
- if (iscntrl (c) || c == '&') \
+ if (ISCNTRL (c) || c == '&') \
{ \
if (j % MVS_ASCII_TEXT_LENGTH != 0 ) \
fprintf (FILE, "'\n"); \
diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c
index 0b68ced..6306cfc 100644
--- a/gcc/config/v850/v850.c
+++ b/gcc/config/v850/v850.c
@@ -134,7 +134,7 @@ override_options ()
{
if (small_memory[i].value)
{
- if (!isdigit (*small_memory[i].value))
+ if (!ISDIGIT (*small_memory[i].value))
error ("%s=%s is not numeric.",
small_memory[i].name,
small_memory[i].value);
@@ -3022,8 +3022,7 @@ v850_handle_pragma (p_getc, p_ungetc, name)
/* Read string. */
do
* buff ++ = (c = p_getc ());
- while (c != EOF && isascii (c)
- && (isalnum (c) || c == '_' || c == '.' || c == ' ')
+ while (c != EOF && (ISALNUM (c) || c == '_' || c == '.' || c == ' ')
&& (buff < buffer + 126));
if (c != '"')
@@ -3033,8 +3032,7 @@ v850_handle_pragma (p_getc, p_ungetc, name)
break;
default:
- while (c != EOF && isascii (c)
- && (isalnum (c) || c == '_' || c == '.')
+ while (c != EOF && (ISALNUM (c) || c == '_' || c == '.')
&& (buff < buffer + 126))
* buff ++ = (c = p_getc ());
break;
diff --git a/gcc/doprint.c b/gcc/doprint.c
index 2dc4dde..9d01f9a 100644
--- a/gcc/doprint.c
+++ b/gcc/doprint.c
@@ -88,7 +88,7 @@ _doprnt (format, ap, stream)
if (*ptr == '*')
COPY_VA_INT;
else
- while (isdigit(*ptr)) /* Handle explicit numeric value. */
+ while (ISDIGIT(*ptr)) /* Handle explicit numeric value. */
*sptr++ = *ptr++;
if (*ptr == '.')
@@ -97,7 +97,7 @@ _doprnt (format, ap, stream)
if (*ptr == '*')
COPY_VA_INT;
else
- while (isdigit(*ptr)) /* Handle explicit numeric value. */
+ while (ISDIGIT(*ptr)) /* Handle explicit numeric value. */
*sptr++ = *ptr++;
}
while (strchr ("hlL", *ptr))
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index acf6222..8fd19f3 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -1,3 +1,15 @@
+Thu Sep 16 18:07:11 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * bad.c (ffebad_finish): Use uppercase ctype macro from system.h.
+
+ * fini.c (main): Likewise.
+
+ * intrin.c (ffeintrin_init_0): Likewise.
+
+ * lex.c (ffelex_hash_): Likewise.
+
+ * src.c (ffesrc_init_1): Likewise.
+
Tue Sep 14 12:14:28 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* g77spec.c (lang_specific_driver): Remove unnecessary argument in
diff --git a/gcc/f/bad.c b/gcc/f/bad.c
index 704fa12..5b42129 100644
--- a/gcc/f/bad.c
+++ b/gcc/f/bad.c
@@ -461,7 +461,7 @@ ffebad_finish ()
{
char c;
- c = toupper (s[0]);
+ c = TOUPPER (s[0]);
fprintf (stderr, "%c%s ", c, &s[1]);
}
else if (s[0] != '\0')
diff --git a/gcc/f/fini.c b/gcc/f/fini.c
index 1b7c981..d09161f 100644
--- a/gcc/f/fini.c
+++ b/gcc/f/fini.c
@@ -381,8 +381,8 @@ main (int argc, char **argv)
cc = buf[i];
if (ISALPHA (cc))
{
- newname->name_uc[i] = toupper (cc);
- newname->name_lc[i] = tolower (cc);
+ newname->name_uc[i] = TOUPPER (cc);
+ newname->name_lc[i] = TOLOWER (cc);
newname->name_ic[i] = cc;
}
else
diff --git a/gcc/f/intrin.c b/gcc/f/intrin.c
index dbf375b..d59458c 100644
--- a/gcc/f/intrin.c
+++ b/gcc/f/intrin.c
@@ -1588,7 +1588,7 @@ ffeintrin_init_0 ()
if ((ISDIGIT (*p1) || (*p1 == '_')) && (*p1 == *p2) && (*p1 == *p3))
continue;
if (! ISUPPER ((unsigned char)*p1) || ! ISLOWER ((unsigned char)*p2)
- || (*p1 != toupper ((unsigned char)*p2))
+ || (*p1 != TOUPPER (*p2))
|| ((*p3 != *p1) && (*p3 != *p2)))
break;
}
diff --git a/gcc/f/lex.c b/gcc/f/lex.c
index 3136d40..b6198b2 100644
--- a/gcc/f/lex.c
+++ b/gcc/f/lex.c
@@ -1126,8 +1126,9 @@ ffelex_hash_ (FILE *finput)
static char buffer [128];
char * buff = buffer;
- /* Read the pragma name into a buffer. */
- while (isspace (c = getc (finput)))
+ /* Read the pragma name into a buffer.
+ ISSPACE() may evaluate its argument more than once! */
+ while (((c = getc (finput)), ISSPACE(c)))
continue;
do
@@ -1135,7 +1136,7 @@ ffelex_hash_ (FILE *finput)
* buff ++ = c;
c = getc (finput);
}
- while (c != EOF && ! isspace (c) && c != '\n'
+ while (c != EOF && ! ISSPACE (c) && c != '\n'
&& buff < buffer + 128);
pragma_ungetc (c);
diff --git a/gcc/f/src.c b/gcc/f/src.c
index 7b23931..e434fbf 100644
--- a/gcc/f/src.c
+++ b/gcc/f/src.c
@@ -120,10 +120,10 @@ ffesrc_init_1 ()
}
for (i = 'A'; i <= 'Z'; ++i)
- ffesrc_tolower_[i] = tolower (i);
+ ffesrc_tolower_[i] = TOLOWER (i);
for (i = 'a'; i <= 'z'; ++i)
- ffesrc_toupper_[i] = toupper (i);
+ ffesrc_toupper_[i] = TOUPPER (i);
ffesrc_check_symbol_ = (ffe_case_symbol () != FFE_caseNONE);
@@ -153,7 +153,7 @@ ffesrc_init_1 ()
if (ffesrc_ok_match_init_lower_)
for (i = 'a'; i <= 'z'; ++i)
- ffesrc_char_match_init_[i] = toupper (i);
+ ffesrc_char_match_init_[i] = TOUPPER (i);
else
for (i = 'a'; i <= 'z'; ++i)
ffesrc_char_match_init_[i] = FFESRC_INVALID_SYMBOL_CHAR_;
@@ -164,21 +164,21 @@ ffesrc_init_1 ()
if (ffesrc_ok_match_noninit_lower_)
for (i = 'a'; i <= 'z'; ++i)
- ffesrc_char_match_noninit_[i] = toupper (i);
+ ffesrc_char_match_noninit_[i] = TOUPPER (i);
else
for (i = 'a'; i <= 'z'; ++i)
ffesrc_char_match_noninit_[i] = FFESRC_INVALID_SYMBOL_CHAR_;
if (ffe_case_source () == FFE_caseLOWER)
for (i = 'A'; i <= 'Z'; ++i)
- ffesrc_char_source_[i] = tolower (i);
+ ffesrc_char_source_[i] = TOLOWER (i);
else if (ffe_case_source () == FFE_caseUPPER)
for (i = 'a'; i <= 'z'; ++i)
- ffesrc_char_source_[i] = toupper (i);
+ ffesrc_char_source_[i] = TOUPPER (i);
if (ffe_case_match () == FFE_caseLOWER)
for (i = 'A'; i <= 'Z'; ++i)
- ffesrc_char_internal_init_[i] = tolower (i);
+ ffesrc_char_internal_init_[i] = TOLOWER (i);
switch (ffe_case_symbol ())
{
diff --git a/gcc/fixinc/fixincl.c b/gcc/fixinc/fixincl.c
index 036c6fa..1a570f2 100644
--- a/gcc/fixinc/fixincl.c
+++ b/gcc/fixinc/fixincl.c
@@ -221,13 +221,13 @@ main (argc, argv)
{
if (fgets (pz_buf, MAXPATHLEN, stdin) == (char *) NULL)
break;
- while (isspace (*pz_buf))
+ while (ISSPACE (*pz_buf))
pz_buf++;
if ((*pz_buf == '\0') || (*pz_buf == '#'))
continue;
apz_names[file_name_ct++] = pz_buf;
pz_buf += strlen (pz_buf);
- while (isspace (pz_buf[-1]))
+ while (ISSPACE (pz_buf[-1]))
pz_buf--;
*pz_buf++ = '\0';
}
@@ -813,7 +813,7 @@ quoted_file_exists (pz_src_path, pz_file_path, pz_file)
for (;;) {
char ch = *pz_file++;
- if (! isgraph( ch ))
+ if (! ISGRAPH(ch))
return 0;
if (ch == '"')
break;
@@ -875,9 +875,10 @@ extract_quoted_files (pz_data, pz_file_name, p_re_match)
pz_incl_quot += p_re_match->rm_so;
/* Skip forward to the included file name */
- while (isspace (*pz_incl_quot))
+ while (ISSPACE (*pz_incl_quot))
pz_incl_quot++;
- while (isspace (*++pz_incl_quot))
+ /* ISSPACE() may evaluate is argument more than once! */
+ while ((++pz_incl_quot, ISSPACE (*pz_incl_quot)))
;
pz_incl_quot += sizeof ("include") - 1;
while (*pz_incl_quot++ != '"')
diff --git a/gcc/fixinc/server.c b/gcc/fixinc/server.c
index 9f9bd6b..06fa26a 100644
--- a/gcc/fixinc/server.c
+++ b/gcc/fixinc/server.c
@@ -163,7 +163,7 @@ load_data (fp)
return (char *) NULL;
}
- while ((pz_scan > pz_text) && isspace (pz_scan[-1]))
+ while ((pz_scan > pz_text) && ISSPACE (pz_scan[-1]))
pz_scan--;
*pz_scan = NUL;
return realloc ((void *) pz_text, strlen (pz_text) + 1);
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d3a7696..cddcded 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1072,7 +1072,7 @@ real_hex_to_f (s, mode)
}
/* Value of exponent.
The exponent field is a decimal integer. */
- while (isdigit(*p))
+ while (ISDIGIT(*p))
{
k = (*p++ & 0x7f) - '0';
expon = 10 * expon + k;
diff --git a/gcc/genattr.c b/gcc/genattr.c
index 9a3357a..4316c35 100644
--- a/gcc/genattr.c
+++ b/gcc/genattr.c
@@ -56,7 +56,7 @@ struct function_unit
static void extend_range PROTO((struct range *, int, int));
static void init_range PROTO((struct range *));
-static void write_upcase PROTO((char *));
+static void write_upcase PROTO((const char *));
static void gen_attr PROTO((rtx));
static void write_units PROTO((int, struct range *, struct range *,
struct range *, struct range *,
@@ -81,13 +81,10 @@ init_range (range)
static void
write_upcase (str)
- char *str;
+ const char *str;
{
for (; *str; str++)
- if (ISLOWER(*str))
- printf ("%c", toupper(*str));
- else
- printf ("%c", *str);
+ putchar (TOUPPER(*str));
}
static void
@@ -117,10 +114,8 @@ gen_attr (attr)
write_upcase (XSTR (attr, 0));
printf ("_");
}
- else if (ISLOWER(*p))
- printf ("%c", toupper(*p));
else
- printf ("%c", *p);
+ putchar (TOUPPER(*p));
}
printf ("};\n");
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index f0ba4de..f35e0e4 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -434,7 +434,7 @@ static void write_attr_case PROTO((struct attr_desc *, struct attr_value *,
static void write_unit_name PROTO((const char *, int, const char *));
static void write_attr_valueq PROTO((struct attr_desc *, char *));
static void write_attr_value PROTO((struct attr_desc *, rtx));
-static void write_upcase PROTO((char *));
+static void write_upcase PROTO((const char *));
static void write_indent PROTO((int));
static void write_eligible_delay PROTO((const char *));
static void write_function_unit_info PROTO((void));
@@ -1354,8 +1354,7 @@ convert_const_symbol_ref (exp, attr)
strcat (p, "_");
strcat (p, XSTR (av->value, 0));
for (; *p != '\0'; p++)
- if (ISLOWER(*p))
- *p = toupper (*p);
+ *p = TOUPPER (*p);
value = attr_rtx (SYMBOL_REF, string);
RTX_UNCHANGING_P (value) = 1;
@@ -2838,8 +2837,7 @@ evaluate_eq_attr (exp, value, insn_code, insn_index)
strcat (string, "_");
strcat (string, XSTR (exp, 1));
for (p = string; *p ; p++)
- if (ISLOWER(*p))
- *p = toupper (*p);
+ *p = TOUPPER (*p);
newexp = attr_rtx (EQ, value,
attr_rtx (SYMBOL_REF,
@@ -5351,13 +5349,14 @@ write_attr_value (attr, value)
static void
write_upcase (str)
- char *str;
+ const char *str;
{
while (*str)
- if (ISLOWER(*str))
- printf ("%c", toupper(*str++));
- else
- printf ("%c", *str++);
+ {
+ /* The argument of TOUPPER should not have side effects. */
+ putchar (TOUPPER(*str));
+ str++;
+ }
}
static void
diff --git a/gcc/genemit.c b/gcc/genemit.c
index 6b3687d..d1b3a1b 100644
--- a/gcc/genemit.c
+++ b/gcc/genemit.c
@@ -135,12 +135,7 @@ print_code (code)
{
register const char *p1;
for (p1 = GET_RTX_NAME (code); *p1; p1++)
- {
- if (ISLOWER(*p1))
- putchar (toupper(*p1));
- else
- putchar (*p1);
- }
+ putchar (TOUPPER(*p1));
}
static void
diff --git a/gcc/genopinit.c b/gcc/genopinit.c
index f364a01..5884691 100644
--- a/gcc/genopinit.c
+++ b/gcc/genopinit.c
@@ -195,7 +195,7 @@ gen_insn (insn)
for (i = ((int) MAX_MACHINE_MODE) - 1; i >= 0; i--)
{
for (p = GET_MODE_NAME(i), q = np; *p; p++, q++)
- if (tolower ((unsigned char)*p) != *q)
+ if (TOLOWER (*p) != *q)
break;
if (*p == 0
@@ -249,11 +249,11 @@ gen_insn (insn)
break;
case 'a':
for (np = GET_MODE_NAME(m1); *np; np++)
- printf ("%c", tolower ((unsigned char)*np));
+ putchar (TOLOWER (*np));
break;
case 'b':
for (np = GET_MODE_NAME(m2); *np; np++)
- printf ("%c", tolower ((unsigned char)*np));
+ putchar (TOLOWER (*np));
break;
case 'A':
printf ("%smode", GET_MODE_NAME(m1));
@@ -266,7 +266,7 @@ gen_insn (insn)
break;
case 'C':
for (np = GET_RTX_NAME(op); *np; np++)
- printf ("%c", toupper ((unsigned char)*np));
+ putchar (TOUPPER (*np));
break;
}
}
diff --git a/gcc/genpeep.c b/gcc/genpeep.c
index 8c02ba3..e5f4833 100644
--- a/gcc/genpeep.c
+++ b/gcc/genpeep.c
@@ -370,12 +370,7 @@ print_code (code)
{
register const char *p1;
for (p1 = GET_RTX_NAME (code); *p1; p1++)
- {
- if (ISLOWER(*p1))
- putchar (toupper(*p1));
- else
- putchar (*p1);
- }
+ putchar (TOUPPER(*p1));
}
PTR
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index 0d6a2d1..49d4a4e 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -1639,12 +1639,7 @@ print_code (code)
{
register const char *p1;
for (p1 = GET_RTX_NAME (code); *p1; p1++)
- {
- if (ISLOWER(*p1))
- putchar (toupper(*p1));
- else
- putchar (*p1);
- }
+ putchar (TOUPPER(*p1));
}
static int
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 558be7d..455a37d 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -4324,7 +4324,7 @@ init_libfuncs (optable, first_mode, last_mode, opname, suffix)
for (q = opname; *q; )
*p++ = *q++;
for (q = mname; *q; q++)
- *p++ = tolower ((unsigned char)*q);
+ *p++ = TOLOWER (*q);
*p++ = suffix;
*p++ = '\0';
diff --git a/gcc/system.h b/gcc/system.h
index 960e174..9252098 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -89,27 +89,52 @@ extern int fputs_unlocked PROTO ((const char *, FILE *));
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
+/* The ctype functions are often implemented as macros which do
+ lookups in arrays using the parameter as the offset. If the ctype
+ function parameter is a char, then gcc will (appropriately) warn
+ that a "subscript has type char". Using a (signed) char as a subscript
+ is bad because you may get negative offsets and thus it is not 8-bit
+ safe. The CTYPE_CONV macro ensures that the parameter is cast to an
+ unsigned char when a char is passed in. When an int is passed in, the
+ parameter is left alone so we don't lose EOF.
+*/
+
+#define CTYPE_CONV(CH) \
+ (sizeof(CH) == sizeof(unsigned char) ? (int)(unsigned char)(CH) : (int)(CH))
+
+
+/* WARNING! The argument to the ctype replacement macros below is
+ evaluated more than once so it must not have side effects! */
+
#ifdef isblank
-# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
+# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (CTYPE_CONV(c)))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
-# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
+# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (CTYPE_CONV(c)))
+#else
+# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (CTYPE_CONV(c)) && !isspace (CTYPE_CONV(c)))
+#endif
+
+#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (CTYPE_CONV(c)))
+#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (CTYPE_CONV(c)))
+#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (CTYPE_CONV(c)))
+#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (CTYPE_CONV(c)))
+#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (CTYPE_CONV(c)))
+#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (CTYPE_CONV(c)))
+#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (CTYPE_CONV(c)))
+#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (CTYPE_CONV(c)))
+#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (CTYPE_CONV(c)))
+#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (CTYPE_CONV(c)))
+
+#if STDC_HEADERS
+# define TOLOWER(c) (tolower (CTYPE_CONV(c)))
+# define TOUPPER(c) (toupper (CTYPE_CONV(c)))
#else
-# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
-#endif
-
-#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
-#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
-#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
-#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
-#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
-#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
-#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
-#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
-#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
-#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
+# define TOLOWER(c) (ISUPPER (c) ? tolower (CTYPE_CONV(c)) : (c))
+# define TOUPPER(c) (ISLOWER (c) ? toupper (CTYPE_CONV(c)) : (c))
+#endif
/* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
- Its arg may be any int or unsigned int; it need not be an unsigned char.