]> git.tdb.fi Git - libs/core.git/commitdiff
Fix warnings about certain narrowing conversions not being allowed in C++11
authorMikko Rasa <tdb@tdb.fi>
Thu, 10 May 2012 21:11:17 +0000 (00:11 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 10 May 2012 21:11:17 +0000 (00:11 +0300)
source/io/poll.cpp
source/stringcodec/iso2022jp.cpp
source/stringcodec/jisx0208.cpp
source/strings/utils.cpp

index 9697ebfc3aa2094225325ea0aebcadb75d19953d..fb5c62fcbf1737f23e556d169f59d5652f00c2db 100644 (file)
@@ -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;
 
index 14a4b99f83196b835b44eba00afb51082760d37a..ebfe5f79acd210f61b7159900b0129ab899517a4 100644 (file)
@@ -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);
        }
 }
index d56ec33d22a2da43bc6ff8b8bc1d6af30e549706..008a5e14fbd3dd59d4f4d5ecd455045f3b1a3d51 100644 (file)
@@ -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
index fff6cdb290362cb724b96b61c29f68c5970dfe0c..a67eb15b1f4b2b738fecc1b40bc60e7e9e3a97f3 100644 (file)
@@ -253,7 +253,9 @@ string c_escape(const string &str, bool escape_8bit)
                        result += "\\\\";
                else if(static_cast<unsigned char>(*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<unsigned char>(*i)>>(6-j*3))&7);
                        result.append(buf, 4);
                }
                else