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 void
Arguments::Parse(int argc, const char* const* argv) Arguments::Parse(int argc, const char* const* argv)
{ {
int argi = 1; int argi;
while (argi < argc) { for (argi = 1; argi < argc; argi ++) {
const char* arg = argv[argi++]; const char* arg = argv[argi];
if (*arg == '-') { if (*arg == '-') {
if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0)
fUsageRequested = true; fUsageRequested = true;
else if (strcmp(arg, "-t") == 0 || strcmp(arg, "--title") == 0) {
/*} 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) {
// title // title
if (argi >= argc) if (argi >= argc)
fUsageRequested = true; fUsageRequested = true;
else else
fTitle = argv[argi++]; 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; fFullScreen = true;
argi++; else {
} else {
// illegal option // illegal option
fprintf(stderr, B_TRANSLATE("Unrecognized option \"%s\"\n"), fprintf(stderr, B_TRANSLATE("Unrecognized option \"%s\"\n"),
arg); arg);
fUsageRequested = true; fUsageRequested = true;
} }
} else { } else {
// no option, so the remainder is the shell program with arguments // 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; argi = argc;
fStandardShell = false; fStandardShell = false;
} }