- 4.1.1. New upstream.

This commit is contained in:
Tim Waugh 2010-01-22 10:41:31 +00:00
parent c4cccc3c53
commit 881add5b1f
14 changed files with 61 additions and 753 deletions

View File

@ -1 +1,2 @@
dos2unix-3.1.tar.bz2
dos2unix-4.1.1.tar.gz

View File

@ -1,238 +0,0 @@
Patch by Bill Anderson, to fix bug:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=57507
Description of Problem:
The dos2unix man page examples are confusing.
For instance, one piece of text mentions "c.txt", but that file
isn't used in the following example.
--- dos2unix-3.1/dos2unix.1 2004-09-28 03:17:29.000000000 -0600
+++ dos2unix-3.1/dos2unix.1-new 2004-09-28 03:16:32.000000000 -0600
@@ -1,123 +1,126 @@
.\" $$Id: dos2unix.1 2.2 1995/03/31 01:50:45 blin Exp blin $$
-.TH dos2unix 1 "dos2unix v3.0" "1995.03.31"
-
-.SH NAME
-
+.\"
+.TH "dos2unix" "1" "dos2unix v3.0" "1995.03.31" ""
+.SH "NAME"
dos2unix \- DOS/MAC to UNIX text file format converter
-.SH SYNOPSYS
-
-dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
-.PP
+.SH "SYNOPSYS"
+dos2unix [options] [\-c convmode] [\-o file ...] [\-n infile outfile ...]
+.PP
Options:
-.PP
-[-hkqV] [--help] [--keepdate] [--quiet] [--version]
-
-.SH DESCRIPTION
+.PP
+[\-hkqV] [\-\-help] [\-\-keepdate] [\-\-quiet] [\-\-version]
-.PP
+.SH "DESCRIPTION"
+.PP
This manual page documents dos2unix, the program that converts plain text
files in DOS/MAC format to UNIX format.
-.SH OPTIONS
-
+.SH "OPTIONS"
The following options are available:
-.TP
-.B \-h --help
+.TP
+.B \-h \-\-help
Print online help.
-.TP
-.B \-k --keepdate
+.TP
+.B \-k \-\-keepdate
Keep the date stamp of output file same as input file.
-.TP
-.B \-q --quiet
+.TP
+.B \-q \-\-quiet
Quiet mode. Suppress all warning and messages.
-.TP
-.B \-V --version
+.TP
+.B \-V \-\-version
Prints version information.
-.TP
-.B \-c --convmode convmode
-Sets conversion mode. Simulates dos2unix under SunOS.
+.TP
+.B \-c \-\-convmode convmode
+Sets conversion mode. Where convmode is one of:
+.B ASCII, 7bit, ISO, Mac
+with ASCII being the default.
+Simulates dos2unix under SunOS.
+
+
-.TP
-.B \-o --oldfile file ...
+.TP
+.B \-o \-\-oldfile file ...
Old file mode. Convert the file and write output to it. The program
default to run in this mode. Wildcard names may be used.
-.TP
-.B \-n --newfile infile outfile ...
+.TP
+.B \-n \-\-newfile infile outfile ...
New file mode. Convert the infile and write output to outfile. File names
must be given in pairs and wildcard names should NOT be used or you WILL
lost your files.
-.SH EXAMPLES
-
-.LP
+.SH "EXAMPLES"
+.LP
Get input from stdin and write output to stdout.
-.IP
+.IP
.B dos2unix
-.LP
+.LP
Convert and replace a.txt. Convert and replace b.txt.
-.IP
+.IP
.B dos2unix a.txt b.txt
-.IP
-.B dos2unix -o a.txt b.txt
+.IP
+.B dos2unix \-o a.txt b.txt
-.LP
+.LP
Convert and replace a.txt in ASCII conversion mode.
+.IP
+.B dos2unix a.txt \-c iso b.txt
+
+.LP
Convert and replace b.txt in ISO conversion mode.
+.IP
+.B dos2unix \-c ascii a.txt \-c iso b.txt
+
+.LP
Convert c.txt from Mac to Unix ascii format.
-.IP
-.B dos2unix a.txt -c iso b.txt
-.IP
-.B dos2unix -c ascii a.txt -c iso b.txt
-.IP
-.B dos2unix -c mac a.txt b.txt
-.LP
+.IP
+.B dos2unix \-c mac c.txt b.txt
+
+.LP
Convert and replace a.txt while keeping original date stamp.
-.IP
-.B dos2unix -k a.txt
-.IP
-.B dos2unix -k -o a.txt
+.IP
+.B dos2unix \-k a.txt
+.IP
+.B dos2unix \-k \-o a.txt
-.LP
+.LP
Convert a.txt and write to e.txt.
-.IP
-.B dos2unix -n a.txt e.txt
+.IP
+.B dos2unix \-n a.txt e.txt
-.LP
+.LP
Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt.
-.IP
-.B dos2unix -k -n a.txt e.txt
+.IP
+.B dos2unix \-k \-n a.txt e.txt
-.LP
+.LP
Convert and replace a.txt. Convert b.txt and write to e.txt.
-.IP
-.B dos2unix a.txt -n b.txt e.txt
-.IP
-.B dos2unix -o a.txt -n b.txt e.txt
+.IP
+.B dos2unix a.txt \-n b.txt e.txt
+.IP
+.B dos2unix \-o a.txt \-n b.txt e.txt
-.LP
+.LP
Convert c.txt and write to e.txt. Convert and replace a.txt.
Convert and replace b.txt. Convert d.txt and write to f.txt.
-.IP
-.B dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
+.IP
+.B dos2unix \-n c.txt e.txt \-o a.txt b.txt \-n d.txt f.txt
-.SH DIAGNOSTICS
-
-.SH BUGS
+.SH "DIAGNOSTICS"
+.SH "BUGS"
The program does not work properly under MSDOS in stdio processing mode.
If you know why is that so, please tell me.
-.SH AUTHORS
-
-Benjamin Lin -
+.SH "AUTHORS"
+Benjamin Lin \-
.B <blin@socs.uts.edu.au>
@@ -125,18 +128,17 @@
.B <wuebben@kde.org>
-.SH MISCELLANY
-
+.SH "MISCELLANY"
Tested environment:
-.IP
+.IP
Linux 1.2.0 with GNU C 2.5.8
-.IP
+.IP
SunOS 4.1.3 with GNU C 2.6.3
-.IP
-MS-DOS 6.20 with Borland C++ 4.02
-.PP
+.IP
+MS\-DOS 6.20 with Borland C++ 4.02
+.PP
Suggestions and bug reports are welcome.
-.SH SEE ALSO
+.SH "SEE ALSO"
unix2dos(1) mac2unix(1)

