Skip to content

Commit

Permalink
kernel: move usage printing out of InitSystem
Browse files Browse the repository at this point in the history
Also remove GAP version from the usage message.
  • Loading branch information
fingolfin committed Jan 3, 2025
1 parent f580daf commit 5e291df
Showing 1 changed file with 14 additions and 26 deletions.
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 @@ static BOOL ParseMemory(Char * s, UInt *result)

#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 @@ static Int storePosInteger( Char **argv, void *Where )
}
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 @@ static Int storeMemory( Char **argv, void *Where )
{
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 @@ static Int storeMemory2( Char **argv, void *Where )
{
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 @@ void InitSystem (
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 @@ void InitSystem (
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 @@ void InitSystem (
}
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 );
}

0 comments on commit 5e291df

Please sign in to comment.