[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 12 Dec 2023 11:44:30 -0500 (EST) |
branch: master
commit f22be3f481b09b3d12007ce4bf7496f3be55b981
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Dec 12 17:44:21 2023 +0100
* tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES),
tp/Texinfo/XS/main/errors.c (vmessage_list_line_error),
tp/Texinfo/XS/parsetexi/errors_parser.c,
tp/Texinfo/XS/parsetexi/errors_parser.h: rename
message_list_line_error_internal as vmessage_list_line_error. Update
callers.
Add errors_parser.c and move functions using parser internal
structures, current_source_info, error_messages_list and debug_output
from errors.c to errors_parser.c. This corresponds to
line_error_internal, line_error_ext, line_error, line_warn,
command_warn, command_error, forget_errors, bug_message_internal
and bug_message.
---
ChangeLog | 15 ++++
tp/Texinfo/XS/Makefile.am | 2 +
tp/Texinfo/XS/main/errors.c | 141 ++++--------------------------
tp/Texinfo/XS/main/errors.h | 19 ++--
tp/Texinfo/XS/main/targets.c | 2 +-
tp/Texinfo/XS/main/translations.c | 2 +-
tp/Texinfo/XS/parsetexi/close.c | 2 +-
tp/Texinfo/XS/parsetexi/end_line.c | 2 +-
tp/Texinfo/XS/parsetexi/errors_parser.c | 138 +++++++++++++++++++++++++++++
tp/Texinfo/XS/parsetexi/errors_parser.h | 23 +++++
tp/Texinfo/XS/parsetexi/handle_commands.c | 2 +-
tp/Texinfo/XS/parsetexi/indices.c | 2 +-
tp/Texinfo/XS/parsetexi/input.c | 4 +-
tp/Texinfo/XS/parsetexi/labels.c | 2 +-
tp/Texinfo/XS/parsetexi/macro.c | 2 +-
tp/Texinfo/XS/parsetexi/menus.c | 2 +-
tp/Texinfo/XS/parsetexi/multitable.c | 2 +-
tp/Texinfo/XS/parsetexi/parser.c | 2 +-
tp/Texinfo/XS/parsetexi/separator.c | 2 +-
19 files changed, 215 insertions(+), 151 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d38d659e97..79bbe163a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-12-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES),
+ tp/Texinfo/XS/main/errors.c (vmessage_list_line_error),
+ tp/Texinfo/XS/parsetexi/errors_parser.c,
+ tp/Texinfo/XS/parsetexi/errors_parser.h: rename
+ message_list_line_error_internal as vmessage_list_line_error. Update
+ callers.
+ Add errors_parser.c and move functions using parser internal
+ structures, current_source_info, error_messages_list and debug_output
+ from errors.c to errors_parser.c. This corresponds to
+ line_error_internal, line_error_ext, line_error, line_warn,
+ command_warn, command_error, forget_errors, bug_message_internal
+ and bug_message.
+
2023-12-12 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/errors.c (message_list_line_error_internal)
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index a6a368248c..77434f9fda 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -162,6 +162,8 @@ libtexinfo_la_SOURCES= \
parsetexi/context_stack.h \
parsetexi/debug_parser.c \
parsetexi/debug_parser.h \
+ parsetexi/errors_parser.c \
+ parsetexi/errors_parser.h \
parsetexi/end_line.c \
parsetexi/separator.c \
parsetexi/multitable.c \
diff --git a/tp/Texinfo/XS/main/errors.c b/tp/Texinfo/XS/main/errors.c
index a41d54bb10..6876717295 100644
--- a/tp/Texinfo/XS/main/errors.c
+++ b/tp/Texinfo/XS/main/errors.c
@@ -30,18 +30,11 @@
#include "document_types.h"
/* also for xvasprintf */
#include "text.h"
-/* for debug_output */
-#include "debug.h"
/* for fatal */
#include "utils.h"
#include "errors.h"
-/* Current filename and line number. Used for reporting. */
-SOURCE_INFO current_source_info;
-
-ERROR_MESSAGE_LIST error_messages_list;
-
static ERROR_MESSAGE *
reallocate_error_messages (ERROR_MESSAGE_LIST *error_messages)
{
@@ -132,12 +125,12 @@ message_list_line_formatted_message (ERROR_MESSAGE_LIST
*error_messages,
fprintf (stderr, "%s", error_message->error_line);
}
-static void
-message_list_line_error_internal (ERROR_MESSAGE_LIST *error_messages,
- enum error_type type, int continuation,
- int warn,
- const SOURCE_INFO *cmd_source_info,
- const char *format, va_list v)
+void
+vmessage_list_line_error (ERROR_MESSAGE_LIST *error_messages,
+ enum error_type type, int continuation,
+ int warn,
+ const SOURCE_INFO *cmd_source_info,
+ const char *format, va_list v)
{
char *message;
@@ -238,54 +231,6 @@ message_list_document_error_internal (ERROR_MESSAGE_LIST
*error_messages,
continuation, message);
}
-static void
-line_error_internal (enum error_type type, int continuation,
- const SOURCE_INFO *cmd_source_info,
- const char *format, va_list v)
-{
- message_list_line_error_internal (&error_messages_list,
- type, continuation, debug_output, cmd_source_info,
- format, v);
-}
-
-void
-line_error_ext (enum error_type type, int continuation,
- SOURCE_INFO *cmd_source_info,
- const char *format, ...)
-{
- va_list v;
-
- va_start (v, format);
- line_error_internal (type, continuation, cmd_source_info, format, v);
-}
-
-void
-line_error (const char *format, ...)
-{
- va_list v;
-
- va_start (v, format);
- line_error_internal (MSG_error, 0, ¤t_source_info, format, v);
-}
-
-void
-line_warn (const char *format, ...)
-{
- va_list v;
-
- va_start (v, format);
- line_error_internal (MSG_warning, 0, ¤t_source_info, format, v);
-}
-
-void
-command_warn (const ELEMENT *e, const char *format, ...)
-{
- va_list v;
-
- va_start (v, format);
- line_error_internal (MSG_warning, 0, &e->source_info, format, v);
-}
-
void
message_list_line_error_ext (ERROR_MESSAGE_LIST *error_messages,
OPTIONS *conf,
@@ -295,9 +240,9 @@ message_list_line_error_ext (ERROR_MESSAGE_LIST
*error_messages,
va_list v;
va_start (v, format);
- message_list_line_error_internal (error_messages, type, continuation,
- (conf && conf->DEBUG > 0),
- cmd_source_info, format, v);
+ vmessage_list_line_error (error_messages, type, continuation,
+ (conf && conf->DEBUG > 0),
+ cmd_source_info, format, v);
}
void
@@ -308,9 +253,9 @@ message_list_command_warn (ERROR_MESSAGE_LIST
*error_messages,
va_list v;
va_start (v, format);
- message_list_line_error_internal (error_messages, MSG_warning, 0,
- (conf && conf->DEBUG > 0),
- &e->source_info, format, v);
+ vmessage_list_line_error (error_messages, MSG_warning, 0,
+ (conf && conf->DEBUG > 0),
+ &e->source_info, format, v);
}
/* similar as message_list_command_warn, to be used only when the calling
@@ -320,18 +265,9 @@ vmessage_list_command_warn (ERROR_MESSAGE_LIST
*error_messages,
OPTIONS *conf,
const ELEMENT *e, const char *format, va_list v)
{
- message_list_line_error_internal (error_messages, MSG_warning, 0,
- (conf && conf->DEBUG > 0),
- &e->source_info, format, v);
-}
-
-void
-command_error (const ELEMENT *e, const char *format, ...)
-{
- va_list v;
-
- va_start (v, format);
- line_error_internal (MSG_error, 0, &e->source_info, format, v);
+ vmessage_list_line_error (error_messages, MSG_warning, 0,
+ (conf && conf->DEBUG > 0),
+ &e->source_info, format, v);
}
void
@@ -342,9 +278,9 @@ message_list_command_error (ERROR_MESSAGE_LIST
*error_messages,
va_list v;
va_start (v, format);
- message_list_line_error_internal (error_messages, MSG_error, 0,
- (conf && conf->DEBUG > 0),
- &e->source_info, format, v);
+ vmessage_list_line_error (error_messages, MSG_error, 0,
+ (conf && conf->DEBUG > 0),
+ &e->source_info, format, v);
}
/* FIXME continuation? */
@@ -399,44 +335,3 @@ clear_error_message_list (ERROR_MESSAGE_LIST
*error_messages)
wipe_error_messages (error_messages);
error_messages->number = 0;
}
-
-/* not used */
-void
-wipe_errors (void)
-{
- wipe_error_message_list (&error_messages_list);
-}
-
-void
-forget_errors (void)
-{
- memset (&error_messages_list, 0, sizeof (ERROR_MESSAGE_LIST));
-}
-
-static void
-bug_message_internal (char *format, va_list v)
-{
- fprintf (stderr, "You found a bug: ");
- vfprintf (stderr, format, v);
- fprintf (stderr, "\n");
- if (current_source_info.file_name)
- {
- fprintf (stderr,
- "last location %s:%d", current_source_info.file_name,
- current_source_info.line_nr);
- if (current_source_info.macro)
- fprintf (stderr, " (possibly involving @%s)",
current_source_info.macro);
- fprintf (stderr, "\n");
- }
- exit (1);
-}
-
-void
-bug_message (char *format, ...)
-{
- va_list v;
-
- va_start (v, format);
- bug_message_internal (format, v);
-}
-
diff --git a/tp/Texinfo/XS/main/errors.h b/tp/Texinfo/XS/main/errors.h
index fb95650ed7..07e8b58c37 100644
--- a/tp/Texinfo/XS/main/errors.h
+++ b/tp/Texinfo/XS/main/errors.h
@@ -8,23 +8,17 @@
#include "options_types.h"
#include "document_types.h"
-void line_error (const char *format, ...);
-void line_warn (const char *format, ...);
-void command_error (const ELEMENT *e, const char *format, ...);
-void command_warn (const ELEMENT *e, const char *format, ...);
-void wipe_errors (void);
-void forget_errors (void);
-void line_error_ext (enum error_type type, int continuation,
- SOURCE_INFO *cmd_source_info, const char *format, ...);
-void bug_message (char *format, ...);
-char *prepare_error_line_message (ERROR_MESSAGE *error_message);
-
void wipe_error_message_list (ERROR_MESSAGE_LIST *error_messages);
void clear_error_message_list (ERROR_MESSAGE_LIST *error_messages);
void message_list_line_formatted_message (ERROR_MESSAGE_LIST *error_messages,
enum error_type type, int continuation,
const SOURCE_INFO *cmd_source_info,
char *message, int warn);
+void vmessage_list_line_error (ERROR_MESSAGE_LIST *error_messages,
+ enum error_type type, int continuation,
+ int warn,
+ const SOURCE_INFO *cmd_source_info,
+ const char *format, va_list v);
void message_list_line_error_ext (ERROR_MESSAGE_LIST *error_messages,
OPTIONS *conf,
enum error_type type, int continuation,
@@ -50,7 +44,4 @@ void vmessage_list_command_warn (ERROR_MESSAGE_LIST
*error_messages,
OPTIONS *conf,
const ELEMENT *e, const char *format, va_list v);
-extern ERROR_MESSAGE_LIST error_messages_list;
-extern SOURCE_INFO current_source_info;
-
#endif
diff --git a/tp/Texinfo/XS/main/targets.c b/tp/Texinfo/XS/main/targets.c
index 3d3ccfa584..b19d8f97c3 100644
--- a/tp/Texinfo/XS/main/targets.c
+++ b/tp/Texinfo/XS/main/targets.c
@@ -22,7 +22,7 @@
#include "tree_types.h"
#include "document_types.h"
#include "tree.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "debug.h"
#include "builtin_commands.h"
/* for get_label_element and fatal */
diff --git a/tp/Texinfo/XS/main/translations.c
b/tp/Texinfo/XS/main/translations.c
index 0bd9e7c3d9..08c1e54050 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -34,7 +34,7 @@
#include "text.h"
#include "utils.h"
#include "tree.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "debug.h"
#include "api.h"
#include "document.h"
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index 4ed91e44cb..d979161c31 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -24,7 +24,7 @@
#include "def.h"
#include "debug.h"
#include "debug_parser.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "counter.h"
#include "builtin_commands.h"
#include "source_marks.h"
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index e3811b4e4e..fc9ca293ff 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -26,7 +26,7 @@
#include "tree.h"
#include "debug_parser.h"
#include "debug.h"
-#include "errors.h"
+#include "errors_parser.h"
/* for isascii_alnum whitespace_chars read_flag_name
indices_info_index_by_name ultimate_index fatal */
#include "utils.h"
diff --git a/tp/Texinfo/XS/parsetexi/errors_parser.c
b/tp/Texinfo/XS/parsetexi/errors_parser.c
new file mode 100644
index 0000000000..73897e66f3
--- /dev/null
+++ b/tp/Texinfo/XS/parsetexi/errors_parser.c
@@ -0,0 +1,138 @@
+/* Copyright 2010-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 <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#ifdef ENABLE_NLS
+#include <locale.h>
+#include <gettext.h>
+#include <libintl.h>
+#endif
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "tree_types.h"
+#include "document_types.h"
+/* for debug_output */
+#include "debug.h"
+#include "errors.h"
+#include "errors_parser.h"
+
+
+/* Current filename and line number. Used for reporting. */
+SOURCE_INFO current_source_info;
+
+ERROR_MESSAGE_LIST error_messages_list;
+
+static void
+line_error_internal (enum error_type type, int continuation,
+ const SOURCE_INFO *cmd_source_info,
+ const char *format, va_list v)
+{
+ vmessage_list_line_error (&error_messages_list,
+ type, continuation, debug_output, cmd_source_info,
+ format, v);
+}
+
+void
+line_error_ext (enum error_type type, int continuation,
+ SOURCE_INFO *cmd_source_info,
+ const char *format, ...)
+{
+ va_list v;
+
+ va_start (v, format);
+ line_error_internal (type, continuation, cmd_source_info, format, v);
+}
+
+void
+line_error (const char *format, ...)
+{
+ va_list v;
+
+ va_start (v, format);
+ line_error_internal (MSG_error, 0, ¤t_source_info, format, v);
+}
+
+void
+line_warn (const char *format, ...)
+{
+ va_list v;
+
+ va_start (v, format);
+ line_error_internal (MSG_warning, 0, ¤t_source_info, format, v);
+}
+
+void
+command_warn (const ELEMENT *e, const char *format, ...)
+{
+ va_list v;
+
+ va_start (v, format);
+ line_error_internal (MSG_warning, 0, &e->source_info, format, v);
+}
+
+void
+command_error (const ELEMENT *e, const char *format, ...)
+{
+ va_list v;
+
+ va_start (v, format);
+ line_error_internal (MSG_error, 0, &e->source_info, format, v);
+}
+
+/* not used */
+void
+wipe_errors (void)
+{
+ wipe_error_message_list (&error_messages_list);
+}
+
+void
+forget_errors (void)
+{
+ memset (&error_messages_list, 0, sizeof (ERROR_MESSAGE_LIST));
+}
+
+static void
+bug_message_internal (char *format, va_list v)
+{
+ fprintf (stderr, "You found a bug: ");
+ vfprintf (stderr, format, v);
+ fprintf (stderr, "\n");
+ if (current_source_info.file_name)
+ {
+ fprintf (stderr,
+ "last location %s:%d", current_source_info.file_name,
+ current_source_info.line_nr);
+ if (current_source_info.macro)
+ fprintf (stderr, " (possibly involving @%s)",
current_source_info.macro);
+ fprintf (stderr, "\n");
+ }
+ exit (1);
+}
+
+void
+bug_message (char *format, ...)
+{
+ va_list v;
+
+ va_start (v, format);
+ bug_message_internal (format, v);
+}
+
diff --git a/tp/Texinfo/XS/parsetexi/errors_parser.h
b/tp/Texinfo/XS/parsetexi/errors_parser.h
new file mode 100644
index 0000000000..7ba06aa5c5
--- /dev/null
+++ b/tp/Texinfo/XS/parsetexi/errors_parser.h
@@ -0,0 +1,23 @@
+/* errors_parser.h - declarations for errors_parser.c */
+#ifndef PARSER_ERRORS_H
+#define PARSER_ERRORS_H
+
+#include <stdarg.h>
+
+#include "tree_types.h"
+#include "document_types.h"
+
+void line_error (const char *format, ...);
+void line_warn (const char *format, ...);
+void command_error (const ELEMENT *e, const char *format, ...);
+void command_warn (const ELEMENT *e, const char *format, ...);
+void wipe_errors (void);
+void forget_errors (void);
+void line_error_ext (enum error_type type, int continuation,
+ SOURCE_INFO *cmd_source_info, const char *format, ...);
+void bug_message (char *format, ...);
+
+extern ERROR_MESSAGE_LIST error_messages_list;
+extern SOURCE_INFO current_source_info;
+
+#endif
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 969e1e9a05..95cd49bc00 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -38,7 +38,7 @@
#include "commands.h"
#include "def.h"
#include "debug.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "tree.h"
#include "input.h"
#include "extra.h"
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index 0d53d8e6bb..f61ce45683 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -24,7 +24,7 @@
#include "options_types.h"
#include "document_types.h"
#include "tree.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "debug.h"
#include "command_stack.h"
#include "context_stack.h"
diff --git a/tp/Texinfo/XS/parsetexi/input.c b/tp/Texinfo/XS/parsetexi/input.c
index 32a7bfb19d..8d6c47e100 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -23,9 +23,9 @@
/* for global_info */
#include "parser.h"
-#include "utils.h"
/* for xasprintf and other */
-#include "errors.h"
+#include "utils.h"
+#include "errors_parser.h"
#include "debug.h"
#include "input.h"
#include "text.h"
diff --git a/tp/Texinfo/XS/parsetexi/labels.c b/tp/Texinfo/XS/parsetexi/labels.c
index f68a945cb5..7d0ec84e5e 100644
--- a/tp/Texinfo/XS/parsetexi/labels.c
+++ b/tp/Texinfo/XS/parsetexi/labels.c
@@ -23,7 +23,7 @@
#include "parser.h"
#include "tree_types.h"
#include "tree.h"
-#include "errors.h"
+#include "errors_parser.h"
/* for whitespace_chars and count_multibyte */
#include "utils.h"
/* for parse_node_manual */
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index c01e4bc248..9525e8492d 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -26,7 +26,7 @@
#include "tree_types.h"
#include "debug.h"
#include "debug_parser.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "text.h"
#include "counter.h"
#include "input.h"
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 8f16336d34..fc61e041fb 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -22,7 +22,7 @@
#include "tree.h"
#include "element_types.h"
#include "debug.h"
-#include "errors.h"
+#include "errors_parser.h"
/* for whitespace_chars */
#include "utils.h"
/* for parse_node_manual */
diff --git a/tp/Texinfo/XS/parsetexi/multitable.c
b/tp/Texinfo/XS/parsetexi/multitable.c
index 0e1cc87d04..f524984402 100644
--- a/tp/Texinfo/XS/parsetexi/multitable.c
+++ b/tp/Texinfo/XS/parsetexi/multitable.c
@@ -17,7 +17,7 @@
#include "tree_types.h"
#include "tree.h"
-#include "errors.h"
+#include "errors_parser.h"
/* for item_line_parent */
#include "utils.h"
#include "builtin_commands.h"
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index cdfd8559ee..8476dac976 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -31,7 +31,7 @@
#include "debug.h"
#include "debug_parser.h"
/* error_messages_list forget_errors ... */
-#include "errors.h"
+#include "errors_parser.h"
#include "text.h"
#include "counter.h"
#include "builtin_commands.h"
diff --git a/tp/Texinfo/XS/parsetexi/separator.c
b/tp/Texinfo/XS/parsetexi/separator.c
index 540fb9935c..a122d377fa 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -28,7 +28,7 @@
#include "builtin_commands.h"
#include "debug.h"
#include "debug_parser.h"
-#include "errors.h"
+#include "errors_parser.h"
#include "command_stack.h"
#include "context_stack.h"
/* for parse_node_manual */