summaryrefslogtreecommitdiffstats
path: root/gettext-tools
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-05-03 12:13:13 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:13:13 +0200
commit019d270c02816ce99e75545dab55c53291a670b3 (patch)
tree23358e1c4d11e3f12acfc80394f0320f75fcb61a /gettext-tools
parent25d7990e12e56643490f4c2133c8d4922cf95665 (diff)
downloadexternal_gettext-019d270c02816ce99e75545dab55c53291a670b3.zip
external_gettext-019d270c02816ce99e75545dab55c53291a670b3.tar.gz
external_gettext-019d270c02816ce99e75545dab55c53291a670b3.tar.bz2
Code simplification: use xasprintf.
Diffstat (limited to 'gettext-tools')
-rw-r--r--gettext-tools/src/ChangeLog11
-rw-r--r--gettext-tools/src/msginit.c6
-rw-r--r--gettext-tools/src/write-java.c10
-rw-r--r--gettext-tools/src/x-c.c8
-rw-r--r--gettext-tools/src/xgettext.c18
5 files changed, 20 insertions, 33 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 8db1b54..617d21c 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,16 @@
2006-04-30 Bruno Haible <bruno@clisp.org>
+ * msginit.c (main): Simplify by use of xasprintf().
+ * write-java.c: Include xvasprintf.h.
+ (msgdomain_write_java): Simplify by use of xasprintf().
+ * x-c.c: Include xvasprintf.h.
+ (phase8a_get): Simplify by use of xasprintf().
+ * xgettext.c: Don't include stpcpy.h.
+ (remember_a_message, remember_a_message_plural): Simplify by use of
+ xasprintf().
+
+2006-04-30 Bruno Haible <bruno@clisp.org>
+
* msgfmt.c: Include xvasprintf.h.
* msginit.c: Likewise.
* msgl-cat.c: Likewise.
diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c
index 97b15e3..a732519 100644
--- a/gettext-tools/src/msginit.c
+++ b/gettext-tools/src/msginit.c
@@ -313,11 +313,7 @@ file. This is necessary so you can test your translations.\n")));
/* Default output file name is CATALOGNAME.po. */
if (output_file == NULL)
{
- size_t cnlen = strlen (catalogname);
-
- output_file = (char *) xmalloc (cnlen + 3 + 1);
- memcpy (output_file, catalogname, cnlen);
- memcpy (output_file + cnlen, ".po", 3 + 1);
+ output_file = xasprintf ("%s.po", catalogname);
/* But don't overwrite existing PO files. */
if (access (output_file, F_OK) == 0)
diff --git a/gettext-tools/src/write-java.c b/gettext-tools/src/write-java.c
index 29ad650..b4d8f3f 100644
--- a/gettext-tools/src/write-java.c
+++ b/gettext-tools/src/write-java.c
@@ -66,6 +66,7 @@
#include "c-ctype.h"
#include "error.h"
#include "xerror.h"
+#include "xvasprintf.h"
#include "javacomp.h"
#include "message.h"
#include "msgfmt.h"
@@ -948,11 +949,7 @@ but the Java ResourceBundle format doesn't support contexts\n")));
}
if (locale_name != NULL)
- {
- class_name =
- (char *) xmalloc (strlen (resource_name) + 1 + strlen (locale_name) + 1);
- sprintf (class_name, "%s_%s", resource_name, locale_name);
- }
+ class_name = xasprintf ("%s_%s", resource_name, locale_name);
else
class_name = xstrdup (resource_name);
@@ -979,8 +976,7 @@ but the Java ResourceBundle format doesn't support contexts\n")));
if (locale_name != NULL)
{
- char *suffix = (char *) xmalloc (1 + strlen (locale_name) + 5 + 1);
- sprintf (suffix, "_%s.java", locale_name);
+ char *suffix = xasprintf ("_%s.java", locale_name);
java_file_name = concatenated_pathname (last_dir, p, suffix);
free (suffix);
}
diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c
index 4e16312..cacc773 100644
--- a/gettext-tools/src/x-c.c
+++ b/gettext-tools/src/x-c.c
@@ -33,6 +33,7 @@
#include "error.h"
#include "error-progname.h"
#include "xalloc.h"
+#include "xvasprintf.h"
#include "exit.h"
#include "hash.h"
#include "gettext.h"
@@ -1445,12 +1446,7 @@ phase8a_get (token_ty *tp)
if (tp->type == token_type_name && is_inttypes_macro (tp->string))
{
/* Turn PRIdXXX into "<PRIdXXX>". */
- size_t len = strlen (tp->string);
- char *new_string = (char *) xmalloc (len + 3);
- new_string[0] = '<';
- memcpy (new_string + 1, tp->string, len);
- new_string[len + 1] = '>';
- new_string[len + 2] = '\0';
+ char *new_string = xasprintf ("<%s>", tp->string);
free (tp->string);
tp->string = new_string;
tp->comment = add_reference (savable_comment);
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index f03166a..54ebce5 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -51,7 +51,6 @@
#include "exit.h"
#include "pathname.h"
#include "c-strcase.h"
-#include "stpcpy.h"
#include "open-po.h"
#include "read-po-abstract.h"
#include "message.h"
@@ -2040,13 +2039,7 @@ meta information, not the empty string.\n")));
/* Construct the msgstr from the prefix and suffix, otherwise use the
empty string. */
if (msgstr_prefix)
- {
- msgstr = (char *) xmalloc (strlen (msgstr_prefix)
- + strlen (msgid)
- + strlen (msgstr_suffix) + 1);
- stpcpy (stpcpy (stpcpy (msgstr, msgstr_prefix), msgid),
- msgstr_suffix);
- }
+ msgstr = xasprintf ("%s%s%s", msgstr_prefix, msgid, msgstr_suffix);
else
msgstr = "";
@@ -2245,13 +2238,8 @@ remember_a_message_plural (message_ty *mp, char *string,
otherwise use the empty string. The translator will have to
provide additional plural forms. */
if (msgstr_prefix)
- {
- msgstr1 = (char *) xmalloc (strlen (msgstr_prefix)
- + strlen (msgid_plural)
- + strlen (msgstr_suffix) + 1);
- stpcpy (stpcpy (stpcpy (msgstr1, msgstr_prefix), msgid_plural),
- msgstr_suffix);
- }
+ msgstr1 =
+ xasprintf ("%s%s%s", msgstr_prefix, msgid_plural, msgstr_suffix);
else
msgstr1 = "";
msgstr1_len = strlen (msgstr1) + 1;