Avoid uninitialized warnings in Bessel functions.
[glibc.git] / string / bug-strtok1.c
blobda30acf2e6308fd4268c59209e4193baabaa4d7d
1 /* See BZ #2126. */
2 #include <string.h>
3 #include <stdio.h>
5 static int
6 do_test (void)
8 const char str[] = "axaaba";
9 char *token;
10 char *cp;
11 char *l;
12 int result = 0;
14 puts ("test strtok");
15 cp = strdupa (str);
16 printf ("cp = %p, len = %zu\n", cp, strlen (cp));
17 token = strtok (cp, "ab");
18 result |= token == NULL || strcmp (token, "x");
19 printf ("token: %s (%d)\n", token ? token : "NULL", result);
20 token = strtok(0, "ab");
21 result |= token != NULL;
22 printf ("token: %s (%d)\n", token ? token : "NULL", result);
23 token = strtok(0, "a");
24 result |= token != NULL;
25 printf ("token: %s (%d)\n", token ? token : "NULL", result);
27 puts ("test strtok_r");
28 cp = strdupa (str);
29 size_t len = strlen (cp);
30 printf ("cp = %p, len = %zu\n", cp, len);
31 token = strtok_r (cp, "ab", &l);
32 result |= token == NULL || strcmp (token, "x");
33 printf ("token: %s, next = %p (%d)\n", token ? token : "NULL", l, result);
34 token = strtok_r(0, "ab", &l);
35 result |= token != NULL || l != cp + len;
36 printf ("token: %s, next = %p (%d)\n", token ? token : "NULL", l, result);
37 token = strtok_r(0, "a", &l);
38 result |= token != NULL || l != cp + len;
39 printf ("token: %s, next = %p (%d)\n", token ? token : "NULL", l, result);
41 return result;
44 #define TEST_FUNCTION do_test ()
45 #include "../test-skeleton.c"