View | Details | Raw Unified | Return to bug 275268
Collapse All | Expand All

(-)b/multimedia/ffmpeg4/files/patch-doc_t2h.pm (+214 lines)
Added Link Here
1
--- doc/t2h.pm.orig	2023-04-12 18:01:50 UTC
2
+++ doc/t2h.pm
3
@@ -20,8 +20,45 @@
4
 # License along with FFmpeg; if not, write to the Free Software
5
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
 
7
+# Texinfo 7.0 changed the syntax of various functions.
8
+# Provide a shim for older versions.
9
+sub ff_set_from_init_file($$) {
10
+    my $key = shift;
11
+    my $value = shift;
12
+    if (exists &{'texinfo_set_from_init_file'}) {
13
+        texinfo_set_from_init_file($key, $value);
14
+    } else {
15
+        set_from_init_file($key, $value);
16
+    }
17
+}
18
+
19
+sub ff_get_conf($) {
20
+    my $key = shift;
21
+    if (exists &{'texinfo_get_conf'}) {
22
+        texinfo_get_conf($key);
23
+    } else {
24
+        get_conf($key);
25
+    }
26
+}
27
+
28
+sub get_formatting_function($$) {
29
+    my $obj = shift;
30
+    my $func = shift;
31
+
32
+    my $sub = $obj->can('formatting_function');
33
+    if ($sub) {
34
+        return $obj->formatting_function($func);
35
+    } else {
36
+        return $obj->{$func};
37
+    }
38
+}
39
+
40
+# determine texinfo version
41
+my $program_version_num = version->declare(ff_get_conf('PACKAGE_VERSION'))->numify;
42
+my $program_version_6_8 = $program_version_num >= 6.008000;
43
+
44
 # no navigation elements
45
-set_from_init_file('HEADERS', 0);
46
+ff_set_from_init_file('HEADERS', 0);
47
 
48
 sub ffmpeg_heading_command($$$$$)
49
 {
50
@@ -55,7 +92,7 @@ sub ffmpeg_heading_command($$$$$)
51
         $element = $command->{'parent'};
52
     }
53
     if ($element) {
54
-        $result .= &{$self->{'format_element_header'}}($self, $cmdname,
55
+        $result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname,
56
                                                        $command, $element);
57
     }
58
 
59
@@ -112,7 +149,11 @@ sub ffmpeg_heading_command($$$$$)
60
                 $cmdname
61
                     = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
62
             }
63
-            $result .= &{$self->{'format_heading_text'}}(
64
+            # format_heading_text expects an array of headings for texinfo >= 7.0
65
+            if ($program_version_num >= 7.000000) {
66
+                $heading = [$heading];
67
+            }
68
+            $result .= &{get_formatting_function($self,'format_heading_text')}(
69
                         $self, $cmdname, $heading,
70
                         $heading_level +
71
                         $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
72
@@ -127,14 +168,18 @@ foreach my $command (keys(%Texinfo::Common::sectioning
73
 }
74
 
75
 # print the TOC where @contents is used
76
-set_from_init_file('INLINE_CONTENTS', 1);
77
+if ($program_version_6_8) {
78
+    ff_set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
79
+} else {
80
+    ff_set_from_init_file('INLINE_CONTENTS', 1);
81
+}
82
 
83
 # make chapters <h2>
84
-set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
85
+ff_set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
86
 
87
 # Do not add <hr>
88
-set_from_init_file('DEFAULT_RULE', '');
89
-set_from_init_file('BIG_RULE', '');
90
+ff_set_from_init_file('DEFAULT_RULE', '');
91
+ff_set_from_init_file('BIG_RULE', '');
92
 
93
 # Customized file beginning
94
 sub ffmpeg_begin_file($$$)
95
@@ -151,7 +196,18 @@ sub ffmpeg_begin_file($$$)
96
     my ($title, $description, $encoding, $date, $css_lines,
97
         $doctype, $bodytext, $copying_comment, $after_body_open,
98
         $extra_head, $program_and_version, $program_homepage,
99
-        $program, $generator) = $self->_file_header_informations($command);
100
+        $program, $generator);
101
+    if ($program_version_num >= 7.000000) {
102
+        ($title, $description, $encoding, $date, $css_lines,
103
+         $doctype, $bodytext, $copying_comment, $after_body_open,
104
+         $extra_head, $program_and_version, $program_homepage,
105
+         $program, $generator) = $self->_file_header_information($command);
106
+    } else {
107
+        ($title, $description, $encoding, $date, $css_lines,
108
+         $doctype, $bodytext, $copying_comment, $after_body_open,
109
+         $extra_head, $program_and_version, $program_homepage,
110
+         $program, $generator) = $self->_file_header_informations($command);
111
+    }
112
 
113
     my $links = $self->_get_links ($filename, $element);
114
 
115
@@ -184,7 +240,11 @@ EOT
116
 
117
     return $head1 . $head_title . $head2 . $head_title . $head3;
118
 }
119
-texinfo_register_formatting_function('begin_file', \&ffmpeg_begin_file);
120
+if ($program_version_6_8) {
121
+    texinfo_register_formatting_function('format_begin_file', \&ffmpeg_begin_file);
122
+} else {
123
+    texinfo_register_formatting_function('begin_file', \&ffmpeg_begin_file);
124
+}
125
 
126
 sub ffmpeg_program_string($)
127
 {
128
@@ -201,13 +261,17 @@ sub ffmpeg_program_string($)
129
       $self->gdt('This document was generated automatically.'));
130
   }
