diff options
| author | Paul Eggert | 2013-08-03 14:09:57 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-08-03 14:09:57 -0700 |
| commit | 98f638d640c0bb4cbda7a3134611b03b6ee08d44 (patch) | |
| tree | 7fd18ad6b0446afcf7211e50eec3bc954a8f3454 | |
| parent | 416a3e013f845dc93385cfdf8b95e1f42bab5462 (diff) | |
| download | emacs-98f638d640c0bb4cbda7a3134611b03b6ee08d44.tar.gz emacs-98f638d640c0bb4cbda7a3134611b03b6ee08d44.zip | |
* composite.h: Minor fixups.
(composition_registered_p): Rename from COMPOSITION_REGISTERD_P
to fix a misspelling, and change it to an inline function while
we're at it (it need not be a macro). All uses changed.
(composition_method, composition_valid_p):
Rewrite to avoid assignments in if-conditions.
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/composite.c | 2 | ||||
| -rw-r--r-- | src/composite.h | 61 |
3 files changed, 42 insertions, 30 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8f275f0fe89..69e00cadbe9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-08-03 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * composite.h: Minor fixups. | ||
| 4 | (composition_registered_p): Rename from COMPOSITION_REGISTERD_P | ||
| 5 | to fix a misspelling, and change it to an inline function while | ||
| 6 | we're at it (it need not be a macro). All uses changed. | ||
| 7 | (composition_method, composition_valid_p): | ||
| 8 | Rewrite to avoid assignments in if-conditions. | ||
| 9 | |||
| 1 | 2013-08-03 Dmitry Antipov <dmantipov@yandex.ru> | 10 | 2013-08-03 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 11 | ||
| 3 | Do not use global Lisp_Object in composition macros. | 12 | Do not use global Lisp_Object in composition macros. |
diff --git a/src/composite.c b/src/composite.c index 91a5c75630a..28942fe4f74 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -1873,7 +1873,7 @@ See `find-composition' for more details. */) | |||
| 1873 | if (NILP (detail_p)) | 1873 | if (NILP (detail_p)) |
| 1874 | return list3 (make_number (start), make_number (end), Qt); | 1874 | return list3 (make_number (start), make_number (end), Qt); |
| 1875 | 1875 | ||
| 1876 | if (COMPOSITION_REGISTERD_P (prop)) | 1876 | if (composition_registered_p (prop)) |
| 1877 | id = COMPOSITION_ID (prop); | 1877 | id = COMPOSITION_ID (prop); |
| 1878 | else | 1878 | else |
| 1879 | { | 1879 | { |
diff --git a/src/composite.h b/src/composite.h index fbb5add7c55..53665b36bd1 100644 --- a/src/composite.h +++ b/src/composite.h | |||
| @@ -49,34 +49,38 @@ enum composition_method { | |||
| 49 | /* Maximum number of components a single composition can have. */ | 49 | /* Maximum number of components a single composition can have. */ |
| 50 | #define MAX_COMPOSITION_COMPONENTS 16 | 50 | #define MAX_COMPOSITION_COMPONENTS 16 |
| 51 | 51 | ||
| 52 | /* These macros access information about a composition that | 52 | /* These operations access information about a composition that |
| 53 | has `composition' property PROP. PROP is: | 53 | has `composition' property PROP. PROP is: |
| 54 | ((LENGTH . COMPONENTS) . MODIFICATION-FUNC) | 54 | ((LENGTH . COMPONENTS) . MODIFICATION-FUNC) |
| 55 | or | 55 | or |
| 56 | (COMPOSITION-ID . (LENGTH COMPONENTS . MODIFICATION-FUNC)) | 56 | (COMPOSITION-ID . (LENGTH COMPONENTS . MODIFICATION-FUNC)) |
| 57 | They don't check validity of PROP. */ | 57 | They don't check validity of PROP. */ |
| 58 | 58 | ||
| 59 | /* Return 1 if the composition is already registered. */ | 59 | /* Return true if PROP is already registered. */ |
| 60 | #define COMPOSITION_REGISTERD_P(prop) INTEGERP (XCAR (prop)) | 60 | COMPOSITE_INLINE bool |
| 61 | composition_registered_p (Lisp_Object prop) | ||
| 62 | { | ||
| 63 | return INTEGERP (XCAR (prop)); | ||
| 64 | } | ||
| 61 | 65 | ||
| 62 | /* Return ID number of the already registered composition. */ | 66 | /* Return ID number of the already registered composition. */ |
| 63 | #define COMPOSITION_ID(prop) XINT (XCAR (prop)) | 67 | #define COMPOSITION_ID(prop) XINT (XCAR (prop)) |
| 64 | 68 | ||
| 65 | /* Return length of the composition. */ | 69 | /* Return length of the composition. */ |
| 66 | #define COMPOSITION_LENGTH(prop) \ | 70 | #define COMPOSITION_LENGTH(prop) \ |
| 67 | (COMPOSITION_REGISTERD_P (prop) \ | 71 | (composition_registered_p (prop) \ |
| 68 | ? XINT (XCAR (XCDR (prop))) \ | 72 | ? XINT (XCAR (XCDR (prop))) \ |
| 69 | : XINT (XCAR (XCAR (prop)))) | 73 | : XINT (XCAR (XCAR (prop)))) |
| 70 | 74 | ||
| 71 | /* Return components of the composition. */ | 75 | /* Return components of the composition. */ |
| 72 | #define COMPOSITION_COMPONENTS(prop) \ | 76 | #define COMPOSITION_COMPONENTS(prop) \ |
| 73 | (COMPOSITION_REGISTERD_P (prop) \ | 77 | (composition_registered_p (prop) \ |
| 74 | ? XCAR (XCDR (XCDR (prop))) \ | 78 | ? XCAR (XCDR (XCDR (prop))) \ |
| 75 | : XCDR (XCAR (prop))) | 79 | : XCDR (XCAR (prop))) |
| 76 | 80 | ||
| 77 | /* Return modification function of the composition. */ | 81 | /* Return modification function of the composition. */ |
| 78 | #define COMPOSITION_MODIFICATION_FUNC(prop) \ | 82 | #define COMPOSITION_MODIFICATION_FUNC(prop) \ |
| 79 | (COMPOSITION_REGISTERD_P (prop) \ | 83 | (composition_registered_p (prop) \ |
| 80 | ? XCDR (XCDR (XCDR (prop))) \ | 84 | ? XCDR (XCDR (XCDR (prop))) \ |
| 81 | : CONSP (prop) ? XCDR (prop) : Qnil) | 85 | : CONSP (prop) ? XCDR (prop) : Qnil) |
| 82 | 86 | ||
| @@ -199,43 +203,42 @@ extern void syms_of_composite (void); | |||
| 199 | extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object, | 203 | extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object, |
| 200 | Lisp_Object); | 204 | Lisp_Object); |
| 201 | 205 | ||
| 202 | /* Return the method of composition. */ | 206 | /* Return the method of a composition with property PROP. */ |
| 207 | |||
| 203 | COMPOSITE_INLINE enum composition_method | 208 | COMPOSITE_INLINE enum composition_method |
| 204 | composition_method (Lisp_Object prop) | 209 | composition_method (Lisp_Object prop) |
| 205 | { | 210 | { |
| 206 | Lisp_Object temp; | 211 | if (composition_registered_p (prop)) |
| 207 | 212 | return composition_table[COMPOSITION_ID (prop)]->method; | |
| 208 | return (COMPOSITION_REGISTERD_P (prop) | 213 | else |
| 209 | ? composition_table[COMPOSITION_ID (prop)]->method | 214 | { |
| 210 | : (temp = XCDR (XCAR (prop)), | 215 | Lisp_Object temp = XCDR (XCAR (prop)); |
| 211 | (NILP (temp) | 216 | return (NILP (temp) |
| 212 | ? COMPOSITION_RELATIVE | 217 | ? COMPOSITION_RELATIVE |
| 213 | : (INTEGERP (temp) || STRINGP (temp)) | 218 | : INTEGERP (temp) || STRINGP (temp) |
| 214 | ? COMPOSITION_WITH_ALTCHARS | 219 | ? COMPOSITION_WITH_ALTCHARS |
| 215 | : COMPOSITION_WITH_RULE_ALTCHARS))); | 220 | : COMPOSITION_WITH_RULE_ALTCHARS); |
| 221 | } | ||
| 216 | } | 222 | } |
| 217 | 223 | ||
| 218 | /* Return 1 if the composition is valid. It is valid if | 224 | /* Given offsets START and END, return true if PROP is a valid composition |
| 219 | length of the composition equals to (END - START). */ | 225 | property with length END - START. */ |
| 226 | |||
| 220 | COMPOSITE_INLINE bool | 227 | COMPOSITE_INLINE bool |
| 221 | composition_valid_p (ptrdiff_t start, ptrdiff_t end, Lisp_Object prop) | 228 | composition_valid_p (ptrdiff_t start, ptrdiff_t end, Lisp_Object prop) |
| 222 | { | 229 | { |
| 223 | Lisp_Object temp; | ||
| 224 | |||
| 225 | return (CONSP (prop) | 230 | return (CONSP (prop) |
| 226 | && (COMPOSITION_REGISTERD_P (prop) | 231 | && (composition_registered_p (prop) |
| 227 | ? (COMPOSITION_ID (prop) >= 0 | 232 | ? (COMPOSITION_ID (prop) >= 0 |
| 228 | && COMPOSITION_ID (prop) <= n_compositions | 233 | && COMPOSITION_ID (prop) <= n_compositions |
| 229 | && CONSP (XCDR (prop))) | 234 | && CONSP (XCDR (prop))) |
| 230 | : (temp = XCAR (prop), | 235 | : (CONSP (XCAR (prop)) |
| 231 | (CONSP (temp) | 236 | && (NILP (XCDR (XCAR (prop))) |
| 232 | && (temp = XCDR (temp), | 237 | || STRINGP (XCDR (XCAR (prop))) |
| 233 | (NILP (temp) | 238 | || VECTORP (XCDR (XCAR (prop))) |
| 234 | || STRINGP (temp) | 239 | || INTEGERP (XCDR (XCAR (prop))) |
| 235 | || VECTORP (temp) | 240 | || CONSP (XCDR (XCAR (prop)))))) |
| 236 | || INTEGERP (temp) | 241 | && COMPOSITION_LENGTH (prop) == end - start); |
| 237 | || CONSP (temp)))))) | ||
| 238 | && (end - start) == COMPOSITION_LENGTH (prop)); | ||
| 239 | } | 242 | } |
| 240 | 243 | ||
| 241 | /* Macros for lispy glyph-string. This is completely different from | 244 | /* Macros for lispy glyph-string. This is completely different from |