Browse Source

fix a few compile errors and a potential case conversion bug in unicode

pull/1/head
Sami Vaarala 11 years ago
parent
commit
8b69579ab3
  1. 15
      src/duk_unicode_support.c

15
src/duk_unicode_support.c

@ -634,9 +634,9 @@ static duk_codepoint_t slow_case_conversion(duk_hthread *thr,
DUK_DDDPRINT("range: start_i=%d, start_o=%d, count=%d, skip=%d",
(int) start_i, (int) start_o, (int) count, (int) skip);
tmp_cp = cp - start_i;
if (tmp_cp >= 0 &&
tmp_cp < (duk_codepoint_t) count * (duk_codepoint_t) skip &&
if (cp >= start_i) {
tmp_cp = cp - start_i; /* always >= 0 */
if (tmp_cp < (duk_codepoint_t) count * (duk_codepoint_t) skip &&
(tmp_cp % (duk_codepoint_t) skip) == 0) {
DUK_DDDPRINT("range matches input codepoint");
cp = start_o + tmp_cp;
@ -644,6 +644,7 @@ static duk_codepoint_t slow_case_conversion(duk_hthread *thr,
}
}
}
}
/* 1:1 conversion */
n = duk_bd_decode(bd_ctx, 6);
@ -703,15 +704,13 @@ static duk_codepoint_t slow_case_conversion(duk_hthread *thr,
static duk_signed_codepoint_t case_transform_helper(duk_hthread *thr,
duk_hbuffer_dynamic *buf,
duk_signed_codepoint_t cp,
duk_codepoint_t cp,
duk_signed_codepoint_t prev,
duk_signed_codepoint_t next,
duk_small_int_t uppercase,
duk_small_int_t language) {
duk_bitdecoder_ctx bd_ctx;
DUK_ASSERT(cp >= 0);
/* fast path for ASCII */
if (cp < 0x80UL) {
/* FIXME: context sensitive rules exist for ASCII range too.
@ -823,7 +822,7 @@ void duk_unicode_case_convert_string(duk_hthread *thr, duk_small_int_t uppercase
/* may generate any number of output codepoints */
case_transform_helper(thr,
h_buf,
curr,
(duk_codepoint_t) curr,
prev,
next,
uppercase,
@ -845,7 +844,7 @@ void duk_unicode_case_convert_string(duk_hthread *thr, duk_small_int_t uppercase
*/
duk_codepoint_t duk_unicode_re_canonicalize_char(duk_hthread *thr, duk_codepoint_t cp) {
duk_codepoint_t y;
duk_signed_codepoint_t y;
y = case_transform_helper(thr,
NULL, /* buf */

Loading…
Cancel
Save