]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New functions for accessing a message's range.
authorBruno Haible <bruno@clisp.org>
Sat, 4 Oct 2008 11:31:19 +0000 (11:31 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:54 +0000 (12:15 +0200)
gettext-tools/libgettextpo/ChangeLog
gettext-tools/libgettextpo/gettext-po.c
gettext-tools/libgettextpo/gettext-po.h.in

index 6935323f0e7bbfa4bc6656783ab3f7bd7846de0c..e77709dfb178c170b59d76531912ab061d822966 100644 (file)
@@ -1,3 +1,10 @@
+2008-10-04  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * gettext-po.c (po_message_check_format): Update for signature changes
index 68bd13cbeb6a4f45e480f3da5aa4afc9d1d8788e..893afda4431cfc52f0dda9e6f932881490900605 100644 (file)
@@ -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 *
index 71275ff67615b18e9f07cbe4d7dcad7da9e20b53..80005382369684faed1768a30790b55e5bb76316 100644 (file)
@@ -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 <bruno@clisp.org>, 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 ============================ */