Szerkesztő:GumiBot/code66

A Wikipédiából, a szabad enciklopédiából

A(z) 66. kódú hibát javító kódrészlet[szerkesztés]

sub fix_66 {	# Image description with full|partial <small> (==77)
    my ($error_code, $title_str, $text_str) = @_;

    my @filelinks;
    my $count = 0;
    while ($text_str =~ m{(\[\[(File|Fájl|Kép):[^\]]+\]\])}gs) {
        my ($pos, $filelink, $len) =
            (pos($text_str), $1, length($&));
        $pos -= $len;
        next unless (my $replacement = $filelink) =~ s|</?small>||g;
        unshift(@filelinks, {
            'pos'       => $pos,
            len         => $len,
            filelink    => $filelink,
            replacement => $replacement,
        });
        $count++;
    }
    $count or return ('Kepalairasban nincs <small>');
    foreach (@filelinks) {
        substr($text_str, $_->{pos}, $_->{len}) = $_->{replacement};
    }

    my $summary_str = $latin2->decode(
        "Bot: $count képaláírásból törölve a <small>. (Hibakód: $error_code)"
    );
    return ($summary_str, $count, $text_str);
}