Tcl Library Source Code

Changes On Branch tkt-c974e352d2-ak
Login

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

Changes In Branch tkt-c974e352d2-ak Excluding Merge-Ins

This is equivalent to a diff from 0e381eadd7 to b27e9f8077

2017-05-29
22:24
Merged json fixes check-in: dbdaf3dff4 user: aku tags: trunk
22:23
Extended the token regexp with special cases for partial numbers (no leading cardinal, no fraction), with other parts becoming mandatory. This fixes mismatching and misconversion of numbers like "1." and ".1". Added tests for these cases. Closed-Leaf check-in: b27e9f8077 user: aku tags: tkt-c974e352d2-ak
20:56
Manually applied the patch from the ticket. Further some cleanup and simplification (Use 8.5 features (lassign, {*})) Closed-Leaf check-in: a0ec57b1bd user: aku tags: tkt-8fd2561785-ak
19:34
Added "Jacobi symbol" to numtheory package and corrected the minimum Tcl version for the geometry package. (Still need to check what the failures with Tcl 8.5 are all about) check-in: 0e381eadd7 user: arjenmarkus tags: trunk
19:05
Ticket 214986cedd: Reworked documentation of splitx to describe the handling of capture groups better. check-in: 0512fb6a9e user: aku tags: trunk

Changes to modules/json/json.man.

1
2
3
4
5
6
7
8
9
[comment {-*- tcl -*- doctools manpage}]
[vset VERSION 1.3.3]
[manpage_begin json n [vset VERSION]]
[keywords {data exchange}]
[keywords {exchange format}]
[keywords javascript]
[keywords json]
[copyright {2006 ActiveState Software Inc.}]
[copyright {2009 Thomas Maeder, Glue Software Engineering AG}]

|







1
2
3
4
5
6
7
8
9
[comment {-*- tcl -*- doctools manpage}]
[vset VERSION 1.3.4]
[manpage_begin json n [vset VERSION]]
[keywords {data exchange}]
[keywords {exchange format}]
[keywords javascript]
[keywords json]
[copyright {2006 ActiveState Software Inc.}]
[copyright {2009 Thomas Maeder, Glue Software Engineering AG}]

Changes to modules/json/json.tcl.

215
216
217
218
219
220
221
222




223
224
225
226
227
228
229
230
231
232
233
234
    # number tokens
    # negative lookahead (?!0)[[:digit:]]+ might be more elegant, but
    # would slow down tokenizing by a factor of up to 3!
    variable positiveRE {[1-9][[:digit:]]*}
    variable cardinalRE "-?(?:$positiveRE|0)"
    variable fractionRE {[.][[:digit:]]+}
    variable exponentialRE {[eE][+-]?[[:digit:]]+}
    variable numberRE "${cardinalRE}(?:$fractionRE)?(?:$exponentialRE)?"





    # JSON token, and validation
    variable tokenRE "$singleCharTokenRE|$stringRE|$wordTokenRE|$numberRE"
    variable tokenREv "$singleCharTokenRE|$stringREv|$wordTokenRE|$numberRE"


    # 0..n white space characters
    set whiteSpaceRE {[[:space:]]*}

    # Regular expression for validating a JSON text
    variable validJsonRE "^(?:${whiteSpaceRE}(?:$tokenREv))*${whiteSpaceRE}$"
}







|
>
>
>
>




<







215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230

231
232
233
234
235
236
237
    # number tokens
    # negative lookahead (?!0)[[:digit:]]+ might be more elegant, but
    # would slow down tokenizing by a factor of up to 3!
    variable positiveRE {[1-9][[:digit:]]*}
    variable cardinalRE "-?(?:$positiveRE|0)"
    variable fractionRE {[.][[:digit:]]+}
    variable exponentialRE {[eE][+-]?[[:digit:]]+}
    variable numberREa "${cardinalRE}(?:$fractionRE)?(?:$exponentialRE)?"
    variable numberREb "${fractionRE}(?:$exponentialRE)?"
    variable numberREc "${cardinalRE}\[.\](?:$exponentialRE)?"
    variable numberRE  "$numberREa|$numberREb|$numberREc"
    variable numberRE  "$numberREa|$numberREb|$numberREc"

    # JSON token, and validation
    variable tokenRE "$singleCharTokenRE|$stringRE|$wordTokenRE|$numberRE"
    variable tokenREv "$singleCharTokenRE|$stringREv|$wordTokenRE|$numberRE"


    # 0..n white space characters
    set whiteSpaceRE {[[:space:]]*}

    # Regular expression for validating a JSON text
    variable validJsonRE "^(?:${whiteSpaceRE}(?:$tokenREv))*${whiteSpaceRE}$"
}
275
276
277
278
279
280
281
282
proc ::json::string2json {str} {
    return "\"$str\""
}

