[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Merge special command line data type into lineraw
From: |
Patrice Dumas |
Subject: |
branch master updated: Merge special command line data type into lineraw |
Date: |
Sun, 05 Mar 2023 06:26:47 -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 9cb60404f5 Merge special command line data type into lineraw
9cb60404f5 is described below
commit 9cb60404f5fb8283c96c757d8be9147a192345ab
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 5 12:26:37 2023 +0100
Merge special command line data type into lineraw
* tp/Texinfo/Common.pm (_informative_command_value),
tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
tp/Texinfo/ParserNonXS.pm(_handle_line_command)
(_parse_rawline_command), tp/Texinfo/XS/parsetexi/end_line.c
(parse_rawline_command), tp/Texinfo/XS/parsetexi/handle_commands.c
(handle_line_command), tp/Texinfo/command_data.txt: merge LINE_special
commands in LINE_lineraw, with arguments. Rename
parse_special_misc_command as parse_rawline_command and have the
function return the information on whether the command had special
args.
---
ChangeLog | 15 +++++++++++++++
tp/Texinfo/Common.pm | 8 +++-----
tp/Texinfo/Convert/TexinfoMarkup.pm | 14 ++++++--------
tp/Texinfo/ParserNonXS.pm | 31 +++++++++++++++----------------
tp/Texinfo/XS/parsetexi/commands.h | 9 ++++-----
tp/Texinfo/XS/parsetexi/end_line.c | 10 +++++++---
tp/Texinfo/XS/parsetexi/handle_commands.c | 28 ++++++++++------------------
tp/Texinfo/XS/parsetexi/parser.h | 4 ++--
tp/Texinfo/command_data.txt | 31 +++++++++++++++----------------
9 files changed, 77 insertions(+), 73 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 245f3a1295..db53c75051 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-03-05 Patrice Dumas <pertusus@free.fr>
+
+ Merge special command line data type into lineraw
+
+ * tp/Texinfo/Common.pm (_informative_command_value),
+ tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
+ tp/Texinfo/ParserNonXS.pm(_handle_line_command)
+ (_parse_rawline_command), tp/Texinfo/XS/parsetexi/end_line.c
+ (parse_rawline_command), tp/Texinfo/XS/parsetexi/handle_commands.c
+ (handle_line_command), tp/Texinfo/command_data.txt: merge LINE_special
+ commands in LINE_lineraw, with arguments. Rename
+ parse_special_misc_command as parse_rawline_command and have the
+ function return the information on whether the command had special
+ args.
+
2023-03-05 Patrice Dumas <pertusus@free.fr>
* tp/t/02coverage.t, tp/Makefile.am (test_files), tp/Makefile.tres:
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index da0cb4b267..47bb2ee103 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1311,13 +1311,11 @@ sub _informative_command_value($)
my $cmdname = $element->{'cmdname'};
- if ($Texinfo::Commands::line_commands{$cmdname} eq 'lineraw'
- or $Texinfo::Commands::line_commands{$cmdname} eq 'special') {
- if ($Texinfo::Commands::line_commands{$cmdname} eq 'lineraw'
- and not $Texinfo::Commands::commands_args_number{$cmdname}) {
+ if ($Texinfo::Commands::line_commands{$cmdname} eq 'lineraw') {
+ if (not $Texinfo::Commands::commands_args_number{$cmdname}) {
return 1;
} elsif ($element->{'args'}) {
- return $element->{'args'}->[0]->{'text'};
+ return join(' ', map {$_->{'text'}} @{$element->{'args'}});
}
} elsif ($element->{'extra'}
and exists($element->{'extra'}->{'text_arg'})) {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index b893ceaa11..b892955fcc 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -900,8 +900,11 @@ sub _convert($$;$)
.$arg.$end_space
.$self->txi_markup_close_element($cmdname).$end_line;
}
- } elsif ($type eq 'special') {
- if ($cmdname eq 'clear' or $cmdname eq 'set') {
+ } elsif ($type eq 'lineraw') {
+ if ($cmdname eq 'c' or $cmdname eq 'comment') {
+ return $self->txi_markup_comment(
+ " $cmdname".$element->{'args'}->[0]->{'text'})
+ } elsif ($cmdname eq 'clear' or $cmdname eq 'set') {
my $attribute = [];
if ($element->{'args'} and $element->{'args'}->[0]
and defined($element->{'args'}->[0]->{'text'})) {
@@ -930,7 +933,7 @@ sub _convert($$;$)
};
return $self->txi_markup_open_element($cmdname, $attribute)
.$value.$self->txi_markup_close_element($cmdname)."\n";
- } else {
+ } elsif ($cmdname eq 'unmacro') {
# should only be unmacro
my $attribute = [$self->_arg_line($element)];
if ($element->{'args'} and $element->{'args'}->[0]
@@ -939,11 +942,6 @@ sub _convert($$;$)
}
return $self->txi_markup_open_element($cmdname, $attribute)
.$self->txi_markup_close_element($cmdname)."\n";
- }
- } elsif ($type eq 'lineraw') {
- if ($cmdname eq 'c' or $cmdname eq 'comment') {
- return $self->txi_markup_comment(
- " $cmdname".$element->{'args'}->[0]->{'text'})
} elsif ($Texinfo::Commands::commands_args_number{$cmdname}) {
my $value = '';
if ($element->{'args'} and $element->{'args'}->[0]
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 977eb95052..afb6ac21f1 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -5109,7 +5109,7 @@ sub _handle_line_command($$$$$$)
my $command_e;
# all the cases using the raw line
- if ($arg_spec eq 'lineraw' or $arg_spec eq 'special') {
+ if ($arg_spec eq 'lineraw') {
my $ignored = 0;
if ($command eq 'insertcopying') {
my $parent = $current;
@@ -5142,16 +5142,12 @@ sub _handle_line_command($$$$$$)
}
$command_e = {'cmdname' => $command,
'parent' => $current};
- my $args = [];
- my $has_comment;
- if ($arg_spec eq 'lineraw') {
- $args = [ $line ];
- } elsif ($arg_spec eq 'special') {
- ($args, $has_comment)
- = _parse_special_misc_command($self, $line, $command, $source_info);
- $command_e->{'info'} = {'arg_line' => $line};
- # FIXME add a check on @clickstyle argument at that point?
- }
+
+ my ($args, $has_comment, $special_arg)
+ = _parse_rawline_command($self, $line, $command, $source_info);
+ $command_e->{'info'} = {'arg_line' => $line}
+ if ($special_arg);
+ # FIXME add a check on @clickstyle argument at that point?
# if using the @set txi* instead of a proper @-command, replace
# by the tree obtained with the @-command. Even though
@@ -6965,15 +6961,17 @@ sub _parse_texi($$$)
return $root;
}
-# parse special line @-commands, unmacro, set, clear, clickstyle.
-# Also remove spaces or ignore text, as specified in the line_commands hash.
-sub _parse_special_misc_command($$$$)
+# parse special rawline @-commands, unmacro, set, clear, clickstyle
+# and simply set the line as argument for other commands.
+sub _parse_rawline_command($$$$)
{
my ($self, $line, $command, $source_info) = @_;
my $args = [];
+ my $special_arg = 1;
my $has_comment = 0;
+
if ($command eq 'set') {
# REVALUE
if ($line =~
/^\s+([\w\-][^\s{\\}~`\^+"<>|@]*)(\@(comment|c)((\@|\s+).*)?|\s+(.*?))?\s*$/) {
@@ -7042,9 +7040,10 @@ sub _parse_special_misc_command($$$$)
$command, $line), $source_info);
}
} else {
- die $self->_bug_message("Unknown special command $command", $source_info);
+ $args = [ $line ];
+ $special_arg = 0;
}
- return ($args, $has_comment);
+ return ($args, $has_comment, $special_arg);
}
# at the end of an @-command line with arguments, parse the resulting
diff --git a/tp/Texinfo/XS/parsetexi/commands.h
b/tp/Texinfo/XS/parsetexi/commands.h
index 6547a2d1b7..1bc39bf8c3 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -106,11 +106,10 @@ void wipe_user_commands (void);
*/
/* Types of line command (has CF_line flag). Values for COMMAND.data. */
-#define LINE_special -1
-#define LINE_lineraw -2
-#define LINE_specific -4
-#define LINE_text -6
-#define LINE_line -7
+#define LINE_lineraw -1
+#define LINE_specific -2
+#define LINE_text -3
+#define LINE_line -4
/* Types of command without brace nor argument on line (has CF_nobrace flag).
*/
#define NOBRACE_symbol 0
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 80dac6cd13..bd6563173e 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -124,9 +124,10 @@ skip_to_comment_if_comment_or_spaces (char *after_argument,
return r;
}
-/* Process argument to special line command. */
+/* Process argument to raw line command. */
ELEMENT *
-parse_special_misc_command (char *line, enum command_id cmd, int *has_comment)
+parse_rawline_command (char *line, enum command_id cmd,
+ int *has_comment, int *special_arg)
{
#define ADD_ARG(string, len) do { \
ELEMENT *E = new_element (ET_NONE); \
@@ -138,6 +139,8 @@ parse_special_misc_command (char *line, enum command_id
cmd, int *has_comment)
char *p = 0, *q = 0, *r = 0;
char *value = 0, *remaining = 0;;
+ *special_arg = 1;
+
switch (cmd)
{
case CM_set:
@@ -265,7 +268,8 @@ parse_special_misc_command (char *line, enum command_id
cmd, int *has_comment)
free (value);
break;
default:
- fatal ("unknown special line command");
+ *special_arg = 0;
+ ADD_ARG (line, strlen(line));
}
return args;
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 777655e888..5ab885c509 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -326,15 +326,16 @@ handle_line_command (ELEMENT *current, char **line_inout,
arg_spec = command_data(data_cmd).data;
/* All the cases using the raw line.
- With LINE_lineraw, the line is taken as is as argument, and possibly
- later ignored for commands without arg.
- With LINE_special, arguments are determined especially from the
- raw line */
- if (arg_spec == LINE_lineraw || arg_spec == LINE_special)
+ For some commands, the arguments are determined especially from the
+ raw line, for other the line is taken as is as argument, and possibly
+ later ignored for commands without arg.
+ */
+ if (arg_spec == LINE_lineraw)
{
ELEMENT *args = 0;
enum command_id equivalent_cmd = 0;
int has_comment = 0;
+ int special_arg = 0;
int ignored = 0;
if (cmd == CM_insertcopying)
@@ -383,19 +384,10 @@ handle_line_command (ELEMENT *current, char **line_inout,
command_e = new_element (ET_NONE);
command_e->cmd = cmd;
- if (arg_spec == LINE_lineraw)
- {
- ELEMENT *arg;
- args = new_element (ET_NONE);
- arg = new_element (ET_NONE);
- add_to_element_contents (args, arg);
- text_append (&arg->text, line);
- }
- else /* arg_spec == LINE_special */
- {
- args = parse_special_misc_command (line, cmd, &has_comment);
- add_info_string_dup (command_e, "arg_line", line);
- }
+ args = parse_rawline_command (line, cmd,
+ &has_comment, &special_arg);
+ if (special_arg)
+ add_info_string_dup (command_e, "arg_line", line);
/* Handle @set txicodequoteundirected as an
alternative to @codequoteundirected. */
diff --git a/tp/Texinfo/XS/parsetexi/parser.h b/tp/Texinfo/XS/parsetexi/parser.h
index 19d72ccb61..a57b959ef7 100644
--- a/tp/Texinfo/XS/parsetexi/parser.h
+++ b/tp/Texinfo/XS/parsetexi/parser.h
@@ -132,8 +132,8 @@ ELEMENT *end_line (ELEMENT *current);
ELEMENT *end_line_def_line (ELEMENT *current);
ELEMENT *end_line_misc_line (ELEMENT *current);
ELEMENT *end_line_starting_block (ELEMENT *current);
-ELEMENT *parse_special_misc_command (char *line, enum command_id cmd,
- int *has_commment);
+ELEMENT *parse_rawline_command (char *line, enum command_id cmd,
+ int *has_commment, int *special_arg);
void check_register_target_element_label (ELEMENT *label_element,
ELEMENT *target_element);
diff --git a/tp/Texinfo/command_data.txt b/tp/Texinfo/command_data.txt
index 1a9f2ad4ad..2533f3231b 100644
--- a/tp/Texinfo/command_data.txt
+++ b/tp/Texinfo/command_data.txt
@@ -95,16 +95,15 @@ refill
nobrace,preamble,deprecated,no_paragraph NOBRACE_oth
# file is processed
#
# The values signification is:
-# special: no value and macro expansion, all the line is used, and
-# analysed during parsing (_parse_special_misc_command)
-# lineraw: no value and macro expansion, the line is kept as-is, not
-# analysed. Some of the commands have the line as argument.
-# text: the line is parsed as texinfo, and the argument is converted
-# to simple text with convert_to_text allowing only a few
@-commands
-# line: the line is parsed as texinfo
-# specific: the line is parsed as texinfo and the result should be plain
-# text maybe followed by a comment; the result is analysed
-# during parsing (parse_line_command_args).
+# lineraw: no value and macro expansion, the line is kept as-is.
+# Some have the line as argument, some have the line especially
+# analysed during parsing (parse_rawline_command)
+# text: the line is parsed as texinfo, and the argument is converted
+# to simple text with convert_to_text allowing only a few
@-commands
+# line: the line is parsed as texinfo
+# specific: the line is parsed as texinfo and the result should be plain
+# text maybe followed by a comment; the result is analysed
+# during parsing (parse_line_command_args).
#
# Beware that @item may be a 'line' command or a 'nobrace' command
# depending on the context.
@@ -146,10 +145,12 @@ end line,preamble,contain_plain_text
LINE_text
c line,preamble LINE_lineraw 1
comment line,preamble LINE_lineraw 1
-# set, clear, special argument
-set line,preamble LINE_special
-clear line,preamble LINE_special
-unmacro line,preamble LINE_special
+# set, clear, argument especially parsed
+set line,preamble LINE_lineraw 2
+clear line,preamble LINE_lineraw 1
+unmacro line,preamble LINE_lineraw 1
+# arg should be an @-command
+clickstyle line,global,preamble LINE_lineraw 1
# special
definfoenclose line,preamble,contain_plain_text,deprecated
LINE_specific 3
@@ -235,8 +236,6 @@ defcodeindex line,preamble,contain_plain_text
LINE_specific
# language code arg
documentlanguage line,global,preamble,contain_plain_text LINE_text
-# arg should be an @-command
-clickstyle line,global,preamble LINE_special
# arg code example distinct
kbdinputstyle line,global,preamble,contain_plain_text LINE_specific
1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Merge special command line data type into lineraw,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/t/02coverage.t, tp/Makefile.am (test_files), tp/Makefile.tres: add delcomment_on_comment with a DEL comment on a @comment line.
- Next by Date:
branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c, tp/Texinfo/XS/parsetexi/handle_commands.c (skip_to_comment): (skip_to_comment_if_comment_or_spaces, parse_rawline_command): move parse_rawline_command, skip_to_comment and skip_to_comment_if_comment_or_spaces to handle_commands.c.
- Previous by thread:
branch master updated: * tp/t/02coverage.t, tp/Makefile.am (test_files), tp/Makefile.tres: add delcomment_on_comment with a DEL comment on a @comment line.
- Next by thread:
branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c, tp/Texinfo/XS/parsetexi/handle_commands.c (skip_to_comment): (skip_to_comment_if_comment_or_spaces, parse_rawline_command): move parse_rawline_command, skip_to_comment and skip_to_comment_if_comment_or_spaces to handle_commands.c.
- Index(es):