fail posix_spawn file_actions operations with negative fds
[musl.git] / src / regex / regerror.c
blob5b347cc73c7351b72ec40efa4901818751da7019
1 #include <string.h>
2 #include <regex.h>
3 #include <stdio.h>
4 #include "locale_impl.h"
6 /* Error message strings for error codes listed in `regex.h'. This list
7 needs to be in sync with the codes listed there, naturally. */
9 /* Converted to single string by Rich Felker to remove the need for
10 * data relocations at runtime, 27 Feb 2006. */
12 static const char messages[] = {
13 "No error\0"
14 "No match\0"
15 "Invalid regexp\0"
16 "Unknown collating element\0"
17 "Unknown character class name\0"
18 "Trailing backslash\0"
19 "Invalid back reference\0"
20 "Missing ']'\0"
21 "Missing ')'\0"
22 "Missing '}'\0"
23 "Invalid contents of {}\0"
24 "Invalid character range\0"
25 "Out of memory\0"
26 "Repetition not preceded by valid expression\0"
27 "\0Unknown error"
30 size_t regerror(int e, const regex_t *restrict preg, char *restrict buf, size_t size)
32 const char *s;
33 for (s=messages; e && *s; e--, s+=strlen(s)+1);
34 if (!*s) s++;
35 s = LCTRANS_CUR(s);
36 return 1+snprintf(buf, size, "%s", s);