[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Merge LINE_skipline in LINE_lineraw, distinguish
From: |
Patrice Dumas |
Subject: |
branch master updated: Merge LINE_skipline in LINE_lineraw, distinguish with arg number |
Date: |
Wed, 01 Mar 2023 16:43: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 fd02b611b7 Merge LINE_skipline in LINE_lineraw, distinguish with arg
number
fd02b611b7 is described below
commit fd02b611b7e1da3cd037a525341648e0e304179c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Mar 1 22:43:37 2023 +0100
Merge LINE_skipline in LINE_lineraw, distinguish with arg number
* tp/Texinfo/Common.pm (_informative_command_value),
tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/command_data.awk,
tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command),
tp/Texinfo/command_data.txt: merge LINE_lineraw with LINE_skipline,
but set the number of arguments to 1 for former lineraw commands and
to 0 for former LINE_skipline commands. Use the number of arguments
to distinguish when needed.
---
ChangeLog | 14 ++++++++++
tp/Texinfo/Commands.pod | 3 +-
tp/Texinfo/Common.pm | 3 +-
tp/Texinfo/Convert/TexinfoMarkup.pm | 26 +++++++++---------
tp/Texinfo/ParserNonXS.pm | 19 +++++++------
tp/Texinfo/XS/parsetexi/command_data.awk | 2 +-
tp/Texinfo/XS/parsetexi/commands.h | 1 -
tp/Texinfo/XS/parsetexi/handle_commands.c | 20 ++++++++------
tp/Texinfo/XS/parsetexi/parser.c | 2 +-
tp/Texinfo/command_data.txt | 41 ++++++++++++++--------------
tp/maintain/regenerate_commands_perl_info.pl | 2 +-
11 files changed, 77 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9e1d8dee9b..e035f95816 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-03-01 Patrice Dumas <pertusus@free.fr>
+
+ Merge LINE_skipline in LINE_lineraw, distinguish with arg number
+
+ * tp/Texinfo/Common.pm (_informative_command_value),
+ tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
+ tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/command_data.awk,
+ tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command),
+ tp/Texinfo/command_data.txt: merge LINE_lineraw with LINE_skipline,
+ but set the number of arguments to 1 for former lineraw commands and
+ to 0 for former LINE_skipline commands. Use the number of arguments
+ to distinguish when needed.
+
2023-03-01 Patrice Dumas <pertusus@free.fr>
* tp/Makefile.tres, tp/t/58alias.t: add alias_macro_target_removed
diff --git a/tp/Texinfo/Commands.pod b/tp/Texinfo/Commands.pod
index 9c6884f034..da455ac3f4 100644
--- a/tp/Texinfo/Commands.pod
+++ b/tp/Texinfo/Commands.pod
@@ -131,7 +131,8 @@ and C<@abbr>, 5 for C<@image> and C<@ref>.
Values are not necessarily set for all the commands, as commands are
also classified by type of command, some type of commands implying a
number of arguments, and the number of arguments may not be set if it
-corresponds to the default (0 for block commands, 1 for other commands).
+corresponds to the default (0 for block commands, 1 for other commands
+that take arguments).
=item %brace_code_commands
X<C<%brace_code_commands>>
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index ed14ba7558..b87b0bc25e 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1207,7 +1207,8 @@ sub _informative_command_value($)
my $cmdname = $element->{'cmdname'};
- if ($Texinfo::Commands::line_commands{$cmdname} eq 'skipline') {
+ if ($Texinfo::Commands::line_commands{$cmdname} eq 'lineraw'
+ and not $Texinfo::Commands::commands_args_number{$cmdname}) {
return 1;
} elsif ($element->{'extra'}
and exists($element->{'extra'}->{'text_arg'})) {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 22320671c9..b893ceaa11 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -900,18 +900,6 @@ sub _convert($$;$)
.$arg.$end_space
.$self->txi_markup_close_element($cmdname).$end_line;
}
- } elsif ($type eq 'skipline') {
- my $attribute = [];
- if ($element->{'args'} and $element->{'args'}->[0]
- and defined($element->{'args'}->[0]->{'text'})) {
- my $line = $element->{'args'}->[0]->{'text'};
- chomp($line);
- $attribute = [['line', $line]]
- if ($line ne '');
- }
- my $result = $self->txi_markup_open_element($cmdname, $attribute)
- .$self->txi_markup_close_element($cmdname)."\n";
- return $result;
} elsif ($type eq 'special') {
if ($cmdname eq 'clear' or $cmdname eq 'set') {
my $attribute = [];
@@ -956,7 +944,7 @@ sub _convert($$;$)
if ($cmdname eq 'c' or $cmdname eq 'comment') {
return $self->txi_markup_comment(
" $cmdname".$element->{'args'}->[0]->{'text'})
- } else {
+ } elsif ($Texinfo::Commands::commands_args_number{$cmdname}) {
my $value = '';
if ($element->{'args'} and $element->{'args'}->[0]
and defined($element->{'args'}->[0]->{'text'})) {
@@ -966,6 +954,18 @@ sub _convert($$;$)
chomp ($value);
return $self->txi_markup_open_element($cmdname).$value
.$self->txi_markup_close_element($cmdname)."\n";
+ } else {
+ my $attribute = [];
+ if ($element->{'args'} and $element->{'args'}->[0]
+ and defined($element->{'args'}->[0]->{'text'})) {
+ my $line = $element->{'args'}->[0]->{'text'};
+ chomp($line);
+ $attribute = [['line', $line]]
+ if ($line ne '');
+ }
+ my $result = $self->txi_markup_open_element($cmdname, $attribute)
+ .$self->txi_markup_close_element($cmdname)."\n";
+ return $result;
}
} else {
print STDERR "BUG: unknown line_command style $type\n"
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 36da2b192b..7b52ad1d70 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4271,7 +4271,7 @@ sub _end_line($$$)
$current = _end_line_starting_block($self, $current, $source_info);
# misc command line arguments
- # Never go here if skipline/noarg/...
+ # Never go here if lineraw/noarg/...
} elsif ($current->{'type'} and $current->{'type'} eq 'line_arg') {
$current = _end_line_misc_line($self, $current, $source_info);
}
@@ -5008,7 +5008,7 @@ sub _process_remaining_on_line($$$$)
if ($self->{'DEBUG'});
($line, $source_info) = _next_text($self, $current);
if (!defined($line)) {
- # end of the file or of a text fragment.
+ # End of the file or of a text fragment.
print STDERR "NO MORE LINE for empty text\n" if ($self->{'DEBUG'});
return ($current, $line, $source_info, $retval);
# goto funexit; # used in XS code
@@ -5641,13 +5641,12 @@ sub _process_remaining_on_line($$$$)
}
}
- # skipline text line lineraw /^\d$/
+ # text line lineraw special specific
my $arg_spec = $self->{'line_commands'}->{$command};
my $misc;
# all the cases using the raw line
- if ($arg_spec eq 'skipline' or $arg_spec eq 'lineraw'
- or $arg_spec eq 'special') {
+ if ($arg_spec eq 'lineraw' or $arg_spec eq 'special') {
my $ignored = 0;
if ($command eq 'insertcopying') {
my $parent = $current;
@@ -5682,7 +5681,7 @@ sub _process_remaining_on_line($$$$)
'parent' => $current};
my $args = [];
my $has_comment;
- if ($arg_spec eq 'lineraw' or $arg_spec eq 'skipline') {
+ if ($arg_spec eq 'lineraw') {
$args = [ $line ];
} elsif ($arg_spec eq 'special') {
($args, $has_comment)
@@ -5729,7 +5728,11 @@ sub _process_remaining_on_line($$$$)
{ 'type' => 'misc_arg', 'text' => $arg,
'parent' => $current->{'contents'}->[-1] };
}
- if (scalar(@$args) and $arg_spec ne 'skipline') {
+ # TODO: Could we have just set misc->args directly as args?
+ if (scalar(@$args)
+ and ($arg_spec eq 'special'
+ # lineraw with the line as argument
+ or $commands_args_number{$command})) {
$misc->{'extra'} = {} if (!$misc->{'extra'});
$misc->{'extra'}->{'misc_args'} = $args;
}
@@ -5760,7 +5763,7 @@ sub _process_remaining_on_line($$$$)
return ($current, $line, $source_info, $GET_A_NEW_LINE);
# goto funexit; # used in XS code
} else {
- # $arg_spec is text, line or a number
+ # $arg_spec is text, line or specific
# @item or @itemx in @table
if ($command eq 'item' or $command eq 'itemx') {
my $parent;
diff --git a/tp/Texinfo/XS/parsetexi/command_data.awk
b/tp/Texinfo/XS/parsetexi/command_data.awk
index 46932d9a08..3c15d76aa5 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.awk
+++ b/tp/Texinfo/XS/parsetexi/command_data.awk
@@ -201,7 +201,7 @@ END {
where = match(command_data, /^NOBRACE_/)
}
}
- if (where != 0 || command_data == "BRACE_noarg") {
+ if (where != 0 || command_data == "BRACE_noarg" || command_data ==
"LINE_lineraw" ) {
args_nr_data = "0"
} else {
args_nr_data = "1"
diff --git a/tp/Texinfo/XS/parsetexi/commands.h
b/tp/Texinfo/XS/parsetexi/commands.h
index 0941756c57..6547a2d1b7 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -108,7 +108,6 @@ 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_skipline -3
#define LINE_specific -4
#define LINE_text -6
#define LINE_line -7
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index ca1bebe2cd..4df15b460f 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -316,15 +316,16 @@ handle_line_command (ELEMENT *current, char **line_inout,
}
}
- /* Look up information about this command ( skipline text
- line lineraw specific ). */
+ /* Look up information about this command
+ ( text line lineraw specific special ). */
arg_spec = command_data(cmd).data;
/* All the cases using the raw line.
- TODO: I don't understand what the difference is between these.
- LINE_skipline is used where the command takes no argument at all. */
- if (arg_spec == LINE_skipline || arg_spec == LINE_lineraw
- || arg_spec == LINE_special)
+ 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)
{
ELEMENT *args = 0;
enum command_id equivalent_cmd = 0;
@@ -377,7 +378,7 @@ handle_line_command (ELEMENT *current, char **line_inout,
misc = new_element (ET_NONE);
misc->cmd = cmd;
- if (arg_spec == LINE_skipline || arg_spec == LINE_lineraw)
+ if (arg_spec == LINE_lineraw)
{
ELEMENT *arg;
args = new_element (ET_NONE);
@@ -465,7 +466,10 @@ handle_line_command (ELEMENT *current, char **line_inout,
add_to_element_args (misc, misc_arg);
}
/* TODO: Could we have just set misc->args directly as args? */
- if (args->contents.number > 0 && arg_spec != LINE_skipline)
+ if (args->contents.number > 0
+ && (arg_spec == LINE_special
+ /* lineraw with the line as argument */
+ || command_data (cmd).args_number > 0))
add_extra_misc_args (misc, "misc_args", args);
else
destroy_element_and_children (args);
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 850c4105c4..cca8aeaa91 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1633,7 +1633,7 @@ process_remaining_on_line (ELEMENT **current_inout, char
**line_inout)
if (!line)
{
- /* TODO: Can this only happen at end of file? */
+ /* End of the file or of a text fragment. */
goto funexit;
}
}
diff --git a/tp/Texinfo/command_data.txt b/tp/Texinfo/command_data.txt
index 3fc79a2dc4..4f2b49db78 100644
--- a/tp/Texinfo/command_data.txt
+++ b/tp/Texinfo/command_data.txt
@@ -98,8 +98,7 @@ refill
nobrace,preamble,deprecated,no_paragraph NOBRACE_oth
# 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
-# skipline: no argument, everything else on the line is skipped
+# 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
@@ -140,12 +139,12 @@ majorheading
line,formatted_line,contain_basic_inline,sectioning_head
centerchap
line,formatted_line,root,contain_basic_inline,sectioning_heading,deprecated
LINE_line
# end of document, end of block
-bye line,preamble LINE_skipline
+bye line,preamble LINE_lineraw
end line,preamble,contain_plain_text LINE_text
# comments
-c line,preamble LINE_lineraw
-comment line,preamble LINE_lineraw
+c line,preamble LINE_lineraw 1
+comment line,preamble LINE_lineraw 1
# set, clear, special argument
set line,preamble LINE_special
@@ -164,21 +163,21 @@ setfilename
line,close_paragraph,global_unique,preamble,contain_plai
verbatiminclude
line,formattable_line,close_paragraph,contain_plain_text LINE_text
include line,preamble,contain_plain_text
LINE_text
-raisesections line,preamble LINE_skipline
-lowersections line,preamble LINE_skipline
-contents line,close_paragraph,global,preamble LINE_skipline
-shortcontents line,close_paragraph,global,preamble LINE_skipline
-summarycontents line,close_paragraph,global,preamble LINE_skipline
-insertcopying line,formattable_line,close_paragraph,global
LINE_skipline
+raisesections line,preamble LINE_lineraw
+lowersections line,preamble LINE_lineraw
+contents line,close_paragraph,global,preamble LINE_lineraw
+shortcontents line,close_paragraph,global,preamble LINE_lineraw
+summarycontents line,close_paragraph,global,preamble LINE_lineraw
+insertcopying line,formattable_line,close_paragraph,global
LINE_lineraw
# more relevant in preamble
documentencoding line,global,preamble,contain_plain_text LINE_text
-novalidate line,global_unique,preamble LINE_skipline
+novalidate line,global_unique,preamble LINE_lineraw
# Position with regard with direntry is significant
dircategory line,close_paragraph,preamble,contain_basic_inline
LINE_line
# arg like 200mm,150mm or 11.5in
pagesizes line,global_unique,preamble,contain_plain_text
LINE_line
-finalout line,preamble LINE_skipline
+finalout line,preamble LINE_lineraw
# arg none asis
# or a number and forbids anything else on the line
paragraphindent line,global,preamble,contain_plain_text LINE_specific
1
@@ -204,12 +203,12 @@ exampleindent
line,global,preamble,contain_plain_text LINE_specific
footnotestyle line,global_unique,preamble,contain_plain_text
LINE_specific 1
# arg after|before|none
urefbreakstyle line,global,preamble,contain_plain_text LINE_specific
1
-smallbook line,global_unique,preamble LINE_skipline
-afivepaper line,global_unique,preamble LINE_skipline
-afourpaper line,global_unique,preamble LINE_skipline
-afourlatex line,global_unique,preamble LINE_skipline
-afourwide line,global_unique,preamble LINE_skipline
-bsixpaper line,global_unique,preamble LINE_skipline
+smallbook line,global_unique,preamble LINE_lineraw
+afivepaper line,global_unique,preamble LINE_lineraw
+afourpaper line,global_unique,preamble LINE_lineraw
+afourlatex line,global_unique,preamble LINE_lineraw
+afourwide line,global_unique,preamble LINE_lineraw
+bsixpaper line,global_unique,preamble LINE_lineraw
# arg off on single double singleafter doubleafter
# interacts with setchapternewpage
headings line,global,preamble,contain_plain_text LINE_specific
1
@@ -260,7 +259,7 @@ itemx
line,formatted_line,close_paragraph,contain_basic_inline
# in index entries
subentry line,in_index,contain_basic_inline LINE_line
# for printed output. @vskip 0pt plus 1filll
-vskip line,formattable_line
LINE_lineraw
+vskip line,formattable_line
LINE_lineraw 1
# one numerical/real arg
need
line,formattable_line,close_paragraph,contain_plain_text LINE_specific 1
@@ -273,7 +272,7 @@ subtitle
line,formatted_line,global,contain_basic_inline
title line,formatted_line,global_unique,contain_basic_inline
LINE_line
# numerical arg
sp
line,formattable_line,close_paragraph,contain_plain_text LINE_specific 1
-page line,formatted_line,close_paragraph
LINE_skipline
+page line,formatted_line,close_paragraph LINE_lineraw
##########################################################
diff --git a/tp/maintain/regenerate_commands_perl_info.pl
b/tp/maintain/regenerate_commands_perl_info.pl
index 9878407875..07a1104c27 100755
--- a/tp/maintain/regenerate_commands_perl_info.pl
+++ b/tp/maintain/regenerate_commands_perl_info.pl
@@ -131,7 +131,7 @@ print OUT '# @-commands max number of arguments. Not set
for all commands,
# in general it only matters if > 1, as commands with 0 args
# are in specific categories, and default handling of commands
# ignore commas as argument delimiter, which corresponds to commands
-# with 1 argument. Only used in Parser.
+# with 1 argument. Mostly used in Parser.
our %commands_args_number = (
';
foreach my $args_command (sort(keys(%command_args_nr))) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Merge LINE_skipline in LINE_lineraw, distinguish with arg number,
Patrice Dumas <=