diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | doc/fblocked.n | 4 | ||||
-rw-r--r-- | doc/fconfigure.n | 18 | ||||
-rw-r--r-- | doc/file.n | 14 | ||||
-rw-r--r-- | doc/fileevent.n | 15 | ||||
-rw-r--r-- | doc/flush.n | 4 | ||||
-rw-r--r-- | doc/for.n | 6 | ||||
-rw-r--r-- | doc/foreach.n | 8 | ||||
-rw-r--r-- | doc/format.n | 28 | ||||
-rw-r--r-- | doc/gets.n | 7 | ||||
-rw-r--r-- | doc/glob.n | 16 | ||||
-rw-r--r-- | doc/global.n | 12 | ||||
-rw-r--r-- | doc/http.n | 61 | ||||
-rw-r--r-- | doc/if.n | 24 | ||||
-rw-r--r-- | doc/incr.n | 16 | ||||
-rw-r--r-- | doc/info.n | 8 | ||||
-rw-r--r-- | doc/interp.n | 26 | ||||
-rw-r--r-- | doc/join.n | 8 | ||||
-rw-r--r-- | doc/lappend.n | 6 | ||||
-rw-r--r-- | doc/lindex.n | 22 | ||||
-rw-r--r-- | doc/linsert.n | 10 | ||||
-rw-r--r-- | doc/list.n | 10 | ||||
-rw-r--r-- | doc/llength.n | 18 | ||||
-rw-r--r-- | doc/load.n | 16 | ||||
-rw-r--r-- | doc/lrange.n | 17 | ||||
-rw-r--r-- | doc/lreplace.n | 13 | ||||
-rw-r--r-- | doc/lsort.n | 24 |
27 files changed, 202 insertions, 211 deletions
@@ -1,6 +1,6 @@ 2004-10-27 Donal K. Fellows <donal.k.fellows@man.ac.uk> - * doc/[a-e]*.n: Many small general documentation fixes. + * doc/[a-l]*.n: Many small general documentation fixes. 2004-10-26 David Gravereaux <davygrvy@pobox.com> diff --git a/doc/fblocked.n b/doc/fblocked.n index 0132a7b..89545eb 100644 --- a/doc/fblocked.n +++ b/doc/fblocked.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: fblocked.n,v 1.5 2004/05/28 12:23:50 dkf Exp $ +'\" RCS: @(#) $Id: fblocked.n,v 1.6 2004/10/27 12:53:22 dkf Exp $ .so man.macros .TH fblocked n 7.5 Tcl "Tcl Built-In Commands" .BS @@ -36,7 +36,7 @@ The \fBfblocked\fR command is particularly useful when writing network servers, as it allows you to write your code in a line-by-line style without preventing the servicing of other connections. This can be seen in this simple echo-service: - +.PP .CS # This is called whenever a new client connects to the server proc connect {chan host port} { diff --git a/doc/fconfigure.n b/doc/fconfigure.n index dcea8cd..807ce90 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.10 2004/05/20 21:18:44 dkf Exp $ +'\" RCS: @(#) $Id: fconfigure.n,v 1.11 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH fconfigure n 8.3 Tcl "Tcl Built-In Commands" @@ -204,14 +204,14 @@ sockets and thus support the socket options. Instruct Tcl to always send output to \fBstdout\fR immediately, whether or not it is to a terminal: .CS -fconfigure stdout -buffering none +\fBfconfigure\fR stdout -buffering none .CE - +.PP Open a socket and read lines from it without ever blocking the processing of other events: .CS set s [socket some.where.com 12345] -fconfigure $s -blocking 0 +\fBfconfigure\fR $s -blocking 0 fileevent $s readable "readMe $s" proc readMe chan { if {[gets $chan line] < 0} { @@ -227,12 +227,12 @@ proc readMe chan { } } .CE - +.PP Read a PPM-format image from a file: .CS # Open the file and put it into Unix ASCII mode set f [open teapot.ppm] -fconfigure $f \-encoding ascii \-translation lf +\fBfconfigure\fR $f \-encoding ascii \-translation lf # Get the header if {[gets $f] ne "P6"} { @@ -249,12 +249,12 @@ while {[llength $words] < 3} { } # Those words supply the size of the image and its -# overall depth per channel. +# overall depth per channel. Assign to variables. lassign $words xSize ySize depth # Now switch to binary mode to pull in the data, -# one byte per channel (red,gree,blue) per pixel. -fconfigure $f \-translation binary +# one byte per channel (red,green,blue) per pixel. +\fBfconfigure\fR $f \-translation binary set numDataBytes [expr {3 * $xSize * $ySize}] set data [read $f $numDataBytes] @@ -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.36 2004/08/31 15:19:36 dkf Exp $ +'\" RCS: @(#) $Id: file.n,v 1.37 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH file n 8.3 Tcl "Tcl Built-In Commands" @@ -447,8 +447,8 @@ proc findMatchingCFiles {dir} { } } foreach file [glob -nocomplain -directory $dir *.c] { - set objectFile [file tail [file rootname $file]]$ext - if {[file exists $objectFile]} { + set objectFile [\fBfile\fR tail [\fBfile\fR rootname $file]]$ext + if {[\fBfile\fR exists $objectFile]} { lappend files $file } } @@ -462,11 +462,11 @@ to the new place: set oldName foobar.txt set newName foo/bar.txt # Make sure that where we're going to move to exists... -if {![file isdirectory [file dirname $newName]]} { - file mkdir [file dirname $newName] +if {![\fBfile\fR isdirectory [\fBfile\fR dirname $newName]]} { + \fBfile\fR mkdir [\fBfile\fR dirname $newName] } -file rename $oldName $newName -file link -symbolic $oldName $newName +\fBfile\fR rename $oldName $newName +\fBfile\fR link -symbolic $oldName $newName .CE .SH "SEE ALSO" diff --git a/doc/fileevent.n b/doc/fileevent.n index 8e82564..f5ac7fc 100644 --- a/doc/fileevent.n +++ b/doc/fileevent.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: fileevent.n,v 1.5 2001/09/27 05:50:56 andreas_kupries Exp $ +'\" RCS: @(#) $Id: fileevent.n,v 1.6 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH fileevent n 7.5 Tcl "Tcl Built-In Commands" @@ -100,21 +100,18 @@ If an error occurs while executing the script then the In addition, the file event handler is deleted if it ever returns an error; this is done in order to prevent infinite loops due to buggy handlers. - .SH EXAMPLE -.PP +In this setup \fBGetData\fR will be called with the channel as an +argument whenever $chan becomes readable. .CS - proc GetData {chan} { +proc GetData {chan} { if {![eof $chan]} { puts [gets $chan] } - } - - fileevent $chan readable [list GetData $chan] +} +\fBfileevent\fR $chan readable [list GetData $chan] .CE -In this setup \fBGetData\fR will be called with the channel as an -argument whenever $chan becomes readable. .SH CREDITS .PP diff --git a/doc/flush.n b/doc/flush.n index 0bb308c..fa009c2 100644 --- a/doc/flush.n +++ b/doc/flush.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: flush.n,v 1.5 2004/05/27 15:40:07 dkf Exp $ +'\" RCS: @(#) $Id: flush.n,v 1.6 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH flush n 7.5 Tcl "Tcl Built-In Commands" @@ -38,7 +38,7 @@ underlying file or device is able to absorb it. Prompt for the user to type some information in on the console: .CS puts -nonewline "Please type your name: " -flush stdout +\fBflush\fR stdout gets stdin name puts "Hello there, $name!" .CE @@ -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.4 2004/05/05 22:08:10 dkf Exp $ +'\" RCS: @(#) $Id: for.n,v 1.5 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH for n "" Tcl "Tcl Built-In Commands" @@ -56,7 +56,7 @@ for {set x 0} {$x<10} {incr x} { puts "x is $x" } .CE - +.PP Either loop infinitely or not at all because the expression being evaluated is actually the constant, or even generate an error! The actual behaviour will depend on whether the variable \fIx\fR exists @@ -69,7 +69,7 @@ for {set x 0} $x<10 {incr x} { puts "x is $x" } .CE - +.PP Print out the powers of two from 1 to 1024: .CS for {set x 1} {$x<=1024} {set x [expr {$x * 2}]} { diff --git a/doc/foreach.n b/doc/foreach.n index 09faa2a..7054708 100644 --- a/doc/foreach.n +++ b/doc/foreach.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: foreach.n,v 1.3 2000/09/07 14:27:48 poenitz Exp $ +'\" RCS: @(#) $Id: foreach.n,v 1.4 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH foreach n "" Tcl "Tcl Built-In Commands" @@ -56,7 +56,7 @@ The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. .DS set x {} -foreach {i j} {a b c d e f} { +\fBforeach\fR {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" @@ -66,7 +66,7 @@ foreach {i j} {a b c d e f} { The next loop uses i and j to iterate over two lists in parallel. .DS set x {} -foreach i {a b c} j {d e f g} { +\fBforeach\fR i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" @@ -76,7 +76,7 @@ foreach i {a b c} j {d e f g} { The two forms are combined in the following example. .DS set x {} -foreach i {a b c} {j k} {d e f g} { +\fBforeach\fR i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" diff --git a/doc/format.n b/doc/format.n index b17d67c..0a25957 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.9 2004/08/31 15:19:36 dkf Exp $ +'\" RCS: @(#) $Id: format.n,v 1.10 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH format n 8.1 Tcl "Tcl Built-In Commands" @@ -219,33 +219,29 @@ are ignored on all other conversions. .SH EXAMPLES Convert the output of \fBtime\fR into seconds to an accuracy of hundredths of a second: - .CS set us [lindex [time $someTclCode] 0] -puts [format "%.2f seconds to execute" [expr {$us / 1e6}]] +puts [\fBformat\fR "%.2f seconds to execute" [expr {$us / 1e6}]] .CE - +.PP Create a packed X11 literal color specification: - .CS # Each color-component should be in range (0..255) -set color [format "#%02x%02x%02x" $r $g $b] +set color [\fBformat\fR "#%02x%02x%02x" $r $g $b] .CE - +.PP Use XPG3 format codes to allow reordering of fields (a technique that is often used in localized message catalogs; see \fBmsgcat\fR) without -reordering the data values passed to format: - +reordering the data values passed to \fBformat\fR: .CS set fmt1 "Today, %d shares in %s were bought at $%.2f each" -puts [format $fmt1 123 "Global BigCorp" 19.37] +puts [\fBformat\fR $fmt1 123 "Global BigCorp" 19.37] set fmt2 "Bought %2\\$s equity ($%3$.2f x %1\\$d) today" -puts [format $fmt2 123 "Global BigCorp" 19.37] +puts [\fBformat\fR $fmt2 123 "Global BigCorp" 19.37] .CE - +.PP Print a small table of powers of three: - .CS # Set up the column widths set w1 5 @@ -254,13 +250,13 @@ set w2 10 # Make a nice header (with separator) for the table first set sep +-[string repeat - $w1]-+-[string repeat - $w2]-+ puts $sep -puts [format "| %-*s | %-*s |" $w1 "Index" $w2 "Power"] +puts [\fBformat\fR "| %-*s | %-*s |" $w1 "Index" $w2 "Power"] puts $sep # Print the contents of the table set p 1 for {set i 0} {$i<=20} {incr i} { - puts [format "| %*d | %*ld |" $w1 $i $w2 $p] + puts [\fBformat\fR "| %*d | %*ld |" $w1 $i $w2 $p] set p [expr {wide($p) * 3}] } @@ -269,7 +265,7 @@ puts $sep .CE .SH "SEE ALSO" -sprintf(3), string(n) +scan(n), sprintf(3), string(n) .SH KEYWORDS conversion specifier, format, sprintf, string, substitution @@ -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: gets.n,v 1.5 2004/04/16 10:28:55 dkf Exp $ +'\" RCS: @(#) $Id: gets.n,v 1.6 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH gets n 7.5 Tcl "Tcl Built-In Commands" @@ -51,15 +51,14 @@ produce the same results as if there were an input line consisting only of the end-of-line character(s). The \fBeof\fR and \fBfblocked\fR commands can be used to distinguish these three cases. - .SH "EXAMPLE" This example reads a file one line at a time and prints it out with the current line number attached to the start of each line. - +.PP .CS set chan [open "some.file.txt"] set lineNumber 0 -while {[gets $chan line] >= 0} { +while {[\fBgets\fR $chan line] >= 0} { puts "[incr lineNumber]: $line" } close $chan @@ -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: glob.n,v 1.16 2004/05/11 14:09:59 vincentdarley Exp $ +'\" RCS: @(#) $Id: glob.n,v 1.17 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH glob n 8.3 Tcl "Tcl Built-In Commands" @@ -185,23 +185,23 @@ join $path\fR (or \fBfile normalize $path\fR in Tcl 8.4). .SH EXAMPLES Find all the Tcl files in the current directory: .CS -glob *.tcl +\fBglob\fR *.tcl .CE - +.PP Find all the Tcl files in the user's home directory, irrespective of what the current directory is: .CS -glob \-directory ~ *.tcl +\fBglob\fR \-directory ~ *.tcl .CE - +.PP Find all subdirectories of the current directory: .CS -glob \-type d * +\fBglob\fR \-type d * .CE - +.PP Find all files whose name contains an "a", a "b" or the sequence "cde": .CS -glob \-type f *{a,b,cde}* +\fBglob\fR \-type f *{a,b,cde}* .CE .SH "SEE ALSO" diff --git a/doc/global.n b/doc/global.n index 4555d68..a11e88b 100644 --- a/doc/global.n +++ b/doc/global.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: global.n,v 1.8 2004/05/29 18:50:32 jenglish Exp $ +'\" RCS: @(#) $Id: global.n,v 1.9 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH global n "" Tcl "Tcl Built-In Commands" @@ -23,7 +23,7 @@ This command has no effect unless executed in the context of a proc body. If the \fBglobal\fR command is executed in the context of a proc body, it creates local variables linked to the corresponding global variables (and therefore these variables are listed by info locals). - +.PP If \fIvarname\fR contains namespace qualifiers, the local variable's name is the unqualified name of the global variable, as determined by the \fBnamespace tail\fR command. @@ -31,15 +31,15 @@ the unqualified name of the global variable, as determined by the \fIvarname\fR is always treated as the name of a variable, not an array element. An error is returned if the name looks like an array element, such as \fBa(b)\fR. -.SH "EXAMPLE 1" +.SH EXAMPLES This procedure sets the namespace variable \fI::a::x\fR .CS proc reset {} { - global a::x + \fBglobal\fR a::x set x 0 } .CE -.SH "EXAMPLE 2" +.PP This procedure accumulates the strings passed to it in a global buffer, separated by newlines. It is useful for situations when you want to build a message piece-by-piece (as if with \fBputs\fR) but @@ -47,7 +47,7 @@ send that full message in a single piece (e.g. over a connection opened with \fBsocket\fR or as part of a counted HTTP response). .CS proc accum {string} { - global accumulator + \fBglobal\fR accumulator append accumulator $string \\n } .CE @@ -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.22 2004/09/06 09:44:57 dkf Exp $ +'\" RCS: @(#) $Id: http.n,v 1.23 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH "http" n 2.5 http "Tcl Bundled Packages" @@ -497,38 +497,41 @@ A copy of the \fBContent-Type\fR meta-data value. The requested URL. .RE .SH EXAMPLE -.DS +.CS # Copy a URL to a file and print meta-data -proc ::http::copy { url file {chunk 4096} } { - set out [open $file w] - set token [geturl $url -channel $out -progress ::http::Progress \\ - -blocksize $chunk] - close $out - # This ends the line started by ::http::Progress - 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 [copy [string trim $value] $file $chunk] - } - } - incr max - foreach {name value} $state(meta) { - puts [format "%-*s %s" $max $name: $value] - } +proc httpcopy { url file {chunk 4096} } { + set out [open $file w] + set token [\fB::http::geturl\fR $url -channel $out \\ + -progress httpCopyProgress -blocksize $chunk] + close $out + + # This ends the line started by httpCopyProgress + puts stderr "" - return $token + 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 } -proc ::http::Progress {args} { - puts -nonewline stderr . ; flush stderr +proc httpCopyProgress {args} { + puts -nonewline stderr . + flush stderr } -.DE +.CE .SH "SEE ALSO" safe(n), socket(n), safesock(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.4 2004/04/30 20:25:26 dkf Exp $ +'\" RCS: @(#) $Id: if.n,v 1.5 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH if n "" Tcl "Tcl Built-In Commands" @@ -41,35 +41,35 @@ if none of the expressions was non-zero and there was no \fIbodyN\fR. .SH EXAMPLES A simple conditional: .CS -if {$vbl == 1} { puts "vbl is one" } +\fBif\fR {$vbl == 1} { puts "vbl is one" } .CE - +.PP With an \fBelse\fR-clause: .CS -if {$vbl == 1} { +\fBif\fR {$vbl == 1} { puts "vbl is one" -} else { +} \fBelse\fR { puts "vbl is not one" } .CE - +.PP With an \fBelseif\fR-clause too: .CS -if {$vbl == 1} { +\fBif\fR {$vbl == 1} { puts "vbl is one" -} elseif {$vbl == 2} { +} \fBelseif\fR {$vbl == 2} { puts "vbl is two" -} else { +} \fBelse\fR { puts "vbl is not one or two" } .CE - +.PP Remember, expressions can be multi-line, but in that case it can be a good idea to use the optional \fBthen\fR keyword for clarity: .CS -if { +\fBif\fR { $vbl == 1 || $vbl == 2 || $vbl == 3 -} then { +} \fBthen\fR { puts "vbl is one, two or three" } .CE @@ -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: incr.n,v 1.4 2004/04/30 22:45:56 dkf Exp $ +'\" RCS: @(#) $Id: incr.n,v 1.5 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH incr n "" Tcl "Tcl Built-In Commands" @@ -29,25 +29,25 @@ and also returned as result. .SH EXAMPLES Add one to the contents of the variable \fIx\fR: .CS -incr x +\fBincr\fR x .CE - +.PP Add 42 to the contents of the variable \fIx\fR: .CS -incr x 42 +\fBincr\fR x 42 .CE - +.PP Add the contents of the variable \fIy\fR to the contents of the variable \fIx\fR: .CS -incr x $y +\fBincr\fR x $y .CE - +.PP Add nothing at all to the variable \fIx\fR (often useful for checking whether an argument to a procedure is actually numeric and generating an error if it is not): .CS -incr x 0 +\fBincr\fR x 0 .CE .SH "SEE ALSO" @@ -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: info.n,v 1.12 2004/10/25 22:03:31 dkf Exp $ +'\" RCS: @(#) $Id: info.n,v 1.13 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH info n 8.4 Tcl "Tcl Built-In Commands" @@ -214,8 +214,8 @@ script: proc printProc {procName} { set result [list proc $procName] set formals {} - foreach var [info args $procName] { - if {[info default $procName $var def]} { + foreach var [\fBinfo\fR args $procName] { + if {[\fBinfo\fR default $procName $var def]} { lappend formals [list $var $def] } else { # Still need the list-quoting because variable @@ -223,7 +223,7 @@ proc printProc {procName} { lappend formals [list $var] } } - puts [lappend result $formals [info body $procName]] + puts [lappend result $formals [\fBinfo\fR body $procName]] } .CE diff --git a/doc/interp.n b/doc/interp.n index 17eae53..e219d15 100644 --- a/doc/interp.n +++ b/doc/interp.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: interp.n,v 1.17 2004/09/21 16:20:02 dkf Exp $ +'\" RCS: @(#) $Id: interp.n,v 1.18 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH interp n 7.6 Tcl "Tcl Built-In Commands" @@ -717,30 +717,30 @@ by Nathaniel Borenstein and Marshall Rose. .SH EXAMPLES Creating and using an alias for a command in the current interpreter: .CS -interp alias {} getIndex {} lsearch {alpha beta gamma delta} +\fBinterp\fR alias {} getIndex {} lsearch {alpha beta gamma delta} set idx [getIndex delta] .CE - -.VS 8.5 +.PP Executing an arbitrary command in a safe interpreter where every invokation of \fBlappend\fR is logged: .CS -set i [interp create -safe] -$i hide lappend -$i alias lappend loggedLappend $i +set i [\fBinterp\fR create -safe] +\fBinterp\fR hide $i lappend +\fBinterp\fR alias $i lappend {} loggedLappend $i proc loggedLappend {i args} { puts "logged invokation of lappend $args" - $i invokehidden lappend {expand}$args + \fBinterp\fR invokehidden $i lappend {expand}$args } -$i eval $someUntrustedScript +\fBinterp\fR eval $i $someUntrustedScript .CE - +.PP +.VS 8.5 Setting a resource limit on an interpreter so that an infinite loop terminates. .CS -set i [interp create] -$i limit command -value 1000 -$i eval { +set i [\fBinterp\fR create] +\fBinterp\fR limit $i command -value 1000 +\fBinterp\fR eval $i { set x 0 while {1} { puts "Counting up... [incr x]" @@ -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: join.n,v 1.4 2004/05/11 21:31:43 dkf Exp $ +'\" RCS: @(#) $Id: join.n,v 1.5 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH join n "" Tcl "Tcl Built-In Commands" @@ -28,14 +28,14 @@ The \fIjoinString\fR argument defaults to a space character. Making a comma-separated list: .CS set data {1 2 3 4 5} -join $data ", " +\fBjoin\fR $data ", " \fB=> 1, 2, 3, 4, 5\fR .CE - +.PP Using \fBjoin\fR to flatten a list by a single level: .CS set data {1 {2 3} 4 {5 {6 7} 8}} -join $data +\fBjoin\fR $data \fB=> 1 2 3 4 5 {6 7} 8\fR .CE diff --git a/doc/lappend.n b/doc/lappend.n index 732370b..92f2394 100644 --- a/doc/lappend.n +++ b/doc/lappend.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: lappend.n,v 1.8 2004/05/18 20:59:24 dkf Exp $ +'\" RCS: @(#) $Id: lappend.n,v 1.9 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH lappend n "" Tcl "Tcl Built-In Commands" @@ -36,9 +36,9 @@ Using \fBlappend\fR to build up a list of numbers. .CS % set var 1 1 -% lappend var 2 +% \fBlappend\fR var 2 1 2 -% lappend var 3 4 5 +% \fBlappend\fR var 3 4 5 1 2 3 4 5 .CE diff --git a/doc/lindex.n b/doc/lindex.n index 81e8bd0..de16a6e 100644 --- a/doc/lindex.n +++ b/doc/lindex.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: lindex.n,v 1.7 2001/11/14 23:15:33 hobbs Exp $ +'\" RCS: @(#) $Id: lindex.n,v 1.8 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH lindex n 8.4 Tcl "Tcl Built-In Commands" @@ -69,16 +69,16 @@ lindex [lindex [lindex $a 1] 2] 3 .CE .SH EXAMPLES .CS -lindex {a b c} => a b c -lindex {a b c} {} => a b c -lindex {a b c} 0 => a -lindex {a b c} 2 => c -lindex {a b c} end => c -lindex {a b c} end-1 => b -lindex {{a b c} {d e f} {g h i}} 2 1 => h -lindex {{a b c} {d e f} {g h i}} {2 1} => h -lindex {{{a b} {c d}} {{e f} {g h}}} 1 1 0 => g -lindex {{{a b} {c d}} {{e f} {g h}}} {1 1 0} => g +\fBlindex\fR {a b c} \fI=> a b c\fR +\fBlindex\fR {a b c} {} \fI=> a b c\fR +\fBlindex\fR {a b c} 0 \fI=> a\fR +\fBlindex\fR {a b c} 2 \fI=> c\fR +\fBlindex\fR {a b c} end \fI=> c\fR +\fBlindex\fR {a b c} end-1 \fI=> b\fR +\fBlindex\fR {{a b c} {d e f} {g h i}} 2 1 \fI=> h\fR +\fBlindex\fR {{a b c} {d e f} {g h i}} {2 1} \fI=> h\fR +\fBlindex\fR {{{a b} {c d}} {{e f} {g h}}} 1 1 0 \fI=> g\fR +\fBlindex\fR {{{a b} {c d}} {{e f} {g h}}} {1 1 0} \fI=> g\fR .CE .VE .SH "SEE ALSO" diff --git a/doc/linsert.n b/doc/linsert.n index eddf1ec..ff62dc1 100644 --- a/doc/linsert.n +++ b/doc/linsert.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: linsert.n,v 1.9 2004/08/31 15:19:36 dkf Exp $ +'\" RCS: @(#) $Id: linsert.n,v 1.10 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH linsert n 8.2 Tcl "Tcl Built-In Commands" @@ -29,17 +29,15 @@ value \fBend\fR, or if it is greater than or equal to the number of elements in the list, then the new elements are appended to the list. \fBend\-\fIinteger\fR refers to the last element in the list minus the specified integer offset. - .SH EXAMPLE Putting some values into a list, first indexing from the start and then indexing from the end, and then chaining them together: - .CS set oldList {the fox jumps over the dog} -set midList [linsert $oldList 1 quick] -set newList [linsert $midList end-1 lazy] +set midList [\fBlinsert\fR $oldList 1 quick] +set newList [\fBlinsert\fR $midList end-1 lazy] # The old lists still exist though... -set newerList [linsert [linsert $oldList end-1 quick] 1 lazy] +set newerList [\fBlinsert\fR [\fBlinsert\fR $oldList end-1 quick] 1 lazy] .CE .SH "SEE ALSO" @@ -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: list.n,v 1.9 2004/05/17 15:16:13 dkf Exp $ +'\" RCS: @(#) $Id: list.n,v 1.10 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH list n "" Tcl "Tcl Built-In Commands" @@ -32,7 +32,7 @@ the list, while \fBlist\fR works directly from the original arguments. .SH EXAMPLE The command .CS -list a b "c d e " " f {g h}" +\fBlist\fR a b "c d e " " f {g h}" .CE will return .CS @@ -44,11 +44,11 @@ while \fBconcat\fR with the same arguments will return .CE .SH "SEE ALSO" -lappend(n), lindex(n), linsert(n), llength(n), +lappend(n), lindex(n), linsert(n), llength(n), lrange(n), .VS 8.5 lrepeat(n), -.VE -lrange(n), lreplace(n), lsearch(n), lset(n), lsort(n) +.VE 8.5 +lreplace(n), lsearch(n), lset(n), lsort(n) .SH KEYWORDS element, list diff --git a/doc/llength.n b/doc/llength.n index f784614..6b395b6 100644 --- a/doc/llength.n +++ b/doc/llength.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: llength.n,v 1.7 2004/04/16 22:20:58 dkf Exp $ +'\" RCS: @(#) $Id: llength.n,v 1.8 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH llength n "" Tcl "Tcl Built-In Commands" @@ -26,26 +26,26 @@ the number of elements in it. .SH EXAMPLES The result is the number of elements: .CS -% llength {a b c d e} +% \fBllength\fR {a b c d e} 5 -% llength {a b c} +% \fBllength\fR {a b c} 3 -% llength {} +% \fBllength\fR {} 0 .CE - +.PP Elements are not guaranteed to be exactly words in a dictionary sense of course, especially when quoting is used: .CS -% llength {a b {c d} e} +% \fBllength\fR {a b {c d} e} 4 -% llength {a b { } c d e} +% \fBllength\fR {a b { } c d e} 6 .CE - +.PP An empty list is not necessarily an empty string: .CS -% set var { }; puts "[string length $var],[llength $var]" +% set var { }; puts "[string length $var],[\fBllength\fR $var]" 1,0 .CE @@ -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.11 2004/09/06 09:44:57 dkf Exp $ +'\" RCS: @(#) $Id: load.n,v 1.12 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH load n 7.5 Tcl "Tcl Built-In Commands" @@ -122,7 +122,7 @@ When loading a DLL in the current directory, Windows will ignore ``./'' as a path specifier and use a search heuristic to find the DLL instead. To avoid this, load the DLL with: .CS -load [file join [pwd] mylib.DLL] +\fBload\fR [file join [pwd] mylib.DLL] .CE .SH BUGS .PP @@ -158,12 +158,12 @@ it can then be loaded into Tcl with the following: .CS # Load the extension switch $tcl_platform(platform) { - windows { - \fBload\fR ./foo.dll - } - unix { - \fBload\fR ./libfoo[info sharedlibextension] - } + windows { + \fBload\fR ./foo.dll + } + unix { + \fBload\fR ./libfoo[info sharedlibextension] + } } # Now execute the command defined by the extension diff --git a/doc/lrange.n b/doc/lrange.n index 86c124e..06ecd56d 100644 --- a/doc/lrange.n +++ b/doc/lrange.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: lrange.n,v 1.8 2004/05/29 18:50:33 jenglish Exp $ +'\" RCS: @(#) $Id: lrange.n,v 1.9 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH lrange n 7.4 Tcl "Tcl Built-In Commands" @@ -35,26 +35,25 @@ Note: ``\fBlrange \fIlist first first\fR'' does not always produce the same result as ``\fBlindex \fIlist first\fR'' (although it often does for simple fields that aren't enclosed in braces); it does, however, produce exactly the same results as ``\fBlist [lindex \fIlist first\fB]\fR'' - .SH EXAMPLES Selecting the first two elements: .CS -% lrange {a b c d e} 0 1 +% \fBlrange\fR {a b c d e} 0 1 a b .CE - +.PP Selecting the last three elements: .CS -% lrange {a b c d e} end-2 end +% \fBlrange\fR {a b c d e} end-2 end c d e .CE - +.PP Selecting everything except the first and last element: .CS -% lrange {a b c d e} 1 end-1 +% \fBlrange\fR {a b c d e} 1 end-1 b c d .CE - +.PP Selecting a single element with \fBlrange\fR is not the same as doing so with \fBlindex\fR: .CS @@ -62,7 +61,7 @@ so with \fBlindex\fR: some {elements to} select % lindex $var 1 elements to -% lrange $var 1 1 +% \fBlrange\fR $var 1 1 {elements to} .CE diff --git a/doc/lreplace.n b/doc/lreplace.n index 6ddec46..0a9bf6a 100644 --- a/doc/lreplace.n +++ b/doc/lreplace.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: lreplace.n,v 1.9 2004/04/16 22:20:58 dkf Exp $ +'\" RCS: @(#) $Id: lreplace.n,v 1.10 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH lreplace n 7.4 Tcl "Tcl Built-In Commands" @@ -43,25 +43,24 @@ Each \fIelement\fR argument will become a separate element of the list. If no \fIelement\fR arguments are specified, then the elements between \fIfirst\fR and \fIlast\fR are simply deleted. If \fIlist\fR is empty, any \fIelement\fR arguments are added to the end of the list. - .SH EXAMPLES Replacing an element of a list with another: .CS -% lreplace {a b c d e} 1 1 foo +% \fBlreplace\fR {a b c d e} 1 1 foo a foo c d e .CE - +.PP Replacing two elements of a list with three: .CS -% lreplace {a b c d e} 1 2 three more elements +% \fBlreplace\fR {a b c d e} 1 2 three more elements a three more elements d e .CE - +.PP Deleting the last element from a list in a variable: .CS % set var {a b c d e} a b c d e -% set var [lreplace $var end end] +% set var [\fBlreplace\fR $var end end] a b c d .CE diff --git a/doc/lsort.n b/doc/lsort.n index 9e29db3..ae7d177 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.17 2004/10/14 17:20:11 dkf Exp $ +'\" RCS: @(#) $Id: lsort.n,v 1.18 2004/10/27 12:53:22 dkf Exp $ '\" .so man.macros .TH lsort n 8.3 Tcl "Tcl Built-In Commands" @@ -129,46 +129,46 @@ option. .PP Sorting a list using ASCII sorting: .CS -% lsort {a10 B2 b1 a1 a2} +% \fBlsort\fR {a10 B2 b1 a1 a2} B2 a1 a10 a2 b1 .CE .PP Sorting a list using Dictionary sorting: .CS -% lsort -dictionary {a10 B2 b1 a1 a2} +% \fBlsort\fR -dictionary {a10 B2 b1 a1 a2} a1 a2 a10 b1 B2 .CE .PP Sorting lists of integers: .CS -% lsort -integer {5 3 1 2 11 4} +% \fBlsort\fR -integer {5 3 1 2 11 4} 1 2 3 4 5 11 -% lsort -integer {1 2 0x5 7 0 4 -1} +% \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: .CS -% lsort -real {5 3 1 2 11 4} +% \fBlsort\fR -real {5 3 1 2 11 4} 1 2 3 4 5 11 -% lsort -real {.5 0.07e1 0.4 6e-1} +% \fBlsort\fR -real {.5 0.07e1 0.4 6e-1} 0.4 .5 6e-1 0.07e1 .CE .PP Sorting using indices: .CS % # Note the space character before the c -% lsort {{a 5} { c 3} {b 4} {e 1} {d 2}} +% \fBlsort\fR {{a 5} { c 3} {b 4} {e 1} {d 2}} { c 3} {a 5} {b 4} {d 2} {e 1} -% lsort -index 0 {{a 5} { c 3} {b 4} {e 1} {d 2}} +% \fBlsort\fR -index 0 {{a 5} { c 3} {b 4} {e 1} {d 2}} {a 5} {b 4} { c 3} {d 2} {e 1} -% lsort -index 1 {{a 5} { c 3} {b 4} {e 1} {d 2}} +% \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 Stripping duplicate values using sorting: .CS -% lsort -unique {a b c a b c a b c} +% \fBlsort\fR -unique {a b c a b c a b c} a b c .CE .PP @@ -184,7 +184,7 @@ More complex sorting using a comparison function: } return [string compare [lindex $a 1] [lindex $b 1]] } -% lsort -command compare \\ +% \fBlsort\fR -command compare \\ {{3 apple} {0x2 carrot} {1 dingo} {2 banana}} {1 dingo} {2 banana} {0x2 carrot} {3 apple} .CE |