Tk Library Source Code

Artifact [e91ff7efe2]
Login

Artifact e91ff7efe2fc8e3c94434db49ee7555ee12983d6:

Attachment "bug544453.patch" to ticket [544453ffff] added by patthoyts 2002-04-16 16:25:51.
*** uuencode.tcl.orig	Fri Jan 25 07:36:08 2002
--- uuencode.tcl	Tue Apr 16 10:21:12 2002
***************
*** 8,13 ****
--- 8,15 ----
  # -------------------------------------------------------------------------
  # @(#)$Id: uuencode.tcl,v 1.3 2002/01/17 23:09:40 patthoyts Exp $
  
+ package require log;                    # tcllib 1.0
+ 
  namespace eval uuencode {
      namespace export encode decode uuencode uudecode
  }
***************
*** 33,43 ****
  
  proc uuencode::Decode {s} {
      set r {}
!     binary scan $s c* d
!     if {[expr {[llength $d] % 4}] != 0} {
!         return -code error "invalid uuencoded string: length must be a\
!               multiple of 4"
      }
          
      foreach {c0 c1 c2 c3} $d {
          append r [format %c [expr {((($c0-0x20)&0x3F) << 2) & 0xFF
--- 35,48 ----
  
  proc uuencode::Decode {s} {
      set r {}
!     # Check length and pad if necessary.
!     if {[set mod [expr {[string length $s] % 4}]] != 0} {
!         log::log notice "invalid uuencoded string: length must be a\
!               multiple of 4."
!         append s [string repeat "`" [expr {4 - $mod}]]
      }
+ 
+     binary scan $s c* d
          
      foreach {c0 c1 c2 c3} $d {
          append r [format %c [expr {((($c0-0x20)&0x3F) << 2) & 0xFF
***************
*** 62,67 ****
--- 67,78 ----
          return [::uuencode -mode encode $s]
      }
      proc uuencode::decode {s} {
+         # Check length and pad if necessary.
+         if {[set mod [expr {[string length $s] % 4}]] != 0} {
+             log::log notice "invalid uuencoded string: length must be a\
+               multiple of 4."
+             append s [string repeat "`" [expr {4 - $mod}]]
+         }
          return [::uuencode -mode decode $s]
      }
  }
***************
*** 156,162 ****
  
      if {$opts(filename) != {}} {
          set f [open $opts(filename) r]
-         fconfigure $f -translation binary
          set data [read $f]
          close $f
      } else {
--- 167,172 ----