Ticket #68747: patch-texinfo-7.diff

File patch-texinfo-7.diff, 7.7 KB (added by maxcrees (Max Rees), 12 months ago)
  • doc/t2h.pm

    Backported from the below upstream commit.
    
    From f01fdedb69e4accb1d1555106d8f682ff1f1ddc7 Mon Sep 17 00:00:00 2001
    From: Frank Plowman <post@frankplowman.com>
    Date: Wed, 8 Nov 2023 07:55:18 +0000
    Subject: [PATCH 1/1] doc/html: support texinfo 7.0
    
    Resolves trac ticket #10636 (http://trac.ffmpeg.org/ticket/10636).
    
    Texinfo 7.0, released in November 2022, changed the names of various
    functions. Compiling docs with Texinfo 7.0 resulted in warnings and
    improperly formatted documentation. More old names appear to have
    been removed in Texinfo 7.1, released October 2023, which causes docs
    compilation to fail.
    
    This commit addresses the issue by adding logic to switch between the old
    and new function names depending on the Texinfo version. Texinfo 6.8
    produces identical documentation before and after the patch.
    
    CC
    https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1938238.html
    https://bugs.gentoo.org/916104
    
    Signed-off-by: Frank Plowman <post@frankplowman.com>
    ---
     doc/t2h.pm | 106 ++++++++++++++++++++++++++++++++++++++++++-----------
     1 file changed, 85 insertions(+), 21 deletions(-)
    
    diff --git a/doc/t2h.pm b/doc/t2h.pm
    index d07d974286..b7485e1f1e 100644
     
    2020# License along with FFmpeg; if not, write to the Free Software
    2121# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    2222
     23# Texinfo 7.0 changed the syntax of various functions.
     24# Provide a shim for older versions.
     25sub ff_set_from_init_file($$) {
     26    my $key = shift;
     27    my $value = shift;
     28    if (exists &{'texinfo_set_from_init_file'}) {
     29        texinfo_set_from_init_file($key, $value);
     30    } else {
     31        set_from_init_file($key, $value);
     32    }
     33}
     34
     35sub ff_get_conf($) {
     36    my $key = shift;
     37    if (exists &{'texinfo_get_conf'}) {
     38        texinfo_get_conf($key);
     39    } else {
     40        get_conf($key);
     41    }
     42}
     43
     44sub get_formatting_function($$) {
     45    my $obj = shift;
     46    my $func = shift;
     47
     48    my $sub = $obj->can('formatting_function');
     49    if ($sub) {
     50        return $obj->formatting_function($func);
     51    } else {
     52        return $obj->{$func};
     53    }
     54}
     55
     56# determine texinfo version
     57my $program_version_num = version->declare(ff_get_conf('PACKAGE_VERSION'))->numify;
     58my $program_version_6_8 = $program_version_num >= 6.008000;
     59
    2360# no navigation elements
    24 set_from_init_file('HEADERS', 0);
     61ff_set_from_init_file('HEADERS', 0);
    2562
    2663sub ffmpeg_heading_command($$$$$)
    2764{
    sub ffmpeg_heading_command($$$$$) 
    5592        $element = $command->{'parent'};
    5693    }
    5794    if ($element) {
    58         $result .= &{$self->{'format_element_header'}}($self, $cmdname,
     95        $result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname,
    5996                                                       $command, $element);
    6097    }
    6198
    sub ffmpeg_heading_command($$$$$) 
    112149                $cmdname
    113150                    = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
    114151            }
    115             $result .= &{$self->{'format_heading_text'}}(
     152            # format_heading_text expects an array of headings for texinfo >= 7.0
     153            if ($program_version_num >= 7.000000) {
     154                $heading = [$heading];
     155            }
     156            $result .= &{get_formatting_function($self,'format_heading_text')}(
    116157                        $self, $cmdname, $heading,
    117158                        $heading_level +
    118159                        $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
    foreach my $command (keys(%Texinfo::Common::sectioning 
    127168}
    128169
    129170# print the TOC where @contents is used
    130 set_from_init_file('INLINE_CONTENTS', 1);
     171ff_set_from_init_file('INLINE_CONTENTS', 1);
    131172
    132173# make chapters <h2>
    133 set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
     174ff_set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
    134175
    135176# Do not add <hr>
    136 set_from_init_file('DEFAULT_RULE', '');
    137 set_from_init_file('BIG_RULE', '');
     177ff_set_from_init_file('DEFAULT_RULE', '');
     178ff_set_from_init_file('BIG_RULE', '');
    138179
    139180# Customized file beginning
    140181sub ffmpeg_begin_file($$$)
    sub ffmpeg_begin_file($$$) 
    151192    my ($title, $description, $encoding, $date, $css_lines,
    152193        $doctype, $bodytext, $copying_comment, $after_body_open,
    153194        $extra_head, $program_and_version, $program_homepage,
    154         $program, $generator) = $self->_file_header_informations($command);
     195        $program, $generator);
     196    if ($program_version_num >= 7.000000) {
     197        ($title, $description, $encoding, $date, $css_lines,
     198         $doctype, $bodytext, $copying_comment, $after_body_open,
     199         $extra_head, $program_and_version, $program_homepage,
     200         $program, $generator) = $self->_file_header_information($command);
     201    } else {
     202        ($title, $description, $encoding, $date, $css_lines,
     203         $doctype, $bodytext, $copying_comment, $after_body_open,
     204         $extra_head, $program_and_version, $program_homepage,
     205         $program, $generator) = $self->_file_header_informations($command);
     206    }
    155207
    156208    my $links = $self->_get_links ($filename, $element);
    157209
    sub ffmpeg_end_file($) 
    207259sub ffmpeg_end_file($)
    208260{
    209261    my $self = shift;
    210     my $program_string = &{$self->{'format_program_string'}}($self);
     262    my $program_string = &{get_formatting_function($self,'format_program_string')}($self);
    211263    my $program_text = <<EOT;
    212264      <p style="font-size: small;">
    213265        $program_string
    texinfo_register_formatting_function('end_file', \&ffm 
    224276
    225277# Dummy title command
    226278# Ignore title. Title is handled through ffmpeg_begin_file().
    227 set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
     279ff_set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
    228280sub ffmpeg_title($$$$)
    229281{
    230282    return '';
    sub ffmpeg_float($$$$$) 
    242294    my $args = shift;
    243295    my $content = shift;
    244296
    245     my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
    246                                                                 $command);
     297    my ($caption, $prepended);
     298    if ($program_version_num >= 7.000000) {
     299        ($caption, $prepended) = Texinfo::Convert::Converter::float_name_caption($self,
     300                                                                                 $command);
     301    } else {
     302        ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
     303                                                                     $command);
     304    }
    247305    my $caption_text = '';
    248306    my $prepended_text;
    249307    my $prepended_save = '';
    sub ffmpeg_float($$$$$) 
    315373            $caption->{'args'}->[0], 'float caption');
    316374    }
    317375    if ($prepended_text.$caption_text ne '') {
    318         $prepended_text = $self->_attribute_class('div','float-caption'). '>'
    319                 . $prepended_text;
     376        if ($program_version_num >= 7.000000) {
     377            $prepended_text = $self->html_attribute_class('div',['float-caption']). '>'
     378                    . $prepended_text;
     379        } else {
     380            $prepended_text = $self->_attribute_class('div','float-caption'). '>'
     381                    . $prepended_text;
     382        }
    320383        $caption_text .= '</div>';
    321384    }
    322385    my $html_class = '';
    sub ffmpeg_float($$$$$) 
    329392        $prepended_text = '';
    330393        $caption_text   = '';
    331394    }
    332     return $self->_attribute_class('div', $html_class). '>' . "\n" .
    333         $prepended_text . $caption_text . $content . '</div>';
     395    if ($program_version_num >= 7.000000) {
     396        return $self->html_attribute_class('div', [$html_class]). '>' . "\n" .
     397            $prepended_text . $caption_text . $content . '</div>';
     398    } else {
     399        return $self->_attribute_class('div', $html_class). '>' . "\n" .
     400            $prepended_text . $caption_text . $content . '</div>';
     401    }
    334402}
    335403
    336404texinfo_register_command_formatting('float',