Tcl Library Source Code

Changes On Branch tkt-39ab616d8f-ak
Login

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

Changes In Branch tkt-39ab616d8f-ak Excluding Merge-Ins

This is equivalent to a diff from 4500808784 to 1a871993e4

2017-05-29
17:17
Merged last bit from ticket branch. Final. check-in: e1f5469305 user: aku tags: trunk
17:16
Added another test to validate the the Critcl implementation is truly ok. Closed-Leaf check-in: 1a871993e4 user: aku tags: tkt-39ab616d8f-ak
17:05
Merged fix for ticket 39ab616d8f (struct::graph dfs pre walk multi-entry issue) check-in: 89bf85ed39 user: aku tags: trunk
17:03
Version of struct::graph bumped to 2.4.1. check-in: db54ffb154 user: aku tags: tkt-39ab616d8f-ak
16:32
Work on ticket [39ab616d8f]. Created tests case from the given exmaple. Confirmed issue for Tcl implementation. Critcl implementation OTOH is ok. check-in: 1c69e62ccb user: aku tags: tkt-39ab616d8f-ak
2017-05-28
21:00
Fix ldap TLS options Fixes [Ticket 7cf9323d38af6cf4e074ec10f6f15ad4c4e1fdf1] check-in: 4500808784 user: schlenk tags: trunk
15:26
Add several procedures to the math::numtheory package, such factorising a number and estimating the number of primes up to a certain size. Package version now 1.1 check-in: cd42b3ddf8 user: arjenmarkus tags: trunk

Changes to modules/md5/md5x.tcl.

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
    set pad [expr {56 - ($len % 64)}]
    if {$len % 64 > 56} {
        incr pad 64
    }
    if {$pad == 0} {
        incr pad 64
    }



    append state(i) [binary format a$pad \x80]

    # RFC1321:3.2 - Append length in bits as little-endian wide int.
    append state(i) [binary format ii [expr {8 * $state(n)}] 0]



    # Calculate the hash for the remaining block.
    set len [string length $state(i)]
    for {set n 0} {($n + 64) <= $len} {} {
        MD5Hash $token [string range $state(i) $n [incr n 64]]
    }




    # RFC1321:3.5 - Output
    set r [bytes $state(A)][bytes $state(B)][bytes $state(C)][bytes $state(D)]
    unset state


    return $r
}

# -------------------------------------------------------------------------
# HMAC Hashed Message Authentication (RFC 2104)
#
# hmac = H(K xor opad, H(K xor ipad, text))







>
>
>




>
>






>
>
>




>
>







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
    set pad [expr {56 - ($len % 64)}]
    if {$len % 64 > 56} {
        incr pad 64
    }
    if {$pad == 0} {
        incr pad 64
    }

    puts "P $pad|bits=[expr {8 * $state(n)}]"

    append state(i) [binary format a$pad \x80]

    # RFC1321:3.2 - Append length in bits as little-endian wide int.
    append state(i) [binary format ii [expr {8 * $state(n)}] 0]

puts DATA=[Hex $state(i)]([string length $state(i)])

    # Calculate the hash for the remaining block.
    set len [string length $state(i)]
    for {set n 0} {($n + 64) <= $len} {} {
        MD5Hash $token [string range $state(i) $n [incr n 64]]
    }

    puts md5-post__________________________________________
    parray ::${token}

    # RFC1321:3.5 - Output
    set r [bytes $state(A)][bytes $state(B)][bytes $state(C)][bytes $state(D)]
    unset state

    puts HASH=[Hex $r]
    return $r
}

# -------------------------------------------------------------------------
# HMAC Hashed Message Authentication (RFC 2104)
#
# hmac = H(K xor opad, H(K xor ipad, text))
253
254
255
256
257
258
259


260
261
262
263


