From 420bbf283f1a022a91aa7a12e964503468cf79c6 Mon Sep 17 00:00:00 2001 From: ronny Date: Thu, 1 Nov 2001 15:07:35 +0000 Subject: added --dump-args and --restore-args options git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@876 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- main/coclmain.icl | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'main') diff --git a/main/coclmain.icl b/main/coclmain.icl index 4e6d3ca..f19b269 100644 --- a/main/coclmain.icl +++ b/main/coclmain.icl @@ -56,14 +56,64 @@ coclMainWithVersionCheck currentVersion latestDefVersion latestImpVersion testA } | not (fst (checkVersion (versionCompare expectedVersion observedVersion) stderr)) = set_return_code (-1) world + # (commandArgs, world) + = getCommandArgs (tl [arg \\ arg <-: getCommandLine]) testArgs world # (success, world) = accFiles (compiler commandArgs) world = set_return_code (if success 0(-1)) world where - commandArgs - = if (length realArgs == 0) testArgs realArgs - realArgs - = tl [arg \\ arg <-: getCommandLine] + getCommandArgs :: [{#Char}] [{#Char}] *World -> ([{#Char}], *World) + getCommandArgs [] testArgs world + = getArgs testArgs world + getCommandArgs realArgs _ world + = getArgs realArgs world + + getArgs :: [{#Char}] *World -> ([{#Char}], *World) + getArgs ["--dump-args" : commandArgs] world + # (opened, file, world) + = fopen CoclArgsFile FWriteText world + | not opened + = abort ("--dump-args " +++ CoclArgsFile +++ " could not be opened\n") + # file + = foldSt (\s -> fwritec '\n' o fwrites s) commandArgs file + # (closed, world) + = fclose file world + | not closed + = abort ("--dump-args " +++ CoclArgsFile +++ " could not be closed\n") + = (commandArgs, world) + getArgs ["--restore-args"] world + # (opened, file, world) + = fopen CoclArgsFile FReadText world + | not opened + = abort ("--restore-args " +++ CoclArgsFile +++ " could not be opened\n") + # (commandArgs, file) + = readArgs [] file + # (closed, world) + = fclose file world + | not closed + = abort ("--restore-args " +++ CoclArgsFile +++ " could not be closed\n") + = (commandArgs, world) + where + readArgs :: [{#Char}] *File -> ([{#Char}], *File) + readArgs reversedArgs file + # (arg, file) + = freadline file + | arg == "" + = (reverse reversedArgs, file) + // otherwise + = readArgs [chopNewline arg : reversedArgs] file + + chopNewline :: {#Char} -> {#Char} + chopNewline s + | s.[n-1] == '\n' + = s % (0, n-2) + // otherwise + = s + where + n + = size s + +CoclArgsFile :== "coclargs.txt" import thread_message; -- cgit v1.2.3