summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-01-20 13:42:17 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-01-20 13:42:17 (GMT)
commit1549d82a2029add6f62dde489d26a70b466f4fd0 (patch)
tree6b453022eb94d1d13ccd73cb7e033e4859af45fd
parentee1c40272a0ee43da070323282205173df4a8816 (diff)
downloadtcl-1549d82a2029add6f62dde489d26a70b466f4fd0.zip
tcl-1549d82a2029add6f62dde489d26a70b466f4fd0.tar.gz
tcl-1549d82a2029add6f62dde489d26a70b466f4fd0.tar.bz2
Use a consistent indentation of 4 for code examples.
-rw-r--r--doc/after.n10
-rw-r--r--doc/append.n4
-rw-r--r--doc/apply.n41
-rw-r--r--doc/array.n16
-rw-r--r--doc/break.n16
-rw-r--r--doc/chan.n30
-rw-r--r--doc/continue.n13
-rw-r--r--doc/dict.n44
-rw-r--r--doc/eval.n15
-rw-r--r--doc/fconfigure.n32
-rw-r--r--doc/file.n36
-rw-r--r--doc/for.n17
-rw-r--r--doc/format.n9
-rw-r--r--doc/http.n52
-rw-r--r--doc/if.n23
-rw-r--r--doc/interp.n14
-rw-r--r--doc/load.n16
-rw-r--r--doc/lsort.n44
-rw-r--r--doc/msgcat.n21
-rw-r--r--doc/package.n11
-rw-r--r--doc/proc.n15
-rw-r--r--doc/return.n78
-rw-r--r--doc/scan.n27
-rw-r--r--doc/socket.n11
-rw-r--r--doc/source.n4
-rw-r--r--doc/split.n17
-rw-r--r--doc/switch.n46
-rw-r--r--doc/upvar.n12
-rw-r--r--doc/vwait.n148
29 files changed, 434 insertions, 388 deletions
diff --git a/doc/after.n b/doc/after.n
index e6d2dd0..8ccada1 100644
--- a/doc/after.n
+++ b/doc/after.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: after.n,v 1.12 2008/10/15 10:43:37 dkf Exp $
+'\" RCS: @(#) $Id: after.n,v 1.13 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH after n 7.5 Tcl "Tcl Built-In Commands"
@@ -114,7 +114,7 @@ seconds:
.PP
.CS
proc sleep {N} {
- \fBafter\fR [expr {int($N * 1000)}]
+ \fBafter\fR [expr {int($N * 1000)}]
}
.CE
.PP
@@ -138,9 +138,9 @@ responsive during a slow task.
.PP
.CS
proc doOneStep {} {
- if {[::my_calc::one_step]} {
- \fBafter idle\fR [list \fBafter\fR 0 doOneStep]
- }
+ if {[::my_calc::one_step]} {
+ \fBafter idle\fR [list \fBafter\fR 0 doOneStep]
+ }
}
doOneStep
.CE
diff --git a/doc/append.n b/doc/append.n
index c044c08..6217b80 100644
--- a/doc/append.n
+++ b/doc/append.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: append.n,v 1.11 2008/10/15 10:43:37 dkf Exp $
+'\" RCS: @(#) $Id: append.n,v 1.12 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH append n "" Tcl "Tcl Built-In Commands"
@@ -37,7 +37,7 @@ Building a string of comma-separated numbers piecemeal using a loop.
.CS
set var 0
for {set i 1} {$i<=10} {incr i} {
- \fBappend\fR var "," $i
+ \fBappend\fR var "," $i
}
puts $var
# Prints 0,1,2,3,4,5,6,7,8,9,10
diff --git a/doc/apply.n b/doc/apply.n
index e76c1e5..9d373e1 100644
--- a/doc/apply.n
+++ b/doc/apply.n
@@ -48,18 +48,18 @@ The semantics of \fBapply\fR can also be described by:
.PP
.CS
proc apply {fun args} {
- set len [llength $fun]
- if {($len < 2) || ($len > 3)} {
- error "can't interpret \e"$fun\e" as anonymous function"
- }
- lassign $fun argList body ns
- set name ::$ns::[getGloballyUniqueName]
- set body0 {
- rename [lindex [info level 0] 0] {}
- }
- proc $name $argList ${body0}$body
- set code [catch {uplevel 1 $name $args} res opt]
- return -options $opt $res
+ set len [llength $fun]
+ if {($len < 2) || ($len > 3)} {
+ error "can't interpret \e"$fun\e" as anonymous function"
+ }
+ lassign $fun argList body ns
+ set name ::$ns::[getGloballyUniqueName]
+ set body0 {
+ rename [lindex [info level 0] 0] {}
+ }
+ proc $name $argList ${body0}$body
+ set code [catch {uplevel 1 $name $args} res opt]
+ return -options $opt $res
}
.CE
.SH EXAMPLES
@@ -69,11 +69,11 @@ to each element of a list.
.PP
.CS
proc map {lambda list} {
- set result {}
- foreach item $list {
- lappend result [\fBapply\fR $lambda $item]
- }
- return $result
+ set result {}
+ foreach item $list {
+ lappend result [\fBapply\fR $lambda $item]
+ }
+ return $result
}
map {x {return [string length $x]:$x}} {a bb ccc dddd}
\fI\(-> 1:a 2:bb 3:ccc 4:dddd\fR
@@ -87,8 +87,8 @@ The \fBapply\fR command is also useful for defining callbacks for use in the
.CS
set vbl "123abc"
trace add variable vbl write {\fBapply\fR {{v1 v2 op} {
- upvar 1 $v1 v
- puts "updated variable to \e"$v\e""
+ upvar 1 $v1 v
+ puts "updated variable to \e"$v\e""
}}}
set vbl 123
set vbl abc
@@ -97,3 +97,6 @@ set vbl abc
proc(n), uplevel(n)
.SH KEYWORDS
anonymous function, argument, lambda, procedure,
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/array.n b/doc/array.n
index f045102..49bc0e6 100644
--- a/doc/array.n
+++ b/doc/array.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: array.n,v 1.21 2007/12/13 15:22:32 dgp Exp $
+'\" RCS: @(#) $Id: array.n,v 1.22 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH array n 8.3 Tcl "Tcl Built-In Commands"
@@ -138,14 +138,14 @@ The command always returns an empty string.
.SH EXAMPLES
.CS
\fBarray set\fR colorcount {
- red 1
- green 5
- blue 4
- white 9
+ red 1
+ green 5
+ blue 4
+ white 9
}
foreach {color count} [\fBarray get\fR colorcount] {
- puts "Color: $color Count: $count"
+ puts "Color: $color Count: $count"
}
\fB\(->\fR Color: blue Count: 4
Color: white Count: 9
@@ -153,7 +153,7 @@ foreach {color count} [\fBarray get\fR colorcount] {
Color: red Count: 1
foreach color [\fBarray names\fR colorcount] {
- puts "Color: $color Count: $colorcount($color)"
+ puts "Color: $color Count: $colorcount($color)"
}
\fB\(->\fR Color: blue Count: 4
Color: white Count: 9
@@ -161,7 +161,7 @@ foreach color [\fBarray names\fR colorcount] {
Color: red Count: 1
foreach color [lsort [\fBarray names\fR colorcount]] {
- puts "Color: $color Count: $colorcount($color)"
+ puts "Color: $color Count: $colorcount($color)"
}
\fB\(->\fR Color: blue Count: 4
Color: green Count: 5
diff --git a/doc/break.n b/doc/break.n
index 77a0d97..4d758a4 100644
--- a/doc/break.n
+++ b/doc/break.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: break.n,v 1.11 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: break.n,v 1.12 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH break n "" Tcl "Tcl Built-In Commands"
@@ -16,7 +16,6 @@ break \- Abort looping command
.SH SYNOPSIS
\fBbreak\fR
.BE
-
.SH DESCRIPTION
.PP
This command is typically invoked inside the body of a looping command
@@ -35,15 +34,16 @@ Print a line for each of the integers from 0 to 5:
.PP
.CS
for {set x 0} {$x<10} {incr x} {
- if {$x > 5} {
- \fBbreak\fR
- }
- puts "x is $x"
+ if {$x > 5} {
+ \fBbreak\fR
+ }
+ puts "x is $x"
}
.CE
-
.SH "SEE ALSO"
catch(n), continue(n), for(n), foreach(n), return(n), while(n)
-
.SH KEYWORDS
abort, break, loop
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/chan.n b/doc/chan.n
index a413049..067a408 100644
--- a/doc/chan.n
+++ b/doc/chan.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: chan.n,v 1.25 2010/01/14 11:47:08 dkf Exp $
+'\" RCS: @(#) $Id: chan.n,v 1.26 2010/01/20 13:42:17 dkf Exp $
.so man.macros
.TH chan n 8.5 Tcl "Tcl Built-In Commands"
.BS
@@ -769,24 +769,24 @@ set offset 0
\fI# Search for string "FOOBAR" in the file\fR
while {[\fBchan gets\fR $f line] >= 0} {
- set idx [string first FOOBAR $line]
- if {$idx > -1} {
- \fI# Found it; rewrite line\fR
+ set idx [string first FOOBAR $line]
+ if {$idx > -1} {
+ \fI# Found it; rewrite line\fR
- \fBchan seek\fR $f [expr {$offset + $idx}]
- \fBchan puts\fR -nonewline $f BARFOO
+ \fBchan seek\fR $f [expr {$offset + $idx}]
+ \fBchan puts\fR -nonewline $f BARFOO
- \fI# Skip to end of following line, and truncate\fR
- \fBchan gets\fR $f
- \fBchan gets\fR $f
- \fBchan truncate\fR $f
+ \fI# Skip to end of following line, and truncate\fR
+ \fBchan gets\fR $f
+ \fBchan gets\fR $f
+ \fBchan truncate\fR $f
- \fI# Stop searching the file now\fR
- break
- }
+ \fI# Stop searching the file now\fR
+ break
+ }
- \fI# Save offset of start of next line for later\fR
- set offset [\fBchan tell\fR $f]
+ \fI# Save offset of start of next line for later\fR
+ set offset [\fBchan tell\fR $f]
}
\fBchan close\fR $f
.CE
diff --git a/doc/continue.n b/doc/continue.n
index e98763c..beb29b7 100644
--- a/doc/continue.n
+++ b/doc/continue.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: continue.n,v 1.11 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: continue.n,v 1.12 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH continue n "" Tcl "Tcl Built-In Commands"
@@ -34,13 +34,16 @@ Print a line for each of the integers from 0 to 10 \fIexcept\fR 5:
.PP
.CS
for {set x 0} {$x<10} {incr x} {
- if {$x == 5} {
- \fBcontinue\fR
- }
- puts "x is $x"
+ if {$x == 5} {
+ \fBcontinue\fR
+ }
+ puts "x is $x"
}
.CE
.SH "SEE ALSO"
break(n), for(n), foreach(n), return(n), while(n)
.SH KEYWORDS
continue, iteration, loop
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/dict.n b/doc/dict.n
index ffb1500..023e811 100644
--- a/doc/dict.n
+++ b/doc/dict.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: dict.n,v 1.22 2010/01/19 09:48:58 dkf Exp $
+'\" RCS: @(#) $Id: dict.n,v 1.23 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH dict n 8.5 Tcl "Tcl Built-In Commands"
@@ -328,16 +328,16 @@ Constructing and using nested dictionaries:
set i 0
puts "There are [\fBdict size\fR $employeeInfo] employees"
\fBdict for\fR {id info} $employeeInfo {
- puts "Employee #[incr i]: $id"
- \fBdict with\fR info {
- puts " Name: $forenames $surname"
- puts " Address: $street, $city"
- puts " Telephone: $phone"
- }
+ puts "Employee #[incr i]: $id"
+ \fBdict with\fR info {
+ puts " Name: $forenames $surname"
+ puts " Address: $street, $city"
+ puts " Telephone: $phone"
+ }
}
# Another way to iterate and pick out names...
foreach id [\fBdict keys\fR $employeeInfo] {
- puts "Hello, [\fBdict get\fR $employeeInfo $id forenames]!"
+ puts "Hello, [\fBdict get\fR $employeeInfo $id forenames]!"
}
.CE
.PP
@@ -347,7 +347,7 @@ A localizable version of \fBstring toupper\fR:
# Set up the basic C locale
set capital [\fBdict create\fR C [\fBdict create\fR]]
foreach c [split {abcdefghijklmnopqrstuvwxyz} ""] {
- \fBdict set\fR capital C $c [string toupper $c]
+ \fBdict set\fR capital C $c [string toupper $c]
}
# English locales can luckily share the "C" locale
@@ -366,22 +366,22 @@ Showing the detail of \fBdict with\fR:
.PP
.CS
proc sumDictionary {varName} {
- upvar 1 $varName vbl
- foreach key [\fBdict keys\fR $vbl] {
- # Manufacture an entry in the subdictionary
- \fBdict set\fR vbl $key total 0
- # Add the values and remove the old
- \fBdict with\fR vbl $key {
- set total [expr {$x + $y + $z}]
- unset x y z
- }
- }
- puts "last total was $total, for key $key"
+ upvar 1 $varName vbl
+ foreach key [\fBdict keys\fR $vbl] {
+ # Manufacture an entry in the subdictionary
+ \fBdict set\fR vbl $key total 0
+ # Add the values and remove the old
+ \fBdict with\fR vbl $key {
+ set total [expr {$x + $y + $z}]
+ unset x y z
+ }
+ }
+ puts "last total was $total, for key $key"
}
set myDict {
- a {x 1 y 2 z 3}
- b {x 6 y 5 z 4}
+ a {x 1 y 2 z 3}
+ b {x 6 y 5 z 4}
}
sumDictionary myDict
diff --git a/doc/eval.n b/doc/eval.n
index 47a8aee..1f305f8 100644
--- a/doc/eval.n
+++ b/doc/eval.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: eval.n,v 1.13 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: eval.n,v 1.14 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH eval n "" Tcl "Tcl Built-In Commands"
@@ -62,11 +62,11 @@ start of the list in the variable:
.PP
.CS
proc lprepend {varName args} {
- upvar 1 $varName var
- # Ensure that the variable exists and contains a list
- lappend var
- # Now we insert all the arguments in one go
- set var [\fBeval\fR [list linsert $var 0] $args]
+ upvar 1 $varName var
+ # Ensure that the variable exists and contains a list
+ lappend var
+ # Now we insert all the arguments in one go
+ set var [\fBeval\fR [list linsert $var 0] $args]
}
.CE
.PP
@@ -80,3 +80,6 @@ set var [linsert $var 0 {*}$args]
catch(n), concat(n), error(n), interp(n), list(n), namespace(n), subst(n), tclvars(n), uplevel(n)
.SH KEYWORDS
concatenate, evaluate, script
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/fconfigure.n b/doc/fconfigure.n
index 610c898..d2b8ee1 100644
--- a/doc/fconfigure.n
+++ b/doc/fconfigure.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: fconfigure.n,v 1.22 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: fconfigure.n,v 1.23 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH fconfigure n 8.3 Tcl "Tcl Built-In Commands"
@@ -232,17 +232,17 @@ set s [socket some.where.com 12345]
\fBfconfigure\fR $s -blocking 0
fileevent $s readable "readMe $s"
proc readMe chan {
- if {[gets $chan line] < 0} {
- if {[eof $chan]} {
- close $chan
- return
- }
- # Could not read a complete line this time; Tcl's
- # internal buffering will hold the partial line for us
- # until some more data is available over the socket.
- } else {
- puts stdout $line
- }
+ if {[gets $chan line] < 0} {
+ if {[eof $chan]} {
+ close $chan
+ return
+ }
+ # Could not read a complete line this time; Tcl's
+ # internal buffering will hold the partial line for us
+ # until some more data is available over the socket.
+ } else {
+ puts stdout $line
+ }
}
.CE
.PP
@@ -255,16 +255,16 @@ set f [open teapot.ppm]
# Get the header
if {[gets $f] ne "P6"} {
- error "not a raw\-bits PPM"
+ error "not a raw\-bits PPM"
}
# Read lines until we have got non-comment lines
# that supply us with three decimal values.
set words {}
while {[llength $words] < 3} {
- gets $f line
- if {[string match "#*" $line]} continue
- lappend words {*}[join [scan $line %d%d%d]]
+ gets $f line
+ if {[string match "#*" $line]} continue
+ lappend words {*}[join [scan $line %d%d%d]]
}
# Those words supply the size of the image and its
diff --git a/doc/file.n b/doc/file.n
index 70f3257..e969c44 100644
--- a/doc/file.n
+++ b/doc/file.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: file.n,v 1.58 2010/01/13 12:08:30 dkf Exp $
+'\" RCS: @(#) $Id: file.n,v 1.59 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH file n 8.3 Tcl "Tcl Built-In Commands"
@@ -491,22 +491,22 @@ directory:
.PP
.CS
proc findMatchingCFiles {dir} {
- set files {}
- switch $::tcl_platform(platform) {
- windows {
- set ext .obj
- }
- unix {
- set ext .o
- }
- }
- foreach file [glob \-nocomplain \-directory $dir *.c] {
- set objectFile [\fBfile tail\fR [\fBfile rootname\fR $file]]$ext
- if {[\fBfile exists\fR $objectFile]} {
- lappend files $file
- }
- }
- return $files
+ set files {}
+ switch $::tcl_platform(platform) {
+ windows {
+ set ext .obj
+ }
+ unix {
+ set ext .o
+ }
+ }
+ foreach file [glob \-nocomplain \-directory $dir *.c] {
+ set objectFile [\fBfile tail\fR [\fBfile rootname\fR $file]]$ext
+ if {[\fBfile exists\fR $objectFile]} {
+ lappend files $file
+ }
+ }
+ return $files
}
.CE
.PP
@@ -518,7 +518,7 @@ set oldName foobar.txt
set newName foo/bar.txt
# Make sure that where we're going to move to exists...
if {![\fBfile isdirectory\fR [\fBfile dirname\fR $newName]]} {
- \fBfile mkdir\fR [\fBfile dirname\fR $newName]
+ \fBfile mkdir\fR [\fBfile dirname\fR $newName]
}
\fBfile rename\fR $oldName $newName
\fBfile link\fR \-symbolic $oldName $newName
diff --git a/doc/for.n b/doc/for.n
index f580d85..a7ad4a5 100644
--- a/doc/for.n
+++ b/doc/for.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: for.n,v 1.12 2010/01/14 14:52:17 dkf Exp $
+'\" RCS: @(#) $Id: for.n,v 1.13 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH for n "" Tcl "Tcl Built-In Commands"
@@ -54,8 +54,8 @@ See below for an example:
Print a line for each of the integers from 0 to 10:
.PP
.CS
-for {set x 0} {$x<10} {incr x} {
- puts "x is $x"
+\fBfor\fR {set x 0} {$x<10} {incr x} {
+ puts "x is $x"
}
.CE
.PP
@@ -68,19 +68,22 @@ the expression will be substituted before the \fBfor\fR command is
executed.
.PP
.CS
-for {set x 0} $x<10 {incr x} {
- puts "x is $x"
+\fBfor\fR {set x 0} $x<10 {incr x} {
+ puts "x is $x"
}
.CE
.PP
Print out the powers of two from 1 to 1024:
.PP
.CS
-for {set x 1} {$x<=1024} {set x [expr {$x * 2}]} {
- puts "x is $x"
+\fBfor\fR {set x 1} {$x<=1024} {set x [expr {$x * 2}]} {
+ puts "x is $x"
}
.CE
.SH "SEE ALSO"
break(n), continue(n), foreach(n), while(n)
.SH KEYWORDS
boolean, for, iteration, loop
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/format.n b/doc/format.n
index 24f35df..242ebfd 100644
--- a/doc/format.n
+++ b/doc/format.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: format.n,v 1.23 2009/02/24 21:04:58 dkf Exp $
+'\" RCS: @(#) $Id: format.n,v 1.24 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH format n 8.1 Tcl "Tcl Built-In Commands"
@@ -270,8 +270,8 @@ puts $sep
# Print the contents of the table
set p 1
for {set i 0} {$i<=20} {incr i} {
- puts [\fBformat\fR "| %*d | %*ld |" $w1 $i $w2 $p]
- set p [expr {wide($p) * 3}]
+ puts [\fBformat\fR "| %*d | %*ld |" $w1 $i $w2 $p]
+ set p [expr {wide($p) * 3}]
}
# Finish off by printing the separator again
@@ -281,3 +281,6 @@ puts $sep
scan(n), sprintf(3), string(n)
.SH KEYWORDS
conversion specifier, format, sprintf, string, substitution
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/http.n b/doc/http.n
index 0c533b8..2ad9eae 100644
--- a/doc/http.n
+++ b/doc/http.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: http.n,v 1.38 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: http.n,v 1.39 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH "http" n 2.7 http "Tcl Bundled Packages"
@@ -606,36 +606,36 @@ progress meter, and prints the meta-data associated with the URL.
.PP
.CS
proc httpcopy { url file {chunk 4096} } {
- set out [open $file w]
- set token [\fB::http::geturl\fR $url -channel $out \e
- -progress httpCopyProgress -blocksize $chunk]
- close $out
+ set out [open $file w]
+ set token [\fB::http::geturl\fR $url -channel $out \e
+ -progress httpCopyProgress -blocksize $chunk]
+ close $out
- # This ends the line started by httpCopyProgress
- puts stderr ""
+ # This ends the line started by httpCopyProgress
+ puts stderr ""
- upvar #0 $token state
- set max 0
- foreach {name value} $state(meta) {
- if {[string length $name] > $max} {
- set max [string length $name]
- }
- if {[regexp -nocase ^location$ $name]} {
- # Handle URL redirects
- puts stderr "Location:$value"
- return [httpcopy [string trim $value] $file $chunk]
- }
- }
- incr max
- foreach {name value} $state(meta) {
- puts [format "%-*s %s" $max $name: $value]
- }
+ upvar #0 $token state
+ set max 0
+ foreach {name value} $state(meta) {
+ if {[string length $name] > $max} {
+ set max [string length $name]
+ }
+ if {[regexp -nocase ^location$ $name]} {
+ # Handle URL redirects
+ puts stderr "Location:$value"
+ return [httpcopy [string trim $value] $file $chunk]
+ }
+ }
+ incr max
+ foreach {name value} $state(meta) {
+ puts [format "%-*s %s" $max $name: $value]
+ }
- return $token
+ return $token
}
proc httpCopyProgress {args} {
- puts -nonewline stderr .
- flush stderr
+ puts -nonewline stderr .
+ flush stderr
}
.CE
.SH "SEE ALSO"
diff --git a/doc/if.n b/doc/if.n
index d80c684..dea7610 100644
--- a/doc/if.n
+++ b/doc/if.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: if.n,v 1.10 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: if.n,v 1.11 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH if n "" Tcl "Tcl Built-In Commands"
@@ -51,9 +51,9 @@ With an \fBelse\fR-clause:
.PP
.CS
\fBif\fR {$vbl == 1} {
- puts "vbl is one"
+ puts "vbl is one"
} \fBelse\fR {
- puts "vbl is not one"
+ puts "vbl is not one"
}
.CE
.PP
@@ -61,11 +61,11 @@ With an \fBelseif\fR-clause too:
.PP
.CS
\fBif\fR {$vbl == 1} {
- puts "vbl is one"
+ puts "vbl is one"
} \fBelseif\fR {$vbl == 2} {
- puts "vbl is two"
+ puts "vbl is two"
} \fBelse\fR {
- puts "vbl is not one or two"
+ puts "vbl is not one or two"
}
.CE
.PP
@@ -74,14 +74,17 @@ good idea to use the optional \fBthen\fR keyword for clarity:
.PP
.CS
\fBif\fR {
- $vbl == 1
- || $vbl == 2
- || $vbl == 3
+ $vbl == 1
+ || $vbl == 2
+ || $vbl == 3
} \fBthen\fR {
- puts "vbl is one, two or three"
+ puts "vbl is one, two or three"
}
.CE
.SH "SEE ALSO"
expr(n), for(n), foreach(n)
.SH KEYWORDS
boolean, conditional, else, false, if, true
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/interp.n b/doc/interp.n
index 082e559..2d2330b 100644
--- a/doc/interp.n
+++ b/doc/interp.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: interp.n,v 1.43 2010/01/10 20:36:49 dkf Exp $
+'\" RCS: @(#) $Id: interp.n,v 1.44 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH interp n 8.6 Tcl "Tcl Built-In Commands"
@@ -832,8 +832,8 @@ set i [\fBinterp create\fR -safe]
\fBinterp hide\fR $i lappend
\fBinterp alias\fR $i lappend {} loggedLappend $i
proc loggedLappend {i args} {
- puts "logged invocation of lappend $args"
- \fBinterp invokehidden\fR $i lappend {*}$args
+ puts "logged invocation of lappend $args"
+ \fBinterp invokehidden\fR $i lappend {*}$args
}
\fBinterp eval\fR $i $someUntrustedScript
.CE
@@ -845,10 +845,10 @@ terminates.
set i [\fBinterp create\fR]
\fBinterp limit\fR $i command -value 1000
\fBinterp eval\fR $i {
- set x 0
- while {1} {
- puts "Counting up... [incr x]"
- }
+ set x 0
+ while {1} {
+ puts "Counting up... [incr x]"
+ }
}
.CE
.SH "SEE ALSO"
diff --git a/doc/load.n b/doc/load.n
index 8675dcd..faba6b5 100644
--- a/doc/load.n
+++ b/doc/load.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: load.n,v 1.25 2010/01/13 12:08:30 dkf Exp $
+'\" RCS: @(#) $Id: load.n,v 1.26 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH load n 7.5 Tcl "Tcl Built-In Commands"
@@ -121,10 +121,12 @@ When loading a DLL in the current directory, Windows will ignore
.QW ./
as a path specifier and use a search heuristic to find the DLL instead.
To avoid this, load the DLL with:
+.RS
.PP
.CS
\fBload\fR [file join [pwd] mylib.DLL]
.CE
+.RE
.SH BUGS
.PP
If the same file is \fBload\fRed by different \fIfileName\fRs, it will
@@ -160,12 +162,12 @@ it can then be loaded into Tcl with the following:
.CS
# Load the extension
switch $tcl_platform(platform) {
- windows {
- \fBload\fR [file join [pwd] foo.dll]
- }
- unix {
- \fBload\fR [file join [pwd] libfoo[info sharedlibextension]]
- }
+ windows {
+ \fBload\fR [file join [pwd] foo.dll]
+ }
+ unix {
+ \fBload\fR [file join [pwd] libfoo[info sharedlibextension]]
+ }
}
# Now execute the command defined by the extension
diff --git a/doc/lsort.n b/doc/lsort.n
index 568f283..7b9d6a6 100644
--- a/doc/lsort.n
+++ b/doc/lsort.n
@@ -7,7 +7,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: lsort.n,v 1.33 2009/02/24 21:04:58 dkf Exp $
+'\" RCS: @(#) $Id: lsort.n,v 1.34 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH lsort n 8.5 Tcl "Tcl Built-In Commands"
@@ -101,7 +101,7 @@ returns \fB{Second 18} {First 24} {Third 30}\fR,
'\"
.CS
lsort -index end-1 \e
- {{a 1 e i} {b 2 3 f g} {c 4 5 6 d h}}
+ {{a 1 e i} {b 2 3 f g} {c 4 5 6 d h}}
.CE
.PP
returns \fB{c 4 5 6 d h} {a 1 e i} {b 2 3 f g}\fR,
@@ -109,9 +109,9 @@ and
.PP
.CS
lsort -index {0 1} {
- {{b i g} 12345}
- {{d e m o} 34512}
- {{c o d e} 54321}
+ {{b i g} 12345}
+ {{d e m o} 34512}
+ {{c o d e} 54321}
}
.CE
.PP
@@ -181,44 +181,44 @@ option.
Sorting a list using ASCII sorting:
.PP
.CS
-% \fBlsort\fR {a10 B2 b1 a1 a2}
+\fI%\fR \fBlsort\fR {a10 B2 b1 a1 a2}
B2 a1 a10 a2 b1
.CE
.PP
Sorting a list using Dictionary sorting:
.PP
.CS
-% \fBlsort\fR -dictionary {a10 B2 b1 a1 a2}
+\fI%\fR \fBlsort\fR -dictionary {a10 B2 b1 a1 a2}
a1 a2 a10 b1 B2
.CE
.PP
Sorting lists of integers:
.PP
.CS
-% \fBlsort\fR -integer {5 3 1 2 11 4}
+\fI%\fR \fBlsort\fR -integer {5 3 1 2 11 4}
1 2 3 4 5 11
-% \fBlsort\fR -integer {1 2 0x5 7 0 4 -1}
+\fI%\fR \fBlsort\fR -integer {1 2 0x5 7 0 4 -1}
-1 0 1 2 4 0x5 7
.CE
.PP
Sorting lists of floating-point numbers:
.PP
.CS
-% \fBlsort\fR -real {5 3 1 2 11 4}
+\fI%\fR \fBlsort\fR -real {5 3 1 2 11 4}
1 2 3 4 5 11
-% \fBlsort\fR -real {.5 0.07e1 0.4 6e-1}
+\fI%\fR \fBlsort\fR -real {.5 0.07e1 0.4 6e-1}
0.4 .5 6e-1 0.07e1
.CE
.PP
Sorting using indices:
.PP
.CS
-% # Note the space character before the c
-% \fBlsort\fR {{a 5} { c 3} {b 4} {e 1} {d 2}}
+\fI%\fR # Note the space character before the c
+\fI%\fR \fBlsort\fR {{a 5} { c 3} {b 4} {e 1} {d 2}}
{ c 3} {a 5} {b 4} {d 2} {e 1}
-% \fBlsort\fR -index 0 {{a 5} { c 3} {b 4} {e 1} {d 2}}
+\fI%\fR \fBlsort\fR -index 0 {{a 5} { c 3} {b 4} {e 1} {d 2}}
{a 5} {b 4} { c 3} {d 2} {e 1}
-% \fBlsort\fR -index 1 {{a 5} { c 3} {b 4} {e 1} {d 2}}
+\fI%\fR \fBlsort\fR -index 1 {{a 5} { c 3} {b 4} {e 1} {d 2}}
{e 1} {d 2} { c 3} {b 4} {a 5}
.CE
.PP
@@ -226,17 +226,17 @@ Sorting using indices:
Sorting a dictionary:
.PP
.CS
-% set d [dict create c d a b h i f g c e]
+\fI%\fR set d [dict create c d a b h i f g c e]
c e a b h i f g
-% \fBlsort\fR -stride 2 $d
+\fI%\fR \fBlsort\fR -stride 2 $d
a b c e f g h i
.CE
.PP
Sorting using striding and multiple indices:
.PP
.CS
-% # Note the first index value is relative to the group
-% \fBlsort\fR \-stride 3 \-index {0 1} \e
+\fI%\fR # Note the first index value is relative to the group
+\fI%\fR \fBlsort\fR \-stride 3 \-index {0 1} \e
{{Bob Smith} 25 Audi {Jane Doe} 40 Ford}
{{Jane Doe} 40 Ford {Bob Smith} 25 Audi}
.CE
@@ -245,14 +245,14 @@ Sorting using striding and multiple indices:
Stripping duplicate values using sorting:
.PP
.CS
-% \fBlsort\fR -unique {a b c a b c a b c}
+\fI%\fR \fBlsort\fR -unique {a b c a b c a b c}
a b c
.CE
.PP
More complex sorting using a comparison function:
.PP
.CS
-% proc compare {a b} {
+\fI%\fR proc compare {a b} {
set a0 [lindex $a 0]
set b0 [lindex $b 0]
if {$a0 < $b0} {
@@ -262,7 +262,7 @@ More complex sorting using a comparison function:
}
return [string compare [lindex $a 1] [lindex $b 1]]
}
-% \fBlsort\fR -command compare \e
+\fI%\fR \fBlsort\fR -command compare \e
{{3 apple} {0x2 carrot} {1 dingo} {2 banana}}
{1 dingo} {2 banana} {0x2 carrot} {3 apple}
.CE
diff --git a/doc/msgcat.n b/doc/msgcat.n
index a212b2f..17cffcb 100644
--- a/doc/msgcat.n
+++ b/doc/msgcat.n
@@ -212,7 +212,7 @@ For example, executing the code
.CS
\fB::msgcat::mcset\fR en hello "hello from ::"
namespace eval foo {
- \fB::msgcat::mcset\fR en hello "hello from ::foo"
+ \fB::msgcat::mcset\fR en hello "hello from ::foo"
}
puts [\fB::msgcat::mc\fR hello]
namespace eval foo {puts [\fB::msgcat::mc\fR hello]}
@@ -241,11 +241,11 @@ locale) the code
\fB::msgcat::mcset\fR en m2 ":: message2"
\fB::msgcat::mcset\fR en m3 ":: message3"
namespace eval ::foo {
- \fB::msgcat::mcset\fR en m2 "::foo message2"
- \fB::msgcat::mcset\fR en m3 "::foo message3"
+ \fB::msgcat::mcset\fR en m2 "::foo message2"
+ \fB::msgcat::mcset\fR en m3 "::foo message3"
}
namespace eval ::foo::bar {
- \fB::msgcat::mcset\fR en m3 "::foo::bar message3"
+ \fB::msgcat::mcset\fR en m3 "::foo::bar message3"
}
namespace import \fB::msgcat::mc\fR
puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]"
@@ -293,7 +293,7 @@ the package. For example, a short \fBes.msg\fR might contain:
.PP
.CS
namespace eval ::mypackage {
- \fB::msgcat::mcset\fR es "Free Beer!" "Cerveza Gracias!"
+ \fB::msgcat::mcset\fR es "Free Beer!" "Cerveza Gracias!"
}
.CE
.SH "RECOMMENDED MESSAGE SETUP FOR PACKAGES"
@@ -335,7 +335,16 @@ format "In location %2\e$s we produced %1\e$d units" $num $city
.CE
.PP
Similarly, positional parameters can be used with \fBscan\fR to
-extract values from internationalized strings.
+extract values from internationalized strings. Note that it is not
+necessary to pass the output of \fB::msgcat::mc\fR to \fBformat\fR
+directly; by passing the values to substitute in as arguments, the
+formatting substitution is done directly.
+.PP
+.CS
+\fBmsgcat::mc\fR {Produced %1$d at %2$s} $num $city
+# ... where that key is mapped to one of the
+# human-oriented versions by \fBmsgcat::mcset\fR
+.CE
.SH CREDITS
.PP
The message catalog code was developed by Mark Harrison.
diff --git a/doc/package.n b/doc/package.n
index 913d3af..9e2cf75 100644
--- a/doc/package.n
+++ b/doc/package.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: package.n,v 1.23 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: package.n,v 1.24 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH package n 7.5 Tcl "Tcl Built-In Commands"
@@ -357,13 +357,16 @@ the functionality is not critical) do this:
.PP
.CS
if {[catch {\fBpackage require\fR Snack}]} {
- # Error thrown - package not found.
- # Set up a dummy interface to work around the absence
+ # Error thrown - package not found.
+ # Set up a dummy interface to work around the absence
} else {
- # We have the package, configure the app to use it
+ # We have the package, configure the app to use it
}
.CE
.SH "SEE ALSO"
msgcat(n), packagens(n), pkgMkIndex(n)
.SH KEYWORDS
package, version
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/proc.n b/doc/proc.n
index bed20a0..75cab29 100644
--- a/doc/proc.n
+++ b/doc/proc.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: proc.n,v 1.11 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: proc.n,v 1.12 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH proc n "" Tcl "Tcl Built-In Commands"
@@ -81,9 +81,9 @@ them out, one by one.
.PP
.CS
\fBproc\fR printArguments args {
- foreach arg $args {
- puts $arg
- }
+ foreach arg $args {
+ puts $arg
+ }
}
.CE
.PP
@@ -93,11 +93,14 @@ defaults to \fB2\fR:
.PP
.CS
\fBproc\fR mult {varName {multiplier 2}} {
- upvar 1 $varName var
- set var [expr {$var * $multiplier}]
+ upvar 1 $varName var
+ set var [expr {$var * $multiplier}]
}
.CE
.SH "SEE ALSO"
info(n), unknown(n)
.SH KEYWORDS
argument, procedure
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/return.n b/doc/return.n
index be1af76..4f77135 100644
--- a/doc/return.n
+++ b/doc/return.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: return.n,v 1.24 2010/01/13 12:08:30 dkf Exp $
+'\" RCS: @(#) $Id: return.n,v 1.25 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH return n 8.5 Tcl "Tcl Built-In Commands"
@@ -214,9 +214,9 @@ procedure, interrupting the procedure body.
.PP
.CS
proc printOneLine {} {
- puts "line 1" ;# This line will be printed.
- \fBreturn\fR
- puts "line 2" ;# This line will not be printed.
+ puts "line 1" ;# This line will be printed.
+ \fBreturn\fR
+ puts "line 2" ;# This line will not be printed.
}
.CE
.PP
@@ -233,25 +233,25 @@ to report invalid arguments.
.PP
.CS
proc factorial {n} {
- if {![string is integer $n] || ($n < 0)} {
- \fBreturn\fR -code error \e
- "expected non-negative integer,\e
- but got \e"$n\e""
- }
- if {$n < 2} {
- \fBreturn\fR 1
- }
- set m [expr {$n - 1}]
- set code [catch {factorial $m} factor]
- if {$code != 0} {
- \fBreturn\fR -code $code $factor
- }
- set product [expr {$n * $factor}]
- if {$product < 0} {
- \fBreturn\fR -code error \e
- "overflow computing factorial of $n"
- }
- \fBreturn\fR $product
+ if {![string is integer $n] || ($n < 0)} {
+ \fBreturn\fR -code error \e
+ "expected non-negative integer,\e
+ but got \e"$n\e""
+ }
+ if {$n < 2} {
+ \fBreturn\fR 1
+ }
+ set m [expr {$n - 1}]
+ set code [catch {factorial $m} factor]
+ if {$code != 0} {
+ \fBreturn\fR -code $code $factor
+ }
+ set product [expr {$n * $factor}]
+ if {$product < 0} {
+ \fBreturn\fR -code error \e
+ "overflow computing factorial of $n"
+ }
+ \fBreturn\fR $product
}
.CE
.PP
@@ -259,7 +259,7 @@ Next, a procedure replacement for \fBbreak\fR.
.PP
.CS
proc myBreak {} {
- \fBreturn\fR -code break
+ \fBreturn\fR -code break
}
.CE
.PP
@@ -275,13 +275,13 @@ re-raise a caught error:
.PP
.CS
proc doSomething {} {
- set resource [allocate]
- catch {
- # Long script of operations
- # that might raise an error
- } result options
- deallocate $resource
- \fBreturn\fR -options $options $result
+ set resource [allocate]
+ catch {
+ # Long script of operations
+ # that might raise an error
+ } result options
+ deallocate $resource
+ \fBreturn\fR -options $options $result
}
.CE
.PP
@@ -290,14 +290,14 @@ to create a procedure replacement for \fBreturn\fR itself:
.PP
.CS
proc myReturn {args} {
- set result ""
- if {[llength $args] % 2} {
- set result [lindex $args end]
- set args [lrange $args 0 end-1]
- }
- set options [dict merge {-level 1} $args]
- dict incr options -level
- \fBreturn\fR -options $options $result
+ set result ""
+ if {[llength $args] % 2} {
+ set result [lindex $args end]
+ set args [lrange $args 0 end-1]
+ }
+ set options [dict merge {-level 1} $args]
+ dict incr options -level
+ \fBreturn\fR -options $options $result
}
.CE
.SH "SEE ALSO"
diff --git a/doc/scan.n b/doc/scan.n
index 48b5df1..7f2eb65 100644
--- a/doc/scan.n
+++ b/doc/scan.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: scan.n,v 1.28 2009/02/24 21:04:58 dkf Exp $
+'\" RCS: @(#) $Id: scan.n,v 1.29 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH scan n 8.4 Tcl "Tcl Built-In Commands"
@@ -235,11 +235,11 @@ care, we would use the \fB%i\fR conversion instead):
.CS
set string "08:08" ;# *Not* octal!
if {[\fBscan\fR $string "%d:%d" hours minutes] != 2} {
- error "not a valid time string"
+ error "not a valid time string"
}
# We have to understand numeric ranges ourselves...
if {$minutes < 0 || $minutes > 59} {
- error "invalid number of minutes"
+ error "invalid number of minutes"
}
.CE
.PP
@@ -251,8 +251,8 @@ leading whitespace correct):
set string " a string {with braced words} + leading space "
set words {}
while {[\fBscan\fR $string %s%n word length] == 2} {
- lappend words $word
- set string [string range $string $length end]
+ lappend words $word
+ set string [string range $string $length end]
}
.CE
.PP
@@ -265,10 +265,10 @@ set string "(5.2,-4e-2)"
# the scan pattern are significant, and that ")" is
# the Unicode character \eu0029
if {
- [\fBscan\fR $string " (%f ,%f %c" x y last] != 3
- || $last != 0x0029
+ [\fBscan\fR $string " (%f ,%f %c" x y last] != 3
+ || $last != 0x0029
} then {
- error "invalid coordinate string"
+ error "invalid coordinate string"
}
puts "X=$x, Y=$y"
.CE
@@ -277,16 +277,19 @@ An interactive session demonstrating the truncation of integer
values determined by size modifiers:
.PP
.CS
-% set tcl_platform(wordSize)
+\fI%\fR set tcl_platform(wordSize)
4
-% scan 20000000000000000000 %d
+\fI%\fR scan 20000000000000000000 %d
2147483647
-% scan 20000000000000000000 %ld
+\fI%\fR scan 20000000000000000000 %ld
9223372036854775807
-% scan 20000000000000000000 %lld
+\fI%\fR scan 20000000000000000000 %lld
20000000000000000000
.CE
.SH "SEE ALSO"
format(n), sscanf(3)
.SH KEYWORDS
conversion specifier, parse, scan
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/socket.n b/doc/socket.n
index 507fd6f..6fe5517 100644
--- a/doc/socket.n
+++ b/doc/socket.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: socket.n,v 1.18 2010/01/13 12:08:30 dkf Exp $
+'\" RCS: @(#) $Id: socket.n,v 1.19 2010/01/20 13:42:17 dkf Exp $
.so man.macros
.TH socket n 8.0 Tcl "Tcl Built-In Commands"
.BS
@@ -165,9 +165,9 @@ Here is a very simple time server:
.PP
.CS
proc Server {channel clientaddr clientport} {
- puts "Connection from $clientaddr registered"
- puts $channel [clock format [clock seconds]]
- close $channel
+ puts "Connection from $clientaddr registered"
+ puts $channel [clock format [clock seconds]]
+ close $channel
}
\fBsocket\fR -server Server 9900
@@ -187,3 +187,6 @@ puts "The time on $server is $line"
fconfigure(n), flush(n), open(n), read(n)
.SH KEYWORDS
asynchronous I/O, bind, channel, connection, domain name, host, network address, socket, tcp
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/source.n b/doc/source.n
index 49ecbf7..d035f72 100644
--- a/doc/source.n
+++ b/doc/source.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: source.n,v 1.20 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: source.n,v 1.21 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH source n "" Tcl "Tcl Built-In Commands"
@@ -62,7 +62,7 @@ Alternatively:
.PP
.CS
foreach scriptFile {foo.tcl bar.tcl} {
- \fBsource\fR $scriptFile
+ \fBsource\fR $scriptFile
}
.CE
.SH "SEE ALSO"
diff --git a/doc/split.n b/doc/split.n
index ef5470b..d68aaf3 100644
--- a/doc/split.n
+++ b/doc/split.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: split.n,v 1.11 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: split.n,v 1.12 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH split n "" Tcl "Tcl Built-In Commands"
@@ -77,16 +77,19 @@ set records [\fBsplit\fR $content "\en"]
## Iterate over the records
foreach rec $records {
- ## Split into fields on colons
- set fields [\fBsplit\fR $rec ":"]
+ ## Split into fields on colons
+ set fields [\fBsplit\fR $rec ":"]
- ## Assign fields to variables and print some out...
- lassign $fields \e
- userName password uid grp longName homeDir shell
- puts "$longName uses [file tail $shell] for a login shell"
+ ## Assign fields to variables and print some out...
+ lassign $fields \e
+ userName password uid grp longName homeDir shell
+ puts "$longName uses [file tail $shell] for a login shell"
}
.CE
.SH "SEE ALSO"
join(n), list(n), string(n)
.SH KEYWORDS
list, split, string
+'\" Local Variables:
+'\" mode: nroff
+'\" End:
diff --git a/doc/switch.n b/doc/switch.n
index 2f638de..ea83c0a 100644
--- a/doc/switch.n
+++ b/doc/switch.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: switch.n,v 1.20 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: switch.n,v 1.21 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH switch n 8.5 Tcl "Tcl Built-In Commands"
@@ -139,10 +139,10 @@ writing regular expressions with alternations, as can be seen here
.PP
.CS
\fBswitch\fR \-glob aaab {
- a*b \-
- b {expr {1}}
- a* {expr {2}}
- default {expr {3}}
+ a*b \-
+ b {expr {1}}
+ a* {expr {2}}
+ default {expr {3}}
}
.CE
.PP
@@ -151,17 +151,17 @@ last) is taken. This example has a result of \fI3\fR:
.PP
.CS
\fBswitch\fR xyz {
- a \-
- b {
- # Correct Comment Placement
- expr {1}
- }
- c {
- expr {2}
- }
- default {
- expr {3}
- }
+ a \-
+ b {
+ # Correct Comment Placement
+ expr {1}
+ }
+ c {
+ expr {2}
+ }
+ default {
+ expr {3}
+ }
}
.CE
.PP
@@ -170,13 +170,13 @@ exactly matched is easily obtained using the \fB\-matchvar\fR option:
.PP
.CS
\fBswitch\fR \-regexp \-matchvar foo \-\- $bar {
- a(b*)c {
- puts "Found [string length [lindex $foo 1]] 'b's"
- }
- d(e*)f(g*)h {
- puts "Found [string length [lindex $foo 1]] 'e's and\e
- [string length [lindex $foo 2]] 'g's"
- }
+ a(b*)c {
+ puts "Found [string length [lindex $foo 1]] 'b's"
+ }
+ d(e*)f(g*)h {
+ puts "Found [string length [lindex $foo 1]] 'e's and\e
+ [string length [lindex $foo 2]] 'g's"
+ }
}
.CE
.SH "SEE ALSO"
diff --git a/doc/upvar.n b/doc/upvar.n
index 08f053c..02a475d 100644
--- a/doc/upvar.n
+++ b/doc/upvar.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: upvar.n,v 1.20 2010/01/13 12:08:30 dkf Exp $
+'\" RCS: @(#) $Id: upvar.n,v 1.21 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH upvar n "" Tcl "Tcl Built-In Commands"
@@ -48,8 +48,8 @@ For example, consider the following procedure:
.PP
.CS
proc \fIadd2\fR name {
- \fBupvar\fR $name x
- set x [expr {$x + 2}]
+ \fBupvar\fR $name x
+ set x [expr {$x + 2}]
}
.CE
.PP
@@ -90,11 +90,11 @@ rather than
.PP
.CS
proc \fItraceproc\fR { name index op } {
- puts $name
+ puts $name
}
proc \fIsetByUpvar\fR { name value } {
- \fBupvar\fR $name localVar
- set localVar $value
+ \fBupvar\fR $name localVar
+ set localVar $value
}
set originalVar 1
trace variable originalVar w \fItraceproc\fR
diff --git a/doc/vwait.n b/doc/vwait.n
index 9cd95cb..d3c62ae 100644
--- a/doc/vwait.n
+++ b/doc/vwait.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: vwait.n,v 1.13 2010/01/13 12:08:30 dkf Exp $
+'\" RCS: @(#) $Id: vwait.n,v 1.14 2010/01/20 13:42:17 dkf Exp $
'\"
.so man.macros
.TH vwait n 8.0 Tcl "Tcl Built-In Commands"
@@ -63,9 +63,9 @@ close the socket and continue running the script:
after 5000 set state timeout
set server [socket -server accept 12345]
proc accept {args} {
- global state connectionInfo
- set state accepted
- set connectionInfo $args
+ global state connectionInfo
+ set state accepted
+ set connectionInfo $args
}
# Wait for something to happen
@@ -77,13 +77,13 @@ after cancel set state timeout
# Do something based on how the vwait finished...
switch $state {
- timeout {
- puts "no connection on port 12345"
- }
- accepted {
- puts "connection: $connectionInfo"
- puts [lindex $connectionInfo 0] "Hello there!"
- }
+ timeout {
+ puts "no connection on port 12345"
+ }
+ accepted {
+ puts "connection: $connectionInfo"
+ puts [lindex $connectionInfo 0] "Hello there!"
+ }
}
.CE
.PP
@@ -92,16 +92,16 @@ variable to be set. Includes an interlock to prevent nested waits.
.PP
.CS
namespace eval example {
- variable v done
- proc wait {delay} {
- variable v
- if {$v ne "waiting"} {
- set v waiting
- after $delay [namespace code {set v done}]
- \fBvwait\fR [namespace which -variable v]
- }
- return $v
- }
+ variable v done
+ proc wait {delay} {
+ variable v
+ if {$v ne "waiting"} {
+ set v waiting
+ after $delay [namespace code {set v done}]
+ \fBvwait\fR [namespace which -variable v]
+ }
+ return $v
+ }
}
.CE
.PP
@@ -111,20 +111,20 @@ is set, or at an idle moment after that.
.PP
.CS
coroutine task apply {{} {
- # simulate [after 1000]
- after 1000 [info coroutine]
- yield
+ # simulate [after 1000]
+ after 1000 [info coroutine]
+ yield
- # schedule the setting of a global variable, as normal
- after 2000 {set var 1}
+ # schedule the setting of a global variable, as normal
+ after 2000 {set var 1}
- # simulate [\fBvwait\fR var]
- proc updatedVar {task args} {
- after idle $task
- trace remove variable ::var write "updatedVar $task"
- }
- trace add variable ::var write "updatedVar [info coroutine]"
- yield
+ # simulate [\fBvwait\fR var]
+ proc updatedVar {task args} {
+ after idle $task
+ trace remove variable ::var write "updatedVar $task"
+ }
+ trace add variable ::var write "updatedVar [info coroutine]"
+ yield
}}
.CE
.SS "NESTED VWAITS BY EXAMPLE"
@@ -138,13 +138,13 @@ outer \fBvwait\fR was waiting for (the setting of \fIa\fR) has occurred.
.PP
.CS
after 500 {
- puts "waiting for b"
- \fBvwait\fR b
- puts "b was set"
+ puts "waiting for b"
+ \fBvwait\fR b
+ puts "b was set"
}
after 1000 {
- puts "setting a"
- set a 10
+ puts "setting a"
+ set a 10
}
puts "waiting for a"
\fBvwait\fR a
@@ -173,25 +173,26 @@ implicit. The first of these options would be written as:
.PP
.CS
after 500 {
- puts "waiting for b"
- trace add variable b write {apply {args {
- global a b
- trace remove variable ::b write [lrange [info level 0] 0 1]
- puts "b was set"
- set ::done ok
- }}}
+ puts "waiting for b"
+ trace add variable b write {apply {args {
+ global a b
+ trace remove variable ::b write \e
+ [lrange [info level 0] 0 1]
+ puts "b was set"
+ set ::done ok
+ }}}
}
after 1000 {
- puts "setting a"
- set a 10
+ puts "setting a"
+ set a 10
}
puts "waiting for a"
trace add variable a write {apply {args {
- global a b
- trace remove variable a write [lrange [info level 0] 0 1]
- puts "a was set"
- puts "setting b"
- set b 42
+ global a b
+ trace remove variable a write [lrange [info level 0] 0 1]
+ puts "a was set"
+ puts "setting b"
+ set b 42
}}}
\fBvwait\fR done
.CE
@@ -202,37 +203,38 @@ like this:
.CS
# A coroutine-based wait-for-variable command
proc waitvar globalVar {
- trace add variable ::$globalVar write \e
- [list apply {{v c args} {
- trace remove variable $v write [lrange [info level 0] 0 3]
- after 0 $c
- }} ::$globalVar [info coroutine]]
- yield
+ trace add variable ::$globalVar write \e
+ [list apply {{v c args} {
+ trace remove variable $v write \e
+ [lrange [info level 0] 0 3]
+ after 0 $c
+ }} ::$globalVar [info coroutine]]
+ yield
}
# A coroutine-based wait-for-some-time command
proc waittime ms {
- after $ms [info coroutine]
- yield
+ after $ms [info coroutine]
+ yield
}
coroutine task-1 eval {
- puts "waiting for a"
- waitvar a
- puts "a was set"
- puts "setting b"
- set b 42
+ puts "waiting for a"
+ waitvar a
+ puts "a was set"
+ puts "setting b"
+ set b 42
}
coroutine task-2 eval {
- waittime 500
- puts "waiting for b"
- waitvar b
- puts "b was set"
- set done ok
+ waittime 500
+ puts "waiting for b"
+ waitvar b
+ puts "b was set"
+ set done ok
}
coroutine task-3 eval {
- waittime 1000
- puts "setting a"
- set a 10
+ waittime 1000
+ puts "setting a"
+ set a 10
}
\fBvwait\fR done
.CE