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:
joey
2003-12-19 19:12:08 +00:00
parent 351c8ca204
commit 51eabc017b
310 changed files with 7852 additions and 5005 deletions

View File

@@ -1,15 +1,19 @@
# $NetBSD: Makefile,v 1.11 1997/03/24 22:15:48 christos Exp $
# $NetBSD: Makefile,v 1.13 1999/02/13 02:54:22 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
PROG= quiz
MAN= quiz.6
SRCS= quiz.c rxp.c
HIDEGAME=hidegame
.if ${MKSHARE} != "no"
CATS= africa america areas arith asia babies bard chinese collectives \
ed elements europe flowers greek inca index latin locomotive \
midearth morse mult murders poetry posneg pres province seq-easy \
seq-hard sexes sov spell state trek ucc
HIDEGAME=hidegame
FILES= ${CATS:S@^@${.CURDIR}/datfiles/@}
FILESDIR=/usr/share/games/quiz.db
.endif
.include <bsd.prog.mk>

View File

@@ -1,5 +1,32 @@
# Makefrag - makefile fragment for quiz
#
# Copyright (c) 1997, 1998, 1999 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.
quiz_DEFS := $(FGETLN_DEFS)
quiz_DIRS := $(GAMESDIR) $(MAN6DIR)
quiz_all: quiz/quiz quiz/quiz.6

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: quiz.6,v 1.6 1997/09/20 14:28:16 lukem Exp $
.\" $NetBSD: quiz.6,v 1.9 2002/09/26 18:32:03 wiz Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -71,16 +71,18 @@ You can pick any two categories from the same subject.
.Nm
will ask questions from the first category and it expects answers from
the second category.
For example, the command ``quiz victim killer'' asks questions which are
the names of victims, and expects you to answer with the cause of their
untimely demise, whereas the command ``quiz killer victim'' works the
other way around.
For example, the command
.Dq quiz victim killer
asks questions which are the names of victims, and expects you to answer
with the cause of their untimely demise, whereas the command
.Dq quiz killer victim
works the other way around.
.Pp
If you get the answer wrong,
.Nm
lets you try again.
To see the right answer, enter a blank line.
.Sh "Index and Data File Syntax"
.Ss Index and Data File Syntax
The index and data files have a similar syntax.
Lines in them consist of several categories separated by colons.
The categories are regular expressions formed using the following

View File

