delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/11/08/11:53:34

From: pavenis AT lanet DOT lv
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>, djgpp-workers AT delorie DOT com
Date: Wed, 8 Nov 2000 17:17:59 +0200
MIME-Version: 1.0
Subject: Re: Patch for dtou.c and utod.c
Message-ID: <3A098AC7.20369.9EE463@localhost>
References: <Pine DOT A41 DOT 4 DOT 05 DOT 10011080927500 DOT 30308-100000 AT ieva06 DOT lanet DOT lv>
In-reply-to: <Pine.SUN.3.91.1001108130937.6166C-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com

On 8 Nov 2000, at 13:27, Eli Zaretskii wrote:

> 
> 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?

It's for case when Ctrl-Z is the first character in buffer. We need to 
zero it as this may be not the first block read. Of course we could try to
write 0 bytes ....

> > 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?

Maybe sometime ...

Andris


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019