aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-11-30 07:58:43 +0000
committerdos-reis <gdr@axiomatics.org>2010-11-30 07:58:43 +0000
commit816865ca0322b9d413aaf562cbf5dd648f9c1038 (patch)
treebad734df4facb483e57f0922942d355939c3146a /src/interp
parentc81dbb595ec1d8352d3cfd420ef1b6926b861a78 (diff)
downloadopen-axiom-816865ca0322b9d413aaf562cbf5dd648f9c1038.tar.gz
Fix SF/2110371
* interp/i-toplev.boot (recordAndPrint): Tidy. (SpadInterpretFile): Move to int-top.boot. * interp/int-top.boot (ncINTERPFILE): Simplify. (ncloopPrintLines): Output onto the standard output stream. (ncloopIncFileName): Issue diagnostic on error output stream. * interp/setvars.boot (setOutputAlgebra): Fix thinko. (setStandardOutputToAlgebraStream): New. * interp/sys-driver.boot (executeSpadScript): Use it. Set verbosity level as appropriate. Redirect output if requested.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/i-toplev.boot5
-rw-r--r--src/interp/int-top.boot28
-rw-r--r--src/interp/setvars.boot15
-rw-r--r--src/interp/sys-driver.boot27
4 files changed, 43 insertions, 32 deletions
diff --git a/src/interp/i-toplev.boot b/src/interp/i-toplev.boot
index 416537f3..09f12bed 100644
--- a/src/interp/i-toplev.boot
+++ b/src/interp/i-toplev.boot
@@ -196,7 +196,7 @@ recordAndPrint(x,md) ==
mode:= (md=$EmptyMode => quadSch(); md)
if (md ~= $Void) or $printVoidIfTrue then
newlineIfDisplaying()
- if $QuietCommand = false then
+ if not $QuietCommand then
output(x',md')
putHist('%,'value,objNewWrap(x,md),$e)
if $printTimeIfTrue or $printTypeIfTrue then printTypeAndTime(x',md')
@@ -331,9 +331,6 @@ intProcessSynonyms str ==
intInterpretPform pf ==
processInteractive(zeroOneTran packageTran pf2Sex pf, pf)
-SpadInterpretFile fn ==
- SpadInterpretStream(1, fn, nil)
-
intNewFloat() ==
["Float"]
diff --git a/src/interp/int-top.boot b/src/interp/int-top.boot
index 90455fae..a200fc17 100644
--- a/src/interp/int-top.boot
+++ b/src/interp/int-top.boot
@@ -44,14 +44,9 @@ ncParseFromString s ==
zeroOneTran packageTran CATCH($SpadReaderTag, parseFromString s)
ncINTERPFILE(file, echo) ==
- savedEcho := $EchoLines
- savedReadingFile := $ReadingFile
- $EchoLines: fluid := echo
- $ReadingFile: fluid := true
- result := SpadInterpretFile file
- $EchoLines := savedEcho
- $ReadingFile := savedReadingFile
- result
+ $EchoLines: local := echo
+ $ReadingFile: local := true
+ SpadInterpretFile file
ncGetFunction(op, dom, sig) ==
applyInPackage(function getNCfunction,_
@@ -150,6 +145,9 @@ SpadInterpretStream(str, source, interactive?) ==
-----------------------------------------------------------------
+SpadInterpretFile fn ==
+ SpadInterpretStream(1, fn, nil)
+
intloopReadConsole(b, n)==
a:= serverReadLine $InputStream
not string? a => leaveScratchpad()
@@ -324,15 +322,15 @@ streamChop(n,s)==
[[d,:a],b]
ncloopPrintLines lines ==
- for line in lines repeat writeLine rest line
- writeLine '" "
+ for line in lines repeat writeLine(rest line,$OutputStream)
+ writeLine('" ",$OutputStream)
ncloopIncFileName string==
- fn := incFileName string
- not fn =>
- writeLine (strconc(string, '" not found"))
- []
- fn
+ fn := incFileName string
+ not fn =>
+ writeLine(strconc(string, '" not found"),$ErrorStream)
+ []
+ fn
ncloopParse s==
[dq,stream]:=first s
diff --git a/src/interp/setvars.boot b/src/interp/setvars.boot
index 2fced3b3..ed8423ab 100644
--- a/src/interp/setvars.boot
+++ b/src/interp/setvars.boot
@@ -987,10 +987,11 @@ setOutputAlgebra arg ==
-- try to figure out what the argument is
- if arg is [fn] and
- fn in '(Y N YE YES NO O ON OF OFF CONSOLE y n ye yes no o on of off console)
- then 'ok
- else arg := [fn,'spout]
+ if arg is [fn] then
+ arg :=
+ fn in '(Y N YE YES NO O ON OF OFF CONSOLE
+ y n ye yes no o on of off console) => arg
+ [fn,'spout]
arg is [fn] =>
UPCASE(fn) in '(Y N YE O OF) =>
@@ -1048,6 +1049,12 @@ describeSetOutputAlgebra() ==
'"The current setting is: ",'%b,setOutputAlgebra "%display%",'%d]
+++ In case we are catching the output, we are also interested in
+++ redirecting traffic on the standard output to that capturing stream.
+setStandardOutputToAlgebraStream() ==
+ $OutputStream := $algebraOutputStream
+
+
-- See the subsection output characters in setvart.boot
--
-- -------------------- The characters Option --------------------
diff --git a/src/interp/sys-driver.boot b/src/interp/sys-driver.boot
index fa76a020..f450e397 100644
--- a/src/interp/sys-driver.boot
+++ b/src/interp/sys-driver.boot
@@ -246,17 +246,26 @@ initializeGlobalState() ==
++ execute Spad script
executeSpadScript(progname,options,file) ==
- $displayStartMsgs := false
+ -- By default, we want script execution to be as quiet as possible.
+ $displayStartMsgs: local := false
+ -- $ProcessInteractiveValue: local := true
+ $verbose: local := false
initializeGlobalState()
- if $verbose then
- $options := []
- $ProcessInteractiveValue := false
- else
- $options := [["quiet"]]
- $ProcessInteractiveValue := true
- $PrintCompilerMessageIfTrue := $verbose
+ outfile := getOptionValue "output"
+ talkative := outfile or $verbose
+ setOutputAlgebra [(talkative => 'on; 'off)]
+ -- FIXME: redirect standard output to null if not talkative
+ $printVoidIfTrue: local := talkative
+ $printTypeIfTrue: local := talkative
+ $options :=
+ talkative => []
+ [["quiet"]]
+ $PrintCompilerMessageIfTrue: local := talkative
+ if outfile ~= nil then
+ setOutputAlgebra [outfile]
+ setStandardOutputToAlgebraStream()
CATCH($intCoerceFailure,
- CATCH($SpadReaderTag,read [file]))
+ CATCH($SpadReaderTag,read [file]))
coreQuit (errorCount()> 0 => 1; 0)
associateRequestWithFileType(Option '"script", '"input",