From candy@kgc.co.jp  Wed Feb  1 05:32:32 1995
Received: from uucp0.iij.ad.jp (uucp0.iij.ad.jp [192.244.176.51]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id FAA10142 for <FreeBSD-gnats-submit@freebsd.org>; Wed, 1 Feb 1995 05:32:31 -0800
Received: (from uucp@localhost) by uucp0.iij.ad.jp (8.6.9+2.4Wb/3.3Wb-UUCP) with UUCP id WAA00488 for FreeBSD-gnats-submit@freebsd.org; Wed, 1 Feb 1995 22:32:16 +0900
Received: from xxx.kgc.co.jp (xxx.kgc.co.jp [192.168.1.8]) by fender.kgc.co.jp (8.6.9+2.4W/3.3W8:95013123) with ESMTP id WAA14428 for <FreeBSD-gnats-submit@freebsd.org>; Wed, 1 Feb 1995 22:29:46 +0900
Received: (from candy@localhost) by xxx.kgc.co.jp (8.6.9/3.3W8:95020114) id WAA24373; Wed, 1 Feb 1995 22:29:45 +0900
Message-Id: <199502011329.WAA24373@xxx.kgc.co.jp>
Date: Wed, 1 Feb 1995 22:29:45 +0900
From: candy@kgc.co.jp
Reply-To: candy@kgc.co.jp
To: FreeBSD-gnats-submit@freebsd.org
Subject: quiz(6) reading database bug, pattern matching bug
X-Send-Pr-Version: 3.2

>Number:         199
>Category:       bin
>Synopsis:       quiz(6) reading database bug, pattern matching bug
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb  1 05:40:01 1995
>Closed-Date:    Sun May 26 13:27:27 PDT 1996
>Last-Modified:  Sun May 26 13:28:37 PDT 1996
>Originator:     Toshihiro Kanda
>Release:        FreeBSD 2.0-RELEASE i386
>Organization:
Keisokugiken corp.
>Environment:

	2.0-RELEASE

>Description:

Quiz(6) doesn't parse database line which ends with '\' correctly.
So, quiz does not ask all questions, and does not recognize
correct answer.

>How-To-Repeat:

First, `quiz function ed-command' asks only 6 questions.
After fixing it, second, see below.

$ grep -A1 'replace "ATT"' /usr/share/games/quiz.db/ed
replace "ATT" in current line by "AT&T":\
[s|.s]/ATT/AT\\&T/{g}{p}

$ quiz function ed-command
replace "ATT" in current line by "AT&T"?
s/ATT/AT\&T/
What?

>Fix:

diff -cr /tmp/usr/src/games/quiz/quiz.c ./quiz.c
*** /tmp/usr/src/games/quiz/quiz.c	Sun Sep  4 13:03:08 1994
--- ./quiz.c	Tue Jan 31 11:03:12 1995
***************
*** 316,326 ****
  	if ((m = malloc(strlen(s) + len + 1)) == NULL)
  		err("%s", strerror(errno));
  	for (mp = m, sp = s; *mp++ = *sp++;);
  
  	if (*(mp - 1) == '\\')
  		--mp;
! 	while ((ch = *mp++ = *tp++) && ch != '\n');
! 	*mp = '\0';
  
  	free(s);
  	return (m);
--- 316,329 ----
  	if ((m = malloc(strlen(s) + len + 1)) == NULL)
  		err("%s", strerror(errno));
  	for (mp = m, sp = s; *mp++ = *sp++;);
+ 	mp--;
  
  	if (*(mp - 1) == '\\')
  		--mp;
! 	memcpy(mp, tp, len);
! 	mp[len] = '\0';
! 	if (mp[len - 1] == '\n')
! 		mp[len - 1] = '\0';
  
  	free(s);
  	return (m);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: scrappy 
State-Changed-When: Sun May 26 13:27:27 PDT 1996 
State-Changed-Why:  
applied submitted patch to -current 
>Unformatted:


