Browse Source

Stub out i18n methods for -DUSE_NLS=OFF

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
tags/debian/2.1.5
David Kalnischkies 4 months ago
parent
commit
c378f9ee57
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      CMake/apti18n.h.in

+ 9
- 4
CMake/apti18n.h.in View File

@@ -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<char*>(msg); }
# define _(x) x
# define P_(msg,plural,n) (n == 1 ? msg : plural)
# define N_(x) x
# define dgettext(d, m) m
#endif

#endif

Loading…
Cancel
Save