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