Skip to content

Commit debf055

Browse files
committed
OptionParser: add white space trimming.
1 parent 6eaa4a6 commit debf055

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

prism/src/prism/OptionParser.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ void printOptions(PrismLog log)
291291
void parse(String optionsString, String switchName) throws PrismException
292292
{
293293
if (optionsString == null || optionsString.isEmpty()) return;
294-
for (String opt : optionsString.split(",")) {
294+
for (String rawOpt : optionsString.split(",")) {
295+
String opt = rawOpt.trim();
295296
if (opt.isEmpty()) continue;
296297
int eq = opt.indexOf('=');
297298
if (eq == -1) {
@@ -301,8 +302,8 @@ void parse(String optionsString, String switchName) throws PrismException
301302
throw new PrismException("No value provided for \"" + opt + "\" option of -" + switchName);
302303
throw new PrismException("Unknown option \"" + opt + "\" for -" + switchName + " switch");
303304
} else {
304-
String key = opt.substring(0, eq);
305-
String val = opt.substring(eq + 1);
305+
String key = opt.substring(0, eq).trim();
306+
String val = opt.substring(eq + 1).trim();
306307
ValueHandler vh = valueHandlers.get(key);
307308
if (vh != null) { vh.accept(key, val, switchName); continue; }
308309
if (flagHandlers.containsKey(key))

0 commit comments

Comments
 (0)