cmp->method = method;
cmp->hash_index = hash_index;
cmp->glyph_len = glyph_len;
- cmp->offsets = xnmalloc (glyph_len, 2 * sizeof *cmp->offsets);
+ cmp->offsets = xnmalloc_atomic (glyph_len, 2 * sizeof *cmp->offsets);
cmp->font = NULL;
if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS)
}
if (min_pos < max_pos)
{
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
specbind (Qinhibit_read_only, Qt);
specbind (Qinhibit_modification_hooks, Qt);
Fremove_list_of_text_properties (make_number (min_pos),
make_number (max_pos),
list1 (Qauto_composed), Qnil);
- unbind_to (count, Qnil);
+ dynwind_end ();
}
}
ptrdiff_t limit, struct window *win, struct face *face,
Lisp_Object string)
{
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
struct frame *f = XFRAME (win->frame);
Lisp_Object pos = make_number (charpos);
ptrdiff_t to;
re = AREF (rule, 0);
if (NILP (re))
len = 1;
- else if (! STRINGP (re))
- return unbind_to (count, Qnil);
+ else if (! STRINGP (re)){
+
+ dynwind_end ();
+ return Qnil;
+ }
else if ((len = fast_looking_at (re, charpos, bytepos, limit, -1, string))
> 0)
{
else
len = string_byte_to_char (string, bytepos + len) - charpos;
}
- if (len <= 0)
- return unbind_to (count, Qnil);
+ if (len <= 0){
+
+ dynwind_end ();
+ return Qnil;
+ }
to = limit = charpos + len;
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
if (! FONT_OBJECT_P (font_object)
|| (! NILP (re)
&& to < limit
- && (fast_looking_at (re, charpos, bytepos, to, -1, string) <= 0)))
- return unbind_to (count, Qnil);
+ && (fast_looking_at (re, charpos, bytepos, to, -1, string) <= 0))){
+
+ dynwind_end ();
+ return Qnil;
+ }
}
else
#endif /* not HAVE_WINDOW_SYSTEM */
lgstring = safe_call (6, Vauto_composition_function, AREF (rule, 2),
pos, make_number (to), font_object, string);
}
- return unbind_to (count, lgstring);
+ dynwind_end ();
+ return lgstring;
}
-static Lisp_Object _work_val;
-
/* 1 iff the character C is composable. Characters of general
category Z? or C? are not composable except for ZWNJ and ZWJ. */
-#define CHAR_COMPOSABLE_P(C) \
- ((C) > ' ' \
- && ((C) == 0x200C || (C) == 0x200D \
- || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \
- (INTEGERP (_work_val) \
- && (XINT (_work_val) <= UNICODE_CATEGORY_So)))))
+static bool
+char_composable_p (int c)
+{
+ Lisp_Object val;
+ return (c > ' '
+ && (c == 0x200C || c == 0x200D
+ || (val = CHAR_TABLE_REF (Vunicode_category_table, c),
+ (INTEGERP (val) && (XINT (val) <= UNICODE_CATEGORY_So)))));
+}
/* Update cmp_it->stop_pos to the next position after CHARPOS (and
BYTEPOS) where character composition may happen. If BYTEPOS is
p = SDATA (string) + bytepos;
c = STRING_CHAR_AND_LENGTH (p, len);
limit = bytepos + len;
- while (CHAR_COMPOSABLE_P (c))
+ while (char_composable_p (c))
{
val = CHAR_TABLE_REF (Vcomposition_function_table, c);
if (! NILP (val))
/* Skip all uncomposable characters. */
if (NILP (string))
{
- while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c))
+ while (charpos - 1 > endpos && ! char_composable_p (c))
{
DEC_BOTH (charpos, bytepos);
c = FETCH_MULTIBYTE_CHAR (bytepos);
}
else
{
- while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c))
+ while (charpos - 1 > endpos && ! char_composable_p (c))
{
p--;
while (! CHAR_HEAD_P (*p))
|-B-|-C-|--D--|
Here, it is known that characters after positions 1 and 9 can
- never be composed (i.e. ! CHAR_COMPOSABLE_P (CH)), and
+ never be composed (i.e. ! char_composable_p (CH)), and
composition A is an invalid one because it's partially covered by
the valid composition C. And to know whether a composition is
valid or not, the only way is to start searching forward from a
while (1)
{
c = STRING_CHAR (cur.p);
- if (! CHAR_COMPOSABLE_P (c))
+ if (! char_composable_p (c))
{
if (limit <= pos) /* case (1) */
{
return 0;
BACKWARD_CHAR (cur, stop);
c = STRING_CHAR (cur.p);
- } while (! CHAR_COMPOSABLE_P (c));
+ } while (! char_composable_p (c));
fore_check_limit = cur.pos + 1;
}
else /* case (2) */
prev = cur;
BACKWARD_CHAR (cur, stop);
c = STRING_CHAR (cur.p);
- if (! CHAR_COMPOSABLE_P (c))
+ if (! char_composable_p (c))
{
cur = prev;
break;
frame, or nil for the selected frame's terminal device.
If the optional 4th argument STRING is not nil, it is a string
-containing the target characters between indices FROM and TO.
-Otherwise FROM and TO are character positions in current buffer;
-they can be in either order, and can be integers or markers.
+containing the target characters between indices FROM and TO,
+which are treated as in `substring'. Otherwise FROM and TO are
+character positions in current buffer; they can be in either order,
+and can be integers or markers.
A glyph-string is a vector containing information about how to display
a specific character sequence. The format is:
}
else
{
- CHECK_NATNUM (from);
- CHECK_NATNUM (to);
CHECK_STRING (string);
+ validate_subarray (string, from, to, SCHARS (string), &frompos, &topos);
if (! STRING_MULTIBYTE (string))
error ("Attempt to shape unibyte text");
- if (! (XINT (from) <= XINT (to) && XINT (to) <= SCHARS (string)))
- args_out_of_range_3 (string, from, to);
- frompos = XFASTINT (from);
- topos = XFASTINT (to);
frombyte = string_char_to_byte (string, frompos);
}
Scompose_string_internal, 3, 5, 0,
doc: /* Internal use only.
-Compose text between indices START and END of STRING.
-Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC
+Compose text between indices START and END of STRING, where
+START and END are treated as in `substring'. Optional 4th
+and 5th arguments are COMPONENTS and MODIFICATION-FUNC
for the composition. See `compose-string' for more details. */)
- (Lisp_Object string, Lisp_Object start, Lisp_Object end, Lisp_Object components, Lisp_Object modification_func)
+ (Lisp_Object string, Lisp_Object start, Lisp_Object end,
+ Lisp_Object components, Lisp_Object modification_func)
{
- CHECK_STRING (string);
- CHECK_NUMBER (start);
- CHECK_NUMBER (end);
+ ptrdiff_t from, to;
- if (XINT (start) < 0 ||
- XINT (start) > XINT (end)
- || XINT (end) > SCHARS (string))
- args_out_of_range (start, end);
-
- compose_text (XINT (start), XINT (end), components, modification_func, string);
+ CHECK_STRING (string);
+ validate_subarray (string, start, end, SCHARS (string), &from, &to);
+ compose_text (from, to, components, modification_func, string);
return string;
}
{
int i;
+#include "composite.x"
+
DEFSYM (Qcomposition, "composition");
/* Make a hash table for static composition. */
See also the documentation of `auto-composition-mode'. */);
Vcomposition_function_table = Fmake_char_table (Qnil, Qnil);
-
- defsubr (&Scompose_region_internal);
- defsubr (&Scompose_string_internal);
- defsubr (&Sfind_composition_internal);
- defsubr (&Scomposition_get_gstring);
}