summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2023-05-31 10:33:01 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2023-05-31 10:33:01 (GMT)
commit38c9c34398bc61793d4794a1c4dadb3a36f23847 (patch)
tree60950a8e49337252996f44d01e2adcfb7292ae94 /library
parentd3acda84955821249bc38d697afe3cc890ac1bf2 (diff)
downloadtcl-38c9c34398bc61793d4794a1c4dadb3a36f23847.zip
tcl-38c9c34398bc61793d4794a1c4dadb3a36f23847.tar.gz
tcl-38c9c34398bc61793d4794a1c4dadb3a36f23847.tar.bz2
Swapped foreachLine arg order, improved docs
Diffstat (limited to 'library')
-rw-r--r--library/foreachline.tcl2
-rw-r--r--library/readfile.tcl2
-rw-r--r--library/writefile.tcl5
3 files changed, 5 insertions, 4 deletions
diff --git a/library/foreachline.tcl b/library/foreachline.tcl
index 06ad62a..aacbd5b 100644
--- a/library/foreachline.tcl
+++ b/library/foreachline.tcl
@@ -9,7 +9,7 @@
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-proc foreachLine {filename varName body} {
+proc foreachLine {varName filename body} {
upvar 1 $varName line
set f [open $filename "r"]
try {
diff --git a/library/readfile.tcl b/library/readfile.tcl
index 350bcd4..c1d5b84 100644
--- a/library/readfile.tcl
+++ b/library/readfile.tcl
@@ -14,7 +14,7 @@ proc readFile {filename {mode text}} {
set mode [tcl::prefix match -message "mode" -error $ERR $MODES $mode]
# Read the file
- set f [open $filename [expr {$mode eq "text" ? "r" : "rb"}]]
+ set f [open $filename [dict get {text r binary rb} $mode]]
try {
return [read $f]
} finally {
diff --git a/library/writefile.tcl b/library/writefile.tcl
index ca3bbcc..fbd9138 100644
--- a/library/writefile.tcl
+++ b/library/writefile.tcl
@@ -21,13 +21,14 @@ proc writeFile {args} {
set mode [tcl::prefix match -message "mode" -error $ERR $MODES $mode]
}
default {
+ set COMMAND [lindex [info level 0] 0]
return -code error -errorcode {TCL WRONGARGS} \
- "wrong # args: should be \"[lindex [info level 0] 0] filename ?mode? data\""
+ "wrong # args: should be \"$COMMAND filename ?mode? data\""
}
}
# Write the file
- set f [open $filename [expr {$mode eq "text" ? "w" : "wb"}]]
+ set f [open $filename [dict get {text w binary wb} $mode]]
try {
puts -nonewline $f $data
} finally {