@@ -1,4 +1,4 @@
/* $NetBSD: quiz.c,v 1.13 1998/09/13 15:27:29 hubertf Exp $ */
/* $NetBSD: quiz.c,v 1.18 2000/05/08 07:56:05 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
#if 0
static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: quiz.c,v 1.13 1998/09/13 15:27:29 hubertf Exp $");
__RCSID("$NetBSD: quiz.c,v 1.18 2000/05/08 07:56:05 mycroft Exp $");
#endif
#endif /* not lint */
@@ -69,12 +69,12 @@ static QE qlist;
static int catone, cattwo, tflag;
static u_int qsize;
char *appdstr __P((char *, char *, size_t));
char *appdstr __P((char *, const char *, size_t));
void downcase __P((char *));
void get_cats __P((char *, char *));
void get_file __P((char *));
void get_file __P((const char *));
int main __P((int, char *[]));
char *next_cat __P((char *));
const char *next_cat __P((const char *));
void quiz __P((void));
void score __P((u_int, u_int, u_int));
void show_index __P((void));
@@ -86,7 +86,7 @@ main(argc, argv)
char *argv[];
{
int ch;
char *indexfile;
const char *indexfile;
/* Revoke setgid privileges */
setregid(getgid(), getgid());
@@ -125,7 +125,7 @@ main(argc, argv)
void
get_file(file)
char *file;
const char *file;
{
FILE *fp;
QE *qp;
@@ -167,9 +167,9 @@ void
show_index()
{
QE *qp;
char *p, *s;
const char *p, *s;
FILE *pf;
char *pager;
const char *pager;
if (!isatty(1))
pager = "cat";
@@ -178,7 +178,7 @@ show_index()
pager = _PATH_PAGER;
}
if ((pf = popen(pager, "w")) == NULL)
err(1, "%s", _PATH_PAGER);
err(1, "%s", pager);
(void)fprintf(pf, "Subjects:\n\n");
for (qp = qlist.q_next; qp; qp = qp->q_next) {
for (s = next_cat(qp->q_text); s; s = next_cat(s)) {
@@ -202,7 +202,7 @@ get_cats(cat1, cat2)
{
QE *qp;
int i;
char *s;
const char *s;
downcase(cat1);
downcase(cat2);
@@ -237,7 +237,8 @@ quiz()
size_t len;
u_int guesses, rights, wrongs;
int next;
char *answer, *s, *t, question[LINE_SZ];
char *answer, *t, question[LINE_SZ];
const char *s;
srandom(time(NULL));
guesses = rights = wrongs = 0;
@@ -311,9 +312,9 @@ quiz()
score(rights, wrongs, guesses);
}
char *
const char *
next_cat(s)
char * s;
const char * s;
{
int esc;
@@ -338,10 +339,11 @@ next_cat(s)
char *
appdstr(s, tp, len)
char *s;
char *tp;
const char *tp;
size_t len;
{
char *mp, *sp;
char *mp;
const char *sp;
int ch;
char *m;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: quiz.h,v 1.4 1995/04/22 10:16:59 cgd Exp $ */
/* $NetBSD: quiz.h,v 1.5 1999/09/08 21:17:56 jsm Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -58,6 +58,6 @@ typedef struct qentry {
extern char rxperr[];
int rxp_compile __P((char *));
int rxp_compile __P((const char *));
char *rxp_expand __P((void));
int rxp_match __P((char *));
int rxp_match __P((const char *));

View File

@@ -1,4 +1,4 @@
/* $NetBSD: rxp.c,v 1.6 1997/09/20 14:28:19 lukem Exp $ */
/* $NetBSD: rxp.c,v 1.10 2002/12/06 01:54:55 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)rxp.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: rxp.c,v 1.6 1997/09/20 14:28:19 lukem Exp $");
__RCSID("$NetBSD: rxp.c,v 1.10 2002/12/06 01:54:55 thorpej Exp $");
#endif
#endif /* not lint */
@@ -68,6 +68,7 @@ __RCSID("$NetBSD: rxp.c,v 1.6 1997/09/20 14:28:19 lukem Exp $");
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "quiz.h"
/* regexp tokens, arg */
@@ -85,24 +86,24 @@ typedef short Rxp_t; /* type for regexp tokens */
static Rxp_t rxpbuf[RXP_LINE_SZ]; /* compiled regular expression buffer */
char rxperr[128]; /* parser error message */
static int rxp__compile __P((char *, int));
static int rxp__compile __P((const char *, int));
static char *rxp__expand __P((int));
static int rxp__match __P((char *, int, Rxp_t *, Rxp_t *, char *));
static int rxp__match __P((const char *, int, Rxp_t *, Rxp_t *, const char *));
int
rxp_compile(s)
char * s;
const char * s;
{
return (rxp__compile(s, TRUE));
}
static int
rxp__compile(s, first)
char *s;
const char *s;
int first;
{
static Rxp_t *rp;
static char *sp;
static const char *sp;
Rxp_t *grp_ptr;
Rxp_t *alt_ptr;
int esc, err;
@@ -196,24 +197,23 @@ rxp__compile(s, first)
*/
int
rxp_match(s)
char * s;
const char * s;
{
return (rxp__match(s, TRUE, NULL, NULL, NULL));
}
static int
rxp__match(s, first, j_succ, j_fail, sp_fail)
char *s;
const char *s;
int first;
Rxp_t *j_succ; /* jump here on successful alt match */
Rxp_t *j_fail; /* jump here on failed match */
char *sp_fail; /* reset sp to here on failed match */
const char *sp_fail; /* reset sp to here on failed match */
{
static Rxp_t *rp;
static char *sp;
static const char *sp;
int ch;
Rxp_t *grp_end = NULL;
int err;
if (first) {
rp = rxpbuf;
@@ -227,7 +227,7 @@ rxp__match(s, first, j_succ, j_fail, sp_fail)
if (ch != *sp++) {
rp = j_fail;
sp = sp_fail;
return (TRUE);
return (FALSE);
}
rp++;
break;
@@ -247,16 +247,17 @@ rxp__match(s, first, j_succ, j_fail, sp_fail)
break;
case ALT_S:
rp++;
if ((err = rxp__match(sp,
FALSE, grp_end, rxpbuf + *rp++, sp)) != TRUE)
return (err);
rxp__match(sp, FALSE, grp_end, rxpbuf + *rp++, sp);
break;
case ALT_E:
rp = j_succ;
return (TRUE);
case GRP_E:
default:
rp = j_fail;
sp = sp_fail;
return (FALSE);
default:
abort();
}
return (*rp != END ? FALSE : TRUE);
}