View File

@ -1,28 +0,0 @@
--- dos2unix-3.1/dos2unix.c.mode 2003-05-21 08:09:08.000000000 -0700
+++ dos2unix-3.1/dos2unix.c 2003-05-21 08:09:56.000000000 -0700
@@ -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

View File

@ -1,88 +0,0 @@
* 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;

View File

@ -1,93 +0,0 @@
--- dos2unix-3.1/dos2unix.c.segf Thu Jan 17 17:27:42 2002
+++ dos2unix-3.1/dos2unix.c Thu Jan 17 17:28:07 2002
@@ -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");
- mkstemp (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");
- mkstemp (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;

View File

@ -1,141 +0,0 @@
--- dos2unix-3.1/dos2unix.c.tmppath 2004-10-20 16:00:00.342561008 +0200
+++ dos2unix-3.1/dos2unix.c 2004-10-20 16:01:42.210074792 +0200
@@ -69,6 +69,7 @@
#ifdef __MSDOS__
# include <dir.h>
#endif __MSDOS__
+#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -267,6 +268,39 @@
return RetVal;
}
+static int MakeTempFileFrom(const char *OutFN, char **fname_ret)
+{
+ char *cpy = strdup(OutFN);
+ char *dir = NULL;
+ size_t fname_len = 0;
+ char *fname_str = NULL;
+ int fd = -1;
+
+ *fname_ret = NULL;
+
+ if (!cpy)
+ goto make_failed;
+
+ dir = dirname(cpy);
+
+ fname_len = strlen(dir) + strlen("/d2utmpXXXXXX") + sizeof (char);
+ if (!(fname_str = malloc(fname_len)))
+ goto make_failed;
+ sprintf(fname_str, "%s%s", dir, "/d2utmpXXXXXX");
+ *fname_ret = fname_str;
+
+ free(cpy);
+
+ if ((fd = mkstemp(fname_str)) == -1)
+ goto make_failed;
+
+ return (fd);
+
+ make_failed:
+ free(*fname_ret);
+ *fname_ret = NULL;
+ return (-1);
+}
/* convert file ipInFN to UNIX format text and write to file ipOutFN
* RetVal: 0 if success
@@ -277,7 +311,7 @@
int RetVal = 0;
FILE *InF = NULL;
FILE *TempF = NULL;
- char TempPath[16];
+ char *TempPath;
struct stat StatBuf;
struct utimbuf UTimeBuf;
int fd;
@@ -286,8 +320,7 @@
if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
RetVal = -1;
- strcpy (TempPath, "./d2utmpXXXXXX");
- if((fd=mkstemp (TempPath))<0) {
+ if((fd = MakeTempFileFrom(ipOutFN, &TempPath))<0) {
perror("Failed to open output temp file");
RetVal = -1;
}
@@ -304,6 +337,7 @@
if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
{
fclose (InF);
+ InF = NULL;
RetVal = -1;
}
@@ -337,9 +371,6 @@
/* can rename temp file to out file? */
if (!RetVal)
{
- if (stat(ipOutFN, &StatBuf) == 0)
- unlink(ipOutFN);
-
if ((rename(TempPath, ipOutFN) == -1) && (!ipFlag->Quiet))
{
fprintf(stderr, "dos2unix: problems renaming '%s' to '%s'\n", TempPath, ipOutFN);
@@ -347,6 +378,7 @@
RetVal = -1;
}
}
+ free(TempPath);
return RetVal;
}
@@ -362,7 +394,7 @@
int RetVal = 0;
FILE *InF = NULL;
FILE *TempF = NULL;
- char TempPath[16];
+ char *TempPath;
struct stat StatBuf;
struct utimbuf UTimeBuf;
mode_t mode = S_IRUSR | S_IWUSR;
@@ -374,8 +406,7 @@
else
mode = StatBuf.st_mode;
- strcpy (TempPath, "./u2dtmpXXXXXX");
- if((fd=mkstemp (TempPath))<0) {
+ if((fd = MakeTempFileFrom(ipInFN, &TempPath))<0) {
perror("Failed to open output temp file");
RetVal = -1;
}
@@ -395,6 +426,7 @@
if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
{
fclose (InF);
+ InF = NULL;
RetVal = -1;
}
@@ -422,10 +454,6 @@
RetVal = -1;
}
- /* can delete in file? */
- if ((!RetVal) && (unlink(ipInFN) == -1))
- RetVal = -1;
-
/* any error? */
if ((RetVal) && (unlink(TempPath)))
RetVal = -1;
@@ -440,6 +468,7 @@
}
RetVal = -1;
}
+ free(TempPath);
return RetVal;
}

