/* Public API for GNU gettext PO files.
- Copyright (C) 2003-2025 Free Software Foundation, Inc.
+ Copyright (C) 2003-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
#include <string.h>
#include "message.h"
+#include "str-list.h"
#include "xalloc.h"
#include "read-catalog.h"
#include "read-po.h"
const char *real_filename;
const char *logical_filename;
const char **domains;
+ /* Heap allocations that are guaranteed to persist until the po_file_free
+ call. */
+ string_list_ty arena;
};
struct po_message_iterator
file->real_filename = _("<unnamed>");
file->logical_filename = file->real_filename;
file->domains = NULL;
+ string_list_init (&file->arena);
return file;
}
file = XMALLOC (struct po_file);
file->real_filename = filename;
file->logical_filename = filename;
+ string_list_init (&file->arena);
file->mdlp = read_catalog_stream (fp, file->real_filename,
file->logical_filename, &input_format_po,
- &local_xerror_handler);
+ &local_xerror_handler, &file->arena);
file->domains = NULL;
if (fp != stdin)
msgdomain_list_free (file->mdlp);
if (file->domains != NULL)
free (file->domains);
+ string_list_destroy (&file->arena);
free (file);
}
dcatr->mlp = current_domain->mlp;
}
+ string_list_ty arena;
+ string_list_init (&arena);
catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename,
- filename, false, input_syntax);
+ filename, false, input_syntax, &arena);
catalog_reader_free ((abstract_catalog_reader_ty *) dcatr);
/* Reading textual message catalogs (such as PO files), abstract class.
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
catalog_reader_parse (abstract_catalog_reader_ty *catr, FILE *fp,
const char *real_filename, const char *logical_filename,
bool is_pot_role,
- catalog_input_format_ty input_syntax)
+ catalog_input_format_ty input_syntax,
+ string_list_ty *arena)
{
*(catr->xeh->error_message_count_p) = 0;
/* Parse the stream's content. */
call_parse_brief (catr);
- input_syntax->parse (catr, fp, real_filename, logical_filename, is_pot_role);
+ input_syntax->parse (catr, fp, real_filename, logical_filename,
+ is_pot_role, arena);
call_parse_debrief (catr);
unsigned int num_errors = *(catr->xeh->error_message_count_p);
/* Reading textual message catalogs (such as PO files), abstract class.
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
#include "message.h"
#include "xerror-handler.h"
+#include "str-list.h"
#ifdef __cplusplus
/* Parses the contents of FP, invoking the appropriate callbacks. */
void (*parse) (abstract_catalog_reader_ty *catr, FILE *fp,
const char *real_filename, const char *logical_filename,
- bool is_pot_role);
+ bool is_pot_role, string_list_ty *arena);
/* Whether the parse function always produces messages encoded in UTF-8
encoding. */
const char *real_filename,
const char *logical_filename,
bool is_pot_role,
- catalog_input_format_ty input_syntax);
+ catalog_input_format_ty input_syntax,
+ string_list_ty *arena);
/* Call the destructor and deallocate a abstract_catalog_reader_ty (or derived
class) instance. */
/* Reading PO files.
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
This program is free software: you can redistribute it and/or modify
#include "read-catalog-file.h"
#include "open-catalog.h"
+#include "str-list.h"
#include "xerror-handler.h"
char *real_filename;
FILE *fp = open_catalog_file (filename, &real_filename, true);
+ string_list_ty arena;
+ string_list_init (&arena);
msgdomain_list_ty *result =
read_catalog_stream (fp, real_filename, filename, input_syntax,
- textmode_xerror_handler);
+ textmode_xerror_handler, &arena);
if (fp != stdin)
fclose (fp);
/* Reading textual message catalogs (such as PO files).
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
This program is free software: you can redistribute it and/or modify
read_catalog_stream (FILE *fp, const char *real_filename,
const char *logical_filename,
catalog_input_format_ty input_syntax,
- xerror_handler_ty xerror_handler)
+ xerror_handler_ty xerror_handler,
+ string_list_ty *arena)
{
default_catalog_reader_ty *dcatr =
default_catalog_reader_alloc (&default_methods, xerror_handler);
dcatr->mdlp->encoding = po_charset_utf8;
catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename,
- logical_filename, false, input_syntax);
+ logical_filename, false, input_syntax, arena);
msgdomain_list_ty *mdlp = dcatr->mdlp;
catalog_reader_free ((abstract_catalog_reader_ty *) dcatr);
/* Reading textual message catalogs (such as PO files).
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>.
This program is free software: you can redistribute it and/or modify
#include "message.h"
#include "read-catalog-abstract.h"
#include "xerror-handler.h"
+#include "str-list.h"
#include <stdbool.h>
#include <stdio.h>
const char *real_filename,
const char *logical_filename,
catalog_input_format_ty input_syntax,
- xerror_handler_ty xerror_handler);
+ xerror_handler_ty xerror_handler,
+ string_list_ty *arena);
#ifdef __cplusplus
/* Reading C# satellite assemblies.
- Copyright (C) 2003-2025 Free Software Foundation, Inc.
+ Copyright (C) 2003-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "str-list.h"
#include "xerror-handler.h"
#include "xalloc.h"
#include "concat-filename.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
+ string_list_ty arena;
+ string_list_init (&arena);
l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
- textmode_xerror_handler);
+ textmode_xerror_handler, &arena);
fclose (fp);
/* Reading Java ResourceBundles.
- Copyright (C) 2001-2025 Free Software Foundation, Inc.
+ Copyright (C) 2001-2026 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
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "str-list.h"
#include "xerror-handler.h"
#include "gettext.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
+ string_list_ty arena;
+ string_list_init (&arena);
l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
- textmode_xerror_handler);
+ textmode_xerror_handler, &arena);
fclose (fp);
/* GNU gettext - internationalization aids
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>.
Multibyte character handling by Bruno Haible <haible@clisp.cons.org>.
/* Prepare lexical analysis. */
void
lex_start (struct po_parser_state *ps,
- FILE *fp, const char *real_filename, const char *logical_filename)
+ FILE *fp, const char *real_filename, const char *logical_filename,
+ string_list_ty *arena)
{
/* Ignore the logical_filename, because PO file entries already have
their file names attached. But use real_filename for error messages. */
- ps->gram_pos.file_name = xstrdup (real_filename);
+ {
+ char *allocated_file_name = xstrdup (real_filename);
+ string_list_append_move (arena, allocated_file_name);
+ ps->gram_pos.file_name = allocated_file_name;
+ }
mbfile_init (ps->mbf, fp);
#include <stdbool.h>
#include <error.h>
+#include "str-list.h"
#include "pos.h"
#include "read-catalog-abstract.h"
/* Prepare lexical analysis. */
extern void lex_start (struct po_parser_state *ps,
FILE *fp, const char *real_filename,
- const char *logical_filename);
+ const char *logical_filename,
+ string_list_ty *arena);
/* Terminate lexical analysis. */
extern void lex_end (struct po_parser_state *ps);
/* Reading PO files.
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 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
static void
po_parse (abstract_catalog_reader_ty *catr, FILE *fp,
const char *real_filename, const char *logical_filename,
- bool is_pot_role)
+ bool is_pot_role, string_list_ty *arena)
{
struct po_parser_state ps;
ps.catr = catr;
ps.gram_pot_role = is_pot_role;
- lex_start (&ps, fp, real_filename, logical_filename);
+ lex_start (&ps, fp, real_filename, logical_filename, arena);
po_gram_parse (&ps);
lex_end (&ps);
}
/* Reading Java .properties files.
- Copyright (C) 2003-2025 Free Software Foundation, Inc.
+ Copyright (C) 2003-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
static void
properties_parse (abstract_catalog_reader_ty *catr, FILE *file,
const char *real_filename, const char *logical_filename,
- bool is_pot_role)
+ bool is_pot_role, string_list_ty *arena)
{
/* Read the file into memory. */
contents = fread_file (file, 0, &contents_length);
/* Reading C# .resources files.
- Copyright (C) 2003-2025 Free Software Foundation, Inc.
+ Copyright (C) 2003-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "str-list.h"
#include "xerror-handler.h"
#include "message.h"
#include "concat-filename.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
+ string_list_ty arena;
+ string_list_init (&arena);
l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
- textmode_xerror_handler);
+ textmode_xerror_handler, &arena);
fclose (fp);
/* Reading NeXTstep/GNUstep .strings files.
- Copyright (C) 2003-2025 Free Software Foundation, Inc.
+ Copyright (C) 2003-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
static void
stringtable_parse (abstract_catalog_reader_ty *catr, FILE *file,
const char *real_filename, const char *logical_filename,
- bool is_pot_role)
+ bool is_pot_role, string_list_ty *arena)
{
fp = file;
real_file_name = real_filename;
/* Reading tcl/msgcat .msg files.
- Copyright (C) 2002-2025 Free Software Foundation, Inc.
+ Copyright (C) 2002-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "str-list.h"
#include "xerror-handler.h"
#include "xmalloca.h"
#include "gettext.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
+ string_list_ty arena;
+ string_list_init (&arena);
msgdomain_list_ty *mdlp =
read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
- textmode_xerror_handler);
+ textmode_xerror_handler, &arena);
fclose (fp);
/* xgettext PO, JavaProperties, and NXStringTable backends.
- Copyright (C) 1995-2025 Free Software Foundation, Inc.
+ Copyright (C) 1995-2026 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
#include "read-po.h"
#include "read-properties.h"
#include "read-stringtable.h"
+#include "str-list.h"
#include "msgl-header.h"
#include "msgl-iconv.h"
#include "msgl-ascii.h"
dcatr->file_name = real_filename;
dcatr->mdlp = NULL;
dcatr->mlp = mdlp->item[0]->messages;
+
+ string_list_ty arena;
+ string_list_init (&arena);
catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename,
- logical_filename, true, input_syntax);
+ logical_filename, true, input_syntax, &arena);
+
catalog_reader_free ((abstract_catalog_reader_ty *) dcatr);
if (header_charset != NULL)
abstract_catalog_reader_ty *catr =
catalog_reader_alloc (&exclude_methods, textmode_xerror_handler);
- catalog_reader_parse (catr, fp, real_filename, filename, true, &input_format_po);
+
+ string_list_ty arena;
+ string_list_init (&arena);
+ catalog_reader_parse (catr, fp, real_filename, filename, true,
+ &input_format_po, &arena);
+
catalog_reader_free (catr);
if (fp != stdin)