emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116430: * composite.c (fill_gstring_header): Pass p


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r116430: * composite.c (fill_gstring_header): Pass positions as C integers
Date: Thu, 13 Feb 2014 12:17:17 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116430
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Thu 2014-02-13 16:16:42 +0400
message:
  * composite.c (fill_gstring_header): Pass positions as C integers
  and move parameters checking to...
  * composite.c (Fcomposition_get_gstring): ...this function.  Handle
  case when buffer positions are in reversed order and avoid crash
  (Bug#16739).  Adjust docstring.
  * buffer.c (validate_region): Mention current buffer in error message.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/buffer.c                   buffer.c-20091113204419-o5vbwnq5f7feedwu-264
  src/composite.c                
composite.c-20091113204419-o5vbwnq5f7feedwu-1728
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-02-13 02:19:48 +0000
+++ b/src/ChangeLog     2014-02-13 12:16:42 +0000
@@ -1,3 +1,12 @@
+2014-02-13  Dmitry Antipov  <address@hidden>
+
+       * composite.c (fill_gstring_header): Pass positions as C integers
+       and move parameters checking to...
+       * composite.c (Fcomposition_get_gstring): ...this function.  Handle
+       case when buffer positions are in reversed order and avoid crash
+       (Bug#16739).  Adjust docstring.
+       * buffer.c (validate_region): Mention current buffer in error message.
+
 2014-02-12  Marcus Karlsson  <address@hidden>  (tiny change)
 
        * image.c (pbm_load): Set to NO_PIXMAP on error (Bug#16683).

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2014-02-12 01:07:06 +0000
+++ b/src/buffer.c      2014-02-13 12:16:42 +0000
@@ -2261,7 +2261,7 @@
     }
 
   if (! (BEGV <= XINT (*b) && XINT (*e) <= ZV))
-    args_out_of_range (*b, *e);
+    args_out_of_range_3 (Fcurrent_buffer (), *b, *e);
 }
 
 /* Advance BYTE_POS up to a character boundary

=== modified file 'src/composite.c'
--- a/src/composite.c   2014-01-19 13:26:21 +0000
+++ b/src/composite.c   2014-02-13 12:16:42 +0000
@@ -780,35 +780,11 @@
 static Lisp_Object gstring_work_headers;
 
 static Lisp_Object
-fill_gstring_header (Lisp_Object header, Lisp_Object start, Lisp_Object end,
-                    Lisp_Object font_object, Lisp_Object string)
+fill_gstring_header (Lisp_Object header, ptrdiff_t from, ptrdiff_t from_byte,
+                    ptrdiff_t to, Lisp_Object font_object, Lisp_Object string)
 {
-  ptrdiff_t from, to, from_byte;
-  ptrdiff_t len, i;
-
-  if (NILP (string))
-    {
-      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
-       error ("Attempt to shape unibyte text");
-      validate_region (&start, &end);
-      from = XFASTINT (start);
-      to = XFASTINT (end);
-      from_byte = CHAR_TO_BYTE (from);
-    }
-  else
-    {
-      CHECK_STRING (string);
-      if (! STRING_MULTIBYTE (string))
-       error ("Attempt to shape unibyte text");
-      /* The caller checks that START and END are nonnegative integers.  */
-      if (! (XINT (start) <= XINT (end) && XINT (end) <= SCHARS (string)))
-       args_out_of_range_3 (string, start, end);
-      from = XINT (start);
-      to = XINT (end);
-      from_byte = string_char_to_byte (string, from);
-    }
-
-  len = to - from;
+  ptrdiff_t len = to - from, i;
+
   if (len == 0)
     error ("Attempt to shape zero-length text");
   if (VECTORP (header))
@@ -1708,6 +1684,8 @@
 
 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.
 
 A glyph-string is a vector containing information about how to display
 a specific character sequence.  The format is:
@@ -1739,10 +1717,8 @@
   (Lisp_Object from, Lisp_Object to, Lisp_Object font_object, Lisp_Object 
string)
 {
   Lisp_Object gstring, header;
-  ptrdiff_t frompos, topos;
+  ptrdiff_t frompos, frombyte, topos;
 
-  CHECK_NATNUM (from);
-  CHECK_NATNUM (to);
   if (! FONT_OBJECT_P (font_object))
     {
       struct coding_system *coding;
@@ -1754,13 +1730,35 @@
       font_object = CODING_ID_NAME (coding->id);
     }
 
-  header = fill_gstring_header (Qnil, from, to, font_object, string);
+  if (NILP (string))
+    {
+      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
+       error ("Attempt to shape unibyte text");
+      validate_region (&from, &to);
+      frompos = XFASTINT (from);
+      topos = XFASTINT (to);
+      frombyte = CHAR_TO_BYTE (frompos);
+    }
+  else
+    {
+      CHECK_NATNUM (from);
+      CHECK_NATNUM (to);
+      CHECK_STRING (string);
+      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);
+    }
+
+  header = fill_gstring_header (Qnil, frompos, frombyte,
+                               topos, font_object, string);
   gstring = gstring_lookup_cache (header);
   if (! NILP (gstring))
     return gstring;
 
-  frompos = XINT (from);
-  topos = XINT (to);
   if (LGSTRING_GLYPH_LEN (gstring_work) < topos - frompos)
     gstring_work = Fmake_vector (make_number (topos - frompos + 2), Qnil);
   LGSTRING_SET_HEADER (gstring_work, header);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]