diff options
author | ronny | 2001-11-01 15:07:35 +0000 |
---|---|---|
committer | ronny | 2001-11-01 15:07:35 +0000 |
commit | 420bbf283f1a022a91aa7a12e964503468cf79c6 (patch) | |
tree | 1e322703badfca8ac1682709e2174607eaf48fc0 /main | |
parent | removed useless selection (diff) |
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
Diffstat (limited to 'main')
-rw-r--r-- | main/coclmain.icl | 58 |
1 files changed, 54 insertions, 4 deletions
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; |