From 26e60e45fc5955ff004161cac9185d67136b5b72 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 10 Jul 2017 21:53:18 +0200 Subject: [PATCH] getopt: fix an assert triggered in the Windows runtime. --- src/sys/getopt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sys/getopt.cpp b/src/sys/getopt.cpp index 09bd1e18..d2a79684 100644 --- a/src/sys/getopt.cpp +++ b/src/sys/getopt.cpp @@ -71,7 +71,9 @@ void getopt::add_opt(int short_opt, char const *long_opt, bool has_arg) getopt_private::optdesc o { long_opt, has_arg, nullptr, short_opt }; m_private->m_opts.push(o); - if (isalnum(short_opt)) + /* “The standards require that the argument [to isalnum()] is either + * EOF or a value that is representable in the type unsigned char.” */ + if ((int)(unsigned char)short_opt == short_opt && isalnum(short_opt)) { m_private->m_optstring += (char)short_opt; if (has_arg)