From owner-freebsd-ports@FreeBSD.ORG Tue Feb 7 23:05:07 2006 Return-Path: X-Original-To: freebsd-ports@freebsd.org Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 187BE16A420 for ; Tue, 7 Feb 2006 23:05:07 +0000 (GMT) (envelope-from amdmi3@mail.ru) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9261C43D45 for ; Tue, 7 Feb 2006 23:05:06 +0000 (GMT) (envelope-from amdmi3@mail.ru) Received: from [213.148.29.33] (port=2516 helo=nexii.panopticon) by mx1.mail.ru with esmtp id 1F6btR-000C9C-00; Wed, 08 Feb 2006 02:05:05 +0300 Received: from hades.panopticon (hades.panopticon [192.168.0.2]) by nexii.panopticon (Postfix) with ESMTP id 2E2D91142B; Wed, 8 Feb 2006 02:08:40 +0300 (MSK) Received: by hades.panopticon (Postfix, from userid 1000) id 8286921F; Wed, 8 Feb 2006 02:05:10 +0300 (MSK) Date: Wed, 8 Feb 2006 02:05:10 +0300 From: Dmitry Marakasov To: Frank Laszlo Message-ID: <20060207230510.GA73898@hades.panopticon> Mail-Followup-To: Frank Laszlo , freebsd-ports@freebsd.org References: <20060207003529.GA32317@hades.panopticon> <43E8A5DD.5000509@vonostingroup.com> <43E8ABB1.5020606@vonostingroup.com> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <43E8ABB1.5020606@vonostingroup.com> User-Agent: Mutt/1.4.2.1i Cc: freebsd-ports@freebsd.org Subject: Re: USE_DOS2UNIX may be more powerful? X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Feb 2006 23:05:07 -0000 * Frank Laszlo (laszlof@vonostingroup.com) wrote: > Ha, I just noticed it already does this. Look at the code: I did. > So you can define it either way.. > > USE_DOS2UNIX=YES <-- this will parse ALL files within WRKSRC > USE_DOS2UNIX=foo/*.c bar/biz/*.h <-- this will parse only certain files. > > Hope this helps. That's what I was talking about - if you have many, many directories with source/header files, and want to convert them all, you'll need to specify each directory for every file mask. Length of USE_DOS2UNIX will be number_of_dirs*number_of_filemasks. If find is used, it may be shortened a lot. Now when I've given it some thought, I have very simple solution how power of find can be used without compicated syntax and with very small changes to bsd.port.mk. The code explains itself: .if ${USE_DOS2UNIX:U}=="YES" @${ECHO_MSG} "===> Converting DOS text files to UNIX text files" @${FIND} -E ${WRKSRC} -type f -print0 | \ ${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' .else .for f in ${USE_DOS2UNIX} @${ECHO_MSG} "===> Converting DOS text file to UNIX text file: ${f}" @if ${ECHO_CMD} '${f}' | ${GREP} / > /dev/null 2>&1; then \ ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' ${WRKSRC}/${f}; \ else \ ${FIND} -E ${WRKSRC} -type f -name '${f}' -print0 | \ ${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'; \ fi .endfor Now, old syntax works as it did: USE_DOS2UNIX= foo/*.c bar/biz/*.h will convert all *.c files in ${WRKSRC}/foo/ and all *.h files in ${WRKSRC}/bar/baz/ But, also now we can use USE_DOS2UNIX= *.c *.h To convert all *.c and *.h files in all subdirectories under ${WRKSRC}. For the case when we have many directories and cannot use USE_DOS2UNIX=YES as it'll corrupt sometring, I think it's the best solution. -- Best regards, Dmitry mailto:amdmi3@mail.ru