From: Justin Tobler <jltobler@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/3] meson: simplify iconv-emits-BOM check
Date: Mon, 9 Mar 2026 10:33:42 -0500 [thread overview]
Message-ID: <aa7nk37z9VkaiEyt@denethor> (raw)
In-Reply-To: <20260305-pks-gitlab-ci-macos-16-v1-1-ce8da0ff29c2@pks.im>
On 26/03/05 12:20PM, Patrick Steinhardt wrote:
> Simplify the iconv-emits-BOM check that we have in Meson a bit by:
>
> - Dropping useless variables.
>
> - Casting the `inpos` pointer to `void *` instead of using a typedef
> that depends on whether or not we use an old iconv library.
>
> This overall condenses the code signficantly and makes it easier to
> follow.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> meson.build | 56 ++++++++++++++++++++------------------------------------
> 1 file changed, 20 insertions(+), 36 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 4b536e0124..ee3d9ced92 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1040,42 +1040,26 @@ if iconv.found()
> have_old_iconv = true
> endif
>
> - iconv_omits_bom_source = '''#
> - #include <iconv.h>
> -
> - int main(int argc, const char **argv)
> - {
> - '''
> - if have_old_iconv
> - iconv_omits_bom_source += '''
> - typedef const char *iconv_ibp;
> - '''
> - else
> - iconv_omits_bom_source += '''
> - typedef char *iconv_ibp;
> - '''
> - endif
> - iconv_omits_bom_source += '''
> - int v;
> - iconv_t conv;
> - char in[] = "a"; iconv_ibp pin = in;
> - char out[20] = ""; char *pout = out;
> - size_t isz = sizeof in;
> - size_t osz = sizeof out;
> -
> - conv = iconv_open("UTF-16", "UTF-8");
> - iconv(conv, &pin, &isz, &pout, &osz);
> - iconv_close(conv);
> - v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
> - return v != 0xfe + 0xff;
> - }
> - '''
> -
> - if meson.can_run_host_binaries() and compiler.run(iconv_omits_bom_source,
> - dependencies: iconv,
> - name: 'iconv omits BOM',
> - ).returncode() != 0
> - libgit_c_args += '-DICONV_OMITS_BOM'
> + if meson.can_run_host_binaries()
> + if compiler.run('''
> + #include <iconv.h>
> +
> + int main(int argc, const char **argv)
> + {
> + char in[] = "a", *inpos = in;
> + char out[20] = "", *outpos = out;
> + size_t insz = sizeof(in), outsz = sizeof(out);
> + iconv_t conv = iconv_open("UTF-16", "UTF-8");
> + iconv(conv, (void *) &inpos, &insz, &outpos, &outsz);
Ok, we are able to avoid the typedefs used for pin/inpos by simply
casting to void *. This does indeed simplify how the program is
constructed while remaining functionally the same. Looks good.
-Justin
next prev parent reply other threads:[~2026-03-09 15:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 11:20 [PATCH 0/3] gitlab-ci: update to macOS 15 images Patrick Steinhardt
2026-03-05 11:20 ` [PATCH 1/3] meson: simplify iconv-emits-BOM check Patrick Steinhardt
2026-03-09 15:33 ` Justin Tobler [this message]
2026-03-05 11:20 ` [PATCH 2/3] meson: detect broken iconv that requires ICONV_RESTART_RESET Patrick Steinhardt
2026-03-09 16:02 ` Justin Tobler
2026-03-05 11:20 ` [PATCH 3/3] gitlab-ci: update to macOS 15 images Patrick Steinhardt
2026-03-09 16:04 ` Justin Tobler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa7nk37z9VkaiEyt@denethor \
--to=jltobler@gmail.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.