TclVFS

Check-in [9b66c30488]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tidied up the tests so they run all the way through and added lots of zipfs tests. Updated windows nmake build files.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9b66c304880f0c23f263f2614bb7c570b68d8a34
User & Date: patthoyts 2009-01-22 14:36:58
Context
2009-01-22
15:10
Make use of the core zlib and reflected channels to implement memchan and zip file support with Tcl 8.6. check-in: 9f07054c71 user: patthoyts tags: trunk
14:36
Tidied up the tests so they run all the way through and added lots of zipfs tests. Updated windows nmake build files. check-in: 9b66c30488 user: patthoyts tags: trunk
01:34
Applied patch from [Bug 1011492] to ensure we handle zipfiles with a prefix block robustly. check-in: f49334bb20 user: patthoyts tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1
2






3
4
5
6
7
8
9
2009-01-22  Pat Thoyts  <[email protected]>







	* library/zipvfs.tcl: Applied patch from [Bug 1011492] to ensure
	we handle zipfiles with a prefix block robustly.

2009-01-21  Andreas Kupries  <[email protected]>

	* pkgIndex.tcl.in: Incremented version of vfs::zip
	* library/zipvfs.tcl (zip::EndOfArchive): Fixed Schelte Bron's

>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2009-01-22  Pat Thoyts  <[email protected]>

	* win/makefile.vc:  Updated windows build files
	* win/rules.vc:
	* win/nmakehlp.c:

	* tests/*.test: Tidied up the tests. Added lots of zipfs tests.
	
	* library/zipvfs.tcl: Applied patch from [Bug 1011492] to ensure
	we handle zipfiles with a prefix block robustly.

2009-01-21  Andreas Kupries  <[email protected]>

	* pkgIndex.tcl.in: Incremented version of vfs::zip
	* library/zipvfs.tcl (zip::EndOfArchive): Fixed Schelte Bron's

Changes to tests/vfs.test.

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
171
172
173
174
175
176
177


























178
179
180
181




    ::vfs::zip -mode decompress "\x78\x9c\x33\x34\x32\x36\x31\x35\x33\xb7\xb0\x34\x0\x0\xb\x2c\x2\xe"
} {1234567890}

test vfs-4.1 {vfs glob with .. [Bug 2378350]} -setup {
    package require vfs::ns 0.5.1
} -body {
    namespace eval ::test {}
    namespace eval ::test {}
    namespace eval ::test::bar {}
    namespace eval ::test::baz {}
    proc ::test::waz {args} { blah blah}
    proc ::test::bar::lol {args} { body body }
    proc ::test::baz::noz {args} { moo moo }
    vfs::ns::Mount :: nstest
    set res [list]
................................................................................
    catch {vfs::unmount nstest}
    catch {namespace delete ::test}
} -result [list \
	       0 {nstest/test/bar nstest/test/baz nstest/test/waz} \
	       0 {nstest/test/baz/noz} \
	       0 {nstest/test/bar/../baz/noz} \
	       ]



























# cleanup
::tcltest::cleanupTests
return










<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




>
>
>
>
152
153
154
155
156
157
158

159
160
161
162
163
164
165
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
    ::vfs::zip -mode decompress "\x78\x9c\x33\x34\x32\x36\x31\x35\x33\xb7\xb0\x34\x0\x0\xb\x2c\x2\xe"
} {1234567890}

test vfs-4.1 {vfs glob with .. [Bug 2378350]} -setup {
    package require vfs::ns 0.5.1
} -body {
    namespace eval ::test {}

    namespace eval ::test::bar {}
    namespace eval ::test::baz {}
    proc ::test::waz {args} { blah blah}
    proc ::test::bar::lol {args} { body body }
    proc ::test::baz::noz {args} { moo moo }
    vfs::ns::Mount :: nstest
    set res [list]
................................................................................
    catch {vfs::unmount nstest}
    catch {namespace delete ::test}
} -result [list \
	       0 {nstest/test/bar nstest/test/baz nstest/test/waz} \
	       0 {nstest/test/baz/noz} \
	       0 {nstest/test/bar/../baz/noz} \
	       ]

test vfs-4.2 {Test MatchInDirectory fix} -setup {
    package require vfs::ns 0.5.1
} -body {
    namespace eval ::test {}
    namespace eval ::test::quux {}
    proc ::test::waz {args} { blah blah}
    vfs::ns::Mount :: nstest
    set res [list]
    lappend res \
	    [catch {lsort [glob nstest/test/*]} msg] $msg \
	    [catch {lsort [glob nstest/test/quux/*]} msg] $msg \
	    [catch {lsort [glob -nocomplain nstest/test/quux/*]} msg] $msg \
	    [catch {lsort [glob nstest/test/quux/nothingthere/*]} msg] $msg \
	    [catch {lsort [glob -nocomplain nstest/test/quux/nothingthere/*]} msg] $msg \
} -cleanup {
    catch {vfs::unmount nstest}
    catch {namespace delete ::test}
} -result [list \
	       0 {nstest/test/quux nstest/test/waz} \
               1 {no files matched glob pattern "nstest/test/quux/*"} \
               0 {} \
               1 {no files matched glob pattern "nstest/test/quux/nothingthere/*"} \
               0 {} \
	       ]


# cleanup
::tcltest::cleanupTests
return

# Local variables:
# mode: tcl
# End:

Changes to tests/vfsArchive.test.



1
2
3
4
5
6
7
8
..
10
11
12
13
14
15
16








17
18
19
20
21
22
23
...
110
111
112
113
114
115
116
117
118


# Commands covered: running our tests from inside a 'zip' vfs.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001-2002 by Vince Darley.
#
................................................................................
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}









tcltest::testConstraint nativefs \
  [string equal [lindex [file system [info script]] 0] "native"]

proc makeAndMountZipArchive {} {
    puts stdout "Zipping tests" ; update
    cd [file dirname [file dirname [file normalize [info script]]]]
................................................................................
	set res "ok"
	puts stdout "=== End of embedded mk4 tests ==="
    }
    cd $testdir
    set res
} {ok}




>
>
|







 







>
>
>
>
>
>
>
>







 







|
|
>
1
2
3
4
5
6
7
8
9
10
..
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
120
121
122
123
124
125
126
127
128
129
# vfsArchive.test                                               -*- tcl -*-
#
#	Commands covered: running our tests from inside a 'zip' vfs.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001-2002 by Vince Darley.
#
................................................................................
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

# -------------------------------------------------------------------------
# This file really buggers up the normal test suite run.
# Comment this return if you really want to run this.
#
return
#
# -------------------------------------------------------------------------

tcltest::testConstraint nativefs \
  [string equal [lindex [file system [info script]] 0] "native"]

proc makeAndMountZipArchive {} {
    puts stdout "Zipping tests" ; update
    cd [file dirname [file dirname [file normalize [info script]]]]
................................................................................
	set res "ok"
	puts stdout "=== End of embedded mk4 tests ==="
    }
    cd $testdir
    set res
} {ok}

# cleanup
::tcltest::cleanupTests
return

Changes to tests/vfsFtp.test.



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

# Commands covered:  vfs::ftp::Mount and friends.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001 by Vince Darley.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

package require vfs::ftp


puts stdout "These tests require an internet connection, and might"
puts stdout "take a long time to complete."

set dir [pwd]

test vfsFtp-1.1 {mount and cd} {


    vfs::ftp::Mount ftp://ftp.ucsd.edu/pub/alpha/ localmount
    cd localmount
    cd tcl
    file tail [pwd]




} {tcl}

test vfsFtp-1.2 {mount and glob} {


    glob -nocomplain vfsTest.tcl


} {vfsTest.tcl}

test vfsFtp-1.3 {mount and source} {


    source vfsTest.tcl





} {This was returned from a remote file}

# cleanup
cd $dir
catch {vfs::unmount localmount}

::tcltest::cleanupTests
return
>
>
|












|



|

>
|
|
|
<

|
>
>
|
|

|
>
>
>
>
|

|
>
>
|
>
>
|

|
>
>
|
>
>
>
>
>
|


<
<
<


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
# vfsFtp.test                                                   -*- tcl -*-
#
#	Commands covered:  vfs::ftp::Mount and friends.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001 by Vince Darley.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import ::tcltest::*
}

testConstraint ftp [expr {![catch {package require vfs::ftp}]}]

if {[testConstraint ftp]} {
    puts stdout "These tests require an internet connection, and might"
    puts stdout "take a long time to complete."
}


test vfsFtp-1.1 {mount and cd} -constraints {ftp} -setup {
    set cwd [pwd]
} -body {
    vfs::ftp::Mount ftp://ftp.ucsd.edu/pub/alpha/ local
    cd local
    cd tcl
    set result [file tail [pwd]]
    vfs::unmount local
    set result
} -cleanup {
    cd $pwd
} -result {tcl}

test vfsFtp-1.2 {mount and glob} -constraints {ftp} -setup {
    vfs::ftp::Mount ftp://ftp.ucsd.edu/pub/alpha/ local
} -body {
    glob -nocomplain -directory local/tcl vfsTest.tcl
} -cleanup {
    vfs::unmount local
} -result {vfsTest.tcl}

test vfsFtp-1.3 {mount and source} -constraints {ftp} -setup {
    vfs::ftp::Mount ftp://ftp.ucsd.edu/pub/alpha/ local
} -body {
    set f [open local/tcl/vfsTest.tcl r]
    set data [read $f]
    close $f
    set data
} -cleanup {
    vfs::unmount local
} -result {This was returned from a remote file}

# cleanup



::tcltest::cleanupTests
return

Changes to tests/vfsTar.test.

cannot compute difference between binary files

Changes to tests/vfsUrl.test.



1
2
3
4
5
6
7
8

# Commands covered:  vfs::urltype::Mount and friends.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001 by Vince Darley.
#
>
>
|







1
2
3
4
5
6
7
8
9
10
# vfsZip.test                                                   -*- tcl -*-
#
#	Commands covered:  vfs::urltype::Mount and friends.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001 by Vince Darley.
#

Changes to tests/vfsZip.test.



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






















































































# Commands covered:  the 'zip' vfs.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001-2002 by Vince Darley.

#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

package require vfs::zip

test vfsZip-1.1 {mount with error} {
    set f [file join [temporaryDirectory] vfszip.zip]







































































    close [open $f w]






    set res [catch {vfs::zip::Mount $f localmount} err]
    #lappend res $err
    lappend res [catch {file delete $f}]
























































































    set res
} {1 0}





















































































>
>
|






>






|



|

|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
|
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
180
181
182
183
184
185
186
187
188
189
190
191
192

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# vfsZip.test                                                   -*- tcl -*-
#
#	Commands covered:  the 'zip' vfs.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2001-2002 by Vince Darley.
# Copyright (c) 2009 by Pat Thoyts <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import ::tcltest::*
}

testConstraint zipfs [expr {![catch {package require vfs::zip}]}]

# To test this properly we require a zip file. If a zip
# executable can be found then we will create one.
#
testConstraint zipexe [expr {[auto_execok zip] ne ""}]
if {[testConstraint zipfs] && [testConstraint zipexe]} {
    file mkdir zipfs.test
    makeFile {File one} zipfs.test/One.txt
    makeFile {File two} zipfs.test/Two.txt
    file mkdir zipfs.test/Aleph
    makeFile {File aleph one} zipfs.test/Aleph/One.txt
    makeFile {File aleph two} zipfs.test/Aleph/Two.txt
    eval exec [auto_execok zip] [list -r zipfs.zip zipfs.test]
    eval exec [auto_execok zip] [list zipnest.zip zipfs.zip]
}

test vfsZip-1.1 "mount non-existent zip file" -constraints {zipfs} -setup {
    set file [makeFile {} vfszip.zip]
} -body {
    set mnt [vfs::zip::Mount $file localmount]
} -cleanup {
    removeFile $file
} -returnCodes {error} -result {no header found}

test vfsZip-1.2 "mount invalid zip file"  -constraints {zipfs} -setup {
    set file [makeFile {random text} vfszip.zip]
} -body {
    set mnt [vfs::zip::Mount $file localmount]
} -cleanup {
    removeFile $file
} -returnCodes {error} -result {no header found}

test vfsZip-1.3 "mount zipfile" -constraints {zipfs zipexe} -body {
    vfs::zip::Mount zipfs.zip local
    vfs::unmount local
} -result {}

test vfsZip-1.4 "glob" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
} -body {
    glob -directory local *
} -cleanup {
    vfs::unmount local
} -result {local/zipfs.test}

test vfsZip-1.5 "glob files" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
} -body {
    lsort [glob -directory local/zipfs.test -tails *]
} -cleanup {
    vfs::unmount local
} -result {Aleph One.txt Two.txt}

test vfsZip-1.6 "glob non-present files" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
} -body {
    lsort [glob -directory local/zipfs.test -tails ridikulus.txt]
} -cleanup {
    vfs::unmount local
} -returnCodes {error} -result {no files matched glob pattern "ridikulus.txt"}

test vfsZip-1.7 "glob non-present directory" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
} -body {
    lsort [glob -directory local/zipfs.test/ridikulus -tails *]
} -cleanup {
    vfs::unmount local
} -returnCodes {error} -result {no files matched glob pattern "*"}

test vfsZip-1.8 "read file" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
} -body {
    set f [open local/zipfs.test/One.txt r]
    set data [string trim [read $f]]
    close $f
    set data
} -cleanup {
    vfs::unmount local
} -result {File one}

test vfsZip-1.9 "stat file" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local


    unset -nocomplain stat
    set result ""
} -body {
    file stat local/zipfs.test/One.txt stat
    lappend result type $stat(type) size [expr {$stat(size) > 8}]
} -cleanup {
    unset -nocomplain stat
    vfs::unmount local
} -result {type file size 1}

test vfsZip-1.10 "stat directory" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
    unset -nocomplain stat
    set result ""
} -body {
    file stat local/zipfs.test/Aleph stat
    lappend result type $stat(type) size $stat(size)
} -cleanup {
    unset -nocomplain stat
    vfs::unmount local
} -result {type directory size 0}

test vfsZip-1.11 "cd directory" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
    set cwd [pwd]
} -body {
    cd local/zipfs.test/Aleph
    lsort [glob *]
} -cleanup {
    cd $cwd
    vfs::unmount local
} -result {One.txt Two.txt}

test vfsZip-2.0 "nested stat file" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip local
    unset -nocomplain stat
    set result ""
} -body {
    file stat local/zipfs.zip stat
    lappend result type $stat(type) size [expr {$stat(size) != 0}]
} -cleanup {
    unset -nocomplain stat
    vfs::unmount local
} -result {type file size 1}

test vfsZip-2.1 "nested mount" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip local
} -body {
    vfs::zip::Mount local/zipfs.zip nested
    vfs::unmount nested
} -cleanup {
    vfs::unmount local
} -result {}

test vfsZip-2.2 "stat mountpoint" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip local
    vfs::zip::Mount local/zipfs.zip nested
    unset -nocomplain stat
    set result ""
} -body {
    file stat nested stat
    lappend result type $stat(type) size $stat(size)
} -cleanup {
    unset -nocomplain stat
    vfs::unmount nested
    vfs::unmount local
} -result {type directory size 0}

test vfsZip-2.3 "stat nested file" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip local
    vfs::zip::Mount local/zipfs.zip nested
    unset -nocomplain stat
    set result ""
} -body {
    file stat nested/zipfs.test/One.txt stat
    lappend result type $stat(type) size [expr {$stat(size) > 0}]
} -cleanup {
    unset -nocomplain stat
    vfs::unmount nested
    vfs::unmount local
} -result {type file size 1}

test vfsZip-2.4 "nested self-mount" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip local
} -body {
    vfs::zip::Mount local/zipfs.zip local/zipfs.zip
    set r [file isdirectory local/zipfs.zip]
    vfs::unmount local/zipfs.zip
    set r

} -cleanup {
    vfs::unmount local
} -result {1}

test vfsZip-2.5 "nested cwd" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip vfszip25
    vfs::zip::Mount vfszip25/zipfs.zip vfszip25/zipfs.zip
    set cwd [pwd]
} -body {
    cd vfszip25/zipfs.zip/zipfs.test/Aleph
    lsort [glob *]
} -cleanup {
    cd $cwd
    vfs::unmount vfszip25/zipfs.zip
    vfs::unmount vfszip25
} -result {One.txt Two.txt}

# NOTE: this test issues an error, it should probably be a nicer error though if
#       someone unmounts while using the vfs. At the moment the message is garbage.
#
test vfsZip-2.6 "nested cwd, umount in use" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipnest.zip vfszip26
    set cwd [pwd]
} -body {
    vfs::zip::Mount vfszip26/zipfs.zip vfszip26/zipfs.zip
    cd vfszip26/zipfs.zip/zipfs.test/Aleph
    vfs::unmount vfszip26/zipfs.zip
    pwd
} -cleanup {
    cd $cwd
    vfs::unmount vfszip26/zipfs.zip
    vfs::unmount vfszip26
} -returnCodes {error} -match glob -result {*}


test vfsZip-2.7 "nested mount mis-ordered unmounts" -constraints {zipfs zipexe} -setup {
} -body {
    vfs::zip::Mount zipnest.zip vfszip27
    vfs::zip::Mount vfszip27/zipfs.zip vfszip27/zipfs.zip
    set r [file isdirectory vfszip27/zipfs.zip]
    vfs::unmount vfszip27
    vfs::unmount vfszip27/zipfs.zip
    set r
} -cleanup {
} -result {1}

testConstraint bug1533748 [file exists [file join [testsDirectory] bug1533748.zip]]

test vfsZip-3.0 "bug #: ./ prefixed filenames" -constraints {zipfs zipexe bug1533748} -setup {
    vfs::zip::Mount [file join [testsDirectory] bug1533748.zip] vfszip30
} -body {
    list [glob -nocomplain -directory vfszip30 -tails *] \
        [glob -nocomplain -directory vfszip30/articles -tails *] \
} -cleanup {
    vfs::unmount vfszip30
} -result {articles c_5498.xml}

test vfsZip-3.1 "bug #: ./ prefixed filenames" -constraints {zipfs zipexe bug1533748} -setup {
    vfs::zip::Mount [file join [testsDirectory] bug1533748.zip] vfszip31
} -body {
    set f [open vfszip31/articles/c_5498.xml r]
    fconfigure $f -translation binary
    set data [read $f]
    close $f
    expr {[string length $data] == [file size vfszip31/articles/c_5498.xml]}
} -cleanup {
    vfs::unmount vfszip31
} -result {1}

test vfsZip-9.0 "attempt to delete mounted file" -constraints {zipfs zipexe} -setup {
    vfs::zip::Mount zipfs.zip local
} -body {
    file delete zipfs.zip
} -cleanup {
    vfs::unmount local
} -returnCodes {error} -result {error deleting "zipfs.zip": permission denied}

# cleanup
if {[testConstraint zipfs] && [testConstraint zipexe]} {
    file delete -force zipfs.test
    file delete zipfs.zip
    file delete zipnest.zip
}
tcltest::cleanupTests
return

Changes to win/makefile.vc.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
274
275
276
277
278
279
280



281
282
283
284
285
286
287
288
289
290
291
292
293
...
323
324
325
326
327
328
329






330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351

352
353
354
355
356
357
358
...
359
360
361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
...
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 Ajuba Solutions.
# Copyright (c) 2001 ActiveState Corporation.
# Copyright (c) 2001-2002 David Gravereaux.
# Copyright (c) 2003-2006 Pat Thoyts
#
#-------------------------------------------------------------------------
# RCS: @(#)$Id: makefile.vc,v 1.28 2008/12/10 23:00:09 patthoyts Exp $
#-------------------------------------------------------------------------

# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
# VCINSTALLDIR instead. The MSVC Toolkit release defines yet another.
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR) && !defined(VCToolkitInstallDir)
MSG = ^
................................................................................
INCLUDES	= $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)"
BASE_CFLAGS	= $(cflags) $(cdebug) $(crt) $(INCLUDES)
CON_CFLAGS	= $(cflags) $(cdebug) $(crt) -DCONSOLE
TCL_CFLAGS	= -DPACKAGE_NAME="\"$(PROJECT)\"" \
		  -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
                  -DBUILD_$(PROJECT) $(BASE_CFLAGS) $(OPTDEFINES)




#---------------------------------------------------------------------
# Link flags
#---------------------------------------------------------------------

!if $(DEBUG)
ldebug	= -debug:full -debugtype:cv
!if $(MSVCRT)
ldebug = $(ldebug) -nodefaultlib:msvcrt
!endif
!else
ldebug	= -release -opt:ref -opt:icf,3
!endif

................................................................................
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
!if $(VCVERSION) >= 1400 && $(VCVERSION) < 1500
baselibs   = $(baselibs) bufferoverflowU.lib
!endif
!endif







#---------------------------------------------------------------------
# TclTest flags
#---------------------------------------------------------------------

!IF "$(TESTPAT)" != ""
TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
!ENDIF

#---------------------------------------------------------------------
# Project specific targets (EDIT)
#---------------------------------------------------------------------

all:	    setup $(PROJECT)
$(PROJECT): setup $(PRJLIB) pkgIndex
install:    install-binaries install-libraries install-docs
pkgIndex:   setup $(OUT_DIR)\pkgIndex.tcl

test: setup $(PROJECT)
	@set VFS_LIBRARY=$(LIBDIR:\=/)
	@set TCL_LIBRARY=$(TCL_LIBRARY:\=/)
	@set TCLLIBPATH=$(OUT_DIR:\=/)

!if $(TCLINSTALL)
	@set PATH=$(_TCLDIR)\bin;$(PATH)
!else
	@set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH)
!endif
!if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
	$(DEBUGGER) $(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS)
................................................................................
!else
	@echo Please wait while the tests are collected...
	$(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) > tests.log
	type tests.log | more
!endif

shell: setup $(PROJECT)
	@set VFS_LIBRARY=$(LIBDIR:\=/)
	@set TCL_LIBRARY=$(TCL_LIBRARY:\=/)
	@set TCLLIBPATH=$(OUT_DIR:\=/)

!if $(TCLINSTALL)
	@set PATH=$(_TCLDIR)\bin;$(PATH)
!else
	@set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH)
!endif
!if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
	$(DEBUGGER) $(TCLSH)
................................................................................
	type tests.log | more
!endif

setup:
	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)

# See <tcl>/win/coffbase.txt for extension base addresses.
$(PRJLIB): $(DLLOBJS)
!if $(STATIC_BUILD)
	$(lib32) -nologo -out:[email protected] @<<
$**
<<
!else
	$(link32) $(dlllflags) -base:0x10A70000 -out:[email protected] $(baselibs) @<<
$**
<<
	$(_VC_MANIFEST_EMBED_DLL)
	[email protected] $*.exp
!endif

$(PRJSTUBLIB): $(PRJSTUBOBJS)
................................................................................

#---------------------------------------------------------------------
# Clean up
#---------------------------------------------------------------------

clean:
	@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
	@if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch

realclean: clean
	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)

distclean: realclean
	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj






|


|







 







>
>
>





|







 







>
>
>
>
>
>





|

|











<

|
>







 







<

|
>







 







<






|







 







|










11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
...
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357

358
359
360
361
362
363
364
365
366
367
...
368
369
370
371
372
373
374

375
376
377
378
379
380
381
382
383
384
...
388
389
390
391
392
393
394

395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 Ajuba Solutions.
# Copyright (c) 2001 ActiveState Corporation.
# Copyright (c) 2001-2002 David Gravereaux.
# Copyright (c) 2003-2008 Pat Thoyts
#
#-------------------------------------------------------------------------
# RCS: @(#)$Id: makefile.vc,v 1.29 2009/01/22 14:36:58 patthoyts Exp $
#-------------------------------------------------------------------------

# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
# VCINSTALLDIR instead. The MSVC Toolkit release defines yet another.
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR) && !defined(VCToolkitInstallDir)
MSG = ^
................................................................................
INCLUDES	= $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)"
BASE_CFLAGS	= $(cflags) $(cdebug) $(crt) $(INCLUDES)
CON_CFLAGS	= $(cflags) $(cdebug) $(crt) -DCONSOLE
TCL_CFLAGS	= -DPACKAGE_NAME="\"$(PROJECT)\"" \
		  -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
                  -DBUILD_$(PROJECT) $(BASE_CFLAGS) $(OPTDEFINES)

### Stubs files should not be compiled with -GL
STUB_CFLAGS     = $(cflags) $(cdebug:-GL=) #$(TK_DEFINES)

#---------------------------------------------------------------------
# Link flags
#---------------------------------------------------------------------

!if $(DEBUG)
ldebug	= -debug
!if $(MSVCRT)
ldebug = $(ldebug) -nodefaultlib:msvcrt
!endif
!else
ldebug	= -release -opt:ref -opt:icf,3
!endif

................................................................................
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
!if $(VCVERSION) >= 1400 && $(VCVERSION) < 1500
baselibs   = $(baselibs) bufferoverflowU.lib
!endif
!endif

!if exist("$(TCLDIR)\win\coffbase.txt")
dllbase	= -base:@$(TCLDIR)\win\coffbase.txt,tdbc
!else
dllbase = -base:0x10A70000 
!endif

#---------------------------------------------------------------------
# TclTest flags
#---------------------------------------------------------------------

!if "$(TESTPAT)" != ""
TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
!endif

#---------------------------------------------------------------------
# Project specific targets (EDIT)
#---------------------------------------------------------------------

all:	    setup $(PROJECT)
$(PROJECT): setup $(PRJLIB) pkgIndex
install:    install-binaries install-libraries install-docs
pkgIndex:   setup $(OUT_DIR)\pkgIndex.tcl

test: setup $(PROJECT)

	@set TCL_LIBRARY=$(TCL_LIBRARY:\=/)
        @set TCLLIBPATH=$(OUT_DIR_PATH:\=/)
	@set VFS_LIBRARY=$(LIBDIR:\=/)
!if $(TCLINSTALL)
	@set PATH=$(_TCLDIR)\bin;$(PATH)
!else
	@set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH)
!endif
!if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
	$(DEBUGGER) $(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS)
................................................................................
!else
	@echo Please wait while the tests are collected...
	$(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) > tests.log
	type tests.log | more
!endif

shell: setup $(PROJECT)

	@set TCL_LIBRARY=$(TCL_LIBRARY:\=/)
        @set TCLLIBPATH=$(OUT_DIR_PATH:\=/)
	@set VFS_LIBRARY=$(LIBDIR:\=/)
!if $(TCLINSTALL)
	@set PATH=$(_TCLDIR)\bin;$(PATH)
!else
	@set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH)
!endif
!if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
	$(DEBUGGER) $(TCLSH)
................................................................................
	type tests.log | more
!endif

setup:
	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)


$(PRJLIB): $(DLLOBJS)
!if $(STATIC_BUILD)
	$(lib32) -nologo -out:[email protected] @<<
$**
<<
!else
	$(link32) $(dlllflags) $(dllbase) -out:[email protected] $(baselibs) @<<
$**
<<
	$(_VC_MANIFEST_EMBED_DLL)
	[email protected] $*.exp
!endif

$(PRJSTUBLIB): $(PRJSTUBOBJS)
................................................................................

#---------------------------------------------------------------------
# Clean up
#---------------------------------------------------------------------

clean:
	@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
	@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch

realclean: clean
	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)

distclean: realclean
	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj

Changes to win/nmakehlp.c.

7
8
9
10
11
12
13
14
15
16
17
18
19




20
21

22
23
24
25
26
27
28
..
41
42
43
44
45
46
47

48
49
50
51
52
53
54
...
161
162
163
164
165
166
167











168
169
170
171
172
173
174
175
176
177
178
...
710
711
712
713
714
715
716
























717
718
719
720
721
722
723
724
725
726
 * Copyright (c) 2002 by David Gravereaux.
 * Copyright (c) 2006 by Pat Thoyts
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * ----------------------------------------------------------------------------
 * RCS: @(#) $Id: nmakehlp.c,v 1.1 2008/04/30 15:18:56 patthoyts Exp $
 * ----------------------------------------------------------------------------
 */

