svn commit: r196981 - head/usr.bin/unzip
Andrey Chernov
ache at nagual.pp.ru
Wed Sep 9 13:26:19 UTC 2009
On Tue, Sep 08, 2009 at 03:55:13PM +0000, Roman Divacky wrote:
> + * Detect whether this is a text file. The correct way to
> + * do this is to check the least significant bit of the
> + * "internal file attributes" field of the corresponding
> + * file header in the central directory, but libarchive
> + * does not read the central directory, so we have to
> + * guess by looking for non-ASCII characters in the
> + * buffer. Hopefully we won't guess wrong. If we do
> + * guess wrong, we print a warning message later.
> + */
> + if (a_opt && n == 0) {
> + for (p = buffer; p < end; ++p) {
> + if (!isascii((unsigned char)*p)) {
> + text = 0;
> + break;
> + }
> + }
> + }
> +
If I understand the purpose of this code right, better use
isalnum()+ispunct()+ispace()
combination to count non-ASCII people too.
Also setlocale() call must be added to the main() for that.
--
http://ache.pp.ru/
More information about the svn-src-head
mailing list