delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/03/20/05:29:21

Date: Tue, 20 Mar 2001 11:24:33 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Juan Manuel Guerrero <ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De>
cc: djgpp-workers AT delorie DOT com
Subject: Re: 2 suggestions for djtar
In-Reply-To: <5167B200FDB@HRZ1.hrz.tu-darmstadt.de>
Message-ID: <Pine.SUN.3.91.1010320112410.7756O@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 Mon, 19 Mar 2001, Juan Manuel Guerrero wrote:

> +       extension = strrchr(header.name, '.');
> +       if (extension)
> +       {
> +         char *string = xmalloc(strlen(extension) + 1);
> +         strcpy(string, extension);
> + 
> +         i = 0;
> +         while (string[++i])
> +           if (string[i] >= 'A' && string[i] <= 'T')
> +             string[i] = string[i] - 'A' + 'a';
> +         if (strstr(string, ".bat") && string[sizeof(".bat") - 1] == '\0')
> +           batch_file_processing = 1;  /* LF -> CRLF */
> + 
> +         free(string);
> +       }

Why didn't you simply use strncasecmp on the original extension,
instead of copying and modifying it?  That would simplify the code and
avoid possible heap fragmentation due to many small allocations.  Is
there any reason I'm missing for not using strncasecmp?

> !       if (batch_file_processing && !to_tty)
>         {
> !         /* LF -> CRLF.
> !            Note that we don't alter the original uncompressed
> !            data so as not to screw up the CRC computations.  */
> !         char *src = buf, *dest = tbuf;
> !         int buflen = 0;
> !         while (buflen < dsize)
>           {
> !           if (*src == '\n' && *(src - 1) != '\r' && buflen)

The last if clause should test buflen first, and only then reference
src[-1], because if buflen is zero, src[-1] is outside the buffer.

And please also send a short blurb for wc204.txi about this feature,
and a patch for djtar's docs.

With these minor issues taken care of, the patches can go in, I
think.  Thanks for working on this!

- Raw text -


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