aboutsummaryrefslogtreecommitdiff
path: root/development/tclvfs/patches/02-encoding.patch
blob: 997a352fb0a742e6572e591979641b3157507930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
Patch by Sergei Golovan (initially by Victor Wagner taken from
http://sourceforge.net/tracker/index.php?func=detail&aid=1011498&group_id=32692&atid=406308)
fixes -encoding and -eofchar of files opened on VFS.

Probably, the patch is incomplete for mk4fs with ::mk4vfs::zstreamed set to 1.

--- tclvfs-1.3-20080503.orig/library/ftpvfs.tcl
+++ tclvfs-1.3-20080503/library/ftpvfs.tcl
@@ -133,10 +133,13 @@
 	    ftp::Get $fd $name -variable tmp
 
 	    set filed [vfs::memchan]
+	    set encoding [fconfigure $filed -encoding]
+	    set eofchar [fconfigure $filed -eofchar]
+	    set translation [fconfigure $filed -translation]
 	    fconfigure $filed -translation binary
 	    puts -nonewline $filed $tmp
 
-	    fconfigure $filed -translation auto
+	    fconfigure $filed -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $filed 0
 	    return [list $filed]
 	}
--- tclvfs-1.3-20080503.orig/library/httpvfs.tcl
+++ tclvfs-1.3-20080503/library/httpvfs.tcl
@@ -357,11 +357,14 @@
 	"r" {
 	    set token [geturl "$dirurl$urlname" -headers $headers]
 	    set filed [vfs::memchan]
+	    set encoding [fconfigure $filed -encoding]
+	    set eofchar [fconfigure $filed -eofchar]
+	    set translation [fconfigure $filed -translation]
 	    fconfigure $filed -translation binary
 	    puts -nonewline $filed [::http::data $token]
 	    http::cleanup $token
 
-	    fconfigure $filed -translation auto
+	    fconfigure $filed -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $filed 0
 	    # XXX: the close command should free vfs::memchan somehow??
 	    return [list $filed]
--- tclvfs-1.3-20080503.orig/library/tclprocvfs.tcl
+++ tclvfs-1.3-20080503/library/tclprocvfs.tcl
@@ -84,9 +84,12 @@
 	"" -
 	"r" {
 	    set nfd [vfs::memchan]
+	    set encoding [fconfigure $nfd -encoding]
+	    set eofchar [fconfigure $nfd -eofchar]
+	    set translation [fconfigure $nfd -translation]
 	    fconfigure $nfd -translation binary
 	    puts -nonewline $nfd [_generate ::${ns}::${name}]
-	    fconfigure $nfd -translation auto
+	    fconfigure $nfd -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $nfd 0
 	    return [list $nfd]
 	}
--- tclvfs-1.3-20080503.orig/library/webdavvfs.tcl
+++ tclvfs-1.3-20080503/library/webdavvfs.tcl
@@ -153,8 +153,12 @@
 	    upvar #0 $token state
 
 	    set filed [vfs::memchan]
+	    set encoding [fconfigure $filed -encoding]
+	    set eofchar [fconfigure $filed -eofchar]
+	    set translation [fconfigure $filed -translation]
             fconfigure $filed -encoding binary -translation binary
 	    puts -nonewline $filed [::http::data $token]
+	    fconfigure $filed -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $filed 0
 	    ::http::cleanup $token
 	    return [list $filed]
--- tclvfs-1.3-20080503.orig/library/tkvfs.tcl
+++ tclvfs-1.3-20080503/library/tkvfs.tcl
@@ -72,9 +72,12 @@
 	"" -
 	"r" {
 	    set nfd [vfs::memchan]
+	    set encoding [fconfigure $nfd -encoding]
+	    set eofchar [fconfigure $nfd -eofchar]
+	    set translation [fconfigure $nfd -translation]
 	    fconfigure $nfd -translation binary
 	    puts -nonewline $nfd [_generate ${widg}.${name}]
-	    fconfigure $nfd -translation auto
+	    fconfigure $nfd -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $nfd 0
 	    return [list $nfd]
 	}
--- tclvfs-1.3-20080503.orig/library/tarvfs.tcl
+++ tclvfs-1.3-20080503/library/tarvfs.tcl
@@ -107,6 +107,9 @@
 	    ::tar::stat $tarfd $name sb
 	    
 	    set nfd [vfs::memchan]
+	    set encoding [fconfigure $nfd -encoding]
+	    set eofchar [fconfigure $nfd -eofchar]
+	    set translation [fconfigure $nfd -translation]
 	    fconfigure $nfd -translation binary
 	    
 	    # get the starting point from structure
@@ -115,7 +118,7 @@
 	    
 	    puts -nonewline $nfd $data
 	    
-	    fconfigure $nfd -translation auto
+	    fconfigure $nfd -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $nfd 0
 	    return [list $nfd]
 	}
