|
@@ -0,0 +1,199 @@
|
|
|
+From d90e80cf0b3525d780b57d016afaa879e16b0fe4 Mon Sep 17 00:00:00 2001
|
|
|
+From: Max Kellermann <max@musicpd.org>
|
|
|
+Date: Tue, 23 Jul 2024 14:15:16 +0200
|
|
|
+Subject: [PATCH] i18n: add macro my_gettext(), do not define "gettext"
|
|
|
+
|
|
|
+Defining the macro "gettext" can cause breakages if the C++ standard
|
|
|
+library happens to include libintl.h (which GCC 14 does).
|
|
|
+
|
|
|
+Signed-off-by: Tim Soubry <tim.soubry@mind.be>
|
|
|
+Upstream: https://github.com/MusicPlayerDaemon/ncmpc/commit/249b62fc9f5e3a653ebdd22da0d75fbe87069457
|
|
|
+---
|
|
|
+ src/Command.cxx | 2 +-
|
|
|
+ src/HelpPage.cxx | 6 +++---
|
|
|
+ src/KeyDefPage.cxx | 2 +-
|
|
|
+ src/SearchPage.cxx | 6 +++---
|
|
|
+ src/SongPage.cxx | 8 ++++----
|
|
|
+ src/TabBar.cxx | 2 +-
|
|
|
+ src/i18n.h | 8 +++-----
|
|
|
+ 7 files changed, 16 insertions(+), 18 deletions(-)
|
|
|
+
|
|
|
+diff --git a/src/Command.cxx b/src/Command.cxx
|
|
|
+index 1caac250..b12a4a35 100644
|
|
|
+--- a/src/Command.cxx
|
|
|
++++ b/src/Command.cxx
|
|
|
+@@ -238,7 +238,7 @@ get_cmds_max_name_width()
|
|
|
+ const char *
|
|
|
+ get_key_description(Command command)
|
|
|
+ {
|
|
|
+- return gettext(cmds[size_t(command)].description);
|
|
|
++ return my_gettext(cmds[size_t(command)].description);
|
|
|
+ }
|
|
|
+
|
|
|
+ const char *
|
|
|
+diff --git a/src/HelpPage.cxx b/src/HelpPage.cxx
|
|
|
+index fad0f8c0..c07a20c4 100644
|
|
|
+--- a/src/HelpPage.cxx
|
|
|
++++ b/src/HelpPage.cxx
|
|
|
+@@ -242,7 +242,7 @@ HelpPage::GetListItemText(char *, size_t, unsigned i) const noexcept
|
|
|
+ assert(i < std::size(help_text));
|
|
|
+
|
|
|
+ if (row->text != nullptr)
|
|
|
+- return gettext(row->text);
|
|
|
++ return my_gettext(row->text);
|
|
|
+
|
|
|
+ if (row->command != Command::NONE)
|
|
|
+ return get_key_description(row->command);
|
|
|
+@@ -272,7 +272,7 @@ HelpPage::PaintListItem(WINDOW *w, unsigned i,
|
|
|
+
|
|
|
+ if (row->command == Command::NONE) {
|
|
|
+ if (row->text != nullptr)
|
|
|
+- mvwaddstr(w, y, 6, gettext(row->text));
|
|
|
++ mvwaddstr(w, y, 6, my_gettext(row->text));
|
|
|
+ else if (row->highlight == 2)
|
|
|
+ mvwhline(w, y, 3, ACS_HLINE, width - 6);
|
|
|
+ } else {
|
|
|
+@@ -285,7 +285,7 @@ HelpPage::PaintListItem(WINDOW *w, unsigned i,
|
|
|
+ mvwaddch(w, y, 21, ':');
|
|
|
+ mvwaddstr(w, y, 23,
|
|
|
+ row->text != nullptr
|
|
|
+- ? gettext(row->text)
|
|
|
++ ? my_gettext(row->text)
|
|
|
+ : get_key_description(row->command));
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/src/KeyDefPage.cxx b/src/KeyDefPage.cxx
|
|
|
+index be638940..dd301d39 100644
|
|
|
+--- a/src/KeyDefPage.cxx
|
|
|
++++ b/src/KeyDefPage.cxx
|
|
|
+@@ -434,7 +434,7 @@ CommandListPage::GetListItemText(char *buffer, size_t size,
|
|
|
+
|
|
|
+ snprintf(buffer + get_cmds_max_name_width(),
|
|
|
+ size - get_cmds_max_name_width(),
|
|
|
+- " - %s", gettext(get_command_definitions()[idx].description));
|
|
|
++ " - %s", my_gettext(get_command_definitions()[idx].description));
|
|
|
+
|
|
|
+ return buffer;
|
|
|
+ }
|
|
|
+diff --git a/src/SearchPage.cxx b/src/SearchPage.cxx
|
|
|
+index 4f2e3228..9ae8436b 100644
|
|
|
+--- a/src/SearchPage.cxx
|
|
|
++++ b/src/SearchPage.cxx
|
|
|
+@@ -142,7 +142,7 @@ public:
|
|
|
+ " %s : %s [%s]",
|
|
|
+ GetGlobalKeyBindings().GetKeyNames(Command::SEARCH_MODE).c_str(),
|
|
|
+ get_key_description(Command::SEARCH_MODE),
|
|
|
+- gettext(mode[options.search_mode].label));
|
|
|
++ my_gettext(mode[options.search_mode].label));
|
|
|
+ return buffer;
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -453,7 +453,7 @@ SearchPage::GetTitle(char *str, size_t size) const noexcept
|
|
|
+ "%s '%s' [%s]",
|
|
|
+ _("Search"),
|
|
|
+ pattern.c_str(),
|
|
|
+- gettext(mode[options.search_mode].label));
|
|
|
++ my_gettext(mode[options.search_mode].label));
|
|
|
+ else
|
|
|
+ return _("Search");
|
|
|
+
|
|
|
+@@ -478,7 +478,7 @@ SearchPage::OnCommand(struct mpdclient &c, Command cmd)
|
|
|
+ if (mode[options.search_mode].label == nullptr)
|
|
|
+ options.search_mode = 0;
|
|
|
+ screen_status_printf(_("Search mode: %s"),
|
|
|
+- gettext(mode[options.search_mode].label));
|
|
|
++ my_gettext(mode[options.search_mode].label));
|
|
|
+
|
|
|
+ if (pattern.empty())
|
|
|
+ /* show the new mode in the help text */
|
|
|
+diff --git a/src/SongPage.cxx b/src/SongPage.cxx
|
|
|
+index c0830a9e..6d166b13 100644
|
|
|
+--- a/src/SongPage.cxx
|
|
|
++++ b/src/SongPage.cxx
|
|
|
+@@ -174,14 +174,14 @@ static std::unique_ptr<Page>
|
|
|
+ screen_song_init(ScreenManager &_screen, WINDOW *w, Size size) noexcept
|
|
|
+ {
|
|
|
+ for (unsigned i = 0; tag_labels[i].label != nullptr; ++i) {
|
|
|
+- unsigned width = StringWidthMB(gettext(tag_labels[i].label));
|
|
|
++ unsigned width = StringWidthMB(my_gettext(tag_labels[i].label));
|
|
|
+ if (width > max_tag_label_width)
|
|
|
+ max_tag_label_width = width;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (unsigned i = 0; i < std::size(stats_labels); ++i) {
|
|
|
+ if (stats_labels[i] != nullptr) {
|
|
|
+- unsigned width = StringWidthMB(gettext(stats_labels[i]));
|
|
|
++ unsigned width = StringWidthMB(my_gettext(stats_labels[i]));
|
|
|
+
|
|
|
+ if (width > max_stats_label_width)
|
|
|
+ max_stats_label_width = width;
|
|
|
+@@ -267,7 +267,7 @@ get_tag_label(unsigned tag) noexcept
|
|
|
+ {
|
|
|
+ for (unsigned i = 0; tag_labels[i].label != nullptr; ++i)
|
|
|
+ if (tag_labels[i].tag_type == tag)
|
|
|
+- return gettext(tag_labels[i].label);
|
|
|
++ return my_gettext(tag_labels[i].label);
|
|
|
+
|
|
|
+ assert(tag < MPD_TAG_COUNT);
|
|
|
+ return mpd_tag_name((enum mpd_tag_type)tag);
|
|
|
+@@ -351,7 +351,7 @@ SongPage::AddSong(const struct mpd_song *song) noexcept
|
|
|
+ void
|
|
|
+ SongPage::AppendStatsLine(enum stats_label label, const char *value) noexcept
|
|
|
+ {
|
|
|
+- AppendLine(gettext(stats_labels[label]), value, max_stats_label_width);
|
|
|
++ AppendLine(my_gettext(stats_labels[label]), value, max_stats_label_width);
|
|
|
+ }
|
|
|
+
|
|
|
+ bool
|
|
|
+diff --git a/src/TabBar.cxx b/src/TabBar.cxx
|
|
|
+index 426bce12..0518801f 100644
|
|
|
+--- a/src/TabBar.cxx
|
|
|
++++ b/src/TabBar.cxx
|
|
|
+@@ -48,7 +48,7 @@ PaintTabBar(WINDOW *w, const PageMeta ¤t_page_meta,
|
|
|
+ title = current_page_title;
|
|
|
+
|
|
|
+ if (title == nullptr)
|
|
|
+- title = gettext(page->title);
|
|
|
++ title = my_gettext(page->title);
|
|
|
+
|
|
|
+ PaintPageTab(w, page->command, title,
|
|
|
+ page == ¤t_page_meta);
|
|
|
+diff --git a/src/i18n.h b/src/i18n.h
|
|
|
+index 8bda456e..7e98c1b0 100644
|
|
|
+--- a/src/i18n.h
|
|
|
++++ b/src/i18n.h
|
|
|
+@@ -1,8 +1,7 @@
|
|
|
+ // SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
+ // Copyright The Music Player Daemon Project
|
|
|
+
|
|
|
+-#ifndef I18N_H
|
|
|
+-#define I18N_H
|
|
|
++#pragma once
|
|
|
+
|
|
|
+ #include "config.h"
|
|
|
+
|
|
|
+@@ -10,6 +9,7 @@
|
|
|
+
|
|
|
+ #include <libintl.h> // IWYU pragma: export
|
|
|
+
|
|
|
++#define my_gettext(x) gettext(x)
|
|
|
+ #define _(x) gettext(x)
|
|
|
+
|
|
|
+ #ifdef gettext_noop
|
|
|
+@@ -19,12 +19,10 @@
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #else
|
|
|
+-#define gettext(x) (x)
|
|
|
++#define my_gettext(x) (x)
|
|
|
+ #define _(x) x
|
|
|
+ #define N_(x) x
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #define YES_TRANSLATION _("y")
|
|
|
+ #define NO_TRANSLATION _("n")
|
|
|
+-
|
|
|
+-#endif
|
|
|
+--
|
|
|
+2.39.5
|
|
|
+
|