]> code.delx.au - gnu-emacs/commitdiff
(set_text_properties_1): Allow args in either order.
authorRichard M. Stallman <rms@gnu.org>
Mon, 26 Nov 2001 20:10:04 +0000 (20:10 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 26 Nov 2001 20:10:04 +0000 (20:10 +0000)
Do nothing if range is empty.

src/textprop.c

index cd07484204bf128a4aed23f0105435016ce83fbd..7c6a5e6d68643ced6d50dcaf9c528910eff07783 100644 (file)
@@ -1304,7 +1304,7 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
    the text.  This does not obey any hooks.
    You can provide the interval that START is located in as I,
    or pass NULL for I and this function will find it.
-   This function assumes that START < END.  */
+   START and END can be in any order.  */
 
 void
 set_text_properties_1 (start, end, properties, buffer, i)
@@ -1317,7 +1317,14 @@ set_text_properties_1 (start, end, properties, buffer, i)
 
   s = XINT (start);
   len = XINT (end) - s;
-  eassert (len > 0);
+  if (len == 0)
+    return;
+  if (len < 0)
+    {
+      s = s + len;
+      len = - len;
+    }
+
   if (i == 0)
     i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);