diff options
author | Michael Gran <spk121@yahoo.com> | 2009-08-28 23:44:41 -0700 |
---|---|---|
committer | Michael Gran <spk121@yahoo.com> | 2009-08-29 00:00:58 -0700 |
commit | 526ee76ac36921570708a746e73bba1cd7da2f62 (patch) | |
tree | 04e9eb5af114f51504aa8a608adafd3ed5b54eba | |
parent | 6d736fdba2135de42e742924eac32e1c6bd9b79a (diff) | |
download | guile-526ee76ac36921570708a746e73bba1cd7da2f62.tar.gz |
Better range check for codepoints
* libguile/chars.h (SCM_IS_UNICODE_CHAR): check for negative codepoints
-rw-r--r-- | libguile/chars.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libguile/chars.h b/libguile/chars.h index 85b16739a..69ef8d005 100644 --- a/libguile/chars.h +++ b/libguile/chars.h @@ -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)) |