From 0bf625b0c480624e4fa36663bd443d9f1db08c09 Mon Sep 17 00:00:00 2001 From: wuestholz Date: Tue, 28 Oct 2014 17:09:16 +0100 Subject: Fixed minor issue (reported by Alex Summers). --- Source/Core/CommandLineOptions.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/Core/CommandLineOptions.cs b/Source/Core/CommandLineOptions.cs index eca410b2..f938b0f8 100644 --- a/Source/Core/CommandLineOptions.cs +++ b/Source/Core/CommandLineOptions.cs @@ -147,12 +147,22 @@ namespace Microsoft.Boogie { /// public bool GetNumericArgument(ref int arg) { //modifies nextIndex, encounteredErrors, Console.Error.*; + return GetNumericArgument(ref arg, a => 0 <= a); + } + + /// + /// If there is one argument and the filtering predicate holds, then set "arg" to that number and return "true". + /// Otherwise, emit error message, leave "arg" unchanged, and return "false". + /// + public bool GetNumericArgument(ref int arg, Predicate filter) { + Contract.Requires(filter != null); + if (this.ConfirmArgumentCount(1)) { try { Contract.Assume(args[i] != null); Contract.Assert(args[i] is string); // needed to prove args[i].IsPeerConsistent int d = Convert.ToInt32(this.args[this.i]); - if (0 <= d) { + if (filter == null || filter(d)) { arg = d; return true; } @@ -1291,7 +1301,7 @@ namespace Microsoft.Boogie { return true; case "vcsCores": - ps.GetNumericArgument(ref VcsCores); + ps.GetNumericArgument(ref VcsCores, a => 1 <= a); return true; case "vcsLoad": -- cgit v1.2.3