aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-07-27 17:15:43 -0700
committerPaul Eggert2011-07-27 17:15:43 -0700
commit2573a8376a387d19af355f68622512ac3e07d57a (patch)
tree1ffa01d9e12395ebbb8c3f3181d3b9ffdc8c1487 /src
parent49b602e24ecb3fe085d45ac385e1bfda82252090 (diff)
parentdbf38e02c9ade4979418f24a99962cfef170b957 (diff)
downloademacs-2573a8376a387d19af355f68622512ac3e07d57a.tar.gz
emacs-2573a8376a387d19af355f68622512ac3e07d57a.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog97
-rw-r--r--src/bidi.c2
-rw-r--r--src/editfns.c7
-rw-r--r--src/frame.c8
-rw-r--r--src/gnutls.c3
-rw-r--r--src/nsmenu.m10
-rw-r--r--src/nsterm.m3
-rw-r--r--src/xdisp.c194
-rw-r--r--src/xfaces.c3
-rw-r--r--src/xfns.c2
-rw-r--r--src/xml.c28
11 files changed, 307 insertions, 50 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b72de32ffc3..10f6e326891 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,4 @@
12011-07-19 Paul Eggert <eggert@cs.ucla.edu> 12011-07-28 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Integer signedness and overflow and related fixes. (Bug#9079) 3 Integer signedness and overflow and related fixes. (Bug#9079)
4 4
@@ -197,6 +197,101 @@
197 Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally 197 Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally
198 well either way, and we prefer signed to unsigned. 198 well either way, and we prefer signed to unsigned.
199 199
2002011-07-27 Lars Magne Ingebrigtsen <larsi@gnus.org>
201
202 * gnutls.c (emacs_gnutls_read): Don't message anything if the peer
203 closes the connection while we're reading (bug#9182).
204
2052011-07-25 Jan Djärv <jan.h.d@swipnet.se>
206
207 * nsmenu.m (ns_popup_dialog): Add an "ok" button if no buttons
208 are specified (Bug#9168).
209
2102011-07-25 Paul Eggert <eggert@cs.ucla.edu>
211
212 * bidi.c (bidi_dump_cached_states): Fix printf format mismatch.
213 Found by GCC static checking and --with-wide-int on a 32-bit host.
214
2152011-07-25 Eli Zaretskii <eliz@gnu.org>
216
217 * xdisp.c (compute_display_string_pos): Fix logic of caching
218 previous display string position. Initialize cached_prev_pos to
219 -1. Fixes slow-down at the beginning of a buffer.
220
2212011-07-24 Eli Zaretskii <eliz@gnu.org>
222
223 * xfaces.c (check_lface_attrs) [HAVE_WINDOW_SYSTEM]: Allow `nil'
224 for attrs[LFACE_FONTSET_INDEX].
225
2262011-07-23 Paul Eggert <eggert@cs.ucla.edu>
227
228 * xml.c (parse_region): Remove unused local
229 that was recently introduced.
230
2312011-07-23 Eli Zaretskii <eliz@gnu.org>
232
233 * xfns.c (unwind_create_frame) [GLYPH_DEBUG]: Adapt to changes in
234 2008-02-22T17:42:09Z!monnier@iro.umontreal.ca.
235
236 * xdisp.c (move_it_in_display_line_to): Record the best matching
237 position for TO_CHARPOS while scanning the line, and restore it on
238 exit if none of the characters scanned was an exact match. Fixes
239 vertical-motion and pos-visible-in-window-p under bidi redisplay
240 when exact match is impossible due to invisible text, and the
241 lines are truncated.
242
2432011-07-23 Jan Djärv <jan.h.d@swipnet.se>
244
245 * nsterm.m (initFrameFromEmacs): Set NSTitledWindowMask in styleMask
246 for OSX >= 10.7.
247
2482011-07-22 Eli Zaretskii <eliz@gnu.org>
249
250 Fix a significant slow-down of cursor motion with C-n, C-p,
251 C-f/C-b, and C-v/M-v that couldn't keep up with keyboard
252 auto-repeat under bidi redisplay in fontified buffers.
253 * xdisp.c (compute_stop_pos_backwards): New function.
254 (next_element_from_buffer): Call compute_stop_pos_backwards to
255 find a suitable prev_stop when we find ourselves before
256 base_level_stop.
257 (reseat): Don't look for prev_stop, as that could mean a very long
258 run.
259 <cached_disp_pos, cached_disp_buffer, cached_disp_modiff>
260 <cached_disp_overlay_modiff>: Cache for last found display string
261 position.
262 (compute_display_string_pos): Return the cached position if asked
263 about the same buffer in the same area of character positions, and
264 the buffer wasn't changed since the time the display string
265 position was cached.
266
2672011-07-22 Eli Zaretskii <eliz@gnu.org>
268
269 * xdisp.c (rows_from_pos_range): Don't ignore glyphs whose object
270 is an integer, which is important for empty lines. (Bug#9149)
271
2722011-07-22 Chong Yidong <cyd@stupidchicken.com>
273
274 * frame.c (Fmodify_frame_parameters): In tty case, update the
275 default face if necessary (Bug#4238).
276
2772011-07-21 Chong Yidong <cyd@stupidchicken.com>
278
279 * editfns.c (Fstring_to_char): No need to explain what a character
280 is in the docstring (Bug#6576).
281
2822011-07-20 Lars Magne Ingebrigtsen <larsi@gnus.org>
283
284 * xml.c (parse_region): Make sure we always return a tree.
285
2862011-07-20 HAMANO Kiyoto <khiker.mail@gmail.com>
287
288 * xml.c (parse_region): If a document contains only comments,
289 return that, too.
290
2912011-07-20 Lars Magne Ingebrigtsen <larsi@gnus.org>
292
293 * xml.c (make_dom): Return comments, too.
294
2002011-07-19 Paul Eggert <eggert@cs.ucla.edu> 2952011-07-19 Paul Eggert <eggert@cs.ucla.edu>
201 296
202 Port to OpenBSD. 297 Port to OpenBSD.
diff --git a/src/bidi.c b/src/bidi.c
index 697ebb92856..a6af9e36e15 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -2319,7 +2319,7 @@ bidi_dump_cached_states (void)
2319 fprintf (stderr, "The cache is empty.\n"); 2319 fprintf (stderr, "The cache is empty.\n");
2320 return; 2320 return;
2321 } 2321 }
2322 fprintf (stderr, "Total of %"pD"d state%s in cache:\n", 2322 fprintf (stderr, "Total of %"pI"d state%s in cache:\n",
2323 bidi_cache_idx, bidi_cache_idx == 1 ? "" : "s"); 2323 bidi_cache_idx, bidi_cache_idx == 1 ? "" : "s");
2324 2324
2325 for (i = bidi_cache[bidi_cache_idx - 1].charpos; i > 0; i /= 10) 2325 for (i = bidi_cache[bidi_cache_idx - 1].charpos; i > 0; i /= 10)
diff --git a/src/editfns.c b/src/editfns.c
index 18fefa5e3b5..577263c5aea 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -194,12 +194,7 @@ DEFUN ("byte-to-string", Fbyte_to_string, Sbyte_to_string, 1, 1, 0,
194} 194}
195 195
196DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, 196DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0,
197 doc: /* Return the first character in STRING. 197 doc: /* Return the first character in STRING. */)
198A multibyte character is handled correctly.
199The value returned is a Unicode codepoint if it is below #x110000 (in
200hex). Codepoints beyond that are Emacs extensions of Unicode. In
201particular, eight-bit characters are returned as codepoints in the
202range #x3FFF80 through #x3FFFFF, inclusive. */)
203 (register Lisp_Object string) 198 (register Lisp_Object string)
204{ 199{
205 register Lisp_Object val; 200 register Lisp_Object val;
diff --git a/src/frame.c b/src/frame.c
index 635996ca424..19ce78dfd9c 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2437,11 +2437,9 @@ use is not recommended. Explicitly check for a frame-parameter instead. */)
2437 val = values[i]; 2437 val = values[i];
2438 store_frame_param (f, prop, val); 2438 store_frame_param (f, prop, val);
2439 2439
2440 /* Changing the background color might change the background 2440 if (EQ (prop, Qforeground_color)
2441 mode, so that we have to load new defface specs. 2441 || EQ (prop, Qbackground_color))
2442 Call frame-set-background-mode to do that. */ 2442 update_face_from_frame_parameter (f, prop, val);
2443 if (EQ (prop, Qbackground_color))
2444 call1 (Qframe_set_background_mode, frame);
2445 } 2443 }
2446 } 2444 }
2447 return Qnil; 2445 return Qnil;
diff --git a/src/gnutls.c b/src/gnutls.c
index 3175f55041d..fc651d2c7e4 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -382,6 +382,9 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, EMACS_INT nbyte)
382 rtnval = fn_gnutls_record_recv (state, buf, nbyte); 382 rtnval = fn_gnutls_record_recv (state, buf, nbyte);
383 if (rtnval >= 0) 383 if (rtnval >= 0)
384 return rtnval; 384 return rtnval;
385 else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
386 /* The peer closed the connection. */
387 return 0;
385 else if (emacs_gnutls_handle_error (state, rtnval) == 0) 388 else if (emacs_gnutls_handle_error (state, rtnval) == 0)
386 /* non-fatal error */ 389 /* non-fatal error */
387 return -1; 390 return -1;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 6a9ee7dd4f5..6931b7a3c01 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1340,7 +1340,7 @@ Lisp_Object
1340ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) 1340ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1341{ 1341{
1342 id dialog; 1342 id dialog;
1343 Lisp_Object window, tem; 1343 Lisp_Object window, tem, title;
1344 struct frame *f; 1344 struct frame *f;
1345 NSPoint p; 1345 NSPoint p;
1346 BOOL isQ; 1346 BOOL isQ;
@@ -1389,6 +1389,14 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1389 p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2; 1389 p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2;
1390 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; 1390 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2;
1391 1391
1392 title = Fcar (contents);
1393 CHECK_STRING (title);
1394
1395 if (NILP (Fcar (Fcdr (contents))))
1396 /* No buttons specified, add an "Ok" button so users can pop down
1397 the dialog. */
1398 contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil));
1399
1392 BLOCK_INPUT; 1400 BLOCK_INPUT;
1393 dialog = [[EmacsDialogPanel alloc] initFromContents: contents 1401 dialog = [[EmacsDialogPanel alloc] initFromContents: contents
1394 isQuestion: isQ]; 1402 isQuestion: isQ];
diff --git a/src/nsterm.m b/src/nsterm.m
index 546247ab74a..e45dc1a902d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5304,6 +5304,9 @@ ns_term_shutdown (int sig)
5304 win = [[EmacsWindow alloc] 5304 win = [[EmacsWindow alloc]
5305 initWithContentRect: r 5305 initWithContentRect: r
5306 styleMask: (NSResizableWindowMask | 5306 styleMask: (NSResizableWindowMask |
5307#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
5308 NSTitledWindowMask |
5309#endif
5307 NSMiniaturizableWindowMask | 5310 NSMiniaturizableWindowMask |
5308 NSClosableWindowMask) 5311 NSClosableWindowMask)
5309 backing: NSBackingStoreBuffered 5312 backing: NSBackingStoreBuffered
diff --git a/src/xdisp.c b/src/xdisp.c
index 137cbec497c..8f352561719 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3134,6 +3134,14 @@ next_overlay_change (EMACS_INT pos)
3134 return endpos; 3134 return endpos;
3135} 3135}
3136 3136
3137/* Record one cached display string position found recently by
3138 compute_display_string_pos. */
3139static EMACS_INT cached_disp_pos;
3140static EMACS_INT cached_prev_pos = -1;
3141static struct buffer *cached_disp_buffer;
3142static int cached_disp_modiff;
3143static int cached_disp_overlay_modiff;
3144
3137/* Return the character position of a display string at or after 3145/* Return the character position of a display string at or after
3138 position specified by POSITION. If no display string exists at or 3146 position specified by POSITION. If no display string exists at or
3139 after POSITION, return ZV. A display string is either an overlay 3147 after POSITION, return ZV. A display string is either an overlay
@@ -3155,6 +3163,7 @@ compute_display_string_pos (struct text_pos *position,
3155 EMACS_INT begb = string_p ? 0 : BEGV; 3163 EMACS_INT begb = string_p ? 0 : BEGV;
3156 EMACS_INT bufpos, charpos = CHARPOS (*position); 3164 EMACS_INT bufpos, charpos = CHARPOS (*position);
3157 struct text_pos tpos; 3165 struct text_pos tpos;
3166 struct buffer *b;
3158 3167
3159 if (charpos >= eob 3168 if (charpos >= eob
3160 /* We don't support display properties whose values are strings 3169 /* We don't support display properties whose values are strings
@@ -3164,6 +3173,37 @@ compute_display_string_pos (struct text_pos *position,
3164 || (string->s && !STRINGP (object))) 3173 || (string->s && !STRINGP (object)))
3165 return eob; 3174 return eob;
3166 3175
3176 /* Check the cached values. */
3177 if (!STRINGP (object))
3178 {
3179 if (NILP (object))
3180 b = current_buffer;
3181 else
3182 b = XBUFFER (object);
3183 if (b == cached_disp_buffer
3184 && BUF_MODIFF (b) == cached_disp_modiff
3185 && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff)
3186 {
3187 if (cached_prev_pos >= 0
3188 && cached_prev_pos < charpos && charpos <= cached_disp_pos)
3189 return cached_disp_pos;
3190 /* Handle overstepping either end of the known interval. */
3191 if (charpos > cached_disp_pos)
3192 cached_prev_pos = cached_disp_pos;
3193 else /* charpos <= cached_prev_pos */
3194 cached_prev_pos = max (charpos - 1, 0);
3195 }
3196
3197 /* Record new values in the cache. */
3198 if (b != cached_disp_buffer)
3199 {
3200 cached_disp_buffer = b;
3201 cached_prev_pos = max (charpos - 1, 0);
3202 }
3203 cached_disp_modiff = BUF_MODIFF (b);
3204 cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b);
3205 }
3206
3167 /* If the character at CHARPOS is where the display string begins, 3207 /* If the character at CHARPOS is where the display string begins,
3168 return CHARPOS. */ 3208 return CHARPOS. */
3169 pos = make_number (charpos); 3209 pos = make_number (charpos);
@@ -3179,7 +3219,11 @@ compute_display_string_pos (struct text_pos *position,
3179 spec)) 3219 spec))
3180 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, 3220 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3181 frame_window_p)) 3221 frame_window_p))
3182 return charpos; 3222 {
3223 if (!STRINGP (object))
3224 cached_disp_pos = charpos;
3225 return charpos;
3226 }
3183 3227
3184 /* Look forward for the first character with a `display' property 3228 /* Look forward for the first character with a `display' property
3185 that will replace the underlying text when displayed. */ 3229 that will replace the underlying text when displayed. */
@@ -3199,6 +3243,8 @@ compute_display_string_pos (struct text_pos *position,
3199 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, 3243 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3200 frame_window_p)); 3244 frame_window_p));
3201 3245
3246 if (!STRINGP (object))
3247 cached_disp_pos = CHARPOS (tpos);
3202 return CHARPOS (tpos); 3248 return CHARPOS (tpos);
3203} 3249}
3204 3250
@@ -5731,17 +5777,19 @@ reseat (struct it *it, struct text_pos pos, int force_p)
5731 { 5777 {
5732 /* For bidi iteration, we need to prime prev_stop and 5778 /* For bidi iteration, we need to prime prev_stop and
5733 base_level_stop with our best estimations. */ 5779 base_level_stop with our best estimations. */
5734 if (CHARPOS (pos) < it->prev_stop) 5780 /* Implementation note: Of course, POS is not necessarily a
5735 { 5781 stop position, so assigning prev_pos to it is a lie; we
5736 handle_stop_backwards (it, BEGV); 5782 should have called compute_stop_backwards. However, if
5737 if (CHARPOS (pos) < it->base_level_stop) 5783 the current buffer does not include any R2L characters,
5738 it->base_level_stop = 0; 5784 that call would be a waste of cycles, because the
5739 } 5785 iterator will never move back, and thus never cross this
5740 else if (CHARPOS (pos) > it->stop_charpos 5786 "fake" stop position. So we delay that backward search
5741 && it->stop_charpos >= BEGV) 5787 until the time we really need it, in next_element_from_buffer. */
5742 handle_stop_backwards (it, it->stop_charpos); 5788 if (CHARPOS (pos) != it->prev_stop)
5743 else /* force_p */ 5789 it->prev_stop = CHARPOS (pos);
5744 handle_stop (it); 5790 if (CHARPOS (pos) < it->base_level_stop)
5791 it->base_level_stop = 0; /* meaning it's unknown */
5792 handle_stop (it);
5745 } 5793 }
5746 else 5794 else
5747 { 5795 {
@@ -7008,10 +7056,10 @@ next_element_from_string (struct it *it)
7008 embedding level, so test for that explicitly. */ 7056 embedding level, so test for that explicitly. */
7009 && !BIDI_AT_BASE_LEVEL (it->bidi_it)) 7057 && !BIDI_AT_BASE_LEVEL (it->bidi_it))
7010 { 7058 {
7011 /* If we lost track of base_level_stop, we have no better place 7059 /* If we lost track of base_level_stop, we have no better
7012 for handle_stop_backwards to start from than BEGV. This 7060 place for handle_stop_backwards to start from than string
7013 happens, e.g., when we were reseated to the previous 7061 beginning. This happens, e.g., when we were reseated to
7014 screenful of text by vertical-motion. */ 7062 the previous screenful of text by vertical-motion. */
7015 if (it->base_level_stop <= 0 7063 if (it->base_level_stop <= 0
7016 || IT_STRING_CHARPOS (*it) < it->base_level_stop) 7064 || IT_STRING_CHARPOS (*it) < it->base_level_stop)
7017 it->base_level_stop = 0; 7065 it->base_level_stop = 0;
@@ -7199,6 +7247,50 @@ next_element_from_stretch (struct it *it)
7199 return 1; 7247 return 1;
7200} 7248}
7201 7249
7250/* Scan backwards from IT's current position until we find a stop
7251 position, or until BEGV. This is called when we find ourself
7252 before both the last known prev_stop and base_level_stop while
7253 reordering bidirectional text. */
7254
7255static void
7256compute_stop_pos_backwards (struct it *it)
7257{
7258 const int SCAN_BACK_LIMIT = 1000;
7259 struct text_pos pos;
7260 struct display_pos save_current = it->current;
7261 struct text_pos save_position = it->position;
7262 EMACS_INT charpos = IT_CHARPOS (*it);
7263 EMACS_INT where_we_are = charpos;
7264 EMACS_INT save_stop_pos = it->stop_charpos;
7265 EMACS_INT save_end_pos = it->end_charpos;
7266
7267 xassert (NILP (it->string) && !it->s);
7268 xassert (it->bidi_p);
7269 it->bidi_p = 0;
7270 do
7271 {
7272 it->end_charpos = min (charpos + 1, ZV);
7273 charpos = max (charpos - SCAN_BACK_LIMIT, BEGV);
7274 SET_TEXT_POS (pos, charpos, BYTE_TO_CHAR (charpos));
7275 reseat_1 (it, pos, 0);
7276 compute_stop_pos (it);
7277 /* We must advance forward, right? */
7278 if (it->stop_charpos <= charpos)
7279 abort ();
7280 }
7281 while (charpos > BEGV && it->stop_charpos >= it->end_charpos);
7282
7283 if (it->stop_charpos <= where_we_are)
7284 it->prev_stop = it->stop_charpos;
7285 else
7286 it->prev_stop = BEGV;
7287 it->bidi_p = 1;
7288 it->current = save_current;
7289 it->position = save_position;
7290 it->stop_charpos = save_stop_pos;
7291 it->end_charpos = save_end_pos;
7292}
7293
7202/* Scan forward from CHARPOS in the current buffer/string, until we 7294/* Scan forward from CHARPOS in the current buffer/string, until we
7203 find a stop position > current IT's position. Then handle the stop 7295 find a stop position > current IT's position. Then handle the stop
7204 position before that. This is called when we bump into a stop 7296 position before that. This is called when we bump into a stop
@@ -7218,6 +7310,7 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7218 EMACS_INT next_stop; 7310 EMACS_INT next_stop;
7219 7311
7220 /* Scan in strict logical order. */ 7312 /* Scan in strict logical order. */
7313 xassert (it->bidi_p);
7221 it->bidi_p = 0; 7314 it->bidi_p = 0;
7222 do 7315 do
7223 { 7316 {
@@ -7237,11 +7330,11 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7237 } 7330 }
7238 while (charpos <= where_we_are); 7331 while (charpos <= where_we_are);
7239 7332
7240 next_stop = it->stop_charpos;
7241 it->stop_charpos = it->prev_stop;
7242 it->bidi_p = 1; 7333 it->bidi_p = 1;
7243 it->current = save_current; 7334 it->current = save_current;
7244 it->position = save_position; 7335 it->position = save_position;
7336 next_stop = it->stop_charpos;
7337 it->stop_charpos = it->prev_stop;
7245 handle_stop (it); 7338 handle_stop (it);
7246 it->stop_charpos = next_stop; 7339 it->stop_charpos = next_stop;
7247} 7340}
@@ -7338,14 +7431,19 @@ next_element_from_buffer (struct it *it)
7338 embedding level, so test for that explicitly. */ 7431 embedding level, so test for that explicitly. */
7339 && !BIDI_AT_BASE_LEVEL (it->bidi_it)) 7432 && !BIDI_AT_BASE_LEVEL (it->bidi_it))
7340 { 7433 {
7341 /* If we lost track of base_level_stop, we have no better place
7342 for handle_stop_backwards to start from than BEGV. This
7343 happens, e.g., when we were reseated to the previous
7344 screenful of text by vertical-motion. */
7345 if (it->base_level_stop <= 0 7434 if (it->base_level_stop <= 0
7346 || IT_CHARPOS (*it) < it->base_level_stop) 7435 || IT_CHARPOS (*it) < it->base_level_stop)
7347 it->base_level_stop = BEGV; 7436 {
7348 handle_stop_backwards (it, it->base_level_stop); 7437 /* If we lost track of base_level_stop, we need to find
7438 prev_stop by looking backwards. This happens, e.g., when
7439 we were reseated to the previous screenful of text by
7440 vertical-motion. */
7441 it->base_level_stop = BEGV;
7442 compute_stop_pos_backwards (it);
7443 handle_stop_backwards (it, it->prev_stop);
7444 }
7445 else
7446 handle_stop_backwards (it, it->base_level_stop);
7349 return GET_NEXT_DISPLAY_ELEMENT (it); 7447 return GET_NEXT_DISPLAY_ELEMENT (it);
7350 } 7448 }
7351 else 7449 else
@@ -7547,8 +7645,9 @@ move_it_in_display_line_to (struct it *it,
7547{ 7645{
7548 enum move_it_result result = MOVE_UNDEFINED; 7646 enum move_it_result result = MOVE_UNDEFINED;
7549 struct glyph_row *saved_glyph_row; 7647 struct glyph_row *saved_glyph_row;
7550 struct it wrap_it, atpos_it, atx_it; 7648 struct it wrap_it, atpos_it, atx_it, ppos_it;
7551 void *wrap_data = NULL, *atpos_data = NULL, *atx_data = NULL; 7649 void *wrap_data = NULL, *atpos_data = NULL, *atx_data = NULL;
7650 void *ppos_data = NULL;
7552 int may_wrap = 0; 7651 int may_wrap = 0;
7553 enum it_method prev_method = it->method; 7652 enum it_method prev_method = it->method;
7554 EMACS_INT prev_pos = IT_CHARPOS (*it); 7653 EMACS_INT prev_pos = IT_CHARPOS (*it);
@@ -7567,6 +7666,19 @@ move_it_in_display_line_to (struct it *it,
7567 atpos_it.sp = -1; 7666 atpos_it.sp = -1;
7568 atx_it.sp = -1; 7667 atx_it.sp = -1;
7569 7668
7669 /* Use ppos_it under bidi reordering to save a copy of IT for the
7670 position > CHARPOS that is the closest to CHARPOS. We restore
7671 that position in IT when we have scanned the entire display line
7672 without finding a match for CHARPOS and all the character
7673 positions are greater than CHARPOS. */
7674 if (it->bidi_p)
7675 {
7676 SAVE_IT (ppos_it, *it, ppos_data);
7677 SET_TEXT_POS (ppos_it.current.pos, ZV, ZV_BYTE);
7678 if ((op & MOVE_TO_POS) && IT_CHARPOS (*it) >= to_charpos)
7679 SAVE_IT (ppos_it, *it, ppos_data);
7680 }
7681
7570#define BUFFER_POS_REACHED_P() \ 7682#define BUFFER_POS_REACHED_P() \
7571 ((op & MOVE_TO_POS) != 0 \ 7683 ((op & MOVE_TO_POS) != 0 \
7572 && BUFFERP (it->object) \ 7684 && BUFFERP (it->object) \
@@ -7692,6 +7804,11 @@ move_it_in_display_line_to (struct it *it,
7692 if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos)) 7804 if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos))
7693 SET_TEXT_POS (this_line_min_pos, 7805 SET_TEXT_POS (this_line_min_pos,
7694 IT_CHARPOS (*it), IT_BYTEPOS (*it)); 7806 IT_CHARPOS (*it), IT_BYTEPOS (*it));
7807 if (it->bidi_p
7808 && (op & MOVE_TO_POS)
7809 && IT_CHARPOS (*it) > to_charpos
7810 && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it))
7811 SAVE_IT (ppos_it, *it, ppos_data);
7695 continue; 7812 continue;
7696 } 7813 }
7697 7814
@@ -7902,7 +8019,11 @@ move_it_in_display_line_to (struct it *it,
7902 if ((op & MOVE_TO_POS) != 0 8019 if ((op & MOVE_TO_POS) != 0
7903 && !saw_smaller_pos 8020 && !saw_smaller_pos
7904 && IT_CHARPOS (*it) > to_charpos) 8021 && IT_CHARPOS (*it) > to_charpos)
7905 result = MOVE_POS_MATCH_OR_ZV; 8022 {
8023 result = MOVE_POS_MATCH_OR_ZV;
8024 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8025 RESTORE_IT (it, &ppos_it, ppos_data);
8026 }
7906 else 8027 else
7907 result = MOVE_NEWLINE_OR_CR; 8028 result = MOVE_NEWLINE_OR_CR;
7908 break; 8029 break;
@@ -7918,6 +8039,11 @@ move_it_in_display_line_to (struct it *it,
7918 SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it)); 8039 SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it));
7919 if (IT_CHARPOS (*it) < to_charpos) 8040 if (IT_CHARPOS (*it) < to_charpos)
7920 saw_smaller_pos = 1; 8041 saw_smaller_pos = 1;
8042 if (it->bidi_p
8043 && (op & MOVE_TO_POS)
8044 && IT_CHARPOS (*it) >= to_charpos
8045 && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it))
8046 SAVE_IT (ppos_it, *it, ppos_data);
7921 8047
7922 /* Stop if lines are truncated and IT's current x-position is 8048 /* Stop if lines are truncated and IT's current x-position is
7923 past the right edge of the window now. */ 8049 past the right edge of the window now. */
@@ -7927,7 +8053,9 @@ move_it_in_display_line_to (struct it *it,
7927 if (!FRAME_WINDOW_P (it->f) 8053 if (!FRAME_WINDOW_P (it->f)
7928 || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 8054 || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
7929 { 8055 {
7930 if (!get_next_display_element (it) 8056 int at_eob_p = 0;
8057
8058 if ((at_eob_p = !get_next_display_element (it))
7931 || BUFFER_POS_REACHED_P () 8059 || BUFFER_POS_REACHED_P ()
7932 /* If we are past TO_CHARPOS, but never saw any 8060 /* If we are past TO_CHARPOS, but never saw any
7933 character positions smaller than TO_CHARPOS, 8061 character positions smaller than TO_CHARPOS,
@@ -7938,6 +8066,8 @@ move_it_in_display_line_to (struct it *it,
7938 && IT_CHARPOS (*it) > to_charpos)) 8066 && IT_CHARPOS (*it) > to_charpos))
7939 { 8067 {
7940 result = MOVE_POS_MATCH_OR_ZV; 8068 result = MOVE_POS_MATCH_OR_ZV;
8069 if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV)
8070 RESTORE_IT (it, &ppos_it, ppos_data);
7941 break; 8071 break;
7942 } 8072 }
7943 if (ITERATOR_AT_END_OF_LINE_P (it)) 8073 if (ITERATOR_AT_END_OF_LINE_P (it))
@@ -7951,6 +8081,8 @@ move_it_in_display_line_to (struct it *it,
7951 && IT_CHARPOS (*it) > to_charpos) 8081 && IT_CHARPOS (*it) > to_charpos)
7952 { 8082 {
7953 result = MOVE_POS_MATCH_OR_ZV; 8083 result = MOVE_POS_MATCH_OR_ZV;
8084 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8085 RESTORE_IT (it, &ppos_it, ppos_data);
7954 break; 8086 break;
7955 } 8087 }
7956 result = MOVE_LINE_TRUNCATED; 8088 result = MOVE_LINE_TRUNCATED;
@@ -7976,6 +8108,8 @@ move_it_in_display_line_to (struct it *it,
7976 xfree (atx_data); 8108 xfree (atx_data);
7977 if (wrap_data) 8109 if (wrap_data)
7978 xfree (wrap_data); 8110 xfree (wrap_data);
8111 if (ppos_data)
8112 xfree (ppos_data);
7979 8113
7980 /* Restore the iterator settings altered at the beginning of this 8114 /* Restore the iterator settings altered at the beginning of this
7981 function. */ 8115 function. */
@@ -23126,7 +23260,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
23126 base_width = font->average_width; 23260 base_width = font->average_width;
23127 23261
23128 /* Get a face ID for the glyph by utilizing a cache (the same way as 23262 /* Get a face ID for the glyph by utilizing a cache (the same way as
23129 doen for `escape-glyph' in get_next_display_element). */ 23263 done for `escape-glyph' in get_next_display_element). */
23130 if (it->f == last_glyphless_glyph_frame 23264 if (it->f == last_glyphless_glyph_frame
23131 && it->face_id == last_glyphless_glyph_face_id) 23265 && it->face_id == last_glyphless_glyph_face_id)
23132 { 23266 {
@@ -25029,7 +25163,7 @@ rows_from_pos_range (struct window *w,
25029 25163
25030 while (g < e) 25164 while (g < e)
25031 { 25165 {
25032 if (BUFFERP (g->object) 25166 if ((BUFFERP (g->object) || INTEGERP (g->object))
25033 && start_charpos <= g->charpos && g->charpos < end_charpos) 25167 && start_charpos <= g->charpos && g->charpos < end_charpos)
25034 *start = row; 25168 *start = row;
25035 g++; 25169 g++;
@@ -25079,7 +25213,7 @@ rows_from_pos_range (struct window *w,
25079 25213
25080 while (g < e) 25214 while (g < e)
25081 { 25215 {
25082 if (BUFFERP (g->object) 25216 if ((BUFFERP (g->object) || INTEGERP (g->object))
25083 && start_charpos <= g->charpos && g->charpos < end_charpos) 25217 && start_charpos <= g->charpos && g->charpos < end_charpos)
25084 break; 25218 break;
25085 g++; 25219 g++;
diff --git a/src/xfaces.c b/src/xfaces.c
index e0dc2883f33..52b125b42e6 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1920,7 +1920,8 @@ check_lface_attrs (Lisp_Object *attrs)
1920 || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX]) 1920 || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX])
1921 || FONTP (attrs[LFACE_FONT_INDEX])); 1921 || FONTP (attrs[LFACE_FONT_INDEX]));
1922 xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX]) 1922 xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
1923 || STRINGP (attrs[LFACE_FONTSET_INDEX])); 1923 || STRINGP (attrs[LFACE_FONTSET_INDEX])
1924 || NILP (attrs[LFACE_FONTSET_INDEX]));
1924#endif 1925#endif
1925} 1926}
1926 1927
diff --git a/src/xfns.c b/src/xfns.c
index 0d1e4a1bb5e..eec19b9d275 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2933,7 +2933,7 @@ unwind_create_frame (Lisp_Object frame)
2933#if GLYPH_DEBUG 2933#if GLYPH_DEBUG
2934 /* Check that reference counts are indeed correct. */ 2934 /* Check that reference counts are indeed correct. */
2935 xassert (dpyinfo->reference_count == dpyinfo_refcount); 2935 xassert (dpyinfo->reference_count == dpyinfo_refcount);
2936 xassert (dpyinfo->image_cache->refcount == image_cache_refcount); 2936 xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
2937#endif 2937#endif
2938 return Qt; 2938 return Qt;
2939 } 2939 }
diff --git a/src/xml.c b/src/xml.c
index 63041c96b24..55352baae3a 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -71,6 +71,14 @@ make_dom (xmlNode *node)
71 else 71 else
72 return Qnil; 72 return Qnil;
73 } 73 }
74 else if (node->type == XML_COMMENT_NODE)
75 {
76 if (node->content)
77 return list3 (intern ("comment"), Qnil,
78 build_string ((char *) node->content));
79 else
80 return Qnil;
81 }
74 else 82 else
75 return Qnil; 83 return Qnil;
76} 84}
@@ -79,7 +87,6 @@ static Lisp_Object
79parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp) 87parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp)
80{ 88{
81 xmlDoc *doc; 89 xmlDoc *doc;
82 xmlNode *node;
83 Lisp_Object result = Qnil; 90 Lisp_Object result = Qnil;
84 const char *burl = ""; 91 const char *burl = "";
85 EMACS_INT bytes; 92 EMACS_INT bytes;
@@ -117,9 +124,22 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
117 124
118 if (doc != NULL) 125 if (doc != NULL)
119 { 126 {
120 node = xmlDocGetRootElement (doc); 127 xmlNode *n = doc->children->next;
121 if (node != NULL) 128 Lisp_Object r = Qnil;
122 result = make_dom (node); 129
130 while (n) {
131 if (!NILP (r))
132 result = Fcons (r, result);
133 r = make_dom (n);
134 n = n->next;
135 }
136
137 if (NILP (result))
138 result = r;
139 else
140 result = Fcons (intern ("top"),
141 Fcons (Qnil, Fnreverse (Fcons (r, result))));
142
123 xmlFreeDoc (doc); 143 xmlFreeDoc (doc);
124 xmlCleanupParser (); 144 xmlCleanupParser ();
125 } 145 }