#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>




#pragma comment (lib, "user32.lib")
#pragma comment (lib, "kernel32.lib")

#include <stdio.h>
#include <math.h>

/*
 * This library is required for x64 builds with _some_ versions of MSVC
 */
#if defined(_M_IA64) || defined(_M_AMD64)
................................................................................
/* protos */

int		CheckForCompilerFeature(const char *option);
int		CheckForLinkerFeature(const char *option);
int		IsIn(const char *string, const char *substring);
int		GrepForDefine(const char *file, const char *string);
int		SubstituteFile(const char *substs, const char *filename);

const char *    GetVersionFromFile(const char *filename, const char *match);
DWORD WINAPI	ReadFromPipe(LPVOID args);

/* globals */

#define CHUNK	25
#define STATICBUFFERSIZE    1000
................................................................................
		    argv[0]);
		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
		    &dwWritten, NULL);
		return 0;
	    }
	    printf("%s\n", GetVersionFromFile(argv[2], argv[3]));
	    return 0;











	}
    }
    chars = snprintf(msg, sizeof(msg) - 1,
	    "usage: %s -c|-l|-f|-g|-V ...\n"
	    "This is a little helper app to equalize shell differences between WinNT and\n"
	    "Win9x and get nmake.exe to accomplish its job.\n",
	    argv[0]);
    WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
    return 2;
}
 
