]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgfmt: More refactoring on --desktop
authorDaiki Ueno <ueno@gnu.org>
Tue, 6 Oct 2015 03:35:15 +0000 (12:35 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 6 Oct 2015 03:35:43 +0000 (12:35 +0900)
* msgfmt.c (msgfmt_desktop_bulk): Distinguish the number of errors
and the exit status.
* write-desktop.c (msgdomain_write_desktop_bulk): Don't
immediately exit when fwriteerror() returns error.

gettext-tools/src/ChangeLog
gettext-tools/src/msgfmt.c
gettext-tools/src/write-desktop.c

index 95b0b337104df442b2469a0e5568bd0cfd3d23e0..5272c06ff6c95c470f583e2ba1192dea3dc59ebc 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-06  Daiki Ueno  <ueno@gnu.org>
+
+       * msgfmt.c (msgfmt_desktop_bulk): Distinguish the number of errors
+       and the exit status.
+       * write-desktop.c (msgdomain_write_desktop_bulk): Don't
+       immediately exit when fwriteerror() returns error.
+
 2015-10-06  Daiki Ueno  <ueno@gnu.org>
 
        msgfmt: Refactor --desktop handling
@@ -7,6 +14,7 @@
        (msgfmt_operand_list_append): New function.
        (msgfmt_operand_list_add_directory): New function.
        (msgfmt_desktop_bulk): Rewrite using msgfmt_operand_list_ty.
+
        * msgfmt.h (msgfmt_operand_ty)
        (msgfmt_operand_list_ty): New type.
        * write-desktop.c (msgdomain_write_desktop_bulk):
index c1398033a803bc8732ad2a4ad984b00f5edddc6c..3dfafdc6fad54256b3e6c21c0af3edcf81b1c7de 100644 (file)
@@ -1407,8 +1407,8 @@ msgfmt_operand_list_append (msgfmt_operand_list_ty *operands,
 }
 
 static int
-msgfmt_operand_list_add_directory (msgfmt_operand_list_ty *operands,
-                                   const char *directory)
+msgfmt_operand_list_add_from_directory (msgfmt_operand_list_ty *operands,
+                                        const char *directory)
 {
   string_list_ty languages;
   void *saved_dir_list;
@@ -1497,25 +1497,25 @@ msgfmt_desktop_bulk (const char *directory,
                      const char *file_name)
 {
   msgfmt_operand_list_ty operands;
-  int retval;
+  int nerrors, status;
 
   msgfmt_operand_list_init (&operands);
 
   /* Read all .po files.  */
-  retval = msgfmt_operand_list_add_directory (&operands, directory);
-  if (retval > 0)
+  nerrors = msgfmt_operand_list_add_from_directory (&operands, directory);
+  if (nerrors > 0)
     {
       msgfmt_operand_list_destroy (&operands);
-      return retval;
+      return 1;
     }
 
   /* Write the messages into .desktop file.  */
-  retval = msgdomain_write_desktop_bulk (&operands,
+  status = msgdomain_write_desktop_bulk (&operands,
                                          template_file_name,
                                          keywords,
                                          file_name);
 
   msgfmt_operand_list_destroy (&operands);
 
-  return retval;
+  return status;
 }
index cb45f8aae593ad1140974c64bb80164a768e9b76..6cf1db73b87d9397eb659fe233c0e1736a5a6431 100644 (file)
@@ -159,8 +159,7 @@ msgdomain_write_desktop_bulk (msgfmt_operand_list_ty *operands,
       if (msgfmt_reader->output_file == NULL)
         {
           desktop_reader_free (reader);
-          error (EXIT_SUCCESS,
-                 errno, _("error while opening \"%s\" for writing"),
+          error (0, errno, _("error while opening \"%s\" for writing"),
                  file_name);
           return 1;
         }
@@ -170,8 +169,7 @@ msgdomain_write_desktop_bulk (msgfmt_operand_list_ty *operands,
   if (template_file == NULL)
     {
       desktop_reader_free (reader);
-      error (EXIT_SUCCESS,
-             errno, _("error while opening \"%s\" for reading"),
+      error (0, errno, _("error while opening \"%s\" for reading"),
              template_file_name);
       return 1;
     }
@@ -180,8 +178,11 @@ msgdomain_write_desktop_bulk (msgfmt_operand_list_ty *operands,
 
   /* Make sure nothing went wrong.  */
   if (fwriteerror (msgfmt_reader->output_file))
-    error (EXIT_FAILURE, errno, _("error while writing \"%s\" file"),
-           file_name);
+    {
+      error (0, errno, _("error while writing \"%s\" file"),
+             file_name);
+      return 1;
+    }
 
   desktop_reader_free (reader);