View File

@ -1,49 +0,0 @@
--- 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
-
--- dos2unix-3.1/dos2unix.c.orig Thu Nov 19 07:19:25 1998
+++ dos2unix-3.1/dos2unix.c Fri Nov 17 13:25:25 2000
@@ -267,7 +267,7 @@
strcpy (TempPath, "./d2utmp");
strcat (TempPath, "XXXXXX");
- mktemp (TempPath);
+ mkstemp (TempPath);
#ifdef DEBUG
fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
@@ -347,7 +347,7 @@
strcpy (TempPath, "./u2dtmp");
strcat (TempPath, "XXXXXX");
- mktemp (TempPath);
+ mkstemp (TempPath);
#ifdef DEBUG
fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);

30
dos2unix-CFLAGS.patch Normal file
View File

@ -0,0 +1,30 @@
diff -up dos2unix-4.1.1/Makefile.CFLAGS dos2unix-4.1.1/Makefile
--- dos2unix-4.1.1/Makefile.CFLAGS 2010-01-22 10:00:01.207058452 +0000
+++ dos2unix-4.1.1/Makefile 2010-01-22 10:01:15.224057831 +0000
@@ -116,15 +116,14 @@ endif
# ............................................................ flags ...
-GCCFLAGS = -O2 -Wall -D_LARGEFILE_SOURCE
+CFLAGS = -O2 -Wall -D_LARGEFILE_SOURCE
ifdef STATIC
GCCFLAGS += -static
endif
-CFLAGS = -DVER_REVISION=\"$(DOS2UNIX_VERSION)\" \
+EXTRA_CFLAGS = -DVER_REVISION=\"$(DOS2UNIX_VERSION)\" \
-DVER_DATE=\"$(DOS2UNIX_DATE)\" \
- $(GCCFLAGS) \
$(CFLAGS_OS) \
$(NLSDEFS)
@@ -138,7 +137,7 @@ DEFS = $(EXTRA_DEFS)
all: $(BIN) $(MAC2UNIX_BIN) $(MAC2UNIX).1 $(DOCFILES) $(MOFILES)
%.o : %.c
- $(CC) $(CFLAGS) $(DEFS) -c $< -o $@
+ $(CC) $(EXTRA_CFLAGS) $(CFLAGS) $(DEFS) -c $< -o $@
$(BIN): dos2unix.o
$(CC) $< $(LDFLAGS) -o $@

