Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / string / xpg_strerror_r.c
blob66e693611ed81f2cf6e834b12f397bf7e1b2922c
1 /* POSIX variant of strerror_r. */
2 #undef __STRICT_ANSI__
3 #include <errno.h>
4 #include <string.h>
6 int
7 __xpg_strerror_r (int errnum,
8 char *buffer,
9 size_t n)
11 char *error;
12 int result = 0;
14 if (!n)
15 return ERANGE;
16 error = _strerror_r (_REENT, errnum, 1, &result);
17 if (strlen (error) >= n)
19 memcpy (buffer, error, n - 1);
20 buffer[n - 1] = '\0';
21 return ERANGE;
23 strcpy (buffer, error);
24 return (result || *error) ? result : EINVAL;