]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Refactor: Use 'const' in a few more places.
authorBruno Haible <bruno@clisp.org>
Tue, 3 Dec 2024 17:19:15 +0000 (18:19 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 3 Dec 2024 17:19:15 +0000 (18:19 +0100)
* gnulib-local/lib/mem-hash-map.h (hash_find_entry): Mark htab as a 'const' pointer.
* gnulib-local/lib/mem-hash-map.c (lookup, hash_find_entry): Likewise.
* gettext-tools/src/message.h (message_list_search): Mark mlp as a 'const' pointer.
* gettext-tools/src/message.c (message_list_search): Likewise.
* gettext-tools/src/msgl-ascii.h (is_ascii_string_list): Mark slp as a 'const' pointer.
(is_ascii_message): Mark mp as a 'const' pointer.
(is_ascii_message_list): Mark mlp as a 'const' pointer.
(is_ascii_msgdomain_list): Mark mdlp as a 'const' pointer.
* gettext-tools/src/msgl-ascii.c (is_ascii_string_list): Mark slp as a 'const' pointer.
(is_ascii_message): Mark mp as a 'const' pointer.
(is_ascii_message_list): Mark mlp as a 'const' pointer.
(is_ascii_msgdomain_list): Mark mdlp as a 'const' pointer.
* gettext-tools/src/msgl-ofn.h (message_has_filenames_with_spaces): Mark mp as a 'const' pointer.
(message_list_has_filenames_with_spaces): Mark mlp as a 'const' pointer.
(msgdomain_list_has_filenames_with_spaces): Mark mdlp as a 'const' pointer.
* gettext-tools/src/msgl-ofn.c (message_has_filenames_with_spaces): Mark mp as a 'const' pointer.
(message_list_has_filenames_with_spaces): Mark mlp as a 'const' pointer.
(msgdomain_list_has_filenames_with_spaces): Mark mdlp as a 'const' pointer.
* gettext-tools/src/msgl-check.h (check_message_list): Mark mlp as a 'const' pointer.
* gettext-tools/src/msgl-check.c (check_plural, check_message_list): Likewise.

gettext-tools/src/message.c
gettext-tools/src/message.h
gettext-tools/src/msgl-ascii.c
gettext-tools/src/msgl-ascii.h
gettext-tools/src/msgl-check.c
gettext-tools/src/msgl-check.h
gettext-tools/src/msgl-ofn.c
gettext-tools/src/msgl-ofn.h
gnulib-local/lib/mem-hash-map.c
gnulib-local/lib/mem-hash-map.h

index 8d6b88de000833920af7a1b3383dc4ab87eb1675..990c475c133dee33774f64b8dbe034c2fe7f91bd 100644 (file)
@@ -504,7 +504,7 @@ message_list_copy (message_list_ty *mlp, int copy_level)
 
 
 message_ty *
-message_list_search (message_list_ty *mlp,
+message_list_search (const message_list_ty *mlp,
                      const char *msgctxt, const char *msgid)
 {
   if (mlp->use_hashtable)
index 377272f52e51aae7856f76b8ed7071f3acf8f6d4..d0f1c8c985517ade3ed6bd74dd795375f24f138c 100644 (file)
@@ -290,7 +290,7 @@ extern bool
 extern message_list_ty *
        message_list_copy (message_list_ty *mlp, int copy_level);
 extern message_ty *
-       message_list_search (message_list_ty *mlp,
+       message_list_search (const message_list_ty *mlp,
                             const char *msgctxt, const char *msgid);
 /* Return the message in MLP which maximizes the fuzzy_search_goal_function.
    Only messages with a fuzzy_search_goal_function > FUZZY_THRESHOLD are
index a11f20b539e4dec23cefcf80f3263ee1edea756f..07bcd74ad3db9db5871d2ef1b559b301eab09ab2 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list test for ASCII character set.
-   Copyright (C) 2001-2002, 2005-2006, 2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2024 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
@@ -50,7 +50,7 @@ is_ascii_string_desc (string_desc_t string)
 }
 
 bool
-is_ascii_string_list (string_list_ty *slp)
+is_ascii_string_list (const string_list_ty *slp)
 {
   size_t i;
 
@@ -62,7 +62,7 @@ is_ascii_string_list (string_list_ty *slp)
 }
 
 bool
-is_ascii_message (message_ty *mp)
+is_ascii_message (const message_ty *mp)
 {
   const char *p = mp->msgstr;
   const char *p_end = p + mp->msgstr_len;
@@ -99,7 +99,7 @@ is_ascii_message (message_ty *mp)
 }
 
 bool
-is_ascii_message_list (message_list_ty *mlp)
+is_ascii_message_list (const message_list_ty *mlp)
 {
   size_t j;
 
@@ -111,7 +111,7 @@ is_ascii_message_list (message_list_ty *mlp)
 }
 
 bool
-is_ascii_msgdomain_list (msgdomain_list_ty *mdlp)
+is_ascii_msgdomain_list (const msgdomain_list_ty *mdlp)
 {
   size_t k;
 
index b86bd428382de75814b1e5bdfb6ca078770f3367..35212eae86747d717e83635e4b5e788b4ae0bd33 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list test for ASCII character set.
-   Copyright (C) 2001-2003, 2005, 2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2024 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
@@ -34,13 +34,13 @@ extern bool
 extern bool
        is_ascii_string_desc (string_desc_t string);
 extern bool
-       is_ascii_string_list (string_list_ty *slp);
+       is_ascii_string_list (const string_list_ty *slp);
 extern bool
-       is_ascii_message (message_ty *mp);
+       is_ascii_message (const message_ty *mp);
 extern bool
-       is_ascii_message_list (message_list_ty *mlp);
+       is_ascii_message_list (const message_list_ty *mlp);
 extern bool
-       is_ascii_msgdomain_list (msgdomain_list_ty *mdlp);
+       is_ascii_msgdomain_list (const msgdomain_list_ty *mdlp);
 
 
 #ifdef __cplusplus
index 3931a1f3679fbb58857dc25a22238c5e821236ab..3d944dcc8969f7690d236200761886fd8c83f604 100644 (file)
@@ -243,7 +243,7 @@ plural_help (const char *nullentry)
    If no errors, returns in *DISTRIBUTION information about the plural_eval
    values distribution.  */
 static int
-check_plural (message_list_ty *mlp,
+check_plural (const message_list_ty *mlp,
               int ignore_untranslated_messages,
               int ignore_fuzzy_messages,
               struct plural_distribution *distributionp,
@@ -853,7 +853,7 @@ check_message (const message_ty *mp,
 /* Perform all checks on a message list.
    Return the number of errors that were seen.  */
 int
-check_message_list (message_list_ty *mlp,
+check_message_list (const message_list_ty *mlp,
                     int ignore_untranslated_messages,
                     int ignore_fuzzy_messages,
                     int check_newlines,
index 7073bbd09ac9c4e796f57da5372b4bb9d4d0b757..b9f57ea07f9db198d3410d83e149089a92a1a78e 100644 (file)
@@ -54,7 +54,7 @@ extern int check_message (const message_ty *mp,
 
 /* Perform all checks on a message list.
    Return the number of errors that were seen.  */
-extern int check_message_list (message_list_ty *mlp,
+extern int check_message_list (const message_list_ty *mlp,
                                int ignore_untranslated_messages,
                                int ignore_fuzzy_messages,
                                int check_newlines,
index a58dfedd459c897819438c1a337f479ed6007c29..88efe7d0e1225065b7d9f3e12088cc9c9282ba13 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list test for ordinary file names.
-   Copyright (C) 2021 Free Software Foundation, Inc.
+   Copyright (C) 2021-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 
 
 bool
-message_has_filenames_with_spaces (message_ty *mp)
+message_has_filenames_with_spaces (const message_ty *mp)
 {
   size_t n = mp->filepos_count;
   size_t i;
@@ -41,7 +41,7 @@ message_has_filenames_with_spaces (message_ty *mp)
 }
 
 bool
-message_list_has_filenames_with_spaces (message_list_ty *mlp)
+message_list_has_filenames_with_spaces (const message_list_ty *mlp)
 {
   size_t j;
 
@@ -53,7 +53,7 @@ message_list_has_filenames_with_spaces (message_list_ty *mlp)
 }
 
 bool
-msgdomain_list_has_filenames_with_spaces (msgdomain_list_ty *mdlp)
+msgdomain_list_has_filenames_with_spaces (const msgdomain_list_ty *mdlp)
 {
   size_t k;
 
index 8e83de2c29d49cfba3fa4fca82ce83d9f6646d10..442bfe4fa7e1b9c7e6ff1c784254e1d53a90cfa3 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list test for ordinary file names.
-   Copyright (C) 2021 Free Software Foundation, Inc.
+   Copyright (C) 2021-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -31,11 +31,11 @@ extern "C" {
 /* Tests whether some of the file names in the message locations has spaces.  */
 
 extern bool
-       message_has_filenames_with_spaces (message_ty *mp);
+       message_has_filenames_with_spaces (const message_ty *mp);
 extern bool
-       message_list_has_filenames_with_spaces (message_list_ty *mlp);
+       message_list_has_filenames_with_spaces (const message_list_ty *mlp);
 extern bool
-       msgdomain_list_has_filenames_with_spaces (msgdomain_list_ty *mdlp);
+       msgdomain_list_has_filenames_with_spaces (const msgdomain_list_ty *mdlp);
 
 
 #ifdef __cplusplus
index 901592d50ae19908263419fc0bb00daaf0435b5a..b0c3d66a88b417ff91030e83534d2903c9694382 100644 (file)
@@ -1,5 +1,5 @@
 /* hash - implement simple hashing table where the keys are memory blocks.
-   Copyright (C) 1994-1995, 2000-2006, 2018, 2020, 2023 Free Software Foundation, Inc.
+   Copyright (C) 1994-2024 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, October 1994.
 
    This program is free software: you can redistribute it and/or modify
@@ -144,7 +144,7 @@ compute_hashval (const void *key, size_t keylen)
    Return the index of the entry, if present, or otherwise the index a free
    entry where it could be inserted.  */
 static size_t
-lookup (hash_table *htab,
+lookup (const hash_table *htab,
         const void *key, size_t keylen,
         unsigned long int hval)
 {
@@ -187,7 +187,7 @@ lookup (hash_table *htab,
 /* Look up the value of a key in the given table.
    If found, return 0 and set *RESULT to it.  Otherwise return -1.  */
 int
-hash_find_entry (hash_table *htab, const void *key, size_t keylen,
+hash_find_entry (const hash_table *htab, const void *key, size_t keylen,
                  void **result)
 {
   hash_entry *table = htab->table;
index e0905aaafd6ec32aebc9bdd32fa62a7162e645c2..9864812d71e89ebfa78633c9a71fb944563e3d20 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 2000-2003, 2005-2006, 2023 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -45,7 +45,7 @@ extern int hash_destroy (hash_table *htab);
 
 /* Look up the value of a key in the given table.
    If found, return 0 and set *RESULT to it.  Otherwise return -1.  */
-extern int hash_find_entry (hash_table *htab,
+extern int hash_find_entry (const hash_table *htab,
                             const void *key, size_t keylen,
                             void **result);