X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmule-charset.h;h=46cd3a08dd85c5181d449d82316933699fe1e17a;hb=caf1416adb403b6334ce635e58b269b6c653aa39;hp=f098fff605776f27d403c95f8516260d905787e5;hpb=98a6e4055a1fa624c592ac06f79287d55196ca37;p=chise%2Fxemacs-chise.git- diff --git a/src/mule-charset.h b/src/mule-charset.h index f098fff..46cd3a0 100644 --- a/src/mule-charset.h +++ b/src/mule-charset.h @@ -401,19 +401,19 @@ enum LEADING_BYTE_OFFICIAL_2 /* Is this a prefix for a private leading byte? */ -INLINE_HEADER int LEADING_BYTE_PREFIX_P (unsigned char lb); +INLINE_HEADER int LEADING_BYTE_PREFIX_P (Bufbyte lb); INLINE_HEADER int -LEADING_BYTE_PREFIX_P (unsigned char lb) +LEADING_BYTE_PREFIX_P (Bufbyte lb) { return (lb == PRE_LEADING_BYTE_PRIVATE_1 || lb == PRE_LEADING_BYTE_PRIVATE_2); } /* Given a private leading byte, return the leading byte prefix stored - in a string */ + in a string. */ #define PRIVATE_LEADING_BYTE_PREFIX(lb) \ - ((lb) < MIN_LEADING_BYTE_PRIVATE_2 ? \ + ((unsigned int) (lb) < MIN_LEADING_BYTE_PRIVATE_2 ? \ PRE_LEADING_BYTE_PRIVATE_1 : \ PRE_LEADING_BYTE_PRIVATE_2) @@ -423,13 +423,12 @@ LEADING_BYTE_PREFIX_P (unsigned char lb) /* of any format */ /************************************************************************/ -/* Argument `c' should be (unsigned int) or (unsigned char). */ -/* Note that SP and DEL are not included. */ +/* These are carefully designed to work if BYTE is signed or unsigned. */ +/* Note that SPC and DEL are considered ASCII, not control. */ -#define BYTE_ASCII_P(c) ((c) < 0x80) -#define BYTE_C0_P(c) ((c) < 0x20) -/* Do some forced casting just to make *sure* things are gotten right. */ -#define BYTE_C1_P(c) ((unsigned int) ((unsigned int) (c) - 0x80) < 0x20) +#define BYTE_ASCII_P(byte) (((byte) & ~0x7f) == 0) +#define BYTE_C0_P(byte) (((byte) & ~0x1f) == 0) +#define BYTE_C1_P(byte) (((byte) & ~0x1f) == 0x80) /************************************************************************/ @@ -437,13 +436,13 @@ LEADING_BYTE_PREFIX_P (unsigned char lb) /* in a Mule-formatted string */ /************************************************************************/ -/* Does this byte represent the first byte of a character? */ +/* Does BYTE represent the first byte of a character? */ -#define BUFBYTE_FIRST_BYTE_P(c) ((c) < 0xA0) +#define BUFBYTE_FIRST_BYTE_P(byte) ((byte) < 0xA0) -/* Does this byte represent the first byte of a multi-byte character? */ +/* Does BYTE represent the first byte of a multi-byte character? */ -#define BUFBYTE_LEADING_BYTE_P(c) BYTE_C1_P (c) +#define BUFBYTE_LEADING_BYTE_P(byte) BYTE_C1_P (byte) /************************************************************************/ @@ -561,29 +560,33 @@ struct charset_lookup { Bufbyte next_allocated_2_byte_leading_byte; }; -extern struct charset_lookup *chlook; - -#ifdef ERROR_CHECK_TYPECHECK -/* int not Bufbyte even though that is the actual type of a leading byte. - This way, out-of-range values will get caught rather than automatically - truncated. */ -INLINE_HEADER Lisp_Object CHARSET_BY_LEADING_BYTE (int lb); +INLINE_HEADER Lisp_Object CHARSET_BY_LEADING_BYTE (Bufbyte lb); INLINE_HEADER Lisp_Object -CHARSET_BY_LEADING_BYTE (int lb) +CHARSET_BY_LEADING_BYTE (Bufbyte lb) { - assert (lb >= 0x80 && lb <= 0xFF); - return chlook->charset_by_leading_byte[lb - 128]; -} - -#else - -#define CHARSET_BY_LEADING_BYTE(lb) (chlook->charset_by_leading_byte[(lb) - 128]) + extern struct charset_lookup *chlook; +#ifdef ERROR_CHECK_TYPECHECK + /* When error-checking is on, x86 GCC 2.95.2 -O3 miscompiles the + following unless we introduce `tem'. */ + int tem = lb; + type_checking_assert (tem >= 0x80 && tem <= 0xFF); #endif + return chlook->charset_by_leading_byte[lb - 128]; +} -#define CHARSET_BY_ATTRIBUTES(type, final, dir) \ - (chlook->charset_by_attributes[type][final][dir]) +INLINE_HEADER Lisp_Object +CHARSET_BY_ATTRIBUTES (unsigned int type, unsigned char final, int dir); +INLINE_HEADER Lisp_Object +CHARSET_BY_ATTRIBUTES (unsigned int type, unsigned char final, int dir) +{ + extern struct charset_lookup *chlook; + type_checking_assert (type < countof (chlook->charset_by_attributes) && + final < countof (chlook->charset_by_attributes[0]) && + dir < countof (chlook->charset_by_attributes[0][0])); + return chlook->charset_by_attributes[type][final][dir]; +} /* Table of number of bytes in the string representation of a character indexed by the first byte of that representation. @@ -594,13 +597,11 @@ CHARSET_BY_LEADING_BYTE (int lb) extern const Bytecount rep_bytes_by_first_byte[0xA0]; /* Number of bytes in the string representation of a character. */ -INLINE_HEADER int REP_BYTES_BY_FIRST_BYTE (int fb); +INLINE_HEADER int REP_BYTES_BY_FIRST_BYTE (Bufbyte fb); INLINE_HEADER int -REP_BYTES_BY_FIRST_BYTE (int fb) +REP_BYTES_BY_FIRST_BYTE (Bufbyte fb) { -#ifdef ERROR_CHECK_TYPECHECK - assert (0 <= fb && fb < 0xA0); -#endif + type_checking_assert (fb < 0xA0); return rep_bytes_by_first_byte[fb]; }