View File

@ -1,42 +0,0 @@
diff -up dos2unix-3.1/dos2unix.c.c-missing-arg dos2unix-3.1/dos2unix.c
--- dos2unix-3.1/dos2unix.c.c-missing-arg 2008-01-18 09:24:21.000000000 +0000
+++ dos2unix-3.1/dos2unix.c 2008-01-18 09:25:43.000000000 +0000
@@ -533,19 +533,28 @@ int main (int argc, char *argv[])
if ((strcmp(argv[ArgIdx],"-c") == 0) || (strcmp(argv[ArgIdx],"--convmode") == 0))
{
- ArgIdx++;
- if (strcmpi(argv[ArgIdx],"ASCII") == 0)
- pFlag->ConvMode = 0;
- else if (strcmpi(argv[ArgIdx], "7Bit") == 0)
- pFlag->ConvMode = 1;
- else if (strcmpi(argv[ArgIdx], "ISO") == 0)
- pFlag->ConvMode = 2;
- else if (strcmpi(argv[ArgIdx], "Mac") == 0)
- pFlag->ConvMode = 3;
+ if (++ArgIdx < argc)
+ {
+ if (strcmpi(argv[ArgIdx],"ASCII") == 0)
+ pFlag->ConvMode = 0;
+ else if (strcmpi(argv[ArgIdx], "7Bit") == 0)
+ pFlag->ConvMode = 1;
+ else if (strcmpi(argv[ArgIdx], "ISO") == 0)
+ pFlag->ConvMode = 2;
+ else if (strcmpi(argv[ArgIdx], "Mac") == 0)
+ pFlag->ConvMode = 3;
+ else
+ {
+ if (!pFlag->Quiet)
+ fprintf(stderr, "dos2unix: invalid %s conversion mode specified\n",argv[ArgIdx]);
+ ShouldExit = 1;
+ }
+ }
else
{
+ ArgIdx--;
if (!pFlag->Quiet)
- fprintf(stderr, "dos2unix: invalid %s conversion mode specified\n",argv[ArgIdx]);
+ fprintf(stderr,"dos2unix: option `%s' requires an argument\n",argv[ArgIdx]);
ShouldExit = 1;
}
}

View File

@ -1,12 +0,0 @@
diff -up dos2unix-3.1/dos2unix.1.manpage dos2unix-3.1/dos2unix.1
--- dos2unix-3.1/dos2unix.1.manpage 2008-09-08 09:58:46.000000000 +0100
+++ dos2unix-3.1/dos2unix.1 2008-09-08 09:58:56.000000000 +0100
@@ -52,7 +52,7 @@ default to run in this mode. Wildcard na
.B \-n \-\-newfile infile outfile ...
New file mode. Convert the infile and write output to outfile. File names
must be given in pairs and wildcard names should NOT be used or you WILL
-lost your files.
+lose your files.
.SH "EXAMPLES"
.LP

View File

@ -1,15 +0,0 @@
diff -up dos2unix-3.1/dos2unix.c.missing-proto dos2unix-3.1/dos2unix.c
--- dos2unix-3.1/dos2unix.c.missing-proto 2008-04-14 17:11:58.000000000 +0100
+++ dos2unix-3.1/dos2unix.c 2008-04-14 17:12:42.000000000 +0100
@@ -75,6 +75,11 @@ static int macmode = 0;
#include <string.h>
#include <utime.h>
#include <sys/stat.h>
+#if defined(__MSDOS__) || defined(__WIN32__) || defined(_WIN32)
+# include <io.h>
+#else
+# include <unistd.h>
+#endif
#include "dos2unix.h"

View File

