From patchwork Sun Oct 6 10:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 98435 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C4EB3385ED4C for ; Sun, 6 Oct 2024 10:47:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 1E642385EC3F for ; Sun, 6 Oct 2024 10:46:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E642385EC3F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1E642385EC3F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728211577; cv=none; b=cUI9HnbVyeJUH0BJwVR3P04YIy9RvVPj3g7/izQNRYj41/aDBxQnZw0WscZzV1j4k+LpI7wjVFLUDK3D69sxK0ekvsM3yyda2xAMJWgZnqGEs6E9FMxJIki6b6wFaMsflGMZ10BvwkfIZuBct+hZ5p7gmRYBMTG2WpWPwLGe+oE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728211577; c=relaxed/simple; bh=Hf3YyKKNkjic3BPti39vJVj8Cl0su6XzjPKsVPL+HW8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=HOhGpbv7Ec3xJPD6EZ877MYfEH+JFqAUKzL6jJzes+U2cXo2zeOzOYJdQMtfQaY65c8apxFX5dTFikeU7Yc1VBYXC/OPsWTKBKrYb2jH8GMl2t3LWWZrlYEi0e/uYGIio+1RK+rvIlr5DyUNe9m29MngZBqEFhpXEH+hlQ2GdR0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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-out2.suse.de (Postfix) with ESMTPS id C4BF61FCE0 for ; Sun, 6 Oct 2024 10:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728211573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=u3eztqg+OlTR9Nx2Di6R7bK5AHZsldKxrBAhQepHdhE=; b=NPR3VoGhMesoStba75Va5h5zHPtysvCyc6bTJy87xdygt/bOmQFgZTOSvMaKORsfGq6pvd jQWGHGX8G+jXXcy2QXuLvQGC5ly7msfgQleS2gFftJpYVyf0FCpR3zAeuZ+F61mWiNTIVl vU4be6Mno8ans//UbjktsFL815rc6XA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728211573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=u3eztqg+OlTR9Nx2Di6R7bK5AHZsldKxrBAhQepHdhE=; b=QIPWV2CrIMrPqcYmbdMT5CGhA7+dlyLrMr5ruO6SOjRpBpL2gAIgeoAuJS0fpdT/r4G254 XG/9gChvtS5Z4MDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=NPR3VoGh; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=QIPWV2Cr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728211573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=u3eztqg+OlTR9Nx2Di6R7bK5AHZsldKxrBAhQepHdhE=; b=NPR3VoGhMesoStba75Va5h5zHPtysvCyc6bTJy87xdygt/bOmQFgZTOSvMaKORsfGq6pvd jQWGHGX8G+jXXcy2QXuLvQGC5ly7msfgQleS2gFftJpYVyf0FCpR3zAeuZ+F61mWiNTIVl vU4be6Mno8ans//UbjktsFL815rc6XA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728211573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=u3eztqg+OlTR9Nx2Di6R7bK5AHZsldKxrBAhQepHdhE=; b=QIPWV2CrIMrPqcYmbdMT5CGhA7+dlyLrMr5ruO6SOjRpBpL2gAIgeoAuJS0fpdT/r4G254 XG/9gChvtS5Z4MDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AC217131CA for ; Sun, 6 Oct 2024 10:46:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2JVwKHVqAmcWKwAAD6G6ig (envelope-from ) for ; Sun, 06 Oct 2024 10:46:13 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh Date: Sun, 6 Oct 2024 12:46:01 +0200 Message-Id: <20241006104603.7584-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: C4BF61FCE0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.979]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org While trying to add more separators here: ... # Separators: space, slash, tab. grep_separator=" |/| " sed_separator=" \|/\|\t" ... I mistakingly used "|" instead of "\|" in sed_separator. Factor out new variables grep_or and sed_or, and construct the grep_separator and sed_separator variables by joining the elements of a list using grep_or and sed_or. Verified with shellcheck, and tested by rerunning on x86_64-linux. Reviewed-By: Alexandra Petlanova Hajkova --- gdb/contrib/spellcheck.sh | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) base-commit: 23ca0175c66b1add6fe51efc160628c824f6d32f diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh index e7db6217d45..343a43f054c 100755 --- a/gdb/contrib/spellcheck.sh +++ b/gdb/contrib/spellcheck.sh @@ -27,8 +27,47 @@ cache_file=wikipedia-common-misspellings.txt dictionary=$cache_dir/$cache_file # Separators: space, slash, tab. -grep_separator=" |/| " -sed_separator=" \|/\|\t" +declare -a grep_separators +grep_separators=( + " " + "/" + " " +) +declare -a sed_separators +sed_separators=( + " " + "/" + "\t" +) + +join () +{ + local or + or="$1" + shift + + local res + res="" + + local first + first=true + + for item in "$@"; do + if $first; then + first=false + res="$item" + else + res="$res$or$item" + fi + done + + echo "$res" +} + +grep_or="|" +sed_or="\|" +grep_separator=$(join $grep_or "${grep_separators[@]}") +sed_separator=$(join $sed_or "${sed_separators[@]}") usage () {