summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-10-26 10:53:29 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-10-26 10:53:29 (GMT)
commit31145f178e965c316eb97dcb24fe34779c6bd50e (patch)
treec0e528ff9b916f488ffb22ebb1495ed1279ae4a5
parent861d8f512fd6d21d600999faa12dde6bd363bef0 (diff)
downloadtcl-31145f178e965c316eb97dcb24fe34779c6bd50e.zip
tcl-31145f178e965c316eb97dcb24fe34779c6bd50e.tar.gz
tcl-31145f178e965c316eb97dcb24fe34779c6bd50e.tar.bz2
Copied man page and test from Androwish https://www.androwish.org/home/ci/bc8b7e8094b66169
-rw-r--r--doc/binary.n9
-rw-r--r--tests/binary.test11
2 files changed, 19 insertions, 1 deletions
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}