................................................................................
	}
	
	list_free(&substPtr);
    }
    fclose(fp);
    return 0;
}

























/*
 * Local variables:
 *   mode: c
 *   c-basic-offset: 4
 *   fill-column: 78
 *   indent-tabs-mode: t
 *   tab-width: 8
 * End:
 */






|





>
>
>
>


>







 







>







 







>
>
>
>
>
>
>
>
>
>
>



|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










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
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
...
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
 * Copyright (c) 2002 by David Gravereaux.
 * Copyright (c) 2006 by Pat Thoyts
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * ----------------------------------------------------------------------------
 * RCS: @(#) $Id: nmakehlp.c,v 1.2 2009/01/22 14:36:58 patthoyts Exp $
 * ----------------------------------------------------------------------------
 */

#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
#define NO_SHLWAPI_GDI
#define NO_SHLWAPI_STREAM
#define NO_SHLWAPI_REG
#include <shlwapi.h>
#pragma comment (lib, "user32.lib")
#pragma comment (lib, "kernel32.lib")
#pragma comment (lib, "shlwapi.lib")
#include <stdio.h>
#include <math.h>

/*
 * This library is required for x64 builds with _some_ versions of MSVC
 */
#if defined(_M_IA64) || defined(_M_AMD64)
................................................................................
/* protos */

int		CheckForCompilerFeature(const char *option);
int		CheckForLinkerFeature(const char *option);
int		IsIn(const char *string, const char *substring);
int		GrepForDefine(const char *file, const char *string);
int		SubstituteFile(const char *substs, const char *filename);
int		QualifyPath(const char *path);
const char *    GetVersionFromFile(const char *filename, const char *match);
DWORD WINAPI	ReadFromPipe(LPVOID args);

/* globals */

#define CHUNK	25
#define STATICBUFFERSIZE    1000
................................................................................
		    argv[0]);
		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
		    &dwWritten, NULL);
		return 0;
	    }
	    printf("%s\n", GetVersionFromFile(argv[2], argv[3]));
	    return 0;
	case 'Q':
	    if (argc != 3) {
		chars = snprintf(msg, sizeof(msg) - 1,
		    "usage: %s -q path\n"
		    "Emit the fully qualified path\n"
		    "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
		    &dwWritten, NULL);
		return 2;
	    }
	    return QualifyPath(argv[2]);
	}
    }
    chars = snprintf(msg, sizeof(msg) - 1,
	    "usage: %s -c|-l|-f|-g|-V|-s|-Q ...\n"
	    "This is a little helper app to equalize shell differences between WinNT and\n"
	    "Win9x and get nmake.exe to accomplish its job.\n",
	    argv[0]);
    WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
    return 2;
}
 
