/* Header for multilingual character handler.
Ver.1.0
-
Copyright (C) 1995 Free Software Foundation, Inc.
Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
#ifndef _CHARSET_H
#define _CHARSET_H
#define MIN_CHARSET_PRIVATE_DIMENSION1 LEADING_CODE_EXT_11
#define MIN_CHARSET_PRIVATE_DIMENSION2 LEADING_CODE_EXT_21
+/* Maximum value of overall charset identification number. */
+#define MAX_CHARSET 0xFE
+
/* Definition of special charsets. */
#define CHARSET_ASCII 0
#define CHARSET_COMPOSITION 0x80
We provide these macros for efficiency. No range check of CHARSET. */
/* Return entry of CHARSET (lisp integer) in Vcharset_table. */
-#define CHARSET_TABLE_ENTRY(charset) \
- XCHAR_TABLE (Vcharset_table)->contents[charset]
+#define CHARSET_TABLE_ENTRY(charset) \
+ XCHAR_TABLE (Vcharset_table)->contents[((charset) == CHARSET_ASCII \
+ ? 0 : (charset) + 128)]
/* Return information INFO-IDX of CHARSET. */
#define CHARSET_TABLE_INFO(charset, info_idx) \
#define CHARSET_VALID_P(charset) \
((charset) == 0 \
|| ((charset) >= 0x80 && (charset) <= MAX_CHARSET_OFFICIAL_DIMENSION2) \
- || ((charset) >= MIN_CHARSET_PRIVATE_DIMENSION1 && (charset) < MAX_CHARSET))
+ || ((charset) >= MIN_CHARSET_PRIVATE_DIMENSION1 && (charset) <= MAX_CHARSET))
/* 1 if CHARSET is already defined, else 0. */
#define CHARSET_DEFINED_P(charset) \
- (((charset) >= 0) && ((charset) < MAX_CHARSET) \
+ (((charset) >= 0) && ((charset) <= MAX_CHARSET) \
&& !NILP (CHARSET_TABLE_ENTRY (charset)))
/* Since the information CHARSET-BYTES and CHARSET-WIDTH of
/* The charset of non-ASCII character C is set to CHARSET, and the
position-codes of C are set to C1 and C2. C2 of DIMENSION1 character
- is 0. */
+ is -1. */
#define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2) \
((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \
? (charset = CHAR_FIELD2 (c) + 0x70, \
c1 = CHAR_FIELD3 (c), \
- c2 = 0) \
+ c2 = -1) \
: (charset = ((c) < MIN_CHAR_COMPOSITION \
? (CHAR_FIELD1 (c) \
+ ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
/* The charset of character C is set to CHARSET, and the
position-codes of C are set to C1 and C2. C2 of DIMENSION1 character
- is 0. */
+ is -1. */
#define SPLIT_CHAR(c, charset, c1, c2) \
(SINGLE_BYTE_CHAR_P (c) \
- ? charset = CHARSET_ASCII, c1 = (c), c2 = 0 \
+ ? charset = CHARSET_ASCII, c1 = (c), c2 = -1 \
: SPLIT_NON_ASCII_CHAR (c, charset, c1, c2))
/* The charset of the character at STR is set to CHARSET, and the
- position-codes are set to C1 and C2. C2 of DIMENSION1 character is 0.
+ position-codes are set to C1 and C2. C2 of DIMENSION1 character is -1.
If the character is a composite character, the upper 7-bit and
lower 7-bit of CMPCHAR-ID are set in C1 and C2 respectively. No
range checking. */
? c1 = *(str), charset = CHARSET_ASCII \
: charset)
-#define MAX_CHARSET 0xFF
-
/* Mapping table from ISO2022's charset (specified by DIMENSION,
CHARS, and FINAL_CHAR) to Emacs' charset. Should be accessed by
macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR). */
character boundary. This macro relies on the fact that *GPT_ADDR
and *Z_ADDR are always accessible and the values are '\0'. No
range checking of POS. */
-#define INC_POS(pos) \
- do { \
- unsigned char *p = POS_ADDR (pos) + 1; \
- pos++; \
- while (!CHAR_HEAD_P (p)) p++, pos++; \
+#define INC_POS(pos) \
+ do { \
+ unsigned char *p = POS_ADDR (pos); \
+ pos++; \
+ if (*p++ >= 0x80) \
+ while (!CHAR_HEAD_P (p)) p++, pos++; \
} while (0)
/* Decrease the buffer point POS of the current buffer to the previous
#define DEC_POS(pos) \
do { \
unsigned char *p, *p_min; \
- if (--pos < GPT) \
+ int pos_saved = --pos; \
+ if (pos < GPT) \
p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \
else \
p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \
while (p > p_min && !CHAR_HEAD_P (p)) p--, pos--; \
+ if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \
} while (0)
#endif /* emacs */
/* This is the maximum length of multi-byte form. */
#define MAX_LENGTH_OF_MULTI_BYTE_FORM (MAX_COMPONENT_COUNT * 6)
-#endif /* _CHARSET_H */
+/* Maximum character code currently used. */
+#define MAX_CHAR (MIN_CHAR_COMPOSITION + n_cmpchars)
+#endif /* _CHARSET_H */