Hash :
9411c5e4
Author :
Date :
2023-03-27T15:41:30
wcsstr: Ensure worst-case linear execution time. * lib/wchar.in.h (wcsstr): Consider REPLACE_WCSSTR. * lib/wcs-two-way.h: New file, based on lib/str-two-way.h. * lib/wcsstr-impl.h: If requested, use the two-way algorithm. New code based on lib/strstr.c. * m4/wcsstr.m4 (gl_FUNC_WCSSTR_SIMPLE): Renamed from gl_FUNC_WCSSTR. (gl_FUNC_WCSSTR): New macro, based on gl_FUNC_STRSTR in m4/strstr.m4. * m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCSSTR. * modules/wchar (Makefile.am): Substitute REPLACE_WCSSTR. * modules/wcsstr-simple: New file, based on modules/wcsstr. * modules/wcsstr (Description): Document that this module now provides an efficient implementation. (Files): Add lib/wcs-two-way.h. (Depends-on): Depend on wcsstr-simple and the dependencies of the two-way implementation. (configure.ac): Use AC_LIBOBJ instead of a conditional. Don't invoke gl_WCHAR_MODULE_INDICATOR. (Makefile.am): Don't augment lib_SOURCES. * tests/test-wcsstr.c: New file, based on tests/test-strstr.c. * modules/wcsstr-tests: New file, based on modules/strstr-tests. * doc/posix-functions/wcsstr.texi: Mention the worst-case complexity. Mention the new 'wcsstr-simple' module. * doc/posix-functions/strstr.texi: Fix typo.
Description:
wcsstr() function: efficiently locate a substring in a wide string.
Files:
lib/wcsstr.c
lib/wcsstr-impl.h
lib/wcs-two-way.h
m4/wcsstr.m4
Depends-on:
wcsstr-simple
builtin-expect [test $HAVE_WCSSTR = 0 || test $REPLACE_WCSSTR = 1]
wcschr [test $HAVE_WCSSTR = 0 || test $REPLACE_WCSSTR = 1]
wmemchr [test $HAVE_WCSSTR = 0 || test $REPLACE_WCSSTR = 1]
wmemcmp [test $HAVE_WCSSTR = 0 || test $REPLACE_WCSSTR = 1]
configure.ac:
gl_FUNC_WCSSTR
if test $HAVE_WCSSTR = 0 || test $REPLACE_WCSSTR = 1; then
AC_LIBOBJ([wcsstr])
fi
Makefile.am:
Include:
<wchar.h>
License:
LGPL
Maintainer:
all