[PATCH] [gdb/tui] Factor out border-mode help text

Tom Tromey tom@tromey.com
Fri Jun 9 13:39:44 GMT 2023


>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> OTOH, it changes the translation boundaries, and I'm not sure if the
Tom> new parts still classify as "entire sentence".

Tom> Then again, I was not able to find any files containing translations
Tom> for gdb, so perhaps it doesn't matter.

Yeah, gdb has a bunch of calls to gettext but nobody has ever gotten
translations done or installed them in the tree.  I think some of the
build machinery is missing too... hard to recall, it's been ages since I
looked at this.

Tom> +  const std::string help_attribute_mode (_("\
Tom>     normal          normal display\n\
...

Tom> +  const std::string help_tui_border_mode
Tom> +    = (std::string ("\
Tom> +This variable controls the attributes to use for the window borders:\n")
Tom> +       + help_attribute_mode);
...

The text here isn't passed through gettext.
Just wrapping the constant string in _() is enough.

Tom> +  add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums,
Tom> +			&tui_border_mode, _("\
Tom> +Set the attribute mode to use for the TUI window borders."), _("\
Tom> +Show the attribute mode to use for the TUI window borders."),
Tom> +			help_tui_border_mode.c_str (),

Does add_setshow_enum_cmd copy the string that's passed in?  I wouldn't
have thought so.  If not, then this can lead to a use-after-free.
Instead help_tui_border_mode would have to be 'static'.

Tom> +  const std::string help_tui_active_border_mode
Tom> +    = (std::string ("\
Tom> +This variable controls the attributes to use for the active window borders:\n")
Tom> +       + help_attribute_mode);

Here too.  And similarly with 'static' I think.

Tom


More information about the Gdb-patches mailing list