This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Broken strspn and strpbrk macros
- To: libc-alpha at sources dot redhat dot com
- Subject: Broken strspn and strpbrk macros
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Sun, 29 Oct 2000 11:21:12 +0000 (GMT)
glibc's <bits/string2.h> strspn and strpbrk macros are broken when the
second string is empty: they fail to evaluate the first string for its
side effects. This may also apply to the <bits/string.h> versions.
Testcase: compile and run the following with optimization.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int
main (void)
{
const char *a = "abc";
const char *b = a;
puts ("Testing strspn.");
strspn (b++, "");
if (b != a + 1)
abort ();
puts ("Testing strpbrk.");
strpbrk (b++, "");
if (b != a + 2)
abort ();
exit (0);
}
--
Joseph S. Myers
jsm28@cam.ac.uk