From a609cfaa02b699cf1cb1b785b71fd38797345c3d Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Sat, 2 Nov 1996 02:03:37 +0000 Subject: [PATCH] use strerror() to get err string since it is portable --- src/libCom/errSymLib.c | 31 +++++++++++++++++++++---------- src/libCom/error/errSymLib.c | 31 +++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/libCom/errSymLib.c b/src/libCom/errSymLib.c index 713e1af4a..884fc73d3 100644 --- a/src/libCom/errSymLib.c +++ b/src/libCom/errSymLib.c @@ -82,17 +82,8 @@ #include #include - extern SYMTAB_ID statSymTbl; -#else - -#ifndef _NTSDK -/* MS Visual C has defines for these in stdlib.h -kuk- */ -extern int sys_nerr; -extern char *sys_errlist[]; -#endif - #endif @@ -238,6 +229,16 @@ char *name; /**************************************************************** * UNIXSYMFIND ***************************************************************/ +/* + * Use of sys_nerr and sys_errlist in this routine + * present portability problems + * + * ANSI strerror() provides this functionality + * so this is hopefully no longer needed + * joh 10-02-96 + * + */ +#if 0 #ifndef vxWorks #ifdef __STDC__ int UnixSymFind(long status, char *pname, long *pvalue) @@ -257,6 +258,8 @@ int UnixSymFind(status, pname, pvalue) return(0); } #endif +#endif + /**************************************************************** * MODSYMFIND @@ -324,7 +327,15 @@ int errSymFind(status, name) #ifdef vxWorks symFindByValue((SYMTAB_ID)statSymTbl, status, name,(int*) &value, (SYM_TYPE*)&type); #else - UnixSymFind(status, name, &value); + { + const char *pStr = strerror(status); + if (pStr) { + strcpy(name,strerror(status)); + } + else { + sprintf(name,"err = %ld", status); + } + } #endif else ModSymFind(status, name, &value); diff --git a/src/libCom/error/errSymLib.c b/src/libCom/error/errSymLib.c index 713e1af4a..884fc73d3 100644 --- a/src/libCom/error/errSymLib.c +++ b/src/libCom/error/errSymLib.c @@ -82,17 +82,8 @@ #include #include - extern SYMTAB_ID statSymTbl; -#else - -#ifndef _NTSDK -/* MS Visual C has defines for these in stdlib.h -kuk- */ -extern int sys_nerr; -extern char *sys_errlist[]; -#endif - #endif @@ -238,6 +229,16 @@ char *name; /**************************************************************** * UNIXSYMFIND ***************************************************************/ +/* + * Use of sys_nerr and sys_errlist in this routine + * present portability problems + * + * ANSI strerror() provides this functionality + * so this is hopefully no longer needed + * joh 10-02-96 + * + */ +#if 0 #ifndef vxWorks #ifdef __STDC__ int UnixSymFind(long status, char *pname, long *pvalue) @@ -257,6 +258,8 @@ int UnixSymFind(status, pname, pvalue) return(0); } #endif +#endif + /**************************************************************** * MODSYMFIND @@ -324,7 +327,15 @@ int errSymFind(status, name) #ifdef vxWorks symFindByValue((SYMTAB_ID)statSymTbl, status, name,(int*) &value, (SYM_TYPE*)&type); #else - UnixSymFind(status, name, &value); + { + const char *pStr = strerror(status); + if (pStr) { + strcpy(name,strerror(status)); + } + else { + sprintf(name,"err = %ld", status); + } + } #endif else ModSymFind(status, name, &value);