Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Feb 2006 02:05:10 +0300
From:      Dmitry Marakasov <amdmi3@mail.ru>
To:        Frank Laszlo <laszlof@vonostingroup.com>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: USE_DOS2UNIX may be more powerful?
Message-ID:  <20060207230510.GA73898@hades.panopticon>
In-Reply-To: <43E8ABB1.5020606@vonostingroup.com>
References:  <20060207003529.GA32317@hades.panopticon> <43E8A5DD.5000509@vonostingroup.com> <b8a404110602070606s6a0df93ah@mail.gmail.com> <43E8ABB1.5020606@vonostingroup.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060207230510.GA73898>