]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Update after gnulib changed.
authorBruno Haible <bruno@clisp.org>
Thu, 5 Jun 2025 19:30:10 +0000 (21:30 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 5 Jun 2025 19:30:10 +0000 (21:30 +0200)
* gettext-tools/src/msgl-iconv.h (convert_string_desc_directly): Change result
type to rw_string_desc_t.
* gettext-tools/src/msgl-iconv.c (convert_string_desc_directly): Likewise.
* gettext-tools/src/its.c (_its_is_valid_simple_gen_xml): Omit casts to
'char *'. Don't use sd_c_casecmp, sd_cmp as function pointers.
* gettext-tools/src/xg-encoding.h (string_desc_from_current_source_encoding):
Change result type to rw_string_desc_t.
* gettext-tools/src/xg-encoding.c (from_current_source_encoding): Return
converted result directly, without a cast.
(string_desc_from_current_source_encoding): Change result type to
rw_string_desc_t. Return converted result directly, without a cast. Invoke
sd_readwrite.
* gettext-tools/src/x-perl.c (get_here_document): Add benign cast.
(extract_quotelike_pass1, extract_quotelike_pass1_utf8): Change result type to
rw_string_desc_t.
(extract_quotelike, extract_triple_quotelike): Update.
(extract_quotelike_pass3): Add benign casts.
(interpolate_keywords): Don't call sd_set_char_at on a string_desc_t.
* gettext-tools/src/x-rust.c (handle_comments, string_literal_value): Omit casts
to 'char *'. Add benign casts.
(extract_from_function_call, extract_from_function_call_like,
extract_from_node): Omit casts to 'char *'.

gettext-tools/src/its.c
gettext-tools/src/msgl-iconv.c
gettext-tools/src/msgl-iconv.h
gettext-tools/src/x-perl.c
gettext-tools/src/x-rust.c
gettext-tools/src/xg-encoding.c
gettext-tools/src/xg-encoding.h

index 4f6301dd0b605ad0fcccdea6316ffa30906b6918..d2cecb31d0e56830e48ba59dafc72cf8d56982b5 100644 (file)
@@ -2341,7 +2341,7 @@ _its_is_valid_simple_gen_xml (const char *contents,
           if (add_to_node != NULL && !slash_before_tag)
             {
               string_desc_t name =
-                sd_new_addr (name_end - name_start, (char *) name_start);
+                sd_new_addr (name_end - name_start, name_start);
               char *name_c = xsd_c (name);
               if (ignore_case)
                 {
@@ -2434,10 +2434,10 @@ _its_is_valid_simple_gen_xml (const char *contents,
                     {
                       string_desc_t attr_name =
                         sd_new_addr (attr_name_end - attr_name_start,
-                                     (char *) attr_name_start);
+                                     attr_name_start);
                       string_desc_t attr_value =
                         sd_new_addr (attr_value_end - attr_value_start,
-                                     (char *) attr_value_start);
+                                     attr_value_start);
                       char *attr_name_c = xsd_c (attr_name);
                       char *attr_value_c = xsd_c (attr_value);
                       xmlAttr *attr =
@@ -2474,8 +2474,7 @@ _its_is_valid_simple_gen_xml (const char *contents,
             return false;
           /* Seen a complete <...> element start/end.  */
           /* Verify that the tag is allowed.  */
-          string_desc_t tag =
-            sd_new_addr (name_end - name_start, (char *) name_start);
+          string_desc_t tag = sd_new_addr (name_end - name_start, name_start);
           if (!(valid_element == NULL || valid_element (tag)))
             return false;
           if (slash_after_tag || (no_end_element != NULL && no_end_element (tag)))
@@ -2499,8 +2498,9 @@ _its_is_valid_simple_gen_xml (const char *contents,
               if (open_elements_count == 0)
                 /* The end of an element without a corresponding start.  */
                 return false;
-              if ((ignore_case ? sd_c_casecmp : sd_cmp)
-                  (open_elements[open_elements_count - 1], tag)
+              if ((ignore_case
+                   ? sd_c_casecmp (open_elements[open_elements_count - 1], tag)
+                   : sd_cmp (open_elements[open_elements_count - 1], tag))
                   != 0)
                 return false;
               open_elements_count--;
index 178940465ba13ce51131fc88f0cab2e0d15f0c5f..eaa36fe1674f3f0cee71ed00b922ab634575cfbe 100644 (file)
@@ -95,7 +95,7 @@ convert_string_directly (iconv_t cd, const char *string,
   return NULL;
 }
 
-string_desc_t
+rw_string_desc_t
 convert_string_desc_directly (iconv_t cd, string_desc_t string,
                               const struct conversion_context* context)
 {
@@ -108,7 +108,7 @@ convert_string_desc_directly (iconv_t cd, string_desc_t string,
 
   conversion_error (context, textmode_xerror_handler);
   /* NOTREACHED */
-  return sd_new_empty ();
+  return sd_readwrite (sd_new_empty ());
 }
 
 static char *
index 955b05779e34144864b966216e676133192fd6ba..4d745b42e8c12e63dba5b170b75de9c1579dcdb7 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list character set conversion.
-   Copyright (C) 2001-2024 Free Software Foundation, Inc.
+   Copyright (C) 2001-2025 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
@@ -49,7 +49,7 @@ struct conversion_context
    Assumes that either FROM_CODE or TO_CODE is UTF-8.  */
 extern char *convert_string_directly (iconv_t cd, const char *string,
                                       const struct conversion_context* context);
-extern string_desc_t
+extern rw_string_desc_t
        convert_string_desc_directly (iconv_t cd, string_desc_t string,
                                      const struct conversion_context* context);
 
index dd640e08fed97088f882bf8c838228f9a9e57cce..d286b10c12bc96e5111dd081565ee74e958fa40e 100644 (file)
@@ -509,7 +509,8 @@ get_here_document (struct perl_extractor *xp, const char *delimiter)
         my_linebuf[read_bytes - 1] = '\n';
 
       /* Append this line to the accumulator.  */
-      sb_xappend_desc (&buffer, sd_new_addr (read_bytes, my_linebuf));
+      sb_xappend_desc (&buffer,
+                       sd_new_addr (read_bytes, (const char *) my_linebuf));
     }
 
   /* Done accumulating the here document.  */
@@ -736,7 +737,7 @@ free_token (token_ty *tp)
    of the semantics of the construct.  Return the complete string,
    including the starting and the trailing delimiter, with backslashes
    removed where appropriate.  */
-static string_desc_t
+static rw_string_desc_t
 extract_quotelike_pass1 (struct perl_extractor *xp, int delim)
 {
   struct string_buffer buffer;
@@ -782,8 +783,8 @@ extract_quotelike_pass1 (struct perl_extractor *xp, int delim)
 
       if (nested && c == delim)
         {
-          string_desc_t inner = extract_quotelike_pass1 (xp, delim);
-          sb_xappend_desc (&buffer, inner);
+          rw_string_desc_t inner = extract_quotelike_pass1 (xp, delim);
+          sb_xappend_desc (&buffer, sd_readonly (inner));
           sd_free (inner);
         }
       else if (c == '\\')
@@ -814,12 +815,12 @@ extract_quotelike_pass1 (struct perl_extractor *xp, int delim)
 
 /* Like extract_quotelike_pass1, but return the complete string in UTF-8
    encoding.  */
-static string_desc_t
+static rw_string_desc_t
 extract_quotelike_pass1_utf8 (struct perl_extractor *xp, int delim)
 {
-  string_desc_t string = extract_quotelike_pass1 (xp, delim);
-  string_desc_t utf8_string =
-    string_desc_from_current_source_encoding (string, lc_string,
+  rw_string_desc_t string = extract_quotelike_pass1 (xp, delim);
+  rw_string_desc_t utf8_string =
+    string_desc_from_current_source_encoding (sd_readonly (string), lc_string,
                                               logical_file_name,
                                               xp->line_number);
   if (sd_data (utf8_string) != sd_data (string))
@@ -914,7 +915,7 @@ extract_oct (const char *string, size_t len, unsigned int *result)
 static void
 extract_quotelike (struct perl_extractor *xp, token_ty *tp, int delim)
 {
-  string_desc_t string = extract_quotelike_pass1_utf8 (xp, delim);
+  rw_string_desc_t string = extract_quotelike_pass1_utf8 (xp, delim);
   size_t len = sd_length (string);
 
   tp->type = token_type_string;
@@ -934,13 +935,13 @@ static void
 extract_triple_quotelike (struct perl_extractor *xp, token_ty *tp, int delim,
                           bool interpolate)
 {
-  string_desc_t string;
+  rw_string_desc_t string;
 
   tp->type = token_type_regex_op;
 
   string = extract_quotelike_pass1_utf8 (xp, delim);
   if (interpolate)
-    interpolate_keywords (xp, string, xp->line_number);
+    interpolate_keywords (xp, sd_readonly (string), xp->line_number);
   sd_free (string);
 
   if (delim == '(' || delim == '<' || delim == '{' || delim == '[')
@@ -957,7 +958,7 @@ extract_triple_quotelike (struct perl_extractor *xp, token_ty *tp, int delim,
     }
   string = extract_quotelike_pass1_utf8 (xp, delim);
   if (interpolate)
-    interpolate_keywords (xp, string, xp->line_number);
+    interpolate_keywords (xp, sd_readonly (string), xp->line_number);
   sd_free (string);
 }
 
@@ -1091,7 +1092,8 @@ extract_quotelike_pass3 (struct perl_extractor *xp, token_ty *tp)
                 int length =
                   u8_uctomb ((unsigned char *) tmpbuf, oct_number, 2);
                 if (length > 0)
-                  sb_xappend_desc (&buffer, sd_new_addr (length, tmpbuf));
+                  sb_xappend_desc (&buffer,
+                                   sd_new_addr (length, (const char *) tmpbuf));
               }
               continue;
             case 'x':
@@ -1140,7 +1142,8 @@ extract_quotelike_pass3 (struct perl_extractor *xp, token_ty *tp)
                 int length =
                   u8_uctomb ((unsigned char *) tmpbuf, hex_number, 6);
                 if (length > 0)
-                  sb_xappend_desc (&buffer, sd_new_addr (length, tmpbuf));
+                  sb_xappend_desc (&buffer,
+                                   sd_new_addr (length, (const char *) tmpbuf));
               }
               continue;
             case 'c':
@@ -1178,7 +1181,7 @@ extract_quotelike_pass3 (struct perl_extractor *xp, token_ty *tp)
                             u8_uctomb ((unsigned char *) tmpbuf, unicode, 6);
                           if (length > 0)
                             sb_xappend_desc (&buffer,
-                                             sd_new_addr (length, tmpbuf));
+                                             sd_new_addr (length, (const char *) tmpbuf));
                         }
 
                       free (name);
@@ -1878,7 +1881,7 @@ interpolate_keywords (struct perl_extractor *xp, string_desc_t string,
               {
                 string_desc_t contents = sb_contents (&buffer);
                 if (!maybe_hash_deref)
-                  sd_set_char_at (contents, 0, '%');
+                  ((char *) sd_data (contents))[0] = '%';
                 if (hash_find_entry (&keywords,
                                      sd_data (contents),
                                      sd_length (contents),
index 2440bb9b82eabd0b64a54335d096d7a1bb44098a..90f3d9401cffb043a47233f99e87eec4823585de 100644 (file)
@@ -280,7 +280,7 @@ static void handle_comments (TSNode node, const char *contents)
     {
       string_desc_t entire =
         sd_new_addr (ts_node_end_byte (node) - ts_node_start_byte (node),
-                     (char *) contents + ts_node_start_byte (node));
+                     contents + ts_node_start_byte (node));
       /* It should start with two slashes.  */
       if (!(sd_length (entire) >= 2
             && sd_char_at (entire, 0) == '/'
@@ -293,7 +293,7 @@ static void handle_comments (TSNode node, const char *contents)
     {
       string_desc_t entire =
         sd_new_addr (ts_node_end_byte (node) - ts_node_start_byte (node),
-                     (char *) contents + ts_node_start_byte (node));
+                     contents + ts_node_start_byte (node));
       /* It should start and end with the C comment markers.  */
       if (!(sd_length (entire) >= 4
             && sd_char_at (entire, 0) == '/'
@@ -340,7 +340,7 @@ string_literal_value (TSNode node, const char *contents)
              that is non-empty and has no escape sequences.  */
           string_desc_t subnode_string =
             sd_new_addr (ts_node_end_byte (subnode) - ts_node_start_byte (subnode),
-                         (char *) contents + ts_node_start_byte (subnode));
+                         contents + ts_node_start_byte (subnode));
           return xsd_c (subnode_string);
         }
     }
@@ -358,7 +358,7 @@ string_literal_value (TSNode node, const char *contents)
         {
           string_desc_t subnode_string =
             sd_new_addr (ts_node_end_byte (subnode) - ts_node_start_byte (subnode),
-                         (char *) contents + ts_node_start_byte (subnode));
+                         contents + ts_node_start_byte (subnode));
           if (skip_leading_whitespace)
             {
               /* After backslash-newline, skip ASCII whitespace.  */
@@ -431,7 +431,7 @@ string_literal_value (TSNode node, const char *contents)
                   uint8_t buf[6];
                   int n = u8_uctomb (buf, value, sizeof (buf));
                   if (n > 0)
-                    sb_xappend_desc (&buffer, sd_new_addr (n, (char *) buf));
+                    sb_xappend_desc (&buffer, sd_new_addr (n, (const char *) buf));
                   else
                     invalid = true;
                 }
@@ -463,7 +463,7 @@ string_literal_value (TSNode node, const char *contents)
                   uint8_t buf[6];
                   int n = u8_uctomb (buf, value, sizeof (buf));
                   if (n > 0)
-                    sb_xappend_desc (&buffer, sd_new_addr (n, (char *) buf));
+                    sb_xappend_desc (&buffer, sd_new_addr (n, (const char *) buf));
                   else
                     invalid = true;
                 }
@@ -528,7 +528,7 @@ extract_from_function_call (TSNode callee_node,
 
   string_desc_t callee_name =
     sd_new_addr (ts_node_end_byte (callee_node) - ts_node_start_byte (callee_node),
-                 (char *) contents + ts_node_start_byte (callee_node));
+                 contents + ts_node_start_byte (callee_node));
 
   /* Context iterator.  */
   flag_context_list_iterator_ty next_context_iter =
@@ -680,7 +680,7 @@ extract_from_function_call_like (TSNode *callee_node, bool callee_is_macro,
     {
       string_desc_t callee_name =
         sd_new_addr (ts_node_end_byte (*callee_node) - ts_node_start_byte (*callee_node),
-                     (char *) contents + ts_node_start_byte (*callee_node));
+                     contents + ts_node_start_byte (*callee_node));
 
       next_context_iter =
         (args_count >= 2
@@ -1036,7 +1036,7 @@ extract_from_node (TSNode node,
         {
           string_desc_t subnode_string =
             sd_new_addr (ts_node_end_byte (subnode) - ts_node_start_byte (subnode),
-                         (char *) contents + ts_node_start_byte (subnode));
+                         contents + ts_node_start_byte (subnode));
           if (sd_equals (subnode_string, sd_from_c ("gettext")))
             {
               TSNode argsnode = ts_node_child_by_field_id (node, ts_field_arguments);
@@ -1056,7 +1056,7 @@ extract_from_node (TSNode node,
         {
           string_desc_t subnode_string =
             sd_new_addr (ts_node_end_byte (subnode) - ts_node_start_byte (subnode),
-                         (char *) contents + ts_node_start_byte (subnode));
+                         contents + ts_node_start_byte (subnode));
           fprintf (stderr, "identifier=%s\n", xsd_c (subnode_string));
           if (sd_equals (subnode_string, sd_from_c ("println")))
             {
index 148d8b38257e9713bf46a2f57ee295d61a0b54a7..08d3f8a324fd62414b9bddc165f5e0e11533be13 100644 (file)
@@ -184,8 +184,8 @@ from_current_source_encoding (const char *string,
       context.from_filename = file_name;
       context.message = NULL;
 
-      string = convert_string_directly (xgettext_current_source_iconv, string,
-                                        &context);
+      return convert_string_directly (xgettext_current_source_iconv, string,
+                                      &context);
 #else
       /* If we don't have iconv(), the only supported values for
          xgettext_global_source_encoding and thus also for
@@ -199,7 +199,7 @@ from_current_source_encoding (const char *string,
 }
 
 /* Like from_current_source_encoding, for a string that may contain NULs.  */
-string_desc_t
+rw_string_desc_t
 string_desc_from_current_source_encoding (string_desc_t string,
                                           lexical_context_ty lcontext,
                                           const char *file_name,
@@ -242,8 +242,8 @@ string_desc_from_current_source_encoding (string_desc_t string,
       context.from_filename = file_name;
       context.message = NULL;
 
-      string = convert_string_desc_directly (xgettext_current_source_iconv,
-                                             string, &context);
+      return convert_string_desc_directly (xgettext_current_source_iconv,
+                                           string, &context);
 #else
       /* If we don't have iconv(), the only supported values for
          xgettext_global_source_encoding and thus also for
@@ -253,5 +253,5 @@ string_desc_from_current_source_encoding (string_desc_t string,
 #endif
     }
 
-  return string;
+  return sd_readwrite (string);
 }
index 3991a1b9829a1e42f2c0362c5a646f2a6713ed9f..81bc5e295de9119b36c3dbb607461576a278c043 100644 (file)
@@ -1,5 +1,5 @@
 /* Keeping track of the encoding of strings to be extracted.
-   Copyright (C) 2001-2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2025 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
@@ -82,7 +82,7 @@ extern char *from_current_source_encoding (const char *string,
                                            size_t line_number);
 
 /* Like from_current_source_encoding, for a string that may contain NULs.  */
-extern string_desc_t
+extern rw_string_desc_t
        string_desc_from_current_source_encoding (string_desc_t string,
                                                  lexical_context_ty lcontext,
                                                  const char *file_name,