Browse Source

integer constant sign fixes, other trivia

pull/1/head
Sami Vaarala 11 years ago
parent
commit
49597a03b9
  1. 8
      src/duk_builtin_global.c
  2. 30
      src/duk_features.h
  3. 9
      src/duk_unicode.h
  4. 32
      src/duk_unicode_support.c

8
src/duk_builtin_global.c

@ -245,17 +245,17 @@ static void duk_transform_callback_decode_uri(duk_transform_context *tfm_ctx, vo
} else if (t < 0xe0) {
/* 110x xxxx; 2 bytes */
utf8_blen = 2;
min_cp = 0x80UL;
min_cp = 0x80L;
cp = t & 0x1f;
} else if (t < 0xf0) {
/* 1110 xxxx; 3 bytes */
utf8_blen = 3;
min_cp = 0x800UL;
min_cp = 0x800L;
cp = t & 0x0f;
} else if (t < 0xf8) {
/* 1111 0xxx; 4 bytes */
utf8_blen = 4;
min_cp = 0x10000UL;
min_cp = 0x10000L;
cp = t & 0x07;
} else {
/* extended utf-8 not allowed for URIs */
@ -303,7 +303,7 @@ static void duk_transform_callback_decode_uri(duk_transform_context *tfm_ctx, vo
if (cp >= 0x10000L) {
cp -= 0x10000L;
DUK_ASSERT(cp < 0x100000UL);
DUK_ASSERT(cp < 0x100000L);
duk_hbuffer_append_xutf8(tfm_ctx->thr, tfm_ctx->h_buf, (duk_ucodepoint_t) ((cp >> 10) + 0xd800L));
duk_hbuffer_append_xutf8(tfm_ctx->thr, tfm_ctx->h_buf, (duk_ucodepoint_t) ((cp & 0x03ffUL) + 0xdc00L));
} else {

30
src/duk_features.h

@ -492,59 +492,59 @@ typedef duk_size_t size_t;
#define DUK_UINT8_MIN 0UL
#define DUK_UINT8_MAX 0xffUL
#define DUK_INT8_MIN (-0x80L
#define DUK_INT8_MIN (-0x80L)
#define DUK_INT8_MAX 0x7fL
#define DUK_UINT_LEAST8_MIN 0UL
#define DUK_UINT_LEAST8_MAX 0xffUL
#define DUK_INT_LEAST8_MIN (-0x80L
#define DUK_INT_LEAST8_MIN (-0x80L)
#define DUK_INT_LEAST8_MAX 0x7fL
#define DUK_UINT_FAST8_MIN 0UL
#define DUK_UINT_FAST8_MAX 0xffUL
#define DUK_INT_FAST8_MIN (-0x80L
#define DUK_INT_FAST8_MIN (-0x80L)
#define DUK_INT_FAST8_MAX 0x7fL
#define DUK_UINT16_MIN 0UL
#define DUK_UINT16_MAX 0xffffUL
#define DUK_INT16_MIN (-0x8000L
#define DUK_INT16_MIN (-0x8000L)
#define DUK_INT16_MAX 0x7fffL
#define DUK_UINT_LEAST16_MIN 0UL
#define DUK_UINT_LEAST16_MAX 0xffffUL
#define DUK_INT_LEAST16_MIN (-0x8000L
#define DUK_INT_LEAST16_MIN (-0x8000L)
#define DUK_INT_LEAST16_MAX 0x7fffL
#define DUK_UINT_FAST16_MIN 0UL
#define DUK_UINT_FAST16_MAX 0xffffUL
#define DUK_INT_FAST16_MIN (-0x8000L
#define DUK_INT_FAST16_MIN (-0x8000L)
#define DUK_INT_FAST16_MAX 0x7fffL
#define DUK_UINT32_MIN 0UL
#define DUK_UINT32_MAX 0xffffffffUL
#define DUK_INT32_MIN (-0x80000000L
#define DUK_INT32_MIN (-0x80000000L)
#define DUK_INT32_MAX 0x7fffffffL
#define DUK_UINT_LEAST32_MIN 0UL
#define DUK_UINT_LEAST32_MAX 0xffffffffUL
#define DUK_INT_LEAST32_MIN (-0x80000000L
#define DUK_INT_LEAST32_MIN (-0x80000000L)
#define DUK_INT_LEAST32_MAX 0x7fffffffL
#define DUK_UINT_FAST32_MIN 0UL
#define DUK_UINT_FAST32_MAX 0xffffffffUL
#define DUK_INT_FAST32_MIN (-0x80000000L
#define DUK_INT_FAST32_MIN (-0x80000000L)
#define DUK_INT_FAST32_MAX 0x7fffffffL
#define DUK_UINT64_MIN 0ULL
#define DUK_UINT64_MAX 0xffffffffffffffffULL
#define DUK_INT64_MIN (-0x8000000000000000LL
#define DUK_INT64_MIN (-0x8000000000000000LL)
#define DUK_INT64_MAX 0x7fffffffffffffffULL
#define DUK_UINT_LEAST64_MIN 0ULL
#define DUK_UINT_LEAST64_MAX 0xffffffffffffffffULL
#define DUK_INT_LEAST64_MIN (-0x8000000000000000LL
#define DUK_INT_LEAST64_MIN (-0x8000000000000000LL)
#define DUK_INT_LEAST64_MAX 0x7fffffffffffffffULL
#define DUK_UINT_FAST64_MIN 0ULL
#define DUK_UINT_FAST64_MAX 0xffffffffffffffffULL
#define DUK_INT_FAST64_MIN (-0x8000000000000000LL
#define DUK_INT_FAST64_MIN (-0x8000000000000000LL)
#define DUK_INT_FAST64_MAX 0x7fffffffffffffffULL
#define DUK_UINTPTR_MIN 0UL
#define DUK_UINTPTR_MAX 0xffffffffUL
#define DUK_INTPTR_MIN (-0x80000000L
#define DUK_INTPTR_MIN (-0x80000000L)
#define DUK_INTPTR_MAX 0x7fffffffL
#define DUK_UINTMAX_MIN 0UL
#define DUK_UINTMAX_MAX 0xffffffffUL
#define DUK_INTMAX_MIN (-0x80000000L
#define DUK_INTMAX_MIN (-0x80000000L)
#define DUK_INTMAX_MAX 0x7fffffffL
/* SIZE_MAX may be missing so use an approximate value for it. */
@ -880,7 +880,7 @@ extern double duk_computed_nan;
*/
#define DUK_CAUSE_SEGFAULT() do { \
*((int32_t *) NULL) = (int32_t) 0xdeadbeefUL; \
*((uint32_t *) NULL) = (uint32_t) 0xdeadbeefUL; \
} while (0)
/*

9
src/duk_unicode.h

@ -8,9 +8,12 @@
#define DUK_UNICODE_MAX_XUTF8_LENGTH 7 /* up to 36 bit codepoints */
#define DUK_UNICODE_MAX_CESU8_LENGTH 6 /* all codepoints up to U+10FFFF */
#define DUK_UNICODE_CP_ZWNJ 0x200cUL /* zero-width non-joiner */
#define DUK_UNICODE_CP_ZWJ 0x200dUL /* zero-width joiner */
#define DUK_UNICODE_CP_REPLACEMENT_CHARACTER 0xfffdUL /* http://en.wikipedia.org/wiki/Replacement_character#Replacement_character */
/* A few useful codepoints. Integer constants must be signed to avoid
* unexpected coercions in comparisons.
*/
#define DUK_UNICODE_CP_ZWNJ 0x200cL /* zero-width non-joiner */
#define DUK_UNICODE_CP_ZWJ 0x200dL /* zero-width joiner */
#define DUK_UNICODE_CP_REPLACEMENT_CHARACTER 0xfffdL /* http://en.wikipedia.org/wiki/Replacement_character#Replacement_character */
#ifdef DUK_USE_SOURCE_NONBMP
#include "duk_unicode_ids_noa.h"

32
src/duk_unicode_support.c

@ -26,7 +26,7 @@ duk_small_int_t duk_unicode_get_xutf8_length(duk_ucodepoint_t cp) {
} else if (x < 0x4000000UL) {
/* 26 bits */
return 5;
} else if (x < (duk_codepoint_t) 0x80000000UL) {
} else if (x < (duk_ucodepoint_t) 0x80000000UL) {
/* 31 bits */
return 6;
} else {
@ -263,19 +263,19 @@ static duk_uint32_t uni_decode_value(duk_bitdecoder_ctx *bd_ctx) {
duk_uint32_t t;
t = duk_bd_decode(bd_ctx, 4);
if (t <= 0x0e) {
if (t <= 0x0eU) {
return t;
}
t = duk_bd_decode(bd_ctx, 8);
if (t <= 0xfd) {
if (t <= 0xfdU) {
return t + 0x0f;
}
if (t == 0xfe) {
if (t == 0xfeU) {
t = duk_bd_decode(bd_ctx, 12);
return t + 0x0f + 0xfe;
return t + 0x0fU + 0xfeU;
} else {
t = duk_bd_decode(bd_ctx, 24);
return t + 0x0f + 0xfe + 0x1000UL;
return t + 0x0fU + 0xfeU + 0x1000UL;
}
}
@ -379,17 +379,17 @@ duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp) {
hi = (duk_uint_fast32_t) (cp >> 8); /* does not fit into an uchar */
if (hi == 0x0000UL) {
if (lo == 0x09 || lo == 0x0b || lo == 0x0c ||
lo == 0x20 || lo == 0xa0) {
if (lo == 0x09U || lo == 0x0bU || lo == 0x0cU ||
lo == 0x20U || lo == 0xa0U) {
return 1;
}
} else if (hi == 0x0020UL) {
if (lo <= 0x0a || lo == 0x28 || lo == 0x29 ||
lo == 0x2f || lo == 0x5f) {
if (lo <= 0x0aU || lo == 0x28U || lo == 0x29U ||
lo == 0x2fU || lo == 0x5fU) {
return 1;
}
} else if (cp == 0x1680UL || cp == 0x180eUL || cp == 0x3000UL ||
cp == 0xfeffUL) {
} else if (cp == 0x1680L || cp == 0x180eL || cp == 0x3000L ||
cp == 0xfeffL) {
return 1;
}
@ -714,7 +714,7 @@ static duk_codepoint_t case_transform_helper(duk_hthread *thr,
duk_bitdecoder_ctx bd_ctx;
/* fast path for ASCII */
if (cp < 0x80UL) {
if (cp < 0x80L) {
/* FIXME: context sensitive rules exist for ASCII range too.
* Need to add them here.
*/
@ -738,17 +738,17 @@ static duk_codepoint_t case_transform_helper(duk_hthread *thr,
/* FIXME: turkish / azeri */
} else {
/* final sigma context specific rule */
if (cp == 0x03a3UL && /* U+03A3 = GREEK CAPITAL LETTER SIGMA */
if (cp == 0x03a3L && /* U+03A3 = GREEK CAPITAL LETTER SIGMA */
prev >= 0 && /* prev is letter */
next < 0) { /* next is not letter */
/* FIXME: fix conditions */
cp = 0x03c2UL;
cp = 0x03c2L;
goto singlechar;
}
/* FIXME: lithuanian */
if (0 /* language == 'lt' */ &&
cp == 0x0307UL) { /* U+0307 = COMBINING DOT ABOVE */
cp == 0x0307L) { /* U+0307 = COMBINING DOT ABOVE */
goto nochar;
}

Loading…
Cancel
Save