Also, for Perl input, clarify some diagnostics as errors vs. warnings.
* gettext-tools/src/if-error.h: New file.
* gettext-tools/src/if-error.c: New file.
* gettext-tools/src/xg-mixed-string.c: Include if-error.h instead of
error-progname.h.
(mixed_string_buffer_append_lone_surrogate): Invoke 'if_error' instead of
'error'.
* gettext-tools/src/x-awk.c: Include if-error.h instead of error-progname.h.
(phase7_getc, x_awk_lex, extract_parenthesized): Invoke 'if_error' instead of
'error'.
* gettext-tools/src/x-c.c: Include if-error.h instead of error-progname.h.
(phase7_getc, phase5_get, extract_parenthesized): Invoke 'if_error' instead of
'error'.
* gettext-tools/src/x-csharp.c: Include if-error.h instead of error-progname.h.
(do_getc_unicode_escaped, accumulate_escaped, extract_parenthesized): Invoke
'if_error' instead of 'error'.
* gettext-tools/src/x-elisp.c: Include if-error.h instead of error-progname.h.
(do_getc_escaped, read_object): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-java.c: Include if-error.h instead of error-progname.h.
(accumulate_escaped, phase5_get, extract_parenthesized): Invoke 'if_error'
instead of 'error'.
* gettext-tools/src/x-javascript.c: Include if-error.h instead of
error-progname.h.
(phase7_getuc, phase5_scan_regexp, phase5_scan_xml_markup, phase5_get,
extract_balanced): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-librep.c: Include if-error.h instead of error-progname.h.
(read_object): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-lisp.c: Include if-error.h instead of error-progname.h.
(read_object): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-lua.c: Include if-error.h instead of error-progname.h.
(extract_balanced): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-perl.c: Include if-error.h instead of error-progname.h.
(get_here_document, extract_quotelike_pass3, interpolate_keywords, x_perl_lex,
extract_balanced): Invoke 'if_error' instead of 'error'.
(interpolate_keywords): Update extract_quotelike_pass3 invocations.
(extract_balanced): Update collect_message invocations. Call fflush before
abort (needed for MSVC).
* gettext-tools/src/x-php.c: Include if-error.h instead of error-progname.h.
(extract_balanced): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-python.c: Include if-error.h instead of error-progname.h.
(phase7_getuc, extract_balanced): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-rst.c: Include if-error.h instead of error-progname.h.
(extract_rst, extract_rsj): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-scheme.c: Include if-error.h instead of error-progname.h.
(read_object): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-sh.c: Include if-error.h instead of error-progname.h.
(read_word, read_command_list): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-tcl.c: Include if-error.h instead of error-progname.h.
(accumulate_word, read_word): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/x-vala.c: Include if-error.h instead of error-progname.h.
(phase7_getc, phase3_scan_regex, phase3_get, extract_balanced): Invoke
'if_error' instead of 'error'.
* gettext-tools/src/x-ycp.c: Include if-error.h instead of error-progname.h.
(extract_parenthesized): Invoke 'if_error' instead of 'error'.
* gettext-tools/src/xg-arglist-parser.c: Include if-error.h instead of error.h,
error-progname.h.
(arglist_parser_done): Invoke 'if_error' instead of 'error_at_line'.
* gettext-tools/src/xg-message.c: Include if-error.h instead of
error-progname.h.
(set_format_flags_from_context, warn_format_string, remember_a_message): Invoke
'if_error' instead of 'multiline_warning'.
* gettext-tools/src/Makefile.am (noinst_HEADERS): Add if-error.h.
(xgettext_SOURCES): Add if-error.c.
* gettext-tools/src/FILES: Mention if-error.h, if-error.c.
* gettext-tools/po/Makevars (XGETTEXT_OPTIONS): Add option regarding the
'if_error' function.
* gettext-tools/po/POTFILES.in: Add src/if-error.c.
--flag=asprintf:2:c-format --flag=vasprintf:2:c-format \
--flag=xasprintf:1:c-format --flag=error_logger:1:c-format \
--flag=po_error:3:c-format --flag=po_error_at_line:5:c-format \
- --flag=po_gram_error:1:c-format --flag=po_gram_error_at_line:2:c-format
+ --flag=po_gram_error:1:c-format --flag=po_gram_error_at_line:2:c-format \
+ --flag=if_error:6:c-format
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
src/format-smalltalk.c
src/format-tcl.c
src/hostname.c
+src/if-error.c
src/its.c
src/locating-rule.c
src/msgattrib.c
+-------------- The 'xgettext' program
| xgettext.h
| Declarations used by the backends.
+| if-error.h
+| if-error.c
+| Error handling during reading of input files.
| rc-str-list.h
| A reference-counted list-of-immutable-strings type.
| xg-pos.h
write-xml.h \
po-time.h plural-table.h lang-table.h format.h filters.h \
xgettext.h \
+ if-error.h \
rc-str-list.h xg-pos.h xg-encoding.h xg-mixed-string.h xg-arglist-context.h \
xg-arglist-callshape.h xg-arglist-parser.h xg-message.h \
x-po.h x-properties.h x-stringtable.h \
xgettext_SOURCES = ../woe32dll/c++xgettext.cc
endif
xgettext_SOURCES += \
+ if-error.c \
xg-pos.c \
xg-encoding.c \
xg-mixed-string.c \
--- /dev/null
+/* Error handling during reading of input files.
+ Copyright (C) 2023 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* Specification. */
+#include "if-error.h"
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "error.h"
+#include "xerror.h"
+#include "error-progname.h"
+#include "xalloc.h"
+#include "xvasprintf.h"
+#include "gettext.h"
+
+#define _(str) gettext (str)
+
+
+void
+if_error (int severity,
+ const char *filename, size_t lineno, size_t column,
+ bool multiline, const char *format, ...)
+{
+ const char *prefix_tail =
+ (severity == IF_SEVERITY_WARNING ? _("warning: ") : _("error: "));
+
+ va_list args;
+ va_start (args, format);
+ char *message_text = xvasprintf (format, args);
+ if (message_text == NULL)
+ message_text = xstrdup (severity == IF_SEVERITY_WARNING
+ ? _("<unformattable warning message>")
+ : _("<unformattable error message>"));
+
+ error_with_progname = false;
+ if (multiline)
+ {
+ char *prefix;
+ if (filename != NULL)
+ {
+ if (lineno != (size_t)(-1))
+ {
+ if (column != (size_t)(-1))
+ prefix = xasprintf ("%s:%ld:%ld: %s",
+ filename, (long) lineno, (long) column,
+ prefix_tail);
+ else
+ prefix = xasprintf ("%s:%ld: %s", filename, (long) lineno,
+ prefix_tail);
+ }
+ else
+ prefix = xasprintf ("%s: %s", filename, prefix_tail);
+ }
+ else
+ prefix = xasprintf ("%s", prefix_tail);
+
+ if (severity == IF_SEVERITY_WARNING)
+ multiline_warning (prefix, message_text);
+ else
+ multiline_error (prefix, message_text);
+ }
+ else
+ {
+ if (filename != NULL)
+ {
+ if (lineno != (size_t)(-1))
+ {
+ if (column != (size_t)(-1))
+ error (0, 0, "%s:%ld:%ld: %s%s",
+ filename, (long) lineno, (long) column, prefix_tail,
+ message_text);
+ else
+ error (0, 0, "%s:%ld: %s%s",
+ filename, (long) lineno, prefix_tail, message_text);
+ }
+ else
+ error (0, 0, "%s: %s%s", filename, prefix_tail, message_text);
+ }
+ else
+ error (0, 0, "%s%s", prefix_tail, message_text);
+ if (severity == IF_SEVERITY_WARNING)
+ --error_message_count;
+ free (message_text);
+ }
+ error_with_progname = true;
+
+ va_end (args);
+ if (severity == IF_SEVERITY_FATAL_ERROR)
+ exit (EXIT_FAILURE);
+}
--- /dev/null
+/* Error handling during reading of input files.
+ Copyright (C) 2023 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
+
+#ifndef _IF_ERROR_H
+#define _IF_ERROR_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* A higher-level error printing facility than the one in error.h / xerror.h
+ and error-progname.h. */
+
+#define IF_SEVERITY_WARNING 0 /* just a warning, tell the user */
+#define IF_SEVERITY_ERROR 1 /* an error, the operation cannot complete */
+#define IF_SEVERITY_FATAL_ERROR 2 /* an error, the operation must be aborted */
+
+/* Signal a problem of the given severity.
+ FILENAME + LINENO indicate where the problem occurred.
+ If FILENAME is NULL, FILENAME and LINENO and COLUMN are ignored.
+ If LINENO is (size_t)(-1), LINENO and COLUMN are ignored.
+ If COLUMN is (size_t)(-1), it is ignored.
+ FORMAT and the following format string arguments are the problem description
+ (if MULTILINE is true, multiple lines of text, each terminated with a
+ newline, otherwise usually a single line).
+ Does not return if SEVERITY is IF_SEVERITY_FATAL_ERROR. */
+extern void if_error (int severity,
+ const char *filename, size_t lineno, size_t column,
+ bool multiline, const char *format, ...)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+ __attribute__ ((__format__ (__printf__, 6, 7)))
+#endif
+ ;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _IF_ERROR_H */
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "gettext.h"
}
phase1_ungetc (c);
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated string"), logical_file_name,
- line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated string"));
return P7_QUOTES;
}
if (c == EOF || c == '\n')
{
phase1_ungetc (c);
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated regular expression"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated regular expression"));
break;
}
else if (c == '[')
case token_type_lparen:
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_parenthesized (mlp, inner_context, next_context_iter,
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "xvasprintf.h"
#include "mem-hash-map.h"
default:
phase3_ungetc (c);
if (overflow)
- {
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: hexadecimal escape sequence out of range"),
- logical_file_name, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("hexadecimal escape sequence out of range"));
return n;
case '0': case '1': case '2': case '3': case '4':
if (n < 0x110000)
return UNICODE (n);
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid Unicode character"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("invalid Unicode character"));
while (--j >= 0)
phase3_ungetc (buf[j]);
case '"':
/* A double-quote within the delimiter! This is too
weird. We don't support this. */
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: a double-quote in the delimiter of a raw string literal is unsupported"),
- logical_file_name, starting_line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, starting_line_number, (size_t)(-1), false,
+ _("a double-quote in the delimiter of a raw string literal is unsupported"));
FALLTHROUGH;
default:
valid_delimiter_char = false;
}
if (c == EOF)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated raw string literal"),
- logical_file_name, starting_line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, starting_line_number, (size_t)(-1), false,
+ _("unterminated raw string literal"));
tp->type = token_type_eof;
return;
}
- /* The error message for c == '"' was already emitted above. */
+ /* The warning message for c == '"' was already emitted above. */
if (c != '"')
- {
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid raw string literal syntax"),
- logical_file_name, starting_line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, starting_line_number, (size_t)(-1), false,
+ _("invalid raw string literal syntax"));
/* To get into a sane state, read up until the next double-quote,
newline, or EOF. */
while (!(c == EOF || c == '"' || c == '\n'))
c = phase7_getc ();
if (c == P7_NEWLINE)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated character constant"),
- logical_file_name, line_number - 1);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number - 1, (size_t)(-1), false,
+ _("unterminated character constant"));
phase7_ungetc ('\n');
break;
}
if (c == P7_NEWLINE)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated string literal"),
- logical_file_name, line_number - 1);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number - 1, (size_t)(-1), false,
+ _("unterminated string literal"));
phase7_ungetc ('\n');
break;
}
case xgettext_token_type_lparen:
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_parenthesized (mlp, inner_context, next_context_iter,
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
#include "xg-message.h"
#include "c-ctype.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "xerror.h"
#include "xvasprintf.h"
}
if (n >= 0x110000)
- {
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid Unicode character"),
- logical_file_name, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("invalid Unicode character"));
else if (predicate (n))
return n;
if (c == UNL)
{
phase3_ungetc (c);
- error_with_progname = false;
if (delimiter == '\'')
- error (0, 0, _("%s:%d: warning: unterminated character constant"),
- logical_file_name, line_number);
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated character constant"));
else
- error (0, 0, _("%s:%d: warning: unterminated string constant"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated string constant"));
break;
}
if (c == '\\')
case token_type_lparen:
if (++paren_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_parenthesized (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
return false;
}
if (terminator == token_type_rbrace)
- {
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: ')' found where '}' was expected"),
- logical_file_name, token.line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, token.line_number, (size_t)(-1), false,
+ _("')' found where '}' was expected"));
next_context_iter = null_context_list_iterator;
state = 0;
continue;
case token_type_lbrace:
if (++brace_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open braces"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open braces"));
if (extract_parenthesized (mlp, token_type_rbrace,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
return false;
}
if (terminator == token_type_rparen)
- {
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: '}' found where ')' was expected"),
- logical_file_name, token.line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, token.line_number, (size_t)(-1), false,
+ _("'}' found where ')' was expected"));
next_context_iter = null_context_list_iterator;
state = 0;
continue;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "c-ctype.h"
do_getc_escaped (int c, bool in_string)
{
if (escape_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested escape sequence"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested escape sequence"));
switch (c)
{
case 'a':
flag_context_ty outer_context)
{
if (nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested objects"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested objects"));
for (;;)
{
int ch;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "po-charset.h"
if (RED (c) == '\n')
{
phase3_ungetc (c);
- error_with_progname = false;
if (delimiter == '\'')
- error (0, 0, _("%s:%d: warning: unterminated character constant"),
- logical_file_name, line_number);
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated character constant"));
else
- error (0, 0, _("%s:%d: warning: unterminated string constant"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated string constant"));
break;
}
if (RED (c) == '\\')
int ic = phase3_getc ();
if (ic == P2_EOF)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated text block"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated text block"));
tp->type = token_type_other;
return;
}
break;
else
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid syntax in text block"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("invalid syntax in text block"));
tp->type = token_type_other;
return;
}
}
if (ic == P2_EOF)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated text block"),
- logical_file_name, block.line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, block.line_number, (size_t)(-1), false,
+ _("unterminated text block"));
break;
}
if (RED (ic) == '\\')
case token_type_lparen:
if (++paren_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_parenthesized (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
return false;
}
if (terminator == token_type_rbrace)
- {
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: ')' found where '}' was expected"),
- logical_file_name, token.line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, token.line_number, (size_t)(-1), false,
+ _("')' found where '}' was expected"));
next_context_iter = null_context_list_iterator;
state = 0;
continue;
case token_type_lbrace:
if (++brace_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open braces"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open braces"));
if (extract_parenthesized (mlp, token_type_rbrace,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
return false;
}
if (terminator == token_type_rparen)
- {
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: '}' found where ')' was expected"),
- logical_file_name, token.line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, token.line_number, (size_t)(-1), false,
+ _("'}' found where ')' was expected"));
next_context_iter = null_context_list_iterator;
state = 0;
continue;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "progname.h"
#include "xerror.h"
#include "xvasprintf.h"
else
{
phase2_ungetc (c);
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated string"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated string"));
return P7_STRING_END;
}
}
}
if (c == UEOF)
{
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: RegExp literal terminated too early"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("RegExp literal terminated too early"));
return;
}
}
goto eof;
if (c != '>')
{
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: %s is not allowed"),
- logical_file_name, line_number,
- end);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("%s is not allowed"), end);
return -1;
}
return i;
return -1;
eof:
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: unterminated XML markup"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated XML markup"));
return -1;
}
/* Ignore them all, since they are not part of JSX.
But warn about CDATA. */
if (xml_markup_type == 1)
- {
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: ignoring CDATA section"),
- logical_file_name, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("ignoring CDATA section"));
continue;
}
case token_type_lparen:
if (++paren_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_balanced (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
case token_type_lbracket:
if (++bracket_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open brackets"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open brackets"));
if (extract_balanced (mlp, token_type_rbracket,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
case token_type_lbrace:
if (++brace_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open braces"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open braces"));
if (extract_balanced (mlp, token_type_rbrace,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
case token_type_xml_element_start:
if (++xml_element_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open XML elements"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open XML elements"));
if (extract_balanced (mlp, token_type_xml_element_end,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "gettext.h"
read_object (struct object *op, flag_context_ty outer_context)
{
if (nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested objects"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested objects"));
for (;;)
{
int ch;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "gettext.h"
read_object (struct object *op, flag_context_ty outer_context)
{
if (nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested objects"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested objects"));
for (;;)
{
struct char_syntax curr;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "gettext.h"
#include "po-charset.h"
case token_type_lparen:
if (++paren_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_balanced (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
case token_type_lbracket:
if (++bracket_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open brackets"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open brackets"));
if (extract_balanced (mlp, token_type_rbracket,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "c-ctype.h"
#include "po-charset.h"
}
else
{
- error_with_progname = false;
- error (EXIT_SUCCESS, 0,
- _("%s:%d: warning: can't find string terminator \"%s\" anywhere before EOF"),
- real_file_name, line_number, delimiter);
- error_with_progname = true;
-
+ if_error (IF_SEVERITY_WARNING,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("can't find string terminator \"%s\" anywhere before EOF"),
+ delimiter);
break;
}
}
const char *end = strchr (crs, '}');
if (end == NULL)
{
- error_with_progname = false;
- error (error_level, 0,
- _("%s:%d: missing right brace on \\x{HEXNUMBER}"),
- real_file_name, line_number);
- error_with_progname = true;
+ if_error (error_level,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("missing right brace on \\x{HEXNUMBER}"));
++crs;
continue;
}
}
else if ((unsigned char) *crs >= 0x80)
{
- error_with_progname = false;
- error (error_level, 0,
- _("%s:%d: invalid interpolation (\"\\l\") of 8bit character \"%c\""),
- real_file_name, line_number, *crs);
- error_with_progname = true;
+ if_error (error_level,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("invalid interpolation (\"\\l\") of 8bit character \"%c\""),
+ *crs);
}
else
{
}
else if ((unsigned char) *crs >= 0x80)
{
- error_with_progname = false;
- error (error_level, 0,
- _("%s:%d: invalid interpolation (\"\\u\") of 8bit character \"%c\""),
- real_file_name, line_number, *crs);
- error_with_progname = true;
+ if_error (error_level,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("invalid interpolation (\"\\u\") of 8bit character \"%c\""),
+ *crs);
}
else
{
if (!backslashed && !extract_all && (*crs == '$' || *crs == '@'))
{
- error_with_progname = false;
- error (error_level, 0,
- _("%s:%d: invalid variable interpolation at \"%c\""),
- real_file_name, line_number, *crs);
- error_with_progname = true;
+ if_error (error_level,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("invalid variable interpolation at \"%c\""), *crs);
++crs;
}
else if (lowercase)
buffer[bufpos++] = *crs - 'A' + 'a';
else if ((unsigned char) *crs >= 0x80)
{
- error_with_progname = false;
- error (error_level, 0,
- _("%s:%d: invalid interpolation (\"\\L\") of 8bit character \"%c\""),
- real_file_name, line_number, *crs);
- error_with_progname = true;
+ if_error (error_level,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("invalid interpolation (\"\\L\") of 8bit character \"%c\""),
+ *crs);
buffer[bufpos++] = *crs;
}
else
buffer[bufpos++] = *crs - 'a' + 'A';
else if ((unsigned char) *crs >= 0x80)
{
- error_with_progname = false;
- error (error_level, 0,
- _("%s:%d: invalid interpolation (\"\\U\") of 8bit character \"%c\""),
- real_file_name, line_number, *crs);
- error_with_progname = true;
+ if_error (error_level,
+ real_file_name, line_number, (size_t)(-1), false,
+ _("invalid interpolation (\"\\U\") of 8bit character \"%c\""),
+ *crs);
buffer[bufpos++] = *crs;
}
else
lex_pos_ty pos;
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested expressions"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested expressions"));
/* States are:
*
/* The resulting string has to be interpolated twice. */
buffer[bufpos] = '\0';
token.string = xstrdup (buffer);
- extract_quotelike_pass3 (&token, EXIT_FAILURE);
+ extract_quotelike_pass3 (&token, IF_SEVERITY_FATAL_ERROR);
/* The string can only shrink with interpolation (because
we ignore \Q). */
if (!(strlen (token.string) <= bufpos))
case '}':
buffer[bufpos] = '\0';
token.string = xstrdup (buffer);
- extract_quotelike_pass3 (&token, EXIT_FAILURE);
+ extract_quotelike_pass3 (&token, IF_SEVERITY_FATAL_ERROR);
remember_a_message (mlp, NULL, token.string, true, false, context,
&pos, NULL, savable_comment, true);
FALLTHROUGH;
x_perl_lex (message_list_ty *mlp)
{
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested expressions"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested expressions"));
#if DEBUG_PERL
int dummy = token_stack_dump (&token_stack);
tp->sub_type = string_type_q;
tp->comment = add_reference (savable_comment);
#if DEBUG_PERL
- fprintf (stderr,
- "%s:%d: token %s mutated to token_type_string\n",
+ fprintf (stderr, "%s:%d: token %s mutated to token_type_string\n",
real_file_name, line_number, token2string (tp));
#endif
}
#endif
if (nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested expressions"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested expressions"));
for (;;)
{
if (extract_all)
{
- char *string = collect_message (mlp, tp, EXIT_SUCCESS);
+ char *string = collect_message (mlp, tp, IF_SEVERITY_WARNING);
lex_pos_ty pos;
pos.file_name = logical_file_name;
if (must_collect)
{
- char *string = collect_message (mlp, tp, EXIT_FAILURE);
+ char *string = collect_message (mlp, tp, IF_SEVERITY_FATAL_ERROR);
mixed_string_ty *ms =
mixed_string_alloc_utf8 (string, lc_string,
logical_file_name, tp->line_number);
break;
default:
- fprintf (stderr, "%s:%d: error: unknown token type %d\n",
- real_file_name, tp->line_number, (int) tp->type);
+ if_error (IF_SEVERITY_ERROR,
+ real_file_name, tp->line_number, (size_t)(-1), false,
+ "unknown token type %d", (int) tp->type);
+ fflush (stderr);
abort ();
}
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "gettext.h"
case token_type_lparen:
if (++paren_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_balanced (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
case token_type_lbracket:
if (++bracket_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open brackets"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open brackets"));
if (extract_balanced (mlp, token_type_rbracket,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "progname.h"
#include "basename-lgpl.h"
#include "xerror.h"
return UNICODE ('\n');
}
phase2_ungetc (c);
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated string"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("unterminated string"));
return P7_STRING_END;
}
return UNICODE (n);
}
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid Unicode character"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("invalid Unicode character"));
while (--i >= 0)
phase2_ungetc (buf[i]);
case token_type_lparen:
if (++paren_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_balanced (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
case token_type_lbracket:
if (++bracket_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open brackets"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open brackets"));
if (extract_balanced (mlp, token_type_rbracket,
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
#include "xg-mixed-string.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "gettext.h"
for (;;)
{
if (c == EOF || c == '\n')
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: invalid string definition"),
- logical_filename, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_filename, line_number, (size_t)(-1), false,
+ _("invalid string definition"));
if (bufpos >= bufmax)
{
bufmax = 2 * bufmax + 10;
if (c == EOF && ferror (f))
goto bomb;
if (c == EOF || !c_isdigit (c))
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: missing number after #"),
- logical_filename, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_filename, line_number, (size_t)(-1), false,
+ _("missing number after #"));
n = (c - '0');
for (;;)
{
ungetc (c, f);
}
else
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: invalid string expression"),
- logical_filename, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_filename, line_number, (size_t)(-1), false,
+ _("invalid string expression"));
}
if (bufpos >= bufmax)
{
return;
invalid_json:
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: invalid JSON syntax"),
- logical_filename, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_filename, line_number, (size_t)(-1), false,
+ _("invalid JSON syntax"));
return;
invalid_rsj:
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: invalid RSJ syntax"),
- logical_filename, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_filename, line_number, (size_t)(-1), false,
+ _("invalid RSJ syntax"));
return;
invalid_rsj_version:
- error_with_progname = false;
- error (EXIT_FAILURE, 0,
- _("%s:%d: error: invalid RSJ version. Only version 1 is supported."),
- logical_filename, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_filename, line_number, (size_t)(-1), false,
+ _("invalid RSJ version. Only version 1 is supported."));
return;
}
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "gettext.h"
read_object (struct object *op, flag_context_ty outer_context)
{
if (nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested objects"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested objects"));
for (;;)
{
int ch = do_getc ();
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "../../gettext-runtime/src/escapes.h"
NULL, savable_comment, false);
free_token (&string);
- error_with_progname = false;
- error (0, 0, _("%s:%lu: warning: the syntax $\"...\" is deprecated due to security reasons; use eval_gettext instead"),
- pos.file_name, (unsigned long) pos.line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ pos.file_name, pos.line_number, (size_t)(-1), false,
+ _("the syntax $\"...\" is deprecated due to security reasons; use eval_gettext instead"));
/* The result at runtime is not constant. Therefore we
change wp->type. */
read_command_list (int looking_for, flag_context_ty outer_context)
{
if (nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too deeply nested command list"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too deeply nested command list"));
for (;;)
{
enum word_type terminator;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "mem-hash-map.h"
#include "c-ctype.h"
else if (c == '[')
{
if (++bracket_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open brackets"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open brackets"));
read_command_list (']', context);
bracket_nesting_depth--;
wp->type = t_other;
}
phase2_ungetc (c);
}
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid Unicode character"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("invalid Unicode character"));
goto done_escape;
}
saw_unicode_escape:
/* Interpret it as a command list. */
if (++brace_nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open braces"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open braces"));
terminator = read_command_list ('\0', null_context);
brace_nesting_depth--;
#include "xg-arglist-parser.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "xvasprintf.h"
#include "mem-hash-map.h"
default:
phase1_ungetc (c);
if (overflow)
- {
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: hexadecimal escape sequence out of range"),
- logical_file_name, line_number);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("hexadecimal escape sequence out of range"));
return n;
case '0': case '1': case '2': case '3': case '4':
if (n < 0x110000)
return UNICODE (n);
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: invalid Unicode character"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("invalid Unicode character"));
while (--j >= 0)
phase1_ungetc (buf[j]);
}
if (c == EOF)
{
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: regular expression literal terminated too early"),
- logical_file_name, line_number);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("regular expression literal terminated too early"));
return;
}
}
c = phase7_getc ();
if (c == P7_NEWLINE)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated character constant"),
- logical_file_name, line_number - 1);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number - 1, (size_t)(-1), false,
+ _("unterminated character constant"));
phase7_ungetc ('\n');
break;
}
if (c == P7_NEWLINE)
{
- error_with_progname = false;
- error (0, 0,
- _("%s:%d: warning: unterminated string literal"),
- logical_file_name, line_number - 1);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number - 1, (size_t)(-1), false,
+ _("unterminated string literal"));
phase7_ungetc ('\n');
break;
}
case token_type_lparen:
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_balanced (mlp, token_type_rparen,
inner_context, next_context_iter,
arglist_parser_alloc (mlp,
#include "xg-arglist-context.h"
#include "xg-message.h"
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "xalloc.h"
#include "gettext.h"
{
case token_type_i18n:
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_parenthesized (mlp, inner_context, next_context_iter,
true))
return true;
case token_type_lparen:
if (++nesting_depth > MAX_NESTING_DEPTH)
- {
- error_with_progname = false;
- error (EXIT_FAILURE, 0, _("%s:%d: error: too many open parentheses"),
- logical_file_name, line_number);
- }
+ if_error (IF_SEVERITY_FATAL_ERROR,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("too many open parentheses"));
if (extract_parenthesized (mlp, inner_context, next_context_iter,
false))
return true;
#include <stdlib.h>
#include <string.h>
-#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "flexmember.h"
#include "xalloc.h"
#include "xsize.h"
}
if (ambiguous)
- {
- error_with_progname = false;
- error_at_line (0, 0,
- best_cp->msgid_pos.file_name,
- best_cp->msgid_pos.line_number,
- _("warning: ambiguous argument specification for keyword '%.*s'"),
- (int) ap->keyword_len, ap->keyword);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ best_cp->msgid_pos.file_name,
+ best_cp->msgid_pos.line_number,
+ (size_t)(-1), false,
+ _("ambiguous argument specification for keyword '%.*s'"),
+ (int) ap->keyword_len, ap->keyword);
if (best_cp != NULL)
{
const char *separator = strchr (best_msgid, '|');
if (separator == NULL)
- {
- error_with_progname = false;
- error_at_line (0, 0,
- best_cp->msgid_pos.file_name,
- best_cp->msgid_pos.line_number,
- _("warning: missing context for keyword '%.*s'"),
- (int) ap->keyword_len, ap->keyword);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ best_cp->msgid_pos.file_name,
+ best_cp->msgid_pos.line_number,
+ (size_t)(-1), false,
+ _("missing context for keyword '%.*s'"),
+ (int) ap->keyword_len, ap->keyword);
else
{
size_t ctxt_len = separator - best_msgid;
const char *separator = strchr (best_msgid_plural, '|');
if (separator == NULL)
- {
- error_with_progname = false;
- error_at_line (0, 0,
- best_cp->msgid_plural_pos.file_name,
- best_cp->msgid_plural_pos.line_number,
- _("warning: missing context for plural argument of keyword '%.*s'"),
- (int) ap->keyword_len, ap->keyword);
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ best_cp->msgid_plural_pos.file_name,
+ best_cp->msgid_plural_pos.line_number,
+ (size_t)(-1), false,
+ _("missing context for plural argument of keyword '%.*s'"),
+ (int) ap->keyword_len, ap->keyword);
else
{
size_t ctxt_len = separator - best_msgid_plural;
else
{
if (strcmp (ctxt, best_msgctxt) != 0)
- {
- error_with_progname = false;
- error_at_line (0, 0,
- best_cp->msgid_plural_pos.file_name,
- best_cp->msgid_plural_pos.line_number,
- _("warning: context mismatch between singular and plural form"));
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ best_cp->msgid_plural_pos.file_name,
+ best_cp->msgid_plural_pos.line_number,
+ (size_t)(-1), false,
+ _("context mismatch between singular and plural form"));
free (ctxt);
}
best_msgid_plural = xstrdup (separator + 1);
#include <stdio.h>
#include "c-strstr.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "format.h"
#include "read-catalog-abstract.h"
#include "xalloc.h"
{
/* The string is not a valid format string. */
if (is_format[i] != possible)
- {
- char buffer[22];
-
- error_with_progname = false;
- if (pos->line_number == (size_t)(-1))
- buffer[0] = '\0';
- else
- sprintf (buffer, ":%ld", (long) pos->line_number);
- multiline_warning (xasprintf (_("%s%s: warning: "),
- pos->file_name, buffer),
- xasprintf (is_format[i] == yes_according_to_context
- ? _("Although being used in a format string position, the %s is not a valid %s format string. Reason: %s\n")
- : _("Although declared as such, the %s is not a valid %s format string. Reason: %s\n"),
- pretty_msgstr,
- format_language_pretty[i],
- invalid_reason));
- error_with_progname = true;
- }
+ if_error (IF_SEVERITY_WARNING,
+ pos->file_name, pos->line_number, (size_t)(-1), true,
+ is_format[i] == yes_according_to_context
+ ? _("Although being used in a format string position, the %s is not a valid %s format string. Reason: %s\n")
+ : _("Although declared as such, the %s is not a valid %s format string. Reason: %s\n"),
+ pretty_msgstr, format_language_pretty[i],
+ invalid_reason);
is_format[i] = impossible;
free (invalid_reason);
{
if (possible_format_p (is_format[format_python])
&& get_python_format_unnamed_arg_count (string) > 1)
- {
- char buffer[22];
-
- error_with_progname = false;
- if (pos->line_number == (size_t)(-1))
- buffer[0] = '\0';
- else
- sprintf (buffer, ":%ld", (long) pos->line_number);
- multiline_warning (xasprintf (_("%s%s: warning: "),
- pos->file_name, buffer),
- xasprintf (_("\
+ if_error (IF_SEVERITY_WARNING,
+ pos->file_name, pos->line_number, (size_t)(-1), true,
+ _("\
'%s' format string with unnamed arguments cannot be properly localized:\n\
The translator cannot reorder the arguments.\n\
Please consider using a format string with named arguments,\n\
and a mapping instead of a tuple for the arguments.\n"),
- pretty_msgstr));
- error_with_progname = true;
- }
+ pretty_msgstr);
}
}
if (msgctxt == NULL && msgid[0] == '\0' && !xgettext_omit_header)
- {
- char buffer[22];
-
- error_with_progname = false;
- if (pos->line_number == (size_t)(-1))
- buffer[0] = '\0';
- else
- sprintf (buffer, ":%ld", (long) pos->line_number);
- multiline_warning (xasprintf (_("%s%s: warning: "), pos->file_name,
- buffer),
- xstrdup (_("\
+ if_error (IF_SEVERITY_WARNING,
+ pos->file_name, pos->line_number, (size_t)(-1), true,
+ _("\
Empty msgid. It is reserved by GNU gettext:\n\
gettext(\"\") returns the header entry with\n\
-meta information, not the empty string.\n")));
- error_with_progname = true;
- }
+meta information, not the empty string.\n"));
/* See if we have seen this message before. */
mp = message_list_search (mlp, msgctxt, msgid);
/* Handling strings that are given partially in the source encoding and
partially in Unicode.
- Copyright (C) 2001-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2023 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
#include <string.h>
#include "error.h"
-#include "error-progname.h"
+#include "if-error.h"
#include "flexmember.h"
#include "msgl-ascii.h"
#include "po-charset.h"
as a 3-byte sequence, the resulting UTF-8 data stream
would become ill-formed."
So use U+FFFD instead. */
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: lone surrogate U+%04X"),
- logical_file_name, line_number, uc);
- error_with_progname = true;
+ if_error (IF_SEVERITY_WARNING,
+ logical_file_name, line_number, (size_t)(-1), false,
+ _("lone surrogate U+%04X"), uc);
mixed_string_buffer_append_to_utf8_buffer (bp, 0xfffd);
}