From: Dmitry Antipov Date: Sat, 3 Aug 2013 18:16:43 +0000 (+0400) Subject: Do not use global Lisp_Object in composition macros. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1688^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=75c59fb3ec3188d4c7c20675b7beaa07cb0c1891;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index a1685b85d9b..5d1e8c10320 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2013-08-03 Dmitry Antipov + + 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. + 2013-08-03 Dmitry Antipov Drop FRAME_PTR typedef. 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, /* We found a composition. Store the corresponding annotation data in BUF. */ int *head = buf; - enum composition_method method = COMPOSITION_METHOD (prop); + enum composition_method method = composition_method (prop); int nchars = COMPOSITION_LENGTH (prop); 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; auto-compositions. */ #define MAX_AUTO_COMPOSITION_LOOKBACK 3 -/* Temporary variable used in macros COMPOSITION_XXX. */ -Lisp_Object composition_temp; - - /* Return COMPOSITION-ID of a composition at buffer position CHARPOS/BYTEPOS and length NCHARS. The `composition' property of 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) valid too. */ if (from > BEGV && find_composition (from - 1, -1, &start, &end, &prop, Qnil) - && !COMPOSITION_VALID_P (start, end, prop)) + && !composition_valid_p (start, end, prop)) from = start; if (to < ZV && find_composition (to, -1, &start, &end, &prop, Qnil) - && !COMPOSITION_VALID_P (start, end, prop)) + && !composition_valid_p (start, end, prop)) to = end; if (!NILP (Ffboundp (func))) call2 (func, make_number (from), make_number (to)); @@ -524,7 +520,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) latter to the copy of it. */ if (from > BEGV && find_composition (from - 1, -1, &start, &end, &prop, Qnil) - && COMPOSITION_VALID_P (start, end, prop)) + && composition_valid_p (start, end, prop)) { min_pos = start; if (end > to) @@ -538,7 +534,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) } else if (from < ZV && find_composition (from, -1, &start, &from, &prop, Qnil) - && COMPOSITION_VALID_P (start, from, prop)) + && composition_valid_p (start, from, prop)) { if (from > to) max_pos = from; @@ -553,7 +549,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) (to - 1). */ while (from < to - 1 && find_composition (from, to, &start, &from, &prop, Qnil) - && COMPOSITION_VALID_P (start, from, prop) + && composition_valid_p (start, from, prop) && from < to - 1) run_composition_function (start, from, prop); } @@ -562,7 +558,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) { if (from < to && find_composition (to - 1, -1, &start, &end, &prop, Qnil) - && COMPOSITION_VALID_P (start, end, prop)) + && composition_valid_p (start, end, prop)) { /* TO should be also at composition boundary. But, insertion or deletion will make two compositions adjacent @@ -580,7 +576,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask) } else if (to < ZV && find_composition (to, -1, &start, &end, &prop, Qnil) - && COMPOSITION_VALID_P (start, end, prop)) + && composition_valid_p (start, end, prop)) { run_composition_function (start, end, prop); max_pos = end; @@ -1012,7 +1008,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, if (charpos < endpos && find_composition (charpos, endpos, &start, &end, &prop, string) && start >= charpos - && COMPOSITION_VALID_P (start, end, prop)) + && composition_valid_p (start, end, prop)) { cmp_it->stop_pos = endpos = start; cmp_it->ch = -1; @@ -1672,7 +1668,7 @@ composition_adjust_point (ptrdiff_t last_pt, ptrdiff_t new_pt) /* At first check the static composition. */ if (get_property_and_range (new_pt, Qcomposition, &val, &beg, &end, Qnil) - && COMPOSITION_VALID_P (beg, end, val)) + && composition_valid_p (beg, end, val)) { if (beg < new_pt /* && end > new_pt <- It's always the case. */ && (last_pt <= beg || last_pt >= end)) @@ -1872,7 +1868,7 @@ See `find-composition' for more details. */) && (e <= XINT (pos) ? e > end : s < start)) return list3 (make_number (s), make_number (e), gstring); } - if (!COMPOSITION_VALID_P (start, end, prop)) + if (!composition_valid_p (start, end, prop)) return list3 (make_number (start), make_number (end), Qnil); if (NILP (detail_p)) return list3 (make_number (start), make_number (end), Qt); @@ -1890,7 +1886,7 @@ See `find-composition' for more details. */) if (id >= 0) { Lisp_Object components, relative_p, mod_func; - enum composition_method method = COMPOSITION_METHOD (prop); + enum composition_method method = composition_method (prop); int width = composition_table[id]->width; 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 { (COMPOSITION-ID . (LENGTH COMPONENTS . MODIFICATION-FUNC)) They don't check validity of PROP. */ -/* Temporary variable used only in the following macros. */ -extern Lisp_Object composition_temp; - /* Return 1 if the composition is already registered. */ #define COMPOSITION_REGISTERD_P(prop) INTEGERP (XCAR (prop)) @@ -83,35 +80,6 @@ extern Lisp_Object composition_temp; ? XCDR (XCDR (XCDR (prop))) \ : CONSP (prop) ? XCDR (prop) : Qnil) -/* Return the method of composition. */ -#define COMPOSITION_METHOD(prop) \ - (COMPOSITION_REGISTERD_P (prop) \ - ? composition_table[COMPOSITION_ID (prop)]->method \ - : (composition_temp = XCDR (XCAR (prop)), \ - (NILP (composition_temp) \ - ? COMPOSITION_RELATIVE \ - : (INTEGERP (composition_temp) || STRINGP (composition_temp)) \ - ? COMPOSITION_WITH_ALTCHARS \ - : COMPOSITION_WITH_RULE_ALTCHARS))) - -/* Return 1 if the composition is valid. It is valid if length of - the composition equals to (END - START). */ -#define COMPOSITION_VALID_P(start, end, prop) \ - (CONSP (prop) \ - && (COMPOSITION_REGISTERD_P (prop) \ - ? (COMPOSITION_ID (prop) >= 0 \ - && COMPOSITION_ID (prop) <= n_compositions \ - && CONSP (XCDR (prop))) \ - : (composition_temp = XCAR (prop), \ - (CONSP (composition_temp) \ - && (composition_temp = XCDR (composition_temp), \ - (NILP (composition_temp) \ - || STRINGP (composition_temp) \ - || VECTORP (composition_temp) \ - || INTEGERP (composition_temp) \ - || CONSP (composition_temp)))))) \ - && (end - start) == COMPOSITION_LENGTH (prop)) - /* Return the Nth glyph of composition specified by CMP. CMP is a pointer to `struct composition'. */ #define COMPOSITION_GLYPH(cmp, n) \ @@ -233,6 +201,45 @@ extern void syms_of_composite (void); extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object, Lisp_Object); +/* Return the method of composition. */ +COMPOSITE_INLINE enum composition_method +composition_method (Lisp_Object prop) +{ + Lisp_Object temp; + + return (COMPOSITION_REGISTERD_P (prop) + ? composition_table[COMPOSITION_ID (prop)]->method + : (temp = XCDR (XCAR (prop)), + (NILP (temp) + ? COMPOSITION_RELATIVE + : (INTEGERP (temp) || STRINGP (temp)) + ? COMPOSITION_WITH_ALTCHARS + : COMPOSITION_WITH_RULE_ALTCHARS))); +} + +/* Return 1 if the composition is valid. It is valid if + length of the composition equals to (END - START). */ +COMPOSITE_INLINE bool +composition_valid_p (ptrdiff_t start, ptrdiff_t end, Lisp_Object prop) +{ + Lisp_Object temp; + + return (CONSP (prop) + && (COMPOSITION_REGISTERD_P (prop) + ? (COMPOSITION_ID (prop) >= 0 + && COMPOSITION_ID (prop) <= n_compositions + && CONSP (XCDR (prop))) + : (temp = XCAR (prop), + (CONSP (temp) + && (temp = XCDR (temp), + (NILP (temp) + || STRINGP (temp) + || VECTORP (temp) + || INTEGERP (temp) + || CONSP (temp)))))) + && (end - start) == COMPOSITION_LENGTH (prop)); +} + /* Macros for lispy glyph-string. This is completely different from struct glyph_string. */ 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) composition (in the case that the composition is from the current buffer), draw a glyph composed from the composition components. */ if (find_composition (pos, -1, &start, &end, &prop, string) - && COMPOSITION_VALID_P (start, end, prop) + && composition_valid_p (start, end, prop) && (STRINGP (it->string) || (PT <= start || PT >= end))) { if (start < pos) @@ -12852,7 +12852,7 @@ check_point_in_composition (struct buffer *prev_buf, ptrdiff_t prev_pt, if (prev_pt > BUF_BEGV (buf) && prev_pt < BUF_ZV (buf) && find_composition (prev_pt, -1, &start, &end, &prop, buffer) - && COMPOSITION_VALID_P (start, end, prop) + && composition_valid_p (start, end, prop) && start < prev_pt && end > prev_pt) /* The last point was within the composition. Return 1 iff point moved out of the composition. */ @@ -12862,7 +12862,7 @@ check_point_in_composition (struct buffer *prev_buf, ptrdiff_t prev_pt, /* Check a composition at the current point. */ return (pt > BUF_BEGV (buf) && pt < BUF_ZV (buf) && find_composition (pt, -1, &start, &end, &prop, buffer) - && COMPOSITION_VALID_P (start, end, prop) + && composition_valid_p (start, end, prop) && start < pt && end > pt); }