Diff
Not logged in

Differences From Artifact [f1f60ad114]:

To Artifact [d47b6c9f84]:


9342
9343
9344
9345
9346
9347
9348
9349

9350
9351
9352
9353
9354
9355

9356
9357
9358
9359
9360
9361
9362
9342
9343
9344
9345
9346
9347
9348

9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363







-
+






+







	invalid or incomplete multibyte or wide character}}


test io-75.6.gets {invalid utf-8 encoding, gets is not ignored (-profile strict)} -setup {
    set fn [makeFile {} io-75.6]
    set f [open $fn w+]
    fconfigure $f -encoding binary
    # \x81 is invalid in utf-8
    # \x81 is an incomplete byte sequence in utf-8
    puts -nonewline $f A\x81
    flush $f
    seek $f 0
    fconfigure $f -encoding utf-8 -buffering none -eofchar {} \
	-translation lf -profile strict
} -body {
after 1
    gets $f
} -cleanup {
    close $f
    removeFile io-75.6
} -match glob -returnCodes 1 -result {error reading "file*":\
	invalid or incomplete multibyte or wide character}

9678
9679
9680
9681
9682
9683
9684
9685
9686

9687
9688
9689


9690
9691
9692
9693
9694

9695
9696
9697
9698
9699
9700
9701
9702


































9703
9704
9705
9706



9707
9708
9709
9710
9711
9712
9713
9679
9680
9681
9682
9683
9684
9685


9686
9687


9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702

9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737



9738
9739
9740
9741
9742
9743
9744
9745
9746
9747







-
-
+

-
-
+
+





+







-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
+
+
+







    invalid or incomplete multibyte or wide character}}

test io-75.14 {
	[gets] succesfully returns lines prior to error

	invalid utf-8 encoding [gets] continues in non-strict mode after error
} -setup {
    set fn [makeFile {} io-75.14]
    set f [open $fn w+]
    set chan  [file tempfile]
    fconfigure $f -encoding binary
    # \xc0 is invalid in utf-8
    puts -nonewline $f a\nb\xc0\nc\n
    # \xc0\n is an invalid utf-8 sequence
    puts -nonewline $f a\nb\nc\xc0\nd\n
    flush $f
    seek $f 0
    fconfigure $f -encoding utf-8 -buffering none -eofchar {} \
	-translation lf -profile strict
} -body {
    lappend res [gets $f]
    lappend res [gets $f]
    set status [catch {gets $f} cres copts]
    lappend res $status $cres
    chan configure $f -profile tcl8 
    lappend res [gets $f]
    lappend res [gets $f]
    close $f
	return $res
    return $res
} -match glob -result {a b 1 {error reading "*":\
    invalid or incomplete multibyte or wide character} cÀ d}

test io-75.15 {
    invalid utf-8 encoding strict
    gets does not hang
    gets succeeds for the first two lines
} -setup {
    set res {}
    set chan [file tempfile]
    fconfigure $chan -encoding binary
    # \xc0\x40 is an invalid utf-8 sequence
    puts $chan hello\nAB\nCD\xc0\x40EF\nGHI
	seek $chan 0
} -body {
    #Now try to read it with [gets]
    fconfigure $chan -encoding utf-8 -profile strict
    lappend res [gets $chan]
    lappend res [gets $chan]
    set status [catch {gets $chan} cres copts]
    lappend res $status $cres
    set status [catch {gets $chan} cres copts]
    lappend res $status $cres
	chan configure $chan -translation binary
	set data [read $chan 4]
	foreach char [split $data {}] {
		scan $char %c ord
		lappend res [format %x $ord]
	}
    fconfigure $chan -encoding utf-8 -profile strict
	lappend res [gets $chan]
	lappend res [gets $chan]
    return $res
} -cleanup {
    removeFile io-75.14
} -match glob -result {a 1 {error reading "*":\
    invalid or incomplete multibyte or wide character} bÀ c}
    close $chan
} -match glob -result {hello AB 1 {error reading "*": invalid or incomplete multibyte or wide character}\
    1 {error reading "*": invalid or incomplete multibyte or wide character} 43 44 c0 40 EF GHI}

test io-75.14 {invalid utf-8 encoding [gets] coninues in non-strict mode after error} -setup {
    set res {}
    set fn [makeFile {} io-75.14]
    set f [open $fn w+]
    fconfigure $f -encoding binary
    # \xc0 is invalid in utf-8