# ### ### ### ######### ######### #########
## Ready

package provide json 1.3.3







|
278
279
280
281
282
283
284
285
proc ::json::string2json {str} {
    return "\"$str\""
}

# ### ### ### ######### ######### #########
## Ready

package provide json 1.3.4

Changes to modules/json/json_tcl.tcl.

19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
proc ::json::json2dict_tcl {jsonText} {
    variable tokenRE

    set tokens [regexp -all -inline -- $tokenRE $jsonText]
    set nrTokens [llength $tokens]
    set tokenCursor 0


#puts T:\t[join $tokens \nT:\t]
    return [parseValue $tokens $nrTokens tokenCursor]
}

# Parse multiple JSON entities in a string into a list of dictionaries
# @param jsonText JSON text to parse
# @param max      Max number of entities to extract.
# @return list of (dict (or list) containing the objects) represented by $jsonText







>
|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
proc ::json::json2dict_tcl {jsonText} {
    variable tokenRE

    set tokens [regexp -all -inline -- $tokenRE $jsonText]
    set nrTokens [llength $tokens]
    set tokenCursor 0

    #puts I:($jsonText)
    #puts T:\t[join $tokens \nT:\t]
    return [parseValue $tokens $nrTokens tokenCursor]
}

# Parse multiple JSON entities in a string into a list of dictionaries
# @param jsonText JSON text to parse
# @param max      Max number of entities to extract.
# @return list of (dict (or list) containing the objects) represented by $jsonText

Changes to modules/json/pkgIndex.tcl.

1
2
3
4
5
6
7
# Tcl package index file, version 1.1

if {![package vsatisfies [package provide Tcl] 8.4]} {return}
package ifneeded json 1.3.3 [list source [file join $dir json.tcl]]

if {![package vsatisfies [package provide Tcl] 8.5]} {return}
package ifneeded json::write 1.0.3 [list source [file join $dir json_write.tcl]]



|



1
2
3
4
5
6
7
# Tcl package index file, version 1.1

if {![package vsatisfies [package provide Tcl] 8.4]} {return}
package ifneeded json 1.3.4 [list source [file join $dir json.tcl]]

if {![package vsatisfies [package provide Tcl] 8.5]} {return}
package ifneeded json::write 1.0.3 [list source [file join $dir json_write.tcl]]

Changes to modules/json/tests/support.tcl.

80
81
82
83
84
85
86









87
88
89
90
91
92
93
94

set JSON(emptyList4) {[[]]}
set  TCL(emptyList4) {{}}

set JSON(escapes) {"\t\r\n\f\b\/\\\""}
set  TCL(escapes) "\t\r\n\f\b/\\\""












foreach f [TestFilesGlob tests/*.fail] {
    set name [file rootname [file tail $f]]
    set FAIL($name) [tcltest::viewFile $f]
}

foreach f [TestFilesGlob tests/*.err] {







>
>
>
>
>
>
>
>
>
|







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

set JSON(emptyList4) {[[]]}
set  TCL(emptyList4) {{}}

set JSON(escapes) {"\t\r\n\f\b\/\\\""}
set  TCL(escapes) "\t\r\n\f\b/\\\""

foreach {label json tcl} {
    fp1.1  1.1  1.1
    fp1.   1.   1.
    fp.1   .1   .1
    fp0.1  0.1  0.1
    fp1    1    1
} {
    set JSON($label) $json
    set TCL($label) $tcl
}

foreach f [TestFilesGlob tests/*.fail] {
    set name [file rootname [file tail $f]]
    set FAIL($name) [tcltest::viewFile $f]
}

foreach f [TestFilesGlob tests/*.err] {