Mail Archives: djgpp-workers/2000/11/08/09:57:17
On Wed, 8 Nov 2000, Andris Pavenis wrote:
> Unfortunatelly they are not ok when built with paranoid options used in
> djlsrXXX.zip as we still have warnings treated as errors (rebuilt
> all from CVS sources under Linux this morning). So one additional small
> patch is needed.
[snip]
> static int
> dtou(char *fname)
> {
> - int i, k, k2, sf, df, l, l2, err=0, isCR=0;
> + int i, k, k2, sf, df, l, l2=0, err=0, isCR=0;
> char buf[16384];
> char tfname[FILENAME_MAX], *bn, *w;
> struct stat st;
> @@ -60,7 +60,7 @@
> else buf[k++] = buf[i];
> isCR = 0;
> }
> - if (k>0) l2=write(df, buf, k);
> + l2=(k>0 ? write(df, buf, k) : 0);
Given that l2 is already initialized at the beginning of dtou(), do you
really need the second change above? What does the compiler say if you
don't make the second change?
> One additional suggestion: There are small DOS utility in Simtelnet
> (simtelnet/msdos/fileutils/nocrlf10.zip) which permits to repair
> binary files which are errorously transfered as text (it was DOS only so
> no LFN support, of course). Now only change we need for that in dtou is to
> skip Ctrl-Z processing. My suggestion is to do that if executable name is
> nocrlf only.
I'd suggest a command-line option instead. That way, the feature won't
mysteriously disappear if someone renames the executable.
And, if we are talking about adding features to DTOU, here's a small
wishlist:
- add verbose operation option, whereby the program will print whether
it removed any CR's and ^Z's, and whether some lines had LF without a
CR (a sure sign the file is either binary or has inconsistent EOL
format for some other reason).
- add an option which will remove any number of CRs before an LF, as in
"\r\r\r\r\r\n" (this happens with buggy ports of Unix software, such
as the Windows CVS client, which always blindly add a CR to LF, even
if there's already a CR there).
- return an exit status which says whether any changes were done to the
file.
- add an option which causes the file time stamps to be preserved only
if the file was left unchanged.
- explain more about how these two programs work in utils.tex.
Any takers?
- Raw text -