summaryrefslogtreecommitdiff
path: root/src/od.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1992-11-24 19:18:43 +0000
committerJim Meyering <jim@meyering.net>1992-11-24 19:18:43 +0000
commit267096a929a867b5cbb4a3731e96ee9339edf21e (patch)
treedb6b2d060d032e6aeb833891317c58ac0a2fdc65 /src/od.c
parentca05c45625ed2cf9ad8c858a1553fb85eac8d5fe (diff)
downloadcoreutils-267096a929a867b5cbb4a3731e96ee9339edf21e.tar.xz
* (print_ascii, dump_strings): Use ISDIGIT and ISPRINT
macros like pr.c. Suggested by David J. MacKenzie.
Diffstat (limited to 'src/od.c')
-rw-r--r--src/od.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/od.c b/src/od.c
index de57c81e2..d6b1c1b2f 100644
--- 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. */
}