From nobody@FreeBSD.org  Sun Dec  4 15:42:49 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C94801065676
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 Dec 2011 15:42:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id B7D928FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 Dec 2011 15:42:49 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pB4FgnOu051617
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 4 Dec 2011 15:42:49 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id pB4FgnRV051610;
	Sun, 4 Dec 2011 15:42:49 GMT
	(envelope-from nobody)
Message-Id: <201112041542.pB4FgnRV051610@red.freebsd.org>
Date: Sun, 4 Dec 2011 15:42:49 GMT
From: Scott Robinson <scott@quadhome.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: csplit includes extra lines in inner context
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         163062
>Category:       bin
>Synopsis:       csplit(1) includes extra lines in inner context
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 04 15:50:10 UTC 2011
>Closed-Date:    
>Last-Modified:  Mon Jul 01 01:28:45 UTC 2013
>Originator:     Scott Robinson
>Release:        8.1
>Organization:
>Environment:
FreeBSD hostname 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>Description:
csplit includes the lines of matching context lines for inner matches
when using repeated matches.

I don't know if this is correct or not. The GNU version of csplit doesn't
do it.

My discovery and investigation is documented:
http://stackoverflow.com/questions/8373793/how-can-i-split-a-file-up-by-matching-lines-context/8374825
>How-To-Repeat:
#!/bin/sh

test -e

work="$(basename $0).$RANDOM"
mkdir $work

csplit -sk -f "$work/" - '/#/' '{9999}' <<EOF
First
#
Second
#
Third
EOF

if [ $(grep -c '#' $work/01) -eq 2 ]; then
  echo FAIL Repeat
else
  echo PASS Repeat
fi

rm $work/*

csplit -sk -f "$work/" - '/#/' '/#/' <<EOF
First
#
Second
#
Third
EOF

if [ $(grep -c '#' $work/01) -eq 2 ]; then
  echo FAIL Exact
else
  echo PASS Exact
fi

uname -a
>Fix:


>Release-Note:
>Audit-Trail:

From: =?ISO-8859-1?Q?G=E1bor_Gy=F6ngyi?= <gaborg1988@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/163062: csplit(1) includes extra lines in inner context
Date: Sun, 30 Jun 2013 17:47:54 +0200

 --089e012290fa0a811704e06109f5
 Content-Type: multipart/alternative; boundary=089e012290fa0a811304e06109f3
 
 --089e012290fa0a811304e06109f3
 Content-Type: text/plain; charset=ISO-8859-1
 
 I attached a simple patch to fix this bug. It passes the test which can be
 found in the PR. Csplit svn revision: 252418
 
 --089e012290fa0a811304e06109f3--
 --089e012290fa0a811704e06109f5
 Content-Type: text/plain; charset=US-ASCII; name="patch.txt"
 Content-Disposition: attachment; filename="patch.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_hikep41t0
 
 LS0tIGNzcGxpdC5jCTIwMTMtMDYtMzAgMTc6MTI6MjYuMDAwMDAwMDAwICswMjAwCisrKyBjc3Bs
 aXRfbmV3LmMJMjAxMy0wNi0zMCAxNzoxODo0Ny4wMDAwMDAwMDAgKzAyMDAKQEAgLTM5OSw4ICsz
 OTksMTEgQEAKIAkJZmlyc3QgPSAwOwogCX0KIAotCWlmIChwID09IE5VTEwpCisJaWYgKHAgPT0g
 TlVMTCkgeworCQl0b29tdWNoKE5VTEwsIDApOwogCQllcnJ4KDEsICIlczogbm8gbWF0Y2giLCBy
 ZSk7CisJfQorCiAKIAlpZiAob2ZzIDw9IDApIHsKIAkJLyoK
 --089e012290fa0a811704e06109f5--
>Unformatted:
