8 const char str
[] = "axaaba";
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");
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
);
44 #define TEST_FUNCTION do_test ()
45 #include "../test-skeleton.c"