From 9ad1f135fafcca1d43766dc928e50e4de201614c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 21 Jan 1998 18:28:09 +0000 Subject: 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. --- tools/build/cklength.c | 27 +++++++++++++++++++-------- tools/build/eolstrip.c | 27 ++++++++++++++++++++------- tools/build/packhex.c | 17 +++++++++++++++++ tools/build/src/Makefile.in | 2 +- tools/build/src/cklength.c | 27 +++++++++++++++++++-------- tools/build/src/eolstrip.c | 27 ++++++++++++++++++++------- tools/build/src/packhex.c | 17 +++++++++++++++++ tools/build/src/unhex.c | 35 ++++++++++++++++++++++++----------- tools/build/unhex.c | 35 ++++++++++++++++++++++++----------- 9 files changed, 161 insertions(+), 53 deletions(-) (limited to 'tools/build') 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 #include +#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 #include +#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 #include +#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 #include +#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 #include +#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 #include +#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 #include +#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 #include +#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); -- cgit v1.2.3