diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-10-17 20:17:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-10-17 20:17:22 -0700 |
commit | 9b18f519decaf0cd7f52571c3c44012e3fc23a3a (patch) | |
tree | 5848a0bfd530e51183dbbf1e201a56ccf437fbd1 /utf8.c | |
parent | 9f158a44b7e88c1dcfb8d56f4f85d642fc423b59 (diff) | |
download | txr-9b18f519decaf0cd7f52571c3c44012e3fc23a3a.tar.gz txr-9b18f519decaf0cd7f52571c3c44012e3fc23a3a.tar.bz2 txr-9b18f519decaf0cd7f52571c3c44012e3fc23a3a.zip |
Converting cast expressions to macros that are retargetted
to C++ style casts when compiling as C++.
* lib.h (strip_qual, convert, coerce): New casting macros.
(TAG_MASK, tag, type, wli_noex, auto_str, static_str,
litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros.
* arith.c (mul, isqrt_fixnum, bit): Use cast macros.
* configure (INT_PTR_MAX): Define using cast macro.
* debug.c (debug_init): Use cast macro.
* eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init):
Use cast macros.
* filter.c (filter_init): Use cast macro.
* gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use
cast macros.
* hash.c (hash_double, equal_hash, eql_hash, hash_equal_op,
hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash,
copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash,
hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy,
hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use
cast macros.
* lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc,
chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring,
upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str,
c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec,
cobj_print_op, obj_init): Likewise.
* match.c (do_match_line, hv_trampoline, match_files, dir_tables_init):
Likewise.
* parser.l (grammar): Likewise.
* parser.y (parse): Likewise.
* rand.c (make_state, make_random_state, random_fixnum, random):
Likewise.
* regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO,
CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range,
L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range,
L2_contains, L2_free, L3_fill_range, L3_contains, L3_free,
char_set_create, char_set_cobj_destroy, nfa_state_accept,
nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -114,7 +114,7 @@ size_t utf8_from_uc(wchar_t *wdst, const unsigned char *src) if (ch >= 0x80 && ch < 0xC0) { wch <<= 6; wch |= (ch & 0x3F); - state = (enum utf8_state) (state - 1); + state = convert(enum utf8_state, state - 1); if (state == utf8_init) { if (wch < wch_min || (wch <= 0xFFFF && (wch & 0xFF00) == 0xDC00) || @@ -147,7 +147,7 @@ size_t utf8_from_uc(wchar_t *wdst, const unsigned char *src) size_t utf8_from(wchar_t *wdst, const char *src) { - return utf8_from_uc(wdst, (const unsigned char *) src); + return utf8_from_uc(wdst, coerce(const unsigned char *, src)); } size_t utf8_to_uc(unsigned char *dst, const wchar_t *wsrc) @@ -197,13 +197,13 @@ size_t utf8_to_uc(unsigned char *dst, const wchar_t *wsrc) size_t utf8_to(char *dst, const wchar_t *wsrc) { - return utf8_to_uc((unsigned char *) dst, wsrc); + return utf8_to_uc(coerce(unsigned char *, dst), wsrc); } wchar_t *utf8_dup_from_uc(const unsigned char *str) { size_t nchar = utf8_from_uc(0, str); - wchar_t *wstr = (wchar_t *) chk_malloc(nchar * sizeof *wstr); + wchar_t *wstr = coerce(wchar_t *, chk_malloc(nchar * sizeof *wstr)); utf8_from_uc(wstr, str); return wstr; } @@ -211,7 +211,7 @@ wchar_t *utf8_dup_from_uc(const unsigned char *str) wchar_t *utf8_dup_from(const char *str) { size_t nchar = utf8_from(0, str); - wchar_t *wstr = (wchar_t *) chk_malloc(nchar * sizeof *wstr); + wchar_t *wstr = coerce(wchar_t *, chk_malloc(nchar * sizeof *wstr)); utf8_from(wstr, str); return wstr; } @@ -227,7 +227,7 @@ unsigned char *utf8_dup_to_uc(const wchar_t *wstr) char *utf8_dup_to(const wchar_t *wstr) { size_t nbyte = utf8_to(0, wstr); - char *str = (char *) chk_malloc(nbyte); + char *str = coerce(char *, chk_malloc(nbyte)); utf8_to(str, wstr); return str; } @@ -332,9 +332,9 @@ wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(mem_t *ctx), mem_t *ctx) if (ch >= 0x80 && ch < 0xC0) { ud->wch <<= 6; ud->wch |= (ch & 0x3F); - ud->state = (enum utf8_state) (ud->state - 1); + ud->state = convert(enum utf8_state, ud->state - 1); if (ud->state == utf8_init) { - if (ud->wch < ud->wch_min || + if (ud->wch < ud->wch_min || (ud->wch <= 0xFFFF && (ud->wch & 0xFF00) == 0xDC00) || (ud->wch > 0x10FFFF)) { |