mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
copy in from cvs; cvs2svn fucked up big time
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
@@ -1,4 +1,30 @@
|
||||
# Makefrag - makefile fragment for arithmetic
|
||||
#
|
||||
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
arithmetic_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: arithmetic.6,v 1.6 1998/04/28 07:19:28 fair Exp $
|
||||
.\" $NetBSD: arithmetic.6,v 1.9 2002/09/26 18:31:58 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -38,7 +38,7 @@
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dt ARITHMETIC 6
|
||||
.Os BSD 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm arithmetic
|
||||
.Nd quiz on simple arithmetic
|
||||
@@ -54,7 +54,7 @@ After every 20 problems, it prints the score so far and the time taken.
|
||||
You can quit at any time by typing the interrupt or end-of-file character.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width indent
|
||||
.It Fl o
|
||||
By default,
|
||||
.Nm
|
||||
@@ -81,7 +81,8 @@ divide by or subtract will be between 0 and
|
||||
.Ar range .
|
||||
(Of course,
|
||||
.Nm
|
||||
will not ask you to divide by 0.) The default
|
||||
will not ask you to divide by 0.)
|
||||
The default
|
||||
.I range
|
||||
is 10.
|
||||
.El
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: arithmetic.c,v 1.12 1998/09/14 09:13:46 hubertf Exp $ */
|
||||
/* $NetBSD: arithmetic.c,v 1.18 2002/03/31 04:07:22 hubertf Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: arithmetic.c,v 1.12 1998/09/14 09:13:46 hubertf Exp $");
|
||||
__RCSID("$NetBSD: arithmetic.c,v 1.18 2002/03/31 04:07:22 hubertf Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -94,7 +94,7 @@ int main __P((int, char *[]));
|
||||
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/";
|
||||
@@ -106,6 +106,8 @@ int nright, nwrong;
|
||||
time_t qtime;
|
||||
#define NQUESTS 20
|
||||
|
||||
extern char *__progname; /* from crt0.o */
|
||||
|
||||
/*
|
||||
* Select keys from +-x/ to be asked addition, subtraction, multiplication,
|
||||
* and division problems. More than one key may be given. The default is
|
||||
@@ -118,8 +120,6 @@ main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
int ch, cnt;
|
||||
|
||||
/* Revoke setgid privileges */
|
||||
@@ -157,7 +157,7 @@ main(argc, argv)
|
||||
for (cnt = NQUESTS; cnt--;)
|
||||
if (problem() == EOF)
|
||||
exit(0);
|
||||
showstats();
|
||||
showstats(0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@@ -165,15 +165,16 @@ main(argc, argv)
|
||||
/* Handle interrupt character. Print score and exit. */
|
||||
void
|
||||
intr(dummy)
|
||||
int dummy __attribute__((unused));
|
||||
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%%",
|
||||
@@ -182,6 +183,10 @@ showstats()
|
||||
(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");
|
||||
}
|
||||
|
||||
@@ -388,9 +393,7 @@ opnum(op)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
extern char *__progname; /* from crt0.o */
|
||||
|
||||
(void)fprintf(stderr, "usage: %s [-o +-x/] [-r range]\n",
|
||||
(void)fprintf(stderr, "Usage: %s [-o +-x/] [-r range]\n",
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user