From: Bruno Haible Date: Sat, 4 Oct 2008 11:31:19 +0000 (+0000) Subject: New functions for accessing a message's range. X-Git-Tag: v0.18~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64c4423481c92b9dafa7651b78e96ec4837f8862;p=thirdparty%2Fgettext.git New functions for accessing a message's range. --- diff --git a/gettext-tools/libgettextpo/ChangeLog b/gettext-tools/libgettextpo/ChangeLog index 6935323f0..e77709dfb 100644 --- a/gettext-tools/libgettextpo/ChangeLog +++ b/gettext-tools/libgettextpo/ChangeLog @@ -1,3 +1,10 @@ +2008-10-04 Bruno Haible + + * gettext-po.h.in (po_message_is_range, po_message_set_range): New + declarations. + * gettext-po.c (po_message_is_range, po_message_set_range): New + functions. + 2008-10-03 Bruno Haible * gettext-po.c (po_message_check_format): Update for signature changes diff --git a/gettext-tools/libgettextpo/gettext-po.c b/gettext-tools/libgettextpo/gettext-po.c index 68bd13cbe..893afda44 100644 --- a/gettext-tools/libgettextpo/gettext-po.c +++ b/gettext-tools/libgettextpo/gettext-po.c @@ -1092,6 +1092,48 @@ po_message_set_format (po_message_t message, const char *format_type, /*bool*/in } +/* If a numeric range of a message is set, return true and store the minimum + and maximum value in *MINP and *MAXP. */ + +int +po_message_is_range (po_message_t message, int *minp, int *maxp) +{ + message_ty *mp = (message_ty *) message; + + if (has_range_p (mp->range)) + { + *minp = mp->range.min; + *minp = mp->range.max; + return 1; + } + else + return 0; +} + + +/* Change the numeric range of a message. MIN and MAX must be non-negative, + with MIN < MAX. Use MIN = MAX = -1 to remove the numeric range of a + message. */ + +void +po_message_set_range (po_message_t message, int min, int max) +{ + message_ty *mp = (message_ty *) message; + + if (min >= 0 && max >= min) + { + mp->range.min = min; + mp->range.max = max; + } + else if (min < 0 && max < 0) + { + mp->range.min = -1; + mp->range.max = -1; + } + /* Other values of min and max are invalid. */ +} + + /* Return the file name. */ const char * diff --git a/gettext-tools/libgettextpo/gettext-po.h.in b/gettext-tools/libgettextpo/gettext-po.h.in index 71275ff67..800053823 100644 --- a/gettext-tools/libgettextpo/gettext-po.h.in +++ b/gettext-tools/libgettextpo/gettext-po.h.in @@ -1,5 +1,5 @@ /* Public API for GNU gettext PO files - contained in libgettextpo. - Copyright (C) 2003-2007 Free Software Foundation, Inc. + Copyright (C) 2003-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -301,6 +301,15 @@ 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); +/* If a numeric range of a message is set, return true and store the minimum + and maximum value in *MINP and *MAXP. */ +extern int po_message_is_range (po_message_t message, int *minp, int *maxp); + +/* Change the numeric range of a message. MIN and MAX must be non-negative, + with MIN < MAX. Use MIN = MAX = -1 to remove the numeric range of a + message. */ +extern void po_message_set_range (po_message_t message, int min, int max); + /* =========================== po_filepos_t API ============================ */