diff options
Diffstat (limited to 'quiz/quiz.c')
-rw-r--r-- | quiz/quiz.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/quiz/quiz.c b/quiz/quiz.c index 00e2e2a4..00fff817 100644 --- a/quiz/quiz.c +++ b/quiz/quiz.c @@ -1,9 +1,10 @@ /*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by - * Jim R. Oldroyd at The Instruction Set. + * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at + * Commodore Business Machines. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,14 +36,13 @@ */ #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1991 The Regents of the University of California.\n\ - All rights reserved.\n"; +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -/*static char sccsid[] = "from: @(#)quiz.c 5.1 (Berkeley) 11/10/91";*/ -static char rcsid[] = "$Id: quiz.c,v 1.6 1994/04/08 08:33:13 pk Exp $"; +static char sccsid[] = "@(#)quiz.c 8.2 (Berkeley) 1/3/94"; #endif /* not lint */ #include <sys/types.h> @@ -60,7 +60,7 @@ static QE qlist; static int catone, cattwo, tflag; static u_int qsize; -char *appdstr __P((char *, char *)); +char *appdstr __P((char *, char *, size_t)); void downcase __P((char *)); void get_cats __P((char *, char *)); void get_file __P((char *)); @@ -130,10 +130,9 @@ get_file(file) qp = &qlist; qsize = 0; while ((lp = fgetln(fp, &len)) != NULL) { - if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\') { - lp[len - 1] = '\0'; - qp->q_text = appdstr(qp->q_text, lp); - } else { + if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\') + qp->q_text = appdstr(qp->q_text, lp, len); + else { if ((qp->q_next = malloc(sizeof(QE))) == NULL) err(1, NULL); qp = qp->q_next; @@ -212,10 +211,10 @@ quiz() { register QE *qp; register int i; + size_t len; u_int guesses, rights, wrongs; - int len, next; - char *s, *t, question[LINE_SZ]; - char *answer; + int next; + char *answer, *s, *t, question[LINE_SZ]; srandom(time(NULL)); guesses = rights = wrongs = 0; @@ -305,18 +304,18 @@ next_cat(s) } char * -appdstr(s, tp) +appdstr(s, tp, len) char *s; register char *tp; + size_t len; { register char *mp, *sp; register int ch; char *m; - if ((m = malloc(strlen(s) + strlen(tp) + 1)) == NULL) + if ((m = malloc(strlen(s) + len + 1)) == NULL) err(1, NULL); for (mp = m, sp = s; *mp++ = *sp++;); - --mp; if (*(mp - 1) == '\\') --mp; |