Commit f6bbde28 by Zack Weinberg

safe-ctype.h: New file.

include:
	* safe-ctype.h: New file.
libiberty:
	* safe-ctype.c: New file.
	* Makefile.in (CFILES): Add safe-ctype.c.
	(REQUIRED_OFILES): Add safe-ctype.o.

	* argv.c: Define ISBLANK and use it, not isspace.
	* basename.c, cplus-dem.c, fnmatch.c, pexecute.c, strtod.c,
	strtol.c, strtoul.c: Include safe-ctype.h, not ctype.h.  Use
	uppercase ctype macros.  Don't test ISUPPER(c)/ISLOWER(c)
	before calling TOLOWER(c)/TOUPPER(c).
gcc:
	* Makefile.in (HOST_RTL): Add safe-ctype.o.
	(safe-ctype.o): New rule.
	* system.h: Include safe-ctype.h, not ctype.h.  No need to
	wrap ctype macros.

	* cpphash.h: Zap IStable and related macros.  Define is_* in
	terms of safe-ctype.h macros.
	* cppinit.c: Delete the IStable and all related code.

	* tradcpp.c: Delete is_idchar, is_idstart, is_hor_space, and
	is_space arrays.  Delete initialize_char_syntax.  Change all
	references to the above arrays to use macros instead.
	* tradcpp.h: Define is_idchar, is_idstart, is_space, and
	is_nvspace in terms of safe_ctype.h's macros.
	* tradcif.y: is_idchar, is_idstart are macros not arrays.

	* config/i370/i370.c, config/winnt/dirent.c,
	config/winnt/fixinc-nt.c, config/winnt/ld.c:
	Use uppercase ctype macros.  If we included ctype.h,
	include safe-ctype.h instead.

	* fixinc/fixfixes.c: Use uppercase ctype macros.  Don't test
	ISLOWER(c) before calling TOUPPER(c).
	* fixinc/fixincl.c (extract_quoted_files): Simplify out some gunk.
	* fixinc/gnu-regex.c: Include safe-ctype.h, not ctype.h.  No need to
	wrap ctype macros.  Don't test ISUPPER(x) before calling TOLOWER(x).
gcc/ch:
	* lex.c: Don't bother checking whether ISUPPER(c) before
	calling TOLOWER(c).  Don't bother checking whether isascii(c)
	before testing ISSPACE(c); ISSPACE(c) includes '\n'.
gcc/f:
	* Make-lang.in: Link f/fini with safe-ctype.o.
	* bad.c: Don't test ISUPPER(c) || ISLOWER(c) before calling TOUPPER(c).
	* com.c: Use TOUPPER, not ffesrc_toupper.
	* fini.c: Don't test ISALPHA(c) before calling TOUPPER(c)/TOLOWER(c).
	* intrin.c: Don't test IN_CTYPE_DOMAIN(c).
	* src.c: Delete ffesrc_toupper_ and ffesrc_tolower_ and their
	initializing code; use TOUPPER and TOLOWER instead of
	ffesrc_toupper and ffesrc_tolower.
	* src.h: Don't declare ffesrc_toupper_ or ffesrc_tolower_.
	Don't define ffesrc_toupper or ffesrc_tolower.
gcc/java:
	* jvgenmain.c: Use ISPRINT not isascii.