................................................................................
	}
	
	list_free(&substPtr);
    }
    fclose(fp);
    return 0;
}
 
/*
 * QualifyPath --
 *
 *	This composes the current working directory with a provided path
 *	and returns the fully qualified and normalized path.
 *	Mostly needed to setup paths for testing.
 */

int
QualifyPath(
    const char *szPath)
{
    char szCwd[MAX_PATH + 1];
    char szTmp[MAX_PATH + 1];
    char *p;
    GetCurrentDirectory(MAX_PATH, szCwd);
    while ((p = strchr(szPath, '/')) && *p)
	*p = '\\';
    PathCombine(szTmp, szCwd, szPath);
    PathCanonicalize(szCwd, szTmp);
    printf("%s\n", szCwd);
    return 0;
}

/*
 * Local variables:
 *   mode: c
 *   c-basic-offset: 4
 *   fill-column: 78
 *   indent-tabs-mode: t
 *   tab-width: 8
 * End:
 */

Changes to win/rules.vc.

1
2
3
4
5
6
7
8
..
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
188
189
190
191
192
193
194


195
196
197
198
199
200
201
...
457
458
459
460
461
462
463
464
465
466
467




468
469
470
471
472
473
474
...
492
493
494
495
496
497
498

499





500
501
502
503






504
505





