nixpkgs/pkgs/tools/text/dos2unix/dos2unix-c-missing-arg.patch
Rob Vermaas a6cd7eb8a1 dos2unix and unix2dos provided by griswold
svn path=/nixpkgs/trunk/; revision=19409
2010-01-13 21:09:55 +00:00

43 lines
1.6 KiB
Diff

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;
}
}