]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
* (print_ascii, dump_strings): Use ISDIGIT and ISPRINT
authorJim Meyering <jim@meyering.net>
Tue, 24 Nov 1992 19:18:43 +0000 (19:18 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 24 Nov 1992 19:18:43 +0000 (19:18 +0000)
macros like pr.c.  Suggested by David J. MacKenzie.

src/od.c

index de57c81e2a43136e45f76bd3ff5028597570779b..d6b1c1b2fe414a581f5506c4a3a072dc8afaa4c7 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -39,6 +39,14 @@ char *alloca ();
 #include <sys/types.h>
 #include "system.h"
 
+#ifdef isascii
+#define ISPRINT(c) (isascii (c) && isprint (c))
+#define ISDIGIT(c) (isascii (c) && isdigit (c))
+#else
+#define ISPRINT(c) isprint (c)
+#define ISDIGIT(c) isdigit (c)
+#endif
+
 #if defined(__GNUC__) || defined(STDC_HEADERS)
 #include <float.h>
 #endif
@@ -615,7 +623,7 @@ print_ascii (n_bytes, block, unused_fmt_string)
          break;
 
        default:
-         sprintf (buf, (isascii (c) && isprint (c) ? "  %c" : "%03o"), c);
+         sprintf (buf, (ISPRINT (c) ? "  %c" : "%03o"), c);
          s = (const char *) buf;
        }
 
@@ -641,7 +649,7 @@ simple_strtoul (s, p, val)
   unsigned long int sum;
 
   sum = 0;
-  while (isdigit (*s))
+  while (ISDIGIT (*s))
     {
       unsigned int c = *s++ - '0';
       if (sum > (ULONG_MAX - c) / 10)
@@ -1422,7 +1430,7 @@ dump_strings ()
              free (buf);
              return err;
            }
-         if (!(isascii (c) && isprint (c)))
+         if (!ISPRINT (c))
            /* Found a non-printing.  Try again starting with next char.  */
            goto tryline;
          buf[i] = c;
@@ -1447,7 +1455,7 @@ dump_strings ()
            }
          if (c == '\0')
            break;              /* It is; print this string.  */
-         if (!(isascii (c) && isprint (c)))
+         if (!ISPRINT (c))
            goto tryline;       /* It isn't; give up on this string.  */
          buf[i++] = c;         /* String continues; store it all.  */
        }