binutils-gdb/gdb/unittests
Lancelot SIX d3ee35dbf7 Improve gdb_tilde_expand logic.
Before this patch, gdb_tilde_expand would use glob(3) in order to expand
tilde at the begining of a path. This implementation has limitation when
expanding a tilde leading path to a non existing file since glob fails to
expand.

This patch proposes to use glob only to expand the tilde component of the
path and leaves the rest of the path unchanged.

This patch is a followup to the following discution:
https://sourceware.org/pipermail/gdb-patches/2021-January/174776.html

Before the patch:

	gdb_tilde_expand("~") -> "/home/lsix"
	gdb_tilde_expand("~/a/c/b") -> error() is called

After the patch:

	gdb_tilde_expand("~") -> "/home/lsix"
	gdb_tilde_expand("~/a/c/b") -> "/home/lsix/a/c/b"

Tested on x84_64 linux.

gdb/ChangeLog:

	* Makefile.in (SELFTESTS_SRCS): Add
	unittests/gdb_tilde_expand-selftests.c.
	* unittests/gdb_tilde_expand-selftests.c: New file.

gdbsupport/ChangeLog:

	* gdb_tilde_expand.cc (gdb_tilde_expand): Improve
	implementation.
	(gdb_tilde_expand_up): Delegate logic to gdb_tilde_expand.
	* gdb_tilde_expand.h (gdb_tilde_expand): Update description.
2021-01-23 17:17:38 +00:00
..
basic_string_view
optional
array-view-selftests.c
child-path-selftests.c
cli-utils-selftests.c
command-def-selftests.c
common-utils-selftests.c
copy_bitwise-selftests.c
enum-flags-selftests.c
environ-selftests.c
filtered_iterator-selftests.c
format_pieces-selftests.c
function-view-selftests.c
gdb_tilde_expand-selftests.c
gmp-utils-selftests.c
lookup_name_info-selftests.c
main-thread-selftests.c
memory-map-selftests.c
memrange-selftests.c
mkdir-recursive-selftests.c
observable-selftests.c
offset-type-selftests.c
optional-selftests.c
parse-connection-spec-selftests.c
ptid-selftests.c
rsp-low-selftests.c
scoped_fd-selftests.c
scoped_mmap-selftests.c
scoped_restore-selftests.c
search-memory-selftests.c
string_view-selftests.c
style-selftests.c
tracepoint-selftests.c
tui-selftests.c
unpack-selftests.c
utils-selftests.c
vec-utils-selftests.c
xml-utils-selftests.c