From: Bruno Haible Date: Tue, 19 Nov 2024 15:26:45 +0000 (+0100) Subject: libgettextpo: Extend the function po_message_set_format. X-Git-Tag: v0.23~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59a82e1e1c103896f575b2c47ca216b67ff8e534;p=thirdparty%2Fgettext.git libgettextpo: Extend the function po_message_set_format. Reported by Alexander Potashev at . * 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. --- diff --git a/NEWS b/NEWS index 98fc2b023..c72300ceb 100644 --- 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 diff --git a/gettext-tools/doc/gettext.texi b/gettext-tools/doc/gettext.texi index 7f5f2152c..1ad25573e 100644 --- a/gettext-tools/doc/gettext.texi +++ b/gettext-tools/doc/gettext.texi @@ -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}) diff --git a/gettext-tools/libgettextpo/gettext-po.c b/gettext-tools/libgettextpo/gettext-po.c index 25a9ee14f..7de2f1864 100644 --- a/gettext-tools/libgettextpo/gettext-po.c +++ b/gettext-tools/libgettextpo/gettext-po.c @@ -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); } diff --git a/gettext-tools/libgettextpo/gettext-po.in.h b/gettext-tools/libgettextpo/gettext-po.in.h index b902b28f5..59982f969 100644 --- a/gettext-tools/libgettextpo/gettext-po.in.h +++ b/gettext-tools/libgettextpo/gettext-po.in.h @@ -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. */