From b2852660193b839832b91f166a226fe61577e592 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 20 Nov 2002 20:49:57 +0000 Subject: [PATCH] Use strerror if available. --- v7/src/microcode/bchutl.c | 40 ++++++++++++++++++++++++--------------- v7/src/microcode/uxtop.c | 22 ++++++++++++++++----- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/v7/src/microcode/bchutl.c b/v7/src/microcode/bchutl.c index 411f9ce8c..11f619196 100644 --- a/v7/src/microcode/bchutl.c +++ b/v7/src/microcode/bchutl.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: bchutl.c,v 1.12 2002/11/20 19:46:07 cph Exp $ +$Id: bchutl.c,v 1.13 2002/11/20 20:49:46 cph Exp $ -Copyright (c) 1991-2000 Massachusetts Institute of Technology +Copyright (c) 1991-2000, 2002 Massachusetts Institute of Technology This file is part of MIT Scheme. @@ -34,6 +34,17 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # include #endif +#ifdef HAVE_STRERROR + +char * +DEFUN (error_name, (code), int code) +{ + static char buf [512]; + sprintf (buf, "%d, %s", code, (strerror (code))); + return (buf); +} + +#else /* not HAVE_STRERROR */ #ifdef __WIN32__ #define lseek _lseek @@ -41,25 +52,24 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. char * DEFUN (error_name, (code), int code) { - static char buf[512]; - - sprintf (&buf[0], "%d, unknown error", code); - return (&buf[0]); + static char buf [512]; + sprintf (buf, "%d, unknown error", code); + return (buf); } #else /* not __WIN32__ */ #ifdef __OS2__ #if defined(__IBMC__) || defined(__WATCOMC__) || defined(__EMX__) -#include +# include #endif char * DEFUN (error_name, (code), int code) { static char buf [512]; - sprintf ((&buf[0]), "%d, unknown error", code); - return (&buf[0]); + sprintf (buf, "%d, unknown error", code); + return (buf); } #else /* not __OS2__ */ @@ -67,20 +77,20 @@ DEFUN (error_name, (code), int code) char * DEFUN (error_name, (code), int code) { - static char buf[512]; - + static char buf [512]; if ((code >= 0) && (code <= sys_nerr)) - sprintf (&buf[0], "%d, %s", code, sys_errlist[code]); + sprintf (buf, "%d, %s", code, sys_errlist[code]); else - sprintf (&buf[0], "%d, unknown error", code); - return (&buf[0]); + sprintf (buf, "%d, unknown error", code); + return (buf); } #endif /* not __OS2__ */ #endif /* not __WIN32__ */ +#endif /* not HAVE_STRERROR */ #ifndef SEEK_SET -#define SEEK_SET 0 +# define SEEK_SET 0 #endif int diff --git a/v7/src/microcode/uxtop.c b/v7/src/microcode/uxtop.c index 28281ccc5..9fd4dd0da 100644 --- a/v7/src/microcode/uxtop.c +++ b/v7/src/microcode/uxtop.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: uxtop.c,v 1.26 2002/11/20 19:46:15 cph Exp $ +$Id: uxtop.c,v 1.27 2002/11/20 20:49:57 cph Exp $ -Copyright (c) 1990-2000 Massachusetts Institute of Technology +Copyright (c) 1990-2000, 2002 Massachusetts Institute of Technology This file is part of MIT Scheme. @@ -289,13 +289,23 @@ DEFUN (syserr_to_error_code, (syserr), enum syserr_names syserr) } } +#ifdef HAVE_STRERROR + +CONST char * +DEFUN (OS_error_code_to_message, (syserr), unsigned int syserr) +{ + return (strerror (syserr_to_error_code ((enum syserr_names) syserr))); +} + +#else /* not HAVE_STRERROR */ + #ifdef __HPUX__ -#define NEED_ERRLIST_DEFINITIONS +# define NEED_ERRLIST_DEFINITIONS #endif #ifdef NEED_ERRLIST_DEFINITIONS -extern char * sys_errlist []; -extern int sys_nerr; + extern char * sys_errlist []; + extern int sys_nerr; #endif CONST char * @@ -304,6 +314,8 @@ DEFUN (OS_error_code_to_message, (syserr), unsigned int syserr) int code = (syserr_to_error_code ((enum syserr_names) syserr)); return (((code > 0) && (code <= sys_nerr)) ? (sys_errlist [code]) : 0); } + +#endif /* not HAVE_STRERROR */ static char * syscall_names_table [] = { -- 2.25.1