aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Bo ├śrsted Andresen <bo.andresen@zlin.dk> 2009-02-12 06:16:08 +0100
committerAvatar Bo ├śrsted Andresen <bo.andresen@zlin.dk> 2009-02-12 06:20:36 +0100
commitf6980972b8f3110e9764df4281a683eae0c09d4c (patch)
tree16eb3209b7958a4048cb475be7e5de4de7565162
parente1989b5c456c71d64a7b1b886fb18be833e9ae8b (diff)
downloadpaludis-f6980972b8f3110e9764df4281a683eae0c09d4c.tar.gz
paludis-f6980972b8f3110e9764df4281a683eae0c09d4c.tar.xz
Fix handling of optional empty exlib arrays.
-rw-r--r--paludis/repositories/e/e_repository_TEST_exlibs.cc1
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_exlibs_setup.sh22
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash10
3 files changed, 27 insertions, 6 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs.cc b/paludis/repositories/e/e_repository_TEST_exlibs.cc
index 8ac1b8a..3dbd94d 100644
--- a/paludis/repositories/e/e_repository_TEST_exlibs.cc
+++ b/paludis/repositories/e/e_repository_TEST_exlibs.cc
@@ -174,6 +174,7 @@ namespace test_cases
ExlibsTest test_exarray_spaces("exarray-spaces", success);
ExlibsTest test_exarray_default("exarray-default", success);
ExlibsTest test_exarray_default_spaces("exarray-default-spaces", success);
+ ExlibsTest test_exarray_empty("exarray-empty", success);
ExlibsTest test_noarray("noarray", success);
ExlibsTest test_noarray_bad("noarray-bad", throws_UnsupportedActionError);
ExlibsTest test_scalar_required("scalar-required", throws_UnsupportedActionError);
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
index e0a4690..390a707 100755
--- a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
@@ -321,6 +321,28 @@ pkg_setup() {
[[ ${FOO[@]} == "1 1 2 2 3 3" ]] || die "FOO[@] != 1 1 2 2 3 3"
}
END
+mkdir -p "packages/cat/exarray-empty"
+cat <<'END' > packages/cat/exarray-empty/foo.exlib || exit 1
+myexparam bar=[ ]
+
+check_foo() {
+ exparam bar[#] | grep -q ^0$ || die "Bad bar[#]"
+ exparam bar[0] | grep -q ^$ || die "Bad bar[0]"
+ exparam bar[*] | grep -q ^$ || die "Bad bar[*]"
+ exparam -v FOO bar[@]
+}
+END
+cat <<'END' > packages/cat/exarray-empty/exarray-empty-1.ebuild || exit 1
+require foo
+PLATFORMS="test"
+
+pkg_setup() {
+ check_foo || die "check_foo returned errror"
+ [[ ${#FOO[@]} -eq 0 ]] || die "Wrong number of elements, ${#FOO[@]} in FOO[@]"
+ [[ -z ${FOO[0]} ]] || die "Bad FOO[0]"
+ [[ -z ${FOO[@]} ]] || die "FOO[@] non-empty"
+}
+END
mkdir -p "packages/cat/noarray"
cat <<'END' > packages/cat/noarray/foo.exlib || exit 1
myexparam bar
diff --git a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
index f47524d..b72fe4e 100644
--- a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
@@ -201,12 +201,10 @@ require()
a_v=$(exparam_var_name ${CURRENT_EXLIB})__ALLDECLS__
for v in ${!a_v}; do
c_v=$(exparam_var_name ${CURRENT_EXLIB})_${v%\[\]}
- if [[ -n ${!c_v+set} ]]; then
- if [[ $(eval "declare -p ${c_v}") == declare\ -a\ ${c_v}=* ]]; then
- [[ ${v} == *\[\] ]] || die "${CURRENT_EXLIB}.exlib requires a scalar ${v} parameter but got an array"
- else
- [[ ${v} != *\[\] ]] || die "${CURRENT_EXLIB}.exlib requires an array ${v} but got a scalar"
- fi
+ if [[ $(eval "declare -p ${c_v}") == declare\ -a\ ${c_v}=* ]]; then
+ [[ ${v} == *\[\] ]] || die "${CURRENT_EXLIB}.exlib requires a scalar ${v} parameter but got an array"
+ elif [[ -n ${!c_v+set} ]]; then
+ [[ ${v} != *\[\] ]] || die "${CURRENT_EXLIB}.exlib requires an array ${v} but got a scalar"
else
die "${CURRENT_EXLIB}.exlib requires a ${v} parameter"
fi