From: <ma...@ev...> - 2002-04-20 12:44:57
|
They had some bugs so serious I'm surprised they worked. *** tramp.el~ --- tramp.el *************** *** 1068,1117 **** on the remote file system.") ;; Perl script to implement `mime-encode' ! (defvar tramp-perl-mime-encode (concat ! "sub encode_base64 ($); ! my $buf; ! while(read(STDIN, $buf, 60*57)) { print encode_base64($buf) } ! sub encode_base64 ($) { ! my $res = \"\"; ! my $eol = \"\n\"; ! pos($_[0]) = 0; # ensure start at the beginning ! while ($_[0] =~ /(.{1,45})/gs) { ! $res .= substr(pack(\"u\", $1), 1); ! chop($res); ! } ! $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs ! # fix padding at the end ! my $padding = (3 - length($_[0]) % 3) % 3; ! $res =~ s/.{$padding}$/\"=\" x $padding/e if $padding; ! # break encoded string into lines of no more than 76 characters each ! if (length $eol) { ! $res =~ s/(.{1,76})/$1$eol/g; ! } ! $res;}")) ;; Perl script to implement `mime-decode' ! (defvar tramp-perl-mime-decode (concat ! "sub decode_base64 ($); ! my $buf; ! while(read(STDIN, $buf, 60*57)) { print decode_base64($buf) } ! sub decode_base64 ($) { ! local($^W) = 0; # unpack(\"u\",...) gives bogus warning in 5.00[123] ! ! my $str = shift; ! my $res = \"\"; ! ! $str =~ tr|A-Za-z0-9+=/||cd; # remove non-base64 chars ! if (length($str) % 4) { ! warn(\"Length of base64 data not a multiple of 4\") ! } ! $str =~ s/=+$//; # remove padding ! $str =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format ! while ($str =~ /(.{1,60})/gs) { ! my $len = chr(32 + length($1)*3/4); # compute length byte ! $res .= unpack(\"u\", $len . $1 ); # uudecode ! } ! $res;}")) ; These values conform to `file-attributes' from XEmacs 21.2. ; GNU Emacs and other tools not checked. --- 1068,1105 ---- on the remote file system.") ;; Perl script to implement `mime-encode' ! (defvar tramp-perl-mime-encode ! (concat "sub encode_base64 ($;$);" ! "local $/;my $buf = <STDIN>;" ! "print encode_base64($buf);" ! "sub encode_base64 ($;$) {" ! "my $res = \"\";" ! "my $eol = $_[1] || \"\n\";" ! "pos($_[0]) = 0;" ! "while ($_[0] =~ /(.{1,45})/gs) {" ! "$res .= substr(pack(\"u\", $1), 1);" ! "chop $res;}" ! "$res =~ tr|` -_|AA-Za-z0-9+/|;" ! "my $padding = (3 - length($_[0]) % 3) % 3;" ! "$res =~ s/.{$padding}$/\"=\" x $padding/e if $padding;" ! "if (length $eol) {" ! "$res =~ s/(.{1,76})/$1$eol/g;}$res;}")) ;; Perl script to implement `mime-decode' ! (defvar tramp-perl-mime-decode ! (concat "sub decode_base64 ($);" ! "local $/;my $buf = <STDIN>;" ! "print decode_base64($buf);" ! "sub decode_base64 ($) {" ! "local($^W) = 0;" ! "my $str = shift;" ! "my $ret;" ! "for($str) {" ! "tr{A-Za-z0-9+=/}{}cd;" ! "s{=+$}{};" ! "tr{A-Za-z0-9+/}{ -_};" ! "return join('', map{ unpack('u', chr(32 + length($_)*0.75) . $_)}" ! "/(.{1,60})/gs );}}")) ; These values conform to `file-attributes' from XEmacs 21.2. ; GNU Emacs and other tools not checked. -- Find inner peace and ten thousand around you shall be saved. -- St. Seraphim of Sarov |