From 31145f178e965c316eb97dcb24fe34779c6bd50e Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 26 Oct 2020 10:53:29 +0000 Subject: Copied man page and test from Androwish https://www.androwish.org/home/ci/bc8b7e8094b66169 --- doc/binary.n | 9 +++++++++ tests/binary.test | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/binary.n b/doc/binary.n index 0e8b28e..3ba823b 100644 --- a/doc/binary.n +++ b/doc/binary.n @@ -762,6 +762,15 @@ high-to-low order within each byte. For example, will return \fB2\fR with \fB01110\fR stored in \fIvar1\fR and \fB1000011100000101\fR stored in \fIvar2\fR. .RE +.IP \fBC\fR 5 +This form is similar to \fBA\fR, except that it scans the data from start +and terminates at the first null (C string semantics). For example, +.RS +.CS +\fBbinary scan\fR "abc\e000efghi" A* var1 +.CE +will return \fB1\fR with \fBabc\fR stored in \fIvar1\fR. +.RE .IP \fBH\fR 5 The data is turned into a string of \fIcount\fR hexadecimal digits in high-to-low order represented as a sequence of characters in the set diff --git a/tests/binary.test b/tests/binary.test index cf3195f..501ec0d 100644 --- a/tests/binary.test +++ b/tests/binary.test @@ -759,7 +759,16 @@ test binary-21.12 {Tcl_BinaryObjCmd: scan} -setup { } -body { list [binary scan "abc def \x00ghi " A* arg1] $arg1 } -result [list 1 "abc def \x00ghi"] - +test binary-21.13 {Tcl_BinaryObjCmd: scan} -setup { + unset -nocomplain arg1 +} -body { + list [binary scan "abc def \x00 " C* arg1] $arg1 +} -result {1 {abc def }} +test binary-21.12 {Tcl_BinaryObjCmd: scan} -setup { + unset -nocomplain arg1 +} -body { + list [binary scan "abc def \x00ghi" C* arg1] $arg1 +} -result {1 {abc def }} test binary-22.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { binary scan abc b } -result {not enough arguments for all format specifiers} -- cgit v0.12