summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
parentd73ed76b03671198b0a73994beef019943746338 (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 'tools')
-rw-r--r--tools/build/cklength.c27
-rw-r--r--tools/build/eolstrip.c27
-rw-r--r--tools/build/packhex.c17
-rw-r--r--tools/build/src/Makefile.in2
-rw-r--r--tools/build/src/cklength.c27
-rw-r--r--tools/build/src/eolstrip.c27
-rw-r--r--tools/build/src/packhex.c17
-rw-r--r--tools/build/src/unhex.c35
-rw-r--r--tools/build/unhex.c35
9 files changed, 161 insertions, 53 deletions
diff --git a/tools/build/cklength.c b/tools/build/cklength.c
index ef271971fc..4b712a1d63 100644
--- a/tools/build/cklength.c
+++ b/tools/build/cklength.c
@@ -35,6 +35,24 @@ maximum line length. The default maximum line length is 80.\n\
#include <memory.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 BUFFER_SIZE 512
#define SUCCESS 0
@@ -231,8 +249,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;
@@ -250,12 +266,7 @@ 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);
- else
- (void) fprintf(stderr, "\n");
+ (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
(void) fflush(stderr);
diff --git a/tools/build/eolstrip.c b/tools/build/eolstrip.c
index b8854fabf1..d15151c8b0 100644
--- a/tools/build/eolstrip.c
+++ b/tools/build/eolstrip.c
@@ -30,6 +30,24 @@ Strip the white space from the end of every line on the list of files.\n\
#include <memory.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 BUFFER_SIZE 2048
#define MAX_PATH 2048
@@ -218,8 +236,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;
@@ -237,12 +253,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);
diff --git a/tools/build/packhex.c b/tools/build/packhex.c
index 6410b520c6..aa92761a91 100644
--- a/tools/build/packhex.c
+++ b/tools/build/packhex.c
@@ -37,6 +37,23 @@
#include <stdlib.h>
#include <string.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
+
#if defined(__unix__) && !defined(EXIT_FAILURE)
#define EXIT_FAILURE -1
#define EXIT_SUCCESS 0
diff --git a/tools/build/src/Makefile.in b/tools/build/src/Makefile.in
index 642b76e2c4..a24e9c264a 100644
--- a/tools/build/src/Makefile.in
+++ b/tools/build/src/Makefile.in
@@ -40,7 +40,7 @@ include $(RTEMS_ROOT)/make/leaf.cfg
#
DEFINES +=
-CPPFLAGS +=
+CPPFLAGS += -I.
CFLAGS +=
LD_PATHS +=
diff --git a/tools/build/src/cklength.c b/tools/build/src/cklength.c
index ef271971fc..4b712a1d63 100644
--- a/tools/build/src/cklength.c
+++ b/tools/build/src/cklength.c
@@ -35,6 +35,24 @@ maximum line length. The default maximum line length is 80.\n\
#include <memory.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 BUFFER_SIZE 512
#define SUCCESS 0
@@ -231,8 +249,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;
@@ -250,12 +266,7 @@ 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);
- else
- (void) fprintf(stderr, "\n");
+ (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
(void) fflush(stderr);
diff --git a/tools/build/src/eolstrip.c b/tools/build/src/eolstrip.c
index b8854fabf1..d15151c8b0 100644
--- a/tools/build/src/eolstrip.c
+++ b/tools/build/src/eolstrip.c
@@ -30,6 +30,24 @@ Strip the white space from the end of every line on the list of files.\n\
#include <memory.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 BUFFER_SIZE 2048
#define MAX_PATH 2048
@@ -218,8 +236,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;
@@ -237,12 +253,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);
diff --git a/tools/build/src/packhex.c b/tools/build/src/packhex.c
index 6410b520c6..aa92761a91 100644
--- a/tools/build/src/packhex.c
+++ b/tools/build/src/packhex.c
@@ -37,6 +37,23 @@
#include <stdlib.h>
#include <string.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
+
#if defined(__unix__) && !defined(EXIT_FAILURE)
#define EXIT_FAILURE -1
#define EXIT_SUCCESS 0
diff --git a/tools/build/src/unhex.c b/tools/build/src/unhex.c
index a75ba8e665..d9a4beb861 100644
--- a/tools/build/src/unhex.c
+++ b/tools/build/src/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);
diff --git a/tools/build/unhex.c b/tools/build/unhex.c
index a75ba8e665..d9a4beb861 100644
--- a/tools/build/unhex.c
+++ b/tools/build/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);