comparison src/text.h @ 3063:d30cd499e445

[xemacs-hg @ 2005-11-13 10:48:01 by ben] further error-checking, etc. alloc.c, lrecord.h: Move around the handling of setting of lheader->uid so it's in set_lheader_implementation() -- that way, even non-MC-ALLOC builds get useful uid's in their bare lrecords. Redo related code for strings so the non-ascii count that is stored in the uid isn't hosed. events.c: Save and restore the uid around event zeroing/deadbeefing. lisp.h: Set the correct value of MAX_STRING_ASCII_BEGIN under MC_ALLOC. lisp.h: rearrange the basic code handling ints and chars. basic int stuff goes first, followed by basic char stuff, followed in turn by stuff that mixes ints and chars. this is required since some basic defn's have become inline functions. XCHAR and CHARP have additional error-checking in that they check to make sure that the value in question is not just a character but a valid character (i.e. its numeric value is valid). print.c: debug_p4 now has a useful UID in all cases and uses it; but it also prints the raw header address (previously, you just got one of them). text.h: some basic char defn's that belonged in lisp.h have been moved there. valid_ichar_p() is moved too since the inline functions need it.
author ben
date Sun, 13 Nov 2005 10:48:04 +0000
parents 902d5bd9b75c
children 1ce0622a56a3
comparison
equal deleted inserted replaced
3062:21d92abaac3a 3063:d30cd499e445
1 /* Header file for text manipulation primitives and macros. 1 /* Header file for text manipulation primitives and macros.
2 Copyright (C) 1985-1995 Free Software Foundation, Inc. 2 Copyright (C) 1985-1995 Free Software Foundation, Inc.
3 Copyright (C) 1995 Sun Microsystems, Inc. 3 Copyright (C) 1995 Sun Microsystems, Inc.
4 Copyright (C) 2000, 2001, 2002, 2003, 2004 Ben Wing. 4 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
1003 Ichar. 1003 Ichar.
1004 */ 1004 */
1005 1005
1006 #define itext_ichar_n(ptr, offset) \ 1006 #define itext_ichar_n(ptr, offset) \
1007 itext_ichar (itext_n_addr (ptr, offset)) 1007 itext_ichar (itext_n_addr (ptr, offset))
1008
1009
1010 /* ---------------------------- */
1011 /* Working with Ichars */
1012 /* ---------------------------- */
1013
1014 /* NOTE: There are other functions/macros for working with Ichars in
1015 charset.h, for retrieving the charset of an Ichar, the length of an
1016 Ichar when converted to text, etc.
1017 */
1018
1019 #ifdef MULE
1020
1021 MODULE_API int non_ascii_valid_ichar_p (Ichar ch);
1022
1023 /* Return whether the given Ichar is valid.
1024 */
1025
1026 DECLARE_INLINE_HEADER (
1027 int
1028 valid_ichar_p (Ichar ch)
1029 )
1030 {
1031 return (! (ch & ~0xFF)) || non_ascii_valid_ichar_p (ch);
1032 }
1033
1034 #else /* not MULE */
1035
1036 #define valid_ichar_p(ch) (! (ch & ~0xFF))
1037
1038 #endif /* not MULE */
1039
1040 DECLARE_INLINE_HEADER (
1041 Lisp_Object
1042 make_char (Ichar val)
1043 )
1044 {
1045 type_checking_assert (valid_ichar_p (val));
1046 return make_char_1 (val);
1047 }
1048
1049 #define CHAR_INTP(x) (INTP (x) && valid_ichar_p (XINT (x)))
1050
1051 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
1052
1053 DECLARE_INLINE_HEADER (
1054 Ichar
1055 XCHAR_OR_CHAR_INT (Lisp_Object obj)
1056 )
1057 {
1058 return CHARP (obj) ? XCHAR (obj) : XINT (obj);
1059 }
1060
1061 /* Signal an error if CH is not a valid character or integer Lisp_Object.
1062 If CH is an integer Lisp_Object, convert it to a character Lisp_Object,
1063 but merely by repackaging, without performing tests for char validity.
1064 */
1065
1066 #define CHECK_CHAR_COERCE_INT(x) do { \
1067 if (CHARP (x)) \
1068 ; \
1069 else if (CHAR_INTP (x)) \
1070 x = make_char (XINT (x)); \
1071 else \
1072 x = wrong_type_argument (Qcharacterp, x); \
1073 } while (0)
1074
1075 1008
1076 1009
1077 /************************************************************************/ 1010 /************************************************************************/
1078 /* */ 1011 /* */
1079 /* working with Lisp strings */ 1012 /* working with Lisp strings */