summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src
diff options
context:
space:
mode:
authorGuido Flohr <guido@imperia.net>2014-04-10 17:40:52 +0900
committerDaiki Ueno <ueno@gnu.org>2014-05-10 08:32:38 +0900
commit2832f5c072ad569ddda09262a526018ba8fda265 (patch)
tree81bb6c37b11fbbea4cad4e259bade1f9f1f870c5 /gettext-tools/src
parent7f6b140674a2c2feb6658468dcaa97ac3f805be4 (diff)
downloadexternal_gettext-2832f5c072ad569ddda09262a526018ba8fda265.zip
external_gettext-2832f5c072ad569ddda09262a526018ba8fda265.tar.gz
external_gettext-2832f5c072ad569ddda09262a526018ba8fda265.tar.bz2
msgattrib: Add --empty option
Diffstat (limited to 'gettext-tools/src')
-rw-r--r--gettext-tools/src/ChangeLog9
-rw-r--r--gettext-tools/src/msgattrib.c30
2 files changed, 37 insertions, 2 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 6832740..ddf70f3 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,12 @@
+2014-05-10 Guido Flohr <guido@imperia.net>
+
+ msgattrib: Add --empty option to clear msgstr
+ * msgattrib.c (REMOVE_TRANSLATION): New enum value.
+ (long_options): Add --empty.
+ (main): Set REMOVE_TRANSLATION flag when --empty is given.
+ (usage): Show help of --empty.
+ (process_message_list): Handle REMOVE_TRANSLATION flag.
+
2014-05-09 Daiki Ueno <ueno@gnu.org>
vala: Interpret string literals lazily
diff --git a/gettext-tools/src/msgattrib.c b/gettext-tools/src/msgattrib.c
index 01b6f97..326f28c 100644
--- a/gettext-tools/src/msgattrib.c
+++ b/gettext-tools/src/msgattrib.c
@@ -73,7 +73,8 @@ enum
SET_OBSOLETE = 1 << 2,
RESET_OBSOLETE = 1 << 3,
REMOVE_PREV = 1 << 4,
- ADD_PREV = 1 << 5
+ ADD_PREV = 1 << 5,
+ REMOVE_TRANSLATION = 1 << 6
};
static int to_change;
@@ -84,6 +85,7 @@ static const struct option long_options[] =
{ "clear-fuzzy", no_argument, NULL, CHAR_MAX + 8 },
{ "clear-obsolete", no_argument, NULL, CHAR_MAX + 10 },
{ "clear-previous", no_argument, NULL, CHAR_MAX + 18 },
+ { "empty", no_argument, NULL, CHAR_MAX + 23 },
{ "color", optional_argument, NULL, CHAR_MAX + 19 },
{ "directory", required_argument, NULL, 'D' },
{ "escape", no_argument, NULL, 'E' },
@@ -336,6 +338,10 @@ main (int argc, char **argv)
message_print_style_filepos (filepos_comment_none);
break;
+ case CHAR_MAX + 23: /* --empty */
+ to_change |= REMOVE_TRANSLATION;
+ break;
+
default:
usage (EXIT_FAILURE);
/* NOTREACHED */
@@ -472,6 +478,8 @@ Attribute manipulation:\n"));
printf (_("\
--clear-previous remove the \"previous msgid\" from all messages\n"));
printf (_("\
+ --empty when removing 'fuzzy', also set msgstr empty\n"));
+ printf (_("\
--only-file=FILE.po manipulate only entries listed in FILE.po\n"));
printf (_("\
--ignore-file=FILE.po manipulate only entries not listed in FILE.po\n"));
@@ -615,7 +623,25 @@ process_message_list (message_list_ty *mlp,
}
if (to_change & RESET_FUZZY)
- mp->is_fuzzy = false;
+ {
+ if ((to_change & REMOVE_TRANSLATION)
+ && mp->is_fuzzy && !mp->obsolete)
+ {
+ unsigned long int nplurals = 0;
+ char *msgstr;
+ size_t pos;
+
+ for (pos = 0; pos < mp->msgstr_len; ++pos)
+ if (!mp->msgstr[pos])
+ ++nplurals;
+ free ((char *) mp->msgstr);
+ msgstr = XNMALLOC (nplurals, char);
+ memset (msgstr, '\0', nplurals);
+ mp->msgstr = msgstr;
+ mp->msgstr_len = nplurals;
+ }
+ mp->is_fuzzy = false;
+ }
/* Always keep the header entry non-obsolete. */
if ((to_change & SET_OBSOLETE) && !is_header (mp))
mp->obsolete = true;