glibc/sysdeps
Adhemerval Zanella c66c908230 posix: Sync glob with gnulib [BZ #1062]
This patch syncs posix/glob.c implementation with gnulib version
b5ec983 (glob: simplify symlink detection).  The only difference
to gnulib code is

  * DT_UNKNOWN, DT_DIR, and DT_LNK definition in the case there
    were not already defined.  Gnulib code which uses
    HAVE_STRUCT_DIRENT_D_TYPE will redefine them wrongly because
    GLIBC does not define HAVE_STRUCT_DIRENT_D_TYPE.  Instead
    the patch check for each definition instead.

Also, the patch requires additional globfree and globfree64 files
for compatibility version on some architectures.  Also the code
simplification leads to not macro simplification (not need for
NO_GLOB_PATTERN_P anymore).

Checked on x86_64-linux-gnu and on a build using build-many-glibcs.py
for all major architectures.

	[BZ #1062]
	* posix/Makefile (routines): Add globfree, globfree64, and
	glob_pattern_p.
	* posix/flexmember.h: New file.
	* posix/glob_internal.h: Likewise.
	* posix/glob_pattern_p.c: Likewise.
	* posix/globfree.c: Likewise.
	* posix/globfree64.c: Likewise.
	* sysdeps/gnu/globfree64.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/globfree.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/globfree64.c: Likewise.
	* sysdeps/unix/sysv/linux/oldglob.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/globfree64.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/globfree.c: Likewise.
	* sysdeps/wordsize-64/globfree.c: Likewise.
	* sysdeps/wordsize-64/globfree64.c: Likewise.
	* posix/glob.c (HAVE_CONFIG_H): Use !_LIBC instead.
	[NDEBUG): Remove comments.
	(GLOB_ONLY_P, _AMIGA, VMS): Remove define.
	(dirent_type): New type.  Use uint_fast8_t not
	uint8_t, as C99 does not require uint8_t.
	(DT_UNKNOWN, DT_DIR, DT_LNK): New macros.
	(struct readdir_result): Use dirent_type.  Do not define skip_entry
	unless it is needed; this saves a byte on platforms lacking d_ino.
	(readdir_result_type, readdir_result_skip_entry):
	New functions, replacing ...
	(readdir_result_might_be_symlink, readdir_result_might_be_dir):
	 these functions, which were removed.  This makes the callers
	easier to read.  All callers changed.
	(D_INO_TO_RESULT): Now empty if there is no d_ino.
	(size_add_wrapv, glob_use_alloca): New static functions.
	(glob, glob_in_dir): Check for size_t overflow in several places,
	and fix some size_t checks that were not quite right.
	Remove old code using SHELL since Bash no longer
	uses this.
	(glob, prefix_array): Separate MS code better.
	(glob_in_dir): Remove old Amiga and VMS code.
	(globfree, __glob_pattern_type, __glob_pattern_p): Move to
	separate files.
	(glob_in_dir): Do not rely on undefined behavior in accessing
	struct members beyond their bounds.  Use a flexible array member
	instead
	(link_stat): Rename from link_exists2_p and return -1/0 instead of
	0/1.  Caller changed.
	(glob): Fix memory leaks.
	* posix/glob64 (globfree64): Move to separate file.
	* sysdeps/gnu/glob64.c (NO_GLOB_PATTERN_P): Remove define.
	(globfree64): Remove hidden alias.
	* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Add
	oldglob.
	* sysdeps/unix/sysv/linux/alpha/glob.c (__new_globfree): Move to
	separate file.
	* sysdeps/unix/sysv/linux/i386/glob64.c (NO_GLOB_PATTERN_P): Remove
	define.
	Move compat code to separate file.
	* sysdeps/wordsize-64/glob.c (globfree): Move definitions to
	separate file.
2017-09-08 09:39:13 +02:00
..
aarch64 Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
alpha Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
arm Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
generic Prefer new libm function wrappers for !LIBM_SVID_COMPAT. 2017-09-05 23:35:55 +00:00
gnu posix: Sync glob with gnulib [BZ #1062] 2017-09-08 09:39:13 +02:00
hppa Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
i386 Remove remaining _HAVE_STRING_ARCH_* definitions (BZ #18858) 2017-09-06 14:35:23 -03:00
ia64 Prefer new libm function wrappers for !LIBM_SVID_COMPAT. 2017-09-05 23:35:55 +00:00
ieee754 Prefer new libm function wrappers for !LIBM_SVID_COMPAT. 2017-09-05 23:35:55 +00:00
init_array Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
m68k Simplify HUGE_VAL definitions. 2017-08-31 15:50:50 +00:00
mach Hide __chmod and __mkdir [BZ #18822] 2017-09-04 13:38:51 -07:00
microblaze Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
mips Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
nios2 Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
nptl Remove extra semicolons in struct pthread_mutex (bug 21804) 2017-07-24 12:22:05 +02:00
posix hurd: Fix libc link 2017-09-03 04:36:29 +02:00
powerpc Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
pthread aio: Remove internal_function function attribute 2017-08-31 15:59:06 +02:00
s390 Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
sh Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
sparc Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
tile Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
unix posix: Sync glob with gnulib [BZ #1062] 2017-09-08 09:39:13 +02:00
wordsize-32 Build divdi3 only for architecture that required it 2017-04-06 15:14:34 -03:00
wordsize-64 posix: Sync glob with gnulib [BZ #1062] 2017-09-08 09:39:13 +02:00
x86 hurd: fix libm link 2017-09-03 05:32:10 +02:00
x86_64 Remove remaining _HAVE_STRING_ARCH_* definitions (BZ #18858) 2017-09-06 14:35:23 -03:00