]> Savannah Git Hosting - gnulib.git/commit
wcsstr: Ensure worst-case linear execution time.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Mar 2023 13:41:30 +0000 (15:41 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 27 Mar 2023 13:41:30 +0000 (15:41 +0200)
commit9411c5e467cf60f6295b9fed306029f341a0f24f
treed004f4ae2ddab9e649df6df4c716aa982d6fe119
parent5a9a1ea612598404bca0e4c5dbb9505ed36fd11d
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.
13 files changed:
ChangeLog
doc/posix-functions/strstr.texi
doc/posix-functions/wcsstr.texi
lib/wchar.in.h
lib/wcs-two-way.h [new file with mode: 0644]
lib/wcsstr-impl.h
m4/wchar_h.m4
m4/wcsstr.m4
modules/wchar
modules/wcsstr
modules/wcsstr-simple [new file with mode: 0644]
modules/wcsstr-tests [new file with mode: 0644]
tests/test-wcsstr.c [new file with mode: 0644]