improve system error messages

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35764 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-10-30 13:35:00 +00:00
parent 36e87ee63b
commit cbf57cf013
9 changed files with 65 additions and 36 deletions

View file

@ -23,23 +23,7 @@
*/
/* Carefully turn on _XOPEN_SOURCE for string.h so we
* get the POSIX strerror_r
*/
#if defined(_GNU_SOURCE)
#undef _GNU_SOURCE
#endif
#if defined(_XOPEN_SOURCE)
#if _XOPEN_SOURCE < 600
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#else
#define _XOPEN_SOURCE 600
#endif
#import "common.h"
#include <stdio.h>
#import "Foundation/NSDictionary.h"
@ -144,10 +128,12 @@ strerror_r(int eno, char *buf, int len)
#else
NSString *message;
char buf[BUFSIZ];
int result;
/* FIXME ... not all are POSIX, should we use NSMachErrorDomain for some? */
domain = NSPOSIXErrorDomain;
if (strerror_r(code, buf, BUFSIZ) < 0)
result = strerror_r(code, buf, BUFSIZ);
if (result < 0)
{
snprintf(buf, sizeof(buf), "%ld", code);
}