chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / string / bug-strstr1.c
1 #include <stdio.h>
2 #include <string.h>
3
4 int main (int argc, char** argv)
5 {
6   const char haystack[] =
7     "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD_C3_A7_20_EF_BF_BD";
8
9   const char needle[] =
10     "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
11
12   const char* sub = strstr (haystack, needle);
13
14   if (sub != NULL)
15     {
16       int j;
17
18       fprintf (stderr, "BUG: expected NULL, got:\n%s\n%s\n", sub, needle);
19       for (j = 0; needle[j] != '\0'; ++j)
20         putchar (needle[j] == sub[j] ? ' ' : '^');
21       puts ("");
22       return 1;
23     }
24
25   return 0;
26 }