aboutsummaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-14 15:22:40 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-14 15:22:40 +0000
commit1ffaaca2a33e068501a14c4b635c0948cdba79e0 (patch)
tree7ec9c63900f5978c51dbbe45b56e36dc470d0ba3 /posix
parent4ca020f54d113fca0e45cb5c5317fbe98bb04bec (diff)
downloadglibc-1ffaaca2a33e068501a14c4b635c0948cdba79e0.zip
glibc-1ffaaca2a33e068501a14c4b635c0948cdba79e0.tar.gz
glibc-1ffaaca2a33e068501a14c4b635c0948cdba79e0.tar.bz2
Update.
1998-09-14 22:46 Tim Waugh <tim@cyberelk.demon.co.uk> * posix/wordexp-test.c: Chet Ramey confirmed that bash's behaviour for field-splitting :abc: is correct, and that two fields should result. Revert tests to reflect this. * posix/wordexp.c (w_emptyword): Remove function. (exec_comm): Don't use w_emptyword. (parse_param): Likewise.
Diffstat (limited to 'posix')
-rw-r--r--posix/wordexp-test.c12
-rw-r--r--posix/wordexp.c41
2 files changed, 13 insertions, 40 deletions
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index 1815241..be81c4b 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -51,11 +51,15 @@ struct test_case_struct
{ 0, "two three", "one $var", 0, 3, { "one", "two", "three", }, IFS },
{ 0, "two three", "one \"$var\"", 0, 2, { "one", "two three", }, "" },
{ 0, "two three", "one $var", 0, 2, { "one", "two three", }, "" },
- { 0, ":abc:", "$var", 0, 3, { "", "abc", "", }, ":" },
- { 0, NULL, "$(echo :abc:)", 0, 3, { "", "abc", "", }, ":" },
- { 0, NULL, "$(echo :abc:\\ )", 0, 3, { "", "abc", "", }, ": " },
+
+ /* The non-whitespace IFS char at the end delimits the second field
+ * but does NOT start a new field. */
+ { 0, ":abc:", "$var", 0, 2, { "", "abc", }, ":" },
+
+ { 0, NULL, "$(echo :abc:)", 0, 2, { "", "abc", }, ":" },
+ { 0, NULL, "$(echo :abc:\\ )", 0, 2, { "", "abc", }, ": " },
{ 0, NULL, "$(echo :abc\\ )", 0, 2, { "", "abc", }, ": " },
- { 0, ":abc:", "$(echo $var)", 0, 3, { "", "abc", "", }, ":" },
+ { 0, ":abc:", "$(echo $var)", 0, 2, { "", "abc", }, ":" },
{ 0, NULL, ":abc:", 0, 1, { " abc ", }, ":" },
{ 0, NULL, "$(echo :abc:)def", 0, 3, { "", "abc", "def", }, ":" },
{ 0, NULL, "$(echo abc:de)f", 0, 2, { "abc", "def", }, ":" },
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 0737519..0139a99 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -136,21 +136,6 @@ w_addmem (char *buffer, size_t *actlen, size_t *maxlen, const char *str,
return buffer;
}
-
-/* Result of w_emptyword will not be ignored even if it is the last. */
-static inline char *
-w_emptyword (size_t *actlen, size_t *maxlen)
-{
- char *word = malloc (1 + W_CHUNK);
- *maxlen = W_CHUNK;
- *actlen = 0;
-
- if (word)
- *word = '\0';
-
- return word;
-}
-
static char *
internal_function
w_addstr (char *buffer, size_t *actlen, size_t *maxlen, const char *str)
@@ -835,7 +820,6 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
int i;
char *buffer;
pid_t pid;
- int keep_empty_word = 0;
/* Don't fork() unless necessary */
if (!comm || !*comm)
@@ -933,11 +917,6 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
if (strchr (ifs_white, buffer[i]) == NULL)
{
/* Current character is IFS but not whitespace */
-
- /* After this delimiter, another field must result.
- * Make a note. */
- keep_empty_word = 1;
-
if (copying == 2)
{
/* current character
@@ -971,14 +950,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
if (w_addword (pwordexp, *word) == WRDE_NOSPACE)
goto no_space;
- if (keep_empty_word)
- {
- *word = w_emptyword (word_length, max_length);
- if (*word == NULL)
- goto no_space;
- }
- else
- *word = w_newword (word_length, max_length);
+ *word = w_newword (word_length, max_length);
/* fall back round the loop.. */
}
else
@@ -986,9 +958,6 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
/* Not IFS character */
copying = 1;
- if (buffer[i] != '\n')
- keep_empty_word = 0;
-
*word = w_addchar (*word, word_length, max_length,
buffer[i]);
if (*word == NULL)
@@ -1003,13 +972,13 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
{
(*word)[--*word_length] = '\0';
- /* If the last word was entirely newlines, and the previous word
- * wasn't delimited with IFS non-whitespace, turn it into a new word
+ /* If the last word was entirely newlines, turn it into a new word
* which can be ignored if there's nothing following it. */
- if (!keep_empty_word && *word_length == 0)
+ if (*word_length == 0)
{
free (*word);
*word = w_newword (word_length, max_length);
+ break;
}
}
@@ -1768,7 +1737,7 @@ envsubst:
goto no_space;
}
- *word = w_emptyword (word_length, max_length);
+ *word = w_newword (word_length, max_length);
}
/* Skip IFS whitespace before the field */