aboutsummaryrefslogtreecommitdiff
path: root/tclcompat.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-12-06 20:21:55 +1000
committerSteve Bennett <steveb@workware.net.au>2010-12-06 21:01:32 +1000
commit66a081898ffe0ebc643284160b4e937872274c5f (patch)
tree5da59fd2b02f5fd1b8ee11303d4749d87e98e3db /tclcompat.tcl
parent3fb099f57df1392661a2f49f3437759b73d36065 (diff)
downloadjimtcl-66a081898ffe0ebc643284160b4e937872274c5f.zip
jimtcl-66a081898ffe0ebc643284160b4e937872274c5f.tar.gz
jimtcl-66a081898ffe0ebc643284160b4e937872274c5f.tar.bz2
Make tclcompat work without aio
This is an unusual case, but useful for testing Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tclcompat.tcl')
-rw-r--r--tclcompat.tcl45
1 files changed, 23 insertions, 22 deletions
diff --git a/tclcompat.tcl b/tclcompat.tcl
index 0f9bec9..bd0cedc 100644
--- a/tclcompat.tcl
+++ b/tclcompat.tcl
@@ -7,35 +7,36 @@
# Set up the ::env array
set env [env]
-# Tcl-compatible I/O commands
-foreach p {gets flush close eof seek tell} {
- proc $p {chan args} {p} {
- tailcall $chan $p {*}$args
+if {[info commands stdout] ne ""} {
+ # Tcl-compatible I/O commands
+ foreach p {gets flush close eof seek tell} {
+ proc $p {chan args} {p} {
+ tailcall $chan $p {*}$args
+ }
}
-}
-unset p
+ unset p
-# puts is complicated by -nonewline
-#
-proc puts {{-nonewline {}} {chan stdout} msg} {
- if {${-nonewline} ni {-nonewline {}}} {
- tailcall ${-nonewline} puts $msg
+ # puts is complicated by -nonewline
+ #
+ proc puts {{-nonewline {}} {chan stdout} msg} {
+ if {${-nonewline} ni {-nonewline {}}} {
+ tailcall ${-nonewline} puts $msg
+ }
+ tailcall $chan puts {*}${-nonewline} $msg
}
- tailcall $chan puts {*}${-nonewline} $msg
-}
-# read is complicated by -nonewline
-#
-# read chan ?maxchars?
-# read -nonewline chan
-proc read {{-nonewline {}} chan} {
- if {${-nonewline} ni {-nonewline {}}} {
- tailcall ${-nonewline} read {*}${chan}
+ # read is complicated by -nonewline
+ #
+ # read chan ?maxchars?
+ # read -nonewline chan
+ proc read {{-nonewline {}} chan} {
+ if {${-nonewline} ni {-nonewline {}}} {
+ tailcall ${-nonewline} read {*}${chan}
+ }
+ tailcall $chan read {*}${-nonewline}
}
- tailcall $chan read {*}${-nonewline}
}
-
# case var ?in? pattern action ?pattern action ...?
proc case {var args} {
# Skip dummy parameter