506














507







508
509






510

511
512
513
514
515
516
517




518
519

520
521
522
523
524
525
526




527
528
529
530
531
532
533
534
535
536
537


538

539
540
541
542
543
544
545
...
558
559
560
561
562
563
564

565
566
567

568



569
570

571


572




573
574
575




576

577
578
579
580
581

582
583
584
585

586
587
588
589
590
591
592
593

594

595
596






597
598

599
600
601
602
603
604
605
#------------------------------------------------------------------------------
# rules.vc --
#
#	Microsoft Visual C++ makefile include for decoding the commandline
#	macros.  This file does not need editing to build Tcl.
#
#	This version is modified from the Tcl source version to support
#	building extensions using nmake.
................................................................................
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 2001-2002 David Gravereaux.
# Copyright (c) 2003-2008 Patrick Thoyts
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: rules.vc,v 1.1 2008/04/30 15:18:56 patthoyts Exp $
#------------------------------------------------------------------------------

!ifndef _RULES_VC
_RULES_VC = 1

cc32		= $(CC)   # built-in default.
link32		= link
................................................................................
!else
### Fix the path separators.
_INSTALLDIR	= $(INSTALLDIR:/=\)
!endif

!ifndef MACHINE
!if "$(CPU)" == "" || "$(CPU)" == "i386"
MACHINE         = IX86
!else
MACHINE         = $(CPU)
!endif
!endif

