rebuild ffmpeg for libvpx-1.15.0; fix gcc-14 problem; add patch for new
[oi-userland.git] / components / encumbered / ffmpeg / patches / 04-texinfo.patch
blob8585503649b873411f735a76b52e700783ab800b
1 This patch is from https://ffmpeg.org//pipermail/ffmpeg-devel/2024-November/335575.html
3 Here is a proposed patch for portability of doc/t2h.pm for GNU Texinfo
4 7.1 and 7.1.90 (7.2 pretest). I tested against 7.1 and 7.1.90 (7.2
5 pretest). There is a difference in the headings compared to the website
6 version, maybe related to FA_ICONS not being set the same, but the
7 result seems correct.
9 I also renamed $element to $output_unit in ffmpeg_heading_command as in
10 new equivalent makeinfo/texi2any code the $element variable is the
11 $command variable in ffmpeg_heading_command, which is very confusing. I
12 left as is the $command variable to have a patch easier to read, but it
13 could make sense to rename $command as $element later on.
15 The patch could also have effects with Texinfo 7.0, since some of the
16 changes are for that version, but that probably never show up because it
17 is for situations that may not exist in ffmpeg manuals (for example
18 @node without sectioning command), or because the code is robust to some
19 missing information (case of $heading_level in ffmpeg_heading_command
20 that was not set, as far as I can tell).
22 ---
23 doc/t2h.pm | 169 ++++++++++++++++++++++++++++++++++++++++-------------
24 1 file changed, 129 insertions(+), 40 deletions(-)
26 diff --git a/doc/t2h.pm b/doc/t2h.pm
27 index b7485e1f1e..1359960f27 100644
28 --- a/doc/t2h.pm
29 +++ b/doc/t2h.pm
30 @@ -54,12 +54,24 @@ sub get_formatting_function($$) {
33 # determine texinfo version
34 -my $program_version_num = version->declare(ff_get_conf('PACKAGE_VERSION'))->numify;
35 +my $package_version = ff_get_conf('PACKAGE_VERSION');
36 +$package_version =~ s/\+dev$//;
37 +my $program_version_num = version->declare($package_version)->numify;
38 my $program_version_6_8 = $program_version_num >= 6.008000;
40 # no navigation elements
41 ff_set_from_init_file('HEADERS', 0);
43 +my %sectioning_commands = %Texinfo::Common::sectioning_commands;
44 +if (scalar(keys(%sectioning_commands)) == 0) {
45 + %sectioning_commands = %Texinfo::Commands::sectioning_heading_commands;
48 +my %root_commands = %Texinfo::Common::root_commands;
49 +if (scalar(keys(%root_commands)) == 0) {
50 + %root_commands = %Texinfo::Commands::root_commands;
53 sub ffmpeg_heading_command($$$$$)
55 my $self = shift;
56 @@ -77,6 +89,9 @@ sub ffmpeg_heading_command($$$$$)
57 return $result;
60 + # no need to set it as the $element_id is output unconditionally
61 + my $heading_id;
63 my $element_id = $self->command_id($command);
64 $result .= "<a name=\"$element_id\"></a>\n"
65 if (defined($element_id) and $element_id ne '');
66 @@ -84,24 +99,40 @@ sub ffmpeg_heading_command($$$$$)
67 print STDERR "Process $command "
68 .Texinfo::Structuring::_print_root_command_texi($command)."\n"
69 if ($self->get_conf('DEBUG'));
70 - my $element;
71 - if ($Texinfo::Common::root_commands{$command->{'cmdname'}}
72 - and $command->{'parent'}
73 - and $command->{'parent'}->{'type'}
74 - and $command->{'parent'}->{'type'} eq 'element') {
75 - $element = $command->{'parent'};
76 + my $output_unit;
77 + if ($root_commands{$command->{'cmdname'}}) {
78 + if ($command->{'associated_unit'}) {
79 + $output_unit = $command->{'associated_unit'};
80 + } elsif ($command->{'structure'}
81 + and $command->{'structure'}->{'associated_unit'}) {
82 + $output_unit = $command->{'structure'}->{'associated_unit'};
83 + } elsif ($command->{'parent'}
84 + and $command->{'parent'}->{'type'}
85 + and $command->{'parent'}->{'type'} eq 'element') {
86 + $output_unit = $command->{'parent'};
87 + }
89 - if ($element) {
91 + if ($output_unit) {
92 $result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname,
93 - $command, $element);
94 + $command, $output_unit);
97 my $heading_level;
98 # node is used as heading if there is nothing else.
99 if ($cmdname eq 'node') {
100 - if (!$element or (!$element->{'extra'}->{'section'}
101 - and $element->{'extra'}->{'node'}
102 - and $element->{'extra'}->{'node'} eq $command
103 + if (!$output_unit or
104 + (((!$output_unit->{'extra'}->{'section'}
105 + and $output_unit->{'extra'}->{'node'}
106 + and $output_unit->{'extra'}->{'node'} eq $command)
107 + or
108 + ((($output_unit->{'extra'}->{'unit_command'}
109 + and $output_unit->{'extra'}->{'unit_command'} eq $command)
110 + or
111 + ($output_unit->{'unit_command'}
112 + and $output_unit->{'unit_command'} eq $command))
113 + and $command->{'extra'}
114 + and not $command->{'extra'}->{'associated_section'}))
115 # bogus node may not have been normalized
116 and defined($command->{'extra'}->{'normalized'}))) {
117 if ($command->{'extra'}->{'normalized'} eq 'Top') {
118 @@ -111,7 +142,15 @@ sub ffmpeg_heading_command($$$$$)
121 } else {
122 - $heading_level = $command->{'level'};
123 + if (defined($command->{'extra'})
124 + and defined($command->{'extra'}->{'section_level'})) {
125 + $heading_level = $command->{'extra'}->{'section_level'};
126 + } elsif ($command->{'structure'}
127 + and defined($command->{'structure'}->{'section_level'})) {
128 + $heading_level = $command->{'structure'}->{'section_level'};
129 + } else {
130 + $heading_level = $command->{'level'};
134 my $heading = $self->command_text($command);
135 @@ -119,8 +158,8 @@ sub ffmpeg_heading_command($$$$$)
136 # if there is an error in the node.
137 if (defined($heading) and $heading ne '' and defined($heading_level)) {
139 - if ($Texinfo::Common::root_commands{$cmdname}
140 - and $Texinfo::Common::sectioning_commands{$cmdname}) {
141 + if ($root_commands{$cmdname}
142 + and $sectioning_commands{$cmdname}) {
143 my $content_href = $self->command_contents_href($command, 'contents',
144 $self->{'current_filename'});
145 if ($content_href) {
146 @@ -140,7 +179,13 @@ sub ffmpeg_heading_command($$$$$)
150 - if ($self->in_preformatted()) {
151 + my $in_preformatted;
152 + if ($program_version_num >= 7.001090) {
153 + $in_preformatted = $self->in_preformatted_context();
154 + } else {
155 + $in_preformatted = $self->in_preformatted();
157 + if ($in_preformatted) {
158 $result .= $heading."\n";
159 } else {
160 # if the level was changed, set the command name right
161 @@ -149,21 +194,25 @@ sub ffmpeg_heading_command($$$$$)
162 $cmdname
163 = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
165 - # format_heading_text expects an array of headings for texinfo >= 7.0
166 if ($program_version_num >= 7.000000) {
167 - $heading = [$heading];
169 - $result .= &{get_formatting_function($self,'format_heading_text')}(
170 + $result .= &{get_formatting_function($self,'format_heading_text')}($self,
171 + $cmdname, [$cmdname], $heading,
172 + $heading_level +$self->get_conf('CHAPTER_HEADER_LEVEL') -1,
173 + $heading_id, $command);
175 + } else {
176 + $result .= &{get_formatting_function($self,'format_heading_text')}(
177 $self, $cmdname, $heading,
178 $heading_level +
179 $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
183 $result .= $content if (defined($content));
184 return $result;
187 -foreach my $command (keys(%Texinfo::Common::sectioning_commands), 'node') {
188 +foreach my $command (keys(%sectioning_commands), 'node') {
189 texinfo_register_command_formatting($command, \&ffmpeg_heading_command);
192 @@ -188,28 +237,56 @@ sub ffmpeg_begin_file($$$)
193 my $filename = shift;
194 my $element = shift;
196 - my $command;
197 - if ($element and $self->get_conf('SPLIT')) {
198 - $command = $self->element_command($element);
199 + my ($element_command, $node_command, $command_for_title);
200 + if ($element) {
201 + if ($element->{'unit_command'}) {
202 + $element_command = $element->{'unit_command'};
203 + } elsif ($self->can('tree_unit_element_command')) {
204 + $element_command = $self->tree_unit_element_command($element);
205 + } elsif ($self->can('tree_unit_element_command')) {
206 + $element_command = $self->element_command($element);
209 + $node_command = $element_command;
210 + if ($element_command and $element_command->{'cmdname'}
211 + and $element_command->{'cmdname'} ne 'node'
212 + and $element_command->{'extra'}
213 + and $element_command->{'extra'}->{'associated_node'}) {
214 + $node_command = $element_command->{'extra'}->{'associated_node'};
217 + $command_for_title = $element_command if ($self->get_conf('SPLIT'));
220 - my ($title, $description, $encoding, $date, $css_lines,
221 - $doctype, $bodytext, $copying_comment, $after_body_open,
222 - $extra_head, $program_and_version, $program_homepage,
223 + my ($title, $description, $keywords, $encoding, $date, $css_lines, $doctype,
224 + $root_html_element_attributes, $body_attributes, $copying_comment,
225 + $after_body_open, $extra_head, $program_and_version, $program_homepage,
226 $program, $generator);
227 - if ($program_version_num >= 7.000000) {
228 - ($title, $description, $encoding, $date, $css_lines,
229 - $doctype, $bodytext, $copying_comment, $after_body_open,
230 + if ($program_version_num >= 7.001090) {
231 + ($title, $description, $keywords, $encoding, $date, $css_lines, $doctype,
232 + $root_html_element_attributes, $body_attributes, $copying_comment,
233 + $after_body_open, $extra_head, $program_and_version, $program_homepage,
234 + $program, $generator) = $self->_file_header_information($command_for_title,
235 + $filename);
236 + } elsif ($program_version_num >= 7.000000) {
237 + ($title, $description, $encoding, $date, $css_lines, $doctype,
238 + $root_html_element_attributes, $copying_comment, $after_body_open,
239 $extra_head, $program_and_version, $program_homepage,
240 - $program, $generator) = $self->_file_header_information($command);
241 + $program, $generator) = $self->_file_header_information($command_for_title,
242 + $filename);
243 } else {
244 ($title, $description, $encoding, $date, $css_lines,
245 - $doctype, $bodytext, $copying_comment, $after_body_open,
246 - $extra_head, $program_and_version, $program_homepage,
247 - $program, $generator) = $self->_file_header_informations($command);
248 + $doctype, $root_html_element_attributes, $copying_comment,
249 + $after_body_open, $extra_head, $program_and_version, $program_homepage,
250 + $program, $generator) = $self->_file_header_informations($command_for_title);
253 - my $links = $self->_get_links ($filename, $element);
254 + my $links;
255 + if ($program_version_num >= 7.000000) {
256 + $links = $self->_get_links($filename, $element, $node_command);
257 + } else {
258 + $links = $self->_get_links ($filename, $element);
261 my $head1 = $ENV{"FFMPEG_HEADER1"} || <<EOT;
262 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
263 @@ -252,13 +329,25 @@ sub ffmpeg_program_string($)
264 if (defined($self->get_conf('PROGRAM'))
265 and $self->get_conf('PROGRAM') ne ''
266 and defined($self->get_conf('PACKAGE_URL'))) {
267 - return $self->convert_tree(
268 + if ($program_version_num >= 7.001090) {
269 + return $self->convert_tree(
270 + $self->cdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.',
271 + { 'program_homepage' => {'text' => $self->get_conf('PACKAGE_URL')},
272 + 'program' => {'text' => $self->get_conf('PROGRAM') }}));
273 + } else {
274 + return $self->convert_tree(
275 $self->gdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.',
276 - { 'program_homepage' => $self->get_conf('PACKAGE_URL'),
277 - 'program' => $self->get_conf('PROGRAM') }));
278 + { 'program_homepage' => {'text' => $self->get_conf('PACKAGE_URL')},
279 + 'program' => {'text' => $self->get_conf('PROGRAM') }}));
281 } else {
282 - return $self->convert_tree(
283 - $self->gdt('This document was generated automatically.'));
284 + if ($program_version_num >= 7.001090) {
285 + return $self->convert_tree(
286 + $self->cdt('This document was generated automatically.'));
287 + } else {
288 + return $self->convert_tree(
289 + $self->gdt('This document was generated automatically.'));
293 if ($program_version_6_8) {
295 2.45.2