PERFORCE change 144026 for review

Gabor Kovesdan gabor at FreeBSD.org
Tue Jun 24 19:21:26 UTC 2008


Tim Kientzle escribió:
> Gabor,
>
> Unrelated, but I noticed that you have an unchecked
> call to mbstowcs() here.  mbstowcs() can fail; I
> recently went through a couple months of pain reworking
> chunks of libarchive to correctly handle such failures.
> I ended up falling back on mbtowc() to convert one
> character at a time.
Thanks Tim, I've forgotten about this check here, but yes, I understand 
its importance.
>
> You'll see conversion failures, for example, if
> someone is using a multi-character locale such
> as UTF-8 and runs grep over a file encoded in ISO-8859-1.
> (People often use "grep -R <symbol> /usr/src" for example,
> and a lot of C source files have people's names
> in ISO-8859-1.)
>
> Throwing out the entire file (or even entire line)
> because of a single character that can't be
> interpreted is probably not going to be feasible.
I've tried it with LC_ALL=hu_HU.UTF-8 on ISO8859-[12] files and it still 
works. But to be sure, I'll just return 0 instead of calling err. Do you 
think it's ok, or do we need something special?

Gabor


More information about the p4-projects mailing list