Re: [PATCH v2 2/3] configure.ac: define ICONV_OMITS_BOM if necessary
- From
Jeff King <peff@peff.net>
- Date
- Nov 1, 2019, 16:56 UTC
- Message-ID
- <20191101165657.GC26219@sigill.intra.peff.net>
- In-Reply-To
- <7c2c6f060393abf3ac831837e4bf8ed366c2fa69.1572596278.git.congdanhqx@gmail.com>
On Fri, Nov 01, 2019 at 03:25:10PM +0700, Doan Tran Cong Danh wrote:
Show 9 quoted lines
> From commit 79444c9294, ("utf8: handle systems that don't write BOM for
> UTF-16", 2019-02-12), we're supporting those systems with iconv that
> omits BOM with:
>
> make ICONV_OMITS_BOM=Yes
>
> However, typing the flag all the time is cumbersome and error-prone.
>
> Add a checking into configure script to detect this flag automatically.s/checking/check/
The patch looks good to me, though my knowledge of both iconv and autoconf is relatively lacking. I'll assume it works on your system, though. :)
One thing I noticed:
> + v = (unsigned char)(out[0]) + (unsigned char)(out[1]); > + return v != 0xfe + 0xff;
I wondered at first why not just:
return v[0] != 0xfe || v[1] != 0xff;
but the answer is that you are catching BOMs of either endianness. We might at some point need to distinguish the two, but I think for the purposes of OMITS_BOM, we don't have to care. So we can worry about that later (if ever).
-Peff