[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/parsetexi/parser.c (set_restricte
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/XS/parsetexi/parser.c (set_restricted, global_restricted): New. * tp/Texinfo/XS/parsetexi/macro.c (new_macro): Do nothing if global_restricted is set. |
Date: |
Mon, 27 Nov 2023 14:20:56 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new be33963510 * tp/Texinfo/XS/parsetexi/parser.c (set_restricted,
global_restricted): New. * tp/Texinfo/XS/parsetexi/macro.c (new_macro): Do
nothing if global_restricted is set.
be33963510 is described below
commit be33963510b041753ce2ba860f9f66be87f40214
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Nov 27 19:20:48 2023 +0000
* tp/Texinfo/XS/parsetexi/parser.c (set_restricted, global_restricted):
New.
* tp/Texinfo/XS/parsetexi/macro.c (new_macro): Do nothing if
global_restricted is set.
* tp/Texinfo/XS/parsetexi/Parsetexi.xs,
* tp/Texinfo/XS/parsetexi/api.c (parser_set_restricted):
New function. Call set_restricted.
* tp/Texinfo/Common.pm (%parser_options): Add 'restricted'.
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (simple_parser):
Set 'restricted' flag.
(parser): If 'restricted' flag is set, call parser_set_restricted.
* tp/t/init_files_tests.t
(macro_defined_txiinternalvalue_in_translation): Re-add test,
to check what is done with this input and init file. From Patrice.
---
ChangeLog | 19 +++++++++++++++++++
tp/Makefile.tres | 1 +
tp/Texinfo/Common.pm | 1 +
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 11 ++++++++++-
tp/Texinfo/XS/parsetexi/Parsetexi.xs | 3 +++
tp/Texinfo/XS/parsetexi/api.c | 6 ++++++
tp/Texinfo/XS/parsetexi/api.h | 1 +
tp/Texinfo/XS/parsetexi/macro.c | 3 +++
tp/Texinfo/XS/parsetexi/parser.c | 9 ++++++++-
tp/Texinfo/XS/parsetexi/parser.h | 2 ++
tp/t/init_files_tests.t | 7 +++++++
11 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f9b7939785..f171343eb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2023-11-27 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XS/parsetexi/parser.c (set_restricted, global_restricted):
+ New.
+ * tp/Texinfo/XS/parsetexi/macro.c (new_macro): Do nothing if
+ global_restricted is set.
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.xs,
+ * tp/Texinfo/XS/parsetexi/api.c (parser_set_restricted):
+ New function. Call set_restricted.
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (simple_parser):
+ Set 'restricted' flag.
+ (parser): If 'restricted' flag is set, call parser_set_restricted.
+
+ * tp/t/init_files_tests.t
+ (macro_defined_txiinternalvalue_in_translation): Re-add test,
+ to check what is done with this input and init file. From Patrice.
+
2023-11-27 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/ParserNonXS.pm (_new_macro),
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 6fb559e2e1..d46f256d9c 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -988,6 +988,7 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/init_files_tests/customize_translations/res_html \
t/results/init_files_tests/documentation_examples.pl \
t/results/init_files_tests/documentation_examples/res_html \
+ t/results/init_files_tests/macro_defined_txiinternalvalue_in_translation.pl \
t/results/init_files_tests/modified_translation.pl \
t/results/init_files_tests/redefined_need.pl \
t/results/init_files_tests/sc_formatting_with_css.pl \
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 9467c49287..4e06b22294 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -206,6 +206,7 @@ my %parser_options = (
'IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME' => 1,
'CPP_LINE_DIRECTIVES' => 1, # handle cpp like synchronization lines
'MAX_MACRO_CALL_NESTING' => 100000, # max number of nested macro calls
+ 'restricted' => 0, # used in translations to disable some commands
);
# this serves both to set defaults and list customization variable
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 7e3d9fe23b..d850510f40 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -77,7 +77,14 @@ sub get_conf($$)
}
sub simple_parser {
- goto &parser;
+ my $conf = shift;
+
+ my $new_conf = {'restricted' => 1};
+ if ($conf) {
+ %$new_conf = (%$new_conf, %$conf);
+ }
+
+ return parser($new_conf);
}
# Initialize the parser
@@ -164,6 +171,8 @@ sub parser (;$$)
parser_set_locale_encoding ($utf8_bytes);
} elsif ($key eq 'accept_internalvalue' and $conf->{$key}) {
parser_set_accept_internalvalue(1);
+ } elsif ($key eq 'restricted' and $conf->{$key}) {
+ parser_set_restricted(1);
} elsif ($key eq 'registrar' or $key eq 'COMMAND_LINE_ENCODING') {
# no action needed, only used in perl code
} else {
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index dff91d6297..071b0f5380 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -153,3 +153,6 @@ parser_set_debug (int i)
void
parser_set_accept_internalvalue (int value)
+void
+parser_set_restricted (int value)
+
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 0e7c927c0d..9e56790398 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -267,3 +267,9 @@ parser_set_accept_internalvalue (int value)
{
set_accept_internalvalue (value);
}
+
+void
+parser_set_restricted (int value)
+{
+ set_restricted(value);
+}
diff --git a/tp/Texinfo/XS/parsetexi/api.h b/tp/Texinfo/XS/parsetexi/api.h
index 8fabdbf08e..7070cc02aa 100644
--- a/tp/Texinfo/XS/parsetexi/api.h
+++ b/tp/Texinfo/XS/parsetexi/api.h
@@ -18,6 +18,7 @@ void parser_add_include_directory (char *filename);
void parser_add_expanded_format (char *format);
void parser_clear_expanded_formats (void);
void parser_set_accept_internalvalue (int value);
+void parser_set_restricted (int value);
void parser_set_DOC_ENCODING_FOR_INPUT_FILE_NAME (int i);
void parser_set_input_file_name_encoding (char *value);
void parser_set_locale_encoding (char *value);
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 5e2a4387ac..c01e4bc248 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -69,6 +69,9 @@ new_macro (char *name, ELEMENT *macro)
MACRO *m = 0;
size_t free_slot = 0;
+ if (global_restricted)
+ return;
+
/* Check for an existing definition first for us to overwrite. */
new = lookup_command (name);
if (new)
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index b157937e58..cdfd8559ee 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -312,6 +312,7 @@ char *global_clickstyle = 0;
char *global_documentlanguage = 0;
int global_documentlanguage_fixed = 0;
int global_accept_internalvalue = 0;
+int global_restricted = 0;
enum kbd_enum global_kbdinputstyle = kbd_distinct;
@@ -336,11 +337,17 @@ set_documentlanguage_override (char *value)
void
-set_accept_internalvalue(int value)
+set_accept_internalvalue (int value)
{
global_accept_internalvalue = value;
}
+void
+set_restricted (int value)
+{
+ global_restricted = value;
+}
+
/* Record the information from a command of global effect. */
int
register_global_command (ELEMENT *current)
diff --git a/tp/Texinfo/XS/parsetexi/parser.h b/tp/Texinfo/XS/parsetexi/parser.h
index 873305ed49..568ea850f8 100644
--- a/tp/Texinfo/XS/parsetexi/parser.h
+++ b/tp/Texinfo/XS/parsetexi/parser.h
@@ -81,6 +81,7 @@ int parse_texi (ELEMENT *root_elt, ELEMENT *current_elt);
int parse_texi_document (void);
void set_documentlanguage_override (char *value);
void set_accept_internalvalue (int value);
+void set_restricted (int value);
void push_conditional_stack (enum command_id cond, SOURCE_MARK *source_mark);
CONDITIONAL_STACK_ITEM *pop_conditional_stack (void);
@@ -132,6 +133,7 @@ extern char *global_clickstyle;
extern char *global_documentlanguage;
extern int global_documentlanguage_fixed;
extern int global_accept_internalvalue;
+extern int global_restricted;
enum kbd_enum {kbd_none, kbd_code, kbd_example, kbd_distinct };
extern enum kbd_enum global_kbdinputstyle;
diff --git a/tp/t/init_files_tests.t b/tp/t/init_files_tests.t
index 0b1ae6e7e2..3e4276abd5 100644
--- a/tp/t/init_files_tests.t
+++ b/tp/t/init_files_tests.t
@@ -21,6 +21,13 @@ fr @error{}.
pt @error{}.
', {'init_files' => ['command_translation_modified.init']}],
+['macro_defined_txiinternalvalue_in_translation',
+'@sp 1
+
+@sp 2
+
+',{'init_files' => ['translate_txiinternalvalue_macro.init'],
+}],
);
my @file_tests = (