summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-10-06 12:35:15 +0900
committerDaiki Ueno <ueno@gnu.org>2015-10-06 12:35:43 +0900
commite140a5832aa431d81af938b3e4368555fd3dbb02 (patch)
treee2cfc4230bb2de3ee340fd9efc1a752fa8395b1d
parentd5a1f03517517ac2474ee50ea0b4f5d270457478 (diff)
downloadexternal_gettext-e140a5832aa431d81af938b3e4368555fd3dbb02.zip
external_gettext-e140a5832aa431d81af938b3e4368555fd3dbb02.tar.gz
external_gettext-e140a5832aa431d81af938b3e4368555fd3dbb02.tar.bz2
msgfmt: More refactoring on --desktop
* 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.
-rw-r--r--gettext-tools/src/ChangeLog8
-rw-r--r--gettext-tools/src/msgfmt.c16
-rw-r--r--gettext-tools/src/write-desktop.c13
3 files changed, 23 insertions, 14 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 95b0b33..5272c06 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,12 @@
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
* msgfmt.c (get_languages): Avoid redundant memory allocation.
(msgfmt_operand_list_init): New function.
@@ -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):
diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c
index c139803..3dfafdc 100644
--- a/gettext-tools/src/msgfmt.c
+++ b/gettext-tools/src/msgfmt.c
@@ -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;
}
diff --git a/gettext-tools/src/write-desktop.c b/gettext-tools/src/write-desktop.c
index cb45f8a..6cf1db7 100644
--- a/gettext-tools/src/write-desktop.c
+++ b/gettext-tools/src/write-desktop.c
@@ -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);