1 #include <string.h>
2 #include <regex.h>
3 #include <stdio.h>
4 // #include "locale_impl.h"
5
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. */
8
9 /* Converted to single string by Rich Felker to remove the need for
10 * data relocations at runtime, 27 Feb 2006. */
11
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"
28 };
29
regerror(int e,const regex_t * __restrict preg,char * __restrict buf,size_t size)30 size_t regerror(int e, const regex_t *__restrict preg, char *__restrict buf, size_t size)
31 {
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);
37 }
38