]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Silence "assignment discards ‘const’ qualifier from pointer target type" warnings.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:32:23 +0000 (01:32 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Jun 2023 13:54:10 +0000 (15:54 +0200)
* gettext-tools/src/msginit.c (language_team_address): New local variable
'result'.
(plural_forms): Adjust type of local variable 'dirs'.
* gettext-tools/src/xg-message.c (remember_a_message): Reduce scope and adjust
type of local variable 'msgstr'.
(remember_a_message_plural): New local variable 'msgstr1_malloc'.
* gettext-tools/src/xgettext.c (main): New local variable
'defaulted_output_dir'.

gettext-tools/src/msginit.c
gettext-tools/src/xg-message.c
gettext-tools/src/xgettext.c

index 21ac4cb4b517cf205abea78749b2ac8bc1ac0d8a..511cbb9faa1c33e60423263422f3754f1194d00c 100644 (file)
@@ -1,5 +1,5 @@
 /* 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
@@ -1291,6 +1291,7 @@ language_team_address ()
     char *line;
     size_t linesize;
     size_t linelen;
+    const char *result;
     int exitstatus;
 
     /* Call the team-address shell script.  */
@@ -1317,9 +1318,13 @@ language_team_address ()
     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);
 
@@ -1332,7 +1337,7 @@ language_team_address ()
         goto failed;
       }
 
-    return line;
+    return result;
   }
 
 failed:
@@ -1434,7 +1439,8 @@ plural_forms ()
   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];
index 818b8675f4120a80770aaa45cc7703caa125c620..281768768771a3b6f7250f6a5b163e926ac4a3f7 100644 (file)
@@ -249,7 +249,6 @@ remember_a_message (message_list_ty *mlp, char *msgctxt, char *msgid,
   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.  */
@@ -354,6 +353,8 @@ meta information, not the empty string.\n")));
     }
   else
     {
+      const char *msgstr;
+
       /* Construct the msgstr from the prefix and suffix, otherwise use the
          empty string.  */
       if (msgstr_prefix)
@@ -557,10 +558,6 @@ remember_a_message_plural (message_ty *mp, char *string, bool is_utf8,
                            bool comment_is_utf8)
 {
   char *msgid_plural;
-  char *msgstr1;
-  size_t msgstr1_len;
-  char *msgstr;
-  size_t i;
 
   msgid_plural = string;
 
@@ -572,14 +569,23 @@ remember_a_message_plural (message_ty *mp, char *string, bool is_utf8,
   /* 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;
@@ -588,8 +594,7 @@ remember_a_message_plural (message_ty *mp, char *string, bool is_utf8,
       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.  */
index f271b5c05d3c04c1e064befb7449db85be62b7ab..cbfa9fe39c8c5cb4e8f8c3fc3f3a969bdaa24c29 100644 (file)
@@ -765,24 +765,27 @@ xgettext cannot work without keywords to look for"));
   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)