/* Substitution of environment variables in shell format strings.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
putchar ('$');
if (opening_brace)
putchar ('{');
- string_desc_fwrite (stdout, sb_contents (&buffer));
+ sd_fwrite (stdout, sb_contents (&buffer));
if (closing_brace)
putchar ('}');
}
/* Internationalization Tag Set (ITS) handling
- Copyright (C) 2015-2024 Free Software Foundation, Inc.
+ Copyright (C) 2015-2025 Free Software Foundation, Inc.
This file was written by Daiki Ueno <ueno@gnu.org>, 2015.
doc->encoding = BAD_CAST xstrdup ("UTF-8");
return true;
}
- string_desc_t enc = string_desc_from_c ((char *) doc->encoding);
- if (string_desc_c_casecmp (enc, string_desc_from_c ("UTF-8")) == 0
- || string_desc_c_casecmp (enc, string_desc_from_c ("UTF8")) == 0)
+ string_desc_t enc = sd_from_c ((char *) doc->encoding);
+ if (sd_c_casecmp (enc, sd_from_c ("UTF-8")) == 0
+ || sd_c_casecmp (enc, sd_from_c ("UTF8")) == 0)
return true;
/* The document's encoding is not UTF-8. Conversion would be expensive. */
return false;
if (add_to_node != NULL && !slash_before_tag)
{
string_desc_t name =
- string_desc_new_addr (name_end - name_start,
- (char *) name_start);
- char *name_c = xstring_desc_c (name);
+ sd_new_addr (name_end - name_start, (char *) name_start);
+ char *name_c = xsd_c (name);
if (ignore_case)
{
/* Convert the name to lower case. */
if (add_to_node != NULL)
{
string_desc_t attr_name =
- string_desc_new_addr (attr_name_end - attr_name_start,
- (char *) attr_name_start);
+ sd_new_addr (attr_name_end - attr_name_start,
+ (char *) attr_name_start);
string_desc_t attr_value =
- string_desc_new_addr (attr_value_end - attr_value_start,
- (char *) attr_value_start);
- char *attr_name_c = xstring_desc_c (attr_name);
- char *attr_value_c = xstring_desc_c (attr_value);
+ sd_new_addr (attr_value_end - attr_value_start,
+ (char *) attr_value_start);
+ char *attr_name_c = xsd_c (attr_name);
+ char *attr_value_c = xsd_c (attr_value);
xmlAttr *attr =
xmlNewProp (current_node, BAD_CAST attr_name_c,
BAD_CAST attr_value_c);
/* Seen a complete <...> element start/end. */
/* Verify that the tag is allowed. */
string_desc_t tag =
- string_desc_new_addr (name_end - name_start, (char *) name_start);
+ sd_new_addr (name_end - name_start, (char *) 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 ? string_desc_c_casecmp : string_desc_cmp)
+ if ((ignore_case ? sd_c_casecmp : sd_cmp)
(open_elements[open_elements_count - 1], tag)
!= 0)
return false;
/* Invariant:
If tag occurs in the table, it is at an index >= lo, < hi. */
size_t i = (lo + hi) / 2; /* >= lo, < hi */
- int cmp = string_desc_cmp (tag, string_desc_from_c (allowed[i]));
+ int cmp = sd_cmp (tag, sd_from_c (allowed[i]));
if (cmp == 0)
return true;
if (cmp < 0)
/* Invariant:
If tag occurs in the table, it is at an index >= lo, < hi. */
size_t i = (lo + hi) / 2; /* >= lo, < hi */
- int cmp = string_desc_cmp (tag, string_desc_from_c (allowed[i]));
+ int cmp = sd_cmp (tag, sd_from_c (allowed[i]));
if (cmp == 0)
return true;
if (cmp < 0)
/* Specification:
https://html.spec.whatwg.org/
Search for "Tag omission in text/html: No end tag." */
- return string_desc_cmp (tag, string_desc_from_c ("br")) == 0
- || string_desc_cmp (tag, string_desc_from_c ("hr")) == 0;
+ return sd_cmp (tag, sd_from_c ("br")) == 0
+ || sd_cmp (tag, sd_from_c ("hr")) == 0;
}
/* Returns true if the argument is a piece of simple well-formed HTML
/* Message list test for ASCII character set.
- 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
bool
is_ascii_string_desc (string_desc_t string)
{
- size_t len = string_desc_length (string);
+ size_t len = sd_length (string);
size_t i;
for (i = 0; i < len; i++)
- if (!c_isascii ((unsigned char) string_desc_char_at (string, i)))
+ if (!c_isascii ((unsigned char) sd_char_at (string, i)))
return false;
return true;
}
/* Message list charset and locale charset handling.
- 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
char *result = NULL;
size_t resultlen = 0;
- if (xmem_cd_iconv (string_desc_data (string), string_desc_length (string),
+ if (xmem_cd_iconv (sd_data (string), sd_length (string),
cd, &result, &resultlen) == 0)
- return string_desc_new_addr (resultlen, result);
+ return sd_new_addr (resultlen, result);
conversion_error (context, textmode_xerror_handler);
/* NOTREACHED */
- return string_desc_new_empty ();
+ return sd_new_empty ();
}
static char *
/* Reading Desktop Entry files.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file was written by Daiki Ueno <ueno@gnu.org>.
This program is free software: you can redistribute it and/or modify
/* Finish the key part and start the locale part. */
APPEND (0);
found_locale = true;
- locale_start = string_desc_length (sb_contents (&buffer));
+ locale_start = sd_length (sb_contents (&buffer));
for (;;)
{
}
size_t before_value_lineno = pos.line_number;
- value_start = string_desc_length (sb_contents (&buffer));
+ value_start = sd_length (sb_contents (&buffer));
for (;;)
{
c = phase2_getc ();
/* xgettext awk backend.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
if (c == '\n' || c == EOF)
break;
/* We skip all leading white space, but not EOLs. */
- if (!(string_desc_length (sb_contents (&buffer)) == 0
+ if (!(sd_length (sb_contents (&buffer)) == 0
&& (c == ' ' || c == '\t')))
sb_xappend1 (&buffer, c);
}
default:
{
string_desc_t contents = sb_contents (&buffer);
- if (string_desc_length (contents) == 1
- && string_desc_char_at (contents, 0) == '_'
+ if (sd_length (contents) == 1
+ && sd_char_at (contents, 0) == '_'
&& c == '"')
{
sb_free (&buffer);
/* xgettext C/C++/ObjectiveC backend.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
case '"':
{
string_desc_t contents = sb_contents (&buffer);
- const char *buf = string_desc_data (contents);
- size_t buflen = string_desc_length (contents);
+ const char *buf = sd_data (contents);
+ size_t buflen = sd_length (contents);
/* Recognize C11 / C++11 string literals.
See (for C) ISO 9899:2011 section 6.4.5
/* Update the state. */
string_desc_t raw_contents = sb_contents (&buffer);
- const char *raw_buf = string_desc_data (raw_contents);
- size_t raw_buflen = string_desc_length (raw_contents);
+ const char *raw_buf = sd_data (raw_contents);
+ size_t raw_buflen = sd_length (raw_contents);
if (c == (state < raw_buflen ? raw_buf[state] : '"'))
{
if (state < raw_buflen)
can be part of a number token. It's called a "digit
separator". See ISO C 23 § 6.4.4.1 and § 6.4.4.2. */
string_desc_t contents = sb_contents (&buffer);
- if (string_desc_length (contents) > 0)
+ if (sd_length (contents) > 0)
{
char prev =
- string_desc_char_at (contents,
- string_desc_length (contents) - 1);
+ sd_char_at (contents, sd_length (contents) - 1);
if ((prev >= '0' && prev <= '9')
|| (prev >= 'A' && prev <= 'F')
|| (prev >= 'a' && prev <= 'f'))
/* xgettext Perl backend.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
This file was written by Guido Flohr <guido@imperia.net>, 2002-2010.
my_linebuf[read_bytes - 1] = '\n';
/* Append this line to the accumulator. */
- sb_xappend_desc (&buffer, string_desc_new_addr (read_bytes, my_linebuf));
+ sb_xappend_desc (&buffer, sd_new_addr (read_bytes, my_linebuf));
}
/* Done accumulating the here document. */
{
string_desc_t inner = extract_quotelike_pass1 (xp, delim);
sb_xappend_desc (&buffer, inner);
- string_desc_free (inner);
+ sd_free (inner);
}
else if (c == '\\')
{
string_desc_from_current_source_encoding (string, lc_string,
logical_file_name,
xp->line_number);
- if (string_desc_data (utf8_string) != string_desc_data (string))
- string_desc_free (string);
+ if (sd_data (utf8_string) != sd_data (string))
+ sd_free (string);
return utf8_string;
}
extract_quotelike (struct perl_extractor *xp, token_ty *tp, int delim)
{
string_desc_t string = extract_quotelike_pass1_utf8 (xp, delim);
- size_t len = string_desc_length (string);
+ size_t len = sd_length (string);
tp->type = token_type_string;
/* Take the string without the delimiters at the start and at the end. */
if (!(len >= 2))
abort ();
- tp->string = string_desc_c (string_desc_substring (string, 1, len - 1));
- string_desc_free (string);
+ tp->string = sd_c (sd_substring (string, 1, len - 1));
+ sd_free (string);
tp->comment = add_reference (savable_comment);
}
string = extract_quotelike_pass1_utf8 (xp, delim);
if (interpolate)
interpolate_keywords (xp, string, xp->line_number);
- string_desc_free (string);
+ sd_free (string);
if (delim == '(' || delim == '<' || delim == '{' || delim == '[')
{
string = extract_quotelike_pass1_utf8 (xp, delim);
if (interpolate)
interpolate_keywords (xp, string, xp->line_number);
- string_desc_free (string);
+ sd_free (string);
}
/* Perform pass 3 of quotelike extraction (interpolation).
int length =
u8_uctomb ((unsigned char *) tmpbuf, oct_number, 2);
if (length > 0)
- sb_xappend_desc (&buffer,
- string_desc_new_addr (length, tmpbuf));
+ sb_xappend_desc (&buffer, sd_new_addr (length, tmpbuf));
}
continue;
case 'x':
int length =
u8_uctomb ((unsigned char *) tmpbuf, hex_number, 6);
if (length > 0)
- sb_xappend_desc (&buffer,
- string_desc_new_addr (length, tmpbuf));
+ sb_xappend_desc (&buffer, sd_new_addr (length, tmpbuf));
}
continue;
case 'c':
u8_uctomb ((unsigned char *) tmpbuf, unicode, 6);
if (length > 0)
sb_xappend_desc (&buffer,
- string_desc_new_addr (length, tmpbuf));
+ sd_new_addr (length, tmpbuf));
}
free (name);
/* Hash references are treated in a special way, when looking for
our keywords. */
string_desc_t contents = sb_contents (&buffer);
- if (string_desc_char_at (contents, 0) == '$')
+ if (sd_char_at (contents, 0) == '$')
{
- if (string_desc_length (contents) == 1)
+ if (sd_length (contents) == 1)
maybe_hash_value = true;
- else if (string_desc_length (contents) == 2
- && string_desc_char_at (contents, 1) == '$')
+ else if (sd_length (contents) == 2
+ && sd_char_at (contents, 1) == '$')
{
if (!(c == '{'
|| (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
state = initial;
region = null_context_region ();
- length = string_desc_length (string);
+ length = sd_length (string);
index = 0;
token.type = token_type_string;
{
void *keyword_value;
- c = string_desc_char_at (string, index++);
+ c = sd_char_at (string, index++);
if (state == initial)
buffer.length = 0;
sb_free (&buffer);
return;
}
- c = string_desc_char_at (string, index++);
+ c = sd_char_at (string, index++);
break;
case '$':
sb_xappend1 (&buffer, '$');
{
string_desc_t contents = sb_contents (&buffer);
if (hash_find_entry (&keywords,
- string_desc_data (contents),
- string_desc_length (contents),
+ sd_data (contents),
+ sd_length (contents),
&keyword_value)
== 0)
{
flag_context_list_iterator (
flag_context_list_table_lookup (
flag_context_list_table,
- string_desc_data (contents),
- string_desc_length (contents)));
+ sd_data (contents),
+ sd_length (contents)));
region =
inheriting_region (null_context_region (),
flag_context_list_iterator_advance (
{
string_desc_t contents = sb_contents (&buffer);
if (!maybe_hash_deref)
- string_desc_set_char_at (contents, 0, '%');
+ sd_set_char_at (contents, 0, '%');
if (hash_find_entry (&keywords,
- string_desc_data (contents),
- string_desc_length (contents),
+ sd_data (contents),
+ sd_length (contents),
&keyword_value)
== 0)
{
flag_context_list_iterator (
flag_context_list_table_lookup (
flag_context_list_table,
- string_desc_data (contents),
- string_desc_length (contents)));
+ sd_data (contents),
+ sd_length (contents)));
region =
inheriting_region (null_context_region (),
flag_context_list_iterator_advance (
}
else
{
- c = string_desc_char_at (string, index++);
+ c = sd_char_at (string, index++);
if (c == '\"')
{
sb_xappend1 (&buffer, c);
}
else
{
- c = string_desc_char_at (string, index++);
+ c = sd_char_at (string, index++);
if (c == '\'')
{
sb_xappend1 (&buffer, c);
}
else
{
- c = string_desc_char_at (string, index++);
+ c = sd_char_at (string, index++);
if (c == '\"')
{
sb_xappend1 (&buffer, c);
}
else
{
- c = string_desc_char_at (string, index++);
+ c = sd_char_at (string, index++);
if (c == '\'')
{
sb_xappend1 (&buffer, c);
extract_quotelike (xp, tp, delim);
sb_free (&buffer);
if (delim != '\'')
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
xp->line_number);
free (tp->string);
drop_reference (tp->comment);
case 'x':
tp->type = token_type_string;
tp->sub_type = string_type_qq;
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
xp->line_number);
break;
case 'r':
case '"':
extract_quotelike (xp, tp, c);
tp->sub_type = string_type_qq;
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
xp->line_number);
return;
case '`':
extract_quotelike (xp, tp, c);
tp->sub_type = string_type_qq;
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
xp->line_number);
return;
tp->type = token_type_string;
tp->sub_type = string_type_qq;
tp->line_number = xp->line_number + 1;
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
tp->line_number);
return;
}
tp->sub_type = string_type_qq;
tp->comment = add_reference (savable_comment);
tp->line_number = xp->line_number + 1;
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
tp->line_number);
return;
}
if (prefer_regexp_over_division (tp->last_type))
{
extract_quotelike (xp, tp, c);
- interpolate_keywords (xp, string_desc_from_c (tp->string),
+ interpolate_keywords (xp, sd_from_c (tp->string),
xp->line_number);
free (tp->string);
drop_reference (tp->comment);
/* xgettext PHP backend.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file was written by Bruno Haible <bruno@clisp.org>, 2002.
bool heredoc = true;
string_desc_t label = sb_contents (&buffer);
size_t label_start = 0;
- size_t label_end = string_desc_length (label);
+ size_t label_end = sd_length (label);
if (label_end >= 2
- && ((string_desc_char_at (label, label_start) == '\''
- && string_desc_char_at (label, label_end - 1) == '\'')
- || (string_desc_char_at (label, label_start) == '"'
- && string_desc_char_at (label, label_end - 1) == '"')))
+ && ((sd_char_at (label, label_start) == '\''
+ && sd_char_at (label, label_end - 1) == '\'')
+ || (sd_char_at (label, label_start) == '"'
+ && sd_char_at (label, label_end - 1) == '"')))
{
- heredoc = (string_desc_char_at (label, label_start) == '"');
+ heredoc = (sd_char_at (label, label_start) == '"');
label_start++;
label_end--;
}
}
else if (in_label_pos >= 0
&& in_label_pos < label_end - label_start
- && c == string_desc_char_at (label, label_start + in_label_pos))
+ && c == sd_char_at (label, label_start + in_label_pos))
{
in_label_pos++;
}
/* xgettext RST/RSJ backend.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
c = phase1_getc ();
}
phase1_ungetc (c);
- return (string_desc_length (sb_contents (&buffer)) == 0 ? pr_none : pr_parsed);
+ return (sd_length (sb_contents (&buffer)) == 0 ? pr_none : pr_parsed);
}
static struct mixed_string_buffer stringbuf;
/* xgettext YCP backend.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
if (c == '\n' || c == EOF)
break;
/* We skip all leading white space, but not EOLs. */
- if (!(string_desc_length (sb_contents (&buffer)) == 0
+ if (!(sd_length (sb_contents (&buffer)) == 0
&& (c == ' ' || c == '\t')))
sb_xappend1 (&buffer, c);
}
break;
}
/* We skip all leading white space, but not EOLs. */
- if (string_desc_length (sb_contents (&buffer)) == 0
+ if (sd_length (sb_contents (&buffer)) == 0
&& (c == ' ' || c == '\t'))
continue;
sb_xappend1 (&buffer, c);
if (c == '\n' || c == EOF)
break;
/* We skip all leading white space, but not EOLs. */
- if (!(string_desc_length (sb_contents (&buffer)) == 0
+ if (!(sd_length (sb_contents (&buffer)) == 0
&& (c == ' ' || c == '\t')))
sb_xappend1 (&buffer, c);
}
default:
{
string_desc_t contents = sb_contents (&buffer);
- if (string_desc_length (contents) == 1
- && string_desc_char_at (contents, 0) == '_'
+ if (sd_length (contents) == 1
+ && sd_char_at (contents, 0) == '_'
&& c == '(')
{
sb_free (&buffer);
/* 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
}
else if (xgettext_current_source_encoding == po_charset_utf8)
{
- if (u8_check ((const uint8_t *) string_desc_data (string),
- string_desc_length (string))
+ if (u8_check ((const uint8_t *) sd_data (string), sd_length (string))
!= NULL)
{
multiline_error (xstrdup (""),