Blame src/regression/regex-ere-backref.c
|
Szabolcs Nagy |
1a68cd |
// commit 7c8c86f6308c7e0816b9638465a5917b12159e8f 2015-03-20
|
|
Szabolcs Nagy |
1a68cd |
// backref is not valid in ere
|
|
Szabolcs Nagy |
1a68cd |
#include <regex.h>
|
|
Szabolcs Nagy |
1a68cd |
#include "test.h"
|
|
Szabolcs Nagy |
1a68cd |
|
|
Szabolcs Nagy |
1a68cd |
int main(void)
|
|
Szabolcs Nagy |
1a68cd |
{
|
|
Szabolcs Nagy |
1a68cd |
char buf[200];
|
|
Szabolcs Nagy |
1a68cd |
char pat[] = "(a)\\1";
|
|
Szabolcs Nagy |
1a68cd |
regex_t r;
|
|
Szabolcs Nagy |
1a68cd |
int n;
|
|
Szabolcs Nagy |
1a68cd |
|
|
Szabolcs Nagy |
1a68cd |
n = regcomp(&r, pat, REG_EXTENDED);
|
|
Szabolcs Nagy |
1a68cd |
if (n) {
|
|
Szabolcs Nagy |
1a68cd |
regerror(n, &r, buf, sizeof buf);
|
|
Szabolcs Nagy |
1a68cd |
t_error("regcomp(%s) returned %d (%s) wanted 0\n", pat, n, buf);
|
|
Szabolcs Nagy |
1a68cd |
}
|
|
Szabolcs Nagy |
1a68cd |
|
|
Szabolcs Nagy |
1a68cd |
n = regexec(&r, "aa", 0, 0, 0);
|
|
Szabolcs Nagy |
1a68cd |
if (n != REG_NOMATCH) {
|
|
Szabolcs Nagy |
1a68cd |
regerror(n, &r, buf, sizeof buf);
|
|
Szabolcs Nagy |
1a68cd |
t_error("regexec(/%s/ ~ \"aa\") returned %d (%s), wanted REG_NOMATCH\n",
|
|
Szabolcs Nagy |
1a68cd |
pat, n, buf);
|
|
Szabolcs Nagy |
1a68cd |
}
|
|
Szabolcs Nagy |
1a68cd |
|
|
Szabolcs Nagy |
1a68cd |
n = regexec(&r, "a1", 0, 0, 0);
|
|
Szabolcs Nagy |
1a68cd |
if (n) {
|
|
Szabolcs Nagy |
1a68cd |
regerror(n, &r, buf, sizeof buf);
|
|
Szabolcs Nagy |
1a68cd |
t_error("regexec(/%s/ ~ \"a1\") returned %d (%s), wanted 0\n",
|
|
Szabolcs Nagy |
1a68cd |
pat, n, buf);
|
|
Szabolcs Nagy |
1a68cd |
}
|
|
Szabolcs Nagy |
1a68cd |
|
|
Szabolcs Nagy |
1a68cd |
return t_status;
|
|
Szabolcs Nagy |
1a68cd |
}
|