Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2006 13:27:49 -0300
From:      "Alejandro Pulver" <alejandro@varnet.biz>
To:        "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org>
Subject:   ports/92688: [PATCH] bsd.port.mk: add check to USE_DOS2UNIX
Message-ID:  <1138811269.0@phobos.mars.bsd>
Resent-Message-ID: <200602011630.k11GUAdm091396@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         92688
>Category:       ports
>Synopsis:       [PATCH] bsd.port.mk: add check to USE_DOS2UNIX
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 01 16:30:10 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Alejandro Pulver
>Release:        FreeBSD 5.4-RELEASE i386
>Organization:
>Environment:


System: FreeBSD 5.4-RELEASE #0: Sat May 21 12:14:47 ART 2005
    root@ale.varnet.bsd:/usr/src/sys/i386/compile/ATHLON-ALE



>Description:


This patch adds DOS text files detection support for the "patch-dos2unix target", and only removes the (one) trailing CR (\r) character.

This is because the conversion can (actually does) damage non-text files. Also the current version will delete all control characters at the end of the line, not only a CR (this can produce unexpected results).


>How-To-Repeat:





>Fix:


--- bsd.port.mk.diff begins here ---
--- /usr/ports/Mk/bsd.port.mk	Fri Jan 27 23:11:05 2006
+++ bsd.port.mk	Wed Feb  1 13:22:04 2006
@@ -3231,12 +3231,15 @@
 .if defined(USE_DOS2UNIX)
 .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:]]*$$//'
+	@${FIND} ${WRKSRC} -type f -print0 | ${XARGS} -0 ${SH} -c \
+		'while [ $$# -gt 0 ]; do ${FILE} "$$1" | ${GREP} -q CRLF && \
+		${REINPLACE_CMD} -i"" -e "s/`${PRINTF} \"\r\"`$$//" "$$1"; \
+		shift; done' sep
 .else
 .for f in ${USE_DOS2UNIX}
 	@${ECHO_MSG} "===>   Converting DOS text file to UNIX text file: ${f}"
-	@${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' ${WRKSRC}/${f}
+	@${FILE} "${WRKSRC}/${f}" | ${GREP} -q CRLF && \
+		${REINPLACE_CMD} -i"" -e "s/`${PRINTF} '\r'`$$//" "${WRKSRC}/${f}"
 .endfor
 .endif
 .else
--- bsd.port.mk.diff ends here ---



>Release-Note:
>Audit-Trail:
>Unformatted:



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