Change prototype to take msgctxtid + offset instead of two strings, to
authorMatthias Clasen <mclasen@redhat.com>
Mon, 10 Dec 2007 05:24:36 +0000 (05:24 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 10 Dec 2007 05:24:36 +0000 (05:24 +0000)
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

ChangeLog
glib/gi18n-lib.h
glib/gi18n.h
glib/gstrfuncs.c
glib/gstrfuncs.h

index c4cfff0..e97ff2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * tests/gio-ls.c : (new file) a test program emulating some of 'ls'
index e5d1cd9..9ba1f51 100644 (file)
@@ -28,9 +28,9 @@
 #endif
 
 #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 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__ */
index b208db0..a5c829b 100644 (file)
@@ -23,9 +23,9 @@
 #include <libintl.h>
 
 #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 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__ */
index badac77..6d60381 100644 (file)
@@ -2849,19 +2849,20 @@ g_strv_length (gchar **str_array)
  * g_dpgettext:
  * @domain: the translation domain to use, or %NULL to use
  *   the domain set with textdomain()
- * @msgctxtid: a combined message context and message id
- * @msgid: the message id, or %NULL
+ * @msgctxtid: a combined message context and message id, separated
+ *   by a \004 character
+ * @msgidoffset: the offset of the message id in @msgctxid
  *
  * This function is a variant of dgettext() which supports
  * a disambiguating message context. GNU gettext uses the
  * '\004' character to separate the message context and
- * message id in @msgctxtid. If %NULL is passed as @msgid,
- * this function also supports the older convention of using 
- * '|' as a separator. 
+ * message id in @msgctxtid.
+ * If 0 is passed as @msgidoffset, this function will fall back to
+ * trying to use the deprecated convention of using "|" as a separation
+ * character.
  *
  * Applications should normally not use this function directly,
- * but use the C_() or Q_() macros for translations with
- * context.
+ * but use the C_() macro for translations with context.
  *
  * Returns: The translated string
  *
@@ -2870,7 +2871,7 @@ g_strv_length (gchar **str_array)
 const gchar *
 g_dpgettext (const gchar *domain, 
              const gchar *msgctxtid, 
-             const gchar *msgid)
+             gsize        msgidoffset)
 {
   const gchar *translation;
   gchar *sep;
@@ -2879,8 +2880,8 @@ g_dpgettext (const gchar *domain,
 
   if (translation == msgctxtid)
     {
-      if (msgid)
-        return msgid;
+      if (msgidoffset > 0)
+        return msgctxtid + msgidoffset;
 
       sep = strchr (msgctxtid, '|');
  
index aac58f3..bf35326 100644 (file)
@@ -245,7 +245,7 @@ G_CONST_RETURN gchar *g_strip_context  (const gchar *msgid,
 
 G_CONST_RETURN gchar *g_dpgettext      (const gchar *domain,
                                         const gchar *msgctxtid,
-                                        const gchar *msgid);
+                                        gsize        msgidoffset);
 
 G_END_DECLS