/* Initializes a new PO file.
- Copyright (C) 2001-2022 Free Software Foundation, Inc.
+ Copyright (C) 2001-2023 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
char *line;
size_t linesize;
size_t linelen;
+ const char *result;
int exitstatus;
/* Call the team-address shell script. */
line = NULL; linesize = 0;
linelen = getline (&line, &linesize, fp);
if (linelen == (size_t)(-1))
- line = "";
- else if (linelen > 0 && line[linelen - 1] == '\n')
- line[linelen - 1] = '\0';
+ result = "";
+ else
+ {
+ if (linelen > 0 && line[linelen - 1] == '\n')
+ line[linelen - 1] = '\0';
+ result = line;
+ }
fclose (fp);
goto failed;
}
- return line;
+ return result;
}
failed:
if (gettextcldrdir != NULL && gettextcldrdir[0] != '\0')
{
const char *gettextlibdir;
- char *dirs[3], *last_dir;
+ const char *dirs[3];
+ char *last_dir;
const char *argv[4];
pid_t child;
int fd[1];
enum is_wrap do_wrap;
enum is_syntax_check do_syntax_check[NSYNTAXCHECKS];
message_ty *mp;
- char *msgstr;
size_t i;
/* See whether we shall exclude this message. */
}
else
{
+ const char *msgstr;
+
/* Construct the msgstr from the prefix and suffix, otherwise use the
empty string. */
if (msgstr_prefix)
bool comment_is_utf8)
{
char *msgid_plural;
- char *msgstr1;
- size_t msgstr1_len;
- char *msgstr;
- size_t i;
msgid_plural = string;
/* See if the message is already a plural message. */
if (mp->msgid_plural == NULL)
{
+ char *msgstr1_malloc = NULL;
+ const char *msgstr1;
+ size_t msgstr1_len;
+ char *msgstr;
+ size_t i;
+
mp->msgid_plural = msgid_plural;
/* Construct the first plural form from the prefix and suffix,
otherwise use the empty string. The translator will have to
provide additional plural forms. */
if (msgstr_prefix)
- msgstr1 =
- xasprintf ("%s%s%s", msgstr_prefix, msgid_plural, msgstr_suffix);
+ {
+ msgstr1_malloc =
+ xasprintf ("%s%s%s", msgstr_prefix, msgid_plural, msgstr_suffix);
+ msgstr1 = msgstr1_malloc;
+ }
else
msgstr1 = "";
msgstr1_len = strlen (msgstr1) + 1;
memcpy (msgstr + mp->msgstr_len, msgstr1, msgstr1_len);
mp->msgstr = msgstr;
mp->msgstr_len = mp->msgstr_len + msgstr1_len;
- if (msgstr_prefix)
- free (msgstr1);
+ free (msgstr1_malloc);
/* Determine whether the context specifies that the msgid_plural is a
format string. */
else if (msgstr_prefix == NULL && msgstr_suffix != NULL)
msgstr_prefix = "";
- /* Default output directory is the current directory. */
- if (output_dir == NULL)
- output_dir = ".";
+ {
+ /* Default output directory is the current directory. */
+ const char *defaulted_output_dir = (output_dir != NULL ? output_dir : ".");
- /* Construct the name of the output file. If the default domain has
- the special name "-" we write to stdout. */
- if (output_file)
- {
- if (IS_RELATIVE_FILE_NAME (output_file) && strcmp (output_file, "-") != 0)
- /* Please do NOT add a .po suffix! */
- file_name = xconcatenated_filename (output_dir, output_file, NULL);
- else
- file_name = xstrdup (output_file);
- }
- else if (strcmp (default_domain, "-") == 0)
- file_name = "-";
- else
- file_name = xconcatenated_filename (output_dir, default_domain, ".po");
+ /* Construct the name of the output file. If the default domain has
+ the special name "-" we write to stdout. */
+ if (output_file)
+ {
+ if (IS_RELATIVE_FILE_NAME (output_file) && strcmp (output_file, "-") != 0)
+ /* Please do NOT add a .po suffix! */
+ file_name =
+ xconcatenated_filename (defaulted_output_dir, output_file, NULL);
+ else
+ file_name = xstrdup (output_file);
+ }
+ else if (strcmp (default_domain, "-") == 0)
+ file_name = "-";
+ else
+ file_name =
+ xconcatenated_filename (defaulted_output_dir, default_domain, ".po");
+ }
/* Determine list of files we have to process. */
if (files_from != NULL)