diff options
author | Jim Blandy <jimb@red-bean.com> | 1999-09-06 13:51:59 +0000 |
---|---|---|
committer | Jim Blandy <jimb@red-bean.com> | 1999-09-06 13:51:59 +0000 |
commit | d1d7638d5d7d34f046678d8af5f56d8f6479f30f (patch) | |
tree | c0d743cce0c48192b16333764abe02268a153266 | |
parent | dff2f651e3c86e43d077897de8f76f05ab9e2c30 (diff) | |
download | guile-d1d7638d5d7d34f046678d8af5f56d8f6479f30f.tar.gz |
* mb.h (scm_mb_get, scm_mb_put, scm_mb_len, scm_mb_boundary_p):
Cast character arguments to unsigned char, so we don't get weird
behavior if the user passes in a signed char.
* mbemacs.h (IS_ASCII_CHAR): Same.
-rw-r--r-- | libguile/mb.h | 14 | ||||
-rw-r--r-- | libguile/mbemacs.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/libguile/mb.h b/libguile/mb.h index 7e208e330..73c9d00b7 100644 --- a/libguile/mb.h +++ b/libguile/mb.h @@ -72,13 +72,13 @@ extern SCM scm_text_not_guile_char; /* Retrieve the character whose encoding is at P. */ #define scm_mb_get(p) \ - (*(p) < 128 ? *(p) : scm_mb_get_func (p)) + ((unsigned char) *(p) < 128 ? *(p) : scm_mb_get_func (p)) extern scm_char_t scm_mb_get_func (const unsigned char *p); /* Store the encoding of the character C at P, and return the encoding's length in bytes. */ #define scm_mb_put(c, p) \ - ((c) < 128 ? (*(p) = c, 1) : scm_mb_put_func ((c), (p))) + ((unsigned char) (c) < 128 ? (*(p) = c, 1) : scm_mb_put_func ((c), (p))) extern int scm_mb_put_func (scm_char_t c, unsigned char *p); /* The length of the longest character encoding, in bytes. */ @@ -86,10 +86,10 @@ extern int scm_mb_put_func (scm_char_t c, unsigned char *p); /* Given an encoding's first byte, return its length. */ #define scm_mb_len(b) \ - ((b) < 0x80 ? 1 \ - : (b) < 0x90 ? 2 \ - : (b) < 0x9C ? 3 \ - : (b) < 0x9E ? 4 \ + ((unsigned char) (b) < 0x80 ? 1 \ + : (unsigned char) (b) < 0x90 ? 2 \ + : (unsigned char) (b) < 0x9C ? 3 \ + : (unsigned char) (b) < 0x9E ? 4 \ : 1) extern int scm_mb_len_func (unsigned char b); @@ -102,7 +102,7 @@ extern int scm_mb_len_char_func (scm_char_t c); /* Finding character encoding boundaries. */ /* Return true if P points at the first byte of an encoding. */ -#define scm_mb_boundary_p(p) (*(p) < 0xA0) +#define scm_mb_boundary_p(p) ((unsigned char) *(p) < 0xA0) /* Round P to the previous/next character boundary. */ extern const unsigned char *scm_mb_floor (const unsigned char *p); diff --git a/libguile/mbemacs.h b/libguile/mbemacs.h index b3f0d6790..22e67a437 100644 --- a/libguile/mbemacs.h +++ b/libguile/mbemacs.h @@ -193,7 +193,7 @@ | ((pos1) << 7) \ | (pos2)) -#define IS_ASCII_CHAR(c) ((c) < 0x80) +#define IS_ASCII_CHAR(c) ((unsigned char) (c) < 0x80) #define FIRST_CHAR1O (BUILD_CHAR1 (0x81, 0x20)) #define LAST_CHAR1O (BUILD_CHAR1 (0x8f, 0x7F)) |