Rewrite and simplify argument parsing of terminal. This makes runnning Terminal -f someApp work.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38262 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-08-19 08:53:19 +00:00
parent 49550a2089
commit a8e3f94438
+9 -34
View File
@@ -40,57 +40,32 @@ Arguments::~Arguments()
void
Arguments::Parse(int argc, const char* const* argv)
{
int argi = 1;
while (argi < argc) {
const char* arg = argv[argi++];
int argi;
for (argi = 1; argi < argc; argi ++) {
const char* arg = argv[argi];
if (*arg == '-') {
if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) {
if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0)
fUsageRequested = true;
/*} else if (strcmp(arg, "-l") == 0) {
// location
float x, y;
if (argi + 1 >= argc
|| sscanf(argv[argi++], "%f", &x) != 1
|| sscanf(argv[argi++], "%f", &y) != 1) {
print_usage_and_exit(true);
}
fBounds.OffsetTo(x, y);
} else if (strcmp(arg, "-s") == 0) {
// size
float width, height;
if (argi + 1 >= argc
|| sscanf(argv[argi++], "%f", &width) != 1
|| sscanf(argv[argi++], "%f", &height) != 1) {
print_usage_and_exit(true);
}
fBounds.right = fBounds.left + width;
fBounds.bottom = fBounds.top + height;
*/
} else if (strcmp(arg, "-t") == 0 || strcmp(arg, "--title") == 0) {
else if (strcmp(arg, "-t") == 0 || strcmp(arg, "--title") == 0) {
// title
if (argi >= argc)
fUsageRequested = true;
else
fTitle = argv[argi++];
} else if (strcmp(arg, "-f") == 0 || strcmp(arg, "--fullscreen") == 0) {
} else if (strcmp(arg, "-f") == 0 || strcmp(arg, "--fullscreen")
== 0)
fFullScreen = true;
argi++;
} else {
else {
// illegal option
fprintf(stderr, B_TRANSLATE("Unrecognized option \"%s\"\n"),
arg);
fUsageRequested = true;
}
} else {
// no option, so the remainder is the shell program with arguments
_SetShellArguments(argc - argi + 1, argv + argi - 1);
_SetShellArguments(argc - argi, argv + argi);
argi = argc;
fStandardShell = false;
}