delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/11/08/09:57:17

Date: Wed, 8 Nov 2000 13:27:53 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: Re: Patch for dtou.c and utod.c
In-Reply-To: <Pine.A41.4.05.10011080927500.30308-100000@ieva06.lanet.lv>
Message-ID: <Pine.SUN.3.91.1001108130937.6166C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


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