From eea48e59d38beb3240989145a203c839f01695fd Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Sat, 31 Mar 2012 14:24:33 -0400 Subject: [PATCH] Avoid compiler warning on platforms where wchar_t is uint32_t (arm) --- src/terminal/parser.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/terminal/parser.cc b/src/terminal/parser.cc index db0b0b7..227763f 100644 --- a/src/terminal/parser.cc +++ b/src/terminal/parser.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include "parser.h" @@ -121,11 +122,16 @@ std::list Parser::UTF8Parser::input( char c ) throw std::string( "Unknown return value from mbrtowc" ); } - if ( (pwc < 0) || (pwc > 0x10FFFF) ) { /* outside Unicode range */ + /* Cast to unsigned for checks, because some + platforms (e.g. ARM) use uint32_t as wchar_t, + causing compiler warning on "pwc > 0" check. */ + uint64_t pwcheck = pwc; + + if ( pwcheck > 0x10FFFF ) { /* outside Unicode range */ pwc = (wchar_t) 0xFFFD; } - if ( (pwc >= 0xD800) && (pwc <= 0xDFFF) ) { /* surrogate code point */ + if ( (pwcheck >= 0xD800) && (pwcheck <= 0xDFFF) ) { /* surrogate code point */ /* OS X unfortunately allows these sequences without EILSEQ, but they are ill-formed UTF-8 and we shouldn't repeat them to the