Patch by Bill Anderson
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=57507
---- dos2unix-3.1/dos2unix.1
-+++ dos2unix-3.1/dos2unix.1
+--- dos2unix-5.1.1/man/man1/dos2unix.1~
++++ dos2unix-5.1.1/man/man1/dos2unix.1
@@ -4,127 +4,104 @@
.SH NAME
+++ /dev/null
-Ripped from Fedora
-
---- dos2unix-3.1/dos2unix.c
-+++ dos2unix-3.1/dos2unix.c
-@@ -345,11 +345,14 @@ int ConvertDosToUnixOldFile(char* ipInFN
- char TempPath[16];
- struct stat StatBuf;
- struct utimbuf UTimeBuf;
-+ mode_t mode = S_IRUSR | S_IWUSR;
- int fd;
-
- /* retrieve ipInFN file date stamp */
-- if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
-+ if (stat(ipInFN, &StatBuf))
- RetVal = -1;
-+ else
-+ mode = StatBuf.st_mode;
-
- strcpy (TempPath, "./u2dtmpXXXXXX");
- if((fd=mkstemp (TempPath))<0) {
-@@ -357,6 +360,9 @@ int ConvertDosToUnixOldFile(char* ipInFN
- RetVal = -1;
- }
-
-+ if (!RetVal && fchmod (fd, mode) && fchmod (fd, S_IRUSR | S_IWUSR))
-+ RetVal = -1;
-+
- #ifdef DEBUG
- fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
- #endif DEBUG
+++ /dev/null
-* Fix http://bugzilla.redhat.com/57508 (make dos2unix not modify Mac
- files unless in mac2unix mode)
-* Make mac2unix mode not create duplicate Unix line delimiters when
- run on a DOS file. (mschwendt@users.sf.net)
-
-diff -Nur dos2unix-3.1-orig/dos2unix.c dos2unix-3.1/dos2unix.c
---- dos2unix-3.1-orig/dos2unix.c 1998-11-19 13:19:25.000000000 +0100
-+++ dos2unix-3.1/dos2unix.c 2004-09-26 20:57:41.606587616 +0200
-@@ -153,6 +153,24 @@
- }
-
-
-+void StripDelimiter(FILE* ipInF, FILE* ipOutF, CFlag *ipFlag, int CurChar)
-+{
-+ int TempNextChar;
-+ /* Don't modify Mac files when in dos2unix mode. */
-+ if ( (TempNextChar = getc(ipInF)) != EOF) {
-+ ungetc( TempNextChar, ipInF ); /* put back peek char */
-+ if ( TempNextChar != '\x0a' ) {
-+ putc( CurChar, ipOutF ); /* Mac line, put back CR */
-+ }
-+ }
-+ else if ( CurChar == '\x0d' ) { /* EOF: last Mac line delimiter (CR)? */
-+ putc( CurChar, ipOutF );
-+ }
-+ if (ipFlag->NewLine) { /* add additional LF? */
-+ putc('\n', ipOutF);
-+ }
-+}
-+
- /* converts stream ipInF to UNIX format text and write to stream ipOutF
- * RetVal: 0 if success
- * -1 otherwise
-@@ -161,6 +179,7 @@
- {
- int RetVal = 0;
- int TempChar;
-+ int TempNextChar;
-
- if ( macmode )
- ipFlag->ConvMode = 3;
-@@ -177,9 +196,7 @@
- break;
- }
- } else {
-- if (ipFlag->NewLine) {
-- putc('\n', ipOutF);
-- }
-+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar );
- }
- }
- break;
-@@ -193,9 +210,7 @@
- break;
- }
- } else {
-- if (ipFlag->NewLine) {
-- putc('\n', ipOutF);
-- }
-+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar );
- }
- }
- break;
-@@ -209,9 +224,7 @@
- break;
- }
- } else {
-- if (ipFlag->NewLine) {
-- putc('\n', ipOutF);
-- }
-+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar );
- }
- }
- break;
-@@ -227,6 +240,13 @@
- }
- }
- else{
-+ if ( (TempNextChar = getc(ipInF)) != EOF) {
-+ ungetc( TempNextChar, ipInF ); /* put back peek char */
-+ /* Don't touch this delimiter if it's a CR,LF pair. */
-+ if ( TempNextChar == '\x0a' ) {
-+ continue;
-+ }
-+ }
- if (putc('\x0a', ipOutF) == EOF)
- {
- RetVal = -1;
+++ /dev/null
---- dos2unix-3.1/dos2unix.c
-+++ dos2unix-3.1/dos2unix.c
-@@ -147,9 +147,9 @@
- * RetVal: NULL if failure
- * file stream otherwise
- */
--FILE* OpenOutFile(char *ipFN)
-+FILE* OpenOutFile(int fd)
- {
-- return (fopen(ipFN, W_CNTRL));
-+ return (fdopen(fd, W_CNTRL));
- }
-
-
-@@ -260,14 +260,17 @@
- char TempPath[16];
- struct stat StatBuf;
- struct utimbuf UTimeBuf;
-+ int fd;
-
- /* retrieve ipInFN file date stamp */
- if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
- RetVal = -1;
-
-- strcpy (TempPath, "./d2utmp");
-- strcat (TempPath, "XXXXXX");
-- mktemp (TempPath);
-+ strcpy (TempPath, "./d2utmpXXXXXX");
-+ if((fd=mkstemp (TempPath))<0) {
-+ perror("Failed to open output temp file");
-+ RetVal = -1;
-+ }
-
- #ifdef DEBUG
- fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
-@@ -278,7 +281,7 @@
- RetVal = -1;
-
- /* can open out file? */
-- if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL))
-+ if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
- {
- fclose (InF);
- RetVal = -1;
-@@ -295,6 +298,8 @@
- /* can close out file? */
- if ((TempF) && (fclose(TempF) == EOF))
- RetVal = -1;
-+ if(fd>=0)
-+ close(fd);
-
- if ((!RetVal) && (ipFlag->KeepDate))
- {
-@@ -340,14 +345,17 @@
- char TempPath[16];
- struct stat StatBuf;
- struct utimbuf UTimeBuf;
-+ int fd;
-
- /* retrieve ipInFN file date stamp */
- if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
- RetVal = -1;
-
-- strcpy (TempPath, "./u2dtmp");
-- strcat (TempPath, "XXXXXX");
-- mktemp (TempPath);
-+ strcpy (TempPath, "./u2dtmpXXXXXX");
-+ if((fd=mkstemp (TempPath))<0) {
-+ perror("Failed to open output temp file");
-+ RetVal = -1;
-+ }
-
- #ifdef DEBUG
- fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
-@@ -358,7 +366,7 @@
- RetVal = -1;
-
- /* can open out file? */
-- if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL))
-+ if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
- {
- fclose (InF);
- RetVal = -1;
-@@ -376,6 +384,9 @@
- if ((TempF) && (fclose(TempF) == EOF))
- RetVal = -1;
-
-+ if(fd>=0)
-+ close(fd);
-+
- if ((!RetVal) && (ipFlag->KeepDate))
- {
- UTimeBuf.actime = StatBuf.st_atime;
+++ /dev/null
---- dos2unix-3.1/Makefile.orig Thu Nov 19 07:09:38 1998
-+++ dos2unix-3.1/Makefile Fri Nov 17 13:25:35 2000
-@@ -1,10 +1,12 @@
-+CFLAGS=
-+
- default: dos2unix
-
- all: dos2unix link install
-
-
- dos2unix:
-- gcc -O dos2unix.c -o dos2unix
-+ gcc $(CFLAGS) dos2unix.c -o dos2unix
-
-
- link:
-@@ -12,11 +14,10 @@
- ln -s dos2unix.1 mac2unix.1
-
- clean:
-- rm dos2unix
-+ rm -f dos2unix mac2unix mac2unix.1 *~ *.orig core
-
- install:
- install -m 755 dos2unix /usr/local/bin
- install -m 644 dos2unix.1 /usr/local/man/man1
- install -m 755 mac2unix /usr/local/bin
- install -m 644 mac2unix.1 /usr/local/man/man1
--
-
Summary(uk.UTF-8): dos2unix - конвертор текстових файлів DOS в формат UNIX
Summary(zh_CN.UTF-8): 转换DOS或MAC文本文件到UNIX格式
Name: dos2unix
-Version: 3.1
-Release: 21
+Version: 5.1.1
+Release: 1
License: Freer than LGPL
Group: Applications/Text
-Source0: http://www.go.dlr.de/linux/src/%{name}-%{version}.tar.gz
-# Source0-md5: 25ff56bab202de63ea6f6c211c416e96
-Patch0: %{name}.patch
-Patch1: %{name}-segfault.patch
+Source0: http://www.xs4all.nl/~waterlan/dos2unix/%{name}-%{version}.tar.gz
+# Source0-md5: b8f6d8109fc6decf412bc1e3959450c0
+URL: http://www.xs4all.nl/~waterlan/dos2unix.html
Patch2: %{name}-includes.patch
Patch3: %{name}-manpage-update.patch
-Patch4: %{name}-preserve-file-modes.patch
-Patch5: %{name}-safeconv.patch
Patch6: %{name}-workaround-rename-EXDEV.patch
+Obsoletes: unix2dos
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
%prep
%setup -q
-%patch0 -p1
-%patch1 -p1
%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-%patch6 -p1
+#%patch3 -p1
+#%patch6 -p1
%build
-%{__cc} %{rpmcflags} -o dos2unix dos2unix.c
+%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1}
+%{__make} install \
+ DESTDIR=$RPM_BUILD_ROOT
-install dos2unix $RPM_BUILD_ROOT%{_bindir}
-install dos2unix.1 $RPM_BUILD_ROOT%{_mandir}/man1
+%find_lang %{name} --all-name
-ln -sf dos2unix $RPM_BUILD_ROOT%{_bindir}/mac2unix
-
-echo ".so dos2unix.1" > $RPM_BUILD_ROOT%{_mandir}/man1/mac2unix.1
+find $RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
-%files
+%files -f %{name}.lang
%defattr(644,root,root,755)
-%doc COPYRIGHT
-%attr(755,root,root) %{_bindir}/*
+%doc COPYING.txt ChangeLog.txt NEWS.txt README.txt TODO.txt
+%attr(755,root,root) %{_bindir}/dos2unix
+%attr(755,root,root) %{_bindir}/mac2unix
+%attr(755,root,root) %{_bindir}/unix2dos
+%attr(755,root,root) %{_bindir}/unix2mac
%{_mandir}/man1/*