1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/enc
shyouhei 6732423b5e enc/unicode.c: 'a' is bigger than 'A'
In ASCII, 'a' is bigger than 'A'. Which means 'A' - 'a' is a negative
number (-32, to be precise). In C, the type of 'a' and 'A' are signed
int (cf: ISO/IEC 9899:1990 section 6.1.3.4). So 'A' - 'a' is also a
signed int. It is `(signed int)-32`.

The problem is, OnigCodePoint is unsigned int. Adding a negative
number to a variable of OnigCodepoint (`code` here) introduces an
unintentional cast of `(unsigned)(signed)-32`, which is
4,294,967,264. Adding this value to code then overflows, and the
result eventually becomes normal codepoint.

The series of operations are not a serious problem but because
`code >= 'a'` holds, we can `(code - 'a') + 'A'` to reroute this.

See also: https://github.com/k-takata/Onigmo/pull/107


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16 02:34:00 +00:00
..
jis
trans
unicode revert r65091, r65090 because ci fails 2018-10-16 07:53:37 +00:00
ascii.c
big5.c
cp949.c
depend ruby tool/update-deps --fix 2018-07-05 12:48:45 +00:00
ebcdic.h
emacs_mule.c
encdb.c
encinit.c.erb
euc_jp.c
euc_kr.c
euc_tw.c
gb2312.c
gb18030.c
gbk.c
iso_2022_jp.h
iso_8859.h
iso_8859_1.c
iso_8859_2.c
iso_8859_3.c
iso_8859_4.c
iso_8859_5.c
iso_8859_6.c
iso_8859_7.c
iso_8859_8.c
iso_8859_9.c
iso_8859_10.c
iso_8859_11.c
iso_8859_13.c
iso_8859_14.c
iso_8859_15.c
iso_8859_16.c
koi8_r.c
koi8_u.c
make_encmake.rb Refactor ERB version checking for keyword arguments 2018-02-27 11:12:23 +00:00
Makefile.in
mktable.c
shift_jis.c
shift_jis.h
unicode.c enc/unicode.c: 'a' is bigger than 'A' 2018-11-16 02:34:00 +00:00
us_ascii.c
utf_7.h
utf_8.c
utf_16_32.h
utf_16be.c
utf_16le.c
utf_32be.c
utf_32le.c
windows_31j.c
windows_1250.c
windows_1251.c
windows_1252.c
windows_1253.c
windows_1254.c
windows_1257.c
x_emoji.h