From c378f9ee5746b06ead26793881b1449c53b1d7c6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 May 2020 10:49:41 +0200 Subject: Stub out i18n methods for -DUSE_NLS=OFF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replacing the macros with stub inline functions allows for more versatile usage, e.g. fixing this compile error: In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++locale.h:41, from /usr/include/c++/9/bits/localefwd.h:40, from /usr/include/c++/9/ios:41, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from include/apt-pkg/configuration.h:30, from ../apt-pkg/contrib/netrc.cc:16: /usr/include/c++/9/clocale:54:11: error: ‘::setlocale’ has not been declared 54 | using ::setlocale; Gbp-Dch: Ignore --- CMake/apti18n.h.in | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'CMake') diff --git a/CMake/apti18n.h.in b/CMake/apti18n.h.in index 192979590..de9c84965 100644 --- a/CMake/apti18n.h.in +++ b/CMake/apti18n.h.in @@ -2,6 +2,9 @@ /* Internationalization macros for apt. This header should be included last in each C file. */ +#ifndef APT_I18N_H +#define APT_I18N_H + // Set by autoconf #cmakedefine USE_NLS @@ -19,11 +22,13 @@ # define N_(x) x #else // apt will not use any gettext -# define setlocale(a, b) -# define textdomain(a) -# define bindtextdomain(a, b) +extern "C" inline char* setlocale(int, const char*) throw() { return nullptr; } +extern "C" inline char* textdomain(const char*) throw() { return nullptr; } +extern "C" inline char* bindtextdomain(const char*, const char*) throw() { return nullptr; } +extern "C" inline char* dgettext(const char*, const char* msg) throw() { return const_cast(msg); } # define _(x) x # define P_(msg,plural,n) (n == 1 ? msg : plural) # define N_(x) x -# define dgettext(d, m) m +#endif + #endif -- cgit v1.2.3-18-g5258