From danfe@regency.nsu.ru  Thu Jul 15 06:59:16 2004
Return-Path: <danfe@regency.nsu.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E053116A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Jul 2004 06:59:16 +0000 (GMT)
Received: from mx.nsu.ru (mx.nsu.ru [212.192.164.5])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6341A43D55
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Jul 2004 06:59:15 +0000 (GMT)
	(envelope-from danfe@regency.nsu.ru)
Received: from regency.nsu.ru ([193.124.210.26])
	by mx.nsu.ru with esmtp (Exim 4.32)
	id 1Bl0Ip-00066F-9p
	for FreeBSD-gnats-submit@freebsd.org; Thu, 15 Jul 2004 14:05:11 +0700
Received: from regency.nsu.ru (localhost [127.0.0.1])
	by regency.nsu.ru (8.12.10/8.12.10) with ESMTP id i6F7159k099571
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Jul 2004 14:01:05 +0700 (NOVST)
	(envelope-from danfe@regency.nsu.ru)
Received: (from danfe@localhost)
	by regency.nsu.ru (8.12.10/8.12.10/Submit) id i6F714tO099473;
	Thu, 15 Jul 2004 14:01:05 +0700 (NOVST)
	(envelope-from danfe)
Message-Id: <200407150701.i6F714tO099473@regency.nsu.ru>
Date: Thu, 15 Jul 2004 14:01:05 +0700 (NOVST)
From: Alexey Dokuchaev <danfe@regency.nsu.ru>
Reply-To: Alexey Dokuchaev <danfe@regency.nsu.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         69086
>Category:       docs
>Synopsis:       Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 15 07:00:44 GMT 2004
>Closed-Date:    Mon Aug 09 11:51:59 GMT 2004
>Last-Modified:  Mon Aug 09 11:51:59 GMT 2004
>Originator:     Alexey Dokuchaev
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
CNIT NSU
>Environment:
System: FreeBSD regency.nsu.ru 4.9-STABLE FreeBSD 4.9-STABLE #1: Wed Mar 3 13:17:54 NOVT 2004 root@regency.nsu.ru:/usr/src/sys/compile/REGENCY i386
>Description:
Quite often, we have to port sotfware written for or under Windows/DOS,
which use dumb CR/LF convention for text files instead of Unix plain LF.
This often causes problems with further patching, compiler warning,
scipts execution (/bin/sh^M not found), etc.

Since there's no standard practice of dealing with such situations,
people often come up with all sorts of solutions, i.e. supplying
explicit patches in files/, adding dependency(!!!) on dos2unix, of
wrapping tr -d '\r' in a script and calling it instead of sed(1) in my
proposal, which is simple and straightforward.

I therefore suggest including this in Porter's Handbook, as in attached
patch.
>How-To-Repeat:
Try porting some fairly complex CR/LF code.
>Fix:

Index: book.sgml
===================================================================
RCS file: /home/pub/ftp/pub/FreeBSD/development/FreeBSD-CVS//doc/en_US.ISO8859-1/books/porters-handbook/book.sgml,v
retrieving revision 1.461
diff -u -r1.461 book.sgml
--- book.sgml	12 Jul 2004 08:24:15 -0000	1.461
+++ book.sgml	15 Jul 2004 06:55:26 -0000
@@ -681,6 +681,24 @@
 	  lines!); define <literal>USE_AUTOCONF_VER=213</literal> and take the
 	  diffs of <filename>configure.in</filename>.</para>
 
