From dbbac62f710319f48e695e4cb895e14a2a879895 Mon Sep 17 00:00:00 2001 From: Mitsuru Kariya Date: Wed, 22 Jul 2015 03:01:46 +0900 Subject: [PATCH] C#: fix arguments handling The arguments handling was incorrect like below. - step6 to step8 *ARGV* was right but the filename of load-file was wrong. - stepA The filename of load-file was right but *ARGV* includes the filename. --- cs/step6_file.cs | 6 +++--- cs/step7_quote.cs | 6 +++--- cs/step8_macros.cs | 6 +++--- cs/step9_try.cs | 6 +++--- cs/stepA_mal.cs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cs/step6_file.cs b/cs/step6_file.cs index a84e87c9..361de6ba 100644 --- a/cs/step6_file.cs +++ b/cs/step6_file.cs @@ -141,13 +141,13 @@ namespace Mal { } repl_env.set(new MalSymbol("eval"), new MalFunc( a => EVAL(a[0], repl_env))); - int fileIdx = 1; + int fileIdx = 0; if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; - fileIdx = 2; + fileIdx = 1; } MalList _argv = new MalList(); - for (int i=fileIdx; i < args.Length; i++) { + for (int i=fileIdx+1; i < args.Length; i++) { _argv.conj_BANG(new MalString(args[i])); } repl_env.set(new MalSymbol("*ARGV*"), _argv); diff --git a/cs/step7_quote.cs b/cs/step7_quote.cs index 7b031521..0940ae89 100644 --- a/cs/step7_quote.cs +++ b/cs/step7_quote.cs @@ -173,13 +173,13 @@ namespace Mal { } repl_env.set(new MalSymbol("eval"), new MalFunc( a => EVAL(a[0], repl_env))); - int fileIdx = 1; + int fileIdx = 0; if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; - fileIdx = 2; + fileIdx = 1; } MalList _argv = new MalList(); - for (int i=fileIdx; i < args.Length; i++) { + for (int i=fileIdx+1; i < args.Length; i++) { _argv.conj_BANG(new MalString(args[i])); } repl_env.set(new MalSymbol("*ARGV*"), _argv); diff --git a/cs/step8_macros.cs b/cs/step8_macros.cs index cac14113..bfd9f744 100644 --- a/cs/step8_macros.cs +++ b/cs/step8_macros.cs @@ -210,13 +210,13 @@ namespace Mal { } repl_env.set(new MalSymbol("eval"), new MalFunc( a => EVAL(a[0], repl_env))); - int fileIdx = 1; + int fileIdx = 0; if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; - fileIdx = 2; + fileIdx = 1; } MalList _argv = new MalList(); - for (int i=fileIdx; i < args.Length; i++) { + for (int i=fileIdx+1; i < args.Length; i++) { _argv.conj_BANG(new MalString(args[i])); } repl_env.set(new MalSymbol("*ARGV*"), _argv); diff --git a/cs/step9_try.cs b/cs/step9_try.cs index bea360cc..0893724f 100644 --- a/cs/step9_try.cs +++ b/cs/step9_try.cs @@ -231,13 +231,13 @@ namespace Mal { } repl_env.set(new MalSymbol("eval"), new MalFunc( a => EVAL(a[0], repl_env))); - int fileIdx = 1; + int fileIdx = 0; if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; - fileIdx = 2; + fileIdx = 1; } MalList _argv = new MalList(); - for (int i=fileIdx; i < args.Length; i++) { + for (int i=fileIdx+1; i < args.Length; i++) { _argv.conj_BANG(new MalString(args[i])); } repl_env.set(new MalSymbol("*ARGV*"), _argv); diff --git a/cs/stepA_mal.cs b/cs/stepA_mal.cs index 0ccb39e2..15f62895 100644 --- a/cs/stepA_mal.cs +++ b/cs/stepA_mal.cs @@ -237,7 +237,7 @@ namespace Mal { fileIdx = 1; } MalList _argv = new MalList(); - for (int i=fileIdx; i < args.Length; i++) { + for (int i=fileIdx+1; i < args.Length; i++) { _argv.conj_BANG(new MalString(args[i])); } repl_env.set(new MalSymbol("*ARGV*"), _argv); -- 2.20.1