!ifndef CFG_ENCODING
CFG_ENCODING	= \"cp1252\"
................................................................................
!message *** Compiler has 'Optimizations'
OPTIMIZING	= 1
!else
!message *** Compiler does not have 'Optimizations'
OPTIMIZING	= 0
!endif

OPTIMIZATIONS  =

!if [nmakehlp -c -Ot]
OPTIMIZATIONS  = $(OPTIMIZATIONS) -Ot
!endif

!if [nmakehlp -c -Oi]
OPTIMIZATIONS  = $(OPTIMIZATIONS) -Oi
................................................................................

_VC_MANIFEST_EMBED_EXE=
_VC_MANIFEST_EMBED_DLL=
VCVER=0
!if ![echo VCVERSION=_MSC_VER > vercl.x] \
    && ![cl -nologo -TC -P vercl.x $(ERRNULL)]
!include vercl.i


!if $(VCVERSION) >= 1500
VCVER=9
!elseif $(VCVERSION) >= 1400
VCVER=8
!elseif $(VCVERSION) >= 1300
VCVER=7
!elseif $(VCVERSION) >= 1200
................................................................................
!endif
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_DO64BIT
!endif


#----------------------------------------------------------
# Get common info used when building extensions.
#----------------------------------------------------------

!if "$(PROJECT)" != "tcl"





# If INSTALLDIR set to tcl root dir then reset to the lib dir.
!if exist("$(_INSTALLDIR)\include\tcl.h")
_INSTALLDIR=$(_INSTALLDIR)\lib
!endif

!if !defined(TCLDIR)
................................................................................
_TCL_H          = $(_TCLDIR)\generic\tcl.h
!else
MSG =^
Failed to find tcl.h.  The TCLDIR macro does not appear correct.
!error $(MSG)
!endif
!endif







!if [echo REM = This file is generated from rules.vc > version.vc]
!endif
!if exist("$(_TCL_H)")
!if [echo TCL_DOTVERSION = \>> version.vc] \






   && [nmakehlp -V "$(_TCL_H)" TCL_VERSION >> version.vc]
!endif





!endif














!include version.vc







TCL_VERSION	= $(TCL_DOTVERSION:.=)







!if $(TCLINSTALL)

