Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: move usage printing out of InitSystem #5891

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@

#endif

static void usage(void)
{
fputs("usage: gap [OPTIONS] [FILES]\n", stderr);
fputs(" use '-h' option to get help.\n", stderr);
fputs("\n", stderr);
SyExit(1);

Check warning on line 370 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L367-L370

Added lines #L367 - L370 were not covered by tests
}

struct optInfo {
Char shortkey;
Char longkey[50];
Expand Down Expand Up @@ -391,7 +399,7 @@
}
if (p == argv[0] || *p || n == 0) {
fputs("Argument not a positive integer\n", stderr);
return -1;
usage();

Check warning on line 402 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L402

Added line #L402 was not covered by tests
}
*where = n;
return 1;
Expand All @@ -412,7 +420,7 @@
{
UInt * where = (UInt *)Where;
if (!ParseMemory(argv[0], where))
return -1;
usage();

Check warning on line 423 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L423

Added line #L423 was not covered by tests
return 1;
}
#endif
Expand All @@ -422,7 +430,7 @@
{
UInt * where = (UInt *)Where;
if (!ParseMemory(argv[0], where))
return -1;
usage();

Check warning on line 433 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L433

Added line #L433 was not covered by tests
*where /= 1024;
return 1;
}
Expand Down Expand Up @@ -616,7 +624,7 @@
fputs("gap: sorry, options must not be grouped '", stderr);
fputs(argv[1], stderr);
fputs("'.\n", stderr);
goto usage;
usage();

Check warning on line 627 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L627

Added line #L627 was not covered by tests
}


Expand All @@ -638,17 +646,11 @@
buf[1] = '\0';
fputs(buf, stderr);
fputs(" arguments\n", stderr);
goto usage;
usage();

Check warning on line 649 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L649

Added line #L649 was not covered by tests
}
if (options[i].handler) {
res = (*options[i].handler)(argv+2, options[i].otherArg);

switch (res)
{
case -1: goto usage;
// case -2: goto fullusage;
default: ; // fall through and continue
}
GAP_ASSERT(res == options[i].minargs);
}
else
res = options[i].minargs;
Expand Down Expand Up @@ -737,18 +739,4 @@
}
DotGapPath[strlen(DotGapPath)-1] = '\0';
}


// now we start
return;

// print a usage message
usage:
fputs("usage: gap [OPTIONS] [FILES]\n", stderr);
fputs(" run the Groups, Algorithms and Programming system, Version ", stderr);
fputs(SyBuildVersion, stderr);
fputs("\n", stderr);
fputs(" use '-h' option to get help.\n", stderr);
fputs("\n", stderr);
SyExit( 1 );
}
Loading