]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New functions message_list_copy, msgdomain_list_copy.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Nov 2006 12:34:20 +0000 (12:34 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:23 +0000 (12:14 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/message.c
gettext-tools/src/message.h

index 2ebb8b1fc6b0ab4431a2747eb7f9c9a6167b4f88..1c3c9f8c5b062e0ea637f29bdb3e1cf9c557136c 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-25  Bruno Haible  <bruno@clisp.org>
+
+       * message.h (message_list_copy, msgdomain_list_copy): New declarations.
+       * message.c (message_list_copy, msgdomain_list_copy): New functions.
+
 2006-11-25  Bruno Haible  <bruno@clisp.org>
 
        * msgl-iconv.h (iconv_msgdomain_list): Add update_header argument.
index b7019f3056202e5828bcdbd7d1f73cffea87dc29..6bacc7fbfd6efb86062f06f82b1035232169abfb 100644 (file)
@@ -448,6 +448,24 @@ message_list_msgids_changed (message_list_ty *mlp)
 }
 
 
+message_list_ty *
+message_list_copy (message_list_ty *mlp, int copy_level)
+{
+  message_list_ty *result;
+  size_t j;
+
+  result = message_list_alloc (mlp->use_hashtable);
+  for (j = 0; j < mlp->nitems; j++)
+    {
+      message_ty *mp = mlp->item[j];
+
+      message_list_append (result, copy_level ? mp : message_copy (mp));
+    }
+
+  return result;
+}
+
+
 message_ty *
 message_list_search (message_list_ty *mlp,
                     const char *msgctxt, const char *msgid)
@@ -780,6 +798,43 @@ msgdomain_list_sublist (msgdomain_list_ty *mdlp, const char *domain,
 }
 
 
+/* Copy a message domain list.
+   If copy_level = 0, also copy the messages.  If copy_level = 1, share the
+   messages but copy the domains.  If copy_level = 2, share the domains.  */
+msgdomain_list_ty *
+msgdomain_list_copy (msgdomain_list_ty *mdlp, int copy_level)
+{
+  msgdomain_list_ty *result;
+  size_t j;
+
+  result = XMALLOC (msgdomain_list_ty);
+  result->nitems = 0;
+  result->nitems_max = 0;
+  result->item = NULL;
+  result->use_hashtable = mdlp->use_hashtable;
+  result->encoding = mdlp->encoding;
+
+  for (j = 0; j < mdlp->nitems; j++)
+    {
+      msgdomain_ty *mdp = mdlp->item[j];
+
+      if (copy_level < 2)
+       {
+         msgdomain_ty *result_mdp = XMALLOC (msgdomain_ty);
+
+         result_mdp->domain = mdp->domain;
+         result_mdp->messages = message_list_copy (mdp->messages, copy_level);
+
+         msgdomain_list_append (result, result_mdp);
+       }
+      else
+       msgdomain_list_append (result, mdp);
+    }
+
+  return result;
+}
+
+
 #if 0 /* unused */
 message_ty *
 msgdomain_list_search (msgdomain_list_ty *mdlp,
index dc7a234ee2ca26039b91f69f995a22c9ae0931c2..09648831e369342166546f6c12297c0f4d3136e4 100644 (file)
@@ -225,6 +225,11 @@ extern void
    changed.  */
 extern bool
        message_list_msgids_changed (message_list_ty *mlp);
+/* Copy a message list.
+   If copy_level = 0, also copy the messages.  If copy_level = 1, share the
+   messages.  */
+extern message_list_ty *
+       message_list_copy (message_list_ty *mlp, int copy_level);
 extern message_ty *
        message_list_search (message_list_ty *mlp,
                            const char *msgctxt, const char *msgid);
@@ -298,6 +303,11 @@ extern void
 extern message_list_ty *
        msgdomain_list_sublist (msgdomain_list_ty *mdlp, const char *domain,
                               bool create);
+/* Copy a message domain list.
+   If copy_level = 0, also copy the messages.  If copy_level = 1, share the
+   messages but copy the domains.  If copy_level = 2, share the domains.  */
+extern msgdomain_list_ty *
+       msgdomain_list_copy (msgdomain_list_ty *mdlp, int copy_level);
 extern message_ty *
        msgdomain_list_search (msgdomain_list_ty *mdlp,
                              const char *msgctxt, const char *msgid);