TCLSH		= "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
!if !exist($(TCLSH)) && $(TCL_THREADS)
TCLSH           = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe"
!endif
TCLSTUBLIB	= "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
TCLIMPLIB	= "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
TCL_LIBRARY	= $(_TCLDIR)\lib




TCL_INCLUDES    = -I"$(_TCLDIR)\include"
!else

TCLSH		= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe"
!if !exist($(TCLSH)) && $(TCL_THREADS)
TCLSH		= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe"
!endif
TCLSTUBLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
TCLIMPLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
TCL_LIBRARY	= $(_TCLDIR)\library




TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
!endif

!endif

#----------------------------------------------------------
# Optionally check for Tk info for building extensions.
#----------------------------------------------------------

!ifdef PROJECT_REQUIRES_TK
!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"




!if !defined(TKDIR)
!if exist("$(_INSTALLDIR)\..\include\tk.h")
TKINSTALL      = 1
_TKDIR         = $(_INSTALLDIR)\..
_TK_H          = $(_TKDIR)\include\tk.h
TKDIR          = $(_TKDIR)
!elseif exist("$(_TCLDIR)\include\tk.h")
................................................................................
_TK_H          = $(_TKDIR)\generic\tk.h
!else
MSG =^
Failed to find tk.h. The TKDIR macro does not appear correct.
!error $(MSG)
!endif
!endif


!if defined(TKDIR)
TK_DOTVERSION = 8.4

!if exist("$(_TK_H)")



!if [echo TK_DOTVERSION = \>> version.vc] \
   && [nmakehlp -V "$(_TK_H)" TK_VERSION >> version.vc]

!endif


!endif




!include version.vc
TK_VERSION = $(TK_DOTVERSION:.=)





!if $(TKINSTALL)

WISH		= "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe"
!if !exist($(WISH)) && $(TCL_THREADS)
WISH		= "$(_TKDIR)\bin\wish$(TK_VERSION)t$(SUFX).exe"
!endif
TKSTUBLIB	= "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"

TKIMPLIB	= "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
TK_INCLUDES     = -I"$(_TKDIR)\include"
TK_LIBRARY	= $(_TKDIR)\lib
!else

WISH		= "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe"
!if !exist($(WISH)) && $(TCL_THREADS)
WISH		= "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)t$(SUFX).exe"
!endif
TKSTUBLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
TKIMPLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"
TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
TK_LIBRARY	= $(_TKDIR)\library

!endif


!endif






!endif
!endif


#----------------------------------------------------------
# Display stats being used.
#----------------------------------------------------------

!message *** Intermediate directory will be '$(TMP_DIR)'
!message *** Output directory will be '$(OUT_DIR)'
|







 







|







 







|







 







|







 







>
>







 







|


|
>
>
>
>







 







>

>
>
>
>
>
|

<
|
>
>
>
>
>
>
|

>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
|

>
>
>
>
>
>

>
|

|




>
>
>
>


>
|

|




>
>
>
>





|
|
|

<
|
>
>

>







 







>

<
<
>
|
>
>
>
|
<
>

>
>

>
>
>
>
|
<

>
>
>
>

>
|

|


>


<

>
|

|



<

>

>


>
>
>
>
>
>

<
>







1
2
3
4
5
6
7
8
..
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
...
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
...
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513

514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594

595
596
597
598
599
600
601
602
603
604
605
606
...
619
620
621
622
623
624
625
626
627


628
629
630
631
632
633

634
635
636
637
638
639
640
641
642
643

644
645
646
647
648
649
650
651
652
653
654
655
656
657
658

659
660
661
662
663
664
665
666

667
668
669
670
671
672
673
674
675
676
677
678
679

680
681
682
683
684
685
686
687
#------------------------------------------------------------- -*- Makefile -*-
# rules.vc --
#
#	Microsoft Visual C++ makefile include for decoding the commandline
#	macros.  This file does not need editing to build Tcl.
#
#	This version is modified from the Tcl source version to support
#	building extensions using nmake.
................................................................................
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 2001-2002 David Gravereaux.
# Copyright (c) 2003-2008 Patrick Thoyts
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: rules.vc,v 1.2 2009/01/22 14:36:58 patthoyts Exp $
#------------------------------------------------------------------------------

!ifndef _RULES_VC
_RULES_VC = 1

cc32		= $(CC)   # built-in default.
link32		= link
................................................................................
!else
### Fix the path separators.
_INSTALLDIR	= $(INSTALLDIR:/=\)
!endif

!ifndef MACHINE
!if "$(CPU)" == "" || "$(CPU)" == "i386"
MACHINE		= IX86
!else
MACHINE         = $(CPU)
!endif
!endif

!ifndef CFG_ENCODING
CFG_ENCODING	= \"cp1252\"
................................................................................
!message *** Compiler has 'Optimizations'
OPTIMIZING	= 1
!else
!message *** Compiler does not have 'Optimizations'
OPTIMIZING	= 0
!endif

OPTIMIZATIONS   =

!if [nmakehlp -c -Ot]
OPTIMIZATIONS  = $(OPTIMIZATIONS) -Ot
!endif

!if [nmakehlp -c -Oi]
OPTIMIZATIONS  = $(OPTIMIZATIONS) -Oi
................................................................................

_VC_MANIFEST_EMBED_EXE=
_VC_MANIFEST_EMBED_DLL=
VCVER=0
!if ![echo VCVERSION=_MSC_VER > vercl.x] \
    && ![cl -nologo -TC -P vercl.x $(ERRNULL)]
!include vercl.i
!if ![del /q vercl.x vercl.i $(ERRNULL)]
!endif
!if $(VCVERSION) >= 1500
VCVER=9
!elseif $(VCVERSION) >= 1400
VCVER=8
!elseif $(VCVERSION) >= 1300
VCVER=7
!elseif $(VCVERSION) >= 1200
................................................................................
!endif
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_DO64BIT
!endif


#----------------------------------------------------------
# Locate the Tcl headers to build against
#----------------------------------------------------------

!if "$(PROJECT)" == "tcl"

_TCL_H          = ..\generic\tcl.h

!else

# If INSTALLDIR set to tcl root dir then reset to the lib dir.
!if exist("$(_INSTALLDIR)\include\tcl.h")
_INSTALLDIR=$(_INSTALLDIR)\lib
!endif

