From 16284e7d81c8d903edecbbaa014ae84589140150 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 9 Oct 2002 14:07:35 +0000 Subject: More clarification of [binary scan]'s behaviour. --- ChangeLog | 4 ++++ doc/binary.n | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a4cb5e..79e1b2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-10-09 Donal K. Fellows + + * doc/binary.n: More clarification of [binary scan]'s behaviour. + 2002-10-09 Daniel Steffen * generic/tclIntDecls.h: fixed botched regen. diff --git a/doc/binary.n b/doc/binary.n index 7064b99..3be7d59 100644 --- a/doc/binary.n +++ b/doc/binary.n @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: binary.n,v 1.10 2002/10/04 10:23:33 dkf Exp $ +'\" RCS: @(#) $Id: binary.n,v 1.11 2002/10/09 14:07:43 dkf Exp $ '\" .so man.macros .TH binary n 8.0 Tcl "Tcl Built-In Commands" @@ -337,16 +337,27 @@ A similar example as with \fBbinary format\fR should explain the relation between field specifiers and arguments in case of the binary scan subcommand: .CS -\fBbinary scan $bytes i3i first second\fR +\fBbinary scan $bytes s3s first second\fR .CE .PP This command (provided the binary string in the variable \fIbytes\fR is long enough) assigns a list of three integers to the variable \fIfirst\fR and assigns a single value to the variable \fIsecond\fR. -If \fIbytes\fR contains fewer than 16 bytes (i.e. four 4-byte +If \fIbytes\fR contains fewer than 8 bytes (i.e. four 2-byte integers), no assignment to \fIsecond\fR will be made, and if -\fIbytes\fR contains fewer than 12 bytes (i.e. three 4-byte integers), -no assignment to \fIfirst\fR will be made. +\fIbytes\fR contains fewer than 6 bytes (i.e. three 2-byte integers), +no assignment to \fIfirst\fR will be made. Hence: +.CS +\fBputs [binary scan abcdefg s3s first second]\fR +\fBputs $first\fR +\fBputs $second\fR +.CE +will print (assuming neither variable is set previously): +.CS +\fB1\fR +\fB25185 25699 26213\fR +\fIcan't read "second": no such variable\fR +.CE .PP It is \fBimportant\fR to note that the \fBc\fR, \fBs\fR, and \fBS\fR (and \fBi\fR and \fBI\fR on 64bit systems) will be scanned into -- cgit v0.12