Change prototype to take msgctxtid + offset instead of two strings, to

2007-12-10  Matthias Clasen  <mclasen@redhat.com>

        * glib/gstrfuncs.h:
        * glib/gstrfuncs.c (g_dpgettext): Change prototype to take
        msgctxtid + offset instead of two strings, to avoid duplication
        of string constants if the compiler/linker don't perform constant
        suffix merging.  (#502590, Christian Persch)

        * glib/gi18n.h:
        * glib/gi18n-lib.h: Adapt the definitions of C_() and Q_().


svn path=/trunk/; revision=6081
This commit is contained in:
Matthias Clasen 2007-12-10 05:24:36 +00:00 committed by Matthias Clasen
parent d527cd5d9b
commit d0d19f0dba
5 changed files with 27 additions and 15 deletions

View File

@ -1,3 +1,14 @@
2007-12-10 Matthias Clasen <mclasen@redhat.com>
* glib/gstrfuncs.h:
* glib/gstrfuncs.c (g_dpgettext): Change prototype to take
msgctxtid + offset instead of two strings, to avoid duplication
of string constants if the compiler/linker don't perform constant
suffix merging. (#502590, Christian Persch)
* glib/gi18n.h:
* glib/gi18n-lib.h: Adapt the definitions of C_() and Q_().
2007-12-09 Hans Breuer <hans@breuer.org> 2007-12-09 Hans Breuer <hans@breuer.org>
* tests/gio-ls.c : (new file) a test program emulating some of 'ls' * tests/gio-ls.c : (new file) a test program emulating some of 'ls'

View File

@ -28,9 +28,9 @@
#endif #endif
#define _(String) dgettext (GETTEXT_PACKAGE, String) #define _(String) dgettext (GETTEXT_PACKAGE, String)
#define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, NULL) #define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, 0)
#define N_(String) (String) #define N_(String) (String)
#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, String) #define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, strlen (Context) + 1)
#endif /* __G_I18N_LIB_H__ */ #endif /* __G_I18N_LIB_H__ */

View File

@ -23,9 +23,9 @@
#include <libintl.h> #include <libintl.h>
#define _(String) gettext (String) #define _(String) gettext (String)
#define Q_(String) g_dpgettext (NULL, String, NULL) #define Q_(String) g_dpgettext (NULL, String, 0)
#define N_(String) (String) #define N_(String) (String)
#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, String) #define C_(Context,String) g_dpgettext (NULL, Context "\004" String, strlen (Context) + 1)
#endif /* __G_I18N_H__ */ #endif /* __G_I18N_H__ */

View File

@ -2849,19 +2849,20 @@ g_strv_length (gchar **str_array)
* g_dpgettext: * g_dpgettext:
* @domain: the translation domain to use, or %NULL to use * @domain: the translation domain to use, or %NULL to use
* the domain set with textdomain() * the domain set with textdomain()
* @msgctxtid: a combined message context and message id * @msgctxtid: a combined message context and message id, separated
* @msgid: the message id, or %NULL * by a \004 character
* @msgidoffset: the offset of the message id in @msgctxid
* *
* This function is a variant of dgettext() which supports * This function is a variant of dgettext() which supports
* a disambiguating message context. GNU gettext uses the * a disambiguating message context. GNU gettext uses the
* '\004' character to separate the message context and * '\004' character to separate the message context and
* message id in @msgctxtid. If %NULL is passed as @msgid, * message id in @msgctxtid.
* this function also supports the older convention of using * If 0 is passed as @msgidoffset, this function will fall back to
* '|' as a separator. * trying to use the deprecated convention of using "|" as a separation
* character.
* *
* Applications should normally not use this function directly, * Applications should normally not use this function directly,
* but use the C_() or Q_() macros for translations with * but use the C_() macro for translations with context.
* context.
* *
* Returns: The translated string * Returns: The translated string
* *
@ -2870,7 +2871,7 @@ g_strv_length (gchar **str_array)
const gchar * const gchar *
g_dpgettext (const gchar *domain, g_dpgettext (const gchar *domain,
const gchar *msgctxtid, const gchar *msgctxtid,
const gchar *msgid) gsize msgidoffset)
{ {
const gchar *translation; const gchar *translation;
gchar *sep; gchar *sep;
@ -2879,8 +2880,8 @@ g_dpgettext (const gchar *domain,
if (translation == msgctxtid) if (translation == msgctxtid)
{ {
if (msgid) if (msgidoffset > 0)
return msgid; return msgctxtid + msgidoffset;
sep = strchr (msgctxtid, '|'); sep = strchr (msgctxtid, '|');

View File

@ -245,7 +245,7 @@ G_CONST_RETURN gchar *g_strip_context (const gchar *msgid,
G_CONST_RETURN gchar *g_dpgettext (const gchar *domain, G_CONST_RETURN gchar *g_dpgettext (const gchar *domain,
const gchar *msgctxtid, const gchar *msgctxtid,
const gchar *msgid); gsize msgidoffset);
G_END_DECLS G_END_DECLS