1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Better range check for codepoints

* libguile/chars.h (SCM_IS_UNICODE_CHAR): check for negative codepoints
This commit is contained in:
Michael Gran 2009-08-28 23:44:41 -07:00
parent 6d736fdba2
commit 526ee76ac3

View file

@ -48,9 +48,13 @@ typedef scm_t_int32 scm_t_wchar;
: SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char))
#define SCM_CODEPOINT_MAX (0x10ffff)
#define SCM_CODEPOINT_SURROGATE_START (0xd800)
#define SCM_CODEPOINT_SURROGATE_END (0xdfff)
#define SCM_IS_UNICODE_CHAR(c) \
((scm_t_wchar) (c) <= 0xd7ff \
|| ((scm_t_wchar) (c) >= 0xe000 && (scm_t_wchar) (c) <= SCM_CODEPOINT_MAX))
(((scm_t_wchar) (c) >= 0 \
&& (scm_t_wchar) (c) < SCM_CODEPOINT_SURROGATE_START) \
|| ((scm_t_wchar) (c) > SCM_CODEPOINT_SURROGATE_END \
&& (scm_t_wchar) (c) <= SCM_CODEPOINT_MAX))