changeset 62962:6ab08ae41502

(MODE_LINE_NOPROP_LEN): New macro. (x_consider_frame_title, Fformat_mode_line): Save offset into mode_line_noprop_buf rather than pointer, in case buffer is relocated.
author Kim F. Storm <storm@cua.dk>
date Thu, 02 Jun 2005 12:27:05 +0000
parents 2945f8ec464e
children fcacef2ed810 6aee1e9b0bd7
files src/xdisp.c
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Thu Jun 02 12:25:57 2005 +0000
+++ b/src/xdisp.c	Thu Jun 02 12:27:05 2005 +0000
@@ -8173,6 +8173,9 @@
 static char *mode_line_noprop_buf_end;
 static char *mode_line_noprop_ptr;
 
+#define MODE_LINE_NOPROP_LEN(start) \
+  ((mode_line_noprop_ptr - mode_line_noprop_buf) - start)
+
 static enum {
   MODE_LINE_DISPLAY = 0,
   MODE_LINE_TITLE,
@@ -8212,7 +8215,7 @@
     vector = Fmake_vector (make_number (7), Qnil);
 
   AREF (vector, 0) = make_number (mode_line_target);
-  AREF (vector, 1) = make_number (mode_line_noprop_ptr - mode_line_noprop_buf);
+  AREF (vector, 1) = make_number (MODE_LINE_NOPROP_LEN (0));
   AREF (vector, 2) = mode_line_string_list;
   AREF (vector, 3) = mode_line_proptrans_alist;
   AREF (vector, 4) = mode_line_string_face;
@@ -8263,7 +8266,7 @@
      double the buffer's size.  */
   if (mode_line_noprop_ptr == mode_line_noprop_buf_end)
     {
-      int len = mode_line_noprop_ptr - mode_line_noprop_buf;
+      int len = MODE_LINE_NOPROP_LEN (0);
       int new_size = 2 * len * sizeof *mode_line_noprop_buf;
       mode_line_noprop_buf = (char *) xrealloc (mode_line_noprop_buf, new_size);
       mode_line_noprop_buf_end = mode_line_noprop_buf + new_size;
@@ -8330,7 +8333,8 @@
       /* Do we have more than one visible frame on this X display?  */
       Lisp_Object tail;
       Lisp_Object fmt;
-      char *title_start;
+      int title_start;
+      char *title;
       int len;
       struct it it;
       int count = SPECPDL_INDEX ();
@@ -8361,12 +8365,12 @@
       fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format;
 
       mode_line_target = MODE_LINE_TITLE;
-      title_start = mode_line_noprop_ptr;
+      title_start = MODE_LINE_NOPROP_LEN (0);
       init_iterator (&it, XWINDOW (f->selected_window), -1, -1,
 		     NULL, DEFAULT_FACE_ID);
       display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0);
-      len = mode_line_noprop_ptr - title_start;
-
+      len = MODE_LINE_NOPROP_LEN (title_start);
+      title = mode_line_noprop_buf + title_start;
       unbind_to (count, Qnil);
 
       /* Set the title only if it's changed.  This avoids consing in
@@ -8376,8 +8380,8 @@
 	 higher level than this.)  */
       if (! STRINGP (f->name)
 	  || SBYTES (f->name) != len
-	  || bcmp (title_start, SDATA (f->name), len) != 0)
-	x_implicitly_set_name (f, make_string (title_start, len), Qnil);
+	  || bcmp (title, SDATA (f->name), len) != 0)
+	x_implicitly_set_name (f, make_string (title, len), Qnil);
     }
 }
 
@@ -16300,7 +16304,7 @@
   int no_props = INTEGERP (face);
   int count = SPECPDL_INDEX ();
   Lisp_Object str;
-  char *string_start = NULL;
+  int string_start = 0;
 
   if (NILP (window))
     window = selected_window;
@@ -16343,7 +16347,7 @@
       mode_line_target = MODE_LINE_NOPROP;
       mode_line_string_face_prop = Qnil;
       mode_line_string_list = Qnil;
-      string_start = mode_line_noprop_ptr;
+      string_start = MODE_LINE_NOPROP_LEN (0);
     }
   else
     {
@@ -16352,8 +16356,6 @@
       mode_line_string_face = face;
       mode_line_string_face_prop
 	= (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil)));
-
-      string_start = NULL;
     }
 
   push_frame_kboard (it.f);
@@ -16362,8 +16364,8 @@
 
   if (no_props)
     {
-      len = mode_line_noprop_ptr - string_start;
-      str = make_string (string_start, len);
+      len = MODE_LINE_NOPROP_LEN (string_start);
+      str = make_string (mode_line_noprop_buf + string_start, len);
     }
   else
     {