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)
{
{
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 =
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)))
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--;
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)
{
conversion_error (context, textmode_xerror_handler);
/* NOTREACHED */
- return sd_new_empty ();
+ return sd_readwrite (sd_new_empty ());
}
static char *
/* 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
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);
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. */
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;
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 == '\\')
/* 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))
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;
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 == '[')
}
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);
}
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':
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':
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);
{
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),
{
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) == '/'
{
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) == '/'
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);
}
}
{
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. */
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;
}
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;
}
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 =
{
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
{
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);
{
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")))
{
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
}
/* 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,
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
#endif
}
- return string;
+ return sd_readwrite (string);
}
/* 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
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,