diff options
| author | Dmitry Antipov | 2013-08-03 22:16:43 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-03 22:16:43 +0400 |
| commit | 75c59fb3ec3188d4c7c20675b7beaa07cb0c1891 (patch) | |
| tree | dace6552f5541628f3ffd52031bf143889fadc2b /src | |
| parent | 5e471f0dbc0f9b42646a3689552723902b990f76 (diff) | |
| download | emacs-75c59fb3ec3188d4c7c20675b7beaa07cb0c1891.tar.gz emacs-75c59fb3ec3188d4c7c20675b7beaa07cb0c1891.zip | |
Do not use global Lisp_Object in composition macros.
* composite.h (composition_temp): Remove declaration.
(COMPOSITION_METHOD, COMPOSITION_VALID_P): Replace with...
(composition_method, composition_valid_p): ...inline functions.
* composite.c (composition_temp): Remove.
(run_composition_function, update_compositions)
(composition_compute_stop_pos, composition_adjust_point)
(Ffind_composition_internal):
* coding.c (handle_composition_annotation):
* xdisp.c (handle_composition_prop, check_point_in_composition):
Related users changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/coding.c | 2 | ||||
| -rw-r--r-- | src/composite.c | 26 | ||||
| -rw-r--r-- | src/composite.h | 71 | ||||
| -rw-r--r-- | src/xdisp.c | 6 |
5 files changed, 68 insertions, 51 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a1685b85d9b..5d1e8c10320 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,19 @@ | |||
| 1 | 2013-08-03 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2013-08-03 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Do not use global Lisp_Object in composition macros. | ||
| 4 | * composite.h (composition_temp): Remove declaration. | ||
| 5 | (COMPOSITION_METHOD, COMPOSITION_VALID_P): Replace with... | ||
| 6 | (composition_method, composition_valid_p): ...inline functions. | ||
| 7 | * composite.c (composition_temp): Remove. | ||
| 8 | (run_composition_function, update_compositions) | ||
| 9 | (composition_compute_stop_pos, composition_adjust_point) | ||
| 10 | (Ffind_composition_internal): | ||
| 11 | * coding.c (handle_composition_annotation): | ||
| 12 | * xdisp.c (handle_composition_prop, check_point_in_composition): | ||
| 13 | Related users changed. | ||
| 14 | |||
| 15 | 2013-08-03 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 16 | |||
| 3 | Drop FRAME_PTR typedef. | 17 | Drop FRAME_PTR typedef. |
| 4 | * composite.c, font.c, font.h, fontset.c, fontset.h, frame.c, frame.h: | 18 | * composite.c, font.c, font.h, fontset.c, fontset.h, frame.c, frame.h: |
| 5 | * ftfont.c, ftxfont.c, gtkutil.c, gtkutil.h, image.c, keyboard.c: | 19 | * ftfont.c, ftxfont.c, gtkutil.c, gtkutil.h, image.c, keyboard.c: |
diff --git a/src/coding.c b/src/coding.c index 0cdd8f9cd9e..5b637627763 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -7497,7 +7497,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit, | |||
| 7497 | /* We found a composition. Store the corresponding | 7497 | /* We found a composition. Store the corresponding |
| 7498 | annotation data in BUF. */ | 7498 | annotation data in BUF. */ |
| 7499 | int *head = buf; | 7499 | int *head = buf; |
| 7500 | enum composition_method method = COMPOSITION_METHOD (prop); | 7500 | enum composition_method method = composition_method (prop); |
| 7501 | int nchars = COMPOSITION_LENGTH (prop); | 7501 | int nchars = COMPOSITION_LENGTH (prop); |
| 7502 | 7502 | ||
| 7503 | ADD_COMPOSITION_DATA (buf, nchars, 0, method); | 7503 | ADD_COMPOSITION_DATA (buf, nchars, 0, method); |
diff --git a/src/composite.c b/src/composite.c index 5dbddba78bb..91a5c75630a 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -160,10 +160,6 @@ static Lisp_Object Qauto_composition_function; | |||
| 160 | auto-compositions. */ | 160 | auto-compositions. */ |
| 161 | #define MAX_AUTO_COMPOSITION_LOOKBACK 3 | 161 | #define MAX_AUTO_COMPOSITION_LOOKBACK 3 |
| 162 | 162 | ||
| 163 | /* Temporary variable used in macros COMPOSITION_XXX. */ | ||
| 164 | Lisp_Object composition_temp; | ||
| 165 | |||
| 166 | |||
| 167 | /* Return COMPOSITION-ID of a composition at buffer position | 163 | /* Return COMPOSITION-ID of a composition at buffer position |
| 168 | CHARPOS/BYTEPOS and length NCHARS. The `composition' property of | 164 | CHARPOS/BYTEPOS and length NCHARS. The `composition' property of |
| 169 | the sequence is PROP. STRING, if non-nil, is a string that | 165 | the sequence is PROP. STRING, if non-nil, is a string that |
| @@ -478,11 +474,11 @@ run_composition_function (ptrdiff_t from, ptrdiff_t to, Lisp_Object prop) | |||
| 478 | valid too. */ | 474 | valid too. */ |
| 479 | if (from > BEGV | 475 | if (from > BEGV |
| 480 | && find_composition (from - 1, -1, &start, &end, &prop, Qnil) | 476 | && find_composition (from - 1, -1, &start, &end, &prop, Qnil) |
| 481 | && !COMPOSITION_VALID_P (start, end, prop)) | 477 | && !composition_valid_p (start, end, prop)) |
| 482 | from = start; | 478 | from = start; |
| 483 | if (to < ZV | 479 | if (to < ZV |
| 484 | && find_composition (to, -1, &start, &end, &prop, Qnil) | 480 | && find_composition (to, -1, &start, &end, &prop, Qnil) |
| 485 | && !COMPOSITION_VALID_P (start, end, prop)) | 481 | && !composition_valid_p (start, end, prop)) |
| 486 | to = end; | 482 | to = end; |
| 487 | if (!NILP (Ffboundp (func))) | 483 | if (!NILP (Ffboundp (func))) |
| 488 | call2 (func, make_number (from), make_number (to)); | 484 | call2 (func, make_number (from), make_number (to)); |
| @@ -524,7 +520,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) | |||
| 524 | latter to the copy of it. */ | 520 | latter to the copy of it. */ |
| 525 | if (from > BEGV | 521 | if (from > BEGV |
| 526 | && find_composition (from - 1, -1, &start, &end, &prop, Qnil) | 522 | && find_composition (from - 1, -1, &start, &end, &prop, Qnil) |
| 527 | && COMPOSITION_VALID_P (start, end, prop)) | 523 | && composition_valid_p (start, end, prop)) |
| 528 | { | 524 | { |
| 529 | min_pos = start; | 525 | min_pos = start; |
| 530 | if (end > to) | 526 | if (end > to) |
| @@ -538,7 +534,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) | |||
| 538 | } | 534 | } |
| 539 | else if (from < ZV | 535 | else if (from < ZV |
| 540 | && find_composition (from, -1, &start, &from, &prop, Qnil) | 536 | && find_composition (from, -1, &start, &from, &prop, Qnil) |
| 541 | && COMPOSITION_VALID_P (start, from, prop)) | 537 | && composition_valid_p (start, from, prop)) |
| 542 | { | 538 | { |
| 543 | if (from > to) | 539 | if (from > to) |
| 544 | max_pos = from; | 540 | max_pos = from; |
| @@ -553,7 +549,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) | |||
| 553 | (to - 1). */ | 549 | (to - 1). */ |
| 554 | while (from < to - 1 | 550 | while (from < to - 1 |
| 555 | && find_composition (from, to, &start, &from, &prop, Qnil) | 551 | && find_composition (from, to, &start, &from, &prop, Qnil) |
| 556 | && COMPOSITION_VALID_P (start, from, prop) | 552 | && composition_valid_p (start, from, prop) |
| 557 | && from < to - 1) | 553 | && from < to - 1) |
| 558 | run_composition_function (start, from, prop); | 554 | run_composition_function (start, from, prop); |
| 559 | } | 555 | } |
| @@ -562,7 +558,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) | |||
| 562 | { | 558 | { |
| 563 | if (from < to | 559 | if (from < to |
| 564 | && find_composition (to - 1, -1, &start, &end, &prop, Qnil) | 560 | && find_composition (to - 1, -1, &start, &end, &prop, Qnil) |
| 565 | && COMPOSITION_VALID_P (start, end, prop)) | 561 | && composition_valid_p (start, end, prop)) |
| 566 | { | 562 | { |
| 567 | /* TO should be also at composition boundary. But, | 563 | /* TO should be also at composition boundary. But, |
| 568 | insertion or deletion will make two compositions adjacent | 564 | insertion or deletion will make two compositions adjacent |
| @@ -580,7 +576,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) | |||
| 580 | } | 576 | } |
| 581 | else if (to < ZV | 577 | else if (to < ZV |
| 582 | && find_composition (to, -1, &start, &end, &prop, Qnil) | 578 | && find_composition (to, -1, &start, &end, &prop, Qnil) |
| 583 | && COMPOSITION_VALID_P (start, end, prop)) | 579 | && composition_valid_p (start, end, prop)) |
| 584 | { | 580 | { |
| 585 | run_composition_function (start, end, prop); | 581 | run_composition_function (start, end, prop); |
| 586 | max_pos = end; | 582 | max_pos = end; |
| @@ -1012,7 +1008,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1012 | if (charpos < endpos | 1008 | if (charpos < endpos |
| 1013 | && find_composition (charpos, endpos, &start, &end, &prop, string) | 1009 | && find_composition (charpos, endpos, &start, &end, &prop, string) |
| 1014 | && start >= charpos | 1010 | && start >= charpos |
| 1015 | && COMPOSITION_VALID_P (start, end, prop)) | 1011 | && composition_valid_p (start, end, prop)) |
| 1016 | { | 1012 | { |
| 1017 | cmp_it->stop_pos = endpos = start; | 1013 | cmp_it->stop_pos = endpos = start; |
| 1018 | cmp_it->ch = -1; | 1014 | cmp_it->ch = -1; |
| @@ -1672,7 +1668,7 @@ composition_adjust_point (ptrdiff_t last_pt, ptrdiff_t new_pt) | |||
| 1672 | 1668 | ||
| 1673 | /* At first check the static composition. */ | 1669 | /* At first check the static composition. */ |
| 1674 | if (get_property_and_range (new_pt, Qcomposition, &val, &beg, &end, Qnil) | 1670 | if (get_property_and_range (new_pt, Qcomposition, &val, &beg, &end, Qnil) |
| 1675 | && COMPOSITION_VALID_P (beg, end, val)) | 1671 | && composition_valid_p (beg, end, val)) |
| 1676 | { | 1672 | { |
| 1677 | if (beg < new_pt /* && end > new_pt <- It's always the case. */ | 1673 | if (beg < new_pt /* && end > new_pt <- It's always the case. */ |
| 1678 | && (last_pt <= beg || last_pt >= end)) | 1674 | && (last_pt <= beg || last_pt >= end)) |
| @@ -1872,7 +1868,7 @@ See `find-composition' for more details. */) | |||
| 1872 | && (e <= XINT (pos) ? e > end : s < start)) | 1868 | && (e <= XINT (pos) ? e > end : s < start)) |
| 1873 | return list3 (make_number (s), make_number (e), gstring); | 1869 | return list3 (make_number (s), make_number (e), gstring); |
| 1874 | } | 1870 | } |
| 1875 | if (!COMPOSITION_VALID_P (start, end, prop)) | 1871 | if (!composition_valid_p (start, end, prop)) |
| 1876 | return list3 (make_number (start), make_number (end), Qnil); | 1872 | return list3 (make_number (start), make_number (end), Qnil); |
| 1877 | if (NILP (detail_p)) | 1873 | if (NILP (detail_p)) |
| 1878 | return list3 (make_number (start), make_number (end), Qt); | 1874 | return list3 (make_number (start), make_number (end), Qt); |
| @@ -1890,7 +1886,7 @@ See `find-composition' for more details. */) | |||
| 1890 | if (id >= 0) | 1886 | if (id >= 0) |
| 1891 | { | 1887 | { |
| 1892 | Lisp_Object components, relative_p, mod_func; | 1888 | Lisp_Object components, relative_p, mod_func; |
| 1893 | enum composition_method method = COMPOSITION_METHOD (prop); | 1889 | enum composition_method method = composition_method (prop); |
| 1894 | int width = composition_table[id]->width; | 1890 | int width = composition_table[id]->width; |
| 1895 | 1891 | ||
| 1896 | components = Fcopy_sequence (COMPOSITION_COMPONENTS (prop)); | 1892 | components = Fcopy_sequence (COMPOSITION_COMPONENTS (prop)); |
diff --git a/src/composite.h b/src/composite.h index 603291044bc..4fdb2564eb1 100644 --- a/src/composite.h +++ b/src/composite.h | |||
| @@ -56,9 +56,6 @@ enum composition_method { | |||
| 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 | /* Temporary variable used only in the following macros. */ | ||
| 60 | extern Lisp_Object composition_temp; | ||
| 61 | |||
| 62 | /* Return 1 if the composition is already registered. */ | 59 | /* Return 1 if the composition is already registered. */ |
| 63 | #define COMPOSITION_REGISTERD_P(prop) INTEGERP (XCAR (prop)) | 60 | #define COMPOSITION_REGISTERD_P(prop) INTEGERP (XCAR (prop)) |
| 64 | 61 | ||
| @@ -83,35 +80,6 @@ extern Lisp_Object composition_temp; | |||
| 83 | ? XCDR (XCDR (XCDR (prop))) \ | 80 | ? XCDR (XCDR (XCDR (prop))) \ |
| 84 | : CONSP (prop) ? XCDR (prop) : Qnil) | 81 | : CONSP (prop) ? XCDR (prop) : Qnil) |
| 85 | 82 | ||
| 86 | /* Return the method of composition. */ | ||
| 87 | #define COMPOSITION_METHOD(prop) \ | ||
| 88 | (COMPOSITION_REGISTERD_P (prop) \ | ||
| 89 | ? composition_table[COMPOSITION_ID (prop)]->method \ | ||
| 90 | : (composition_temp = XCDR (XCAR (prop)), \ | ||
| 91 | (NILP (composition_temp) \ | ||
| 92 | ? COMPOSITION_RELATIVE \ | ||
| 93 | : (INTEGERP (composition_temp) || STRINGP (composition_temp)) \ | ||
| 94 | ? COMPOSITION_WITH_ALTCHARS \ | ||
| 95 | : COMPOSITION_WITH_RULE_ALTCHARS))) | ||
| 96 | |||
| 97 | /* Return 1 if the composition is valid. It is valid if length of | ||
| 98 | the composition equals to (END - START). */ | ||
| 99 | #define COMPOSITION_VALID_P(start, end, prop) \ | ||
| 100 | (CONSP (prop) \ | ||
| 101 | && (COMPOSITION_REGISTERD_P (prop) \ | ||
| 102 | ? (COMPOSITION_ID (prop) >= 0 \ | ||
| 103 | && COMPOSITION_ID (prop) <= n_compositions \ | ||
| 104 | && CONSP (XCDR (prop))) \ | ||
| 105 | : (composition_temp = XCAR (prop), \ | ||
| 106 | (CONSP (composition_temp) \ | ||
| 107 | && (composition_temp = XCDR (composition_temp), \ | ||
| 108 | (NILP (composition_temp) \ | ||
| 109 | || STRINGP (composition_temp) \ | ||
| 110 | || VECTORP (composition_temp) \ | ||
| 111 | || INTEGERP (composition_temp) \ | ||
| 112 | || CONSP (composition_temp)))))) \ | ||
| 113 | && (end - start) == COMPOSITION_LENGTH (prop)) | ||
| 114 | |||
| 115 | /* Return the Nth glyph of composition specified by CMP. CMP is a | 83 | /* Return the Nth glyph of composition specified by CMP. CMP is a |
| 116 | pointer to `struct composition'. */ | 84 | pointer to `struct composition'. */ |
| 117 | #define COMPOSITION_GLYPH(cmp, n) \ | 85 | #define COMPOSITION_GLYPH(cmp, n) \ |
| @@ -233,6 +201,45 @@ extern void syms_of_composite (void); | |||
| 233 | extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object, | 201 | extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object, |
| 234 | Lisp_Object); | 202 | Lisp_Object); |
| 235 | 203 | ||
| 204 | /* Return the method of composition. */ | ||
| 205 | COMPOSITE_INLINE enum composition_method | ||
| 206 | composition_method (Lisp_Object prop) | ||
| 207 | { | ||
| 208 | Lisp_Object temp; | ||
| 209 | |||
| 210 | return (COMPOSITION_REGISTERD_P (prop) | ||
| 211 | ? composition_table[COMPOSITION_ID (prop)]->method | ||
| 212 | : (temp = XCDR (XCAR (prop)), | ||
| 213 | (NILP (temp) | ||
| 214 | ? COMPOSITION_RELATIVE | ||
| 215 | : (INTEGERP (temp) || STRINGP (temp)) | ||
| 216 | ? COMPOSITION_WITH_ALTCHARS | ||
| 217 | : COMPOSITION_WITH_RULE_ALTCHARS))); | ||
| 218 | } | ||
| 219 | |||
| 220 | /* Return 1 if the composition is valid. It is valid if | ||
| 221 | length of the composition equals to (END - START). */ | ||
| 222 | COMPOSITE_INLINE bool | ||
| 223 | composition_valid_p (ptrdiff_t start, ptrdiff_t end, Lisp_Object prop) | ||
| 224 | { | ||
| 225 | Lisp_Object temp; | ||
| 226 | |||
| 227 | return (CONSP (prop) | ||
| 228 | && (COMPOSITION_REGISTERD_P (prop) | ||
| 229 | ? (COMPOSITION_ID (prop) >= 0 | ||
| 230 | && COMPOSITION_ID (prop) <= n_compositions | ||
| 231 | && CONSP (XCDR (prop))) | ||
| 232 | : (temp = XCAR (prop), | ||
| 233 | (CONSP (temp) | ||
| 234 | && (temp = XCDR (temp), | ||
| 235 | (NILP (temp) | ||
| 236 | || STRINGP (temp) | ||
| 237 | || VECTORP (temp) | ||
| 238 | || INTEGERP (temp) | ||
| 239 | || CONSP (temp)))))) | ||
| 240 | && (end - start) == COMPOSITION_LENGTH (prop)); | ||
| 241 | } | ||
| 242 | |||
| 236 | /* Macros for lispy glyph-string. This is completely different from | 243 | /* Macros for lispy glyph-string. This is completely different from |
| 237 | struct glyph_string. */ | 244 | struct glyph_string. */ |
| 238 | 245 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index e73d629b153..7a1f03ce244 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -5346,7 +5346,7 @@ handle_composition_prop (struct it *it) | |||
| 5346 | composition (in the case that the composition is from the current | 5346 | composition (in the case that the composition is from the current |
| 5347 | buffer), draw a glyph composed from the composition components. */ | 5347 | buffer), draw a glyph composed from the composition components. */ |
| 5348 | if (find_composition (pos, -1, &start, &end, &prop, string) | 5348 | if (find_composition (pos, -1, &start, &end, &prop, string) |
| 5349 | && COMPOSITION_VALID_P (start, end, prop) | 5349 | && composition_valid_p (start, end, prop) |
| 5350 | && (STRINGP (it->string) || (PT <= start || PT >= end))) | 5350 | && (STRINGP (it->string) || (PT <= start || PT >= end))) |
| 5351 | { | 5351 | { |
| 5352 | if (start < pos) | 5352 | if (start < pos) |
| @@ -12852,7 +12852,7 @@ check_point_in_composition (struct buffer *prev_buf, ptrdiff_t prev_pt, | |||
| 12852 | 12852 | ||
| 12853 | if (prev_pt > BUF_BEGV (buf) && prev_pt < BUF_ZV (buf) | 12853 | if (prev_pt > BUF_BEGV (buf) && prev_pt < BUF_ZV (buf) |
| 12854 | && find_composition (prev_pt, -1, &start, &end, &prop, buffer) | 12854 | && find_composition (prev_pt, -1, &start, &end, &prop, buffer) |
| 12855 | && COMPOSITION_VALID_P (start, end, prop) | 12855 | && composition_valid_p (start, end, prop) |
| 12856 | && start < prev_pt && end > prev_pt) | 12856 | && start < prev_pt && end > prev_pt) |
| 12857 | /* The last point was within the composition. Return 1 iff | 12857 | /* The last point was within the composition. Return 1 iff |
| 12858 | point moved out of the composition. */ | 12858 | point moved out of the composition. */ |
| @@ -12862,7 +12862,7 @@ check_point_in_composition (struct buffer *prev_buf, ptrdiff_t prev_pt, | |||
| 12862 | /* Check a composition at the current point. */ | 12862 | /* Check a composition at the current point. */ |
| 12863 | return (pt > BUF_BEGV (buf) && pt < BUF_ZV (buf) | 12863 | return (pt > BUF_BEGV (buf) && pt < BUF_ZV (buf) |
| 12864 | && find_composition (pt, -1, &start, &end, &prop, buffer) | 12864 | && find_composition (pt, -1, &start, &end, &prop, buffer) |
| 12865 | && COMPOSITION_VALID_P (start, end, prop) | 12865 | && composition_valid_p (start, end, prop) |
| 12866 | && start < pt && end > pt); | 12866 | && start < pt && end > pt); |
| 12867 | } | 12867 | } |
| 12868 | 12868 | ||