Ticket #4058: mythtv-perl_bindings-disable_replacements_in_format_name.patch

File mythtv-perl_bindings-disable_replacements_in_format_name.patch, 1.7 KB (added by sphery <mtdean@…>, 13 years ago)
  • bindings/perl/MythTV/Program.pm

     
    207207        my $replacement = (shift or '-');
    208208        my $allow_dirs  = (shift) ? 1 : 0;
    209209        my $underscores = (shift) ? 1 : 0;
     210        my $no_replace  = (shift) ? 1 : 0;
    210211    # Escape where necessary
    211212        my $safe_sep = $separator;
    212213           $safe_sep =~ s/([^\w\s])/\\$1/sg;
     
    387388        $name =~ s/(?<!%)(?:%($keys))/$fields{$1}/g;
    388389        $name =~ s/%%/%/g;
    389390    # Some basic cleanup for illegal (windows) filename characters, etc.
    390         $name =~ tr/\ \t\r\n/ /s;
    391         $name =~ tr/"/'/s;
    392         $name =~ s/(?:[\/\\:*?<>|]+\s*)+(?=[^\d\s])/$replacement /sg;
    393         $name =~ s/[\/\\:*?<>|]/$replacement/sg;
    394         $name =~ s/(?:(?:$safe_sep)+\s*)+(?=[^\d\s])/$separator /sg;
    395         $name =~ s/^($safe_sep|$safe_rep|\ )+//s;
    396         $name =~ s/($safe_sep|$safe_rep|\ )+$//s;
    397         $name =~ s/\0($safe_sep|$safe_rep|\ )+/\0/s;
    398         $name =~ s/($safe_sep|$safe_rep|\ )+\0/\0/s;
     391        unless ($no_replace) {
     392            $name =~ tr/\ \t\r\n/ /s;
     393            $name =~ tr/"/'/s;
     394            $name =~ s/(?:[\/\\:*?<>|]+\s*)+(?=[^\d\s])/$replacement /sg;
     395            $name =~ s/[\/\\:*?<>|]/$replacement/sg;
     396            $name =~ s/(?:(?:$safe_sep)+\s*)+(?=[^\d\s])/$separator /sg;
     397            $name =~ s/^($safe_sep|$safe_rep|\ )+//s;
     398            $name =~ s/($safe_sep|$safe_rep|\ )+$//s;
     399            $name =~ s/\0($safe_sep|$safe_rep|\ )+/\0/s;
     400            $name =~ s/($safe_sep|$safe_rep|\ )+\0/\0/s;
     401        }
    399402    # Underscores?
    400403        if ($underscores) {
    401404            $name =~ tr/ /_/s;