public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 1/4] [gdb/tui] Remove default entries in TUI translation tables
Date: Fri, 23 Jun 2023 13:15:33 +0200	[thread overview]
Message-ID: <20230623111536.1623-1-tdevries@suse.de> (raw)

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


             reply	other threads:[~2023-06-23 11:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 11:15 Tom de Vries [this message]
2023-06-23 11:15 ` [PATCH 2/4] [gdb/tui] Introduce translate_acs Tom de Vries
2023-06-23 20:28   ` Tom Tromey
2023-06-23 11:15 ` [PATCH 3/4] [gdb/tui] Merge tui border-kind corner translation tables Tom de Vries
2023-06-23 20:30   ` Tom Tromey
2023-06-23 11:15 ` [PATCH 4/4] [gdb/tui] Make translate return entry->value instead of entry Tom de Vries
2023-06-23 20:30   ` Tom Tromey
2023-06-23 20:28 ` [PATCH 1/4] [gdb/tui] Remove default entries in TUI translation tables Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230623111536.1623-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).