264
265
266
267
268
269
270
# Note:
#  This function body is substituted later on to inline some of the 
#  procedures and to make is a bit more comprehensible.
#
set ::md5::MD5Hash_body {
    variable $token
    upvar 0 $token state



    # RFC1321:3.4 - Process Message in 16-Word Blocks
    binary scan $msg i* blocks
    foreach {X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15} $blocks {


        set A $state(A)
        set B $state(B)
        set C $state(C)
        set D $state(D)

        # Round 1
        # Let [abcd k s i] denote the operation







>
>




>
>







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# Note:
#  This function body is substituted later on to inline some of the 
#  procedures and to make is a bit more comprehensible.
#
set ::md5::MD5Hash_body {
    variable $token
    upvar 0 $token state

    puts TR__=[Hex $msg]([string length $msg])

    # RFC1321:3.4 - Process Message in 16-Word Blocks
    binary scan $msg i* blocks
    foreach {X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15} $blocks {
        puts BL

        set A $state(A)
        set B $state(B)
        set C $state(C)
        set D $state(D)

        # Round 1
        # Let [abcd k s i] denote the operation
598
599
600
601
602
603
604





605




606
607
608
609
610
611
612
    if {$opts(-channel) == {}} {

        if {[llength $args] != 1} {
            return -code error "wrong # args:\
                should be \"md5 ?-hex? -filename file | string\""
        }
        set tok [MD5Init]





        MD5Update $tok [lindex $args 0]




        set r [MD5Final $tok]

    } else {

        set tok [MD5Init]
        # FRINK: nocheck
        set [subst $tok](reading) 1







>
>
>
>
>

>
>
>
>







612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
    if {$opts(-channel) == {}} {

        if {[llength $args] != 1} {
            return -code error "wrong # args:\
                should be \"md5 ?-hex? -filename file | string\""
        }
        set tok [MD5Init]

        puts md5_______________________________________________
        parray ::${tok}

        puts IN=(([lindex $args 0]))
        MD5Update $tok [lindex $args 0]

        puts md5-final_________________________________________
        parray ::${tok}

        set r [MD5Final $tok]

    } else {

        set tok [MD5Init]
        # FRINK: nocheck
        set [subst $tok](reading) 1

Changes to modules/md5/md5x.test.

93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
    "F96B697D7CB7938D525A2F31AAF161D0"
    5    "abcdefghijklmnopqrstuvwxyz"
    "C3FCD3D76192E4007DFB496CCA67E13B"
    6    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    "D174AB98D277D9F5A5611C2C9F419D9F"
    7    "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
    "57EDF4A22BE3C955AC49DA2E2107B67A"

    8    "a\$apr1\$a" "020C3DD6931F7E94ECC99A1F4E4C53E2"
}
foreach impl [implementations] {
    select_implementation $impl
    foreach {n msg expected} $tests {
        test md5-v2-$impl-2.$n "md5 ($impl impl)" {
            list [catch {::md5::md5 -hex -- $msg} msg] $msg
        } [list 0 $expected]







>
|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    "F96B697D7CB7938D525A2F31AAF161D0"
    5    "abcdefghijklmnopqrstuvwxyz"
    "C3FCD3D76192E4007DFB496CCA67E13B"
    6    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    "D174AB98D277D9F5A5611C2C9F419D9F"
    7    "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
    "57EDF4A22BE3C955AC49DA2E2107B67A"
    8    "a\$apr1\$a"
    "020C3DD6931F7E94ECC99A1F4E4C53E2"
}
foreach impl [implementations] {
    select_implementation $impl
    foreach {n msg expected} $tests {
        test md5-v2-$impl-2.$n "md5 ($impl impl)" {
            list [catch {::md5::md5 -hex -- $msg} msg] $msg
        } [list 0 $expected]

Changes to modules/struct/graph.man.

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
[comment {-*- tcl -*-}]
[manpage_begin struct::graph n 2.4]
[keywords adjacent]
[keywords arc]
[keywords cgraph]
[keywords degree]
[keywords edge]
[keywords graph]
[keywords loop]
[keywords neighbour]
[keywords node]
[keywords serialization]
[keywords subgraph]
[keywords vertex]
[copyright {2002-2009 Andreas Kupries <[email protected]>}]
[moddesc   {Tcl Data Structures}]
[titledesc {Create and manipulate directed graph objects}]
[category  {Data structures}]
[require Tcl 8.4]
[require struct::graph [opt 2.4]]
[require struct::list  [opt 1.5]]
[require struct::set   [opt 2.2.3]]
[description]
[para]

A directed graph is a structure containing two collections of
elements, called [term nodes] and [term arcs] respectively, together
|
|

















|







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
[comment {-*- tcl -*-}][vset VERSION 2.4.1]
[manpage_begin struct::graph n [vset VERSION]]
[keywords adjacent]
[keywords arc]
[keywords cgraph]
[keywords degree]
[keywords edge]
[keywords graph]
[keywords loop]
[keywords neighbour]
[keywords node]
[keywords serialization]
[keywords subgraph]
[keywords vertex]
[copyright {2002-2009 Andreas Kupries <[email protected]>}]
[moddesc   {Tcl Data Structures}]
[titledesc {Create and manipulate directed graph objects}]
[category  {Data structures}]
[require Tcl 8.4]
[require struct::graph [opt  [vset VERSION]]]
[require struct::list  [opt 1.5]]
[require struct::set   [opt 2.2.3]]
[description]
[para]

A directed graph is a structure containing two collections of
elements, called [term nodes] and [term arcs] respectively, together

Changes to modules/struct/graph.tcl.

173
174
175
176
177
178
179
180
## Ready

namespace eval ::struct {
    # Export the constructor command.
    namespace export graph
}

package provide struct::graph 2.4







|
173
174
175
176
177
178
179
180
## Ready

namespace eval ::struct {
    # Export the constructor command.
    namespace export graph
}

package provide struct::graph 2.4.1

Changes to modules/struct/graph.test.

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
# -*- tcl -*-
# graph.test:  tests for the graph structure.
#
# 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) 1998-2000 by Ajuba Solutions.

# All rights reserved.
#
# RCS: @(#) $Id: graph.test,v 1.27 2007/04/12 03:01:54 andreas_kupries Exp $

# -------------------------------------------------------------------------

source [file join \








>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- tcl -*-
# graph.test:  tests for the graph structure.
#
# 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) 1998-2000 by Ajuba Solutions.
# Copyright (c) 2017-2017 Andreas Kupries
# All rights reserved.
#
# RCS: @(#) $Id: graph.test,v 1.27 2007/04/12 03:01:54 andreas_kupries Exp $

# -------------------------------------------------------------------------

source [file join \

Changes to modules/struct/graph/tests/walk.test.

1
2
3
4
5
6
7
8
9
10
11
12
# -*- tcl -*-
# Graph tests - walk
# Copyright (c) 2006 Andreas Kupries <[email protected]>
# All rights reserved.
# RCS: @(#) $Id: walk.test,v 1.3 2008/12/13 03:57:33 andreas_kupries Exp $

# Syntax: graph walk NODE ?-dir forward|backward? ?-order pre|post|both? ?-type bfs|dfs? -command cmd

# -------------------------------------------------------------------------
# Wrong # args: Missing, Too many

test graph-${impl}-${setimpl}-walk-1.0 {walk, wrong#args, missing} {} {


|

<







1
2
3
4

5
6
7
8
9
10
11
# -*- tcl -*-
# Graph tests - walk
# Copyright (c) 2006-2017 Andreas Kupries <[email protected]>
# All rights reserved.


# Syntax: graph walk NODE ?-dir forward|backward? ?-order pre|post|both? ?-type bfs|dfs? -command cmd

# -------------------------------------------------------------------------
# Wrong # args: Missing, Too many

test graph-${impl}-${setimpl}-walk-1.0 {walk, wrong#args, missing} {} {
195
196
197
198
199
200
201













































202
203
204
205
206
207
    SETUPwalk
    set t [list ]
    mygraph walk ix -dir backward -order both -command record
    mygraph destroy
    set t
} [tmE  {enter ix enter i enter viii enter vi enter v enter iv enter iii enter ii leave ii leave iii leave iv leave v enter vii leave vii leave vi leave viii leave i leave ix} \
	{enter ix enter i enter viii enter vi enter vii leave vii enter v enter iv enter iii enter ii leave ii leave iii leave iv leave v leave vi leave viii leave i leave ix}]














































# -------------------------------------------------------------------------

rename record {}

# -------------------------------------------------------------------------







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






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
    SETUPwalk
    set t [list ]
    mygraph walk ix -dir backward -order both -command record
    mygraph destroy
    set t
} [tmE  {enter ix enter i enter viii enter vi enter v enter iv enter iii enter ii leave ii leave iii leave iv leave v enter vii leave vii leave vi leave viii leave i leave ix} \
	{enter ix enter i enter viii enter vi enter vii leave vii enter v enter iv enter iii enter ii leave ii leave iii leave iv leave v leave vi leave viii leave i leave ix}]

# -------------------------------------------------------------------------

test graph-${impl}-${setimpl}-tkt.39ab616d8f-walk-4.0 {Ticket 39ab616d8f, dfs pre-order} -setup {
    SETUP
    mygraph node insert a
    mygraph node insert b
    mygraph node insert c
    mygraph arc insert a b ab
    mygraph arc insert b c bc
    mygraph arc insert a c ac
    #  /-> b -\
    # a -----> c
    set t {}    
} -body {
    mygraph walk a -command record -dir forward -order pre -type dfs
    set t
} -cleanup {
    mygraph destroy
    unset t
} -result [tmE {enter a enter b enter c} {enter a enter c enter b}]

test graph-${impl}-${setimpl}-tkt.39ab616d8f-walk-4.1 {Ticket 39ab616d8f, dfs pre-order} -setup {
    # This is like 4.0, with arcs ab, ac inserted in reverse
    # order. This forces the Critcl implementation into the same
    # situation as 4.0 does for Tcl, having c in the work stack as
    # neighbour of a and then getting visited from b before reahed
    # again. Passes.
    SETUP
    mygraph node insert a
    mygraph node insert b
    mygraph node insert c
    mygraph arc insert a c ac
    mygraph arc insert a b ab
    mygraph arc insert b c bc
    #  /-> b -\
    # a -----> c
    set t {}    
} -body {
    mygraph walk a -command record -dir forward -order pre -type dfs
    set t
} -cleanup {
    mygraph destroy
    unset t
} -result [tmE {enter a enter c enter b} {enter a enter b enter c}]

# -------------------------------------------------------------------------

rename record {}

# -------------------------------------------------------------------------

Changes to modules/struct/graph_tcl.tcl.

2763
2764
2765
2766
2767
2768
2769




2770
2771
2772
2773
2774
2775
2776
	if { [string equal $order "pre"] } {
	    # Pre-order Depth-first search

	    while { [llength $st] > 0 } {
		set node [lindex   $st end]
		ldelete st end





		# Evaluate the command at this node
		set cmdcpy $cmd
		lappend cmdcpy enter $name $node
		uplevel 1 $cmdcpy

		set visited($node) .








>
>
>
>







2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
	if { [string equal $order "pre"] } {
	    # Pre-order Depth-first search

	    while { [llength $st] > 0 } {
		set node [lindex   $st end]
		ldelete st end

		# Skip all nodes already visited via some other path
		# through the graph.
		if {[info exists visited($node)]} continue
		
		# Evaluate the command at this node
		set cmdcpy $cmd
		lappend cmdcpy enter $name $node
		uplevel 1 $cmdcpy

		set visited($node) .

Changes to modules/struct/pkgIndex.tcl.

15
16
17
18
19
20
21
22
23

package ifneeded struct::graph     1.2.1 [list source [file join $dir graph1.tcl]]
package ifneeded struct::tree      1.2.2 [list source [file join $dir tree1.tcl]]
package ifneeded struct::matrix    1.2.1 [list source [file join $dir matrix1.tcl]]

if {![package vsatisfies [package provide Tcl] 8.4]} {return}
package ifneeded struct::list      1.8.3  [list source [file join $dir list.tcl]]
package ifneeded struct::graph     2.4    [list source [file join $dir graph.tcl]]
package ifneeded struct::graph::op 0.11.3 [list source [file join $dir graphops.tcl]]







|

15
16
17
18
19
20
21
22
23

package ifneeded struct::graph     1.2.1 [list source [file join $dir graph1.tcl]]
package ifneeded struct::tree      1.2.2 [list source [file join $dir tree1.tcl]]
package ifneeded struct::matrix    1.2.1 [list source [file join $dir matrix1.tcl]]

if {![package vsatisfies [package provide Tcl] 8.4]} {return}
package ifneeded struct::list      1.8.3  [list source [file join $dir list.tcl]]
package ifneeded struct::graph     2.4.1  [list source [file join $dir graph.tcl]]
package ifneeded struct::graph::op 0.11.3 [list source [file join $dir graphops.tcl]]