diff options
author | Christopher Faylor <me@cgf.cx> | 2005-08-28 17:30:34 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-08-28 17:30:34 +0000 |
commit | 453185b136e3c065cd367e3cdf980126b31e709b (patch) | |
tree | f9d4bc2eccb4b24a35d128c124304b8c2eff931a /winsup/cygwin/errno.cc | |
parent | a232350855c824c1649c8dc00738878b72022906 (diff) | |
download | cygnal-453185b136e3c065cd367e3cdf980126b31e709b.tar.gz cygnal-453185b136e3c065cd367e3cdf980126b31e709b.tar.bz2 cygnal-453185b136e3c065cd367e3cdf980126b31e709b.zip |
* cygwin.din: Correct readdir_r typo.
Diffstat (limited to 'winsup/cygwin/errno.cc')
-rw-r--r-- | winsup/cygwin/errno.cc | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 1d9220f21..a33a41945 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -318,27 +318,38 @@ seterrno (const char *file, int line) extern char *_user_strerror _PARAMS ((int)); -/* FIXME: Why is strerror() a long switch and not just: - return sys_errlist[errnum]; - (or moral equivalent). - Some entries in sys_errlist[] don't match the corresponding - entries in strerror(). This seems odd. -*/ +static char * +strerror_worker (int errnum) +{ + char *res; + if (errnum >= 0 && errnum < _sys_nerr) + res = (char *) _sys_errlist [errnum]; + else + res = NULL; + return res; +} -/* CYGWIN internal */ /* strerror: convert from errno values to error strings */ extern "C" char * strerror (int errnum) { - const char *error; - if (errnum >= 0 && errnum < _sys_nerr) - error = _sys_errlist [errnum]; - else - { - __small_sprintf (_my_tls.locals.strerror_buf, "error %d", errnum); - error = _my_tls.locals.strerror_buf; - } - /* FIXME: strerror should really be const in the appropriate newlib - include files. */ - return (char *) error; + char *errstr = strerror_worker (errnum); + if (!errstr) + __small_sprintf (errstr = _my_tls.locals.strerror_buf, "Unknown error %u", + (unsigned) errnum); + return errstr; +} + +#if 0 +extern "C" int +strerror_r (int errnum, char *buf, size_t n) +{ + char *errstr = strerror_worker (errnum); + if (!errstr) + return EINVAL; + if (strlen (errstr) >= n) + return ERANGE; + strcpy (buf, errstr); + return 0; } +#endif |