]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Handle out-of-memory situation.
authorBruno Haible <bruno@clisp.org>
Sat, 8 Feb 2025 07:49:16 +0000 (08:49 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Feb 2025 18:32:23 +0000 (19:32 +0100)
* 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.

gettext-tools/src/x-perl.c
gettext-tools/src/x-rust.c

index 77826490abdcb6edf1d16b7d749890df20ac5035..213f06aab44e15a7a9d42f71c961c88199111783 100644 (file)
@@ -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);
 }
index c2a8c5ce9e18a139b2af91b04c8de4caf8134a5f..79e5ae17cd237b7181d82b10b7942d8cafb31a67 100644 (file)
@@ -33,6 +33,7 @@
 #include <error.h>
 #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");