public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: egcs-19980425, system.h stuff part 4/6
@ 1998-05-04 15:53 Kaveh R. Ghazi
  1998-05-04 18:07 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Kaveh R. Ghazi @ 1998-05-04 15:53 UTC (permalink / raw)
  To: rth; +Cc: egcs

 > From: Richard Henderson <rth@dot.cygnus.com>
 > 
 > On Fri, May 01, 1998 at 08:37:12PM -0400, Kaveh R. Ghazi wrote:
 > > -    if (retried && isalpha(*(U_CHAR *) (--fbeg))) {
 > > -      while (fin != limit && (!isspace(*fin)))
 > > +    if (retried && --fbeg && ISALPHA(*(U_CHAR *) (fbeg))) {
 > > +      while (fin != limit && (!ISSPACE(*fin)))
 > 
 > Nope.  The correct transformation would be
 > 
 > 	if (retried && (--fbeg, ISALPHA(*(U_CHAR *) (fbeg))))
 > 
 > as in the original, the value of fbeg is not tested at all.
 > r~

	Ah, very nice.  My original thought had been that `fbeg' is
always always non-NULL (else the dereference would SEGV) so the
comparison was always true.  However your solution is much better. 
Thanks for reviewing my patch, I'll include your correction.  Are all 6
parts okay to install?

		--Kaveh

--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: egcs-19980425, system.h stuff part 4/6
  1998-05-04 15:53 egcs-19980425, system.h stuff part 4/6 Kaveh R. Ghazi
@ 1998-05-04 18:07 ` Richard Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 1998-05-04 18:07 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: rth, egcs

On Mon, May 04, 1998 at 03:52:25PM -0400, Kaveh R. Ghazi wrote:
> 	Ah, very nice.  My original thought had been that `fbeg' is
> always always non-NULL (else the dereference would SEGV) so the
> comparison was always true.  However your solution is much better. 
> Thanks for reviewing my patch, I'll include your correction.  Are all 6
> parts okay to install?

They look perfectly straightforward to me.  I'd say unless you hear
someone speak up in the next day or so with objections, go ahead and
install them.


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: egcs-19980425, system.h stuff part 4/6
  1998-05-01 21:25 Kaveh R. Ghazi
@ 1998-05-02 10:47 ` Richard Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 1998-05-02 10:47 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: egcs

On Fri, May 01, 1998 at 08:37:12PM -0400, Kaveh R. Ghazi wrote:
> -    if (retried && isalpha(*(U_CHAR *) (--fbeg))) {
> -      while (fin != limit && (!isspace(*fin)))
> +    if (retried && --fbeg && ISALPHA(*(U_CHAR *) (fbeg))) {
> +      while (fin != limit && (!ISSPACE(*fin)))

Nope.  The correct transformation would be

	if (retried && (--fbeg, ISALPHA(*(U_CHAR *) (fbeg))))

as in the original, the value of fbeg is not tested at all.


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* egcs-19980425, system.h stuff part 4/6
@ 1998-05-01 21:25 Kaveh R. Ghazi
  1998-05-02 10:47 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Kaveh R. Ghazi @ 1998-05-01 21:25 UTC (permalink / raw)
  To: egcs

	This is part 4/6.  Note, I only found one instance where the
argument to a ctype macro had side effects.  This was in cccp.c.
Please double check that I preserved the correct behavior of that
code.  (Some of the patches listed in the ChangeLog are in part 5.)



Fri May  1 15:56:40 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* c-common.c: Convert to using ctype macros defined in system.h.
	* c-lex.c: Likewise.
	* cccp.c: Likewise.
	* collect2.c: Likewise.
	* rs6000.c: Likewise.
	* cpplib.c: Likewise.
	* fix-header.c: Likewise.
	* gcc.c: Likewise.
	* gen-protos.c: Likewise.
	* pexecute.c: Likewise.
	* protoize.c: Likewise.
	* rtl.c: Likewise.
	* scan.c: Likewise.
	* stmt.c: Likewise.
	* tlink.c: Likewise.
	* toplev.c: Likewise.	

diff -rup orig/egcs-19980425/gcc/c-common.c egcs-19980425/gcc/c-common.c
--- orig/egcs-19980425/gcc/c-common.c	Fri Apr 24 02:27:03 1998
+++ egcs-19980425/gcc/c-common.c	Fri May  1 15:00:28 1998
@@ -1350,7 +1350,7 @@ check_format_info (info, params)
 	  suppressed = *format_chars == '*';
 	  if (suppressed)
 	    ++format_chars;
-	  while (isdigit (*format_chars))
+	  while (ISDIGIT (*format_chars))
 	    ++format_chars;
 	}
       else if (info->format_type == strftime_format_type)
@@ -1373,7 +1373,7 @@ check_format_info (info, params)
 		  flag_chars[i] = 0;
 		}
 	    }
-	  while (isdigit ((unsigned char) *format_chars))
+	  while (ISDIGIT ((unsigned char) *format_chars))
 	    {
 	      wide = TRUE;
               ++format_chars;
@@ -1474,7 +1474,7 @@ check_format_info (info, params)
 	    }
 	  else
 	    {
-	      while (isdigit (*format_chars))
+	      while (ISDIGIT (*format_chars))
 		{
 		  wide = TRUE;
 		  ++format_chars;
@@ -1484,7 +1484,7 @@ check_format_info (info, params)
 	    {
 	      precise = TRUE;
 	      ++format_chars;
-	      if (*format_chars != '*' && !isdigit (*format_chars))
+	      if (*format_chars != '*' && !ISDIGIT (*format_chars))
 		warning ("`.' not followed by `*' or digit in format");
 	      /* "...a...precision...may be indicated by an asterisk.
 		 In this case, an int argument supplies the...precision."  */
@@ -1509,7 +1509,7 @@ check_format_info (info, params)
 		}
 	      else
 		{
-		  while (isdigit (*format_chars))
+		  while (ISDIGIT (*format_chars))
 		    ++format_chars;
 		}
 	    }
diff -rup orig/egcs-19980425/gcc/c-lex.c egcs-19980425/gcc/c-lex.c
--- orig/egcs-19980425/gcc/c-lex.c	Thu Apr 16 18:22:43 1998
+++ egcs-19980425/gcc/c-lex.c	Fri May  1 15:01:02 1998
@@ -1254,7 +1254,7 @@ yylex ()
     case '$':
     letter:
       p = token_buffer;
-      while (isalnum (c) || c == '_' || c == '$' || c == '@')
+      while (ISALNUM (c) || c == '_' || c == '$' || c == '@')
 	{
 	  /* Make sure this char really belongs in an identifier.  */
 	  if (c == '@' && ! doing_objc_thang)
@@ -1366,7 +1366,7 @@ yylex ()
 
 	next_c = GETC ();
 	UNGETC (next_c);	/* Always undo this lookahead.  */
-	if (!isalnum (next_c) && next_c != '.')
+	if (!ISALNUM (next_c) && next_c != '.')
 	  {
 	    token_buffer[0] = (char)c,  token_buffer[1] = '\0';
 	    yylval.ttype = (c == '0') ? integer_zero_node : integer_one_node;
@@ -1423,7 +1423,7 @@ yylex ()
 	/* Read all the digits-and-decimal-points.  */
 
 	while (c == '.'
-	       || (isalnum (c) && c != 'l' && c != 'L'
+	       || (ISALNUM (c) && c != 'l' && c != 'L'
 		   && c != 'u' && c != 'U'
 		   && c != 'i' && c != 'I' && c != 'j' && c != 'J'
 		   && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
@@ -1452,7 +1452,7 @@ yylex ()
 		   only when it is followed by a digit.
 		   Otherwise, unread the following non-digit
 		   and use the '.' as a structural token.  */
-		if (p == token_buffer + 2 && !isdigit (c))
+		if (p == token_buffer + 2 && !ISDIGIT (c))
 		  {
 		    if (c == '.')
 		      {
@@ -1476,7 +1476,7 @@ yylex ()
 		/* It is not a decimal point.
 		   It should be a digit (perhaps a hex digit).  */
 
-		if (isdigit (c))
+		if (ISDIGIT (c))
 		  {
 		    c = c - '0';
 		  }
@@ -1558,9 +1558,9 @@ yylex ()
 		    *p++ = c;
 		    c = GETC();
 		  }
-		if (! isdigit (c))
+		if (! ISDIGIT (c))
 		  error ("floating constant exponent has no digits");
-	        while (isdigit (c))
+	        while (ISDIGIT (c))
 		  {
 		    if (p >= token_buffer + maxtoken - 3)
 		      p = extend_token_buffer (p);
@@ -1875,7 +1875,7 @@ yylex ()
 	UNGETC (c);
 	*p = 0;
 
-	if (isalnum (c) || c == '.' || c == '_' || c == '$'
+	if (ISALNUM (c) || c == '.' || c == '_' || c == '$'
 	    || (!flag_traditional && (c == '-' || c == '+')
 		&& (p[-1] == 'e' || p[-1] == 'E')))
 	  error ("missing white space after number `%s'", token_buffer);
@@ -1922,7 +1922,7 @@ yylex ()
 		    && (unsigned) c >= (1 << width))
 		  pedwarn ("escape sequence out of range for character");
 #ifdef MAP_CHARACTER
-		if (isprint (c))
+		if (ISPRINT (c))
 		  c = MAP_CHARACTER (c);
 #endif
 	      }
diff -rup orig/egcs-19980425/gcc/cccp.c egcs-19980425/gcc/cccp.c
--- orig/egcs-19980425/gcc/cccp.c	Mon Apr  6 10:01:23 1998
+++ egcs-19980425/gcc/cccp.c	Fri May  1 15:01:25 1998
@@ -1725,7 +1725,7 @@ main (argc, argv)
 
 	if (*vers == 'V')
 	  vers++;
-	if (isdigit (*vers))
+	if (ISDIGIT (*vers))
 	  {
 	    vms_version_value = (*vers - '0') * 10000000;
 	  }
@@ -1733,7 +1733,7 @@ main (argc, argv)
 	if (*vers == '.')
 	  {
 	    vers++;
-	    if (isdigit (*vers))
+	    if (ISDIGIT (*vers))
 	      {
 		vms_version_value += (*vers - '0') * 100000;
 	      }
@@ -2478,10 +2478,10 @@ get_lintcmd (ibp, limit, argstart, argle
   if ((linsize >= 7) && !bcmp (ibp, "VARARGS", 7)) {
     *cmdlen = 7;
     ibp += 7; linsize -= 7;
-    if ((linsize == 0) || ! isdigit (*ibp)) return "VARARGS";
+    if ((linsize == 0) || ! ISDIGIT (*ibp)) return "VARARGS";
 
     /* OK, read a number */
-    for (numptr = *argstart = ibp; (numptr < limit) && isdigit (*numptr);
+    for (numptr = *argstart = ibp; (numptr < limit) && ISDIGIT (*numptr);
 	 numptr++);
     *arglen = numptr - *argstart;
     return "VARARGS";
@@ -4353,8 +4353,8 @@ get_filename:
      * code from case '<' is repeated here) and generates a warning.
      * (Note: macro expansion of `xyz' takes precedence.)
      */
-    if (retried && isalpha(*(U_CHAR *) (--fbeg))) {
-      while (fin != limit && (!isspace(*fin)))
+    if (retried && --fbeg && ISALPHA(*(U_CHAR *) (fbeg))) {
+      while (fin != limit && (!ISSPACE(*fin)))
 	*fend++ = *fin++;
       warning ("VAX-C-style include specification found, use '#include <filename.h>' !");
       vaxc_include = 1;
@@ -4648,7 +4648,7 @@ base_name (fname)
   char *s = fname;
   char *p;
 #if defined (__MSDOS__) || defined (_WIN32)
-  if (isalpha (s[0]) && s[1] == ':') s += 2;
+  if (ISALPHA (s[0]) && s[1] == ':') s += 2;
 #endif
 #ifdef VMS
   if ((p = rindex (s, ':'))) s = p + 1;	/* Skip device.  */
@@ -4671,11 +4671,11 @@ absolute_filename (filename)
      char *filename;
 {
 #if defined (__MSDOS__) || (defined (_WIN32) && !defined (__CYGWIN32__))
-  if (isalpha (filename[0]) && filename[1] == ':') filename += 2;
+  if (ISALPHA (filename[0]) && filename[1] == ':') filename += 2;
 #endif
 #if defined (__CYGWIN32__)
   /* At present, any path that begins with a drive spec is absolute.  */
-  if (isalpha (filename[0]) && filename[1] == ':') return 1;
+  if (ISALPHA (filename[0]) && filename[1] == ':') return 1;
 #endif
   if (filename[0] == '/') return 1;
 #ifdef DIR_SEPARATOR
@@ -6603,7 +6603,7 @@ do_line (buf, limit, op, keyword)
   bp = tem.buf;
   SKIP_WHITE_SPACE (bp);
 
-  if (!isdigit (*bp)) {
+  if (!ISDIGIT (*bp)) {
     error ("invalid format `#line' directive");
     return 0;
   }
@@ -6618,7 +6618,7 @@ do_line (buf, limit, op, keyword)
     pedwarn ("line number out of range in `#line' directive");
 
   /* skip over the line number.  */
-  while (isdigit (*bp))
+  while (ISDIGIT (*bp))
     bp++;
 
 #if 0 /* #line 10"foo.c" is supposed to be allowed.  */
@@ -7100,7 +7100,7 @@ do_xifdef (buf, limit, op, keyword)
     HASHNODE *hp;
 
     if (! traditional) {
-      if (isdigit (buf[0]))
+      if (ISDIGIT (buf[0]))
 	pedwarn ("`#%s' argument starts with a digit", keyword->name);
       else if (end != limit)
 	pedwarn ("garbage at end of `#%s' argument", keyword->name);
@@ -7844,7 +7844,7 @@ quote_string (dst, src, srclen)
     switch ((c = *src++))
       {
       default:
-        if (isprint (c))
+        if (ISPRINT (c))
 	  *dst++ = c;
 	else
 	  {
diff -rup orig/egcs-19980425/gcc/collect2.c egcs-19980425/gcc/collect2.c
--- orig/egcs-19980425/gcc/collect2.c	Mon Apr  6 16:51:28 1998
+++ egcs-19980425/gcc/collect2.c	Fri May  1 15:02:02 1998
@@ -565,7 +565,7 @@ dump_file (name)
     {
       int c;
       while (c = getc (stream),
-	     c != EOF && (isalnum (c) || c == '_' || c == '$' || c == '.'))
+	     c != EOF && (ISALNUM (c) || c == '_' || c == '$' || c == '.'))
 	obstack_1grow (&temporary_obstack, c);
       if (obstack_object_size (&temporary_obstack) > 0)
 	{
@@ -1853,7 +1853,7 @@ write_c_file_stat (stream, name)
   strncpy (prefix, p, q - p);
   prefix[q - p] = 0;
   for (q = prefix; *q; q++)
-    if (!isalnum (*q))
+    if (!ISALNUM (*q))
       *q = '_';
   if (debug)
     fprintf (stderr, "\nwrite_c_file - output name is %s, prefix is %s\n",
@@ -2169,7 +2169,7 @@ scan_prog_file (prog_name, which_pass)
       name = p;
       /* Find the end of the symbol name.
 	 Do not include `|', because Encore nm can tack that on the end.  */
-      for (end = p; (ch2 = *end) != '\0' && !isspace (ch2) && ch2 != '|';
+      for (end = p; (ch2 = *end) != '\0' && !ISSPACE (ch2) && ch2 != '|';
 	   end++)
 	continue;
 
@@ -2303,7 +2303,7 @@ libcompare (d1, d2)
   char *e2 = (*d2)->d_name + i2;
 
   while (*e1 && *e2 && *e1 == '.' && *e2 == '.'
-	 && e1[1] && isdigit (e1[1]) && e2[1] && isdigit (e2[1]))
+	 && e1[1] && ISDIGIT (e1[1]) && e2[1] && ISDIGIT (e2[1]))
     {
       ++e1;
       ++e2;
@@ -2316,7 +2316,7 @@ libcompare (d1, d2)
   if (*e1)
     {
       /* It has a valid numeric extension, prefer this one.  */
-      if (*e1 == '.' && e1[1] && isdigit (e1[1]))
+      if (*e1 == '.' && e1[1] && ISDIGIT (e1[1]))
 	return 1;
       /* It has a invalid numeric extension, must prefer the other one.  */
       else
@@ -2325,7 +2325,7 @@ libcompare (d1, d2)
   else if (*e2)
     {
       /* It has a valid numeric extension, prefer this one.  */
-      if (*e2 == '.' && e2[1] && isdigit (e2[1]))
+      if (*e2 == '.' && e2[1] && ISDIGIT (e2[1]))
 	return -1;
       /* It has a invalid numeric extension, must prefer the other one.  */
       else
@@ -2609,7 +2609,7 @@ scan_libraries (prog_name)
 
       /* Find the end of the symbol name.  */
       for (end = p; 
-	   (ch2 = *end) != '\0' && ch2 != '\n' && !isspace (ch2) && ch2 != '|';
+	   (ch2 = *end) != '\0' && ch2 != '\n' && !ISSPACE (ch2) && ch2 != '|';
 	   end++)
 	continue;
       *end = '\0';
diff -rup orig/egcs-19980425/gcc/config/rs6000/rs6000.c egcs-19980425/gcc/config/rs6000/rs6000.c
--- orig/egcs-19980425/gcc/config/rs6000/rs6000.c	Sat Apr 18 12:16:01 1998
+++ egcs-19980425/gcc/config/rs6000/rs6000.c	Fri May  1 14:46:03 1998
@@ -4450,7 +4450,7 @@ rs6000_gen_section_name (buf, filename, 
 	  p += strlen (section_desc);
         }
 
-      else if (isalnum (*q))
+      else if (ISALNUM (*q))
         *p++ = *q;
     }
 
diff -rup orig/egcs-19980425/gcc/cpplib.c egcs-19980425/gcc/cpplib.c
--- orig/egcs-19980425/gcc/cpplib.c	Sat Apr  4 12:37:41 1998
+++ egcs-19980425/gcc/cpplib.c	Fri May  1 15:03:17 1998
@@ -467,7 +467,7 @@ quote_string (pfile, src)
     switch ((c = *src++))
       {
       default:
-        if (isprint (c))
+        if (ISPRINT (c))
 	  CPP_PUTC_Q (pfile, c);
 	else
 	  {
@@ -2774,7 +2774,7 @@ macroexpand (pfile, hp)
 		      /* Escape these chars */
 		      if (c == '\"' || (in_string && c == '\\'))
 			CPP_PUTC (pfile, '\\');
-		      if (isprint (c))
+		      if (ISPRINT (c))
 			CPP_PUTC (pfile, c);
 		      else
 			{
@@ -3687,7 +3687,7 @@ do_line (pfile, keyword)
   token = get_directive_token (pfile);
 
   if (token != CPP_NUMBER
-      || !isdigit(pfile->token_buffer[old_written]))
+      || !ISDIGIT(pfile->token_buffer[old_written]))
     {
       cpp_error (pfile, "invalid format `#line' command");
       goto bad_line_directive;
@@ -4920,7 +4920,7 @@ cpp_get_token (pfile)
 	case '.':
 	  NEWLINE_FIX;
 	  c2 = PEEKC ();
-	  if (isdigit(c2))
+	  if (ISDIGIT(c2))
 	    {
 	      CPP_RESERVE(pfile, 2);
 	      CPP_PUTC_Q (pfile, '.');
diff -rup orig/egcs-19980425/gcc/fix-header.c egcs-19980425/gcc/fix-header.c
--- orig/egcs-19980425/gcc/fix-header.c	Sun Apr 19 02:48:07 1998
+++ egcs-19980425/gcc/fix-header.c	Fri May  1 14:46:04 1998
@@ -959,13 +959,13 @@ inf_scan_ident (s, c)
      int c;
 {
   s->ptr = s->base;
-  if (isalpha (c) || c == '_')
+  if (ISALPHA (c) || c == '_')
     {
       for (;;)
 	{
 	  SSTRING_PUT (s, c);
 	  c = INF_GET ();
-	  if (c == EOF || !(isalnum (c) || c == '_'))
+	  if (c == EOF || !(ISALNUM (c) || c == '_'))
 	    break;
 	}
     }
@@ -1276,7 +1276,7 @@ main (argc, argv)
 	  c = INF_GET ();
 	  if (c == EOF)
 	    break;
-	  if (isalpha (c) || c == '_')
+	  if (ISALPHA (c) || c == '_')
 	    {
 	      c = inf_scan_ident (&buf, c);
 	      (void) INF_UNGET (c);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-05-04 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-04 15:53 egcs-19980425, system.h stuff part 4/6 Kaveh R. Ghazi
1998-05-04 18:07 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1998-05-01 21:25 Kaveh R. Ghazi
1998-05-02 10:47 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).