[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 03:09:51 -0400 (EDT) |
branch: master
commit 0b38379951bf09db446838c9ef70b80408925466
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jun 7 21:53:33 2024 +0200
* tp/Texinfo/XS/main/element_types.awk,
tp/Texinfo/XS/main/element_types.txt, tp/Texinfo/XS/main/tree_types.h
(enum elt_info_type), tp/Texinfo/XS/main/types_data.h: add
spaces_before and spaces_after flags. Rearrange indices of element in
elt_info.
* tp/Texinfo/XS/structuring_transfo/transformations.c
(fill_gaps_in_sectioning): add the correct types to the created
command elements.
* tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi)
(convert_to_texinfo_internal): expand spaces_before_argument only in
elements which can have the info.
---
ChangeLog | 16 ++++++++++++++++
tp/TODO | 11 +++++++----
tp/Texinfo/XS/main/convert_to_texinfo.c | 20 ++++++++++++--------
tp/Texinfo/XS/main/element_types.awk | 20 ++++++++++----------
tp/Texinfo/XS/main/element_types.c | 20 ++++++++++----------
tp/Texinfo/XS/main/element_types.txt | 21 +++++++++++----------
tp/Texinfo/XS/main/tree_types.h | 8 ++++----
tp/Texinfo/XS/main/types_data.h | 2 ++
tp/Texinfo/XS/structuring_transfo/transformations.c | 10 +++++-----
9 files changed, 77 insertions(+), 51 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0a3406efe8..772ed0b865 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-06-07 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/element_types.awk,
+ tp/Texinfo/XS/main/element_types.txt, tp/Texinfo/XS/main/tree_types.h
+ (enum elt_info_type), tp/Texinfo/XS/main/types_data.h: add
+ spaces_before and spaces_after flags. Rearrange indices of element in
+ elt_info.
+
+ * tp/Texinfo/XS/structuring_transfo/transformations.c
+ (fill_gaps_in_sectioning): add the correct types to the created
+ command elements.
+
+ * tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi)
+ (convert_to_texinfo_internal): expand spaces_before_argument only in
+ elements which can have the info.
+
2024-06-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments),
diff --git a/tp/TODO b/tp/TODO
index 155129d125..a4d2a13da7 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -76,11 +76,14 @@ Gavin and Patrice
char *alias_of
char *command_info_string (for arg_line or command_name or @verb delimiter)
ELEMENT *elements[3]
- spaces_after_cmd_before_arg (brace commands) or comment_at_end (line/block
commands args)
-for type brace_arg, line and block commands, BRACE_context commands
- bracketed_arg line_arg (after comma or in linemacro_call) ET_linemacro_call
+brace commands
+ spaces_after_cmd_before_arg
+line/block commands args
+ comment_at_end
+for type brace_arg, line (not lineraw) and block commands, BRACE_context
commands
+ bracketed_arg line_arg (after comma or in linemacro_call) block_line_arg
(after comma) ET_linemacro_call
spaces_before_argument
-line/block commands args brace_arg
+line/block commands args brace_arg bracketed_arg
spaces_after_argument
3) make building "source marks" optional.
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index 6053e6fe05..e3ddf93d99 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -48,7 +48,8 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
{
enum command_id cmd = element_builtin_cmd (e);
char *arg_line;
- ELEMENT *elt, *spc_before_arg;
+ ELEMENT *elt;
+ ELEMENT *spc_before_arg = 0;
if (cmd)
{
@@ -63,7 +64,8 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
ADD((char *)elt->text->text);
}
- spc_before_arg = lookup_info_element (e, "spaces_before_argument");
+ if (type_data[e->type].flags & TF_spaces_before)
+ spc_before_arg = lookup_info_element (e, "spaces_before_argument");
arg_line = lookup_info_string (e, "arg_line");
if (arg_line)
@@ -157,10 +159,11 @@ convert_to_texinfo_internal (const ELEMENT *e, TEXT
*result)
if (e->type == ET_bracketed_arg
|| e->type == ET_bracketed_linemacro_arg)
ADD("{");
- elt = lookup_info_element (e, "spaces_before_argument");
- if (elt)
+ if (type_data[e->type].flags & TF_spaces_before)
{
- ADD((char *)elt->text->text);
+ elt = lookup_info_element (e, "spaces_before_argument");
+ if (elt)
+ ADD((char *)elt->text->text);
}
}
if (e->c->contents.number > 0)
@@ -170,10 +173,11 @@ convert_to_texinfo_internal (const ELEMENT *e, TEXT
*result)
convert_to_texinfo_internal (e->c->contents.list[i], result);
}
- elt = lookup_info_element (e, "spaces_after_argument");
- if (elt)
+ if (type_data[e->type].flags & TF_spaces_after)
{
- ADD((char *)elt->text->text);
+ elt = lookup_info_element (e, "spaces_after_argument");
+ if (elt)
+ ADD((char *)elt->text->text);
}
if (e->type == ET_block_line_arg || e->type == ET_line_arg)
diff --git a/tp/Texinfo/XS/main/element_types.awk
b/tp/Texinfo/XS/main/element_types.awk
index b6acfd795c..dc4c605fa1 100644
--- a/tp/Texinfo/XS/main/element_types.awk
+++ b/tp/Texinfo/XS/main/element_types.awk
@@ -63,16 +63,16 @@ END {
if (type_flags[t] != "" && match(type_flags[t], /braces/)) {
elt_info_number = 1;
}
- # line_command: spaces_before_argument
- # block_command: spaces_before_argument
- if (t == "block_command" || t == "line_command" ) {
- elt_info_number = 1;
- # block_line_arg and line_arg: comment_at_end, spaces_after_argument
- } else if (t == "brace_arg" || t == "bracketed_arg" \
- || t == "block_line_arg" || t == "line_arg") {
- elt_info_number = 2;
- } else if (t == "context_brace_command") {
- elt_info_number += 2;
+ if (type_flags[t] != "" && match(type_flags[t], /spaces_before/)) {
+ elt_info_number += 1;
+ }
+ # spaces_after_argument
+ if (type_flags[t] != "" && match(type_flags[t], /spaces_after/)) {
+ elt_info_number += 1;
+ }
+ # comment_at_end
+ if (t == "block_line_arg" || t == "line_arg") {
+ elt_info_number += 1;
}
if (type_flags[t] != "") {
split(type_flags[t], flags_array, ",")
diff --git a/tp/Texinfo/XS/main/element_types.c
b/tp/Texinfo/XS/main/element_types.c
index 2327ea7752..b83eee161d 100644
--- a/tp/Texinfo/XS/main/element_types.c
+++ b/tp/Texinfo/XS/main/element_types.c
@@ -4,17 +4,17 @@
TYPE_DATA type_data[] = {
0, 0, 0,
-"index_entry_command", 0, 0,
+"index_entry_command", TF_spaces_before, 1,
"definfoenclose_command", TF_braces, 1,
"nobrace_command", 0, 0,
"brace_noarg_command", TF_braces, 1,
"container_command", 0, 0,
"lineraw_command", 0, 0,
-"line_command", 0, 1,
-"block_command", 0, 1,
+"line_command", TF_spaces_before, 1,
+"block_command", TF_spaces_before, 1,
"brace_command", TF_braces, 1,
"brace_args_command", TF_braces, 1,
-"context_brace_command", TF_braces, 3,
+"context_brace_command", TF_braces | TF_spaces_before, 2,
"empty_line", TF_text, 0,
"raw", TF_text, 0,
"ignorable_spaces_after_command", TF_text, 0,
@@ -40,9 +40,9 @@ TYPE_DATA type_data[] = {
"rawpreformatted", 0, 0,
"brace_container", 0, 0,
"brace_command_context", 0, 0,
-"brace_arg", 0, 2,
-"block_line_arg", 0, 2,
-"line_arg", 0, 2,
+"brace_arg", TF_spaces_before | TF_spaces_after, 2,
+"block_line_arg", TF_spaces_before | TF_spaces_after, 3,
+"line_arg", TF_spaces_before | TF_spaces_after, 3,
"following_arg", 0, 0,
"rawline_arg", TF_text, 0,
"menu_entry", 0, 0,
@@ -64,7 +64,7 @@ TYPE_DATA type_data[] = {
"table_term", 0, 0,
"table_definition", 0, 0,
"inter_item", 0, 0,
-"def_line", 0, 0,
+"def_line", TF_spaces_before, 1,
"def_item", 0, 0,
"inter_def_item", 0, 0,
"before_defline", 0, 0,
@@ -72,7 +72,7 @@ TYPE_DATA type_data[] = {
"multitable_body", 0, 0,
"row", 0, 0,
"balanced_braces", 0, 0,
-"bracketed_arg", 0, 2,
+"bracketed_arg", TF_spaces_before | TF_spaces_after, 2,
"def_line_arg", 0, 0,
"untranslated_def_line_arg", 0, 0,
"def_category", 0, 0,
@@ -88,7 +88,7 @@ TYPE_DATA type_data[] = {
"elided_brace_command_arg", 0, 0,
"macro_call", TF_braces, 1,
"rmacro_call", TF_braces, 1,
-"linemacro_call", 0, 0,
+"linemacro_call", TF_spaces_before, 1,
"bracketed_linemacro_arg", TF_text, 0,
"text", 0, 0,
"_code", 0, 0,
diff --git a/tp/Texinfo/XS/main/element_types.txt
b/tp/Texinfo/XS/main/element_types.txt
index faba8513e6..bc8cdde9f3 100644
--- a/tp/Texinfo/XS/main/element_types.txt
+++ b/tp/Texinfo/XS/main/element_types.txt
@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Types for @-commands
-index_entry_command
+index_entry_command spaces_before
definfoenclose_command braces
# only in C
@@ -25,11 +25,11 @@ brace_noarg_command braces
# @item, @tab
container_command
lineraw_command
-line_command
-block_command
+line_command spaces_before
+block_command spaces_before
brace_command braces
brace_args_command braces
-context_brace_command braces
+context_brace_command braces,spaces_before
# For text elements
empty_line text
@@ -64,9 +64,10 @@ rawpreformatted
brace_container
brace_command_context
# with separate leading spaces in info, and trailing (if not in inline)
-brace_arg
-block_line_arg
-line_arg
+brace_arg spaces_before,spaces_after
+# with comment_at_end
+block_line_arg spaces_before,spaces_after
+line_arg spaces_before,spaces_after
following_arg
rawline_arg text
@@ -95,7 +96,7 @@ table_entry
table_term
table_definition
inter_item
-def_line
+def_line spaces_before
def_item
inter_def_item
before_defline
@@ -104,7 +105,7 @@ multitable_body
row
balanced_braces
-bracketed_arg
+bracketed_arg spaces_before,spaces_after
# container of definition line argument content
def_line_arg
@@ -134,7 +135,7 @@ elided_brace_command_arg
# for macro expansion source marks
macro_call braces
rmacro_call braces
-linemacro_call
+linemacro_call spaces_before
bracketed_linemacro_arg text
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 4c802fa263..37994a3715 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -220,11 +220,11 @@ typedef struct CONTAINER {
/* indices in ELEMENT elt_info */
enum elt_info_type {
eit_spaces_after_cmd_before_arg, /* types with braces flag */
- eit_comment_at_end = 0,
- eit_types_spaces_before_argument = 0,
- eit_spaces_before_argument,
- eit_types_spaces_after_argument = 1,
+ eit_spaces_before_argument = 0, /* diverse types. Only context_brace_command
+ also with braces */
+ eit_comment_at_end = 1, /* block_line_arg line_arg */
eit_spaces_after_argument,
+ eit_brace_content_spaces_before_argument = 1, /* not 0, also brace commands
*/
};
/* indices in ELEMENT string_info */
diff --git a/tp/Texinfo/XS/main/types_data.h b/tp/Texinfo/XS/main/types_data.h
index 3c5abbd4f4..93317d3dd4 100644
--- a/tp/Texinfo/XS/main/types_data.h
+++ b/tp/Texinfo/XS/main/types_data.h
@@ -28,5 +28,7 @@ extern TYPE_DATA type_data[];
#define TF_text 0x0001
#define TF_braces 0x0002
+#define TF_spaces_before 0x0004
+#define TF_spaces_after 0x0008
#endif
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index febec05ec6..f7e2e2bc46 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -242,7 +242,7 @@ fill_gaps_in_sectioning (ELEMENT *root, ELEMENT
*commands_heading_content)
while (next_section_level - current_section_level > 1)
{
ELEMENT *line_content;
- ELEMENT *new_section = new_element (ET_NONE);
+ ELEMENT *new_section;
ELEMENT *spaces_before_argument
= new_text_element (ET_other_text);
ELEMENT *line_arg = new_element (ET_line_arg);
@@ -250,9 +250,9 @@ fill_gaps_in_sectioning (ELEMENT *root, ELEMENT
*commands_heading_content)
ELEMENT *empty_line = new_text_element (ET_empty_line);
current_section_level++;
- new_section->cmd
- = level_to_structuring_command[CM_unnumbered][current_section_level];
- new_section->parent = root;
+ new_section = new_command_element (ET_line_command,
+ level_to_structuring_command[CM_unnumbered][current_section_level]);
+
text_append (spaces_before_argument->text, " ");
add_info_element_oot (new_section, "spaces_before_argument",
@@ -266,7 +266,7 @@ fill_gaps_in_sectioning (ELEMENT *root, ELEMENT
*commands_heading_content)
if (commands_heading_content)
{
line_content = copy_contents (commands_heading_content,
- ET_NONE);
+
commands_heading_content->type);
}
else
{