diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-14 23:47:09 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-14 23:47:34 (EDT) |
commit | ee0c303615c3c4cfac4f778f6bfbb5bd2cc62859 (patch) | |
tree | b253e2eb6a7896d1d9741ad9b8adab09c02181ef | |
parent | 85d78aa5f1add67c54440af8fa9be188606c2591 (diff) |
_ob_match_arch(): Remove loop
ob_arch_is_concerned() calls this function with just one field arch at a
time, so this only needs to handle one arch.
-rw-r--r-- | lib/metadata.sh | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/lib/metadata.sh b/lib/metadata.sh index 9249f87..80ec274 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -161,43 +161,35 @@ ob_get_system_plat() _ob_match_arch() { local match_arch="${1}" - local arch_field="${2}" + local field_arch="${2}" shift 2 || _ob_abort - local field_arch= local match_arch_rest= local field_arch_rest= local match_arch_part= local field_arch_part= - for field_arch in ${arch_field}; do - - # "foo-bar-baz" == "any" - if [ x"${field_arch}" = x'any' ]; then - return 0 - fi - - # "foo-bar-baz" == "foo-any-any" - match_arch_rest="${match_arch}" - field_arch_rest="${field_arch}" - while [ -n "${match_arch_rest}" ] && [ -n "${field_arch_rest}" ] - do - IFS='-' read match_arch_part match_arch_rest <<-EOF - ${match_arch_rest} - EOF - IFS='-' read field_arch_part field_arch_rest <<-EOF - ${field_arch_rest} - EOF - case "${field_arch_part}" in - "${match_arch_part}" | 'any') ;; - *) continue 2;; # Failed match, go to next arch - esac - done + # "foo-bar-baz" == "any" + if [ x"${field_arch}" = x'any' ]; then return 0 + fi + # "foo-bar-baz" == "foo-any-any" + match_arch_rest="${match_arch}" + field_arch_rest="${field_arch}" + while [ -n "${match_arch_rest}" ] && [ -n "${field_arch_rest}" ]; do + IFS='-' read match_arch_part match_arch_rest <<-EOF + ${match_arch_rest} + EOF + IFS='-' read field_arch_part field_arch_rest <<-EOF + ${field_arch_rest} + EOF + case "${field_arch_part}" in + "${match_arch_part}" | 'any') ;; + *) return 1;; # Failed match + esac done - # Nothing matched. - return 1 + return 0 } _ob_match_plat() |