+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.
/* 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)
#include "c-ctype.h"
#include "error.h"
#include "xerror.h"
+#include "xvasprintf.h"
#include "javacomp.h"
#include "message.h"
#include "msgfmt.h"
}
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);
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);
}
#include "error.h"
#include "error-progname.h"
#include "xalloc.h"
+#include "xvasprintf.h"
#include "exit.h"
#include "hash.h"
#include "gettext.h"
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);
#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"
/* 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 = "";
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;