summaryrefslogtreecommitdiffstats
path: root/c/build-tools/unhex.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-01-21 18:28:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-01-21 18:28:09 +0000
commit9ad1f135fafcca1d43766dc928e50e4de201614c (patch)
treed5f4890c13c84ed691264e62101e6eecc9e46831 /c/build-tools/unhex.c
parentChanged reference from PROJECT_ROOT to RTEMS_ROOT. (diff)
downloadrtems-9ad1f135fafcca1d43766dc928e50e4de201614c.tar.bz2
Added autoconf support for strerror/sys_errlist per Ralf Corsepius'
direction. This fixes a problem reported by Steve Evans of Radstone since he is using glibc2.
Diffstat (limited to '')
-rw-r--r--c/build-tools/unhex.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/c/build-tools/unhex.c b/c/build-tools/unhex.c
index a75ba8e665..d9a4beb861 100644
--- a/c/build-tools/unhex.c
+++ b/c/build-tools/unhex.c
@@ -38,6 +38,24 @@ usage: unhex [-va] [ -o file ] [ file [file ... ] ]\n\
#include <stdlib.h>
#include <stdarg.h>
+#include "config.h"
+
+#ifndef VMS
+#ifndef HAVE_STRERROR
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+#define strerror( _err ) \
+ ((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
+
+#else /* HAVE_STRERROR */
+char *strerror ();
+#endif
+#else /* VMS */
+char *strerror (int,...);
+#endif
+
+
#define OK 0
#define FAILURE (-1)
#define Failed(x) ((x) == FAILURE)
@@ -119,10 +137,10 @@ char *MISCSUM = "Checksum mismatch";
char *BADTYPE = "Unrecognized record type";
char *MISTYPE = "Incompatible record types";
-int
-main(argc, argv)
-int argc;
-char **argv;
+int main(
+ int argc,
+ char **argv
+)
{
register int c;
bool showusage = FALSE; /* usage error? */
@@ -680,8 +698,6 @@ error(int error_flag, ...)
{
va_list arglist;
register char *format;
- extern char *sys_errlist[];
- extern int sys_nerr;
int local_errno;
extern int errno;
@@ -699,12 +715,9 @@ error(int error_flag, ...)
va_end(arglist);
if (local_errno)
- if ((local_errno > 0) && (local_errno < sys_nerr))
- (void) fprintf(stderr, " (%s)\n", sys_errlist[local_errno]);
- else
- (void) fprintf(stderr, " (unknown errno=%d)\n", local_errno);
+ (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
else
- (void) fprintf(stderr, "\n");
+ (void) fprintf(stderr, "\n");
(void) fflush(stderr);