Date: Fri, 6 Aug 2004 15:50:29 GMT From: Peter Pentchev <roam@ringlet.net> To: freebsd-doc@FreeBSD.org Subject: Re: docs/69086: Porters Handbook: How to convert from CR/LF to LF using REINPLACE_CMD Message-ID: <200408061550.i76FoTY1013972@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR docs/69086; it has been noted by GNATS. 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200408061550.i76FoTY1013972>