CVS: sml-dist/src/runtime/c-libs/posix-error errmsg.c,1.2,1.3
John Reppy <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj.commits |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/smlnj/sml-dist/src/runtime/c-libs/posix-error
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18651
Modified Files:
errmsg.c
Log Message:
Use strerror when available.
Index: errmsg.c
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/runtime/c-libs/posix-error/errmsg.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** errmsg.c 1 Jun 2000 18:33:45 -0000 1.2
--- errmsg.c 21 Feb 2006 21:32:10 -0000 1.3
***************
*** 7,10 ****
--- 7,11 ----
#include <stdio.h>
#include <errno.h>
+ #include <string.h>
#include "ml-base.h"
#include "ml-values.h"
***************
*** 23,33 ****
ml_val_t s;
if ((0 <= errnum) && (errnum < sys_nerr))
s = ML_CString (msp, sys_errlist[errnum]);
else {
! char buf[32];
sprintf(buf, "<unknown error %d>", errnum);
s = ML_CString (msp, buf);
}
return s;
--- 24,45 ----
ml_val_t s;
+ #if defined(HAS_STRERROR)
+ char *msg = strerror(errnum);
+ if (msg != 0)
+ s = ML_CString (msp, msg);
+ else {
+ char buf[64];
+ sprintf(buf, "<unknown error %d>", errnum);
+ s = ML_CString (msp, buf);
+ }
+ #else
if ((0 <= errnum) && (errnum < sys_nerr))
s = ML_CString (msp, sys_errlist[errnum]);
else {
! char buf[64];
sprintf(buf, "<unknown error %d>", errnum);
s = ML_CString (msp, buf);
}
+ #endif
return s;
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642