]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New functions po_message_remove_filepos, po_message_add_filepos.
authorBruno Haible <bruno@clisp.org>
Fri, 11 Feb 2005 11:10:54 +0000 (11:10 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:12:11 +0000 (12:12 +0200)
gettext-tools/ChangeLog
gettext-tools/src/ChangeLog
gettext-tools/src/gettext-po.c
gettext-tools/src/gettext-po.h
gettext-tools/windows/gettextpo.def

index faf07735fe7ab952bd7ff60fe9fc7f25c2a3f017..b78e1dcdcf3b35a41952f3f6379eb5bdf5d78fdf 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-10  Bruno Haible  <bruno@clisp.org>
+
+       * windows/gettextpo.def: Add po_message_remove_filepos,
+       po_message_add_filepos.
+
 2005-02-10  Bruno Haible  <bruno@clisp.org>
 
        * windows/gettextpo.def: Add po_message_set_extracted_comments.
index fd92e7a6ac705bf69352aaf541ef3b9019c7603a..3eaa36247631a469242eda4a2c2d7fd3baf2acb5 100644 (file)
@@ -1,3 +1,11 @@
+2005-02-10  Bruno Haible  <bruno@clisp.org>
+
+       * gettext-po.h (po_message_remove_filepos, po_message_add_filepos): New
+       declarations.
+       * gettext-po.c (po_message_remove_filepos, po_message_add_filepos): New
+       functions.
+       Suggested by Asgeir Frimannsson <asgeirf@redhat.com>.
+
 2005-02-10  Bruno Haible  <bruno@clisp.org>
 
        * gettext-po.h (po_message_set_extracted_comments): New declaration.
index 8a811978273f21773832885a778a7a253204e99f..0508616aa6ab66058009a0c8f7cdb1d5d4ced8a9 100644 (file)
@@ -686,6 +686,46 @@ po_message_filepos (po_message_t message, int i)
 }
 
 
+/* Remove the i-th file position from a message.
+   The indices of all following file positions for the message are decremented
+   by one.  */
+
+void
+po_message_remove_filepos (po_message_t message, int i)
+{
+  message_ty *mp = (message_ty *) message;
+
+  if (i >= 0)
+    {
+      size_t j = (size_t)i;
+      size_t n = mp->filepos_count;
+
+      if (j < n)
+       {
+         mp->filepos_count = n = n - 1;
+         free ((char *) mp->filepos[j].file_name);
+         for (; j < n; j++)
+           mp->filepos[j] = mp->filepos[j + 1];
+       }
+    }
+}
+
+
+/* Add a file position to a message, if it is not already present for the
+   message.
+   file is the file name.
+   start_line is the line number where the string starts, or (size_t)(-1) if no
+   line number is available.  */
+
+void
+po_message_add_filepos (po_message_t message, const char *file, size_t start_line)
+{
+  message_ty *mp = (message_ty *) message;
+
+  message_comment_filepos (mp, file, start_line);
+}
+
+
 /* Return true if the message is marked obsolete.  */
 
 int
index 8baec019520cb2d0b02cbec9bd3eed4f0e9b8d96..e54d966ac2e14ec3ab5bb2e5ae54b757bd675f2f 100644 (file)
@@ -188,6 +188,18 @@ extern void po_message_set_extracted_comments (po_message_t message, const char
    range.  */
 extern po_filepos_t po_message_filepos (po_message_t message, int i);
 
+/* Remove the i-th file position from a message.
+   The indices of all following file positions for the message are decremented
+   by one.  */
+extern void po_message_remove_filepos (po_message_t message, int i);
+
+/* Add a file position to a message, if it is not already present for the
+   message.
+   file is the file name.
+   start_line is the line number where the string starts, or (size_t)(-1) if no
+   line number is available.  */
+extern void po_message_add_filepos (po_message_t message, const char *file, size_t start_line);
+
 /* Return true if the message is marked obsolete.  */
 extern int po_message_is_obsolete (po_message_t message);
 
index f6358c9a36ee6b2ac7662e798bc2f9cc11e4bdbf..16d477a3cb0367ae13fffd959bdcb846c14053de 100644 (file)
@@ -10,6 +10,7 @@ po_file_write
 po_filepos_file
 po_filepos_start_line
 po_header_field
+po_message_add_filepos
 po_message_check_format
 po_message_comments
 po_message_create
@@ -25,6 +26,7 @@ po_message_msgid
 po_message_msgid_plural
 po_message_msgstr
 po_message_msgstr_plural
+po_message_remove_filepos
 po_message_set_comments
 po_message_set_extracted_comments
 po_message_set_format