]> Savannah Git Hosting - gnulib.git/commit
tempname: merge from glibc and coreutils
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Jun 2020 03:15:25 +0000 (20:15 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Jun 2020 05:16:58 +0000 (22:16 -0700)
commit78f55d5374d6ff9b8460c48a42e924bf69775cd7
tree2a649608f2898ee98a8552e5d696ca8dcdf7148a
parentd4429157c13b49d1749f5ea18fb30e24ffa646aa
tempname: merge from glibc and coreutils

Also, merge in Gnulib’s more-recent methods of making it easier
to share between Gnulib and glibc, and fix a few randomness
glitches.
* lib/tempname.c: Include libc-config.h, not config.h, if !_LIBC.
(__set_errno): Remove; libc-config.h does that for us.
Do not include <sys/time.h>.
(__secure_getenv) [_LIBC]: New macro.
(__try_tempname, __getpid, __gettimeofday) [!_LIBC]: Remove macros.
(RANDOM_BITS): Rewrite.
(RANDOM_VALUE_MAX, BASE_62_DIGITS, BASE_62_POWER): New macros.
(random_value): New typedef.
(try_file, try_dir, try_nocreate): Move up.
(gen_tempname_len, try_tempname_len): New functions.
(gen_tempname_len): Use a constant array rather than a switch.
(try_tempname_len): Don’t assume string length fits in int.
Generalize use of RANDOM_BITS.  If _LIBC, don’t assume RANDOM_BITS
has enough entropy (it’s a bit short).
(__gen_tempname): Rewrite in terms of gen_tempname_len.
(__try_tempname): Rewrite in terms of try_tempname_len.
* lib/tempname.h (gen_tempname_len, try_tempname_len): New decls.
* modules/tempname (Depends-on): Remove gettimeofday, sys_time.
Add getentropy, libc-config.
ChangeLog
lib/tempname.c
lib/tempname.h
modules/tempname