From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1B0AA138334 for ; Sat, 30 Nov 2019 10:01:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E9F1BE0980; Sat, 30 Nov 2019 10:01:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 43BC0E0978 for ; Sat, 30 Nov 2019 10:01:18 +0000 (UTC) Received: from localhost.localdomain (c134-66.icpnet.pl [85.221.134.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 4815E34D5A0; Sat, 30 Nov 2019 10:01:16 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: python@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH] python*r1.eclass: Reliably allow empty s to gen funcs Date: Sat, 30 Nov 2019 11:00:45 +0100 Message-Id: <20191130100045.63855-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.24.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: cac4dba7-0074-495d-b82c-16ad0d45f9d3 X-Archives-Hash: fbb9b491af1b14143dfb8422902a1eec Reliably allow empty pattern lists (equivalent to no restrictions) in all pattern-based generator functions, notably python_gen_cond_dep. Previously, only some of the functions accepted them while others failed via _python_impl_matches function. Signed-off-by: Michał Górny --- eclass/python-r1.eclass | 13 ++++++------- eclass/python-single-r1.eclass | 9 ++++----- eclass/python-utils-r1.eclass | 6 ++++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 833a581fc59f..72ae7f82428a 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -278,7 +278,7 @@ _python_validate_useflags() { # @FUNCTION: _python_gen_usedep # @INTERNAL -# @USAGE: [...] +# @USAGE: [...] # @DESCRIPTION: # Output a USE dependency string for Python implementations which # are both in PYTHON_COMPAT and match any of the patterns passed @@ -353,7 +353,7 @@ python_gen_usedep() { } # @FUNCTION: python_gen_useflags -# @USAGE: [...] +# @USAGE: [...] # @DESCRIPTION: # Output a list of USE flags for Python implementations which # are both in PYTHON_COMPAT and match any of the patterns passed @@ -390,7 +390,7 @@ python_gen_useflags() { } # @FUNCTION: python_gen_cond_dep -# @USAGE: [...] +# @USAGE: [...] # @DESCRIPTION: # Output a list of -ies made conditional to USE flags # of Python implementations which are both in PYTHON_COMPAT and match @@ -486,9 +486,8 @@ python_gen_impl_dep() { local PYTHON_REQ_USE=${1} shift - local patterns=( "${@-*}" ) for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do - if _python_impl_matches "${impl}" "${patterns[@]}"; then + if _python_impl_matches "${impl}" "${@}"; then local PYTHON_PKG_DEP python_export "${impl}" PYTHON_PKG_DEP matches+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" ) @@ -566,7 +565,7 @@ python_gen_any_dep() { local i PYTHON_PKG_DEP out= for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do - if _python_impl_matches "${i}" "${@-*}"; then + if _python_impl_matches "${i}" "${@}"; then local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" python_export "${i}" PYTHON_PKG_DEP @@ -763,7 +762,7 @@ python_setup() { fi # check patterns - _python_impl_matches "${impl}" "${@-*}" || continue + _python_impl_matches "${impl}" "${@}" || continue python_export "${impl}" EPYTHON PYTHON diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index f2ad4881135d..fff816570703 100644 --- a/eclass/python-single-r1.eclass +++ b/eclass/python-single-r1.eclass @@ -252,7 +252,7 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then # @FUNCTION: _python_gen_usedep # @INTERNAL -# @USAGE: [...] +# @USAGE: [...] # @DESCRIPTION: # Output a USE dependency string for Python implementations which # are both in PYTHON_COMPAT and match any of the patterns passed @@ -327,7 +327,7 @@ python_gen_usedep() { } # @FUNCTION: python_gen_useflags -# @USAGE: [...] +# @USAGE: [...] # @DESCRIPTION: # Output a list of USE flags for Python implementations which # are both in PYTHON_COMPAT and match any of the patterns passed @@ -364,7 +364,7 @@ python_gen_useflags() { } # @FUNCTION: python_gen_cond_dep -# @USAGE: [...] +# @USAGE: [...] # @DESCRIPTION: # Output a list of -ies made conditional to USE flags # of Python implementations which are both in PYTHON_COMPAT and match @@ -463,9 +463,8 @@ python_gen_impl_dep() { local PYTHON_REQ_USE=${1} shift - local patterns=( "${@-*}" ) for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do - if _python_impl_matches "${impl}" "${patterns[@]}"; then + if _python_impl_matches "${impl}" "${@}"; then local PYTHON_PKG_DEP python_export "${impl}" PYTHON_PKG_DEP matches+=( "python_single_target_${impl}? ( ${PYTHON_PKG_DEP} )" ) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 4f3ac66f2150..3eadc50f93e6 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -164,11 +164,12 @@ _python_set_impls() { } # @FUNCTION: _python_impl_matches -# @USAGE: ... +# @USAGE: [...] # @INTERNAL # @DESCRIPTION: # Check whether the specified matches at least one # of the patterns following it. Return 0 if it does, 1 otherwise. +# Matches if no patterns are provided. # # can be in PYTHON_COMPAT or EPYTHON form. The patterns can be # either: @@ -176,7 +177,8 @@ _python_set_impls() { # b) '-2' to indicate all Python 2 variants (= !python_is_python3) # c) '-3' to indicate all Python 3 variants (= python_is_python3) _python_impl_matches() { - [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters" + [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter" + [[ ${#} -eq 1 ]] && return 0 local impl=${1} pattern shift -- 2.24.0