34 {MY_REG_NOMATCH,
"MY_REG_NOMATCH",
"regexec() failed to match"},
35 {MY_REG_BADPAT,
"MY_REG_BADPAT",
"invalid regular expression"},
36 {MY_REG_ECOLLATE,
"MY_REG_ECOLLATE",
"invalid collating element"},
37 {MY_REG_ECTYPE,
"MY_REG_ECTYPE",
"invalid character class"},
38 {MY_REG_EESCAPE,
"MY_REG_EESCAPE",
"trailing backslash (\\)"},
39 {MY_REG_ESUBREG,
"MY_REG_ESUBREG",
"invalid backreference number"},
40 {MY_REG_EBRACK,
"MY_REG_EBRACK",
"brackets ([ ]) not balanced"},
41 {MY_REG_EPAREN,
"MY_REG_EPAREN",
"parentheses not balanced"},
42 {MY_REG_EBRACE,
"MY_REG_EBRACE",
"braces not balanced"},
43 {MY_REG_BADBR,
"MY_REG_BADBR",
"invalid repetition count(s)"},
44 {MY_REG_ERANGE,
"MY_REG_ERANGE",
"invalid character range"},
45 {MY_REG_ESPACE,
"MY_REG_ESPACE",
"out of memory"},
46 {MY_REG_BADRPT,
"MY_REG_BADRPT",
"repetition-operator operand invalid"},
47 {MY_REG_EMPTY,
"MY_REG_EMPTY",
"empty (sub)expression"},
48 {MY_REG_ASSERT,
"MY_REG_ASSERT",
"\"can't happen\" -- you found a bug"},
49 {MY_REG_INVARG,
"MY_REG_INVARG",
"invalid argument to regex routine"},
50 {0,
"",
"*** unknown regexp error code ***"},
59 my_regerror(
int errcode,
const my_regex_t *preg,
char *errbuf,
size_t errbuf_size)
61 register struct rerr *r;
63 register int target = errcode &~ MY_REG_ITOA;
67 if (errcode == MY_REG_ATOI)
68 s = regatoi(preg, convbuf);
70 for (r = rerrs; r->code != 0; r++)
71 if (r->code == target)
74 if (errcode&MY_REG_ITOA) {
76 (void) strcpy(convbuf, r->name);
78 sprintf(convbuf,
"MY_REG_0x%x", target);
79 assert(strlen(convbuf) <
sizeof(convbuf));
82 s = (
char*) r->explain;
86 if (errbuf_size > 0) {
87 if (errbuf_size > len)
88 (void) strcpy(errbuf, s);
90 (void) strncpy(errbuf, s, errbuf_size-1);
91 errbuf[errbuf_size-1] =
'\0';
103 regatoi(preg, localbuf)
107 register struct rerr *r;
108 for (r = rerrs; r->code != 0; r++)
109 if (strcmp(r->name, preg->re_endp) == 0)
114 sprintf(localbuf,
"%d", r->code);