[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/debug.c (debug_protect_eol):
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/debug.c (debug_protect_eol): add handling of NULL string. |
Date: |
Tue, 12 Dec 2023 13:49:15 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new cbeb65df96 * tp/Texinfo/XS/main/debug.c (debug_protect_eol): add
handling of NULL string.
cbeb65df96 is described below
commit cbeb65df9621d585de443df9dd352c22ff2e122b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Dec 12 19:49:09 2023 +0100
* tp/Texinfo/XS/main/debug.c (debug_protect_eol): add handling of NULL
string.
* tp/Texinfo/XS/main/translations.c (replace_convert_substrings): add
OPTIONS argument, and use that argument and document error messages
information for translations and debug messages, to avoid using
internal parser data. Update callers.
* tp/Texinfo/XS/main/debug.c, tp/Texinfo/XS/parsetexi/debug_parser.c:
move all the functions that depend on debug_output internal parser
value from debug.c to debug_parser.c, corresponding to
set_debug_output, debug, debug_nonl, debug_print_element and
debug_print_protected_string.
---
ChangeLog | 16 +++++++
tp/Texinfo/XS/convert/convert_html.c | 3 +-
tp/Texinfo/XS/main/debug.c | 69 ++++---------------------------
tp/Texinfo/XS/main/debug.h | 7 ----
tp/Texinfo/XS/main/translations.c | 23 +++++++----
tp/Texinfo/XS/main/translations.h | 4 +-
tp/Texinfo/XS/parsetexi/api.c | 2 +-
tp/Texinfo/XS/parsetexi/close.c | 1 -
tp/Texinfo/XS/parsetexi/context_stack.c | 2 +-
tp/Texinfo/XS/parsetexi/debug_parser.c | 59 ++++++++++++++++++++++++++
tp/Texinfo/XS/parsetexi/debug_parser.h | 8 ++++
tp/Texinfo/XS/parsetexi/def.c | 6 ---
tp/Texinfo/XS/parsetexi/end_line.c | 1 -
tp/Texinfo/XS/parsetexi/errors_parser.c | 2 +-
tp/Texinfo/XS/parsetexi/handle_commands.c | 2 +-
tp/Texinfo/XS/parsetexi/indices.c | 7 +---
tp/Texinfo/XS/parsetexi/input.c | 2 +-
tp/Texinfo/XS/parsetexi/macro.c | 1 -
tp/Texinfo/XS/parsetexi/menus.c | 2 +-
tp/Texinfo/XS/parsetexi/parser.c | 1 -
tp/Texinfo/XS/parsetexi/separator.c | 1 -
tp/Texinfo/XS/parsetexi/source_marks.c | 1 -
22 files changed, 117 insertions(+), 103 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 79bbe163a9..880c57d9b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2023-12-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/debug.c (debug_protect_eol): add handling of NULL
+ string.
+
+ * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): add
+ OPTIONS argument, and use that argument and document error messages
+ information for translations and debug messages, to avoid using
+ internal parser data. Update callers.
+
+ * tp/Texinfo/XS/main/debug.c, tp/Texinfo/XS/parsetexi/debug_parser.c:
+ move all the functions that depend on debug_output internal parser
+ value from debug.c to debug_parser.c, corresponding to
+ set_debug_output, debug, debug_nonl, debug_print_element and
+ debug_print_protected_string.
+
2023-12-12 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES),
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index c9ac3b2dc8..8b668f4fcd 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -481,7 +481,8 @@ html_gdt (const char *string, CONVERTER *self,
in_lang);
int document_descriptor
- = replace_convert_substrings (translated_string, replaced_substrings);
+ = replace_convert_substrings (self->conf, translated_string,
+ replaced_substrings);
free (translated_string);
return document_descriptor;
}
diff --git a/tp/Texinfo/XS/main/debug.c b/tp/Texinfo/XS/main/debug.c
index f466b2b2db..7198b5462c 100644
--- a/tp/Texinfo/XS/main/debug.c
+++ b/tp/Texinfo/XS/main/debug.c
@@ -26,38 +26,6 @@
#include "extra.h"
#include "debug.h"
-/* Whether to dump debugging output on stderr. */
-int debug_output = 0;
-
-void
-set_debug_output (int value)
-{
- debug_output = value;
-}
-
-void
-debug (char *s, ...)
-{
- va_list v;
-
- if (!debug_output)
- return;
- va_start (v, s);
- vfprintf (stderr, s, v);
- fputc ('\n', stderr);
-}
-
-void
-debug_nonl (char *s, ...)
-{
- va_list v;
-
- if (!debug_output)
- return;
- va_start (v, s);
- vfprintf (stderr, s, v);
-}
-
char *
debug_element_command_name (const ELEMENT *e)
{
@@ -72,9 +40,15 @@ debug_element_command_name (const ELEMENT *e)
char *
debug_protect_eol (char *input_string, int *allocated)
{
- char *end_of_line = strchr (input_string, '\n');
+ char *end_of_line;
char *protected_string = input_string;
*allocated = 0;
+
+ if (!input_string)
+ return "[NULL]";
+
+ end_of_line = strchr (input_string, '\n');
+
if (end_of_line) {
char *p;
protected_string = malloc ((strlen(input_string) + 2) * sizeof(char));
@@ -250,32 +224,3 @@ print_element_debug_details (const ELEMENT *e, int
print_parent)
return result;
}
-void
-debug_print_element (const ELEMENT *e, int print_parent)
-{
- if (debug_output)
- {
- char *result;
- result = print_element_debug (e, print_parent);
- fputs (result, stderr);
- free (result);
- }
-}
-
-void
-debug_print_protected_string (char *input_string)
-{
- if (debug_output)
- {
- int allocated = 0;
- char *result;
- if (!input_string)
- result = "[NULL]";
- else
- result = debug_protect_eol (input_string, &allocated);
- fputs (result, stderr);
- if (allocated)
- free (result);
- }
-}
-
diff --git a/tp/Texinfo/XS/main/debug.h b/tp/Texinfo/XS/main/debug.h
index 56e45b8937..b16b520377 100644
--- a/tp/Texinfo/XS/main/debug.h
+++ b/tp/Texinfo/XS/main/debug.h
@@ -7,15 +7,8 @@
#include "tree_types.h"
-extern int debug_output;
-
-void debug (char *s, ...);
-void debug_nonl (char *s, ...);
-void set_debug_output (int value);
-void debug_print_element (const ELEMENT *e, int print_parent);
char *print_element_debug (const ELEMENT *e, int print_parent);
char *print_element_debug_details (const ELEMENT *e, int print_parent);
-void debug_print_protected_string (char *input_string);
char *debug_protect_eol (char *input_string, int *allocated);
#endif
diff --git a/tp/Texinfo/XS/main/translations.c
b/tp/Texinfo/XS/main/translations.c
index 08c1e54050..0fc142687a 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -445,7 +445,7 @@ substitute (ELEMENT *tree, NAMED_STRING_ELEMENT_LIST
*replaced_substrings)
/* the caller should have made sure that the
inserted elements do not appear elsewhere in the tree. */
int
-replace_convert_substrings (char *translated_string,
+replace_convert_substrings (OPTIONS *options, char *translated_string,
NAMED_STRING_ELEMENT_LIST *replaced_substrings)
{
int i;
@@ -506,22 +506,30 @@ replace_convert_substrings (char *translated_string,
*/
document_descriptor = parse_string (texinfo_line, 1);
+ /* FIXME if called from parser through complete_indices, options will
+ not be set, but debug() would do the right thing. debug() is not
+ right in general, though, as it uses parser internal data */
+ /*
debug ("IN TR PARSER '%s'", texinfo_line);
+ */
+ if (options && options->DEBUG > 0)
+ fprintf (stderr, "IN TR PARSER '%s'", texinfo_line);
- if (error_messages_list.number > 0)
+ document = retrieve_document (document_descriptor);
+ if (document->error_messages->number > 0)
{
+ ERROR_MESSAGE_LIST *error_messages = document->error_messages;
fprintf (stderr, "translation %zu error(s)\n",
- error_messages_list.number);
+ error_messages->number);
fprintf (stderr, "translated string: %s\n", translated_string);
fprintf (stderr, "Error messages: \n");
- for (i = 0; i < error_messages_list.number; i++)
- fprintf (stderr, "%s", error_messages_list.list[i].error_line);
+ for (i = 0; i < error_messages->number; i++)
+ fprintf (stderr, "%s", error_messages->list[i].error_line);
}
clear_document_errors (document_descriptor);
parser_set_accept_internalvalue (0);
- document = retrieve_document (document_descriptor);
if (replaced_substrings)
{
ELEMENT *result_tree = substitute (document->tree, replaced_substrings);
@@ -551,7 +559,8 @@ gdt (const char *string, OPTIONS *options,
in_lang);
int document_descriptor
- = replace_convert_substrings (translated_string, replaced_substrings);
+ = replace_convert_substrings (options, translated_string,
+ replaced_substrings);
free (translated_string);
return document_descriptor;
}
diff --git a/tp/Texinfo/XS/main/translations.h
b/tp/Texinfo/XS/main/translations.h
index b1b50e7a3a..9a688e1863 100644
--- a/tp/Texinfo/XS/main/translations.h
+++ b/tp/Texinfo/XS/main/translations.h
@@ -25,8 +25,8 @@ void translations_configure (char *localesdir, char
*strings_textdomain_in);
char *translate_string (OPTIONS *options, const char * string,
const char *translation_context, const char *in_lang);
-int replace_convert_substrings (char *translated_string,
- NAMED_STRING_ELEMENT_LIST *replaced_substrings);
+int replace_convert_substrings (OPTIONS *options, char *translated_string,
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings);
char *replace_substrings (const char *string,
const NAMED_STRING_ELEMENT_LIST *replaced_substrings);
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index bf3d503385..2868abbc6b 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -25,7 +25,7 @@
#include "tree_types.h"
#include "parser.h"
/* for set_debug_output */
-#include "debug.h"
+#include "debug_parser.h"
/* reset_obstacks */
#include "tree.h"
/* wipe_index_names */
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index d979161c31..b99dbd93ad 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -22,7 +22,6 @@
#include "element_types.h"
#include "tree_types.h"
#include "def.h"
-#include "debug.h"
#include "debug_parser.h"
#include "errors_parser.h"
#include "counter.h"
diff --git a/tp/Texinfo/XS/parsetexi/context_stack.c
b/tp/Texinfo/XS/parsetexi/context_stack.c
index 363d2630b4..0a1c566609 100644
--- a/tp/Texinfo/XS/parsetexi/context_stack.c
+++ b/tp/Texinfo/XS/parsetexi/context_stack.c
@@ -20,7 +20,7 @@
#include "command_ids.h"
#include "utils.h"
#include "commands.h"
-#include "debug.h"
+#include "debug_parser.h"
#include "command_stack.h"
#include "context_stack.h"
diff --git a/tp/Texinfo/XS/parsetexi/debug_parser.c
b/tp/Texinfo/XS/parsetexi/debug_parser.c
index 45300d028c..6f915aba1e 100644
--- a/tp/Texinfo/XS/parsetexi/debug_parser.c
+++ b/tp/Texinfo/XS/parsetexi/debug_parser.c
@@ -24,6 +24,65 @@
#include "debug.h"
#include "debug_parser.h"
+/* Whether to dump debugging output on stderr. */
+int debug_output = 0;
+
+void
+set_debug_output (int value)
+{
+ debug_output = value;
+}
+
+/* debug functions used in parser, depending on debug_output */
+
+void
+debug (char *s, ...)
+{
+ va_list v;
+
+ if (!debug_output)
+ return;
+ va_start (v, s);
+ vfprintf (stderr, s, v);
+ fputc ('\n', stderr);
+}
+
+void
+debug_nonl (char *s, ...)
+{
+ va_list v;
+
+ if (!debug_output)
+ return;
+ va_start (v, s);
+ vfprintf (stderr, s, v);
+}
+
+void
+debug_print_element (const ELEMENT *e, int print_parent)
+{
+ if (debug_output)
+ {
+ char *result;
+ result = print_element_debug (e, print_parent);
+ fputs (result, stderr);
+ free (result);
+ }
+}
+
+void
+debug_print_protected_string (char *input_string)
+{
+ if (debug_output)
+ {
+ int allocated = 0;
+ char *result = debug_protect_eol (input_string, &allocated);
+ fputs (result, stderr);
+ if (allocated)
+ free (result);
+ }
+}
+
/* Here use command_name to get command names, using information on
user-defined commands. To be used in parser.
diff --git a/tp/Texinfo/XS/parsetexi/debug_parser.h
b/tp/Texinfo/XS/parsetexi/debug_parser.h
index 03063299a5..df26271d78 100644
--- a/tp/Texinfo/XS/parsetexi/debug_parser.h
+++ b/tp/Texinfo/XS/parsetexi/debug_parser.h
@@ -4,6 +4,14 @@
#include "tree_types.h"
+extern int debug_output;
+
+void debug (char *s, ...);
+void debug_nonl (char *s, ...);
+void set_debug_output (int value);
+void debug_print_element (const ELEMENT *e, int print_parent);
+void debug_print_protected_string (char *input_string);
+
char *print_element_debug_parser (ELEMENT *e, int print_parent);
char *debug_parser_command_name (enum command_id cmd);
void debug_parser_print_element (ELEMENT *e, int print_parent);
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index bad886a628..4a0d90640f 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -33,13 +33,7 @@
/* for relocate_source_marks */
#include "manipulate_tree.h"
#include "source_marks.h"
-/*
-#include "errors.h"
-*/
#include "commands.h"
-/*
-#include "debug.h"
-*/
void
gather_def_item (ELEMENT *current, enum command_id next_command)
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index fc9ca293ff..f496e5d37a 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -25,7 +25,6 @@
#include "text.h"
#include "tree.h"
#include "debug_parser.h"
-#include "debug.h"
#include "errors_parser.h"
/* for isascii_alnum whitespace_chars read_flag_name
indices_info_index_by_name ultimate_index fatal */
diff --git a/tp/Texinfo/XS/parsetexi/errors_parser.c
b/tp/Texinfo/XS/parsetexi/errors_parser.c
index 73897e66f3..3484b9e861 100644
--- a/tp/Texinfo/XS/parsetexi/errors_parser.c
+++ b/tp/Texinfo/XS/parsetexi/errors_parser.c
@@ -29,7 +29,7 @@
#include "tree_types.h"
#include "document_types.h"
/* for debug_output */
-#include "debug.h"
+#include "debug_parser.h"
#include "errors.h"
#include "errors_parser.h"
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 95cd49bc00..c081d6b580 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -37,7 +37,7 @@
#include "builtin_commands.h"
#include "commands.h"
#include "def.h"
-#include "debug.h"
+#include "debug_parser.h"
#include "errors_parser.h"
#include "tree.h"
#include "input.h"
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index f61ce45683..b31653f97c 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -25,7 +25,6 @@
#include "document_types.h"
#include "tree.h"
#include "errors_parser.h"
-#include "debug.h"
#include "command_stack.h"
#include "context_stack.h"
#include "builtin_commands.h"
@@ -433,11 +432,7 @@ complete_indices (int document_descriptor)
break;
}
}
- /*
- fprintf (stderr, "DEF IDX NAME CLASS '%s' '%s' \n",
- print_element_debug(name, 0),
- print_element_debug(class, 0));
- */
+
if (name && class)
{
char *lang = lookup_extra_string (main_entry_element,
diff --git a/tp/Texinfo/XS/parsetexi/input.c b/tp/Texinfo/XS/parsetexi/input.c
index 8d6c47e100..f37e92ffe7 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -26,7 +26,7 @@
/* for xasprintf and other */
#include "utils.h"
#include "errors_parser.h"
-#include "debug.h"
+#include "debug_parser.h"
#include "input.h"
#include "text.h"
#include "commands.h"
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 9525e8492d..f9c5423609 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -24,7 +24,6 @@
#include "utils.h"
#include "tree.h"
#include "tree_types.h"
-#include "debug.h"
#include "debug_parser.h"
#include "errors_parser.h"
#include "text.h"
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index fc61e041fb..9c560dad08 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -21,7 +21,7 @@
#include "tree_types.h"
#include "tree.h"
#include "element_types.h"
-#include "debug.h"
+#include "debug_parser.h"
#include "errors_parser.h"
/* for whitespace_chars */
#include "utils.h"
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 8476dac976..86cdf1fefa 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -28,7 +28,6 @@
#include "utils.h"
/* for relocate_source_marks */
#include "manipulate_tree.h"
-#include "debug.h"
#include "debug_parser.h"
/* error_messages_list forget_errors ... */
#include "errors_parser.h"
diff --git a/tp/Texinfo/XS/parsetexi/separator.c
b/tp/Texinfo/XS/parsetexi/separator.c
index a122d377fa..06cd9ca829 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -26,7 +26,6 @@
#include "counter.h"
/* for command_name and others */
#include "builtin_commands.h"
-#include "debug.h"
#include "debug_parser.h"
#include "errors_parser.h"
#include "command_stack.h"
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.c
b/tp/Texinfo/XS/parsetexi/source_marks.c
index 544065080d..fb3220bbd3 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.c
+++ b/tp/Texinfo/XS/parsetexi/source_marks.c
@@ -19,7 +19,6 @@
#include "tree_types.h"
#include "tree.h"
-#include "debug.h"
#include "debug_parser.h"
/* for count_multibyte and other */
#include "utils.h"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/debug.c (debug_protect_eol): add handling of NULL string.,
Patrice Dumas <=