From owner-freebsd-doc@FreeBSD.ORG Fri Aug 6 13:50:24 2004 Return-Path: Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 457BF16A4CE for ; Fri, 6 Aug 2004 13:50:24 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 200E143D1D for ; Fri, 6 Aug 2004 13:50:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i76DoOJU000562 for ; Fri, 6 Aug 2004 13:50:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i76DoNoL000549; Fri, 6 Aug 2004 13:50:23 GMT (envelope-from gnats) Date: Fri, 6 Aug 2004 13:50:23 GMT Message-Id: <200408061350.i76DoNoL000549@freefall.freebsd.org> To: freebsd-doc@FreeBSD.org From: Peter Pentchev Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Peter Pentchev List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 13:50:24 -0000 The following reply was made to PR docs/69086; it has been noted by GNATS. From: Peter Pentchev To: Alexey Dokuchaev 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 USE_AUTOCONF_VER=213 and take the diffs of configure.in. + 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 (/bin/sh^M not found), etc. To + quickly convert those files from CR/LF to just LF, you can do + something like this: + + USE_REINPLACE= yes + +post-extract: + @${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" -print0 | \ + ${XARGS} -0 ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//' '{}' \; + + Of course, if you need to process each and every file, + above can be omitted. Be aware that this + piece of code will strip all trailing control characters from each + line of processed file (except \n). + Also, if you had to delete a file, then you can do it in the post-extract 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?