]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libgettextpo: Extend the function po_message_set_format.
authorBruno Haible <bruno@clisp.org>
Tue, 19 Nov 2024 15:26:45 +0000 (16:26 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Nov 2024 15:26:45 +0000 (16:26 +0100)
Reported by Alexander Potashev <aspotashev@gmail.com>
at <https://savannah.gnu.org/bugs/?61160>.

* gettext-tools/libgettextpo/gettext-po.c (po_message_set_format): Support a
negative value.
* gettext-tools/libgettextpo/gettext-po.in.h (po_message_set_format): Mention
effects of po_message_set_format (..., -1).
* gettext-tools/doc/gettext.texi (po_message_t API): Likewise.
* NEWS: Mention the change.

NEWS
gettext-tools/doc/gettext.texi
gettext-tools/libgettextpo/gettext-po.c
gettext-tools/libgettextpo/gettext-po.in.h

diff --git a/NEWS b/NEWS
index 98fc2b02344ddc1f845ecf0034dc84bf94f14fdf..c72300ceb83873a5f2668ab7e6fd08194b631a7f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Version 0.23 - October 2024
+Version 0.23 - November 2024
 
 * Programming languages support:
   - XML:
@@ -79,6 +79,8 @@ Version 0.23 - October 2024
 
 * libgettextpo library:
   - This library is now multithread-safe.
+  - The function 'po_message_set_format' now supports resetting a format string
+    mark.
 
 Version 0.22.5 - February 2024
 
index 7f5f2152c495cf21670d95c38d7fc5733f050ade..1ad25573e1c0e66c5c36f40c8f1831403005c9e4 100644 (file)
@@ -6289,8 +6289,14 @@ is marked as being a format string of @var{format_type}.
 @end deftypefun
 
 @deftypefun {void} po_message_set_format (po_message_t@tie{}@var{message}, const@tie{}char@tie{}*@var{format_type}, int@tie{}@var{value})
-The @code{po_message_set_fuzzy} function changes the format mark of
-the message for the @var{format_type} provided.
+The @code{po_message_set_format} function changes
+the format string mark of the message for the @var{format_type} provided.
+Pass @var{value} = 1
+to assert the format string mark (leading to e.g. @samp{c-format}),
+@var{value} = 0
+to assert the opposite (leading to e.g. @samp{no-c-format}),
+or @var{value} = -1
+to remove the format string mark and its opposite.
 @end deftypefun
 
 @deftypefun {int} po_message_is_range (po_message_t@tie{}@var{message}, int@tie{}*@var{minp}, int@tie{}*@var{maxp})
index 25a9ee14f772ffab8cb7ed78a04fcc094280d000..7de2f1864300769cb4ef318f74bc0c3f68880dbd 100644 (file)
@@ -960,7 +960,7 @@ po_message_is_format (po_message_t message, const char *format_type)
 /* Change the format string mark for a given type of a message.  */
 
 void
-po_message_set_format (po_message_t message, const char *format_type, /*bool*/int value)
+po_message_set_format (po_message_t message, const char *format_type, int value)
 {
   message_ty *mp = (message_ty *) message;
   size_t len = strlen (format_type);
@@ -971,7 +971,7 @@ po_message_set_format (po_message_t message, const char *format_type, /*bool*/in
       if (strlen (format_language[i]) == len - 7
           && memcmp (format_language[i], format_type, len - 7) == 0)
         /* The given format_type corresponds to (enum format_type) i.  */
-        mp->is_format[i] = (value ? yes : no);
+        mp->is_format[i] = (value >= 0 ? (value ? yes : no) : undecided);
 }
 
 
index b902b28f57f50ccf910bc8cf745581620297c478..59982f9690d01394138cdd593898b5a4e2575bb0 100644 (file)
@@ -298,8 +298,11 @@ extern void po_message_set_fuzzy (po_message_t message, int fuzzy);
    type (e.g. "c-format").  */
 extern int po_message_is_format (po_message_t message, const char *format_type);
 
-/* Change the format string mark for a given type of a message.  */
-extern void po_message_set_format (po_message_t message, const char *format_type, /*bool*/int value);
+/* Change the format string mark for a given type of a message.
+   Pass value = 1 to assert the format string mark (e.g. "c-format"),
+   value = 0 to assert the opposite (leading to e.g. "no-c-format"),
+   or value = -1 to remove the format string mark and its opposite.  */
+extern void po_message_set_format (po_message_t message, const char *format_type, int value);
 
 /* If a numeric range of a message is set, return true and store the minimum
    and maximum value in *MINP and *MAXP.  */