-/* $NetBSD: arithmetic.c,v 1.14 2000/04/14 05:58:01 simonb Exp $ */
+/* $NetBSD: arithmetic.c,v 1.18 2002/03/31 04:07:22 hubertf Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: arithmetic.c,v 1.14 2000/04/14 05:58:01 simonb Exp $");
+__RCSID("$NetBSD: arithmetic.c,v 1.18 2002/03/31 04:07:22 hubertf Exp $");
#endif
#endif /* not lint */
int opnum __P((int));
void penalise __P((int, int, int));
int problem __P((void));
-void showstats __P((void));
+void showstats __P((int));
void usage __P((void)) __attribute__((__noreturn__));
const char keylist[] = "+-x/";
int ch, cnt;
/* Revoke setgid privileges */
- setregid(getgid(), getgid());
+ setgid(getgid());
while ((ch = getopt(argc, argv, "r:o:")) != -1)
switch(ch) {
for (cnt = NQUESTS; cnt--;)
if (problem() == EOF)
exit(0);
- showstats();
+ showstats(0);
}
/* NOTREACHED */
}
intr(dummy)
int dummy __attribute__((__unused__));
{
- showstats();
+ showstats(1);
exit(0);
}
/* Print score. Original `arithmetic' had a delay after printing it. */
void
-showstats()
+showstats(bool_sigint)
+ int bool_sigint;
{
if (nright + nwrong > 0) {
(void)printf("\n\nRights %d; Wrongs %d; Score %d%%",
(void)printf("\nTotal time %ld seconds; %.1f seconds per problem\n\n",
(long)qtime, (float)qtime / nright);
}
+ if(!bool_sigint) {
+ (void)printf("Press RETURN to continue...\n");
+ while(!getchar()) ;
+ }
(void)printf("\n");
}
void
usage()
{
- extern char *__progname; /* from crt0.o */
-
- (void)fprintf(stderr, "usage: %s [-o +-x/] [-r range]\n",
- __progname);
+ (void)fprintf(stderr, "Usage: %s [-o +-x/] [-r range]\n",
+ getprogname());
exit(1);
}