mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-30 00:49:57 +02:00
commit bash-20160520 snapshot
This commit is contained in:
+1
-1
@@ -92,7 +92,7 @@ sh_regmatch (string, pattern, flags)
|
||||
/* Store the parenthesized subexpressions in the array BASH_REMATCH.
|
||||
Element 0 is the portion that matched the entire regexp. Element 1
|
||||
is the part that matched the first subexpression, and so on. */
|
||||
unbind_variable ("BASH_REMATCH");
|
||||
unbind_variable_noref ("BASH_REMATCH");
|
||||
rematch = make_new_array_variable ("BASH_REMATCH");
|
||||
amatch = array_cell (rematch);
|
||||
|
||||
|
||||
+21
-1
@@ -114,6 +114,23 @@ get_tmpdir (flags)
|
||||
return tdir;
|
||||
}
|
||||
|
||||
static void
|
||||
sh_seedrand ()
|
||||
{
|
||||
#if HAVE_RANDOM
|
||||
int d;
|
||||
static int seeded = 0;
|
||||
if (seeded == 0)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
srandom (tv.tv_sec ^ tv.tv_usec ^ (getpid () << 16) ^ (unsigned int)&d);
|
||||
seeded = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
sh_mktmpname (nameroot, flags)
|
||||
char *nameroot;
|
||||
@@ -122,6 +139,7 @@ sh_mktmpname (nameroot, flags)
|
||||
char *filename, *tdir, *lroot;
|
||||
struct stat sb;
|
||||
int r, tdlen;
|
||||
static int seeded = 0;
|
||||
|
||||
filename = (char *)xmalloc (PATH_MAX + 1);
|
||||
tdir = get_tmpdir (flags);
|
||||
@@ -137,6 +155,7 @@ sh_mktmpname (nameroot, flags)
|
||||
filename = NULL;
|
||||
}
|
||||
#else /* !USE_MKTEMP */
|
||||
sh_seedrand ();
|
||||
while (1)
|
||||
{
|
||||
filenum = (filenum << 1) ^
|
||||
@@ -167,7 +186,7 @@ sh_mktmpfd (nameroot, flags, namep)
|
||||
{
|
||||
char *filename, *tdir, *lroot;
|
||||
int fd, tdlen;
|
||||
|
||||
|
||||
filename = (char *)xmalloc (PATH_MAX + 1);
|
||||
tdir = get_tmpdir (flags);
|
||||
tdlen = strlen (tdir);
|
||||
@@ -186,6 +205,7 @@ sh_mktmpfd (nameroot, flags, namep)
|
||||
*namep = filename;
|
||||
return fd;
|
||||
#else /* !USE_MKSTEMP */
|
||||
sh_seedrand ();
|
||||
do
|
||||
{
|
||||
filenum = (filenum << 1) ^
|
||||
|
||||
Reference in New Issue
Block a user