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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 05652158030 for ; Mon, 27 Feb 2023 04:44:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3ACA5E07FE; Mon, 27 Feb 2023 04:43:59 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0838AE0817 for ; Mon, 27 Feb 2023 04:43:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0B239340E5D for ; Mon, 27 Feb 2023 04:43:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 36ECC7D0 for ; Mon, 27 Feb 2023 04:43:56 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1677473028.b846c59c1e2ad80163745de024154cbe845fedaa.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/ X-VCS-Repository: proj/portage X-VCS-Files: bin/install-qa-check.d/90config-impl-decl X-VCS-Directories: bin/install-qa-check.d/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: b846c59c1e2ad80163745de024154cbe845fedaa X-VCS-Branch: master Date: Mon, 27 Feb 2023 04:43:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c829a250-b154-46e7-9c40-1235563e94fb X-Archives-Hash: c8c33174e68ca3a2364a3e60576ee6b2 commit: b846c59c1e2ad80163745de024154cbe845fedaa Author: Oskari Pirhonen gmail com> AuthorDate: Mon Feb 27 02:05:39 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Feb 27 04:43:48 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b846c59c 90config-impl-decl: bug fixes - Match "-Werror=impl..." from gcc - Use separate RE to check for UTF-8 and ASCII quoting when extracting the function name Signed-off-by: Oskari Pirhonen gmail.com> Signed-off-by: Sam James gentoo.org> bin/install-qa-check.d/90config-impl-decl | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/bin/install-qa-check.d/90config-impl-decl b/bin/install-qa-check.d/90config-impl-decl index 2fb8307ea..d1bc0e067 100644 --- a/bin/install-qa-check.d/90config-impl-decl +++ b/bin/install-qa-check.d/90config-impl-decl @@ -38,6 +38,12 @@ find_log_targets() { find -files0-from - -type f \( "${find_args[@]}" \) -print0 } +has_utf8_ctype() { + # Use python to check if the locale is UTF-8 since tools like locale(1) may + # not exist (eg, musl systems). + [[ "$("${PORTAGE_PYTHON:-/usr/bin/python}" -c 'import locale; print(locale.getlocale()[1])')" == UTF-8 ]] +} + config_impl_decl_check() { local files=() local lines=() @@ -46,19 +52,32 @@ config_impl_decl_check() { local entry local line local func - local re=" function '([[:print:]]+)'" + local re_uni + local re_asc + local is_utf8 + + # Given the UTF-8 character type, both gcc and clang may enclose the + # function name between the LEFT SINGLE QUOTATION MARK and RIGHT SINGLE + # QUOTATION MARK codepoints. + re_uni=$' function \u2018([^\u2019]+)\u2019' + + # This variant matches ASCII single quotes. + re_asc=$' function \x27([^\x27]+)\x27' + + # Is UTF-8 the effective character type? + has_utf8_ctype; is_utf8=$(( $? == 0 )) # Iterate over every log file found and check for '-Wimplicit-function-declaration' while IFS= read -rd '' l; do while IFS= read -ru3 entry; do # Strip ANSI codes (color and erase in line have been seen at least) - entry="$(printf '%s\n' "${entry}" | sed -E -e $'s/\033\[[0-9;]*[A-Za-z]//g')" + entry="$(printf '%s\n' "${entry}" | LC_ALL='C' sed -E -e $'s/\033\[[0-9;]*[A-Za-z]//g')" line="${entry%%:*}" - # This conditional should always be true unless compiler warnings - # get drastically changed - if [[ ${entry} =~ ${re} ]]; then + if [[ ${is_utf8} -eq 1 && ${entry} =~ ${re_uni} ]] || [[ ${entry} =~ ${re_asc} ]]; then func="${BASH_REMATCH[1]}" + else + continue fi has "${func}" "${QA_CONFIG_IMPL_DECL_SKIP[@]}" && continue @@ -67,7 +86,7 @@ config_impl_decl_check() { lines+=( "${line}" ) funcs+=( "${func}" ) # Using -I to ignore binary files is a GNU extension for grep - done 3< <(grep -nEI -e '-Wimplicit-function-declaration' "${l}") + done 3< <(grep -nEI -e '-W(error=)?implicit-function-declaration' "${l}") done < <(find_log_targets) # Drop out early if no impl decls found (all the arrays are the same size)