From: Bruno Haible Date: Tue, 3 Dec 2024 17:19:15 +0000 (+0100) Subject: Refactor: Use 'const' in a few more places. X-Git-Tag: v0.24~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=88b123c76bc9859c2e4a34f5406a849f31ce2ef3;p=thirdparty%2Fgettext.git Refactor: Use 'const' in a few more places. * 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. --- diff --git a/gettext-tools/src/message.c b/gettext-tools/src/message.c index 8d6b88de0..990c475c1 100644 --- a/gettext-tools/src/message.c +++ b/gettext-tools/src/message.c @@ -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) diff --git a/gettext-tools/src/message.h b/gettext-tools/src/message.h index 377272f52..d0f1c8c98 100644 --- a/gettext-tools/src/message.h +++ b/gettext-tools/src/message.h @@ -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 diff --git a/gettext-tools/src/msgl-ascii.c b/gettext-tools/src/msgl-ascii.c index a11f20b53..07bcd74ad 100644 --- a/gettext-tools/src/msgl-ascii.c +++ b/gettext-tools/src/msgl-ascii.c @@ -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 , 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; diff --git a/gettext-tools/src/msgl-ascii.h b/gettext-tools/src/msgl-ascii.h index b86bd4283..35212eae8 100644 --- a/gettext-tools/src/msgl-ascii.h +++ b/gettext-tools/src/msgl-ascii.h @@ -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 , 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 diff --git a/gettext-tools/src/msgl-check.c b/gettext-tools/src/msgl-check.c index 3931a1f36..3d944dcc8 100644 --- a/gettext-tools/src/msgl-check.c +++ b/gettext-tools/src/msgl-check.c @@ -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, diff --git a/gettext-tools/src/msgl-check.h b/gettext-tools/src/msgl-check.h index 7073bbd09..b9f57ea07 100644 --- a/gettext-tools/src/msgl-check.h +++ b/gettext-tools/src/msgl-check.h @@ -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, diff --git a/gettext-tools/src/msgl-ofn.c b/gettext-tools/src/msgl-ofn.c index a58dfedd4..88efe7d0e 100644 --- a/gettext-tools/src/msgl-ofn.c +++ b/gettext-tools/src/msgl-ofn.c @@ -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; diff --git a/gettext-tools/src/msgl-ofn.h b/gettext-tools/src/msgl-ofn.h index 8e83de2c2..442bfe4fa 100644 --- a/gettext-tools/src/msgl-ofn.h +++ b/gettext-tools/src/msgl-ofn.h @@ -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 diff --git a/gnulib-local/lib/mem-hash-map.c b/gnulib-local/lib/mem-hash-map.c index 901592d50..b0c3d66a8 100644 --- a/gnulib-local/lib/mem-hash-map.c +++ b/gnulib-local/lib/mem-hash-map.c @@ -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 , 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; diff --git a/gnulib-local/lib/mem-hash-map.h b/gnulib-local/lib/mem-hash-map.h index e0905aaaf..9864812d7 100644 --- a/gnulib-local/lib/mem-hash-map.h +++ b/gnulib-local/lib/mem-hash-map.h @@ -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);