#include "character.h"
#include "multibyte.h"
+#include "casetab.h"
+#include "chartab.h"
+
/************************************************************************/
/* */
/* definition of Lisp buffer object */
int face_change; /* This is set when a change in how the text should
be displayed (e.g., font, color) is made. */
+ /* Whether buffer specific face is specified. */
+ int buffer_local_face_property;
+
/* change data indicating what portion of the text has changed
since the last time this was reset. Used by redisplay.
Logically we should keep this with the text structure, but
DATA, (ptr, len), // input data is a fixed buffer of size len
ALLOCA, (ptr, len), // output data is in a alloca()ed buffer of size len
MALLOC, (ptr, len), // output data is in a malloc()ed buffer of size len
- C_STRING_ALLOCA, ptr, // equivalent to ALLOCA (ptr, len_ignored) on output.
- C_STRING_MALLOC, ptr, // equivalent to MALLOC (ptr, len_ignored) on output.
+ C_STRING_ALLOCA, ptr, // equivalent to ALLOCA (ptr, len_ignored) on output
+ C_STRING_MALLOC, ptr, // equivalent to MALLOC (ptr, len_ignored) on output
C_STRING, ptr, // equivalent to DATA, (ptr, strlen (ptr) + 1) on input
LISP_STRING, string, // input or output is a Lisp_Object of type string
LISP_BUFFER, buffer, // output is written to (point) in lisp buffer
already guaranteed that the character values are all in the range
0 - 255. Bad lossage will happen otherwise. */
-# define MAKE_TRT_TABLE() Fmake_string (make_int (256), make_char (0))
-# define TRT_TABLE_AS_STRING(table) XSTRING_DATA (table)
-# define TRT_TABLE_CHAR_1(table, ch) \
- string_char (XSTRING (table), (Charcount) ch)
-# define SET_TRT_TABLE_CHAR_1(table, ch1, ch2) \
- set_string_char (XSTRING (table), (Charcount) ch1, ch2)
-
-#ifdef MULE
-# define MAKE_MIRROR_TRT_TABLE() make_opaque (OPAQUE_CLEAR, 256)
-# define MIRROR_TRT_TABLE_AS_STRING(table) ((Bufbyte *) XOPAQUE_DATA (table))
-# define MIRROR_TRT_TABLE_CHAR_1(table, ch) \
- ((Emchar) (MIRROR_TRT_TABLE_AS_STRING (table)[ch]))
-# define SET_MIRROR_TRT_TABLE_CHAR_1(table, ch1, ch2) \
- (MIRROR_TRT_TABLE_AS_STRING (table)[ch1] = (Bufbyte) (ch2))
-#endif
-
-# define IN_TRT_TABLE_DOMAIN(c) (((EMACS_UINT) (c)) <= 255)
-
-#ifdef MULE
-#define MIRROR_DOWNCASE_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_downcase_table)
-#define MIRROR_UPCASE_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_upcase_table)
-#define MIRROR_CANON_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_case_canon_table)
-#define MIRROR_EQV_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_case_eqv_table)
-#else
-#define MIRROR_DOWNCASE_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->downcase_table)
-#define MIRROR_UPCASE_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->upcase_table)
-#define MIRROR_CANON_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->case_canon_table)
-#define MIRROR_EQV_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->case_eqv_table)
-#endif
+#define MAKE_TRT_TABLE() Fmake_char_table (Qgeneric)
+INLINE_HEADER Emchar TRT_TABLE_CHAR_1 (Lisp_Object table, Emchar c);
+INLINE_HEADER Emchar
+TRT_TABLE_CHAR_1 (Lisp_Object table, Emchar ch)
+{
+ Lisp_Object TRT_char;
+ TRT_char = get_char_table (ch, XCHAR_TABLE (table));
+ if (NILP (TRT_char))
+ return ch;
+ else
+ return XCHAR (TRT_char);
+}
+#define SET_TRT_TABLE_CHAR_1(table, ch1, ch2) \
+ Fput_char_table (make_char (ch1), make_char (ch2), table);
INLINE_HEADER Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c);
INLINE_HEADER Emchar
TRT_TABLE_OF (Lisp_Object trt, Emchar c)
{
- return IN_TRT_TABLE_DOMAIN (c) ? TRT_TABLE_CHAR_1 (trt, c) : c;
+ return TRT_TABLE_CHAR_1 (trt, c);
}
/* Macros used below. */
-#define DOWNCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->downcase_table, c)
-#define UPCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->upcase_table, c)
+#define DOWNCASE_TABLE_OF(buf, c) \
+ TRT_TABLE_OF (XCASE_TABLE_DOWNCASE (buf->case_table), c)
+#define UPCASE_TABLE_OF(buf, c) \
+ TRT_TABLE_OF (XCASE_TABLE_UPCASE (buf->case_table), c)
/* 1 if CH is upper case. */
#define DOWNCASE(buf, ch) DOWNCASE_TABLE_OF (buf, ch)
+/************************************************************************/
+/* Lisp string representation convenience functions */
+/************************************************************************/
+/* Because the representation of internally formatted data is subject to change,
+ It's bad style to do something like strcmp (XSTRING_DATA (s), "foo")
+ Instead, use the portable: bufbyte_strcmp (XSTRING_DATA (s), "foo")
+ or bufbyte_memcmp (XSTRING_DATA (s), "foo", 3) */
+
+/* Like strcmp, except first arg points at internally formatted data,
+ while the second points at a string of only ASCII chars. */
+INLINE_HEADER int
+bufbyte_strcmp (const Bufbyte *bp, const char *ascii_string);
+INLINE_HEADER int
+bufbyte_strcmp (const Bufbyte *bp, const char *ascii_string)
+{
+#ifdef MULE
+ while (1)
+ {
+ int diff;
+ type_checking_assert (BYTE_ASCII_P (*ascii_string));
+ if ((diff = charptr_emchar (bp) - *(Bufbyte *) ascii_string) != 0)
+ return diff;
+ if (*ascii_string == '\0')
+ return 0;
+ ascii_string++;
+ INC_CHARPTR (bp);
+ }
+#else
+ return strcmp ((char *)bp, ascii_string);
+#endif
+}
+
+
+/* Like memcmp, except first arg points at internally formatted data,
+ while the second points at a string of only ASCII chars. */
+INLINE_HEADER int
+bufbyte_memcmp (const Bufbyte *bp, const char *ascii_string, size_t len);
+INLINE_HEADER int
+bufbyte_memcmp (const Bufbyte *bp, const char *ascii_string, size_t len)
+{
+#ifdef MULE
+ while (len--)
+ {
+ int diff = charptr_emchar (bp) - *(Bufbyte *) ascii_string;
+ type_checking_assert (BYTE_ASCII_P (*ascii_string));
+ if (diff != 0)
+ return diff;
+ ascii_string++;
+ INC_CHARPTR (bp);
+ }
+ return 0;
+#else
+ return memcmp (bp, ascii_string, len);
+#endif
+}
+
#endif /* INCLUDED_buffer_h_ */