From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id C68063858D20 for ; Fri, 23 Jun 2023 11:15:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C68063858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DF5F21F390; Fri, 23 Jun 2023 11:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687518931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BKUkZagDEUfzwZe2cf5u/06hWwq+4nDWbyI5/e1u+Ds=; b=bFVEo3YVxpjfMTkcjJp38q/qWAHkWEWlS8SeKTqYOe5FGk4w0h62db9pkHH1fsY0ky4Veb y0x8lvss2so6Zcq4AaQu9LNwrBtrZ0hMHRmMnBURsCmKB1S/n5h9TOKS8stLSQloDyU538 +M7AR/AfMCrRjeraI/0Fea2JUvqsNmw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687518931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BKUkZagDEUfzwZe2cf5u/06hWwq+4nDWbyI5/e1u+Ds=; b=00iQCaFQC2n0zN0kwv2BkWiBpNf1mzjZQiiZdyfrve9LISjQUG2fJDIzkRiEONRVAfeXWH T+2d1g2vWy58DFDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C7CED1331F; Fri, 23 Jun 2023 11:15:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xhqRL9N+lWSBFQAAMHmgww (envelope-from ); Fri, 23 Jun 2023 11:15:31 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/4] [gdb/tui] Remove default entries in TUI translation tables Date: Fri, 23 Jun 2023 13:15:33 +0200 Message-Id: <20230623111536.1623-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The TUI translation tables contain default entries at the end: ... static struct tui_translate tui_border_kind_translate_hline[] = { { "space", ' ' }, { "ascii", '-' }, { "acs", -1 }, { 0, 0 }, { "ascii", '-' } }; ... A simpler way of implementing this would be to to declare the first (or last) entry the default, but in fact these default entries are not used. Make this explicit by removing the default entries, and asserting in translate that an entry will always be found. Tested on x86_64-linux. --- gdb/tui/tui-win.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 7d58a2db251..fe80df468fa 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -116,8 +116,7 @@ struct tui_translate }; /* Translation table for border-mode variables. - The list of values must be terminated by a NULL. - After the NULL value, an entry defines the default. */ + The list of values must be terminated by a NULL. */ static struct tui_translate tui_border_mode_translate[] = { { "normal", A_NORMAL }, { "standout", A_STANDOUT }, @@ -126,8 +125,7 @@ static struct tui_translate tui_border_mode_translate[] = { { "half-standout", A_DIM | A_STANDOUT }, { "bold", A_BOLD }, { "bold-standout", A_BOLD | A_STANDOUT }, - { 0, 0 }, - { "normal", A_NORMAL } + { 0, 0 } }; /* Translation tables for border-kind, one for each border @@ -138,48 +136,42 @@ static struct tui_translate tui_border_kind_translate_vline[] = { { "space", ' ' }, { "ascii", '|' }, { "acs", -1 }, - { 0, 0 }, - { "ascii", '|' } + { 0, 0 } }; static struct tui_translate tui_border_kind_translate_hline[] = { { "space", ' ' }, { "ascii", '-' }, { "acs", -1 }, - { 0, 0 }, - { "ascii", '-' } + { 0, 0 } }; static struct tui_translate tui_border_kind_translate_ulcorner[] = { { "space", ' ' }, { "ascii", '+' }, { "acs", -1 }, - { 0, 0 }, - { "ascii", '+' } + { 0, 0 } }; static struct tui_translate tui_border_kind_translate_urcorner[] = { { "space", ' ' }, { "ascii", '+' }, { "acs", -1 }, - { 0, 0 }, - { "ascii", '+' } + { 0, 0 } }; static struct tui_translate tui_border_kind_translate_llcorner[] = { { "space", ' ' }, { "ascii", '+' }, { "acs", -1 }, - { 0, 0 }, - { "ascii", '+' } + { 0, 0 } }; static struct tui_translate tui_border_kind_translate_lrcorner[] = { { "space", ' ' }, { "ascii", '+' }, { "acs", -1 }, - { 0, 0 }, - { "ascii", '+' } + { 0, 0 } }; @@ -257,8 +249,7 @@ chtype tui_border_lrcorner; int tui_border_attrs; int tui_active_border_attrs; -/* Identify the item in the translation table. - When the item is not recognized, use the default entry. */ +/* Identify the item in the translation table. */ static struct tui_translate * translate (const char *name, struct tui_translate *table) { @@ -269,9 +260,7 @@ translate (const char *name, struct tui_translate *table) table++; } - /* Not found, return default entry. */ - table++; - return table; + gdb_assert_not_reached (""); } /* Update the tui internal configuration according to gdb settings. base-commit: 8a269c262e3d0611c01edd915f230bbd2ad78015 -- 2.35.3