From-SVN: r38124
parent f3588f1a
......@@ -627,7 +627,7 @@ HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_ALLOCA) $(USE_HOST_MALLOC) \
$(USE_HOST_VFPRINTF) $(USE_HOST_DOPRINT) $(HOST_CLIB)
HOST_RTL = $(HOST_PREFIX)rtl.o $(HOST_PREFIX)bitmap.o \
$(HOST_PREFIX)ggc-none.o gensupport.o hashtab.o
$(HOST_PREFIX)ggc-none.o gensupport.o hashtab.o safe-ctype.o
HOST_PRINT = $(HOST_PREFIX)print-rtl.o
HOST_ERRORS = $(HOST_PREFIX)errors.o
......@@ -1672,6 +1672,11 @@ hashtab.o: $(srcdir)/../libiberty/hashtab.c $(GCONFIG_H)
$(LN_S) $(srcdir)/../libiberty/hashtab.c hashtab.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) hashtab.c
safe-ctype.o: $(srcdir)/../libiberty/safe-ctype.c $(GCONFIG_H)
rm -f safe-ctype.c
$(LN_S) $(srcdir)/../libiberty/safe-ctype.c safe-ctype.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) safe-ctype.c
genconfig : genconfig.o $(HOST_RTL) $(HOST_PRINT) $(HOST_ERRORS) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genconfig.o $(HOST_RTL) $(HOST_PRINT) $(HOST_ERRORS) $(HOST_LIBS)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -889,8 +889,7 @@ maybe_downcase (str)
return;
while (*str)
{
if (ISUPPER ((unsigned char) *str))
*str = TOLOWER (*str);
*str = TOLOWER (*str);
str++;
}
}
......@@ -1526,9 +1525,9 @@ handle_generic_pragma (buffer)
* buff ++ = c;
c = getc (finput);
}
while (c != EOF && isascii (c) && ! ISSPACE (c) && c != '\n'
&& buff < buffer + 128); /* XXX shared knowledge about size of buffer. */
while (c != EOF && ! ISSPACE (c) && buff < buffer + 128);
/* XXX shared knowledge about size of buffer. */
ungetc (c, finput);
* -- buff = 0;
......
......@@ -906,11 +906,11 @@ mvs_need_alias (realname)
return 1;
if (strchr (realname, '_') != 0)
return 1;
if (isupper (realname[0]))
if (ISUPPER (realname[0]))
{
for (i = 1; i < j; i++)
{
if (islower (realname[i]))
if (ISLOWER (realname[i]))
return 1;
}
}
......@@ -918,7 +918,7 @@ mvs_need_alias (realname)
{
for (i = 1; i < j; i++)
{
if (isupper (realname[i]))
if (ISUPPER (realname[i]))
return 1;
}
}
......@@ -951,9 +951,9 @@ mvs_get_alias (realname, aliasname)
c1 = realname[0];
c2 = realname[1];
if (islower (c1)) c1 = toupper (c1);
if (ISLOWER (c1)) c1 = TOUPPER (c1);
else if (c1 == '_') c1 = 'A';
if (islower (c2)) c2 = toupper (c2);
if (ISLOWER (c2)) c2 = TOUPPER (c2);
else if (c2 == '_' || c2 == '\0') c2 = '#';
sprintf (aliasname, "%c%c%06d", c1, c2, mvs_hash_alias (realname));
......@@ -998,9 +998,9 @@ mvs_check_alias (realname, aliasname)
c1 = realname[0];
c2 = realname[1];
if (islower (c1)) c1 = toupper (c1);
if (ISLOWER (c1)) c1 = TOUPPER (c1);
else if (c1 == '_') c1 = 'A';
if (islower (c2)) c2 = toupper (c2);
if (ISLOWER (c2)) c2 = TOUPPER (c2);
else if (c2 == '_' || c2 == '\0') c2 = '#';
sprintf (aliasname, "%c%c%06d", c1, c2, mvs_hash_alias (realname));
......
......@@ -23,7 +23,7 @@
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <safe-ctype.h>
#include <errno.h>
#include <dirent.h>
......@@ -332,8 +332,8 @@ IsHPFSFileSystem (directory)
unsigned int nDrive;
char szCurDir [MAX_PATH];
if (isalpha (directory[0]) && (directory[1] == ':'))
nDrive = toupper (directory[0]) - '@';
if (ISALPHA (directory[0]) && (directory[1] == ':'))
nDrive = TOUPPER (directory[0]) - '@';
else
{
......
......@@ -64,7 +64,7 @@ newname (olddirname)
char *newname = strdup (olddirname);
if ((strlen (newname) >= 2)
&& (isalpha (newname[0]) && newname[1] == ':'))
&& (ISALPHA (newname[0]) && newname[1] == ':'))
newname [1] = '-';
else if ((strlen (newname) >= 1)
&& (newname [0] == '/' || newname [0] == '\\'))
......
......@@ -86,7 +86,7 @@ locate_file (file_name, path_val)
/* Handle absolute pathnames */
if (file_name [0] == '/' || file_name [0] == DIR_SEPARATOR
|| isalpha (file_name [0]) && file_name [1] == ':')
|| ISALPHA (file_name [0]) && file_name [1] == ':')
{
strncpy (buf, file_name, sizeof buf);
buf[sizeof buf - 1] = '\0';
......
......@@ -135,39 +135,30 @@ struct cpp_buffer
unsigned char sysp;
};
/* Character classes.
/* Character classes. Based on the more primitive macros in safe-ctype.h.
If the definition of `numchar' looks odd to you, please look up the
definition of a pp-number in the C standard [section 6.4.8 of C99].
In the unlikely event that characters other than \r and \n enter
the set is_vspace, the macro handle_newline() in cpplex.c must be
updated. */
#define ISidnum 0x01 /* a-zA-Z0-9_ */
#define ISidstart 0x02 /* _a-zA-Z */
#define ISnumstart 0x04 /* 0-9 */
#define IShspace 0x08 /* ' ' \t */
#define ISvspace 0x10 /* \r \n */
#define ISspace 0x20 /* ' ' \t \r \n \f \v \0 */
#define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
#define is_idchar(x) ((_cpp_IStable[x] & ISidnum) || _dollar_ok(x))
#define is_idstart(x) ((_cpp_IStable[x] & ISidstart) || _dollar_ok(x))
#define is_numchar(x) (_cpp_IStable[x] & ISidnum)
#define is_numstart(x) (_cpp_IStable[x] & ISnumstart)
#define is_hspace(x) (_cpp_IStable[x] & IShspace)
#define is_vspace(x) (_cpp_IStable[x] & ISvspace)
#define is_nvspace(x) ((_cpp_IStable[x] & (ISspace | ISvspace)) == ISspace)
#define is_space(x) (_cpp_IStable[x] & ISspace)
#define is_idchar(x) (ISIDNUM(x) || _dollar_ok(x))
#define is_numchar(x) ISIDNUM(x)
#define is_idstart(x) (ISIDST(x) || _dollar_ok(x))
#define is_numstart(x) ISDIGIT(x)
#define is_hspace(x) ISBLANK(x)
#define is_vspace(x) IS_VSPACE(x)
#define is_nvspace(x) IS_NVSPACE(x)
#define is_space(x) IS_SPACE_OR_NUL(x)
/* These tables are constant if they can be initialized at compile time,
/* This table is constant if it can be initialized at compile time,
which is the case if cpp was compiled with GCC >=2.7, or another
compiler that supports C99. */
#if HAVE_DESIGNATED_INITIALIZERS
extern const unsigned char _cpp_IStable[UCHAR_MAX + 1];
extern const unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
#else
extern unsigned char _cpp_IStable[UCHAR_MAX + 1];
extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
#endif
......
......@@ -125,9 +125,6 @@ enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
runtime. */
#if HAVE_DESIGNATED_INITIALIZERS
#define init_IStable() /* Nothing. */
#define ISTABLE __extension__ const U_CHAR _cpp_IStable[UCHAR_MAX + 1] = {
#define init_trigraph_map() /* Nothing. */
#define TRIGRAPH_MAP \
__extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
......@@ -137,10 +134,6 @@ __extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
#else
#define ISTABLE unsigned char _cpp_IStable[UCHAR_MAX + 1] = { 0 }; \
static void init_IStable PARAMS ((void)) { \
unsigned char *x = _cpp_IStable;
#define TRIGRAPH_MAP U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
static void init_trigraph_map PARAMS ((void)) { \
unsigned char *x = _cpp_trigraph_map;
......@@ -150,45 +143,13 @@ __extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
#endif
#define A(x) s(x, ISidnum|ISidstart)
#define N(x) s(x, ISidnum|ISnumstart)
#define H(x) s(x, IShspace|ISspace)
#define V(x) s(x, ISvspace|ISspace)
#define S(x) s(x, ISspace)
ISTABLE
A('_')
A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i')
A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r')
A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z')
A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I')
A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R')
A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z')
N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
H(' ') H('\t')
V('\n') V('\r')
S('\0') S('\v') S('\f')
END
TRIGRAPH_MAP
s('=', '#') s(')', ']') s('!', '|')
s('(', '[') s('\'', '^') s('>', '}')
s('/', '\\') s('<', '{') s('-', '~')
END
#undef A
#undef N
#undef H
#undef V
#undef S
#undef s
#undef ISTABLE
#undef END
#undef TRIGRAPH_MAP
......@@ -507,11 +468,9 @@ initialize ()
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
#endif
/* Set up the trigraph map and the IStable. These don't need to do
anything if we were compiled with a compiler that supports C99
designated initializers. */
/* Set up the trigraph map. This doesn't need to do anything if we were
compiled with a compiler that supports C99 designated initializers. */
init_trigraph_map ();
init_IStable ();
initialized = 1;
}
......
2000-12-07 Zack Weinberg <zack@wolery.stanford.edu>
* Make-lang.in: Link f/fini with safe-ctype.o.
* bad.c: Don't test ISUPPER(c) || ISLOWER(c) before calling TOUPPER(c).
* com.c: Use TOUPPER, not ffesrc_toupper.
* fini.c: Don't test ISALPHA(c) before calling TOUPPER(c)/TOLOWER(c).
* intrin.c: Don't test IN_CTYPE_DOMAIN(c).
* src.c: Delete ffesrc_toupper_ and ffesrc_tolower_ and their
initializing code; use TOUPPER and TOLOWER instead of
ffesrc_toupper and ffesrc_tolower.
* src.h: Don't declare ffesrc_toupper_ or ffesrc_tolower_.
Don't define ffesrc_toupper or ffesrc_tolower.
2000-11-28 Richard Henderson <rth@redhat.com>
* com.c (ffecom_member_phase2_): Set TREE_USED on the debugging decl.
......@@ -35,11 +48,11 @@ Thu Nov 23 02:18:57 2000 J"orn Rennecke <amylaar@redhat.com>
Sun Nov 19 17:29:22 2000 Matthias Klose <doko@marvin.itso-berlin.de>
* g77.texi (Floating-point precision): Adjust example
to work with glibc (>= 2.1).
* g77.texi (Floating-point precision): Adjust example
to work with glibc (>= 2.1).
Sat Nov 18 13:54:49 2000 Matthias Klose <doko@cs.tu-berlin.de>
Sat Nov 18 13:54:49 2000 Matthias Klose <doko@cs.tu-berlin.de>
* g77.texi (Floating-point Exception Handling): Adjust
example to work with glibc (>= 2.1).
......@@ -149,7 +162,7 @@ Thu Oct 12 22:28:51 2000 Mark Mitchell <mark@codesourcery.com>
(ffeste_R842): Likewise.
(ffeste_R843): Likewise.
(ffeste_R1001): Likewise.
2000-10-05 Richard Henderson <rth@cygnus.com>
* com.c (finish_function): Don't init can_reach_end.
......@@ -188,9 +201,9 @@ Sun Oct 1 11:43:44 2000 Mark Mitchell <mark@codesourcery.com>
* intrin.def: Adjust DEFIMP definition of LOG10, (float) MOD.
2000-08-21 Nix <nix@esperi.demon.co.uk>
* lang-specs.h: Do not process -o or run the assembler if
-fsyntax-only. Use %j instead of /dev/null.
* lang-specs.h: Do not process -o or run the assembler if
-fsyntax-only. Use %j instead of /dev/null.
2000-08-21 Jakub Jelinek <jakub@redhat.com>
......@@ -210,7 +223,7 @@ Sun Oct 1 11:43:44 2000 Mark Mitchell <mark@codesourcery.com>
* news.texi: Ditto.
2000-08-11 G. Helffrich <george@gly.bris.ac.uk>
Toon Moene <toon@moene.indiv.nluug.nl>
Toon Moene <toon@moene.indiv.nluug.nl>
* com.c (ffecom_transform_equiv_): Make EQUIVALENCEs addressable
so that debug info can be attached to their storage.
......
......@@ -137,9 +137,9 @@ f/str-op.h f/str-op.j: f/fini$(build_exeext) f/str-op.fin
f/str-ot.h f/str-ot.j: f/fini$(build_exeext) f/str-ot.fin
./f/fini$(build_exeext) $(srcdir)/f/str-ot.fin f/str-ot.j f/str-ot.h
f/fini$(build_exeext): f/fini.o f/proj-h.o
f/fini$(build_exeext): f/fini.o f/proj-h.o safe-ctype.o
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o f/fini$(build_exeext) \
f/fini.o f/proj-h.o
f/fini.o f/proj-h.o safe-ctype.o
f/fini.o:
$(HOST_CC) $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) \
......
......@@ -457,7 +457,7 @@ ffebad_finish ()
if (ffebad_places_ == 0)
{
/* Didn't output "warning:" string, capitalize it for message. */
if ((s[0] != '\0') && ISALPHA (s[0]) && ISLOWER (s[0]))
if (s[0] != '\0')
{
char c;
......
......@@ -1840,7 +1840,7 @@ ffecom_build_f2c_string_ (int i, const char *s)
tmp = &space[0];
for (p = s, q = tmp; *p != '\0'; ++p, ++q)
*q = ffesrc_toupper (*p);
*q = TOUPPER (*p);
*q = '\0';
t = build_string (i, tmp);
......
......@@ -381,15 +381,9 @@ main (int argc, char **argv)
for (i = 0; i < newname->namelen; ++i)
{
cc = buf[i];
if (ISALPHA (cc))
{
newname->name_uc[i] = TOUPPER (cc);
newname->name_lc[i] = TOLOWER (cc);
newname->name_ic[i] = cc;
}
else
newname->name_uc[i] = newname->name_lc[i] = newname->name_ic[i]
= cc;
newname->name_uc[i] = TOUPPER (cc);
newname->name_lc[i] = TOLOWER (cc);
newname->name_ic[i] = cc;
}
newname->name_uc[i] = newname->name_lc[i] = newname->name_ic[i] = '\0';
......
......@@ -1581,10 +1581,6 @@ ffeintrin_init_0 ()
p3 = ffeintrin_names_[i].name_ic;
for (; *p1 != '\0' && *p2 != '\0' && *p3 != '\0'; ++p1, ++p2, ++p3)
{
if (! IN_CTYPE_DOMAIN (*p1)
|| ! IN_CTYPE_DOMAIN (*p2)
|| ! IN_CTYPE_DOMAIN (*p3))
break;
if ((ISDIGIT (*p1) || (*p1 == '_')) && (*p1 == *p2) && (*p1 == *p3))
continue;
if (! ISUPPER ((unsigned char)*p1) || ! ISLOWER ((unsigned char)*p2)
......
......@@ -32,16 +32,6 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "src.h"
#include "top.h"
/* This array does a toupper (), but any valid char type is valid as an
index and returns identity if not a lower-case character. */
char ffesrc_toupper_[256];
/* This array does a tolower (), but any valid char type is valid as an
index and returns identity if not an upper-case character. */
char ffesrc_tolower_[256];
/* This array is set up so that, given a source-mapped character, the result
of indexing into this array will match an upper-cased character depending
on the source-mapped character's case and the established ffe_case_match()
......@@ -113,18 +103,10 @@ ffesrc_init_1 ()
ffesrc_char_match_noninit_[i] = i;
ffesrc_char_source_[i] = i;
ffesrc_char_internal_init_[i] = i;
ffesrc_toupper_[i] = i;
ffesrc_tolower_[i] = i;
ffesrc_bad_symbol_init_[i] = FFEBAD;
ffesrc_bad_symbol_noninit_[i] = FFEBAD;
}
for (i = 'A'; i <= 'Z'; ++i)
ffesrc_tolower_[i] = TOLOWER (i);
for (i = 'a'; i <= 'z'; ++i)
ffesrc_toupper_[i] = TOUPPER (i);
ffesrc_check_symbol_ = (ffe_case_symbol () != FFE_caseNONE);
ffesrc_ok_match_init_upper_ = (ffe_case_match () != FFE_caseLOWER);
......@@ -230,8 +212,8 @@ ffesrc_strcmp_1ns2i (ffeCase mcase, const char *var, int len,
for (; len > 0; --len, ++var, ++str_ic)
{
c = ffesrc_char_source (*var); /* Transform source. */
c = ffesrc_toupper (c); /* Upcase source. */
d = ffesrc_toupper (*str_ic); /* Upcase InitialCaps char. */
c = TOUPPER (c); /* Upcase source. */
d = TOUPPER (*str_ic); /* Upcase InitialCaps char. */
if (c != d)
{
if ((d != '\0') && (c < d))
......@@ -246,7 +228,7 @@ ffesrc_strcmp_1ns2i (ffeCase mcase, const char *var, int len,
for (; len > 0; --len, ++var, ++str_ic)
{
c = ffesrc_char_source (*var); /* Transform source. */
d = ffesrc_toupper (*str_ic); /* Transform InitialCaps char. */
d = TOUPPER (*str_ic); /* Transform InitialCaps char. */
if (c != d)
{
if ((d != '\0') && (c < d))
......@@ -261,7 +243,7 @@ ffesrc_strcmp_1ns2i (ffeCase mcase, const char *var, int len,
for (; len > 0; --len, ++var, ++str_ic)
{
c = ffesrc_char_source (*var); /* Transform source. */
d = ffesrc_tolower (*str_ic); /* Transform InitialCaps char. */
d = TOLOWER (*str_ic); /* Transform InitialCaps char. */
if (c != d)
{
if ((d != '\0') && (c < d))
......@@ -279,14 +261,14 @@ ffesrc_strcmp_1ns2i (ffeCase mcase, const char *var, int len,
d = *str_ic; /* No transform of InitialCaps char. */
if (c != d)
{
c = ffesrc_toupper (c);
d = ffesrc_toupper (d);
c = TOUPPER (c);
d = TOUPPER (d);
while ((len > 0) && (c == d))
{ /* Skip past equivalent (case-ins) chars. */
--len, ++var, ++str_ic;
if (len > 0)
c = ffesrc_toupper (*var);
d = ffesrc_toupper (*str_ic);
c = TOUPPER (*var);
d = TOUPPER (*str_ic);
}
if ((d != '\0') && (c < d))
return -1;
......@@ -323,7 +305,7 @@ ffesrc_strcmp_2c (ffeCase mcase, const char *var, const char *str_uc,
case FFE_caseNONE:
for (; *var != '\0'; ++var, ++str_uc)
{
c = ffesrc_toupper (*var); /* Upcase source. */
c = TOUPPER (*var); /* Upcase source. */
if (c != *str_uc)
{
if ((*str_uc != '\0') && (c < *str_uc))
......@@ -349,11 +331,11 @@ ffesrc_strcmp_2c (ffeCase mcase, const char *var, const char *str_uc,
{
if (*var != *str_ic)
{
c = ffesrc_toupper (*var);
c = TOUPPER (*var);
while ((c != '\0') && (c == *str_uc))
{ /* Skip past equivalent (case-ins) chars. */
++var, ++str_uc;
c = ffesrc_toupper (*var);
c = TOUPPER (*var);
}
if ((*str_uc != '\0') && (c < *str_uc))
return -1;
......@@ -393,7 +375,7 @@ ffesrc_strncmp_2c (ffeCase mcase, const char *var, const char *str_uc,
case FFE_caseNONE:
for (; len > 0; ++var, ++str_uc, --len)
{
c = ffesrc_toupper (*var); /* Upcase source. */
c = TOUPPER (*var); /* Upcase source. */
if (c != *str_uc)
{
if (c < *str_uc)
......@@ -417,12 +399,12 @@ ffesrc_strncmp_2c (ffeCase mcase, const char *var, const char *str_uc,
{
if (*var != *str_ic)
{
c = ffesrc_toupper (*var);
c = TOUPPER (*var);
while ((len > 0) && (c == *str_uc))
{ /* Skip past equivalent (case-ins) chars. */
--len, ++var, ++str_uc;
if (len > 0)
c = ffesrc_toupper (*var);
c = TOUPPER (*var);
}
if ((len > 0) && (c < *str_uc))
return -1;
......
......@@ -33,8 +33,6 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "bad.h"
#include "top.h"
extern char ffesrc_toupper_[256];
extern char ffesrc_tolower_[256];
extern char ffesrc_char_match_init_[256];
extern char ffesrc_char_match_noninit_[256];
extern char ffesrc_char_source_[256];
......@@ -136,8 +134,6 @@ int ffesrc_strncmp_2c (ffeCase mcase, const char *var, const char *str_uc,
#define ffesrc_terminate_2()
#define ffesrc_terminate_3()
#define ffesrc_terminate_4()
#define ffesrc_toupper(c) (ffesrc_toupper_[(unsigned int) (c)])
#define ffesrc_tolower(c) (ffesrc_tolower_[(unsigned int) (c)])
/* End of #include file. */
......
......@@ -156,7 +156,7 @@ emit_gnu_type ( text, rm )
char* pD = z_TYPE;
while (ps < pe)
*(pD++) = toupper( *(pd++) = *(ps++) );
*(pD++) = TOUPPER( *(pd++) = *(ps++) );
*pD = *pd = NUL;
}
......@@ -612,20 +612,16 @@ FIX_PROC_HEAD( wrap_fix )
"wrap-fix" );
for (;;) {
char ch = *(pz_src++);
char ch = *pz_src++;
if (ISLOWER (ch))
*(pz_dst++) = TOUPPER ( ch );
else if (ISALNUM ( ch ))
*(pz_dst++) = ch;
else if (ch == NUL) {
*(pz_dst++) = ch;
if (ch == NUL) {
*pz_dst++ = ch;
break;
} else if (! ISALNUM (ch)) {
*pz_dst++ = '_';
} else {
*pz_dst++ = TOUPPER (ch);
}
else
*(pz_dst++) = '_';
if (++len >= sizeof( z_fixname )) {
void* p = xmalloc( len + strlen( pz_src ) + 1 );
......
......@@ -771,14 +771,8 @@ extract_quoted_files (pz_data, pz_fixed_file, p_re_match)
pz_incl_quot += p_re_match->rm_so;
/* Skip forward to the included file name */
while (ISSPACE (*pz_incl_quot))
while (*pz_incl_quot != '"')
pz_incl_quot++;
/* ISSPACE() may evaluate its argument more than once! */
while (++pz_incl_quot, ISSPACE (*pz_incl_quot))
;
pz_incl_quot += sizeof ("include") - 1;
while (*pz_incl_quot++ != '"')
;
if (quoted_file_exists (pz_src_dir, pz_fixed_file, pz_incl_quot))
{
......
......@@ -198,50 +198,10 @@ init_syntax_once ()
/* GCC LOCAL: call it gnu-regex.h, not regex.h, to avoid name conflicts */
#include "gnu-regex.h"
/* isalpha etc. are used for the character classes. */
#include <ctype.h>
/* Jim Meyering writes:
"... Some ctype macros are valid only for character codes that
isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
using /bin/cc or gcc but without giving an ansi option). So, all
ctype uses should be through macros like ISPRINT... If
STDC_HEADERS is defined, then autoconf has verified that the ctype
macros don't need to be guarded with references to isascii. ...
Defining isascii to 1 should let any compiler worth its salt
eliminate the && through constant folding."
Solaris defines some of these symbols so we must undefine them first. */
#undef ISASCII
#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
# define ISASCII(c) 1
#else
# define ISASCII(c) isascii(c)
#endif
#ifdef isblank
# define ISBLANK(c) (ISASCII (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
#else
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
#endif
#undef ISPRINT
#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
#define ISALNUM(c) (ISASCII (c) && isalnum (c))
#define ISALPHA(c) (ISASCII (c) && isalpha (c))
#define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
#define ISLOWER(c) (ISASCII (c) && islower (c))
#define ISPUNCT(c) (ISASCII (c) && ispunct (c))
#define ISSPACE(c) (ISASCII (c) && isspace (c))
#define ISUPPER(c) (ISASCII (c) && isupper (c))
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
/* ISALPHA etc. are used for the character classes. */
/* GCC LOCAL: use libiberty's safe-ctype.h, don't bother defining
wrapper macros ourselves. */
#include <safe-ctype.h>
#ifndef NULL
# define NULL (void *)0
......@@ -5613,7 +5573,7 @@ regcomp (preg, pattern, cflags)
/* Map uppercase characters to corresponding lowercase ones. */
for (i = 0; i < CHAR_SET_SIZE; i++)
preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
preg->translate[i] = TOLOWER (i);
}
else
preg->translate = NULL;
......
......@@ -144,7 +144,7 @@ main (int argc, const char **argv)
fprintf (stream, " \"");
for (p = &argv[i][2]; *p; ++p)
{
if (! isascii (*p))
if (! ISPRINT (*p))
fprintf (stream, "\\%o", *p);
else if (*p == '\\' || *p == '"')
fprintf (stream, "\\%c", *p);
......
......@@ -75,91 +75,12 @@ extern int fputs_unlocked PARAMS ((const char *, FILE *));
# endif
#endif
#include <ctype.h>
/* There are an extraordinary number of issues with <ctype.h>.
The last straw is that it varies with the locale. Use libiberty's
replacement instead. */
#include <safe-ctype.h>
/* Jim Meyering writes:
"... Some ctype macros are valid only for character codes that
isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
using /bin/cc or gcc but without giving an ansi option). So, all
ctype uses should be through macros like ISPRINT... If
STDC_HEADERS is defined, then autoconf has verified that the ctype
macros don't need to be guarded with references to isascii. ...
Defining isascii to 1 should let any compiler worth its salt
eliminate the && through constant folding."
Bruno Haible adds:
"... Furthermore, isupper(c) etc. have an undefined result if c is
outside the range -1 <= c <= 255. One is tempted to write isupper(c)
with c being of type `char', but this is wrong if c is an 8-bit
character >= 128 which gets sign-extended to a negative value.
The macro ISUPPER protects against this as well." */
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) || defined(HOST_EBCDIC)
# define IN_CTYPE_DOMAIN(c) 1
#else
# 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 (CTYPE_CONV(c)))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# 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 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.
- It's guaranteed to evaluate its argument exactly once.
- It's typically faster.
Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
it's important to use the locale's definition of `digit' even when the
host does not conform to Posix. */
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
/* Define a default escape character; its different for EBCDIC. */
/* Define a default escape character; it's different for EBCDIC. */
#ifndef TARGET_ESC
#define TARGET_ESC 033
#endif
......
......@@ -402,13 +402,13 @@ yylex ()
if (c >= '0' && c <= '9') {
/* It's a number */
for (namelen = 0;
c = tokstart[namelen], is_idchar[c] || c == '.';
c = tokstart[namelen], is_idchar (c) || c == '.';
namelen++)
;
return parse_number (namelen);
}
if (!is_idstart[c]) {
if (!is_idstart (c)) {
yyerror ("Invalid token in expression");
return ERROR;
}
......@@ -416,7 +416,7 @@ yylex ()
/* It is a name. See how long it is. */
for (namelen = 0;
is_idchar[(int)(unsigned char)tokstart[namelen]];
is_idchar (tokstart[namelen]);
namelen++)
;
......
......@@ -36,7 +36,9 @@ extern struct hashnode *lookup PARAMS ((const unsigned char *, int, int));
extern int parse_c_expression PARAMS ((const char *)); /* in tradcif.y */
extern int test_assertion PARAMS ((unsigned char **));
/* some external tables of character types */
extern unsigned char is_idstart[], is_idchar[];
#define is_idchar(x) ISIDNUM(x)
#define is_idstart(x) ISIDST(x)
#define is_space(x) ISSPACE(x)
#define is_nvspace(x) IS_NVSPACE(x)
#endif /* ! _TRADCPP_H_ */
2000-12-07 Zack Weinberg <zack@wolery.stanford.edu>
* safe-ctype.h: New file.
2000-12-06 Rodney Brown <RodneyBrown@mynd.com>
* getopt.h obstack.h: Standarize copyright statement.
......
/* <ctype.h> replacement macros.
Copyright (C) 2000 Free Software Foundation, Inc.
Contributed by Zack Weinberg <zackw@stanford.edu>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* This is a compatible replacement of the standard C library's <ctype.h>
with the following properties:
- Implements all isxxx() macros required by C99.
- Also implements some character classes useful when
parsing C-like languages.
- Does not change behavior depending on the current locale.
- Behaves properly for all values in the range of a signed or
unsigned char.
To avoid conflicts, this header defines the isxxx functions in upper
case, e.g. ISALPHA not isalpha. */
#ifndef SAFE_CTYPE_H
#define SAFE_CTYPE_H
#ifdef isalpha
#error "safe-ctype.h and ctype.h may not be used simultaneously"
#else
/* Categories. */
enum {
/* In C99 */
_sch_isblank = 0x0001, /* space \t */
_sch_iscntrl = 0x0002, /* nonprinting characters */
_sch_isdigit = 0x0004, /* 0-9 */
_sch_islower = 0x0008, /* a-z */
_sch_isprint = 0x0010, /* any printing character including ' ' */
_sch_ispunct = 0x0020, /* all punctuation */
_sch_isspace = 0x0040, /* space \t \n \r \f \v */
_sch_isupper = 0x0080, /* A-Z */
_sch_isxdigit = 0x0100, /* 0-9A-Fa-f */
/* Extra categories useful to cpplib. */
_sch_isidst = 0x0200, /* A-Za-z_ */
_sch_isvsp = 0x0400, /* \n \r */
_sch_isnvsp = 0x0800, /* space \t \f \v \0 */
/* Combinations of the above. */
_sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */
_sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */
_sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */
_sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */
_sch_iscppsp = _sch_isvsp|_sch_isnvsp /* isspace + \0 */
};
/* This code fundamentally assumes that a byte is 8 bits. Test this
at compile time. */
extern int a_byte_isnt_eight_bits[(unsigned char)256 == 0 ? 1 : -1];
/* Character classification. */
extern const unsigned short _sch_istable[256];
#define _sch_test(c, bit) (_sch_istable[(int)(unsigned char)(c)] & (bit))
#define ISALPHA(c) _sch_test(c, _sch_isalpha)
#define ISALNUM(c) _sch_test(c, _sch_isalnum)
#define ISBLANK(c) _sch_test(c, _sch_isblank)
#define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
#define ISDIGIT(c) _sch_test(c, _sch_isdigit)
#define ISGRAPH(c) _sch_test(c, _sch_isgraph)
#define ISLOWER(c) _sch_test(c, _sch_islower)
#define ISPRINT(c) _sch_test(c, _sch_isprint)
#define ISPUNCT(c) _sch_test(c, _sch_ispunct)
#define ISSPACE(c) _sch_test(c, _sch_isspace)
#define ISUPPER(c) _sch_test(c, _sch_isupper)
#define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
#define ISIDNUM(c) _sch_test(c, _sch_isidnum)
#define ISIDST(c) _sch_test(c, _sch_isidst)
#define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
#define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
#define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
/* Character transformation. */
extern const unsigned char _sch_toupper[256];
extern const unsigned char _sch_tolower[256];
#define TOUPPER(c) _sch_toupper[(int)(unsigned char)(c)]
#define TOLOWER(c) _sch_tolower[(int)(unsigned char)(c)]
#endif /* no ctype.h */
#endif /* SAFE_CTYPE_H */
2000-12-07 Zack Weinberg <zack@wolery.stanford.edu>
* safe-ctype.c: New file.
* Makefile.in (CFILES): Add safe-ctype.c.
(REQUIRED_OFILES): Add safe-ctype.o.
* argv.c: Define ISBLANK and use it, not isspace.
* basename.c, cplus-dem.c, fnmatch.c, pexecute.c, strtod.c,
strtol.c, strtoul.c: Include safe-ctype.h, not ctype.h. Use
uppercase ctype macros. Don't test ISUPPER(c)/ISLOWER(c)
before calling TOLOWER(c)/TOUPPER(c).
2000-12-07 Mike Stump <mrs@wrs.com>
* Makefile.in (distclean): When cleaning, remove testsuite.
......@@ -13,7 +25,7 @@
* cplus-dem.c: Likewise.
(current_demangling_style): Now auto_demangling.
(cplus_demangle): Try v3 demangling if AUTO_DEMANGLING.
(main): Use standard symbol chars for auto_demangling.
(main): Use standard symbol chars for auto_demangling.
2000-11-26 Mark Mitchell <mark@codesourcery.com>
......
......@@ -128,22 +128,22 @@ CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c \
bzero.c calloc.c choose-temp.c clock.c concat.c cplus-dem.c \
cp-demangle.c dyn-string.c fdmatch.c fnmatch.c getcwd.c \
getpwd.c getopt.c getopt1.c getpagesize.c getruntime.c \
floatformat.c hashtab.c hex.c index.c insque.c md5.c memchr.c memcmp.c\
memcpy.c memmove.c memset.c mkstemps.c objalloc.c obstack.c \
floatformat.c hashtab.c hex.c index.c insque.c md5.c memchr.c \
memcmp.c memcpy.c memmove.c memset.c mkstemps.c objalloc.c obstack.c \
partition.c pexecute.c putenv.c random.c rename.c rindex.c setenv.c \
sigsetmask.c sort.c spaces.c splay-tree.c strcasecmp.c strncasecmp.c \
strchr.c strdup.c strerror.c strncmp.c strrchr.c strsignal.c strstr.c \
strtod.c strtol.c strtoul.c tmpnam.c vasprintf.c vfork.c vfprintf.c \
vprintf.c vsprintf.c waitpid.c xatexit.c xexit.c xmalloc.c \
xmemdup.c xstrdup.c xstrerror.c
sigsetmask.c safe-ctype.c sort.c spaces.c splay-tree.c strcasecmp.c \
strncasecmp.c strchr.c strdup.c strerror.c strncmp.c strrchr.c \
strsignal.c strstr.c strtod.c strtol.c strtoul.c tmpnam.c vasprintf.c \
vfork.c vfprintf.c vprintf.c vsprintf.c waitpid.c xatexit.c xexit.c \
xmalloc.c xmemdup.c xstrdup.c xstrerror.c
# These are always included in the library.
REQUIRED_OFILES = argv.o choose-temp.o concat.o cplus-dem.o cp-demangle.o \
dyn-string.o fdmatch.o fnmatch.o getopt.o getopt1.o getpwd.o \
REQUIRED_OFILES = argv.o choose-temp.o concat.o cplus-dem.o cp-demangle.o \
dyn-string.o fdmatch.o fnmatch.o getopt.o getopt1.o getpwd.o \
getruntime.o hashtab.o hex.o floatformat.o md5.o objalloc.o obstack.o \
partition.o pexecute.o sort.o spaces.o splay-tree.o strerror.o \
strsignal.o xatexit.o xexit.o xmalloc.o xmemdup.o xstrdup.o \
xstrerror.o
partition.o pexecute.o safe-ctype.o sort.o spaces.o splay-tree.o \
strerror.o strsignal.o xatexit.o xexit.o xmalloc.o xmemdup.o \
xstrdup.o xstrerror.o
$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
rm -f $(TARGETLIB)
......
......@@ -25,10 +25,7 @@ Boston, MA 02111-1307, USA. */
#include "ansidecl.h"
#include "libiberty.h"
#ifdef isspace
#undef isspace
#endif
#define isspace(ch) ((ch) == ' ' || (ch) == '\t')
#define ISBLANK(ch) ((ch) == ' ' || (ch) == '\t')
/* Routines imported from standard C runtime libraries. */
......@@ -227,7 +224,7 @@ char *input;
do
{
/* Pick off argv[argc] */
while (isspace (*input))
while (ISBLANK (*input))
{
input++;
}
......@@ -260,7 +257,7 @@ char *input;
arg = copybuf;
while (*input != EOS)
{
if (isspace (*input) && !squote && !dquote && !bsquote)
if (ISBLANK (*input) && !squote && !dquote && !bsquote)
{
break;
}
......@@ -326,7 +323,7 @@ char *input;
argc++;
argv[argc] = NULL;
while (isspace (*input))
while (ISBLANK (*input))
{
input++;
}
......
......@@ -20,7 +20,7 @@ BUGS
#include "ansidecl.h"
#include "libiberty.h"
#include <ctype.h>
#include "safe-ctype.h"
#ifndef DIR_SEPARATOR
#define DIR_SEPARATOR '/'
......@@ -50,7 +50,7 @@ basename (name)
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
/* Skip over the disk name in MSDOS pathnames. */
if (isalpha (name[0]) && name[1] == ':')
if (ISALPHA (name[0]) && name[1] == ':')
name += 2;
#endif
......
......@@ -34,7 +34,8 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#endif
#include <ctype.h>
#include "safe-ctype.h"
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
......@@ -544,10 +545,10 @@ consume_count (type)
{
int count = 0;
if (! isdigit ((unsigned char)**type))
if (! ISDIGIT ((unsigned char)**type))
return -1;
while (isdigit ((unsigned char)**type))
while (ISDIGIT ((unsigned char)**type))
{
count *= 10;
......@@ -558,7 +559,7 @@ consume_count (type)
ten. */
if ((count % 10) != 0)
{
while (isdigit ((unsigned char) **type))
while (ISDIGIT ((unsigned char) **type))
(*type)++;
return -1;
}
......@@ -584,7 +585,7 @@ consume_count_with_underscores (mangled)
if (**mangled == '_')
{
(*mangled)++;
if (!isdigit ((unsigned char)**mangled))
if (!ISDIGIT ((unsigned char)**mangled))
return -1;
idx = consume_count (mangled);
......@@ -716,8 +717,8 @@ cplus_demangle_opname (opname, result, options)
}
}
else if (opname[0] == '_' && opname[1] == '_'
&& islower((unsigned char)opname[2])
&& islower((unsigned char)opname[3]))
&& ISLOWER((unsigned char)opname[2])
&& ISLOWER((unsigned char)opname[3]))
{
if (opname[4] == '\0')
{
......@@ -1003,8 +1004,8 @@ ada_demangle (mangled, option)
sizeof (char));
demangled = demangling_buffer;
if (isdigit ((unsigned char) mangled[len0 - 1])) {
for (i = len0 - 2; i >= 0 && isdigit ((unsigned char) mangled[i]); i -= 1)
if (ISDIGIT ((unsigned char) mangled[len0 - 1])) {
for (i = len0 - 2; i >= 0 && ISDIGIT ((unsigned char) mangled[i]); i -= 1)
;
if (i > 1 && mangled[i] == '_' && mangled[i - 1] == '_')
{
......@@ -1018,7 +1019,7 @@ ada_demangle (mangled, option)
}
}
for (i = 0, j = 0; i < len0 && ! isalpha ((unsigned char)mangled[i]);
for (i = 0, j = 0; i < len0 && ! ISALPHA ((unsigned char)mangled[i]);
i += 1, j += 1)
demangled[j] = mangled[i];
......@@ -1042,7 +1043,7 @@ ada_demangle (mangled, option)
demangled[j] = '\000';
for (i = 0; demangled[i] != '\0'; i += 1)
if (isupper ((unsigned char)demangled[i]) || demangled[i] == ' ')
if (ISUPPER ((unsigned char)demangled[i]) || demangled[i] == ' ')
goto Suppress;
if (! changed)
......@@ -1532,7 +1533,7 @@ demangle_signature (work, mangled, declp)
if (HP_DEMANGLING)
{
(*mangled)++;
while (**mangled && isdigit ((unsigned char)**mangled))
while (**mangled && ISDIGIT ((unsigned char)**mangled))
(*mangled)++;
}
else
......@@ -1865,7 +1866,7 @@ demangle_real_value (work, mangled, s)
string_appendn (s, "-", 1);
(*mangled)++;
}
while (isdigit ((unsigned char)**mangled))
while (ISDIGIT ((unsigned char)**mangled))
{
string_appendn (s, *mangled, 1);
(*mangled)++;
......@@ -1874,7 +1875,7 @@ demangle_real_value (work, mangled, s)
{
string_appendn (s, ".", 1);
(*mangled)++;
while (isdigit ((unsigned char)**mangled))
while (ISDIGIT ((unsigned char)**mangled))
{
string_appendn (s, *mangled, 1);
(*mangled)++;
......@@ -1884,7 +1885,7 @@ demangle_real_value (work, mangled, s)
{
string_appendn (s, "e", 1);
(*mangled)++;
while (isdigit ((unsigned char)**mangled))
while (ISDIGIT ((unsigned char)**mangled))
{
string_appendn (s, *mangled, 1);
(*mangled)++;
......@@ -2735,20 +2736,20 @@ demangle_prefix (work, mangled, declp)
}
else if (work -> static_type)
{
if (!isdigit ((unsigned char)scan[0]) && (scan[0] != 't'))
if (!ISDIGIT ((unsigned char)scan[0]) && (scan[0] != 't'))
{
success = 0;
}
}
else if ((scan == *mangled)
&& (isdigit ((unsigned char)scan[2]) || (scan[2] == 'Q')
&& (ISDIGIT ((unsigned char)scan[2]) || (scan[2] == 'Q')
|| (scan[2] == 't') || (scan[2] == 'K') || (scan[2] == 'H')))
{
/* The ARM says nothing about the mangling of local variables.
But cfront mangles local variables by prepending __<nesting_level>
to them. As an extension to ARM demangling we handle this case. */
if ((LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING)
&& isdigit ((unsigned char)scan[2]))
&& ISDIGIT ((unsigned char)scan[2]))
{
*mangled = scan + 2;
consume_count (mangled);
......@@ -2785,7 +2786,7 @@ demangle_prefix (work, mangled, declp)
/* EDG template? */
demangle_arm_hp_template (work, mangled, strlen (*mangled), declp);
}
else if ((scan == *mangled) && !isdigit ((unsigned char)scan[2])
else if ((scan == *mangled) && !ISDIGIT ((unsigned char)scan[2])
&& (scan[2] != 't'))
{
/* Mangled name starts with "__". Skip over any leading '_' characters,
......@@ -2907,7 +2908,7 @@ gnu_special (work, mangled, declp)
1);
break;
default:
if (isdigit((unsigned char)*mangled[0]))
if (ISDIGIT((unsigned char)*mangled[0]))
{
n = consume_count(mangled);
/* We may be seeing a too-large size, or else a
......@@ -3434,13 +3435,13 @@ get_count (type, count)
const char *p;
int n;
if (!isdigit ((unsigned char)**type))
if (!ISDIGIT ((unsigned char)**type))
return (0);
else
{
*count = **type - '0';
(*type)++;
if (isdigit ((unsigned char)**type))
if (ISDIGIT ((unsigned char)**type))
{
p = *type;
n = *count;
......@@ -3450,7 +3451,7 @@ get_count (type, count)
n += *p - '0';
p++;
}
while (isdigit ((unsigned char)*p));
while (ISDIGIT ((unsigned char)*p));
if (*p == '_')
{
*type = p + 1;
......@@ -3580,7 +3581,7 @@ do_type (work, mangled, result)
if (**mangled != 'Q')
string_prepend (&decl, SCOPE_STRING (work));
if (isdigit ((unsigned char)**mangled))
if (ISDIGIT ((unsigned char)**mangled))
{
n = consume_count (mangled);
if (n == -1
......@@ -3900,7 +3901,7 @@ demangle_fund_type (work, mangled, result)
break;
case 'G':
(*mangled)++;
if (!isdigit ((unsigned char)**mangled))
if (!ISDIGIT ((unsigned char)**mangled))
{
success = 0;
break;
......@@ -4012,12 +4013,12 @@ do_hpacc_template_const_value (work, mangled, result)
}
/* We have to be looking at an integer now */
if (!(isdigit ((unsigned char)**mangled)))
if (!(ISDIGIT ((unsigned char)**mangled)))
return 0;
/* We only deal with integral values for template
parameters -- so it's OK to look only for digits */
while (isdigit ((unsigned char)**mangled))
while (ISDIGIT ((unsigned char)**mangled))
{
char_str[0] = **mangled;
string_append (result, char_str);
......@@ -4096,10 +4097,10 @@ snarf_numeric_literal (args, arg)
else if (**args == '+')
(*args)++;
if (!isdigit ((unsigned char)**args))
if (!ISDIGIT ((unsigned char)**args))
return 0;
while (isdigit ((unsigned char)**args))
while (ISDIGIT ((unsigned char)**args))
{
char_str[0] = **args;
string_append (arg, char_str);
......@@ -4663,8 +4664,8 @@ demangle_function_name (work, mangled, declp, scan)
}
}
else if (declp->b[0] == '_' && declp->b[1] == '_'
&& islower((unsigned char)declp->b[2])
&& islower((unsigned char)declp->b[3]))
&& ISLOWER((unsigned char)declp->b[2])
&& ISLOWER((unsigned char)declp->b[3]))
{
if (declp->b[4] == '\0')
{
......@@ -5125,7 +5126,7 @@ main (argc, argv)
int i = 0;
c = getchar ();
/* Try to read a label. */
while (c != EOF && (isalnum (c) || strchr (valid_symbols, c)))
while (c != EOF && (ISALNUM (c) || strchr (valid_symbols, c)))
{
if (i >= MBUF_SIZE-1)
break;
......
......@@ -45,8 +45,7 @@ Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
#include <safe-ctype.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
......@@ -74,8 +73,7 @@ fnmatch (pattern, string, flags)
register const char *p = pattern, *n = string;
register unsigned char c;
/* Note that this evalutes C many times. */
#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
#define FOLD(c) ((flags & FNM_CASEFOLD) ? TOLOWER (c) : (c))
while ((c = *p++) != '\0')
{
......
......@@ -41,12 +41,12 @@ extern int errno;
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#define ISSPACE (x) isspace(x)
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include "libiberty.h"
#include "safe-ctype.h"
/* stdin file number. */
#define STDIN_FILE_NO 0
......
/* <ctype.h> replacement macros.
Copyright (C) 2000 Free Software Foundation, Inc.
Contributed by Zack Weinberg <zackw@stanford.edu>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* This is a compatible replacement of the standard C library's <ctype.h>
with the following properties:
- Implements all isxxx() macros required by C99.
- Also implements some character classes useful when
parsing C-like languages.
- Does not change behavior depending on the current locale.
- Behaves properly for all values in the range of a signed or
unsigned char. */
#include <safe-ctype.h>
#include <stdio.h> /* for EOF */
/* Shorthand */
#define bl _sch_isblank
#define cn _sch_iscntrl
#define di _sch_isdigit
#define is _sch_isidst
#define lo _sch_islower
#define nv _sch_isnvsp
#define pn _sch_ispunct
#define pr _sch_isprint
#define sp _sch_isspace
#define up _sch_isupper
#define vs _sch_isvsp
#define xd _sch_isxdigit
/* Masks. */
#define L lo|is |pr /* lower case letter */
#define XL lo|is|xd|pr /* lowercase hex digit */
#define U up|is |pr /* upper case letter */
#define XU up|is|xd|pr /* uppercase hex digit */
#define D di |xd|pr /* decimal digit */
#define P pn |pr /* punctuation */
#define _ pn|is |pr /* underscore */
#define C cn /* control character */
#define Z nv |cn /* NUL */
#define M nv|sp |cn /* cursor movement: \f \v */
#define V vs|sp |cn /* vertical space: \r \n */
#define T nv|sp|bl|cn /* tab */
#define S nv|sp|bl|pr /* space */
/* Are we ASCII? */
#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 \
&& EOF == -1
const unsigned short _sch_istable[256] =
{
Z, C, C, C, C, C, C, C, /* NUL SOH STX ETX EOT ENQ ACK BEL */
C, T, V, M, M, V, C, C, /* BS HT LF VT FF CR SO SI */
C, C, C, C, C, C, C, C, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
C, C, C, C, C, C, C, C, /* CAN EM SUB ESC FS GS RS US */
S, P, P, P, P, P, P, P, /* SP ! " # $ % & ' */
P, P, P, P, P, P, P, P, /* ( ) * + , - . / */
D, D, D, D, D, D, D, D, /* 0 1 2 3 4 5 6 7 */
D, D, P, P, P, P, P, P, /* 8 9 : ; < = > ? */
P, XU, XU, XU, XU, XU, XU, U, /* @ A B C D E F G */
U, U, U, U, U, U, U, U, /* H I J K L M N O */
U, U, U, U, U, U, U, U, /* P Q R S T U V W */
U, U, U, P, P, P, P, _, /* X Y Z [ \ ] ^ _ */
P, XL, XL, XL, XL, XL, XL, L, /* ` a b c d e f g */
L, L, L, L, L, L, L, L, /* h i j k l m n o */
L, L, L, L, L, L, L, L, /* p q r s t u v w */
L, L, L, P, P, P, P, C, /* x y z { | } ~ DEL */
/* high half of unsigned char is locale-specific, so all tests are
false in "C" locale */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const unsigned char _sch_tolower[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64,
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
91, 92, 93, 94, 95, 96,
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
123,124,125,126,127,
128,129,130,131, 132,133,134,135, 136,137,138,139, 140,141,142,143,
144,145,146,147, 148,149,150,151, 152,153,154,155, 156,157,158,159,
160,161,162,163, 164,165,166,167, 168,169,170,171, 172,173,174,175,
176,177,178,179, 180,181,182,183, 184,185,186,187, 188,189,190,191,
192,193,194,195, 196,197,198,199, 200,201,202,203, 204,205,206,207,
208,209,210,211, 212,213,214,215, 216,217,218,219, 220,221,222,223,
224,225,226,227, 228,229,230,231, 232,233,234,235, 236,237,238,239,
240,241,242,243, 244,245,246,247, 248,249,250,251, 252,253,254,255,
};
const unsigned char _sch_toupper[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64,
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
91, 92, 93, 94, 95, 96,
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
123,124,125,126,127,
128,129,130,131, 132,133,134,135, 136,137,138,139, 140,141,142,143,
144,145,146,147, 148,149,150,151, 152,153,154,155, 156,157,158,159,
160,161,162,163, 164,165,166,167, 168,169,170,171, 172,173,174,175,
176,177,178,179, 180,181,182,183, 184,185,186,187, 188,189,190,191,
192,193,194,195, 196,197,198,199, 200,201,202,203, 204,205,206,207,
208,209,210,211, 212,213,214,215, 216,217,218,219, 220,221,222,223,
224,225,226,227, 228,229,230,231, 232,233,234,235, 236,237,238,239,
240,241,242,243, 244,245,246,247, 248,249,250,251, 252,253,254,255,
};
#else
#error "Unsupported host character set"
#endif /* not ASCII */
......@@ -22,7 +22,7 @@ the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
#include <ctype.h>
#include "safe-ctype.h"
extern double atof ();
......@@ -42,7 +42,7 @@ strtod (str, ptr)
p = str;
while (isspace (*p))
while (ISSPACE (*p))
++p;
if (*p == '+' || *p == '-')
......@@ -88,10 +88,10 @@ strtod (str, ptr)
}
/* digits, with 0 or 1 periods in it. */
if (isdigit (*p) || *p == '.')
if (ISDIGIT (*p) || *p == '.')
{
int got_dot = 0;
while (isdigit (*p) || (!got_dot && *p == '.'))
while (ISDIGIT (*p) || (!got_dot && *p == '.'))
{
if (*p == '.')
got_dot = 1;
......@@ -105,9 +105,9 @@ strtod (str, ptr)
i = 1;
if (p[i] == '+' || p[i] == '-')
++i;
if (isdigit (p[i]))
if (ISDIGIT (p[i]))
{
while (isdigit (p[i]))
while (ISDIGIT (p[i]))
++i;
*ptr = p + i;
return atof (str);
......
......@@ -37,15 +37,11 @@
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <ctype.h>
#include <errno.h>
#ifdef NEED_DECLARATION_ERRNO
extern int errno;
#endif
#if 0
#include <stdlib.h>
#endif
#include "ansidecl.h"
#include "safe-ctype.h"
/* FIXME: It'd be nice to configure around these, but the include files are too
painful. These macros should at least be more portable than hardwired hex
......@@ -88,7 +84,7 @@ strtol(nptr, endptr, base)
*/
do {
c = *s++;
} while (isspace(c));
} while (ISSPACE(c));
if (c == '-') {
neg = 1;
c = *s++;
......@@ -124,10 +120,10 @@ strtol(nptr, endptr, base)
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
if (isdigit(c))
if (ISDIGIT(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else if (ISALPHA(c))
c -= ISUPPER(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
......
......@@ -74,7 +74,7 @@ strtoul(nptr, endptr, base)
*/
do {
c = *s++;
} while (isspace(c));
} while (ISSPACE(c));
if (c == '-') {
neg = 1;
c = *s++;
......@@ -91,10 +91,10 @@ strtoul(nptr, endptr, base)
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
if (isdigit(c))
if (ISDIGIT(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else if (ISALPHA(c))
c -= ISUPPER(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
......
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