summaryrefslogtreecommitdiff
path: root/libguile/chars.h
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2009-08-18 21:13:38 -0700
committerMichael Gran <spk121@yahoo.com>2009-08-18 21:13:38 -0700
commit8ef6962953d8377ce2157f4edd5ba469169728ba (patch)
tree737cfacb52db9c4b5d5f59b9be418aecb3cee652 /libguile/chars.h
parent3dd11c9b130f54895efced104043022ea4609879 (diff)
downloadguile-8ef6962953d8377ce2157f4edd5ba469169728ba.tar.gz
Avoid compilation warnings in SCM_MAKE_CHAR
* libguile/chars.h (SCM_MAKE_CHAR): change inequality
Diffstat (limited to 'libguile/chars.h')
-rw-r--r--libguile/chars.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/libguile/chars.h b/libguile/chars.h
index 51adc21e5..f75aeadd1 100644
--- a/libguile/chars.h
+++ b/libguile/chars.h
@@ -32,9 +32,15 @@
#define SCM_CHARP(x) (SCM_ITAG8(x) == scm_tc8_char)
#define SCM_CHAR(x) ((scm_t_wchar)SCM_ITAG8_DATA(x))
-#define SCM_MAKE_CHAR(x) \
- ((scm_t_int32) (x) < 0 \
- ? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (x), scm_tc8_char) \
+/* SCM_MAKE_CHAR maps signed chars (-128 to 127) and unsigned chars (0
+ to 255) to Latin-1 codepoints (0 to 255) while allowing higher
+ codepoints (256 to 1114111) to pass through unchanged.
+
+ This macro evaluates x twice, which may lead to side effects if not
+ used properly. */
+#define SCM_MAKE_CHAR(x) \
+ ((x) <= 1 \
+ ? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (x), scm_tc8_char) \
: SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char))
#define SCM_CODEPOINT_MAX (0x10ffff)