aboutsummaryrefslogtreecommitdiffstats
path: root/enc/trans/utf_16_32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-21 03:35:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-21 03:35:05 +0000
commit463af63468620614074f024fb4310dc1cd332495 (patch)
treeafb315b64617c1cbacb95ae5a75a115bafe84bd7 /enc/trans/utf_16_32.c
parent76e19bc534c36daf2d093ff3eb434737756a86ef (diff)
downloadruby-463af63468620614074f024fb4310dc1cd332495.tar.gz
* transcode.c (transcode_loop, str_transcoding_resize): use unsigned
char. [ruby-dev:33232] * transcode_data.h (rb_transcoding, rb_transcoder): removed callback parameters. * enc/trans/japanese.c: ditto. * enc/trans/utf_16_32.c: parenthesized bit-or operands. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/trans/utf_16_32.c')
-rw-r--r--enc/trans/utf_16_32.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/enc/trans/utf_16_32.c b/enc/trans/utf_16_32.c
index 1eb04c1519..0247e5dce6 100644
--- a/enc/trans/utf_16_32.c
+++ b/enc/trans/utf_16_32.c
@@ -12,21 +12,21 @@ fun_so_from_utf_16be(const unsigned char* s, unsigned char* o)
}
else if (s[0]<0x08) {
o[0] = 0xC0 | (s[0]<<2) | (s[1]>>6);
- o[1] = 0x80 | s[1]&0x3F;
+ o[1] = 0x80 | (s[1]&0x3F);
return 2;
}
else if ((s[0]&0xF8)!=0xD8) {
o[0] = 0xE0 | s[0]>>4;
o[1] = 0x80 | ((s[0]&0x0F)<<2) | (s[1]>>6);
- o[2] = 0x80 | s[1]&0x3F;
+ o[2] = 0x80 | (s[1]&0x3F);
return 3;
}
else {
unsigned int u = (((s[0]&0x03)<<2)|(s[1]>>6)) + 1;
o[0] = 0xF0 | u>>2;
- o[1] = 0x80 | ((u&0x03)<<4) | (s[1]>>2)&0x0F;
+ o[1] = 0x80 | ((u&0x03)<<4) | ((s[1]>>2)&0x0F);
o[2] = 0x80 | ((s[1]&0x03)<<4) | ((s[2]&0x03)<<2) | (s[3]>>6);
- o[3] = 0x80 | s[3]&0x3F;
+ o[3] = 0x80 | (s[3]&0x3F);
return 4;
}
}
@@ -41,16 +41,16 @@ fun_so_to_utf_16be(const unsigned char* s, unsigned char* o)
}
else if ((s[0]&0xE0)==0xC0) {
o[0] = (s[0]>>2)&0x07;
- o[1] = ((s[0]&0x03)<<6) | s[1]&0x3F;
+ o[1] = ((s[0]&0x03)<<6) | (s[1]&0x3F);
return 2;
}
else if ((s[0]&0xF0)==0xE0) {
- o[0] = (s[0]<<4) | (s[1]>>2)^0x20;
- o[1] = (s[1]<<6) | s[2]^0x80;
+ o[0] = (s[0]<<4) | ((s[1]>>2)^0x20);
+ o[1] = (s[1]<<6) | (s[2]^0x80);
return 2;
}
else {
- int w = (((s[0]&0x07)<<2) | (s[1]>>4)&0x03) - 1;
+ int w = (((s[0]&0x07)<<2) | ((s[1]>>4)&0x03)) - 1;
o[0] = 0xD8 | (w>>2);
o[1] = (w<<6) | ((s[1]&0x0F)<<2) | ((s[2]>>4)-8);
o[2] = 0xDC | ((s[2]>>2)&0x03);
@@ -68,21 +68,21 @@ fun_so_from_utf_16le(const unsigned char* s, unsigned char* o)
}
else if (s[1]<0x08) {
o[0] = 0xC0 | (s[1]<<2) | (s[0]>>6);
- o[1] = 0x80 | s[0]&0x3F;
+ o[1] = 0x80 | (s[0]&0x3F);
return 2;
}
else if ((s[1]&0xF8)!=0xD8) {
o[0] = 0xE0 | s[1]>>4;
o[1] = 0x80 | ((s[1]&0x0F)<<2) | (s[0]>>6);
- o[2] = 0x80 | s[0]&0x3F;
+ o[2] = 0x80 | (s[0]&0x3F);
return 3;
}
else {
unsigned int u = (((s[1]&0x03)<<2)|(s[0]>>6)) + 1;
o[0] = 0xF0 | u>>2;
- o[1] = 0x80 | ((u&0x03)<<4) | (s[0]>>2)&0x0F;
+ o[1] = 0x80 | ((u&0x03)<<4) | ((s[0]>>2)&0x0F);
o[2] = 0x80 | ((s[0]&0x03)<<4) | ((s[3]&0x03)<<2) | (s[2]>>6);
- o[3] = 0x80 | s[2]&0x3F;
+ o[3] = 0x80 | (s[2]&0x3F);
return 4;
}
}
@@ -97,16 +97,16 @@ fun_so_to_utf_16le(const unsigned char* s, unsigned char* o)
}
else if ((s[0]&0xE0)==0xC0) {
o[1] = (s[0]>>2)&0x07;
- o[0] = ((s[0]&0x03)<<6) | s[1]&0x3F;
+ o[0] = ((s[0]&0x03)<<6) | (s[1]&0x3F);
return 2;
}
else if ((s[0]&0xF0)==0xE0) {
- o[1] = (s[0]<<4) | (s[1]>>2)^0x20;
- o[0] = (s[1]<<6) | s[2]^0x80;
+ o[1] = (s[0]<<4) | ((s[1]>>2)^0x20);
+ o[0] = (s[1]<<6) | (s[2]^0x80);
return 2;
}
else {
- int w = (((s[0]&0x07)<<2) | (s[1]>>4)&0x03) - 1;
+ int w = (((s[0]&0x07)<<2) | ((s[1]>>4)&0x03)) - 1;
o[1] = 0xD8 | (w>>2);
o[0] = (w<<6) | ((s[1]&0x0F)<<2) | ((s[2]>>4)-8);
o[3] = 0xDC | ((s[2]>>2)&0x03);