--- tclvfs-1.3-20080503.orig/library/zipvfs.tcl
+++ tclvfs-1.3-20080503/library/zipvfs.tcl
@@ -108,6 +108,9 @@
 	    ::zip::stat $zipfd $name sb
 
 	    set nfd [vfs::memchan]
+	    set encoding [fconfigure $nfd -encoding]
+	    set eofchar [fconfigure $nfd -eofchar]
+	    set translation [fconfigure $nfd -translation]
 	    fconfigure $nfd -translation binary
 
 	    seek $zipfd $sb(ino) start
@@ -115,7 +118,7 @@
 
 	    puts -nonewline $nfd $data
 
-	    fconfigure $nfd -translation auto
+	    fconfigure $nfd -translation $translation -encoding $encoding -eofchar $eofchar
 	    seek $nfd 0
 	    return [list $nfd]
 	}
--- tclvfs-1.3-20080503.orig/library/mk4vfs.tcl
+++ tclvfs-1.3-20080503/library/mk4vfs.tcl
@@ -183,19 +183,25 @@
 		      set fd [vfs::zstream decompress $fd $sb(csize) $sb(size)]
 		    } else {
 		      set fd [vfs::memchan]
+		      set encoding [fconfigure $fd -encoding]
+		      set eofchar [fconfigure $fd -eofchar]
+		      set translation [fconfigure $fd -translation]
 		      fconfigure $fd -translation binary
 		      set s [mk::get $sb(ino) contents]
 		      puts -nonewline $fd [vfs::zip -mode decompress $s]
 
-		      fconfigure $fd -translation auto
+		      fconfigure $fd -translation $translation -encoding $encoding -eofchar $eofchar
 		      seek $fd 0
 		    }
 		} elseif { $::mk4vfs::direct } {
 		    set fd [vfs::memchan]
+		    set encoding [fconfigure $fd -encoding]
+		    set eofchar [fconfigure $fd -eofchar]
+		    set translation [fconfigure $fd -translation]
 		    fconfigure $fd -translation binary
 		    puts -nonewline $fd [mk::get $sb(ino) contents]
 
-		    fconfigure $fd -translation auto
+		    fconfigure $fd -translation $translation -encoding $encoding -eofchar $eofchar
 		    seek $fd 0
 		} else {
 		    set fd [mk::channel $sb(ino) contents r]
@@ -226,6 +232,9 @@
 		}
 
 		set fd [vfs::memchan]
+		set encoding [fconfigure $fd -encoding]
+		set eofchar [fconfigure $fd -eofchar]
+		set translation [fconfigure $fd -translation]
 		fconfigure $fd -translation binary
 		set s [mk::get $sb(ino) contents]
 
@@ -237,7 +246,7 @@
 		    puts -nonewline $fd $s
 		    #set fd [mk::channel $sb(ino) contents a]
 		}
-		fconfigure $fd -translation auto
+		fconfigure $fd -translation $translation -encoding $encoding -eofchar $eofchar
 		seek $fd 0 end
 		return [list $fd [list mk4vfs::do_close $db $fd $mode $sb(ino)]]
 	    }