aboutsummaryrefslogtreecommitdiff
path: root/posix/wordexp-test.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-16 18:30:44 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-16 18:30:44 +0000
commit22bc79788225fb13ff8e66d38e0dd92d44b1e588 (patch)
tree4245a0b22a3abc3601bc9924b5d3452dba61e7c8 /posix/wordexp-test.c
parent6760028826b40e45fe7f12b3e1ec934b032dba55 (diff)
downloadglibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.tar
glibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.tar.gz
glibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.tar.bz2
glibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.zip
Update.
1998-03-15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp-test.c: Add more tests. (testit): Fix logic. * posix/wordexp.c (exec_comm): In the child, redirect stderr to /dev/null instead of closing it, close pipe. Always chop off all trailing newlines. Kill and reap child before returning error. (w_addword, parse_glob): Fix memory leak. (wordexp): Fix dangling pointer problem. 1998-03-16 Ulrich Drepper <drepper@cygnus.com> * elf/dl-close.c (_dl_close): Correct and simplify unmapping. * posix/wordexp-test.c (main): Fix little thinkos and typos. * catgets/Makefile (CPPFLAGS): Change NLSPATH to also examine directory index by only the language.
Diffstat (limited to 'posix/wordexp-test.c')
-rw-r--r--posix/wordexp-test.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index b8a83c5211..2fc5f0ffac 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -47,6 +47,9 @@ struct test_case_struct
/* Simple parameter expansion */
{ 0, "foo", "${var}", 0, 1, { "foo", } },
{ 0, "foo", "$var", 0, 1, { "foo", } },
+ { 0, "foo", "\\\"$var\\\"", 0, 1, { "\"foo\"", } },
+ { 0, "foo", "%$var%", 0, 1, { "%foo%", } },
+ { 0, "foo", "-$var-", 0, 1, { "-foo-", } },
/* Simple quote removal */
{ 0, NULL, "\"quoted\"", 0, 1, { "quoted", } },
@@ -58,12 +61,15 @@ struct test_case_struct
{ 0, NULL, "$( (echo hello) )", 0, 1, { "hello", } },
{ 0, NULL, "$((echo hello);(echo there))", 0, 2, { "hello", "there", } },
{ 0, NULL, "`echo one two`", 0, 2, { "one", "two", } },
+ { 0, NULL, "$(echo ')')", 0, 1, { ")" } },
+ { 0, NULL, "$(echo hello; echo)", 0, 1, { "hello", } },
/* Simple arithmetic expansion */
{ 0, NULL, "$((1 + 1))", 0, 1, { "2", } },
{ 0, NULL, "$((2-3))", 0, 1, { "-1", } },
{ 0, NULL, "$((-1))", 0, 1, { "-1", } },
{ 0, NULL, "$[50+20]", 0, 1, { "70", } },
+ { 0, NULL, "$(((2+3)*(4+5)))", 0, 1, { "45", } },
/* Advanced parameter expansion */
{ 0, NULL, "${var:-bar}", 0, 1, { "bar", } },
@@ -83,11 +89,14 @@ struct test_case_struct
{ 0, "foo", "${var:+bar}", 0, 1, { "bar", } },
{ 0, "", "${var+bar}", 0, 1, { "bar", } },
{ 0, "12345", "${#var}", 0, 1, { "5", } },
+ { 0, NULL, "${var:-'}'}", 0, 1, { "}", } },
+ { 0, NULL, "${var-}", 0, 0, { NULL } },
{ 0, "banana", "${var%na*}", 0, 1, { "bana", } },
{ 0, "banana", "${var%%na*}", 0, 1, { "ba", } },
{ 0, "borabora-island", "${var#*bora}", 0, 1, { "bora-island", } },
{ 0, "borabora-island", "${var##*bora}", 0, 1, {"-island", } },
+ { 0, "100%", "${var%0%}", 0, 1, { "10" } },
/* Pathname expansion */
{ 0, NULL, "???", 0, 2, { "one", "two", } },
@@ -155,6 +164,7 @@ main (int argc, char *argv[])
const char *globfile[] = { "one", "two", "three", NULL };
char tmpdir[32];
struct passwd *pw;
+ char *cwd;
int test;
int fail = 0;
int i;
@@ -206,8 +216,8 @@ main (int argc, char *argv[])
for (i = 0; globfile[i]; ++i)
remove (globfile[i]);
- if (cwd = NULL)
- strcpy (cwd, "..");
+ if (cwd == NULL)
+ cwd = "..";
chdir (cwd);
rmdir (tmpdir);
@@ -233,7 +243,7 @@ testit (struct test_case_struct *tc)
printf ("Test %d: ", ++test);
retval = wordexp (tc->words, &we, tc->flags);
- if (retval != tc->retval || (retval != 0 && we.we_wordc != tc->wordc))
+ if (retval != tc->retval || (retval == 0 && we.we_wordc != tc->wordc))
bzzzt = 1;
else
for (i = 0; i < we.we_wordc; ++i)