!if !defined(TCLDIR)
................................................................................
_TCL_H          = $(_TCLDIR)\generic\tcl.h
!else
MSG =^
Failed to find tcl.h.  The TCLDIR macro does not appear correct.
!error $(MSG)
!endif
!endif
!endif

#--------------------------------------------------------------
# Extract various version numbers from tcl headers
# The generated file is then included in the makefile.
#--------------------------------------------------------------

!if [echo REM = This file is generated from rules.vc > versions.vc]
!endif

!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
   && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
!endif
!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
   && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
!endif
!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
   && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
!endif

# If building the tcl core then we need additional package versions
!if "$(PROJECT)" == "tcl"
!if [echo PKG_HTTP_VER = \>> versions.vc] \
   && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc]
!endif
!if [echo PKG_TCLTEST_VER = \>> versions.vc] \
   && [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc]
!endif
!if [echo PKG_MSGCAT_VER = \>> versions.vc] \
   && [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc]
!endif
!if [echo PKG_PLATFORM_VER = \>> versions.vc] \
   && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc]
!endif
!if [echo PKG_SHELL_VER = \>> versions.vc] \
   && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc]
!endif
!endif

!include versions.vc

#--------------------------------------------------------------
# Setup tcl version dependent stuff headers
#--------------------------------------------------------------

!if "$(PROJECT)" != "tcl"

TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)

!if $(TCL_VERSION) < 81
TCL_DOES_STUBS	= 0
!else
TCL_DOES_STUBS	= 1
!endif

!if $(TCLINSTALL)
_TCLBINDIR      = "$(_TCLDIR)\bin"
TCLSH		= "$(_TCLBINDIR)\tclsh$(TCL_VERSION)$(SUFX).exe"
!if !exist($(TCLSH)) && $(TCL_THREADS)
TCLSH           = "$(_TCLBINDIR)\tclsh$(TCL_VERSION)t$(SUFX).exe"
!endif
TCLSTUBLIB	= "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
TCLIMPLIB	= "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
TCL_LIBRARY	= $(_TCLDIR)\lib
TCLREGLIB	= "$(_TCLDIR)\lib\tclreg11$(SUFX:t=).lib"
TCLDDELIB	= "$(_TCLDIR)\lib\tcldde12$(SUFX:t=).lib"
COFFBASE	= \must\have\tcl\sources\to\build\this\target
TCLTOOLSDIR	= \must\have\tcl\sources\to\build\this\target
TCL_INCLUDES    = -I"$(_TCLDIR)\include"
!else
_TCLBINDIR      = $(_TCLDIR)\win\$(BUILDDIRTOP)
TCLSH		= "$(_TCLBINDIR)\tclsh$(TCL_VERSION)$(SUFX).exe"
!if !exist($(TCLSH)) && $(TCL_THREADS)
TCLSH		= "$(_TCLBINDIR)\tclsh$(TCL_VERSION)t$(SUFX).exe"
!endif
TCLSTUBLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
TCLIMPLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
TCL_LIBRARY	= $(_TCLDIR)\library
TCLREGLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg11$(SUFX:t=).lib"
TCLDDELIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde12$(SUFX:t=).lib"
COFFBASE	= "$(_TCLDIR)\win\coffbase.txt"
TCLTOOLSDIR	= $(_TCLDIR)\tools
TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
!endif

!endif

#-------------------------------------------------------------------------
# Locate the Tk headers to build against
#-------------------------------------------------------------------------


!if "$(PROJECT)" == "tk"
_TK_H          = ..\generic\tk.h
!endif

!ifdef PROJECT_REQUIRES_TK
!if !defined(TKDIR)
!if exist("$(_INSTALLDIR)\..\include\tk.h")
TKINSTALL      = 1
_TKDIR         = $(_INSTALLDIR)\..
_TK_H          = $(_TKDIR)\include\tk.h
TKDIR          = $(_TKDIR)
!elseif exist("$(_TCLDIR)\include\tk.h")
................................................................................
_TK_H          = $(_TKDIR)\generic\tk.h
!else
MSG =^
Failed to find tk.h. The TKDIR macro does not appear correct.
!error $(MSG)
!endif
!endif
!endif



#-------------------------------------------------------------------------
# Extract Tk version numbers
#-------------------------------------------------------------------------

!if defined(PROJECT_REQUIRES_TK) || "$(PROJECT)" == "tk"
!if [echo TK_MAJOR_VERSION = \>> versions.vc] \

   && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
!endif
!if [echo TK_MINOR_VERSION = \>> versions.vc] \
   && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
!endif
!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
   && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
!endif

!include versions.vc


TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)

!if "$(PROJECT)" != "tk"
!if $(TKINSTALL)
_TKBINDIR       = $(_TKDIR)\bin
WISH		= "$(_TKBINDIR)\wish$(TK_VERSION)$(SUFX).exe"
!if !exist($(WISH)) && $(TCL_THREADS)
WISH		= "$(_TKBINDIR)\wish$(TK_VERSION)t$(SUFX).exe"
!endif
TKSTUBLIB	= "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"
TK_LIBRARY	= $(_TKDIR)\lib
TKIMPLIB	= "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
TK_INCLUDES     = -I"$(_TKDIR)\include"

!else
_TKBINDIR       = $(_TKDIR)\win\$(BUILDDIRTOP)
WISH		= "$(_TKBINDIR)\wish$(TCL_VERSION)$(SUFX).exe"
!if !exist($(WISH)) && $(TCL_THREADS)
WISH		= "$(_TKBINDIR)\wish$(TCL_VERSION)t$(SUFX).exe"
!endif
TKSTUBLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
TKIMPLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"

TK_LIBRARY	= $(_TKDIR)\library
TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
!endif
!endif

!endif

#----------------------------------------------------------
# Setup the fully qualified OUT_DIR path as OUT_DIR_PATH
#----------------------------------------------------------
!if [echo OUT_DIR_PATH = \>> versions.vc] \
    && [nmakehlp -Q "$(OUT_DIR)" >> versions.vc]
!endif

!include versions.vc

#----------------------------------------------------------
# Display stats being used.
#----------------------------------------------------------

!message *** Intermediate directory will be '$(TMP_DIR)'
!message *** Output directory will be '$(OUT_DIR)'