2011-10-29 Ulrich Drepper <drepper@gmail.com>
+ * string/test-strchr.c: Make usable for strchrnul testing.
+ * string/test-strchrnul.c: New file.
+ * string/Makefile (strop-tests): Add strchrnul.
+
* po/it.po: Update from translation team.
* po/es.po: Likewise.
stpcpy stpncpy strcat strchr strcmp strcpy strcspn \
strlen strncmp strncpy strpbrk strrchr strspn memmem \
strstr strcasestr strnlen strcasecmp strncasecmp \
- strncat rawmemchr
+ strncat rawmemchr strchrnul
tests := tester inl-tester noinl-tester testcopy test-ffs \
tst-strlen stratcliff tst-svc tst-inlcall \
bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \
#include "test-string.h"
#ifndef WIDE
-# define STRCHR strchr
+# ifdef USE_FOR_STRCHRNUL
+# define STRCHR strchrnul
+# define stupid_STRCHR stupid_STRCHRNUL
+# define simple_STRCHR simple_STRCHRNUL
+# else
+# define STRCHR strchr
+# endif
# define STRLEN strlen
# define CHAR char
# define BIG_CHAR CHAR_MAX
# define UCHAR wchar_t
#endif
+#ifdef USE_FOR_STRCHRNUL
+# define NULLRET(endptr) endptr
+#else
+# define NULLRET(endptr) NULL
+#endif
+
+
typedef CHAR *(*proto_t) (const CHAR *, int);
CHAR *
{
for (; *s != (CHAR) c; ++s)
if (*s == '\0')
- return NULL;
+ return NULLRET ((CHAR *) s);
return (CHAR *) s;
}
while (n--)
if (*s++ == (CHAR) c)
return (CHAR *) s - 1;
- return NULL;
+ return NULLRET ((CHAR *) s - 1);
}
IMPL (stupid_STRCHR, 0)
CHAR *res = CALL (impl, s, c);
if (res != exp_res)
{
- error (0, 0, "Wrong result in function %s %p %p", impl->name,
- res, exp_res);
+ error (0, 0, "Wrong result in function %s %#x %p %p", impl->name,
+ c, res, exp_res);
ret = 1;
return;
}
else if (seek_char == 0)
result = buf + align + len;
else
- result = NULL;
+ result = NULLRET (buf + align + len);
if (HP_TIMING_AVAIL)
printf ("Length %4zd, alignment in bytes %2zd:",
else if (seek_char == 0)
result = (CHAR *) (p + len + align);
else
- result = NULL;
+ result = NULLRET ((CHAR *) (p + len + align));
FOR_EACH_IMPL (impl, 1)
if (CALL (impl, (CHAR *) (p + align), seek_char) != result)