Tk Library Source Code

Artifact [914b5dff5b]
Login

Artifact 914b5dff5b771c034aa90d6ddb378132a9678ebd:

Attachment "503336.diff" to ticket [503336ffff] added by andreas_kupries 2002-01-17 02:32:58.
? modules/fileinput
? modules/ftp/example
? modules/ftpd/examples
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/ChangeLog,v
retrieving revision 1.104
diff -u -r1.104 ChangeLog
--- ChangeLog	2002/01/16 19:00:50	1.104
+++ ChangeLog	2002/01/16 19:31:38
@@ -1,5 +1,6 @@
 2002-01-16  Andreas Kupries  <[email protected]>
 
+	* mime: Implemented FR #503336
  	* ftp:  Fixed bug #503471.
 	* nntp: Fixed bug #502250
 
Index: modules/mime/ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/mime/ChangeLog,v
retrieving revision 1.16
diff -u -r1.16 ChangeLog
--- modules/mime/ChangeLog	2001/11/08 06:44:02	1.16
+++ modules/mime/ChangeLog	2002/01/16 19:31:39
@@ -1,3 +1,10 @@
+2002-01-16  Andreas Kupries  <[email protected]>
+
+	* mime.tcl (qp_encode): Implemented FR #503336, added
+	  'no_softbreak' flag to qp_encode. Default value is false, giving
+	  the original behaviour. If set the encoded data is not broken
+	  into multiple lines, even if longer than 72 characters.
+
 2001-11-07  Andreas Kupries  <[email protected]>
 
 	* mime.n: Clarified documentation for 'parseaddress' in the wake
Index: modules/mime/mime.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/mime/mime.tcl,v
retrieving revision 1.17
diff -u -r1.17 mime.tcl
--- modules/mime/mime.tcl	2001/11/04 04:49:51	1.17
+++ modules/mime/mime.tcl	2002/01/16 19:31:39
@@ -2176,7 +2176,7 @@
 # Results:
 #	The properly quoted string is returned.
 
-proc mime::qp_encode {string {encoded_word 0}} {
+proc mime::qp_encode {string {encoded_word 0} {no_softbreak 0}} {
     # 8.1+ improved string manipulation routines used.
     # Replace outlying characters, characters that would normally
     # be munged by EBCDIC gateways, and special Tcl characters "[\]{}
@@ -2202,24 +2202,29 @@
 
     # Break long lines - ugh
 
-    set result ""
-    foreach line [split $string \n] {
-	while {[string length $line] > 72} {
-	    set chunk [string range $line 0 72]
-	    if {[regexp -- (=|=.)$ $chunk dummy end]} {
-
-		# Don't break in the middle of a code
-
-		set len [expr {72 - [string length $end]}]
-		set chunk [string range $line 0 $len]
-		incr len
-		set line [string range $line $len end]
-	    } else {
-		set line [string range $line 73 end]
+    # Implementation of FR #503336
+    if {$no_softbreak} {
+	set result $string
+    } else {
+	set result ""
+	foreach line [split $string \n] {
+	    while {[string length $line] > 72} {
+		set chunk [string range $line 0 72]
+		if {[regexp -- (=|=.)$ $chunk dummy end]} {
+		    
+		    # Don't break in the middle of a code
+
+		    set len [expr {72 - [string length $end]}]
+		    set chunk [string range $line 0 $len]
+		    incr len
+		    set line [string range $line $len end]
+		} else {
+		    set line [string range $line 73 end]
+		}
+		append result $chunk=\n
 	    }
-	    append result $chunk=\n
+	    append result $line\n
 	}
-	append result $line\n
     }
     
     # Trim off last \n, since the above code has the side-effect