@ -1,19 +1,24 @@
diff -up dos2unix-3.1/dos2unix.c.preserve-file-modes dos2unix-3.1/dos2unix.c
--- dos2unix-3.1/dos2unix.c.preserve-file-modes 2008-09-08 09:58:05.000000000 +0100
+++ dos2unix-3.1/dos2unix.c 2008-09-08 10:16:04.000000000 +0100
@@ -320,9 +320,10 @@ int ConvertDosToUnixNewFile(char *ipInFN
diff -up dos2unix-4.1.1/dos2unix.c.preserve-file-modes dos2unix-4.1.1/dos2unix.c
--- dos2unix-4.1.1/dos2unix.c.preserve-file-modes 2010-01-10 21:02:18.000000000 +0000
+++ dos2unix-4.1.1/dos2unix.c 2010-01-22 09:55:48.870058072 +0000
@@ -472,6 +472,7 @@ int ConvertDosToUnixNewFile(char *ipInFN
char *TempPath;
struct stat StatBuf;
struct utimbuf UTimeBuf;
int fd;
+ mode_t mask;
#ifdef NO_MKSTEMP
FILE* fd;
#else
@@ -487,7 +488,7 @@ int ConvertDosToUnixNewFile(char *ipInFN
ipFlag->status = 0 ;
/* retrieve ipInFN file date stamp */
- if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
+ if (stat(ipInFN, &StatBuf))
RetVal = -1;
if((fd = MakeTempFileFrom(ipOutFN, &TempPath))<0) {
@@ -346,6 +347,12 @@ int ConvertDosToUnixNewFile(char *ipInFN
#ifdef NO_MKSTEMP
@@ -519,6 +520,12 @@ int ConvertDosToUnixNewFile(char *ipInFN
RetVal = -1;
}

View File

@ -1,23 +1,17 @@
Summary: Text file format converter
Name: dos2unix
Version: 3.1
Release: 36%{?dist}
Version: 4.1.1
Release: 1%{?dist}
Group: Applications/Text
License: BSD
# There is no upstream for this.
Source: %{name}-%{version}.tar.bz2
Url: http://www.xs4all.nl/~waterlan/dos2unix.html
Source: http://www.xs4all.nl/~waterlan/dos2unix/%{name}-%{version}.tar.gz
Patch0: %{name}-%{version}.patch
Patch1: dos2unix-3.1-segfault.patch
Patch2: dos2unix-3.1-safeconv.patch
Patch3: dos2unix-3.1-manpage-update-57507.patch
Patch4: dos2unix-3.1-preserve-file-modes.patch
Patch5: dos2unix-3.1-tmppath.patch
Patch6: dos2unix-c-missing-arg.patch
Patch7: dos2unix-missing-proto.patch
Patch8: dos2unix-manpage.patch
Patch9: dos2unix-preserve-file-modes.patch
BuildRequires: gettext
Patch1: dos2unix-preserve-file-modes.patch
Patch2: dos2unix-CFLAGS.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -26,39 +20,20 @@ Dos2unix converts DOS or MAC text files to UNIX format.
%prep
%setup -q
%patch0 -p1 -b .orig
%patch1 -p1 -b .segfault
%patch2 -p1 -b .safeconv
%patch3 -p1 -b .manpage-update-57507
%patch4 -p1 -b .preserve-file-modes
%patch5 -p1 -b .tmppath
%patch6 -p1 -b .c-missing-arg
%patch7 -p1 -b .missing-proto
%patch8 -p1 -b .manpage
%patch9 -p1 -b .preserve-file-modes
for I in *.[ch]; do
sed -e 's,#endif.*,#endif,g' -e 's,#else.*,#else,g' $I > $I.new
mv -f $I.new $I
done
make clean
%patch1 -p1 -b .preserve-file-modes
%patch2 -p1 -b .CFLAGS
%build
make CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE $(getconf LFS_CFLAGS)" \
%{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=%{buildroot} install
%find_lang %{name}
mkdir -p $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1}
install -p -m755 dos2unix $RPM_BUILD_ROOT%{_bindir}
ln -s dos2unix $RPM_BUILD_ROOT%{_bindir}/mac2unix
install -p -m644 dos2unix.1 $RPM_BUILD_ROOT%{_mandir}/man1
ln -s dos2unix.1 $RPM_BUILD_ROOT%{_mandir}/man1/mac2unix.1
%files
%files -f %{name}.lang
%defattr(-,root,root,0755)
%doc COPYRIGHT
%doc COPYING.txt
%{_bindir}/dos2unix
%{_bindir}/mac2unix
%{_mandir}/*/*
@ -67,6 +42,9 @@ ln -s dos2unix.1 $RPM_BUILD_ROOT%{_mandir}/man1/mac2unix.1
rm -rf $RPM_BUILD_ROOT
%changelog
* Fri Jan 22 2010 Tim Waugh <twaugh@redhat.com> 4.1.1-1
- 4.1.1. New upstream.
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1-36
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

View File

@ -1 +1 @@
f90026a397cf787083ec2e4892c6dcdd dos2unix-3.1.tar.bz2
d06f398d1a91d8f02604fa57166d4c44 dos2unix-4.1.1.tar.gz