diff options
author | Stephen Leake <stephen_leake@stephe-leake.org> | 2018-12-13 14:39:02 -0800 |
---|---|---|
committer | Stephen Leake <stephen_leake@stephe-leake.org> | 2018-12-13 14:39:02 -0800 |
commit | 87bef630bf0f45e8da74e43ba614aa2292b296ef (patch) | |
tree | efdead3c0d7dd227bacbd4dfc5c1ff9b4d5c13c3 /src/textprop.c | |
parent | 4d3f7b77cc7dea072d2ecb9f137c2e497bc52da1 (diff) | |
parent | d08b75abe0f0cf9ade812b189c374809a2c7836e (diff) | |
download | emacs-87bef630bf0f45e8da74e43ba614aa2292b296ef.tar.gz |
Merge commit 'd08b75abe0f0cf9ade812b189c374809a2c7836e'
Diffstat (limited to 'src/textprop.c')
-rw-r--r-- | src/textprop.c | 87 |
1 files changed, 25 insertions, 62 deletions
diff --git a/src/textprop.c b/src/textprop.c index 8e8baf43d9f..8a06f0ffad1 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -111,9 +111,6 @@ CHECK_STRING_OR_BUFFER (Lisp_Object x) to by BEGIN and END may be integers or markers; if the latter, they are coerced to integers. - When OBJECT is a string, we increment *BEGIN and *END - to make them origin-one. - Note that buffer points don't correspond to interval indices. For example, point-max is 1 greater than the index of the last character. This difference is handled in the caller, which uses @@ -175,9 +172,6 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, if (! (0 <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end) && XFIXNUM (*end) <= len)) args_out_of_range (*begin, *end); - XSETFASTINT (*begin, XFIXNAT (*begin)); - if (begin != end) - XSETFASTINT (*end, XFIXNAT (*end)); i = string_intervals (object); if (len == 0) @@ -1348,13 +1342,9 @@ Lisp_Object set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, Lisp_Object coherent_change_p) { - register INTERVAL i; - Lisp_Object ostart, oend; + INTERVAL i; bool first_time = true; - ostart = start; - oend = end; - properties = validate_plist (properties); if (NILP (object)) @@ -1382,11 +1372,6 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, if (NILP (properties)) return Qnil; - /* Restore the original START and END values - because validate_interval_range increments them for strings. */ - start = ostart; - end = oend; - i = validate_interval_range (object, &start, &end, hard); /* This can return if start == end. */ if (!i) @@ -1421,34 +1406,25 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, /* Replace properties of text from START to END with new list of properties PROPERTIES. OBJECT is the buffer or string containing the text. This does not obey any hooks. - You should provide the interval that START is located in as I. - START and END can be in any order. */ + I is the interval that START is located in. */ void -set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, INTERVAL i) +set_text_properties_1 (Lisp_Object start, Lisp_Object end, + Lisp_Object properties, Lisp_Object object, INTERVAL i) { - register INTERVAL prev_changed = NULL; - register ptrdiff_t s, len; - INTERVAL unchanged; + INTERVAL prev_changed = NULL; + ptrdiff_t s = XFIXNUM (start); + ptrdiff_t len = XFIXNUM (end) - s; - if (XFIXNUM (start) < XFIXNUM (end)) - { - s = XFIXNUM (start); - len = XFIXNUM (end) - s; - } - else if (XFIXNUM (end) < XFIXNUM (start)) - { - s = XFIXNUM (end); - len = XFIXNUM (start) - s; - } - else + if (len == 0) return; + eassert (0 < len); eassert (i); if (i->position != s) { - unchanged = i; + INTERVAL unchanged = i; i = split_interval_right (unchanged, s - unchanged->position); if (LENGTH (i) > len) @@ -1896,45 +1872,30 @@ Lisp_Object copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_Object pos, Lisp_Object dest, Lisp_Object prop) { - INTERVAL i; - Lisp_Object res; - Lisp_Object stuff; - Lisp_Object plist; - ptrdiff_t s, e, e2, p, len; - bool modified = false; - - i = validate_interval_range (src, &start, &end, soft); + INTERVAL i = validate_interval_range (src, &start, &end, soft); if (!i) return Qnil; CHECK_FIXNUM_COERCE_MARKER (pos); - { - Lisp_Object dest_start, dest_end; - - e = XFIXNUM (pos) + (XFIXNUM (end) - XFIXNUM (start)); - if (MOST_POSITIVE_FIXNUM < e) - args_out_of_range (pos, end); - dest_start = pos; - XSETFASTINT (dest_end, e); - /* Apply this to a copy of pos; it will try to increment its arguments, - which we don't want. */ - validate_interval_range (dest, &dest_start, &dest_end, soft); - } - s = XFIXNUM (start); - e = XFIXNUM (end); - p = XFIXNUM (pos); + EMACS_INT dest_e = XFIXNUM (pos) + (XFIXNUM (end) - XFIXNUM (start)); + if (MOST_POSITIVE_FIXNUM < dest_e) + args_out_of_range (pos, end); + Lisp_Object dest_end = make_fixnum (dest_e); + validate_interval_range (dest, &pos, &dest_end, soft); + + ptrdiff_t s = XFIXNUM (start), e = XFIXNUM (end), p = XFIXNUM (pos); - stuff = Qnil; + Lisp_Object stuff = Qnil; while (s < e) { - e2 = i->position + LENGTH (i); + ptrdiff_t e2 = i->position + LENGTH (i); if (e2 > e) e2 = e; - len = e2 - s; + ptrdiff_t len = e2 - s; - plist = i->plist; + Lisp_Object plist = i->plist; if (! NILP (prop)) while (! NILP (plist)) { @@ -1959,9 +1920,11 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, s = i->position; } + bool modified = false; + while (! NILP (stuff)) { - res = Fcar (stuff); + Lisp_Object res = Fcar (stuff); res = Fadd_text_properties (Fcar (res), Fcar (Fcdr (res)), Fcar (Fcdr (Fcdr (res))), dest); if (! NILP (res)) |