+	<para>Quite often, there is a situation when ported software, being
+	  primarily developed on Windows, uses CR/LF convention for most of its
+	  source files.  This may cause problems with further patching, compiler
+	  warnings, scipts execution (<command>/bin/sh^M</command> not found),
+	  etc.  To quickly convert those files from CR/LF to just LF, you can do
+	  something like this:</para>
+
+	<programlisting>USE_REINPLACE=	yes
+
+post-extract:
+	@${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" \
+		-exec ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//' '{}' \;</programlisting>
+
+	<para>Of course, if you need to process each and every file,
+	  <option>-iregex</option> above can be omitted.  Be aware that this
+	  piece of code will strip all trailing control characters from each
+	  line of processed file (except <literal>\n</literal>).</para>
+
 	<para>Also, if you had to delete a file, then you can do it in the
 	  <maketarget>post-extract</maketarget> target rather than as part of
 	  the patch.  Once you are happy with the resulting diff, please split

>Release-Note:
>Audit-Trail:

From: Giorgos Keramidas <keramida@FreeBSD.org>
To: Alexey Dokuchaev <danfe@regency.nsu.ru>,
	"David O'Brien" <obrien@FreeBSD.org>
Cc: bug-followup@FreeBSD.org, freebsd-ports@FreeBSD.org
Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
Date: Sun, 18 Jul 2004 05:04:00 +0300

 On 2004-07-15 14:01, Alexey Dokuchaev <danfe@regency.nsu.ru> wrote:
 > I therefore suggest including this in Porter's Handbook, as in
 > attached patch.
 
 This looks like a very nice way to filter the sources to me.  I'm not
 very experienced with the way our ports system works though.
 
 Do the people on freebsd-ports agree about this change?  In particular,
 since he seems to be the most active ports committer that updates the
 porters-handbook, does David O'Brien agree with this addition?
 
 > Index: book.sgml
 > ===================================================================
 > RCS file: /home/pub/ftp/pub/FreeBSD/development/FreeBSD-CVS//doc/en_US.ISO8859-1/books/porters-handbook/book.sgml,v
 > retrieving revision 1.461
 > diff -u -r1.461 book.sgml
 > --- book.sgml	12 Jul 2004 08:24:15 -0000	1.461
 > +++ book.sgml	15 Jul 2004 06:55:26 -0000
 > @@ -681,6 +681,24 @@
 >  	  lines!); define <literal>USE_AUTOCONF_VER=213</literal> and take the
 >  	  diffs of <filename>configure.in</filename>.</para>
 >  
 > +	<para>Quite often, there is a situation when ported software, being
 > +	  primarily developed on Windows, uses CR/LF convention for most of its
 > +	  source files.  This may cause problems with further patching, compiler
 > +	  warnings, scipts execution (<command>/bin/sh^M</command> not found),
 > +	  etc.  To quickly convert those files from CR/LF to just LF, you can do
 > +	  something like this:</para>
 > +
 > +	<programlisting>USE_REINPLACE=	yes
 > +
 > +post-extract:
 > +	@${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" \
 > +		-exec ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//' '{}' \;</programlisting>
 > +
 > +	<para>Of course, if you need to process each and every file,
 > +	  <option>-iregex</option> above can be omitted.  Be aware that this
 > +	  piece of code will strip all trailing control characters from each
 > +	  line of processed file (except <literal>\n</literal>).</para>
 > +
 >  	<para>Also, if you had to delete a file, then you can do it in the
 >  	  <maketarget>post-extract</maketarget> target rather than as part of
 >  	  the patch.  Once you are happy with the resulting diff, please split

From: "David O'Brien" <obrien@FreeBSD.org>
To: Giorgos Keramidas <keramida@FreeBSD.org>
Cc: Alexey Dokuchaev <danfe@regency.nsu.ru>,
	bug-followup@FreeBSD.org, freebsd-ports@FreeBSD.org
Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
Date: Mon, 2 Aug 2004 09:04:19 -0700

 On Sun, Jul 18, 2004 at 05:04:00AM +0300, Giorgos Keramidas wrote:
 > On 2004-07-15 14:01, Alexey Dokuchaev <danfe@regency.nsu.ru> wrote:
 > > I therefore suggest including this in Porter's Handbook, as in
 > > attached patch.
 > 
 > This looks like a very nice way to filter the sources to me.  I'm not
 > very experienced with the way our ports system works though.
 > 
 > Do the people on freebsd-ports agree about this change?  In particular,
 > since he seems to be the most active ports committer that updates the
 > porters-handbook, does David O'Brien agree with this addition?
 
 I'm really not the most active ports committer updating the
 porters-handbook these days.  I personally have no problems with the
 proposed changed.
 
 -- 
 -- David  (obrien@FreeBSD.org)

From: Peter Pentchev <roam@ringlet.net>
To: Alexey Dokuchaev <danfe@regency.nsu.ru>
Cc: bug-followup@FreeBSD.org
Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
Date: Fri, 6 Aug 2004 16:43:47 +0300

 On Thu, Jul 15, 2004 at 02:01:05PM +0700, Alexey Dokuchaev wrote:
 > 
 > >Number:         69086
 > >Category:       docs
 > >Synopsis:       Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
 
 What do you think about the following patch, which advocates a bit more
 efficient method (find/xargs will invoke REINPLACE_CMD an order of
 magnitude less than invoking it for each and every file, or even on many
 files in succession :), and also has some minor corrections and
 rewording to the text above?
 
 G'luck,
 Peter
 
 Index: doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
 ===================================================================
 RCS file: /home/ncvs/doc/en_US.ISO8859-1/books/porters-handbook/book.sgml,v
 retrieving revision 1.470
 diff -u -r1.470 book.sgml
 --- doc/en_US.ISO8859-1/books/porters-handbook/book.sgml	5 Aug 2004 10:04:30 -0000	1.470
 +++ doc/en_US.ISO8859-1/books/porters-handbook/book.sgml	6 Aug 2004 13:37:55 -0000
 @@ -682,6 +682,25 @@
  	  lines!); define <literal>USE_AUTOCONF_VER=213</literal> and take the
  	  diffs of <filename>configure.in</filename>.</para>
  
 +	<para>Quite often, there is a situation when the software being
 +	  ported, especially if it is primarily developed on Windows, uses
 +	  the CR/LF convention for most of its source files.  This may cause
 +	  problems with further patching, compiler warnings, scripts
 +	  execution (<command>/bin/sh^M</command> not found), etc.  To
 +	  quickly convert those files from CR/LF to just LF, you can do
 +	  something like this:</para>
 +
 +	<programlisting>USE_REINPLACE=	yes
 +
 +post-extract:
 +	@${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" -print0 | \
 +		${XARGS} -0 ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//' '{}' \;</programlisting>
 +
 +	<para>Of course, if you need to process each and every file,
 +	  <option>-iregex</option> above can be omitted.  Be aware that this
 +	  piece of code will strip all trailing control characters from each
 +	  line of processed file (except <literal>\n</literal>).</para>
 +
  	<para>Also, if you had to delete a file, then you can do it in the
  	  <maketarget>post-extract</maketarget> target rather than as part of
  	  the patch.  Once you are happy with the resulting diff, please split
 
 -- 
 Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 If I were you, who would be reading this sentence?

From: Peter Pentchev <roam@ringlet.net>
To: Alexey Dokuchaev <danfe@regency.nsu.ru>
Cc: bug-followup@FreeBSD.org
Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
Date: Fri, 6 Aug 2004 18:45:14 +0300

 On Fri, Aug 06, 2004 at 04:43:47PM +0300, Peter Pentchev wrote:
 > On Thu, Jul 15, 2004 at 02:01:05PM +0700, Alexey Dokuchaev wrote:
 > > 
 > > >Number:         69086
 > > >Category:       docs
 > > >Synopsis:       Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
 > 
 > What do you think about the following patch, which advocates a bit more
 > efficient method (find/xargs will invoke REINPLACE_CMD an order of
 > magnitude less than invoking it for each and every file, or even on many
 > files in succession :), and also has some minor corrections and
 > rewording to the text above?
 
 Or how about the following, which uses the &windows; entity properly? :)
 
 G'luck,
 Peter
 
 Index: doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
 ===================================================================
 RCS file: /home/ncvs/doc/en_US.ISO8859-1/books/porters-handbook/book.sgml,v
 retrieving revision 1.470
 diff -u -r1.470 book.sgml
 --- doc/en_US.ISO8859-1/books/porters-handbook/book.sgml	5 Aug 2004 10:04:30 -0000	1.470
 +++ doc/en_US.ISO8859-1/books/porters-handbook/book.sgml	6 Aug 2004 15:40:46 -0000
 @@ -18,6 +18,8 @@
  %mailing-lists;
  <!ENTITY % freebsd PUBLIC "-//FreeBSD//ENTITIES DocBook Miscellaneous FreeBSD Entities//EN">
  %freebsd;
 +<!ENTITY % trademarks PUBLIC "-//FreeBSD//ENTITIES DocBook Trademark Entities//EN">
 +%trademarks;
  <!ENTITY % urls PUBLIC "-//FreeBSD//ENTITIES DocBook URL Entities//EN">
  %urls;
  ]>
 @@ -682,6 +684,25 @@
  	  lines!); define <literal>USE_AUTOCONF_VER=213</literal> and take the
  	  diffs of <filename>configure.in</filename>.</para>
  
 +	<para>Quite often, there is a situation when the software being
 +	  ported, especially if it is primarily developed on &windows;, uses
 +	  the CR/LF convention for most of its source files.  This may cause
 +	  problems with further patching, compiler warnings, scripts
 +	  execution (<command>/bin/sh^M</command> not found), etc.  To
 +	  quickly convert those files from CR/LF to just LF, you can do
 +	  something like this:</para>
 +
 +	<programlisting>USE_REINPLACE=	yes
 +
 +post-extract:
 +	@${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" -print0 | \
 +		${XARGS} -0 ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//' '{}' \;</programlisting>
 +
 +	<para>Of course, if you need to process each and every file,
 +	  <option>-iregex</option> above can be omitted.  Be aware that this
 +	  piece of code will strip all trailing control characters from each
 +	  line of processed file (except <literal>\n</literal>).</para>
 +
  	<para>Also, if you had to delete a file, then you can do it in the
  	  <maketarget>post-extract</maketarget> target rather than as part of
  	  the patch.  Once you are happy with the resulting diff, please split
 
 -- 
 Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 I had to translate this sentence into English because I could not read the original Sanskrit.

From: Alexey Dokuchaev <danfe@nsu.ru>
To: Peter Pentchev <roam@ringlet.net>
Cc: bug-followup@FreeBSD.org
Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
Date: Mon, 9 Aug 2004 10:05:01 +0700

 On Fri, Aug 06, 2004 at 04:43:47PM +0300, Peter Pentchev wrote:
 > On Thu, Jul 15, 2004 at 02:01:05PM +0700, Alexey Dokuchaev wrote:
 > > 
 > > >Number:         69086
 > > >Category:       docs
 > > >Synopsis:       Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
 > 
 > What do you think about the following patch, which advocates a bit more
 > efficient method (find/xargs will invoke REINPLACE_CMD an order of
 > magnitude less than invoking it for each and every file, or even on many
 > files in succession :), and also has some minor corrections and
 > rewording to the text above?
 
 Agreed, thanks for your improvements.
 
 ./danfe

From: Alexey Dokuchaev <danfe@nsu.ru>
To: Peter Pentchev <roam@ringlet.net>
Cc: bug-followup@FreeBSD.org
Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
Date: Mon, 9 Aug 2004 10:05:28 +0700

 On Fri, Aug 06, 2004 at 06:45:14PM +0300, Peter Pentchev wrote:
 > On Fri, Aug 06, 2004 at 04:43:47PM +0300, Peter Pentchev wrote:
 > > On Thu, Jul 15, 2004 at 02:01:05PM +0700, Alexey Dokuchaev wrote:
 > > > 
 > > > >Number:         69086
 > > > >Category:       docs
 > > > >Synopsis:       Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD
 > > 
 > > What do you think about the following patch, which advocates a bit more
 > > efficient method (find/xargs will invoke REINPLACE_CMD an order of
 > > magnitude less than invoking it for each and every file, or even on many
 > > files in succession :), and also has some minor corrections and
 > > rewording to the text above?
 > 
 > Or how about the following, which uses the &windows; entity properly? :)
 
 This also looks good.
 
 ./danfe
State-Changed-From-To: open->closed 
State-Changed-By: roam 
State-Changed-When: Mon Aug 9 11:51:43 GMT 2004 
State-Changed-Why:  
Committed with slight modifications.  Thanks for the patch! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=69086 
>Unformatted:
