[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 3 Oct 2024 14:38:00 -0400 (EDT) |
branch: master
commit 7eb7bb95bd06afdf22ff5d67c438c29337371eb7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Aug 7 18:09:08 2024 +0200
* tp/Texinfo/XS/main/document.c (initialize_document_options): add
C function to initialize and set document options novalidate,
documentlanguage based on parser information and call
set_output_encoding, as is done in Perl.
---
ChangeLog | 7 +++++++
tp/Texinfo/XS/main/document.c | 27 +++++++++++++++++++++++++++
tp/Texinfo/XS/main/document.h | 2 ++
3 files changed, 36 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 201e262a92..090552ea35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-08-07 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/document.c (initialize_document_options): add
+ C function to initialize and set document options novalidate,
+ documentlanguage based on parser information and call
+ set_output_encoding, as is done in Perl.
+
2024-08-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/builtin_commands.c (ref_3_args_order)
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index d328ef51b0..79e5d67445 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -20,6 +20,7 @@
#include <string.h>
#include <stddef.h>
+#include "command_ids.h"
#include "tree_types.h"
#include "options_types.h"
#include "document_types.h"
@@ -122,6 +123,32 @@ register_document_options (DOCUMENT *document, OPTIONS
*options,
document->sorted_options = sorted_options;
}
+/* not used when document options are set from Perl */
+void
+initialize_document_options (DOCUMENT *document)
+{
+ OPTIONS *options = new_options ();
+ OPTION **sorted_options = setup_sorted_options (options);
+ const ELEMENT *document_language;
+
+ register_document_options (document, options, sorted_options);
+
+ if (document->global_commands.novalidate)
+ document->options->novalidate.o.integer = 1;
+
+ document_language
+ = get_global_document_command (&document->global_commands,
+ CM_documentlanguage, CL_preamble);
+ if (document_language)
+ {
+ const char *language = informative_command_value (document_language);
+ /* TODO use set_conf_string? or add set_conf in utils.h */
+ document->options->documentlanguage.o.string
+ = strdup (language);
+ }
+ set_output_encoding (document->options, document);
+}
+
const MERGED_INDICES *
document_merged_indices (DOCUMENT *document)
{
diff --git a/tp/Texinfo/XS/main/document.h b/tp/Texinfo/XS/main/document.h
index 1050d8e059..407f1f7805 100644
--- a/tp/Texinfo/XS/main/document.h
+++ b/tp/Texinfo/XS/main/document.h
@@ -23,6 +23,8 @@ void register_document_options (DOCUMENT *document, OPTIONS
*options,
void register_document_convert_index_text_options (DOCUMENT *document,
struct TEXT_OPTIONS *text_options);
+void initialize_document_options (DOCUMENT *document);
+
const MERGED_INDICES *document_merged_indices (DOCUMENT *document);
const INDICES_SORT_STRINGS *document_indices_sort_strings (
DOCUMENT *document,