131
 }
132
-texinfo_register_formatting_function('program_string', \&ffmpeg_program_string);
133
+if ($program_version_6_8) {
134
+    texinfo_register_formatting_function('format_program_string', \&ffmpeg_program_string);
135
+} else {
136
+    texinfo_register_formatting_function('program_string', \&ffmpeg_program_string);
137
+}
138
 
139
 # Customized file ending
140
 sub ffmpeg_end_file($)
141
 {
142
     my $self = shift;
143
-    my $program_string = &{$self->{'format_program_string'}}($self);
144
+    my $program_string = &{get_formatting_function($self,'format_program_string')}($self);
145
     my $program_text = <<EOT;
146
       <p style="font-size: small;">
147
         $program_string
148
@@ -220,11 +284,15 @@ EOT
149
 EOT
150
     return $program_text . $footer;
151
 }
152
-texinfo_register_formatting_function('end_file', \&ffmpeg_end_file);
153
+if ($program_version_6_8) {
154
+    texinfo_register_formatting_function('format_end_file', \&ffmpeg_end_file);
155
+} else {
156
+    texinfo_register_formatting_function('end_file', \&ffmpeg_end_file);
157
+}
158
 
159
 # Dummy title command
160
 # Ignore title. Title is handled through ffmpeg_begin_file().
161
-set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
162
+ff_set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
163
 sub ffmpeg_title($$$$)
164
 {
165
     return '';
166
@@ -242,8 +310,14 @@ sub ffmpeg_float($$$$$)
167
     my $args = shift;
168
     my $content = shift;
169
 
170
-    my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
171
-                                                                $command);
172
+    my ($caption, $prepended);
173
+    if ($program_version_num >= 7.000000) {
174
+        ($caption, $prepended) = Texinfo::Convert::Converter::float_name_caption($self,
175
+                                                                                 $command);
176
+    } else {
177
+        ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
178
+                                                                     $command);
179
+    }
180
     my $caption_text = '';
181
     my $prepended_text;
182
     my $prepended_save = '';
183
@@ -315,8 +389,13 @@ sub ffmpeg_float($$$$$)
184
             $caption->{'args'}->[0], 'float caption');
185
     }
186
     if ($prepended_text.$caption_text ne '') {
187
-        $prepended_text = $self->_attribute_class('div','float-caption'). '>'
188
-                . $prepended_text;
189
+        if ($program_version_num >= 7.000000) {
190
+            $prepended_text = $self->html_attribute_class('div',['float-caption']). '>'
191
+                    . $prepended_text;
192
+        } else {
193
+            $prepended_text = $self->_attribute_class('div','float-caption'). '>'
194
+                    . $prepended_text;
195
+        }
196
         $caption_text .= '</div>';
197
     }
198
     my $html_class = '';
199
@@ -329,8 +408,13 @@ sub ffmpeg_float($$$$$)
200
         $prepended_text = '';
201
         $caption_text   = '';
202
     }
203
-    return $self->_attribute_class('div', $html_class). '>' . "\n" .
204
-        $prepended_text . $caption_text . $content . '</div>';
205
+    if ($program_version_num >= 7.000000) {
206
+        return $self->html_attribute_class('div', [$html_class]). '>' . "\n" .
207
+            $prepended_text . $caption_text . $content . '</div>';
208
+    } else {
209
+        return $self->_attribute_class('div', $html_class). '>' . "\n" .
210
+            $prepended_text . $caption_text . $content . '</div>';
211
+    }
212
 }
213
 
214
 texinfo_register_command_formatting('float',

Return to bug 275268