From: Mikko Rasa Date: Thu, 10 May 2012 21:11:17 +0000 (+0300) Subject: Fix warnings about certain narrowing conversions not being allowed in C++11 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=26636afce9c85c6c78c7267ebcd18d165825024b;p=libs%2Fcore.git Fix warnings about certain narrowing conversions not being allowed in C++11 --- diff --git a/source/io/poll.cpp b/source/io/poll.cpp index 9697ebf..fb5c62f 100644 --- a/source/io/poll.cpp +++ b/source/io/poll.cpp @@ -18,7 +18,7 @@ namespace { using namespace Msp; using namespace Msp::IO; -inline int sys_poll_event(PollEvent event) +inline short int sys_poll_event(PollEvent event) { int result = 0; diff --git a/source/stringcodec/iso2022jp.cpp b/source/stringcodec/iso2022jp.cpp index 14a4b99..ebfe5f7 100644 --- a/source/stringcodec/iso2022jp.cpp +++ b/source/stringcodec/iso2022jp.cpp @@ -40,7 +40,9 @@ void Iso2022Jp::Encoder::encode_char(unichar ch, string &buf) if(mode!=JISX0208) switch_mode(JISX0208, buf); - char jbuf[2] = { jis.ku+0x20, jis.ten+0x20 }; + char jbuf[2]; + jbuf[0] = jis.ku+0x20; + jbuf[1] = jis.ten+0x20; buf.append(jbuf, 2); } } diff --git a/source/stringcodec/jisx0208.cpp b/source/stringcodec/jisx0208.cpp index d56ec33..008a5e1 100644 --- a/source/stringcodec/jisx0208.cpp +++ b/source/stringcodec/jisx0208.cpp @@ -12,7 +12,9 @@ void JisX0208::Encoder::encode_char(unichar ucs, string &buf) unsigned short jis = ucs_to_jisx0208(ucs); if(jis) { - char jbuf[2] = {jis>>8, jis}; + char jbuf[2]; + jbuf[0] = jis>>8; + jbuf[1] = jis; buf.append(jbuf, 2); } else diff --git a/source/strings/utils.cpp b/source/strings/utils.cpp index fff6cdb..a67eb15 100644 --- a/source/strings/utils.cpp +++ b/source/strings/utils.cpp @@ -253,7 +253,9 @@ string c_escape(const string &str, bool escape_8bit) result += "\\\\"; else if(static_cast(*i)<' ' || (escape_8bit && (*i&0x80))) { - char buf[4] = {'\\', '0'+((*i>>6)&3), '0'+((*i>>3)&7), '0'+(*i&7)}; + char buf[4] = { '\\', 0 }; + for(unsigned j=0; j<3; ++j) + buf[1+j] = '0'+((static_cast(*i)>>(6-j*3))&7); result.append(buf, 4); } else