[refactor] Reduced complexity of argument reading by one by refactoring
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
51d8caa51e
commit
63de5448de
@ -146,10 +146,7 @@ public final class GCLCConstants {
|
||||
continue;
|
||||
}
|
||||
if (c == ' ' && !inString) {
|
||||
final String arg = cmd.substring(startIndex, index - 1);
|
||||
if (!arg.isEmpty()) {
|
||||
args.add(removeEscaped(arg));
|
||||
}
|
||||
addArgument(args, cmd.substring(startIndex, index - 1));
|
||||
startIndex = index;
|
||||
} else if (c == '"') {
|
||||
if (inString) {
|
||||
@ -169,4 +166,13 @@ public final class GCLCConstants {
|
||||
return args;
|
||||
}
|
||||
|
||||
/** Add an argument to the list of arguments if it is not an empty string.
|
||||
*
|
||||
* @param args the list of argument
|
||||
* @param arg the candidate argument */
|
||||
private static void addArgument(final List<String> args, final String arg) {
|
||||
if (!arg.isEmpty()) {
|
||||
args.add(removeEscaped(arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user