From: Bruno Haible Date: Sat, 8 Feb 2025 07:49:16 +0000 (+0100) Subject: xgettext: Handle out-of-memory situation. X-Git-Tag: v0.24~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d2e58a546e8ccd4f2aeb88340f192300d88b73ec;p=thirdparty%2Fgettext.git xgettext: Handle out-of-memory situation. * gettext-tools/src/x-perl.c: Include xstring-desc.h. (extract_quotelike): Call xsd_c instead of sd_c. * gettext-tools/src/x-rust.c: Include xstring-desc.h. (string_literal_value): Call xsd_c instead of sd_c. Call sb_xappend_desc instead of sb_append_desc. --- diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index 77826490a..213f06aab 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -35,6 +35,7 @@ #include "sf-istream.h" #include "rc-str-list.h" #include "string-desc.h" +#include "xstring-desc.h" #include "xgettext.h" #include "xg-pos.h" #include "xg-encoding.h" @@ -919,7 +920,7 @@ extract_quotelike (struct perl_extractor *xp, token_ty *tp, int delim) /* Take the string without the delimiters at the start and at the end. */ if (!(len >= 2)) abort (); - tp->string = sd_c (sd_substring (string, 1, len - 1)); + tp->string = xsd_c (sd_substring (string, 1, len - 1)); sd_free (string); tp->comment = add_reference (savable_comment); } diff --git a/gettext-tools/src/x-rust.c b/gettext-tools/src/x-rust.c index c2a8c5ce9..79e5ae17c 100644 --- a/gettext-tools/src/x-rust.c +++ b/gettext-tools/src/x-rust.c @@ -33,6 +33,7 @@ #include #include "message.h" #include "string-desc.h" +#include "xstring-desc.h" #include "string-buffer.h" #include "xgettext.h" #include "xg-pos.h" @@ -43,7 +44,6 @@ #include "xg-message.h" #include "if-error.h" #include "xalloc.h" -#include "string-buffer.h" #include "read-file.h" #include "unistr.h" #include "po-charset.h" @@ -336,7 +336,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)); - return sd_c (subnode_string); + return xsd_c (subnode_string); } } @@ -362,7 +362,7 @@ string_literal_value (TSNode node, const char *contents) || sd_char_at (subnode_string, 0) == '\t')) subnode_string = sd_substring (subnode_string, 1, sd_length (subnode_string)); } - sb_append_desc (&buffer, subnode_string); + sb_xappend_desc (&buffer, subnode_string); skip_leading_whitespace = false; } else if (ts_node_symbol (subnode) == ts_symbol_escape_sequence) @@ -1068,7 +1068,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)); - fprintf (stderr, "identifier=%s\n", sd_c (subnode_string)); + fprintf (stderr, "identifier=%s\n", xsd_c (subnode_string)); if (sd_equals (subnode_string, sd_from_c ("println"))) { fprintf (stderr, "children:\n");