| 1 |
/* PR sanitizer/98920 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
#include <stdio.h> |
| 5 |
#include <sys/types.h> |
| 6 |
#if __has_include(<regex.h>) |
| 7 |
#include <regex.h> |
| 8 |
#endif |
| 9 |
|
| 10 |
int main(void) |
| 11 |
{ |
| 12 |
#ifdef REG_STARTEND |
| 13 |
regex_t r; |
| 14 |
const char s[] = "ban\0ana"; |
| 15 |
regmatch_t pmatch[10]; |
| 16 |
pmatch[0].rm_so = 0; |
| 17 |
pmatch[0].rm_eo = sizeof(s); |
| 18 |
if (regcomp(&r, "ana", 0)) |
| 19 |
return 2; |
| 20 |
if (regexec(&r, s, sizeof(pmatch)/sizeof(pmatch[0]), pmatch, REG_STARTEND)) { |
| 21 |
fprintf(stderr, "failed to match\n"); |
| 22 |
regfree(&r); |
| 23 |
return 3; |
| 24 |
} |
| 25 |
regfree(&r); |
| 26 |
#endif |
| 27 |
return 0; |
| 28 |
} |