Mail Archives: djgpp-workers/2001/03/20/05:29:21
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 -