fixes to read/wait; revert change that processes $'...' quoting in here-documents unconditionally

This commit is contained in:
Chet Ramey
2022-01-24 09:37:14 -05:00
parent 2a1c81bf63
commit 3011048a92
38 changed files with 9824 additions and 6133 deletions
+15 -3
View File
@@ -818,8 +818,7 @@ glob_vector (pat, dir, flags)
add_current = ((flags & (GX_ALLDIRS|GX_ADDCURDIR)) == (GX_ALLDIRS|GX_ADDCURDIR));
/* Scan the directory, finding all names that match.
For each name that matches, allocate a struct globval
/* Scan the directory, finding all names that match For each name that matches, allocate a struct globval
on the stack and store the name in it.
Chain those structs together; lastlink is the front of the chain. */
while (1)
@@ -901,6 +900,9 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (sdlen + 1);
if (nextlink == 0 || nextname == 0)
{
if (firstmalloc && firstmalloc == nextlink)
firstmalloc = 0;
/* If we reset FIRSTMALLOC we can free this here. */
FREE (nextlink);
FREE (nextname);
free (subdir);
@@ -936,8 +938,18 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (D_NAMLEN (dp) + 1);
if (nextlink == 0 || nextname == 0)
{
/* We free NEXTLINK here, since it won't be added to the
LASTLINK chain. If we used malloc, and it returned non-
NULL, firstmalloc will be set to something valid. If it's
NEXTLINK, reset it before we free NEXTLINK to avoid
duplicate frees. If not, it will be taken care of by the
loop below with TMPLINK. */
if (firstmalloc)
FREE (nextlink);
{
if (firstmalloc == nextlink)
firstmalloc = 0;
FREE (nextlink);
}
FREE (nextname);
lose = 1;
break;
+2 -1
View File
@@ -315,8 +315,9 @@ sh_backslash_quote (string, table, flags)
/* Quote characters that get special treatment when in double quotes in STRING
using backslashes. Return a new string. */
char *
sh_backslash_quote_for_double_quotes (string)
sh_backslash_quote_for_double_quotes (string, flags)
char *string;
int flags;
{
unsigned char c;
char *result, *r, *s, *send;