comparison src/intervals.h @ 5414:39f0a30bb163

(NULL_RIGHT_CHILD, NULL_LEFT_CHILD): Assume children must be intervals, never strings or buffers.
author Richard M. Stallman <rms@gnu.org>
date Sun, 02 Jan 1994 19:00:54 +0000
parents c11d710e0403
children 09278b56193e
comparison
equal deleted inserted replaced
5413:8c0dd3e81e28 5414:39f0a30bb163
33 /* Size of a pointer to an interval structure */ 33 /* Size of a pointer to an interval structure */
34 #define INTERVAL_PTR_SIZE (sizeof (struct interval *)) 34 #define INTERVAL_PTR_SIZE (sizeof (struct interval *))
35 35
36 /* True if an interval pointer is null, or is a Lisp_Buffer or 36 /* True if an interval pointer is null, or is a Lisp_Buffer or
37 Lisp_String pointer (meaning it points to the owner of this 37 Lisp_String pointer (meaning it points to the owner of this
38 interval tree.) */ 38 interval tree). */
39 #define NULL_INTERVAL_P(i) ((i) == NULL_INTERVAL || \ 39 #define NULL_INTERVAL_P(i) ((i) == NULL_INTERVAL \
40 XTYPE ((Lisp_Object)(i)) == Lisp_Buffer || \ 40 || XTYPE ((Lisp_Object)(i)) == Lisp_Buffer \
41 XTYPE ((Lisp_Object)(i)) == Lisp_String) 41 || XTYPE ((Lisp_Object)(i)) == Lisp_String)
42 42
43 /* True if this interval has no right child. */ 43 /* True if this interval has no right child. */
44 #define NULL_RIGHT_CHILD(i) (NULL_INTERVAL_P((i)->right)) 44 #define NULL_RIGHT_CHILD(i) ((i)->right == NULL_INTERVAL)
45 45
46 /* True if this interval has no left child. */ 46 /* True if this interval has no left child. */
47 #define NULL_LEFT_CHILD(i) (NULL_INTERVAL_P((i)->left)) 47 #define NULL_LEFT_CHILD(i) ((i)->left == NULL_INTERVAL)
48 48
49 /* True if this interval has no parent. */ 49 /* True if this interval has no parent. */
50 #define NULL_PARENT(i) (NULL_INTERVAL_P((i)->parent)) 50 #define NULL_PARENT(i) (NULL_INTERVAL_P ((i)->parent))
51 51
52 /* True if this interval is the left child of some other interval. */ 52 /* True if this interval is the left child of some other interval. */
53 #define AM_LEFT_CHILD(i) (! NULL_INTERVAL_P ((i)->parent) \ 53 #define AM_LEFT_CHILD(i) (! NULL_INTERVAL_P ((i)->parent) \
54 && (i)->parent->left == (i)) 54 && (i)->parent->left == (i))
55 55
56 /* True if this interval is the right ehild of some other interval. */ 56 /* True if this interval is the right child of some other interval. */
57 #define AM_RIGHT_CHILD(i) (! NULL_INTERVAL_P ((i)->parent) \ 57 #define AM_RIGHT_CHILD(i) (! NULL_INTERVAL_P ((i)->parent) \
58 && (i)->parent->right == (i)) 58 && (i)->parent->right == (i))
59 59
60 /* True if this interval has no children. */ 60 /* True if this interval has no children. */
61 #define LEAF_INTERVAL_P(i) ((i)->left == NULL_INTERVAL \ 61 #define LEAF_INTERVAL_P(i) ((i)->left == NULL_INTERVAL \
63 63
64 /* True if this interval has no parent and is therefore the root. */ 64 /* True if this interval has no parent and is therefore the root. */
65 #define ROOT_INTERVAL_P(i) (NULL_PARENT (i)) 65 #define ROOT_INTERVAL_P(i) (NULL_PARENT (i))
66 66
67 /* True if this interval is the only interval in the interval tree. */ 67 /* True if this interval is the only interval in the interval tree. */
68 #define ONLY_INTERVAL_P(i) (ROOT_INTERVAL_P((i)) && LEAF_INTERVAL_P ((i))) 68 #define ONLY_INTERVAL_P(i) (ROOT_INTERVAL_P ((i)) && LEAF_INTERVAL_P ((i)))
69 69
70 /* True if this interval has both left and right children. */ 70 /* True if this interval has both left and right children. */
71 #define BOTH_KIDS_P(i) ((i)->left != NULL_INTERVAL \ 71 #define BOTH_KIDS_P(i) ((i)->left != NULL_INTERVAL \
72 && (i)->right != NULL_INTERVAL) 72 && (i)->right != NULL_INTERVAL)
73 73
96 /* True if this is a default interval, which is the same as being null 96 /* True if this is a default interval, which is the same as being null
97 or having no properties. */ 97 or having no properties. */
98 #define DEFAULT_INTERVAL_P(i) (NULL_INTERVAL_P (i) || EQ ((i)->plist, Qnil)) 98 #define DEFAULT_INTERVAL_P(i) (NULL_INTERVAL_P (i) || EQ ((i)->plist, Qnil))
99 99
100 /* Reset this interval to its vanilla, or no-property state. */ 100 /* Reset this interval to its vanilla, or no-property state. */
101 #define RESET_INTERVAL(i) { \ 101 #define RESET_INTERVAL(i) \
102 (i)->total_length = (i)->position = 0; \ 102 { \
103 (i)->left = (i)->right = NULL_INTERVAL; \ 103 (i)->total_length = (i)->position = 0; \
104 (i)->parent = NULL_INTERVAL; \ 104 (i)->left = (i)->right = NULL_INTERVAL; \
105 (i)->write_protect = 0; \ 105 (i)->parent = NULL_INTERVAL; \
106 (i)->visible = 0; \ 106 (i)->write_protect = 0; \
107 (i)->front_sticky = (i)->rear_sticky = 0; \ 107 (i)->visible = 0; \
108 (i)->plist = Qnil; \ 108 (i)->front_sticky = (i)->rear_sticky = 0; \
109 } 109 (i)->plist = Qnil; \
110 }
110 111
111 /* Copy the cached property values of interval FROM to interval TO. */ 112 /* Copy the cached property values of interval FROM to interval TO. */
112 #define COPY_INTERVAL_CACHE(from,to) \ 113 #define COPY_INTERVAL_CACHE(from,to) \
113 { \ 114 { \
114 (to)->write_protect = (from)->write_protect; \ 115 (to)->write_protect = (from)->write_protect; \