1570af302Sopenharmony_ci// \0 is not a valid backref, it is undefined by the standard
2570af302Sopenharmony_ci// we treat such cases as literal char
3570af302Sopenharmony_ci#include <regex.h>
4570af302Sopenharmony_ci#include "test.h"
5570af302Sopenharmony_ci
6570af302Sopenharmony_ciint main(void)
7570af302Sopenharmony_ci{
8570af302Sopenharmony_ci	char buf[200];
9570af302Sopenharmony_ci	char pat[] = "a\\0";
10570af302Sopenharmony_ci	regex_t r;
11570af302Sopenharmony_ci	int n;
12570af302Sopenharmony_ci
13570af302Sopenharmony_ci	n = regcomp(&r, pat, 0);
14570af302Sopenharmony_ci	if (n) {
15570af302Sopenharmony_ci		regerror(n, &r, buf, sizeof buf);
16570af302Sopenharmony_ci		t_error("regcomp(%s) returned %d (%s) wanted 0\n", pat, n, buf);
17570af302Sopenharmony_ci	}
18570af302Sopenharmony_ci	n = regexec(&r, "a0", 0, 0, 0);
19570af302Sopenharmony_ci	if (n) {
20570af302Sopenharmony_ci		regerror(n, &r, buf, sizeof buf);
21570af302Sopenharmony_ci		t_error("regexec(/%s/ ~ \"a0\") returned %d (%s), wanted 0\n",
22570af302Sopenharmony_ci			pat, n, buf);
23570af302Sopenharmony_ci	}
24570af302Sopenharmony_ci
25570af302Sopenharmony_ci	return t_status;
26570af302Sopenharmony_ci}
27