mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Cosmetics
Change-Id: I8036046d2e755de2e77ef5bf6502008d4ada0e49
This commit is contained in:
parent
334777eb6e
commit
b4cc24e31e
1 changed files with 141 additions and 134 deletions
|
@ -17,6 +17,7 @@ import org.eclipse.osgi.service.environment.Constants;
|
|||
|
||||
/**
|
||||
* Utilities to work with command line, parse arguments, etc.
|
||||
*
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||
* @since 5.1
|
||||
|
@ -36,16 +37,18 @@ public class CommandLineUtil {
|
|||
return argumentsToArrayUnixStyle(line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing arguments in a shell style.
|
||||
* i.e.
|
||||
* <code>
|
||||
* Parsing arguments in a shell style. i.e.
|
||||
*
|
||||
* <pre>
|
||||
* ["a b c" d] -> [[a b c],[d]]
|
||||
* [a d] -> [[a],[d]]
|
||||
* ['"quoted"'] -> [["quoted"]]
|
||||
* [\\ \" \a] -> [[\],["],[a]]
|
||||
* ["str\\str\a"] -> [[str\str\a]]
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @param line
|
||||
* @return array of arguments, or empty array if line is null or empty
|
||||
*/
|
||||
|
@ -73,7 +76,8 @@ public class CommandLineUtil {
|
|||
// fall through
|
||||
case INITIAL:
|
||||
if (Character.isWhitespace(c)) {
|
||||
if (state == INITIAL) break; // ignore extra spaces
|
||||
if (state == INITIAL)
|
||||
break; // ignore extra spaces
|
||||
// add argument
|
||||
state = INITIAL;
|
||||
String arg = buffer.toString();
|
||||
|
@ -143,23 +147,24 @@ public class CommandLineUtil {
|
|||
}
|
||||
}
|
||||
|
||||
if (state != INITIAL) { // this allow to process empty string as an argument
|
||||
if (state != INITIAL) { // this allow to process empty string as an
|
||||
// argument
|
||||
aList.add(buffer.toString());
|
||||
}
|
||||
return aList.toArray(new String[aList.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parsing arguments in a cmd style.
|
||||
* i.e.
|
||||
* <code>
|
||||
* Parsing arguments in a cmd style. i.e.
|
||||
*
|
||||
* <pre>
|
||||
* ["a b c" d] -> [[a b c],[d]]
|
||||
* [a d] -> [[a],[d]]
|
||||
* ['"quoted"'] -> [['quoted']]
|
||||
* [\\ \" \a] -> [[\\],["],[\a]]
|
||||
* ["str\\str\a"] -> [[str\\str\a]]
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @param line
|
||||
* @return array of arguments, or empty array if line is null or empty
|
||||
*/
|
||||
|
@ -186,7 +191,8 @@ public class CommandLineUtil {
|
|||
// fall through
|
||||
case INITIAL:
|
||||
if (Character.isWhitespace(c)) {
|
||||
if (state == INITIAL) break; // ignore extra spaces
|
||||
if (state == INITIAL)
|
||||
break; // ignore extra spaces
|
||||
// add argument
|
||||
state = INITIAL;
|
||||
String arg = buffer.toString();
|
||||
|
@ -248,7 +254,8 @@ public class CommandLineUtil {
|
|||
}
|
||||
}
|
||||
|
||||
if (state != INITIAL) { // this allow to process empty string as an argument
|
||||
if (state != INITIAL) { // this allow to process empty string as an
|
||||
// argument
|
||||
aList.add(buffer.toString());
|
||||
}
|
||||
return aList.toArray(new String[aList.size()]);
|
||||
|
|
Loading…
Add table
Reference in a new issue