* gettext-tools/src/read-catalog-abstract.h: Include xerror-handler.h.
(ABSTRACT_CATALOG_READER_TY): Add xeh field.
(catalog_reader_alloc): Add xerror_handler parameter.
* gettext-tools/src/read-catalog-abstract.c: Include xerror-handler.h instead of
po-xerror.h.
(catalog_reader_alloc): Add xerror_handler parameter.
(catalog_reader_parse): Use catr->xeh for error handling.
* gettext-tools/src/read-catalog.h: Include xerror-handler.h.
(default_catalog_reader_alloc, read_catalog_stream): Add xerror_handler
parameter.
* gettext-tools/src/read-catalog.c: Include xerror-handler.h instead of
po-xerror.h.
(default_set_domain, default_add_message): Use catr->xeh for error handling.
(default_catalog_reader_alloc, read_catalog_stream): Add xerror_handler
parameter.
* gettext-tools/src/read-po-lex.h: Include read-catalog-abstract.h.
(po_gram_error_at_line): Add catr parameter.
* gettext-tools/src/read-po-lex.c: Include xerror-handler.h instead of
po-xerror.h.
(po_gram_error): Use ps->catr->xeh for error handling.
(po_gram_error_at_line): Add catr parameter. Use catr->xeh for error handling.
(po_lex_charset_set, mbfile_getc, lex_getc): Use ps->catr->xeh for error
handling.
(keyword_p, po_gram_lex): Update invocations of po_gram_error_at_line.
* gettext-tools/src/read-po-gram.y: Update invocations of po_gram_error_at_line.
* gettext-tools/src/read-properties.c: Include xerror-handler.h instead of
po-xerror.h.
(phase4_getuc, read_escaped_string): Add catr parameter. Use catr->xeh for error
handling.
(properties_parse): Use catr->xeh for error handling.
* gettext-tools/src/read-stringtable.c: Include xerror-handler.h instead of
po-xerror.h.
(phase1_getc, phase2_getc, phase3_getc): Add catr parameter. Use catr->xeh for
error handling.
(phase4_getc): Update.
(read_string, stringtable_parse): Use catr->xeh for error handling.
* gettext-tools/libgettextpo/gettext-po.c (po_file_read): Pass a stack-allocated
xerror_handler to read_catalog_stream.
* gettext-tools/src/msgfmt.c: Include xerror-handler.h.
(read_catalog_file_msgfmt): Use the default xerror_handler.
* gettext-tools/src/read-catalog-file.c: Include xerror-handler.h.
(read_catalog_file): Use the default xerror_handler.
* gettext-tools/src/read-csharp.c: Include xerror-handler.h.
(execute_and_read_po_output): Use the default xerror_handler.
* gettext-tools/src/read-java.c: Include xerror-handler.h.
(execute_and_read_po_output): Use the default xerror_handler.
* gettext-tools/src/read-resources.c: Include xerror-handler.h.
(execute_and_read_po_output): Use the default xerror_handler.
* gettext-tools/src/read-tcl.c: Include xerror-handler.h.
(msgdomain_read_tcl): Use the default xerror_handler.
* gettext-tools/src/x-po.c: Include xerror-handler.h.
(extract): Use the default xerror_handler.
* gettext-tools/src/xgettext.c: Include xerror-handler.h.
(read_exclusion_file): Use the default xerror_handler.
return NULL;
}
- /* Establish error handler around read_catalog_stream(). */
- po_xerror =
- (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *))
- handler->xerror;
- po_xerror2 =
- (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *, const message_ty *, const char *, size_t, size_t, int, const char *))
- handler->xerror2;
+ /* Establish error handler for read_catalog_stream(). */
+ unsigned int error_count = 0;
+ struct xerror_handler local_xerror_handler =
+ {
+ (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *))
+ handler->xerror,
+ (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *, const message_ty *, const char *, size_t, size_t, int, const char *))
+ handler->xerror2,
+ &error_count
+ };
gram_max_allowed_errors = UINT_MAX;
file = XMALLOC (struct po_file);
file->real_filename = filename;
file->logical_filename = filename;
file->mdlp = read_catalog_stream (fp, file->real_filename,
- file->logical_filename, &input_format_po);
+ file->logical_filename, &input_format_po,
+ &local_xerror_handler);
file->domains = NULL;
- /* Restore error handler. */
- po_xerror = textmode_xerror;
- po_xerror2 = textmode_xerror2;
+ /* Restore. */
gram_max_allowed_errors = 20;
if (fp != stdin)
#include "relocatable.h"
#include "basename-lgpl.h"
#include "xerror.h"
+#include "xerror-handler.h"
#include "xvasprintf.h"
#include "xalloc.h"
#include "msgfmt.h"
FILE *fp = open_catalog_file (filename, &real_filename, true);
default_catalog_reader_ty *dcatr;
- dcatr = default_catalog_reader_alloc (&msgfmt_methods);
+ dcatr = default_catalog_reader_alloc (&msgfmt_methods,
+ textmode_xerror_handler);
dcatr->pass_obsolete_entries = true;
dcatr->handle_comments = false;
dcatr->allow_domain_directives = true;
#include "po-charset.h"
#include "xalloc.h"
#include "xvasprintf.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
#include "gettext.h"
abstract_catalog_reader_ty *
-catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table)
+catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table,
+ xerror_handler_ty xerror_handler)
{
abstract_catalog_reader_ty *catr;
catr = (abstract_catalog_reader_ty *) xmalloc (method_table->size);
catr->methods = method_table;
+ catr->xeh = xerror_handler;
catr->pass_comments = false;
catr->pass_obsolete_entries = false;
catr->po_lex_isolate_start = NULL;
bool is_pot_role,
catalog_input_format_ty input_syntax)
{
- error_message_count = 0;
+ *(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);
call_parse_debrief (catr);
- if (error_message_count > 0)
- po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
- /*real_filename*/ NULL, (size_t)(-1), (size_t)(-1), false,
- xasprintf (ngettext ("found %u fatal error",
- "found %u fatal errors",
- error_message_count),
- error_message_count));
+ unsigned int num_errors = *(catr->xeh->error_message_count_p);
+ if (num_errors > 0)
+ catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL,
+ /*real_filename*/ NULL, (size_t)(-1), (size_t)(-1),
+ false,
+ xasprintf (ngettext ("found %u fatal error",
+ "found %u fatal errors",
+ num_errors),
+ num_errors));
}
#include <stdio.h>
#include "message.h"
+#include "xerror-handler.h"
#ifdef __cplusplus
#define ABSTRACT_CATALOG_READER_TY \
abstract_catalog_reader_class_ty *methods; \
\
+ /* The error handler. */ \
+ xerror_handler_ty xeh; \
+ \
/* True if comments shall be handled, false if they shall be \
ignored. */ \
bool pass_comments; \
/* Allocate a fresh abstract_catalog_reader_ty (or derived class) instance and
call its constructor. */
extern abstract_catalog_reader_ty *
- catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table);
+ catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table,
+ xerror_handler_ty xerror_handler);
/* Read a PO file from a stream, and dispatch to the various
abstract_catalog_reader_class_ty methods. */
/* Reading PO files.
- Copyright (C) 1995-2023 Free Software Foundation, Inc.
+ Copyright (C) 1995-2024 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 "xerror-handler.h"
msgdomain_list_ty *
FILE *fp = open_catalog_file (filename, &real_filename, true);
msgdomain_list_ty *result;
- result = read_catalog_stream (fp, real_filename, filename, input_syntax);
+ result = read_catalog_stream (fp, real_filename, filename, input_syntax,
+ textmode_xerror_handler);
if (fp != stdin)
fclose (fp);
#include "po-charset.h"
#include "read-po-lex.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
#include "xalloc.h"
#include "read-catalog-special.h"
#include "gettext.h"
dcatr->domain = name;
else
{
- po_xerror (PO_SEVERITY_ERROR, NULL,
- name_pos->file_name, name_pos->line_number, (size_t)(-1),
- false, _("this file may not contain domain directives"));
+ dcatr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ name_pos->file_name, name_pos->line_number, (size_t)(-1),
+ false,
+ _("this file may not contain domain directives"));
/* NAME was allocated in read-po-gram.y but is not used anywhere. */
free (name);
translations are equal or different. This is for consistency
with msgmerge, msgcat and others. The user can use the
msguniq program to get rid of duplicates. */
- po_xerror2 (PO_SEVERITY_ERROR,
- NULL, msgid_pos->file_name, msgid_pos->line_number,
- (size_t)(-1), false, _("duplicate message definition"),
- mp, NULL, 0, 0, false,
- _("this is the location of the first definition"));
+ dcatr->xeh->xerror2 (CAT_SEVERITY_ERROR,
+ NULL,
+ msgid_pos->file_name, msgid_pos->line_number, (size_t)(-1),
+ false,
+ _("duplicate message definition"),
+ mp,
+ NULL, 0, 0,
+ false,
+ _("this is the location of the first definition"));
}
/* We don't need the just constructed entries' parameter string
(allocated in read-po-gram.y). */
default_catalog_reader_ty *
-default_catalog_reader_alloc (default_catalog_reader_class_ty *method_table)
+default_catalog_reader_alloc (default_catalog_reader_class_ty *method_table,
+ xerror_handler_ty xerror_handler)
{
return
- (default_catalog_reader_ty *) catalog_reader_alloc (&method_table->super);
+ (default_catalog_reader_ty *)
+ catalog_reader_alloc (&method_table->super, xerror_handler);
}
msgdomain_list_ty *
read_catalog_stream (FILE *fp, const char *real_filename,
const char *logical_filename,
- catalog_input_format_ty input_syntax)
+ catalog_input_format_ty input_syntax,
+ xerror_handler_ty xerror_handler)
{
default_catalog_reader_ty *dcatr;
msgdomain_list_ty *mdlp;
- dcatr = default_catalog_reader_alloc (&default_methods);
+ dcatr = default_catalog_reader_alloc (&default_methods, xerror_handler);
dcatr->pass_obsolete_entries = true;
dcatr->handle_comments = true;
dcatr->allow_domain_directives = true;
#include "message.h"
#include "read-catalog-abstract.h"
+#include "xerror-handler.h"
#include <stdbool.h>
#include <stdio.h>
/* Allocate a fresh default_catalog_reader_ty (or derived class) instance and
call its constructor. */
extern default_catalog_reader_ty *
- default_catalog_reader_alloc (default_catalog_reader_class_ty *method_table);
+ default_catalog_reader_alloc (default_catalog_reader_class_ty *method_table,
+ xerror_handler_ty xerror_handler);
/* If false, duplicate msgids in the same domain and file generate an error.
read_catalog_stream (FILE *fp,
const char *real_filename,
const char *logical_filename,
- catalog_input_format_ty input_syntax);
+ catalog_input_format_ty input_syntax,
+ xerror_handler_ty xerror_handler);
#ifdef __cplusplus
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "xerror-handler.h"
#include "xalloc.h"
#include "concat-filename.h"
#include "gettext.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
+ l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
+ textmode_xerror_handler);
fclose (fp);
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "xerror-handler.h"
#include "gettext.h"
#define _(str) gettext (str)
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
+ l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
+ textmode_xerror_handler);
fclose (fp);
#define check_obsolete(value1,value2) \
if ((value1).obsolete != (value2).obsolete) \
- po_gram_error_at_line (&(value2).pos, _("inconsistent use of #~"));
+ po_gram_error_at_line (ps->catr, &(value2).pos, \
+ _("inconsistent use of #~"));
static inline void
do_callback_message (struct po_parser_state *ps,
{
check_obsolete ($1, $2);
check_obsolete ($1, $3);
- po_gram_error_at_line (&$1.pos, _("missing 'msgstr[]' section"));
+ po_gram_error_at_line (ps->catr, &$1.pos, _("missing 'msgstr[]' section"));
free_message_intro ($1);
string_list_destroy (&$2.stringlist);
free ($3.string);
{
check_obsolete ($1, $2);
check_obsolete ($1, $3);
- po_gram_error_at_line (&$1.pos, _("missing 'msgid_plural' section"));
+ po_gram_error_at_line (ps->catr, &$1.pos, _("missing 'msgid_plural' section"));
free_message_intro ($1);
string_list_destroy (&$2.stringlist);
free ($3.rhs.msgstr);
| message_intro string_list
{
check_obsolete ($1, $2);
- po_gram_error_at_line (&$1.pos, _("missing 'msgstr' section"));
+ po_gram_error_at_line (ps->catr, &$1.pos, _("missing 'msgstr' section"));
free_message_intro ($1);
string_list_destroy (&$2.stringlist);
}
if ($3.number != ps->plural_counter)
{
if (ps->plural_counter == 0)
- po_gram_error_at_line (&$1.pos, _("first plural form has nonzero index"));
+ po_gram_error_at_line (ps->catr, &$1.pos, _("first plural form has nonzero index"));
else
- po_gram_error_at_line (&$1.pos, _("plural form has wrong index"));
+ po_gram_error_at_line (ps->catr, &$1.pos, _("plural form has wrong index"));
}
ps->plural_counter++;
$$.rhs.msgstr = string_list_concat_destroy (&$5.stringlist);
#include "error-progname.h"
#include "xvasprintf.h"
#include "po-error.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
#include "xmalloca.h"
#if !IN_LIBGETTEXTPO
# include "basename-lgpl.h"
va_start (ap, fmt);
if (vasprintf (&buffer, fmt, ap) < 0)
- error (EXIT_FAILURE, 0, _("memory exhausted"));
+ ps->catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+ _("memory exhausted"));
va_end (ap);
- po_xerror (PO_SEVERITY_ERROR, NULL,
- ps->gram_pos.file_name, ps->gram_pos.line_number,
- ps->gram_pos_column + 1, false, buffer);
+ ps->catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ ps->gram_pos.file_name, ps->gram_pos.line_number,
+ ps->gram_pos_column + 1, false, buffer);
free (buffer);
- if (error_message_count >= gram_max_allowed_errors)
- po_error (EXIT_FAILURE, 0, _("too many errors, aborting"));
+ if (*(ps->catr->xeh->error_message_count_p) >= gram_max_allowed_errors)
+ ps->catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+ _("too many errors, aborting"));
}
void
-po_gram_error_at_line (const lex_pos_ty *pp, const char *fmt, ...)
+po_gram_error_at_line (abstract_catalog_reader_ty *catr, const lex_pos_ty *pp,
+ const char *fmt, ...)
{
va_list ap;
char *buffer;
va_start (ap, fmt);
if (vasprintf (&buffer, fmt, ap) < 0)
- error (EXIT_FAILURE, 0, _("memory exhausted"));
+ catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+ _("memory exhausted"));
va_end (ap);
- po_xerror (PO_SEVERITY_ERROR, NULL, pp->file_name, pp->line_number,
- (size_t)(-1), false, buffer);
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL, pp->file_name, pp->line_number,
+ (size_t)(-1), false, buffer);
free (buffer);
- if (error_message_count >= gram_max_allowed_errors)
- po_error (EXIT_FAILURE, 0, _("too many errors, aborting"));
+ if (*(catr->xeh->error_message_count_p) >= gram_max_allowed_errors)
+ catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+ _("too many errors, aborting"));
}
Charset \"%s\" is not a portable encoding name.\n\
Message conversion to user's charset might not work.\n"),
charset);
- po_xerror (PO_SEVERITY_WARNING, NULL,
- filename, (size_t)(-1), (size_t)(-1), true,
- warning_message);
+ ps->catr->xeh->xerror (CAT_SEVERITY_WARNING, NULL,
+ filename, (size_t)(-1), (size_t)(-1), true,
+ warning_message);
free (warning_message);
}
}
xasprintf ("%s%s%s\n",
warning_message, recommendation, note);
- po_xerror (PO_SEVERITY_WARNING, NULL,
- filename, (size_t)(-1), (size_t)(-1), true,
- whole_message);
+ ps->catr->xeh->xerror (CAT_SEVERITY_WARNING, NULL,
+ filename, (size_t)(-1), (size_t)(-1),
+ true, whole_message);
free (whole_message);
free (warning_message);
xasprintf ("%s%s%s\n",
warning_message, recommendation, note);
- po_xerror (PO_SEVERITY_WARNING, NULL,
- filename, (size_t)(-1), (size_t)(-1), true,
- whole_message);
+ ps->catr->xeh->xerror (CAT_SEVERITY_WARNING, NULL,
+ filename, (size_t)(-1), (size_t)(-1),
+ true, whole_message);
free (whole_message);
free (warning_message);
if (!(filenamelen >= 4
&& memcmp (filename + filenamelen - 4, ".pot", 4) == 0))
- po_xerror (PO_SEVERITY_WARNING,
- NULL, filename, (size_t)(-1), (size_t)(-1), true,
- _("\
+ ps->catr->xeh->xerror (CAT_SEVERITY_WARNING,
+ NULL, filename, (size_t)(-1), (size_t)(-1), true,
+ _("\
Charset missing in header.\n\
Message conversion to user's charset will not work.\n"));
}
else
{
const char *errno_description = strerror (errno);
- po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
- xasprintf ("%s: %s",
- _("iconv failure"),
- errno_description));
+ ps->catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR,
+ NULL, NULL, 0, 0, false,
+ xasprintf ("%s: %s",
+ _("iconv failure"),
+ errno_description));
}
}
else
bomb:
{
const char *errno_description = strerror (errno);
- po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
- xasprintf ("%s: %s",
- xasprintf (_("error while reading \"%s\""),
- ps->gram_pos.file_name),
- errno_description));
+ ps->catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR,
+ NULL, NULL, 0, 0, false,
+ xasprintf ("%s: %s",
+ xasprintf (_("error while reading \"%s\""),
+ ps->gram_pos.file_name),
+ errno_description));
}
break;
}
if (!strcmp (s, "msgctxt"))
return PREV_MSGCTXT;
}
- po_gram_error_at_line (&ps->gram_pos, _("keyword \"%s\" unknown"), s);
+ po_gram_error_at_line (ps->catr, &ps->gram_pos,
+ _("keyword \"%s\" unknown"), s);
return NAME;
}
}
if (mb_iseof (mbc))
{
- po_gram_error_at_line (&ps->gram_pos,
+ po_gram_error_at_line (ps->catr, &ps->gram_pos,
_("end-of-file within string"));
break;
}
if (mb_iseq (mbc, '\n'))
{
- po_gram_error_at_line (&ps->gram_pos,
+ po_gram_error_at_line (ps->catr, &ps->gram_pos,
_("end-of-line within string"));
break;
}
/* Strings cannot contain the msgctxt separator, because it cannot
be faithfully represented in the msgid of a .mo file. */
if (strchr (buf, MSGCTXT_SEPARATOR) != NULL)
- po_gram_error_at_line (&ps->gram_pos,
+ po_gram_error_at_line (ps->catr, &ps->gram_pos,
_("context separator <EOT> within string"));
/* FIXME: Treatment of embedded \000 chars is incorrect. */
#include "error-progname.h"
#include "xerror.h"
#include "pos.h"
+#include "read-catalog-abstract.h"
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
extern void po_gram_error (struct po_parser_state *ps, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
-extern void po_gram_error_at_line (const lex_pos_ty *pos, const char *fmt, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+extern void po_gram_error_at_line (abstract_catalog_reader_ty *catr,
+ const lex_pos_ty *pos, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
/* Set the PO file's encoding from the header entry.
If is_pot_role is true, "charset=CHARSET" is expected and does not deserve
#include "read-catalog-abstract.h"
#include "xalloc.h"
#include "xvasprintf.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
#include "msgl-ascii.h"
#include "read-file.h"
#include "unistr.h"
#define UTF16_VALUE(p4_result) ((unsigned short) ((p4_result) - 0x10000))
static int
-phase4_getuc ()
+phase4_getuc (abstract_catalog_reader_ty *catr)
{
int c = phase3_getc ();
else
{
phase3_ungetc (c1);
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1),
- false, _("warning: invalid \\uxxxx syntax for Unicode character"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: invalid \\uxxxx syntax for Unicode character"));
return 'u';
}
}
- otherwise, if in_key is false, after the end of the logical line. */
static char *
-read_escaped_string (bool in_key)
+read_escaped_string (abstract_catalog_reader_ty *catr, bool in_key)
{
/* The part of the string that has already been converted to UTF-8. */
static unsigned char *utf8_buffer;
do \
{ \
error_with_progname = false; \
- po_xerror (PO_SEVERITY_ERROR, NULL, \
- real_file_name, (line), (size_t)(-1), false, \
- xasprintf (_("warning: lone surrogate U+%04X"), (uc))); \
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL, \
+ real_file_name, (line), (size_t)(-1), false, \
+ xasprintf (_("warning: lone surrogate U+%04X"), \
+ (uc))); \
error_with_progname = true; \
utf8_buffer_ensure_available (3); \
utf8_buffer[utf8_buflen++] = 0xef; \
phase3_ungetc (c);
/* Read the next byte or UTF-16 code point. */
- c = phase4_getuc ();
+ c = phase4_getuc (catr);
if (c == P4_EOF)
break;
if (len < 0)
{
error_with_progname = false;
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1),
- false, _("warning: invalid Unicode character"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: invalid Unicode character"));
error_with_progname = true;
}
else
if (len < 0)
{
error_with_progname = false;
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1),
- false, _("warning: invalid Unicode character"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: invalid Unicode character"));
error_with_progname = true;
}
else
if (contents == NULL)
{
const char *errno_description = strerror (errno);
- po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
- xasprintf ("%s: %s",
- xasprintf (_("error while reading \"%s\""),
- real_filename),
- errno_description));
+ catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+ xasprintf ("%s: %s",
+ xasprintf (_("error while reading \"%s\""),
+ real_filename),
+ errno_description));
return;
}
lex_pos_ty msgid_pos;
msgid_pos = pos;
- msgid = read_escaped_string (true);
+ msgid = read_escaped_string (catr, true);
if (msgid == NULL)
/* Skip blank line. */
;
bool force_fuzzy;
msgstr_pos = pos;
- msgstr = read_escaped_string (false);
+ msgstr = read_escaped_string (catr, false);
if (msgstr == NULL)
msgstr = xstrdup ("");
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "xerror-handler.h"
#include "message.h"
#include "concat-filename.h"
#include "gettext.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
+ l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
+ textmode_xerror_handler);
fclose (fp);
#include "read-catalog-abstract.h"
#include "xalloc.h"
#include "xvasprintf.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
#include "unistr.h"
#include "gettext.h"
static int phase1_pushback_length;
static int
-phase1_getc ()
+phase1_getc (abstract_catalog_reader_ty *catr)
{
int c;
if (ferror (fp))
{
const char *errno_description = strerror (errno);
- po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
- xasprintf ("%s: %s",
- xasprintf (_("error while reading \"%s\""),
- real_file_name),
- errno_description));
+ catr->xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+ xasprintf ("%s: %s",
+ xasprintf (_("error while reading \"%s\""),
+ real_file_name),
+ errno_description));
}
return EOF;
}
static enum enc encoding;
static int
-phase2_getc ()
+phase2_getc (abstract_catalog_reader_ty *catr)
{
if (phase2_pushback_length)
return phase2_pushback[--phase2_pushback_length];
/* Determine the input file's encoding. */
int c0, c1;
- c0 = phase1_getc ();
+ c0 = phase1_getc (catr);
if (c0 == EOF)
return UEOF;
- c1 = phase1_getc ();
+ c1 = phase1_getc (catr);
if (c1 == EOF)
{
phase1_ungetc (c0);
{
int c2;
- c2 = phase1_getc ();
+ c2 = phase1_getc (catr);
if (c2 == EOF)
{
phase1_ungetc (c1);
{
int c0, c1;
- c0 = phase1_getc ();
+ c0 = phase1_getc (catr);
if (c0 == EOF)
return UEOF;
- c1 = phase1_getc ();
+ c1 = phase1_getc (catr);
if (c1 == EOF)
return UEOF;
return (c0 << 8) + c1;
{
int c0, c1;
- c0 = phase1_getc ();
+ c0 = phase1_getc (catr);
if (c0 == EOF)
return UEOF;
- c1 = phase1_getc ();
+ c1 = phase1_getc (catr);
if (c1 == EOF)
return UEOF;
return c0 + (c1 << 8);
int c;
ucs4_t uc;
- c = phase1_getc ();
+ c = phase1_getc (catr);
if (c == EOF)
return UEOF;
buf[0] = c;
if (buf[0] >= 0xc0)
{
- c = phase1_getc ();
+ c = phase1_getc (catr);
if (c == EOF)
return UEOF;
buf[1] = c;
if (buf[0] >= 0xe0
&& ((buf[1] ^ 0x80) < 0x40))
{
- c = phase1_getc ();
+ c = phase1_getc (catr);
if (c == EOF)
return UEOF;
buf[2] = c;
if (buf[0] >= 0xf0
&& ((buf[2] ^ 0x80) < 0x40))
{
- c = phase1_getc ();
+ c = phase1_getc (catr);
if (c == EOF)
return UEOF;
buf[3] = c;
if (buf[0] >= 0xf8
&& ((buf[3] ^ 0x80) < 0x40))
{
- c = phase1_getc ();
+ c = phase1_getc (catr);
if (c == EOF)
return UEOF;
buf[4] = c;
if (buf[0] >= 0xfc
&& ((buf[4] ^ 0x80) < 0x40))
{
- c = phase1_getc ();
+ c = phase1_getc (catr);
if (c == EOF)
return UEOF;
buf[5] = c;
case enc_iso8859_1:
/* Read an ISO-8859-1 encoded character. */
{
- int c = phase1_getc ();
+ int c = phase1_getc (catr);
if (c == EOF)
return UEOF;
/* Phase 3: Read an UCS-4 character, with line number handling. */
static int
-phase3_getc ()
+phase3_getc (abstract_catalog_reader_ty *catr)
{
- int c = phase2_getc ();
+ int c = phase2_getc (catr);
if (c == '\n')
pos.line_number++;
{
int c;
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c != '/')
return c;
- c = phase3_getc ();
+ c = phase3_getc (catr);
switch (c)
{
default:
/* Drop additional stars at the beginning of the comment. */
for (;;)
{
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c != '*')
break;
last_was_star = true;
phase3_ungetc (c);
for (;;)
{
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c == UEOF)
break;
/* We skip all leading white space, but not EOLs. */
comment_start ();
for (;;)
{
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c == '\n' || c == UEOF)
break;
/* We skip all leading white space, but not EOLs. */
/* Read a string enclosed in double-quotes. */
for (;;)
{
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c == UEOF || c == '"')
break;
if (c == '\\')
{
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c == UEOF)
break;
if (c >= '0' && c <= '7')
n = n * 8 + (c - '0');
if (++j == 3)
break;
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (!(c >= '0' && c <= '7'))
{
phase3_ungetc (c);
int j;
for (j = 0; j < 4; j++)
{
- c = phase3_getc ();
+ c = phase3_getc (catr);
if (c >= '0' && c <= '9')
n = n * 16 + (c - '0');
else if (c >= 'A' && c <= 'F')
buffer[buflen++] = c;
}
if (c == UEOF)
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1), false,
- _("warning: unterminated string"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1), false,
+ _("warning: unterminated string"));
}
else
{
/* Read a token outside quotes. */
if (is_quotable (c))
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1), false,
- _("warning: syntax error"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1), false,
+ _("warning: syntax error"));
for (; c != UEOF && !is_quotable (c); c = phase4_getc (catr))
{
if (buflen >= bufmax)
/* Expect a '=' or ';'. */
if (c == UEOF)
{
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1), false,
- _("warning: unterminated key/value pair"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: unterminated key/value pair"));
break;
}
if (c == ';')
msgstr = read_string (catr, &msgstr_pos);
if (msgstr == NULL)
{
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1),
- false, _("warning: unterminated key/value pair"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: unterminated key/value pair"));
break;
}
if (fuzzy_msgstr == NULL && next_is_fuzzy)
{
do
- c = phase3_getc ();
+ c = phase3_getc (catr);
while (c == ' ');
phase3_ungetc (c);
}
else
{
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1),
- false,
- _("warning: syntax error, expected ';' after string"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: syntax error, expected ';' after string"));
break;
}
}
else
{
- po_xerror (PO_SEVERITY_ERROR, NULL,
- real_file_name, pos.line_number, (size_t)(-1), false,
- _("warning: syntax error, expected '=' or ';' after string"));
+ catr->xeh->xerror (CAT_SEVERITY_ERROR, NULL,
+ real_file_name, pos.line_number, (size_t)(-1),
+ false,
+ _("warning: syntax error, expected '=' or ';' after string"));
break;
}
}
#include "wait-process.h"
#include "read-catalog.h"
#include "read-po.h"
+#include "xerror-handler.h"
#include "xmalloca.h"
#include "gettext.h"
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
+ mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po,
+ textmode_xerror_handler);
fclose (fp);
#include "message.h"
#include "xgettext.h"
#include "xalloc.h"
+#include "xerror-handler.h"
#include "read-catalog.h"
#include "read-po.h"
#include "read-properties.h"
header_charset = NULL;
- dcatr = default_catalog_reader_alloc (&extract_methods);
+ dcatr = default_catalog_reader_alloc (&extract_methods,
+ textmode_xerror_handler);
dcatr->handle_comments = true;
dcatr->allow_domain_directives = false;
dcatr->allow_duplicates = false;
#include "verify.h"
#include "c-strstr.h"
#include "xerror.h"
+#include "xerror-handler.h"
#include "filename.h"
#include "concat-filename.h"
#include "c-strcase.h"
FILE *fp = open_catalog_file (filename, &real_filename, true);
abstract_catalog_reader_ty *catr;
- catr = catalog_reader_alloc (&exclude_methods);
+ catr = catalog_reader_alloc (&exclude_methods, textmode_xerror_handler);
catalog_reader_parse (catr, fp, real_filename, filename, true, &input_format_po);
catalog_reader_free (catr);