Now on revision 109798. ------------------------------------------------------------ revno: 109798 committer: Dmitry Antipov branch nick: trunk timestamp: Tue 2012-08-28 10:20:08 +0400 message: Always use set_buffer_if_live to restore original buffer at unwind. * buffer.h (record_unwind_current_buffer): New function. * bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c: * keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c: * undo.c, window.c: Adjust users. * buffer.c (set_buffer_if_live): Fix comment. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-28 05:49:02 +0000 +++ src/ChangeLog 2012-08-28 06:20:08 +0000 @@ -1,5 +1,14 @@ 2012-08-28 Dmitry Antipov + Always use set_buffer_if_live to restore original buffer at unwind. + * buffer.h (record_unwind_current_buffer): New function. + * bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c: + * keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c: + * undo.c, window.c: Adjust users. + * buffer.c (set_buffer_if_live): Fix comment. + +2012-08-28 Dmitry Antipov + Fix usage of set_buffer_internal. * buffer.h (set_buffer_internal): Make it BUFFER_INLINE. * buffer.c (set_buffer_if_live): Use set_buffer_internal. === modified file 'src/buffer.c' --- src/buffer.c 2012-08-28 05:49:02 +0000 +++ src/buffer.c 2012-08-28 06:20:08 +0000 @@ -2204,7 +2204,7 @@ return buffer; } -/* Set the current buffer to BUFFER provided it is alive. */ +/* Set the current buffer to BUFFER provided if it is alive. */ Lisp_Object set_buffer_if_live (Lisp_Object buffer) === modified file 'src/buffer.h' --- src/buffer.h 2012-08-28 05:49:02 +0000 +++ src/buffer.h 2012-08-28 06:20:08 +0000 @@ -1038,6 +1038,15 @@ set_buffer_internal_1 (b); } +/* Arrange to go back to the original buffer after the next + call to unbind_to if the original buffer is still alive. */ + +BUFFER_INLINE void +record_unwind_current_buffer (void) +{ + record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); +} + /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. If NEXTP is non-NULL, return next overlay there. See overlay_at arg CHANGE_REQ for meaning of CHRQ arg. */ === modified file 'src/bytecode.c' --- src/bytecode.c 2012-08-25 03:11:12 +0000 +++ src/bytecode.c 2012-08-28 06:20:08 +0000 @@ -1051,7 +1051,7 @@ CASE (Bsave_current_buffer): /* Obsolete since ??. */ CASE (Bsave_current_buffer_1): - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + record_unwind_current_buffer (); NEXT; CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ === modified file 'src/dispnew.c' --- src/dispnew.c 2012-08-28 00:33:56 +0000 +++ src/dispnew.c 2012-08-28 06:20:08 +0000 @@ -5762,7 +5762,7 @@ UNBLOCK_INPUT; - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); run_window_configuration_change_hook (f); === modified file 'src/editfns.c' --- src/editfns.c 2012-08-21 23:39:56 +0000 +++ src/editfns.c 2012-08-28 06:20:08 +0000 @@ -946,13 +946,10 @@ usage: (save-current-buffer &rest BODY) */) (Lisp_Object args) { - Lisp_Object val; ptrdiff_t count = SPECPDL_INDEX (); - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); - - val = Fprogn (args); - return unbind_to (count, val); + record_unwind_current_buffer (); + return unbind_to (count, Fprogn (args)); } DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, === modified file 'src/fileio.c' --- src/fileio.c 2012-08-28 05:49:02 +0000 +++ src/fileio.c 2012-08-28 06:20:08 +0000 @@ -3480,7 +3480,7 @@ Lisp_Object workbuf; struct buffer *buf; - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); workbuf = Fget_buffer_create (build_string (" *code-converting-work*")); buf = XBUFFER (workbuf); === modified file 'src/fns.c' --- src/fns.c 2012-08-28 05:49:02 +0000 +++ src/fns.c 2012-08-28 06:20:08 +0000 @@ -4656,7 +4656,7 @@ { struct buffer *prev = current_buffer; - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); CHECK_BUFFER (object); === modified file 'src/insdel.c' --- src/insdel.c 2012-08-28 05:49:02 +0000 +++ src/insdel.c 2012-08-28 06:20:08 +0000 @@ -2117,7 +2117,7 @@ return Qnil; } - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (combine_after_change_buffer); === modified file 'src/keyboard.c' --- src/keyboard.c 2012-08-28 05:49:02 +0000 +++ src/keyboard.c 2012-08-28 06:20:08 +0000 @@ -9572,7 +9572,7 @@ because we may get input from a subprocess which wants to change the selected window and stuff (say, emacsclient). */ - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); === modified file 'src/keymap.c' --- src/keymap.c 2012-08-18 06:06:39 +0000 +++ src/keymap.c 2012-08-28 06:20:08 +0000 @@ -1570,9 +1570,7 @@ would not be a problem here, but it is easier to keep things the same. */ - - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); - + record_unwind_current_buffer (); set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); } } === modified file 'src/minibuf.c' --- src/minibuf.c 2012-08-18 06:06:39 +0000 +++ src/minibuf.c 2012-08-28 06:20:08 +0000 @@ -817,7 +817,7 @@ while the buffer doesn't know about them any more. */ delete_all_overlays (XBUFFER (buf)); reset_buffer (XBUFFER (buf)); - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (buf); if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode")))) call0 (intern ("minibuffer-inactive-mode")); === modified file 'src/print.c' --- src/print.c 2012-08-28 05:49:02 +0000 +++ src/print.c 2012-08-28 06:20:08 +0000 @@ -487,7 +487,7 @@ register struct buffer *old = current_buffer; register Lisp_Object buf; - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (Fget_buffer_create (build_string (bufname))); === modified file 'src/process.c' --- src/process.c 2012-08-27 17:23:48 +0000 +++ src/process.c 2012-08-28 06:20:08 +0000 @@ -5196,7 +5196,7 @@ /* There's no good reason to let process filters change the current buffer, and many callers of accept-process-output, sit-for, and friends don't expect current-buffer to be changed from under them. */ - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + record_unwind_current_buffer (); /* Read and dispose of the process output. */ outstream = p->filter; @@ -6587,7 +6587,7 @@ /* There's no good reason to let sentinels change the current buffer, and many callers of accept-process-output, sit-for, and friends don't expect current-buffer to be changed from under them. */ - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + record_unwind_current_buffer (); sentinel = p->sentinel; if (NILP (sentinel)) === modified file 'src/textprop.c' --- src/textprop.c 2012-08-17 21:12:11 +0000 +++ src/textprop.c 2012-08-28 06:20:08 +0000 @@ -760,7 +760,7 @@ if (BUFFERP (object) && current_buffer != XBUFFER (object)) { - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (object); } @@ -843,7 +843,7 @@ if (BUFFERP (object) && current_buffer != XBUFFER (object)) { - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (object); } === modified file 'src/undo.c' --- src/undo.c 2012-08-18 06:06:39 +0000 +++ src/undo.c 2012-08-28 06:20:08 +0000 @@ -324,7 +324,7 @@ /* Make the buffer current to get its local values of variables such as undo_limit. Also so that Vundo_outer_limit_function can tell which buffer to operate on. */ - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + record_unwind_current_buffer (); set_buffer_internal (b); list = BVAR (b, undo_list); === modified file 'src/window.c' --- src/window.c 2012-08-27 21:07:32 +0000 +++ src/window.c 2012-08-28 06:20:08 +0000 @@ -3101,7 +3101,7 @@ /* Use the right buffer. Matters when running the local hooks. */ if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) { - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (Fwindow_buffer (Qnil)); } @@ -3205,7 +3205,7 @@ because that might itself be a local variable. */ if (window_initialized) { - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_current_buffer (); Fset_buffer (buffer); } ------------------------------------------------------------ revno: 109797 committer: Dmitry Antipov branch nick: trunk timestamp: Tue 2012-08-28 09:49:02 +0400 message: Fix usage of set_buffer_internal. * buffer.h (set_buffer_internal): Make it BUFFER_INLINE. * buffer.c (set_buffer_if_live): Use set_buffer_internal. * coding.c (decode_coding): Omit redundant test. * fileio.c (decide_coding_unwind): Likewise. * fns.c (secure_hash): Likewise. * insdel.c (modify_region): Likewise. * keyboard.c (command_loop_1): Likewise. * print.c (PRINTFINISH): Likewise. * xdisp.c (run_window_scroll_functions): Use set_buffer_internal. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-28 00:33:56 +0000 +++ src/ChangeLog 2012-08-28 05:49:02 +0000 @@ -1,3 +1,16 @@ +2012-08-28 Dmitry Antipov + + Fix usage of set_buffer_internal. + * buffer.h (set_buffer_internal): Make it BUFFER_INLINE. + * buffer.c (set_buffer_if_live): Use set_buffer_internal. + * coding.c (decode_coding): Omit redundant test. + * fileio.c (decide_coding_unwind): Likewise. + * fns.c (secure_hash): Likewise. + * insdel.c (modify_region): Likewise. + * keyboard.c (command_loop_1): Likewise. + * print.c (PRINTFINISH): Likewise. + * xdisp.c (run_window_scroll_functions): Use set_buffer_internal. + 2012-08-27 Paul Eggert * dispnew.c: Use bool for boolean. === modified file 'src/buffer.c' --- src/buffer.c 2012-08-24 04:37:57 +0000 +++ src/buffer.c 2012-08-28 05:49:02 +0000 @@ -2099,22 +2099,6 @@ XSETBUFFER (buf, current_buffer); return buf; } - -/* Set the current buffer to B. - - We previously set windows_or_buffers_changed here to invalidate - global unchanged information in beg_unchanged and end_unchanged. - This is no longer necessary because we now compute unchanged - information on a buffer-basis. Every action affecting other - windows than the selected one requires a select_window at some - time, and that increments windows_or_buffers_changed. */ - -void -set_buffer_internal (register struct buffer *b) -{ - if (current_buffer != b) - set_buffer_internal_1 (b); -} /* Set the current buffer to B, and do not set windows_or_buffers_changed. This is used by redisplay. */ @@ -2226,7 +2210,7 @@ set_buffer_if_live (Lisp_Object buffer) { if (! NILP (BVAR (XBUFFER (buffer), name))) - Fset_buffer (buffer); + set_buffer_internal (XBUFFER (buffer)); return Qnil; } === modified file 'src/buffer.h' --- src/buffer.h 2012-08-24 04:37:57 +0000 +++ src/buffer.h 2012-08-28 05:49:02 +0000 @@ -1014,7 +1014,6 @@ extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); extern void validate_region (Lisp_Object *, Lisp_Object *); -extern void set_buffer_internal (struct buffer *); extern void set_buffer_internal_1 (struct buffer *); extern void set_buffer_temp (struct buffer *); extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); @@ -1023,6 +1022,22 @@ extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); extern void mmap_set_vars (bool); +/* Set the current buffer to B. + + We previously set windows_or_buffers_changed here to invalidate + global unchanged information in beg_unchanged and end_unchanged. + This is no longer necessary because we now compute unchanged + information on a buffer-basis. Every action affecting other + windows than the selected one requires a select_window at some + time, and that increments windows_or_buffers_changed. */ + +BUFFER_INLINE void +set_buffer_internal (struct buffer *b) +{ + if (current_buffer != b) + set_buffer_internal_1 (b); +} + /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. If NEXTP is non-NULL, return next overlay there. See overlay_at arg CHANGE_REQ for meaning of CHRQ arg. */ === modified file 'src/coding.c' --- src/coding.c 2012-08-27 16:19:34 +0000 +++ src/coding.c 2012-08-28 05:49:02 +0000 @@ -7006,8 +7006,7 @@ undo_list = Qt; if (BUFFERP (coding->dst_object)) { - if (current_buffer != XBUFFER (coding->dst_object)) - set_buffer_internal (XBUFFER (coding->dst_object)); + set_buffer_internal (XBUFFER (coding->dst_object)); if (GPT != PT) move_gap_both (PT, PT_BYTE); === modified file 'src/fileio.c' --- src/fileio.c 2012-08-27 16:19:34 +0000 +++ src/fileio.c 2012-08-28 05:49:02 +0000 @@ -3142,8 +3142,7 @@ undo_list = XCAR (unwind_data); buffer = XCDR (unwind_data); - if (current_buffer != XBUFFER (buffer)) - set_buffer_internal (XBUFFER (buffer)); + set_buffer_internal (XBUFFER (buffer)); adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE); adjust_overlays_for_delete (BEG, Z - BEG); set_buffer_intervals (current_buffer, NULL); === modified file 'src/fns.c' --- src/fns.c 2012-08-26 09:26:45 +0000 +++ src/fns.c 2012-08-28 05:49:02 +0000 @@ -4661,8 +4661,7 @@ CHECK_BUFFER (object); bp = XBUFFER (object); - if (bp != current_buffer) - set_buffer_internal (bp); + set_buffer_internal (bp); if (NILP (start)) b = BEGV; @@ -4749,8 +4748,7 @@ } object = make_buffer_string (b, e, 0); - if (prev != current_buffer) - set_buffer_internal (prev); + set_buffer_internal (prev); /* Discard the unwind protect for recovering the current buffer. */ specpdl_ptr--; === modified file 'src/insdel.c' --- src/insdel.c 2012-08-18 06:06:39 +0000 +++ src/insdel.c 2012-08-28 05:49:02 +0000 @@ -1779,8 +1779,7 @@ { struct buffer *old_buffer = current_buffer; - if (buffer != old_buffer) - set_buffer_internal (buffer); + set_buffer_internal (buffer); prepare_to_modify_buffer (start, end, NULL); @@ -1794,8 +1793,7 @@ bset_point_before_scroll (buffer, Qnil); - if (buffer != old_buffer) - set_buffer_internal (old_buffer); + set_buffer_internal (old_buffer); } /* Check that it is okay to modify the buffer between START and END, === modified file 'src/keyboard.c' --- src/keyboard.c 2012-08-23 08:33:56 +0000 +++ src/keyboard.c 2012-08-28 05:49:02 +0000 @@ -1434,8 +1434,7 @@ Fkill_emacs (Qnil); /* Make sure the current window's buffer is selected. */ - if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) - set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); + set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); /* Display any malloc warning that just came out. Use while because displaying one warning can cause another. */ @@ -1513,8 +1512,7 @@ /* A filter may have run while we were reading the input. */ if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); - if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) - set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); + set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); ++num_input_keys; === modified file 'src/print.c' --- src/print.c 2012-08-21 23:39:56 +0000 +++ src/print.c 2012-08-28 05:49:02 +0000 @@ -197,8 +197,7 @@ ? PT - start_point : 0), \ old_point_byte + (old_point_byte >= start_point_byte \ ? PT_BYTE - start_point_byte : 0)); \ - if (old != current_buffer) \ - set_buffer_internal (old); + set_buffer_internal (old); #define PRINTCHAR(ch) printchar (ch, printcharfun) === modified file 'src/xdisp.c' --- src/xdisp.c 2012-08-28 00:33:56 +0000 +++ src/xdisp.c 2012-08-28 05:49:02 +0000 @@ -14551,8 +14551,7 @@ make_number (CHARPOS (startp))); SET_TEXT_POS_FROM_MARKER (startp, w->start); /* In case the hook functions switch buffers. */ - if (current_buffer != XBUFFER (w->buffer)) - set_buffer_internal_1 (XBUFFER (w->buffer)); + set_buffer_internal (XBUFFER (w->buffer)); } return startp; ------------------------------------------------------------ revno: 109796 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-08-27 17:33:56 -0700 message: * dispnew.c: Use bool for boolean. (frame_garbaged, display_completed, delayed_size_change) (fonts_changed_p, add_window_display_history) (add_frame_display_history, verify_row_hash) (adjust_glyph_matrix, clear_window_matrices, glyph_row_slice_p) (row_equal_p, realloc_glyph_pool) (allocate_matrices_for_frame_redisplay) (showing_window_margins_p) (adjust_frame_glyphs_for_frame_redisplay) (build_frame_matrix_from_leaf_window, make_current) (mirrored_line_dance, mirror_line_dance, update_frame) (update_window_tree, update_single_window) (check_current_matrix_flags, update_window, update_text_area) (update_window_line, set_window_update_flags, scrolling_window) (update_frame_1, scrolling, buffer_posn_from_coords) (do_pending_window_change, change_frame_size) (change_frame_size_1, sit_for): Use bool for boolean. (clear_glyph_matrix_rows): Rename from enable_glyph_matrix_rows, and remove last int (actually boolean) argument, which was always 0. All callers changed. * dispextern.h, frame.h, lisp.h: Reflect above API changes. * dispextern.h (struct composition_it): Use bool for boolean. (struct glyph_matrix): Don't assume buffer sizes can fit in 'int'. (struct bidi_it): Use unsigned:1, not int, for boolean prev_was_pdf. * dired.c (file_name_completion): Use bool for boolean. (This was missed in an earlier change.) diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 21:07:32 +0000 +++ src/ChangeLog 2012-08-28 00:33:56 +0000 @@ -1,3 +1,33 @@ +2012-08-27 Paul Eggert + + * dispnew.c: Use bool for boolean. + (frame_garbaged, display_completed, delayed_size_change) + (fonts_changed_p, add_window_display_history) + (add_frame_display_history, verify_row_hash) + (adjust_glyph_matrix, clear_window_matrices, glyph_row_slice_p) + (row_equal_p, realloc_glyph_pool) + (allocate_matrices_for_frame_redisplay) + (showing_window_margins_p) + (adjust_frame_glyphs_for_frame_redisplay) + (build_frame_matrix_from_leaf_window, make_current) + (mirrored_line_dance, mirror_line_dance, update_frame) + (update_window_tree, update_single_window) + (check_current_matrix_flags, update_window, update_text_area) + (update_window_line, set_window_update_flags, scrolling_window) + (update_frame_1, scrolling, buffer_posn_from_coords) + (do_pending_window_change, change_frame_size) + (change_frame_size_1, sit_for): + Use bool for boolean. + (clear_glyph_matrix_rows): Rename from enable_glyph_matrix_rows, + and remove last int (actually boolean) argument, which was always 0. + All callers changed. + * dispextern.h, frame.h, lisp.h: Reflect above API changes. + * dispextern.h (struct composition_it): Use bool for boolean. + (struct glyph_matrix): Don't assume buffer sizes can fit in 'int'. + (struct bidi_it): Use unsigned:1, not int, for boolean prev_was_pdf. + * dired.c (file_name_completion): + Use bool for boolean. (This was missed in an earlier change.) + 2012-08-27 Martin Rudalics * window.c (Fset_window_configuration): Revert first part of === modified file 'src/dired.c' --- src/dired.c 2012-08-27 17:23:48 +0000 +++ src/dired.c 2012-08-28 00:33:56 +0000 @@ -460,7 +460,7 @@ Lisp_Object encoded_file; Lisp_Object encoded_dir; struct stat st; - int directoryp; + bool directoryp; /* If not INCLUDEALL, exclude files in completion-ignored-extensions as well as "." and "..". Until shown otherwise, assume we can't exclude anything. */ @@ -530,7 +530,7 @@ if (file_name_completion_stat (encoded_dir, dp, &st) < 0) continue; - directoryp = S_ISDIR (st.st_mode); + directoryp = S_ISDIR (st.st_mode) != 0; tem = Qnil; /* If all_flag is set, always include all. It would not actually be helpful to the user to ignore any possible @@ -718,7 +718,7 @@ /* This tests that the current file is an exact match but BESTMATCH is not (it is too long). */ if ((matchsize == SCHARS (name) - && matchsize + !!directoryp < SCHARS (bestmatch)) + && matchsize + directoryp < SCHARS (bestmatch)) || /* If there is no exact match ignoring case, prefer a match that does not change the case @@ -730,7 +730,7 @@ either both or neither are exact. */ (((matchsize == SCHARS (name)) == - (matchsize + !!directoryp == SCHARS (bestmatch))) + (matchsize + directoryp == SCHARS (bestmatch))) && (cmp = Fcompare_strings (name, zero, make_number (SCHARS (file)), file, zero, === modified file 'src/dispextern.h' --- src/dispextern.h 2012-08-23 20:31:52 +0000 +++ src/dispextern.h 2012-08-28 00:33:56 +0000 @@ -671,7 +671,7 @@ /* Values of BEGV and ZV as of last redisplay. Set in mark_window_display_accurate_1. */ - int begv, zv; + ptrdiff_t begv, zv; }; @@ -1126,11 +1126,11 @@ ((ROW)->phys_height - (ROW)->phys_ascent \ > (ROW)->height - (ROW)->ascent) -/* Non-zero means that fonts have been loaded since the last glyph +/* True means that fonts have been loaded since the last glyph matrix adjustments. The function redisplay_internal adjusts glyph - matrices when this flag is non-zero. */ + matrices when this flag is true. */ -extern int fonts_changed_p; +extern bool fonts_changed_p; /* A glyph for a space. */ @@ -1149,7 +1149,7 @@ /* Non-zero means last display completed. Zero means it was preempted. */ -extern int display_completed; +extern bool display_completed; @@ -1415,7 +1415,7 @@ && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \ && WINDOW_TOTAL_LINES (W) > 1) -/* Value is non-zero if window W wants a header line. */ +/* Value is true if window W wants a header line. */ #define WINDOW_WANTS_HEADER_LINE_P(W) \ (!MINI_WINDOW_P ((W)) \ @@ -1856,7 +1856,6 @@ int resolved_level; /* final resolved level of this character */ int invalid_levels; /* how many PDFs to ignore */ int invalid_rl_levels; /* how many PDFs from RLE/RLO to ignore */ - int prev_was_pdf; /* if non-zero, previous char was PDF */ struct bidi_saved_info prev; /* info about previous character */ struct bidi_saved_info last_strong; /* last-seen strong directional char */ struct bidi_saved_info next_for_neutral; /* surrounding characters for... */ @@ -1879,6 +1878,7 @@ struct bidi_string_data string; /* string to reorder */ bidi_dir_t paragraph_dir; /* current paragraph direction */ ptrdiff_t separator_limit; /* where paragraph separator should end */ + unsigned prev_was_pdf : 1; /* if non-zero, previous char was PDF */ unsigned first_elt : 1; /* if non-zero, examine current char first */ unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */ unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */ @@ -2085,10 +2085,10 @@ ptrdiff_t lookback; /* If non-negative, number of glyphs of the glyph-string. */ int nglyphs; - /* Nonzero iff the composition is created while buffer is scanned in + /* True iff the composition is created while buffer is scanned in reverse order, and thus the grapheme clusters must be rendered from the last to the first. */ - int reversed_p; + bool reversed_p; /** The following members contain information about the current grapheme cluster. */ @@ -3304,7 +3304,7 @@ extern void redraw_frame (struct frame *); extern void cancel_line (int, struct frame *); extern void init_desired_glyphs (struct frame *); -extern int update_frame (struct frame *, int, int); +extern bool update_frame (struct frame *, bool, bool); extern void bitch_at_user (void); void adjust_glyphs (struct frame *); void free_glyphs (struct frame *); @@ -3320,13 +3320,13 @@ void increment_matrix_positions (struct glyph_matrix *, int, int, ptrdiff_t, ptrdiff_t); void blank_row (struct window *, struct glyph_row *, int); -void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int); +void clear_glyph_matrix_rows (struct glyph_matrix *, int, int); void clear_glyph_row (struct glyph_row *); void prepare_desired_row (struct glyph_row *); -void set_window_update_flags (struct window *, int); -void update_single_window (struct window *, int); -void do_pending_window_change (int); -void change_frame_size (struct frame *, int, int, int, int, int); +void set_window_update_flags (struct window *, bool); +void update_single_window (struct window *, bool); +void do_pending_window_change (bool); +void change_frame_size (struct frame *, int, int, bool, bool, bool); void init_display (void); void syms_of_display (void); extern Lisp_Object Qredisplay_dont_pause; === modified file 'src/dispnew.c' --- src/dispnew.c 2012-08-21 10:21:04 +0000 +++ src/dispnew.c 2012-08-28 00:33:56 +0000 @@ -88,7 +88,7 @@ static int required_matrix_height (struct window *); static int required_matrix_width (struct window *); static void adjust_frame_glyphs (struct frame *); -static void change_frame_size_1 (struct frame *, int, int, int, int, int); +static void change_frame_size_1 (struct frame *, int, int, bool, bool, bool); static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t); static void fill_up_frame_row_with_spaces (struct glyph_row *, int); static void build_frame_matrix_from_window_tree (struct glyph_matrix *, @@ -98,20 +98,20 @@ static void adjust_frame_message_buffer (struct frame *); static void adjust_decode_mode_spec_buffer (struct frame *); static void fill_up_glyph_row_with_spaces (struct glyph_row *); -static void clear_window_matrices (struct window *, int); +static void clear_window_matrices (struct window *, bool); static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int); -static int scrolling_window (struct window *, int); -static int update_window_line (struct window *, int, int *); +static int scrolling_window (struct window *, bool); +static bool update_window_line (struct window *, int, bool *); static void mirror_make_current (struct window *, int); #ifdef GLYPH_DEBUG static void check_matrix_pointers (struct glyph_matrix *, struct glyph_matrix *); #endif static void mirror_line_dance (struct window *, int, int, int *, char *); -static int update_window_tree (struct window *, int); -static int update_window (struct window *, int); -static int update_frame_1 (struct frame *, int, int); -static int scrolling (struct frame *); +static bool update_window_tree (struct window *, bool); +static bool update_window (struct window *, bool); +static bool update_frame_1 (struct frame *, bool, bool); +static bool scrolling (struct frame *); static void set_window_cursor_after_update (struct window *); static void adjust_frame_glyphs_for_window_redisplay (struct frame *); static void adjust_frame_glyphs_for_frame_redisplay (struct frame *); @@ -122,14 +122,14 @@ static EMACS_TIME preemption_period; static EMACS_TIME preemption_next_check; -/* Nonzero upon entry to redisplay means do not assume anything about +/* True upon entry to redisplay means do not assume anything about current contents of actual terminal frame; clear and redraw it. */ -int frame_garbaged; - -/* Nonzero means last display completed. Zero means it was preempted. */ - -int display_completed; +bool frame_garbaged; + +/* True means last display completed. False means it was preempted. */ + +bool display_completed; Lisp_Object Qdisplay_table, Qredisplay_dont_pause; @@ -146,13 +146,13 @@ struct frame *last_nonminibuf_frame; -/* 1 means SIGWINCH happened when not safe. */ +/* True means SIGWINCH happened when not safe. */ -static int delayed_size_change; +static bool delayed_size_change; /* 1 means glyph initialization has been completed at startup. */ -static int glyphs_initialized_initially_p; +static bool glyphs_initialized_initially_p; /* Updated window if != 0. Set by update_window. */ @@ -178,15 +178,15 @@ static struct frame *frame_matrix_frame; -/* Non-zero means that fonts have been loaded since the last glyph +/* True means that fonts have been loaded since the last glyph matrix adjustments. Redisplay must stop, and glyph matrices must - be adjusted when this flag becomes non-zero during display. The + be adjusted when this flag becomes true during display. The reason fonts can be loaded so late is that fonts of fontsets are loaded on demand. Another reason is that a line contains many characters displayed by zero width or very narrow glyphs of variable-width fonts. */ -int fonts_changed_p; +bool fonts_changed_p; /* Convert vpos and hpos from frame to window and vice versa. This may only be used for terminal frames. */ @@ -222,16 +222,14 @@ history. */ static uprintmax_t history_tick; - -static void add_frame_display_history (struct frame *, int); /* Add to the redisplay history how window W has been displayed. MSG is a trace containing the information how W's glyph matrix - has been constructed. PAUSED_P non-zero means that the update + has been constructed. PAUSED_P means that the update has been interrupted for pending input. */ static void -add_window_display_history (struct window *w, const char *msg, int paused_p) +add_window_display_history (struct window *w, const char *msg, bool paused_p) { char *buf; @@ -254,11 +252,11 @@ /* Add to the redisplay history that frame F has been displayed. - PAUSED_P non-zero means that the update has been interrupted for + PAUSED_P means that the update has been interrupted for pending input. */ static void -add_frame_display_history (struct frame *f, int paused_p) +add_frame_display_history (struct frame *f, bool paused_p) { char *buf; @@ -395,10 +393,10 @@ return n; } -/* Return non-zero if ROW's hash value is correct, zero if not. +/* Return true if ROW's hash value is correct. Optimized away if ENABLE_CHECKING is not defined. */ -static int +static bool verify_row_hash (struct glyph_row *row) { return row->hash == row_hash (row); @@ -431,9 +429,9 @@ { int i; int new_rows; - int marginal_areas_changed_p = 0; - int header_line_changed_p = 0; - int header_line_p = 0; + bool marginal_areas_changed_p = 0; + bool header_line_changed_p = 0; + bool header_line_p = 0; int left = -1, right = -1; int window_width = -1, window_height = -1; @@ -736,30 +734,28 @@ } -/* Enable a range of rows in glyph matrix MATRIX. START and END are - the row indices of the first and last + 1 row to enable. If - ENABLED_P is non-zero, enabled_p flags in rows will be set to 1. */ +/* Clear the enable_p flags in a range of rows in glyph matrix MATRIX. + START and END are the row indices of the first and last + 1 row to clear. */ void -enable_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end, int enabled_p) +clear_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end) { eassert (start <= end); eassert (start >= 0 && start < matrix->nrows); eassert (end >= 0 && end <= matrix->nrows); for (; start < end; ++start) - matrix->rows[start].enabled_p = enabled_p != 0; + matrix->rows[start].enabled_p = 0; } /* Clear MATRIX. - This empties all rows in MATRIX by setting the enabled_p flag for - all rows of the matrix to zero. The function prepare_desired_row - will eventually really clear a row when it sees one with a zero - enabled_p flag. + Empty all rows in MATRIX by clearing their enabled_p flags. + The function prepare_desired_row will eventually really clear a row + when it sees one with a false enabled_p flag. - Resets update hints to defaults value. The only update hint + Reset update hints to default values. The only update hint currently present is the flag MATRIX->no_scrolling_p. */ void @@ -767,7 +763,7 @@ { if (matrix) { - enable_glyph_matrix_rows (matrix, 0, matrix->nrows, 0); + clear_glyph_matrix_rows (matrix, 0, matrix->nrows); matrix->no_scrolling_p = 0; } } @@ -853,11 +849,11 @@ } -/* Clear matrices in window tree rooted in W. If DESIRED_P is - non-zero clear desired matrices, otherwise clear current matrices. */ +/* Clear matrices in window tree rooted in W. If DESIRED_P, + clear desired matrices, otherwise clear current matrices. */ static void -clear_window_matrices (struct window *w, int desired_p) +clear_window_matrices (struct window *w, bool desired_p) { while (w) { @@ -1109,12 +1105,12 @@ /* Test whether the glyph memory of the glyph row WINDOW_ROW, which is a row in a window matrix, is a slice of the glyph memory of the glyph row FRAME_ROW which is a row in a frame glyph matrix. Value - is non-zero if the glyph memory of WINDOW_ROW is part of the glyph + is true if the glyph memory of WINDOW_ROW is part of the glyph memory of FRAME_ROW. */ #ifdef GLYPH_DEBUG -static int +static bool glyph_row_slice_p (struct glyph_row *window_row, struct glyph_row *frame_row) { struct glyph *window_glyph_start = window_row->glyphs[0]; @@ -1161,7 +1157,7 @@ { if (!row->enabled_p) { - int rp = row->reversed_p; + bool rp = row->reversed_p; clear_glyph_row (row); row->enabled_p = 1; @@ -1260,12 +1256,11 @@ } -/* Test two glyph rows A and B for equality. Value is non-zero if A - and B have equal contents. MOUSE_FACE_P non-zero means compare the - mouse_face_p flags of A and B, too. */ +/* Return true if the glyph rows A and B have equal contents. + MOUSE_FACE_P means compare the mouse_face_p flags of A and B, too. */ -static inline int -row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) +static inline bool +row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p) { eassert (verify_row_hash (a)); eassert (verify_row_hash (b)); @@ -1380,14 +1375,14 @@ is changed from a large value to a smaller one. But, if someone does it once, we can expect that he will do it again. - Value is non-zero if the pool changed in a way which makes + Return true if the pool changed in a way which makes re-adjusting window glyph matrices necessary. */ -static int +static bool realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) { ptrdiff_t needed; - int changed_p; + bool changed_p; changed_p = (pool->glyphs == 0 || matrix_dim.height != pool->nrows @@ -1561,7 +1556,7 @@ X and Y are column/row within the frame glyph matrix where sub-matrices for the window tree rooted at WINDOW must be - allocated. DIM_ONLY_P non-zero means that the caller of this + allocated. DIM_ONLY_P means that the caller of this function is only interested in the result matrix dimension, and matrix adjustments should not be performed. @@ -1638,7 +1633,7 @@ static struct dim allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y, - int dim_only_p, int *window_change_flags) + bool dim_only_p, int *window_change_flags) { struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); int x0 = x, y0 = y; @@ -1646,7 +1641,7 @@ struct dim total; struct dim dim; struct window *w; - int in_horz_combination_p; + bool in_horz_combination_p; /* What combination is WINDOW part of? Compute this once since the result is the same for all windows in the `next' chain. The @@ -1704,7 +1699,7 @@ /* Actually change matrices, if allowed. Do not consider CHANGED_LEAF_MATRIX computed above here because the pool may have been changed which we don't now here. We trust - that we only will be called with DIM_ONLY_P != 0 when + that we only will be called with DIM_ONLY_P when necessary. */ if (!dim_only_p) { @@ -1919,9 +1914,9 @@ f->glyphs_initialized_p = 1; } -/* Return 1 if any window in the tree has nonzero window margins. See +/* Return true if any window in the tree has nonzero window margins. See the hack at the end of adjust_frame_glyphs_for_frame_redisplay. */ -static int +static bool showing_window_margins_p (struct window *w) { while (w) @@ -2052,7 +2047,7 @@ adjust_frame_glyphs_for_frame_redisplay (struct frame *f) { struct dim matrix_dim; - int pool_changed_p; + bool pool_changed_p; int window_change_flags; int top_window_y; @@ -2468,7 +2463,7 @@ desired frame matrix built. W is a leaf window whose desired or current matrix is to be added to FRAME_MATRIX. W's flag must_be_updated_p determines which matrix it contributes to - FRAME_MATRIX. If must_be_updated_p is non-zero, W's desired matrix + FRAME_MATRIX. If W->must_be_updated_p, W's desired matrix is added to FRAME_MATRIX, otherwise W's current matrix is added. Adding a desired matrix means setting up used counters and such in frame rows, while adding a current window matrix to FRAME_MATRIX @@ -2519,7 +2514,7 @@ { struct glyph_row *frame_row = frame_matrix->rows + frame_y; struct glyph_row *window_row = window_matrix->rows + window_y; - int current_row_p = window_matrix == w->current_matrix; + bool current_row_p = window_matrix == w->current_matrix; /* Fill up the frame row with spaces up to the left margin of the window row. */ @@ -2692,7 +2687,7 @@ { struct glyph_row *current_row = MATRIX_ROW (current_matrix, row); struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row); - int mouse_face_p = current_row->mouse_face_p; + bool mouse_face_p = current_row->mouse_face_p; /* Do current_row = desired_row. This exchanges glyph pointers between both rows, and does a structure assignment otherwise. */ @@ -2789,7 +2784,7 @@ /* Assign new rows, maybe clear lines. */ for (i = 0; i < nlines; ++i) { - int enabled_before_p = new_rows[i].enabled_p; + bool enabled_before_p = new_rows[i].enabled_p; eassert (i + unchanged_at_top < matrix->nrows); eassert (unchanged_at_top + copy_from[i] < matrix->nrows); @@ -2897,7 +2892,8 @@ /* W is a leaf window, and we are working on its current matrix m. */ struct glyph_matrix *m = w->current_matrix; - int i, sync_p = 0; + int i; + bool sync_p = 0; struct glyph_row *old_rows; /* Make a copy of the original rows of matrix m. */ @@ -2919,22 +2915,19 @@ int window_from = frame_from - m->matrix_y; /* Is assigned line inside window? */ - int from_inside_window_p + bool from_inside_window_p = window_from >= 0 && window_from < m->matrix_h; /* Is assigned to line inside window? */ - int to_inside_window_p + bool to_inside_window_p = window_to >= 0 && window_to < m->matrix_h; if (from_inside_window_p && to_inside_window_p) { - /* Enabled setting before assignment. */ - int enabled_before_p; - /* Do the assignment. The enabled_p flag is saved over the assignment because the old redisplay did that. */ - enabled_before_p = m->rows[window_to].enabled_p; + bool enabled_before_p = m->rows[window_to].enabled_p; m->rows[window_to] = old_rows[window_from]; m->rows[window_to].enabled_p = enabled_before_p; @@ -3155,17 +3148,16 @@ /* Update frame F based on the data in desired matrices. - If FORCE_P is non-zero, don't let redisplay be stopped by detecting - pending input. If INHIBIT_HAIRY_ID_P is non-zero, don't try - scrolling. - - Value is non-zero if redisplay was stopped due to pending input. */ - -int -update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p) + If FORCE_P, don't let redisplay be stopped by detecting pending input. + If INHIBIT_HAIRY_ID_P, don't try scrolling. + + Value is true if redisplay was stopped due to pending input. */ + +bool +update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p) { - /* 1 means display has been paused because of pending input. */ - int paused_p; + /* True means display has been paused because of pending input. */ + bool paused_p; struct window *root_window = XWINDOW (f->root_window); if (redisplay_dont_pause) @@ -3283,13 +3275,13 @@ Window-based updates ************************************************************************/ -/* Perform updates in window tree rooted at W. FORCE_P non-zero means - don't stop updating when input is pending. */ +/* Perform updates in window tree rooted at W. + If FORCE_P, don't stop updating if input is pending. */ -static int -update_window_tree (struct window *w, int force_p) +static bool +update_window_tree (struct window *w, bool force_p) { - int paused_p = 0; + bool paused_p = 0; while (w && !paused_p) { @@ -3307,11 +3299,11 @@ } -/* Update window W if its flag must_be_updated_p is non-zero. If - FORCE_P is non-zero, don't stop updating if input is pending. */ +/* Update window W if its flag must_be_updated_p is set. + If FORCE_P, don't stop updating if input is pending. */ void -update_single_window (struct window *w, int force_p) +update_single_window (struct window *w, bool force_p) { if (w->must_be_updated_p) { @@ -3460,7 +3452,7 @@ static void check_current_matrix_flags (struct window *w) { - int last_seen_p = 0; + bool last_seen_p = 0; int i, yb = window_text_bottom_y (w); for (i = 0; i < w->current_matrix->nrows - 1; ++i) @@ -3476,14 +3468,14 @@ #endif /* GLYPH_DEBUG */ -/* Update display of window W. FORCE_P non-zero means that we should - not stop when detecting pending input. */ +/* Update display of window W. + If FORCE_P, don't stop updating when input is pending. */ -static int -update_window (struct window *w, int force_p) +static bool +update_window (struct window *w, bool force_p) { struct glyph_matrix *desired_matrix = w->desired_matrix; - int paused_p; + bool paused_p; #if !PERIODIC_PREEMPTION_CHECKING int preempt_count = baud_rate / 2400 + 1; #endif @@ -3506,7 +3498,8 @@ struct glyph_row *row, *end; struct glyph_row *mode_line_row; struct glyph_row *header_line_row; - int yb, changed_p = 0, mouse_face_overwritten_p = 0; + int yb; + bool changed_p = 0, mouse_face_overwritten_p = 0; #if ! PERIODIC_PREEMPTION_CHECKING int n_updated = 0; #endif @@ -3693,15 +3686,15 @@ /* Update the display of the text area of row VPOS in window W. - Value is non-zero if display has changed. */ + Value is true if display has changed. */ -static int +static bool update_text_area (struct window *w, int vpos) { struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); - int changed_p = 0; + bool changed_p = 0; /* Let functions in xterm.c know what area subsequent X positions will be relative to. */ @@ -3751,9 +3744,9 @@ int stop, i, x; struct glyph *current_glyph = current_row->glyphs[TEXT_AREA]; struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA]; - int overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p; + bool overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p; int desired_stop_pos = desired_row->used[TEXT_AREA]; - int abort_skipping = 0; + bool abort_skipping = 0; /* If the desired row extends its face to the text area end, and unless the current row also does so at the same position, @@ -3773,7 +3766,7 @@ in common. */ while (i < stop) { - int can_skip_p = !abort_skipping; + bool can_skip_p = !abort_skipping; /* Skip over glyphs that both rows have in common. These don't have to be written. We can't skip if the last @@ -3847,7 +3840,7 @@ int start_x = x, start_hpos = i; struct glyph *start = desired_glyph; int current_x = x; - int skip_first_p = !can_skip_p; + bool skip_first_p = !can_skip_p; /* Find the next glyph that's equal again. */ while (i < stop @@ -3938,16 +3931,15 @@ } -/* Update row VPOS in window W. Value is non-zero if display has been - changed. */ +/* Update row VPOS in window W. Value is true if display has been changed. */ -static int -update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p) +static bool +update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p) { struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); - int changed_p = 0; + bool changed_p = 0; /* Set the row being updated. This is important to let xterm.c know what line height values are in effect. */ @@ -4095,7 +4087,7 @@ tree rooted at W. */ void -set_window_update_flags (struct window *w, int on_p) +set_window_update_flags (struct window *w, bool on_p) { while (w) { @@ -4198,7 +4190,7 @@ /* Try to reuse part of the current display of W by scrolling lines. - HEADER_LINE_P non-zero means W has a header line. + HEADER_LINE_P means W has a header line. The algorithm is taken from Communications of the ACM, Apr78 "A Technique for Isolating Differences Between Files." It should take @@ -4224,7 +4216,7 @@ 1 if we did scroll. */ static int -scrolling_window (struct window *w, int header_line_p) +scrolling_window (struct window *w, bool header_line_p) { struct glyph_matrix *desired_matrix = w->desired_matrix; struct glyph_matrix *current_matrix = w->current_matrix; @@ -4237,7 +4229,7 @@ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); /* Skip over rows equal at the start. */ - for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i) + for (i = header_line_p; i < current_matrix->nrows - 1; ++i) { struct glyph_row *d = MATRIX_ROW (desired_matrix, i); struct glyph_row *c = MATRIX_ROW (current_matrix, i); @@ -4496,7 +4488,7 @@ for (j = nruns - 1; j > i; --j) { struct run *p = runs[j]; - int truncated_p = 0; + bool truncated_p = 0; if (p->nrows > 0 && p->desired_y < r->desired_y + r->height @@ -4559,7 +4551,7 @@ for (j = 0; j < r->nrows; ++j) { struct glyph_row *from, *to; - int to_overlapped_p; + bool to_overlapped_p; to = MATRIX_ROW (current_matrix, r->desired_vpos + j); from = MATRIX_ROW (desired_matrix, r->desired_vpos + j); @@ -4594,20 +4586,19 @@ /* Update the desired frame matrix of frame F. - FORCE_P non-zero means that the update should not be stopped by - pending input. INHIBIT_HAIRY_ID_P non-zero means that scrolling - should not be tried. - - Value is non-zero if update was stopped due to pending input. */ - -static int -update_frame_1 (struct frame *f, int force_p, int inhibit_id_p) + FORCE_P means that the update should not be stopped by pending input. + INHIBIT_HAIRY_ID_P means that scrolling should not be tried. + + Value is true if update was stopped due to pending input. */ + +static bool +update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p) { /* Frame matrices to work on. */ struct glyph_matrix *current_matrix = f->current_matrix; struct glyph_matrix *desired_matrix = f->desired_matrix; int i; - int pause_p; + bool pause_p; int preempt_count = baud_rate / 2400 + 1; eassert (current_matrix && desired_matrix); @@ -4699,7 +4690,7 @@ } } - pause_p = (i < FRAME_LINES (f) - 1) ? i : 0; + pause_p = 0 < i && i < FRAME_LINES (f) - 1; /* Now just clean up termcap drivers and set cursor, etc. */ if (!pause_p) @@ -4809,7 +4800,7 @@ /* Do line insertions/deletions on frame F for frame-based redisplay. */ -static int +static bool scrolling (struct frame *frame) { int unchanged_at_top, unchanged_at_bottom; @@ -4952,10 +4943,10 @@ struct glyph_matrix *desired_matrix = f->desired_matrix; struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos); - int must_write_whole_line_p; - int write_spaces_p = FRAME_MUST_WRITE_SPACES (f); - int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background - != FACE_TTY_DEFAULT_BG_COLOR); + bool must_write_whole_line_p; + bool write_spaces_p = FRAME_MUST_WRITE_SPACES (f); + bool colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background + != FACE_TTY_DEFAULT_BG_COLOR); if (colored_spaces_p) write_spaces_p = 1; @@ -5289,7 +5280,7 @@ /* start_display takes into account the header-line row, but IT's vpos still counts from the glyph row that includes the window's start position. Adjust for a possible header-line row. */ - it.vpos += WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0; + it.vpos += WINDOW_WANTS_HEADER_LINE_P (w); x0 = *x; @@ -5613,12 +5604,12 @@ #endif /* SIGWINCH */ -/* Do any change in frame size that was requested by a signal. SAFE - non-zero means this function is called from a place where it is - safe to change frame sizes while a redisplay is in progress. */ +/* Do any change in frame size that was requested by a signal. + SAFE means this function is called from a place where it is + safe to change frame sizes while a redisplay is in progress. */ void -do_pending_window_change (int safe) +do_pending_window_change (bool safe) { /* If window_change_signal should have run before, run it now. */ if (redisplaying_p && !safe) @@ -5645,16 +5636,17 @@ /* Change the frame height and/or width. Values may be given as zero to indicate no change is to take place. - If DELAY is non-zero, then assume we're being called from a signal - handler, and queue the change for later - perhaps the next - redisplay. Since this tries to resize windows, we can't call it + If DELAY, assume we're being called from a signal handler, and + queue the change for later - perhaps the next redisplay. + Since this tries to resize windows, we can't call it from a signal handler. - SAFE non-zero means this function is called from a place where it's + SAFE means this function is called from a place where it's safe to change frame sizes while a redisplay is in progress. */ void -change_frame_size (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) +change_frame_size (struct frame *f, int newheight, int newwidth, + bool pretend, bool delay, bool safe) { Lisp_Object tail, frame; @@ -5673,7 +5665,8 @@ } static void -change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) +change_frame_size_1 (struct frame *f, int newheight, int newwidth, + bool pretend, bool delay, bool safe) { int new_frame_total_cols; ptrdiff_t count = SPECPDL_INDEX (); @@ -5929,13 +5922,13 @@ TIMEOUT is number of seconds to wait (float or integer), or t to wait forever. - READING is 1 if reading input. + READING is true if reading input. If DO_DISPLAY is >0 display process output while waiting. If DO_DISPLAY is >1 perform an initial redisplay before waiting. */ Lisp_Object -sit_for (Lisp_Object timeout, int reading, int do_display) +sit_for (Lisp_Object timeout, bool reading, int do_display) { intmax_t sec; int nsec; === modified file 'src/frame.h' --- src/frame.h 2012-08-22 16:05:04 +0000 +++ src/frame.h 2012-08-28 00:33:56 +0000 @@ -34,7 +34,7 @@ /* Miscellanea. */ /* Nonzero means there is at least one garbaged frame. */ -extern int frame_garbaged; +extern bool frame_garbaged; /* The structure representing a frame. */ === modified file 'src/lisp.h' --- src/lisp.h 2012-08-27 17:23:48 +0000 +++ src/lisp.h 2012-08-28 00:33:56 +0000 @@ -2766,7 +2766,7 @@ #endif extern Lisp_Object selected_frame; extern Lisp_Object Vwindow_system; -extern Lisp_Object sit_for (Lisp_Object, int, int); +extern Lisp_Object sit_for (Lisp_Object, bool, int); extern void init_display (void); extern void syms_of_display (void); === modified file 'src/xdisp.c' --- src/xdisp.c 2012-08-26 10:29:37 +0000 +++ src/xdisp.c 2012-08-28 00:33:56 +0000 @@ -15380,7 +15380,7 @@ selected_window is redisplayed. We can return without actually redisplaying the window if - fonts_changed_p is nonzero. In that case, redisplay_internal will + fonts_changed_p. In that case, redisplay_internal will retry. */ static void @@ -16224,7 +16224,7 @@ } #endif /* HAVE_WINDOW_SYSTEM */ - /* We go to this label, with fonts_changed_p nonzero, + /* We go to this label, with fonts_changed_p set, if it is necessary to try again using larger glyph matrices. We have to redeem the scroll bar even in this case, because the loop in redisplay_internal expects that. */ @@ -17705,15 +17705,15 @@ { rotate_matrix (current_matrix, first_unchanged_at_end_vpos + dvpos, bottom_vpos, dvpos); - enable_glyph_matrix_rows (current_matrix, bottom_vpos + dvpos, - bottom_vpos, 0); + clear_glyph_matrix_rows (current_matrix, bottom_vpos + dvpos, + bottom_vpos); } else if (dvpos > 0) { rotate_matrix (current_matrix, first_unchanged_at_end_vpos, bottom_vpos, dvpos); - enable_glyph_matrix_rows (current_matrix, first_unchanged_at_end_vpos, - first_unchanged_at_end_vpos + dvpos, 0); + clear_glyph_matrix_rows (current_matrix, first_unchanged_at_end_vpos, + first_unchanged_at_end_vpos + dvpos); } /* For frame-based redisplay, make sure that current frame and window ------------------------------------------------------------ revno: 109795 committer: martin rudalics branch nick: trunk timestamp: Mon 2012-08-27 23:07:32 +0200 message: In Fset_window_configuration revert first part of last change. * window.c (Fset_window_configuration): Revert first part of last change. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 18:53:10 +0000 +++ src/ChangeLog 2012-08-27 21:07:32 +0000 @@ -1,3 +1,8 @@ +2012-08-27 Martin Rudalics + + * window.c (Fset_window_configuration): Revert first part of + last change. + 2012-08-27 Jan Djärv * nsterm.h (NSPanel): New class variable dialog_return. === modified file 'src/window.c' --- src/window.c 2012-08-27 08:31:19 +0000 +++ src/window.c 2012-08-27 21:07:32 +0000 @@ -5616,24 +5616,6 @@ int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); - /* Don't do this within the main loop below: This may call Lisp - code and is thus potentially unsafe while input is blocked. */ - for (k = 0; k < saved_windows->header.size; k++) - { - p = SAVED_WINDOW_N (saved_windows, k); - window = p->window; - w = XWINDOW (window); - - if (!NILP (p->buffer) - && ((!EQ (w->buffer, p->buffer) - && !NILP (BVAR (XBUFFER (p->buffer), name))) - || NILP (w->buffer) - || NILP (BVAR (XBUFFER (w->buffer), name)))) - /* Record old buffer of window when its buffer is going to - change. */ - call1 (Qrecord_window_buffer, window); - } - /* The mouse highlighting code could get screwed up if it runs during this. */ BLOCK_INPUT; ------------------------------------------------------------ revno: 109794 fixes bug: http://debbugs.gnu.org/12258 committer: Jan D. branch nick: trunk timestamp: Mon 2012-08-27 20:53:10 +0200 message: * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize dialog_return. (windowShouldClose:): Use stop instead of stopModalWithCode. (clicked:): Ditto, and also set dialog_return. (timeout_handler:): Use stop instead of abortModal. Send a dummy event. (runDialogAt:): Make ret Lisp_Object. Set it from dialog_return when modal loop returns. * nsterm.h (NSPanel): New class variable dialog_return. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 17:23:48 +0000 +++ src/ChangeLog 2012-08-27 18:53:10 +0000 @@ -1,3 +1,16 @@ +2012-08-27 Jan Djärv + + * nsterm.h (NSPanel): New class variable dialog_return. + + * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize + dialog_return. + (windowShouldClose:): Use stop instead of stopModalWithCode. + (clicked:): Ditto, and also set dialog_return (Bug#12258). + (timeout_handler:): Use stop instead of abortModal. Send a dummy + event. + (runDialogAt:): Make ret Lisp_Object. Set it from dialog_return when + modal loop returns. + 2012-08-27 Paul Eggert * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans. === modified file 'src/nsmenu.m' --- src/nsmenu.m 2012-08-17 21:52:15 +0000 +++ src/nsmenu.m 2012-08-27 18:53:10 +0000 @@ -1497,6 +1497,7 @@ FlippedView *contentView; NSImage *img; + dialog_return = Qundefined; area.origin.x = 3*SPACER; area.origin.y = 2*SPACER; area.size.width = ICONSIZE; @@ -1584,7 +1585,7 @@ - (BOOL)windowShouldClose: (id)sender { - [NSApp stopModalWithCode: XHASH (Qnil)]; // FIXME: BIG UGLY HACK!! + [NSApp stop:self]; return NO; } @@ -1673,7 +1674,11 @@ seltag = [[sellist objectAtIndex: 0] tag]; if (seltag != XHASH (Qundefined)) // FIXME: BIG UGLY HACK!! - [NSApp stopModalWithCode: seltag]; + { + dialog_return = seltag; + [NSApp stop:self]; + } + return self; } @@ -1756,13 +1761,27 @@ - (void)timeout_handler: (NSTimer *)timedEntry { + NSEvent *nxev = [NSEvent otherEventWithType: NSApplicationDefined + location: NSMakePoint (0, 0) + modifierFlags: 0 + timestamp: 0 + windowNumber: [[NSApp mainWindow] windowNumber] + context: [NSApp context] + subtype: 0 + data1: 0 + data2: 0]; + timer_fired = 1; - [NSApp abortModal]; + /* We use sto because stopModal/abortModal out of the main loop does not + seem to work in 10.6. But as we use stop we must send a real event so + the stop is seen and acted upon. */ + [NSApp stop:self]; + [NSApp postEvent: nxev atStart: NO]; } - (Lisp_Object)runDialogAt: (NSPoint)p { - NSInteger ret = 0; + Lisp_Object ret = Qundefined; while (popup_activated_flag) { @@ -1781,7 +1800,9 @@ forMode: NSModalPanelRunLoopMode]; } timer_fired = 0; + dialog_return = Qundefined; ret = [NSApp runModalForWindow: self]; + ret = dialog_return; if (! timer_fired) { if (tmo != nil) [tmo invalidate]; /* Cancels timer */ === modified file 'src/nsterm.h' --- src/nsterm.h 2012-08-16 06:40:57 +0000 +++ src/nsterm.h 2012-08-27 18:53:10 +0000 @@ -196,6 +196,7 @@ NSMatrix *matrix; int rows, cols; int timer_fired; + Lisp_Object dialog_return; } - initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ; - addButton: (char *)str value: (Lisp_Object)val row: (int)row; ------------------------------------------------------------ revno: 109793 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-08-27 10:23:48 -0700 message: * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans. * composite.c (find_composition, composition_gstring_p) (composition_reseat_it, find_automatic_composition): * data.c (let_shadows_buffer_binding_p) (let_shadows_global_binding_p, set_internal, make_blv) (Fmake_variable_buffer_local, Fmake_local_variable) (Fmake_variable_frame_local, arithcompare, cons_to_unsigned) (cons_to_signed, arith_driver): * dbusbind.c (xd_in_read_queued_messages): * dired.c (directory_files_internal, file_name_completion): Use bool for booleans. * dired.c (file_name_completion): * process.h (fd_callback): Omit int (actually boolean) argument. It wasn't being used. All uses changed. * composite.h, lisp.h: Reflect above API changes. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 16:19:34 +0000 +++ src/ChangeLog 2012-08-27 17:23:48 +0000 @@ -1,5 +1,22 @@ 2012-08-27 Paul Eggert + * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans. + * composite.c (find_composition, composition_gstring_p) + (composition_reseat_it, find_automatic_composition): + * data.c (let_shadows_buffer_binding_p) + (let_shadows_global_binding_p, set_internal, make_blv) + (Fmake_variable_buffer_local, Fmake_local_variable) + (Fmake_variable_frame_local, arithcompare, cons_to_unsigned) + (cons_to_signed, arith_driver): + * dbusbind.c (xd_in_read_queued_messages): + * dired.c (directory_files_internal, file_name_completion): + Use bool for booleans. + * dired.c (file_name_completion): + * process.h (fd_callback): + Omit int (actually boolean) argument. It wasn't being used. + All uses changed. + * composite.h, lisp.h: Reflect above API changes. + * cmds.c, coding.c: Use bool for booleans. * cmds.c (move_point, Fself_insert_command): * coding.h (struct composition status, struct coding_system): === modified file 'src/composite.c' --- src/composite.c 2012-08-07 07:33:18 +0000 +++ src/composite.c 2012-08-27 17:23:48 +0000 @@ -428,7 +428,7 @@ This doesn't check the validity of composition. */ -int +bool find_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t *start, ptrdiff_t *end, Lisp_Object *prop, Lisp_Object object) @@ -709,7 +709,7 @@ Lisp_Object, Lisp_Object, Lisp_Object); -int +bool composition_gstring_p (Lisp_Object gstring) { Lisp_Object header; @@ -1212,11 +1212,13 @@ string. In that case, FACE must not be NULL. If the character is composed, setup members of CMP_IT (id, nglyphs, - from, to, reversed_p), and return 1. Otherwise, update - CMP_IT->stop_pos, and return 0. */ + from, to, reversed_p), and return true. Otherwise, update + CMP_IT->stop_pos, and return false. */ -int -composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, struct face *face, Lisp_Object string) +bool +composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, + ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, + struct face *face, Lisp_Object string) { if (endpos < 0) endpos = NILP (string) ? BEGV : 0; @@ -1482,10 +1484,10 @@ /* This is like find_composition, but find an automatic composition instead. It is assured that POS is not within a static composition. If found, set *GSTRING to the glyph-string - representing the composition, and return 1. Otherwise, *GSTRING to - Qnil, and return 0. */ + representing the composition, and return true. Otherwise, *GSTRING to + Qnil, and return false. */ -static int +static bool find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t *start, ptrdiff_t *end, Lisp_Object *gstring, Lisp_Object string) @@ -1498,7 +1500,7 @@ int c; Lisp_Object window; struct window *w; - int need_adjustment = 0; + bool need_adjustment = 0; window = Fget_buffer_window (Fcurrent_buffer (), Qnil); if (NILP (window)) === modified file 'src/composite.h' --- src/composite.h 2012-08-02 07:31:34 +0000 +++ src/composite.h 2012-08-27 17:23:48 +0000 @@ -223,8 +223,8 @@ extern Lisp_Object composition_hash_table; extern ptrdiff_t get_composition_id (ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object); -extern int find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *, - Lisp_Object *, Lisp_Object); +extern bool find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *, + Lisp_Object *, Lisp_Object); extern void update_compositions (ptrdiff_t, ptrdiff_t, int); extern void make_composition_value_copy (Lisp_Object); extern void compose_region (int, int, Lisp_Object, Lisp_Object, @@ -310,17 +310,16 @@ extern Lisp_Object composition_gstring_put_cache (Lisp_Object, ptrdiff_t); extern Lisp_Object composition_gstring_from_id (ptrdiff_t); -extern int composition_gstring_p (Lisp_Object); +extern bool composition_gstring_p (Lisp_Object); extern int composition_gstring_width (Lisp_Object, ptrdiff_t, ptrdiff_t, struct font_metrics *); extern void composition_compute_stop_pos (struct composition_it *, ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object); -extern int composition_reseat_it (struct composition_it *, - ptrdiff_t, ptrdiff_t, ptrdiff_t, - struct window *, struct face *, - Lisp_Object); +extern bool composition_reseat_it (struct composition_it *, ptrdiff_t, + ptrdiff_t, ptrdiff_t, struct window *, + struct face *, Lisp_Object); extern int composition_update_it (struct composition_it *, ptrdiff_t, ptrdiff_t, Lisp_Object); === modified file 'src/data.c' --- src/data.c 2012-08-26 10:04:27 +0000 +++ src/data.c 2012-08-27 17:23:48 +0000 @@ -1080,10 +1080,10 @@ return newval; } -/* Return 1 if SYMBOL currently has a let-binding +/* Return true if SYMBOL currently has a let-binding which was made in the buffer that is now current. */ -static int +static bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) { struct specbinding *p; @@ -1102,7 +1102,7 @@ return 0; } -static int +static bool let_shadows_global_binding_p (Lisp_Object symbol) { struct specbinding *p; @@ -1118,14 +1118,15 @@ If buffer/frame-locality is an issue, WHERE specifies which context to use. (nil stands for the current buffer/frame). - If BINDFLAG is zero, then if this symbol is supposed to become + If BINDFLAG is false, then if this symbol is supposed to become local in every buffer where it is set, then we make it local. - If BINDFLAG is nonzero, we don't do that. */ + If BINDFLAG is true, we don't do that. */ void -set_internal (register Lisp_Object symbol, register Lisp_Object newval, register Lisp_Object where, int bindflag) +set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, + bool bindflag) { - int voide = EQ (newval, Qunbound); + bool voide = EQ (newval, Qunbound); struct Lisp_Symbol *sym; Lisp_Object tem1; @@ -1464,7 +1465,8 @@ }; static struct Lisp_Buffer_Local_Value * -make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) +make_blv (struct Lisp_Symbol *sym, bool forwarded, + union Lisp_Val_Fwd valcontents) { struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv); Lisp_Object symbol; @@ -1508,7 +1510,7 @@ struct Lisp_Symbol *sym; struct Lisp_Buffer_Local_Value *blv = NULL; union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); - int forwarded IF_LINT (= 0); + bool forwarded IF_LINT (= 0); CHECK_SYMBOL (variable); sym = XSYMBOL (variable); @@ -1580,10 +1582,10 @@ Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. */) - (register Lisp_Object variable) + (Lisp_Object variable) { - register Lisp_Object tem; - int forwarded IF_LINT (= 0); + Lisp_Object tem; + bool forwarded IF_LINT (= 0); union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); struct Lisp_Symbol *sym; struct Lisp_Buffer_Local_Value *blv = NULL; @@ -1767,9 +1769,9 @@ Note that since Emacs 23.1, variables cannot be both buffer-local and frame-local any more (buffer-local bindings used to take precedence over frame-local bindings). */) - (register Lisp_Object variable) + (Lisp_Object variable) { - int forwarded; + bool forwarded; union Lisp_Val_Fwd valcontents; struct Lisp_Symbol *sym; struct Lisp_Buffer_Local_Value *blv = NULL; @@ -2225,7 +2227,7 @@ arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) { double f1 = 0, f2 = 0; - int floatp = 0; + bool floatp = 0; CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1); CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2); @@ -2342,7 +2344,7 @@ uintmax_t cons_to_unsigned (Lisp_Object c, uintmax_t max) { - int valid = 0; + bool valid = 0; uintmax_t val IF_LINT (= 0); if (INTEGERP (c)) { @@ -2395,7 +2397,7 @@ intmax_t cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max) { - int valid = 0; + bool valid = 0; intmax_t val IF_LINT (= 0); if (INTEGERP (c)) { @@ -2513,14 +2515,11 @@ static Lisp_Object arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) { - register Lisp_Object val; - ptrdiff_t argnum; - register EMACS_INT accum = 0; - register EMACS_INT next; - - int overflow = 0; - ptrdiff_t ok_args; - EMACS_INT ok_accum; + Lisp_Object val; + ptrdiff_t argnum, ok_args; + EMACS_INT accum = 0; + EMACS_INT next, ok_accum; + bool overflow = 0; switch (code) { === modified file 'src/dbusbind.c' --- src/dbusbind.c 2012-08-21 16:54:50 +0000 +++ src/dbusbind.c 2012-08-27 17:23:48 +0000 @@ -70,7 +70,7 @@ static Lisp_Object xd_registered_buses; /* Whether we are reading a D-Bus event. */ -static int xd_in_read_queued_messages = 0; +static bool xd_in_read_queued_messages = 0; /* We use "xd_" and "XD_" as prefix for all internal symbols, because @@ -997,8 +997,7 @@ } /* Prototype. */ -static void -xd_read_queued_messages (int fd, void *data, int for_read); +static void xd_read_queued_messages (int fd, void *data); /* Start monitoring WATCH for possible I/O. */ static dbus_bool_t @@ -1686,7 +1685,7 @@ /* Callback called when something is ready to read or write. */ static void -xd_read_queued_messages (int fd, void *data, int for_read) +xd_read_queued_messages (int fd, void *data) { Lisp_Object busp = xd_registered_buses; Lisp_Object bus = Qnil; === modified file 'src/dired.c' --- src/dired.c 2012-08-03 23:36:11 +0000 +++ src/dired.c 2012-08-27 17:23:48 +0000 @@ -109,18 +109,20 @@ } /* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. - When ATTRS is zero, return a list of directory filenames; when - non-zero, return a list of directory filenames and their attributes. + If not ATTRS, return a list of directory filenames; + if ATTRS, return a list of directory filenames and their attributes. In the latter case, ID_FORMAT is passed to Ffile_attributes. */ Lisp_Object -directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort, int attrs, Lisp_Object id_format) +directory_files_internal (Lisp_Object directory, Lisp_Object full, + Lisp_Object match, Lisp_Object nosort, bool attrs, + Lisp_Object id_format) { DIR *d; ptrdiff_t directory_nbytes; Lisp_Object list, dirfilename, encoded_directory; struct re_pattern_buffer *bufp = NULL; - int needsep = 0; + bool needsep = 0; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; DIRENTRY *dp; @@ -227,7 +229,7 @@ if (DIRENTRY_NONEMPTY (dp)) { ptrdiff_t len; - int wanted = 0; + bool wanted = 0; Lisp_Object name, finalname; struct gcpro gcpro1, gcpro2; @@ -381,9 +383,8 @@ } -static Lisp_Object file_name_completion - (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, - Lisp_Object predicate); +static Lisp_Object file_name_completion (Lisp_Object, Lisp_Object, bool, + Lisp_Object); DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, 2, 3, 0, @@ -415,7 +416,7 @@ if (!NILP (handler)) return call4 (handler, Qfile_name_completion, file, directory, predicate); - return file_name_completion (file, directory, 0, 0, predicate); + return file_name_completion (file, directory, 0, predicate); } DEFUN ("file-name-all-completions", Ffile_name_all_completions, @@ -439,14 +440,15 @@ if (!NILP (handler)) return call3 (handler, Qfile_name_all_completions, file, directory); - return file_name_completion (file, directory, 1, 0, Qnil); + return file_name_completion (file, directory, 1, Qnil); } static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr); static Lisp_Object Qdefault_directory; static Lisp_Object -file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, Lisp_Object predicate) +file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, + Lisp_Object predicate) { DIR *d; ptrdiff_t bestmatchsize = 0; @@ -459,10 +461,10 @@ Lisp_Object encoded_dir; struct stat st; int directoryp; - /* If includeall is zero, exclude files in completion-ignored-extensions as + /* If not INCLUDEALL, exclude files in completion-ignored-extensions as well as "." and "..". Until shown otherwise, assume we can't exclude anything. */ - int includeall = 1; + bool includeall = 1; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; @@ -500,7 +502,7 @@ { DIRENTRY *dp; ptrdiff_t len; - int canexclude = 0; + bool canexclude = 0; errno = 0; dp = readdir (d); === modified file 'src/lisp.h' --- src/lisp.h 2012-08-27 16:19:34 +0000 +++ src/lisp.h 2012-08-27 17:23:48 +0000 @@ -2620,7 +2620,7 @@ Lisp_Object); extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); -extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, int); +extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool); extern void syms_of_data (void); extern void init_data (void); extern void swap_in_global_binding (struct Lisp_Symbol *); @@ -3434,7 +3434,7 @@ extern void syms_of_dired (void); extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, - int, Lisp_Object); + bool, Lisp_Object); /* Defined in term.c */ extern int *char_ins_del_vector; === modified file 'src/process.c' --- src/process.c 2012-08-19 21:00:09 +0000 +++ src/process.c 2012-08-27 17:23:48 +0000 @@ -4870,15 +4870,13 @@ for (channel = 0; channel <= max_input_desc; ++channel) { struct fd_callback_data *d = &fd_callback_info[channel]; - if (FD_ISSET (channel, &Available) - && d->func != 0 - && (d->condition & FOR_READ) != 0) - d->func (channel, d->data, 1); - if (FD_ISSET (channel, &write_mask) - && d->func != 0 - && (d->condition & FOR_WRITE) != 0) - d->func (channel, d->data, 0); - } + if (d->func + && ((d->condition & FOR_READ + && FD_ISSET (channel, &Available)) + || (d->condition & FOR_WRITE + && FD_ISSET (channel, &write_mask)))) + d->func (channel, d->data); + } for (channel = 0; channel <= max_process_desc; channel++) { === modified file 'src/process.h' --- src/process.h 2012-08-25 03:11:12 +0000 +++ src/process.h 2012-08-27 17:23:48 +0000 @@ -219,7 +219,7 @@ extern void unhold_keyboard_input (void); extern int kbd_on_hold_p (void); -typedef void (*fd_callback)(int fd, void *data, int for_read); +typedef void (*fd_callback) (int fd, void *data); extern void add_read_fd (int fd, fd_callback func, void *data); extern void delete_read_fd (int fd); === modified file 'src/xsmfns.c' --- src/xsmfns.c 2012-01-19 07:21:25 +0000 +++ src/xsmfns.c 2012-08-27 17:23:48 +0000 @@ -97,7 +97,7 @@ open to a session manager, just return. */ static void -x_session_check_input (int fd, void *data, int for_read) +x_session_check_input (int fd, void *data) { int ret; ------------------------------------------------------------ revno: 109792 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-08-27 09:19:34 -0700 message: * cmds.c, coding.c: Use bool for booleans. * cmds.c (move_point, Fself_insert_command): * coding.h (struct composition status, struct coding_system): * coding.c (detect_coding_utf_8, encode_coding_utf_8) (detect_coding_utf_16, encode_coding_utf_16, detect_coding_emacs_mule) (emacs_mule_char, decode_coding_emacs_mule) (encode_coding_emacs_mule, detect_coding_iso_2022) (decode_coding_iso_2022, encode_invocation_designation) (encode_designation_at_bol, encode_coding_iso_2022) (detect_coding_sjis, detect_coding_big5, decode_coding_sjis) (decode_coding_big5, encode_coding_sjis, encode_coding_big5) (detect_coding_ccl, encode_coding_ccl, decode_coding_raw_text) (encode_coding_raw_text, detect_coding_charset) (decode_coding_charset, encode_coding_charset, detect_eol) (detect_coding, get_translation_table, produce_chars) (consume_chars, reused_workbuf_in_use) (make_conversion_work_buffer, code_conversion_save) (decode_coding_object, encode_coding_object) (detect_coding_system, char_encodable_p) (Funencodable_char_position, code_convert_region) (code_convert_string, code_convert_string_norecord) (Fset_coding_system_priority): * fileio.c (Finsert_file_contents): Use bool for booleans. * coding.h, lisp.h: Reflect above API changes. * coding.c: Remove unnecessary static function decls. (detect_coding): Use unsigned, not signed, to copy an unsigned field. (decode_coding, encode_coding, decode_coding_gap): Return 'void', not a boolean 'int', since callers never look at the return value. (ALLOC_CONVERSION_WORK_AREA): Assume caller returns 'void', not 'int'. * coding.h (decoding_buffer_size, encoding_buffer_size) (emacs_mule_string_char): Remove unused extern decls. (struct iso_2022_spec, struct coding_system): Use 'unsigned int : 1' for boolean fields, since there's more than one. (struct emacs_mule_spec): Remove unused field 'full_support'. All initializations removed. * cmds.c (internal_self_insert): Don't assume EMACS_INT fits in 'int'. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 09:30:26 +0000 +++ src/ChangeLog 2012-08-27 16:19:34 +0000 @@ -1,6 +1,46 @@ +2012-08-27 Paul Eggert + + * cmds.c, coding.c: Use bool for booleans. + * cmds.c (move_point, Fself_insert_command): + * coding.h (struct composition status, struct coding_system): + * coding.c (detect_coding_utf_8, encode_coding_utf_8) + (detect_coding_utf_16, encode_coding_utf_16, detect_coding_emacs_mule) + (emacs_mule_char, decode_coding_emacs_mule) + (encode_coding_emacs_mule, detect_coding_iso_2022) + (decode_coding_iso_2022, encode_invocation_designation) + (encode_designation_at_bol, encode_coding_iso_2022) + (detect_coding_sjis, detect_coding_big5, decode_coding_sjis) + (decode_coding_big5, encode_coding_sjis, encode_coding_big5) + (detect_coding_ccl, encode_coding_ccl, decode_coding_raw_text) + (encode_coding_raw_text, detect_coding_charset) + (decode_coding_charset, encode_coding_charset, detect_eol) + (detect_coding, get_translation_table, produce_chars) + (consume_chars, reused_workbuf_in_use) + (make_conversion_work_buffer, code_conversion_save) + (decode_coding_object, encode_coding_object) + (detect_coding_system, char_encodable_p) + (Funencodable_char_position, code_convert_region) + (code_convert_string, code_convert_string_norecord) + (Fset_coding_system_priority): + * fileio.c (Finsert_file_contents): + Use bool for booleans. + * coding.h, lisp.h: Reflect above API changes. + * coding.c: Remove unnecessary static function decls. + (detect_coding): Use unsigned, not signed, to copy an unsigned field. + (decode_coding, encode_coding, decode_coding_gap): Return 'void', + not a boolean 'int', since callers never look at the return value. + (ALLOC_CONVERSION_WORK_AREA): Assume caller returns 'void', not 'int'. + * coding.h (decoding_buffer_size, encoding_buffer_size) + (emacs_mule_string_char): Remove unused extern decls. + (struct iso_2022_spec, struct coding_system): + Use 'unsigned int : 1' for boolean fields, since there's more than one. + (struct emacs_mule_spec): Remove unused field 'full_support'. + All initializations removed. + * cmds.c (internal_self_insert): Don't assume EMACS_INT fits in 'int'. + 2012-08-27 Dmitry Antipov - Fix spare memory change. + Fix spare memory change (Bug#12286). * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE. (valid_lisp_object_p): Likewise. === modified file 'src/charset.h' --- src/charset.h 2012-08-26 08:41:36 +0000 +++ src/charset.h 2012-08-27 16:19:34 +0000 @@ -496,7 +496,7 @@ -/* 1 if CHARSET may contain the character C. */ +/* True if CHARSET may contain the character C. */ #define CHAR_CHARSET_P(c, charset) \ ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \ || ((CHARSET_UNIFIED_P (charset) \ === modified file 'src/cmds.c' --- src/cmds.c 2012-08-18 06:06:39 +0000 +++ src/cmds.c 2012-08-27 16:19:34 +0000 @@ -47,10 +47,10 @@ return make_number (PT + XINT (n)); } -/* Add N to point; or subtract N if FORWARD is zero. N defaults to 1. +/* Add N to point; or subtract N if FORWARD is false. N defaults to 1. Validate the new location. Return nil. */ static Lisp_Object -move_point (Lisp_Object n, int forward) +move_point (Lisp_Object n, bool forward) { /* This used to just set point to point + XINT (n), and then check to see if it was within boundaries. But now that SET_PT can @@ -277,7 +277,7 @@ At the end, it runs `post-self-insert-hook'. */) (Lisp_Object n) { - int remove_boundary = 1; + bool remove_boundary = 1; CHECK_NATNUM (n); if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) @@ -438,7 +438,7 @@ : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) == Sword)) { - int modiff = MODIFF; + EMACS_INT modiff = MODIFF; Lisp_Object sym; sym = call0 (Qexpand_abbrev); === modified file 'src/coding.c' --- src/coding.c 2012-08-18 06:06:39 +0000 +++ src/coding.c 2012-08-27 16:19:34 +0000 @@ -147,18 +147,18 @@ CODING conforms to the format of XXX, and update the members of DETECT_INFO. - Return 1 if the byte sequence conforms to XXX, otherwise return 0. + Return true if the byte sequence conforms to XXX. Below is the template of these functions. */ #if 0 -static int +static bool detect_coding_XXX (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; int found = 0; ...; @@ -212,7 +212,7 @@ /* A buffer to produce decoded characters. */ int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; while (1) { @@ -260,7 +260,7 @@ static void encode_coding_XXX (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf->charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -651,8 +651,8 @@ /* Safely get one byte from the source text pointed by SRC which ends at SRC_END, and set C to that byte. If there are not enough bytes - in the source, it jumps to `no_more_source'. If multibytep is - nonzero, and a multibyte character is found at SRC, set C to the + in the source, it jumps to 'no_more_source'. If MULTIBYTEP, + and a multibyte character is found at SRC, set C to the negative value of the character code. The caller should declare and set these variables appropriately in advance: src, src_end, multibytep */ @@ -685,7 +685,7 @@ /* Safely get two bytes from the source text pointed by SRC which ends at SRC_END, and set C1 and C2 to those bytes while skipping the heading multibyte characters. If there are not enough bytes in the - source, it jumps to `no_more_source'. If multibytep is nonzero and + source, it jumps to 'no_more_source'. If MULTIBYTEP and a multibyte character is found for C2, set C2 to the negative value of the character code. The caller should declare and set these variables appropriately in advance: @@ -746,8 +746,8 @@ /* Store a byte C in the place pointed by DST and increment DST to the - next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is - nonzero, store in an appropriate multibyte from. The caller should + next free point, and increment PRODUCED_CHARS. If MULTIBYTEP, + store in an appropriate multibyte form. The caller should declare and set the variables `dst' and `multibytep' appropriately in advance. */ @@ -806,83 +806,6 @@ } while (0) -/* Prototypes for static functions. */ -static void record_conversion_result (struct coding_system *coding, - enum coding_result_code result); -static int detect_coding_utf_8 (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_utf_8 (struct coding_system *); -static int encode_coding_utf_8 (struct coding_system *); - -static int detect_coding_utf_16 (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_utf_16 (struct coding_system *); -static int encode_coding_utf_16 (struct coding_system *); - -static int detect_coding_iso_2022 (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_iso_2022 (struct coding_system *); -static int encode_coding_iso_2022 (struct coding_system *); - -static int detect_coding_emacs_mule (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_emacs_mule (struct coding_system *); -static int encode_coding_emacs_mule (struct coding_system *); - -static int detect_coding_sjis (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_sjis (struct coding_system *); -static int encode_coding_sjis (struct coding_system *); - -static int detect_coding_big5 (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_big5 (struct coding_system *); -static int encode_coding_big5 (struct coding_system *); - -static int detect_coding_ccl (struct coding_system *, - struct coding_detection_info *info); -static void decode_coding_ccl (struct coding_system *); -static int encode_coding_ccl (struct coding_system *); - -static void decode_coding_raw_text (struct coding_system *); -static int encode_coding_raw_text (struct coding_system *); - -static void coding_set_source (struct coding_system *); -static ptrdiff_t coding_change_source (struct coding_system *); -static void coding_set_destination (struct coding_system *); -static ptrdiff_t coding_change_destination (struct coding_system *); -static void coding_alloc_by_realloc (struct coding_system *, ptrdiff_t); -static void coding_alloc_by_making_gap (struct coding_system *, - ptrdiff_t, ptrdiff_t); -static unsigned char *alloc_destination (struct coding_system *, - ptrdiff_t, unsigned char *); -static void setup_iso_safe_charsets (Lisp_Object); -static ptrdiff_t encode_designation_at_bol (struct coding_system *, - int *, int *, unsigned char *); -static int detect_eol (const unsigned char *, - ptrdiff_t, enum coding_category); -static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); -static void decode_eol (struct coding_system *); -static Lisp_Object get_translation_table (Lisp_Object, int, int *); -static Lisp_Object get_translation (Lisp_Object, int *, int *); -static int produce_chars (struct coding_system *, Lisp_Object, int); -static inline void produce_charset (struct coding_system *, int *, - ptrdiff_t); -static void produce_annotation (struct coding_system *, ptrdiff_t); -static int decode_coding (struct coding_system *); -static inline int *handle_composition_annotation (ptrdiff_t, ptrdiff_t, - struct coding_system *, - int *, ptrdiff_t *); -static inline int *handle_charset_annotation (ptrdiff_t, ptrdiff_t, - struct coding_system *, - int *, ptrdiff_t *); -static void consume_chars (struct coding_system *, Lisp_Object, int); -static int encode_coding (struct coding_system *); -static Lisp_Object make_conversion_work_buffer (int); -static Lisp_Object code_conversion_restore (Lisp_Object); -static inline int char_encodable_p (int, Lisp_Object); -static Lisp_Object make_subsidiaries (Lisp_Object); - static void record_conversion_result (struct coding_system *coding, enum coding_result_code result) @@ -1264,8 +1187,7 @@ /*** 3. UTF-8 ***/ /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in UTF-8. If it is, return 1, else - return 0. */ + Return true if a text is encoded in UTF-8. */ #define UTF_8_1_OCTET_P(c) ((c) < 0x80) #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) @@ -1278,16 +1200,16 @@ #define UTF_8_BOM_2 0xBB #define UTF_8_BOM_3 0xBF -static int +static bool detect_coding_utf_8 (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; - int bom_found = 0; - int found = 0; + bool bom_found = 0; + bool found = 0; detect_info->checked |= CATEGORY_MASK_UTF_8; /* A coding system of this category is always ASCII compatible. */ @@ -1371,10 +1293,10 @@ int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; if (bom != utf_without_bom) @@ -1513,10 +1435,10 @@ } -static int +static bool encode_coding_utf_8 (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -1577,8 +1499,7 @@ /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in one of UTF-16 based coding systems. - If it is, return 1, else return 0. */ + Return true if a text is encoded in one of UTF-16 based coding systems. */ #define UTF_16_HIGH_SURROGATE_P(val) \ (((val) & 0xFC00) == 0xD800) @@ -1587,13 +1508,13 @@ (((val) & 0xFC00) == 0xDC00) -static int +static bool detect_coding_utf_16 (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; int c1, c2; detect_info->checked |= CATEGORY_MASK_UTF_16; @@ -1680,12 +1601,12 @@ /* We may produces at most 3 chars in one loop. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_16_BOM (coding); enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); int surrogate = CODING_UTF_16_SURROGATE (coding); - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr1 = -1, byte_after_cr2 = -1; if (bom == utf_with_bom) @@ -1795,17 +1716,17 @@ coding->charbuf_used = charbuf - coding->charbuf; } -static int +static bool encode_coding_utf_16 (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 8; enum utf_bom_type bom = CODING_UTF_16_BOM (coding); - int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; + bool big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; ptrdiff_t produced_chars = 0; int c; @@ -1930,16 +1851,15 @@ /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in `emacs-mule'. If it is, return 1, - else return 0. */ + Return true if a text is encoded in 'emacs-mule'. */ -static int +static bool detect_coding_emacs_mule (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; int c; int found = 0; @@ -2029,12 +1949,12 @@ { const unsigned char *src_end = coding->source + coding->src_bytes; const unsigned char *src_base = src; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; int charset_ID; unsigned code; int c; int consumed_chars = 0; - int mseq_found = 0; + bool mseq_found = 0; ONE_MORE_BYTE (c); if (c < 0) @@ -2411,12 +2331,12 @@ /* We can produce up to 2 characters in a loop. */ - 1; ptrdiff_t consumed_chars = 0, consumed_chars_base; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t char_offset = coding->produced_char; ptrdiff_t last_offset = char_offset; int last_id = charset_ascii; - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; @@ -2657,10 +2577,10 @@ } while (0); -static int +static bool encode_coding_emacs_mule (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -2722,7 +2642,7 @@ if (preferred_charset_id >= 0) { - int result; + bool result; charset = CHARSET_FROM_ID (preferred_charset_id); CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); @@ -3017,17 +2937,17 @@ /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in one of ISO-2022 based coding systems. - If it is, return 1, else return 0. */ + Return true if a text is encoded in one of ISO-2022 based coding + systems. */ -static int +static bool detect_coding_iso_2022 (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base = src; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; - int single_shifting = 0; + bool multibytep = coding->src_multibyte; + bool single_shifting = 0; int id; int c, c1; ptrdiff_t consumed_chars = 0; @@ -3390,8 +3310,6 @@ /* Finish the current composition as invalid. */ -static int finish_composition (int *, struct composition_status *); - static int finish_composition (int *charbuf, struct composition_status *cmp_status) { @@ -3541,7 +3459,7 @@ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); ptrdiff_t consumed_chars = 0, consumed_chars_base; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; /* Charsets invoked to graphic plane 0 and 1 respectively. */ int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); @@ -3553,8 +3471,8 @@ ptrdiff_t char_offset = coding->produced_char; ptrdiff_t last_offset = char_offset; int last_id = charset_ascii; - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; int i; @@ -4282,7 +4200,7 @@ struct coding_system *coding, unsigned char *dst, ptrdiff_t *p_nchars) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; ptrdiff_t produced_chars = *p_nchars; int reg; /* graphic register number */ int id = CHARSET_ID (charset); @@ -4380,7 +4298,7 @@ int r[4]; int c, found = 0, reg; ptrdiff_t produced_chars = 0; - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; Lisp_Object attrs; Lisp_Object charset_list; @@ -4422,21 +4340,21 @@ /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ -static int +static bool encode_coding_iso_2022 (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 16; - int bol_designation + bool bol_designation = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL && CODING_ISO_BOL (coding)); ptrdiff_t produced_chars = 0; Lisp_Object attrs, eol_type, charset_list; - int ascii_compatible; + bool ascii_compatible; int c; int preferred_charset_id = -1; @@ -4523,8 +4441,9 @@ CODING_ISO_DESIGNATION (coding, i) = CODING_ISO_INITIAL (coding, i); } - bol_designation - = CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL; + bol_designation = ((CODING_ISO_FLAGS (coding) + & CODING_ISO_FLAG_DESIGNATE_AT_BOL) + != 0); } else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) ENCODE_RESET_PLANE_AND_REGISTER (); @@ -4551,7 +4470,7 @@ if (preferred_charset_id >= 0) { - int result; + bool result; charset = CHARSET_FROM_ID (preferred_charset_id); CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); @@ -4631,16 +4550,15 @@ */ /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in SJIS. If it is, return - CATEGORY_MASK_SJIS, else return 0. */ + Return true if a text is encoded in SJIS. */ -static int +static bool detect_coding_sjis (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; int found = 0; int c; @@ -4688,16 +4606,15 @@ } /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in BIG5. If it is, return - CATEGORY_MASK_BIG5, else return 0. */ + Return true if a text is encoded in BIG5. */ -static int +static bool detect_coding_big5 (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; int found = 0; int c; @@ -4735,8 +4652,7 @@ return 1; } -/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". - If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ +/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ static void decode_coding_sjis (struct coding_system *coding) @@ -4750,15 +4666,15 @@ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); ptrdiff_t consumed_chars = 0, consumed_chars_base; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; struct charset *charset_roman, *charset_kanji, *charset_kana; struct charset *charset_kanji2; Lisp_Object attrs, charset_list, val; ptrdiff_t char_offset = coding->produced_char; ptrdiff_t last_offset = char_offset; int last_id = charset_ascii; - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; CODING_GET_INFO (coding, attrs, charset_list); @@ -4868,14 +4784,14 @@ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); ptrdiff_t consumed_chars = 0, consumed_chars_base; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; struct charset *charset_roman, *charset_big5; Lisp_Object attrs, charset_list, val; ptrdiff_t char_offset = coding->produced_char; ptrdiff_t last_offset = char_offset; int last_id = charset_ascii; - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; CODING_GET_INFO (coding, attrs, charset_list); @@ -4957,13 +4873,12 @@ `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We are sure that all these charsets are registered as official charset (i.e. do not have extended leading-codes). Characters of other - charsets are produced without any encoding. If SJIS_P is 1, encode - SJIS text, else encode BIG5 text. */ + charsets are produced without any encoding. */ -static int +static bool encode_coding_sjis (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -4971,7 +4886,7 @@ int safe_room = 4; ptrdiff_t produced_chars = 0; Lisp_Object attrs, charset_list, val; - int ascii_compatible; + bool ascii_compatible; struct charset *charset_kanji, *charset_kana; struct charset *charset_kanji2; int c; @@ -5054,10 +4969,10 @@ return 0; } -static int +static bool encode_coding_big5 (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -5065,7 +4980,7 @@ int safe_room = 4; ptrdiff_t produced_chars = 0; Lisp_Object attrs, charset_list, val; - int ascii_compatible; + bool ascii_compatible; struct charset *charset_big5; int c; @@ -5130,17 +5045,16 @@ /*** 10. CCL handlers ***/ /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in a coding system of which - encoder/decoder are written in CCL program. If it is, return - CATEGORY_MASK_CCL, else return 0. */ + Return true if a text is encoded in a coding system of which + encoder/decoder are written in CCL program. */ -static int +static bool detect_coding_ccl (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; int found = 0; unsigned char *valids; @@ -5182,7 +5096,7 @@ int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; ptrdiff_t consumed_chars = 0; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; struct ccl_program *ccl = &coding->spec.ccl->ccl; int source_charbuf[1024]; int source_byteidx[1025]; @@ -5243,11 +5157,11 @@ coding->charbuf_used = charbuf - coding->charbuf; } -static int +static bool encode_coding_ccl (struct coding_system *coding) { struct ccl_program *ccl = &coding->spec.ccl->ccl; - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -5308,7 +5222,6 @@ return 0; } - /*** 10, 11. no-conversion handlers ***/ @@ -5317,8 +5230,8 @@ static void decode_coding_raw_text (struct coding_system *coding) { - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); coding->chars_at_source = 1; coding->consumed_char = coding->src_chars; @@ -5333,10 +5246,10 @@ record_conversion_result (coding, CODING_RESULT_SUCCESS); } -static int +static bool encode_coding_raw_text (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = coding->charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -5414,21 +5327,20 @@ } /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". - Check if a text is encoded in a charset-based coding system. If it - is, return 1, else return 0. */ + Return true if a text is encoded in a charset-based coding system. */ -static int +static bool detect_coding_charset (struct coding_system *coding, struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; ptrdiff_t consumed_chars = 0; Lisp_Object attrs, valids, name; int found = 0; ptrdiff_t head_ascii = coding->head_ascii; - int check_latin_extra = 0; + bool check_latin_extra = 0; detect_info->checked |= CATEGORY_MASK_CHARSET; @@ -5532,14 +5444,14 @@ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); ptrdiff_t consumed_chars = 0, consumed_chars_base; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; Lisp_Object attrs = CODING_ID_ATTRS (coding->id); Lisp_Object valids; ptrdiff_t char_offset = coding->produced_char; ptrdiff_t last_offset = char_offset; int last_id = charset_ascii; - int eol_dos = - !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); + bool eol_dos + = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; valids = AREF (attrs, coding_attr_charset_valids); @@ -5648,10 +5560,10 @@ coding->charbuf_used = charbuf - coding->charbuf; } -static int +static bool encode_coding_charset (struct coding_system *coding) { - int multibytep = coding->dst_multibyte; + bool multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; @@ -5659,7 +5571,7 @@ int safe_room = MAX_MULTIBYTE_LENGTH; ptrdiff_t produced_chars = 0; Lisp_Object attrs, charset_list; - int ascii_compatible; + bool ascii_compatible; int c; CODING_GET_INFO (coding, attrs, charset_list); @@ -5865,7 +5777,6 @@ coding->encoder = encode_coding_emacs_mule; coding->common_flags |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); - coding->spec.emacs_mule.full_support = 1; if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) { @@ -5883,7 +5794,6 @@ SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); coding->max_charset_id = max_charset_id; coding->safe_charsets = SDATA (safe_charsets); - coding->spec.emacs_mule.full_support = 1; } coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO; coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO; @@ -6216,11 +6126,9 @@ if ((1 << category) & CATEGORY_MASK_UTF_16) { - int msb, lsb; - - msb = category == (coding_category_utf_16_le - | coding_category_utf_16_le_nosig); - lsb = 1 - msb; + bool msb = category == (coding_category_utf_16_le + | coding_category_utf_16_le_nosig); + bool lsb = !msb; while (src + 1 < src_end) { @@ -6335,7 +6243,7 @@ detect_coding (struct coding_system *coding) { const unsigned char *src, *src_end; - int saved_mode = coding->mode; + unsigned int saved_mode = coding->mode; coding->consumed = coding->consumed_char = 0; coding->produced = coding->produced_char = 0; @@ -6350,7 +6258,7 @@ { int c, i; struct coding_detection_info detect_info; - int null_byte_found = 0, eight_bit_found = 0; + bool null_byte_found = 0, eight_bit_found = 0; detect_info.checked = detect_info.found = detect_info.rejected = 0; for (src = coding->source; src < src_end; src++) @@ -6609,11 +6517,11 @@ /* Return a translation table (or list of them) from coding system - attribute vector ATTRS for encoding (ENCODEP is nonzero) or - decoding (ENCODEP is zero). */ + attribute vector ATTRS for encoding (if ENCODEP) or decoding (if + not ENCODEP). */ static Lisp_Object -get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) +get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup) { Lisp_Object standard, translation_table; Lisp_Object val; @@ -6743,7 +6651,7 @@ static int produce_chars (struct coding_system *coding, Lisp_Object translation_table, - int last_block) + bool last_block) { unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; @@ -6846,7 +6754,7 @@ { if (coding->src_multibyte) { - int multibytep = 1; + bool multibytep = 1; ptrdiff_t consumed_chars = 0; while (1) @@ -6882,7 +6790,7 @@ else while (src < src_end) { - int multibytep = 1; + bool multibytep = 1; int c = *src++; if (dst >= dst_end - 1) @@ -7018,7 +6926,7 @@ if (! coding->charbuf) \ { \ record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ - return coding->result; \ + return; \ } \ coding->charbuf_size = size; \ } while (0) @@ -7079,7 +6987,7 @@ CODING->dst_object. */ -static int +static void decode_coding (struct coding_system *coding) { Lisp_Object attrs; @@ -7212,7 +7120,6 @@ bset_undo_list (current_buffer, undo_list); record_insert (coding->dst_pos, coding->produced_char); } - return coding->result; } @@ -7341,7 +7248,7 @@ const unsigned char *src_end = coding->source + coding->src_bytes; ptrdiff_t pos = coding->src_pos + coding->consumed_char; ptrdiff_t end_pos = coding->src_pos + coding->src_chars; - int multibytep = coding->src_multibyte; + bool multibytep = coding->src_multibyte; Lisp_Object eol_type; int c; ptrdiff_t stop, stop_composition, stop_charset; @@ -7488,7 +7395,7 @@ If CODING->dst_object is nil, the encoded data is placed at the memory area specified by CODING->destination. */ -static int +static void encode_coding (struct coding_system *coding) { Lisp_Object attrs; @@ -7530,8 +7437,6 @@ if (BUFFERP (coding->dst_object) && coding->produced_char > 0) insert_from_gap (coding->produced_char, coding->produced); - - return (coding->result); } @@ -7545,26 +7450,27 @@ versions of Vcode_conversion_workbuf_name. */ static Lisp_Object Vcode_conversion_reused_workbuf; -/* 1 iff Vcode_conversion_reused_workbuf is already in use. */ -static int reused_workbuf_in_use; +/* True iff Vcode_conversion_reused_workbuf is already in use. */ +static bool reused_workbuf_in_use; /* Return a working buffer of code conversion. MULTIBYTE specifies the multibyteness of returning buffer. */ static Lisp_Object -make_conversion_work_buffer (int multibyte) +make_conversion_work_buffer (bool multibyte) { Lisp_Object name, workbuf; struct buffer *current; - if (reused_workbuf_in_use++) + if (reused_workbuf_in_use) { name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); workbuf = Fget_buffer_create (name); } else { + reused_workbuf_in_use = 1; if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) Vcode_conversion_reused_workbuf = Fget_buffer_create (Vcode_conversion_workbuf_name); @@ -7606,7 +7512,7 @@ } Lisp_Object -code_conversion_save (int with_work_buf, int multibyte) +code_conversion_save (bool with_work_buf, bool multibyte) { Lisp_Object workbuf = Qnil; @@ -7617,7 +7523,7 @@ return workbuf; } -int +void decode_coding_gap (struct coding_system *coding, ptrdiff_t chars, ptrdiff_t bytes) { @@ -7660,7 +7566,6 @@ } unbind_to (count, Qnil); - return coding->result; } @@ -7706,8 +7611,8 @@ ptrdiff_t chars = to - from; ptrdiff_t bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte IF_LINT (= 0); - int need_marker_adjustment = 0; + ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0); + bool need_marker_adjustment = 0; Lisp_Object old_deactivate_mark; old_deactivate_mark = Vdeactivate_mark; @@ -7894,9 +7799,9 @@ ptrdiff_t chars = to - from; ptrdiff_t bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte IF_LINT (= 0); - int need_marker_adjustment = 0; - int kill_src_buffer = 0; + ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0); + bool need_marker_adjustment = 0; + bool kill_src_buffer = 0; Lisp_Object old_deactivate_mark; old_deactivate_mark = Vdeactivate_mark; @@ -8172,10 +8077,10 @@ /* Detect how the bytes at SRC of length SRC_BYTES are encoded. If - HIGHEST is nonzero, return the coding system of the highest + HIGHEST, return the coding system of the highest priority among the detected coding systems. Otherwise return a list of detected coding systems sorted by their priorities. If - MULTIBYTEP is nonzero, it is assumed that the bytes are in correct + MULTIBYTEP, it is assumed that the bytes are in correct multibyte form but contains only ASCII and eight-bit chars. Otherwise, the bytes are raw bytes. @@ -8190,7 +8095,7 @@ Lisp_Object detect_coding_system (const unsigned char *src, ptrdiff_t src_chars, ptrdiff_t src_bytes, - int highest, int multibytep, + bool highest, bool multibytep, Lisp_Object coding_system) { const unsigned char *src_end = src + src_bytes; @@ -8200,7 +8105,7 @@ ptrdiff_t id; struct coding_detection_info detect_info; enum coding_category base_category; - int null_byte_found = 0, eight_bit_found = 0; + bool null_byte_found = 0, eight_bit_found = 0; if (NILP (coding_system)) coding_system = Qundecided; @@ -8556,7 +8461,7 @@ } -static inline int +static inline bool char_encodable_p (int c, Lisp_Object attrs) { Lisp_Object tail; @@ -8728,7 +8633,7 @@ Lisp_Object positions; ptrdiff_t from, to; const unsigned char *p, *stop, *pend; - int ascii_compatible; + bool ascii_compatible; setup_coding_system (Fcheck_coding_system (coding_system), &coding); attrs = CODING_ID_ATTRS (coding.id); @@ -8952,7 +8857,7 @@ static Lisp_Object code_convert_region (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object dst_object, - int encodep, int norecord) + bool encodep, bool norecord) { struct coding_system coding; ptrdiff_t from, from_byte, to, to_byte; @@ -9040,7 +8945,8 @@ Lisp_Object code_convert_string (Lisp_Object string, Lisp_Object coding_system, - Lisp_Object dst_object, int encodep, int nocopy, int norecord) + Lisp_Object dst_object, bool encodep, bool nocopy, + bool norecord) { struct coding_system coding; ptrdiff_t chars, bytes; @@ -9088,7 +8994,7 @@ Lisp_Object code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, - int encodep) + bool encodep) { return code_convert_string (string, coding_system, Qt, encodep, 0, 1); } @@ -9489,7 +9395,7 @@ (ptrdiff_t nargs, Lisp_Object *args) { ptrdiff_t i, j; - int changed[coding_category_max]; + bool changed[coding_category_max]; enum coding_category priorities[coding_category_max]; memset (changed, 0, sizeof changed); === modified file 'src/coding.h' --- src/coding.h 2012-08-01 03:51:44 +0000 +++ src/coding.h 2012-08-27 16:19:34 +0000 @@ -321,7 +321,7 @@ { enum composition_state state; enum composition_method method; - int old_form; /* 0:pre-21 form, 1:post-21 form */ + bool old_form; /* true if pre-21 form */ int length; /* number of elements produced in charbuf */ int nchars; /* number of characters composed */ int ncomps; /* number of composition components */ @@ -350,18 +350,18 @@ there was an invalid designation previously. */ int current_designation[4]; - /* Set to 1 temporarily only when graphic register 2 or 3 is invoked - by single-shift while encoding. */ - int single_shifting; - - /* Set to 1 temporarily only when processing at beginning of line. */ - int bol; - /* If positive, we are now scanning CTEXT extended segment. */ int ctext_extended_segment_len; - /* If nonzero, we are now scanning embedded UTF-8 sequence. */ - int embedded_utf_8; + /* True temporarily only when graphic register 2 or 3 is invoked by + single-shift while encoding. */ + unsigned single_shifting : 1; + + /* True temporarily only when processing at beginning of line. */ + unsigned bol : 1; + + /* If true, we are now scanning embedded UTF-8 sequence. */ + unsigned embedded_utf_8 : 1; /* The current composition. */ struct composition_status cmp_status; @@ -369,7 +369,6 @@ struct emacs_mule_spec { - int full_support; struct composition_status cmp_status; }; @@ -470,10 +469,6 @@ Lisp_Object dst_object; unsigned char *destination; - /* Set to 1 if the source of conversion is not in the member - `charbuf', but at `src_object'. */ - int chars_at_source; - /* If an element is non-negative, it is a character code. If it is in the range -128..-1, it is a 8-bit character code @@ -489,18 +484,21 @@ int *charbuf; int charbuf_size, charbuf_used; + /* True if the source of conversion is not in the member + `charbuf', but at `src_object'. */ + unsigned chars_at_source : 1; + /* Set to 1 if charbuf contains an annotation. */ - int annotated; + unsigned annotated : 1; unsigned char carryover[64]; int carryover_bytes; int default_char; - int (*detector) (struct coding_system *, - struct coding_detection_info *); + bool (*detector) (struct coding_system *, struct coding_detection_info *); void (*decoder) (struct coding_system *); - int (*encoder) (struct coding_system *); + bool (*encoder) (struct coding_system *); }; /* Meanings of bits in the member `common_flags' of the structure @@ -688,22 +686,20 @@ #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) /* Extern declarations. */ -extern Lisp_Object code_conversion_save (int, int); -extern int decoding_buffer_size (struct coding_system *, int); -extern int encoding_buffer_size (struct coding_system *, int); +extern Lisp_Object code_conversion_save (bool, bool); extern void setup_coding_system (Lisp_Object, struct coding_system *); extern Lisp_Object coding_charset_list (struct coding_system *); extern Lisp_Object coding_system_charset_list (Lisp_Object); extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, - Lisp_Object, int, int, int); + Lisp_Object, bool, bool, bool); extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, - int); + bool); extern Lisp_Object raw_text_coding_system (Lisp_Object); extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); extern Lisp_Object complement_process_encoding_system (Lisp_Object); -extern int decode_coding_gap (struct coding_system *, - ptrdiff_t, ptrdiff_t); +extern void decode_coding_gap (struct coding_system *, + ptrdiff_t, ptrdiff_t); extern void decode_coding_object (struct coding_system *, Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object); @@ -778,6 +774,5 @@ extern Lisp_Object Qcoding_system_error; extern char emacs_mule_bytes[256]; -extern int emacs_mule_string_char (unsigned char *); #endif /* EMACS_CODING_H */ === modified file 'src/fileio.c' --- src/fileio.c 2012-08-21 23:39:56 +0000 +++ src/fileio.c 2012-08-27 16:19:34 +0000 @@ -3760,7 +3760,8 @@ ptrdiff_t temp; ptrdiff_t this = 0; ptrdiff_t this_count = SPECPDL_INDEX (); - int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool multibyte + = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); Lisp_Object conversion_buffer; struct gcpro gcpro1; === modified file 'src/lisp.h' --- src/lisp.h 2012-08-26 10:04:27 +0000 +++ src/lisp.h 2012-08-27 16:19:34 +0000 @@ -2632,7 +2632,7 @@ /* Defined in coding.c */ extern Lisp_Object Qcharset; extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, - ptrdiff_t, int, int, Lisp_Object); + ptrdiff_t, bool, bool, Lisp_Object); extern void init_coding (void); extern void init_coding_once (void); extern void syms_of_coding (void); ------------------------------------------------------------ revno: 109791 committer: Dmitry Antipov branch nick: trunk timestamp: Mon 2012-08-27 13:30:26 +0400 message: Fix spare memory change. * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE. (valid_lisp_object_p): Likewise. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 08:31:19 +0000 +++ src/ChangeLog 2012-08-27 09:30:26 +0000 @@ -1,3 +1,9 @@ +2012-08-27 Dmitry Antipov + + Fix spare memory change. + * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE. + (valid_lisp_object_p): Likewise. + 2012-08-27 Martin Rudalics * window.c (Fset_window_configuration): Record any window's old === modified file 'src/alloc.c' --- src/alloc.c 2012-08-27 04:15:33 +0000 +++ src/alloc.c 2012-08-27 09:30:26 +0000 @@ -4563,6 +4563,7 @@ switch (m->type) { case MEM_TYPE_NON_LISP: + case MEM_TYPE_SPARE: /* Nothing to do; not a pointer to Lisp memory. */ break; @@ -5019,6 +5020,7 @@ switch (m->type) { case MEM_TYPE_NON_LISP: + case MEM_TYPE_SPARE: return 0; case MEM_TYPE_BUFFER: ------------------------------------------------------------ revno: 109790 committer: martin rudalics branch nick: trunk timestamp: Mon 2012-08-27 11:05:55 +0200 message: In dired-pop-to-buffer make window start at beginning of buffer (Bug#12281). * dired.el (dired-pop-to-buffer): Make window start at beginning of buffer (Bug#12281). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-26 13:42:18 +0000 +++ lisp/ChangeLog 2012-08-27 09:05:55 +0000 @@ -1,3 +1,8 @@ +2012-08-27 Drew Adams + + * dired.el (dired-pop-to-buffer): Make window start at beginning + of buffer (Bug#12281). + 2012-08-26 Chong Yidong * window.el (special-display-regexps, special-display-frame-alist) === modified file 'lisp/dired.el' --- lisp/dired.el 2012-08-22 06:59:38 +0000 +++ lisp/dired.el 2012-08-27 09:05:55 +0000 @@ -2950,6 +2950,8 @@ (split-window-sensibly window)))) pop-up-frames) (pop-to-buffer (get-buffer-create buf))) + ;; See Bug#12281. + (set-window-start nil (point-min)) ;; If dired-shrink-to-fit is t, make its window fit its contents. (when dired-shrink-to-fit ;; Try to not delete window when we want to display less than ------------------------------------------------------------ revno: 109789 committer: martin rudalics branch nick: trunk timestamp: Mon 2012-08-27 10:31:19 +0200 message: Address two problems in Fset_window_configuration (Bug#8789) and (Bug#12208). * window.c (Fset_window_configuration): Record any window's old buffer if it's replaced (see Bug#8789). If the new current buffer doesn't appear in the selected window, go to its old point (Bug#12208). diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-27 04:15:33 +0000 +++ src/ChangeLog 2012-08-27 08:31:19 +0000 @@ -1,3 +1,10 @@ +2012-08-27 Martin Rudalics + + * window.c (Fset_window_configuration): Record any window's old + buffer if it's replaced (see Bug#8789). If the new current + buffer doesn't appear in the selected window, go to its old + point (Bug#12208). + 2012-08-27 Dmitry Antipov Special MEM_TYPE_SPARE to denote reserved memory. === modified file 'src/window.c' --- src/window.c 2012-08-26 10:04:27 +0000 +++ src/window.c 2012-08-27 08:31:19 +0000 @@ -1969,6 +1969,9 @@ is actually stored in that buffer, and the window's pointm isn't used. So don't clobber point in that buffer. */ if (! EQ (buf, XWINDOW (selected_window)->buffer) + /* Don't clobber point in current buffer either (this could be + useful in connection with bug#12208). + && XBUFFER (buf) != current_buffer */ /* This line helps to fix Horsley's testbug.el bug. */ && !(WINDOWP (BVAR (b, last_selected_window)) && w != XWINDOW (BVAR (b, last_selected_window)) @@ -3135,7 +3138,7 @@ DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, Srun_window_configuration_change_hook, 1, 1, 0, doc: /* Run `window-configuration-change-hook' for FRAME. */) - (Lisp_Object frame) + (Lisp_Object frame) { CHECK_LIVE_FRAME (frame); run_window_configuration_change_hook (XFRAME (frame)); @@ -5613,6 +5616,24 @@ int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); + /* Don't do this within the main loop below: This may call Lisp + code and is thus potentially unsafe while input is blocked. */ + for (k = 0; k < saved_windows->header.size; k++) + { + p = SAVED_WINDOW_N (saved_windows, k); + window = p->window; + w = XWINDOW (window); + + if (!NILP (p->buffer) + && ((!EQ (w->buffer, p->buffer) + && !NILP (BVAR (XBUFFER (p->buffer), name))) + || NILP (w->buffer) + || NILP (BVAR (XBUFFER (w->buffer), name)))) + /* Record old buffer of window when its buffer is going to + change. */ + call1 (Qrecord_window_buffer, window); + } + /* The mouse highlighting code could get screwed up if it runs during this. */ BLOCK_INPUT; @@ -5900,7 +5921,13 @@ } if (!NILP (new_current_buffer)) - Fset_buffer (new_current_buffer); + { + Fset_buffer (new_current_buffer); + /* If the new current buffer doesn't appear in the selected + window, go to its old point (see bug#12208). */ + if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) + Fgoto_char (make_number (old_point)); + } Vminibuf_scroll_window = data->minibuf_scroll_window; minibuf_selected_window = data->minibuf_selected_window; ------------------------------------------------------------ revno: 109788 committer: Dmitry Antipov branch nick: trunk timestamp: Mon 2012-08-27 08:15:33 +0400 message: Special MEM_TYPE_SPARE to denote reserved memory. * alloc.c (enum mem_type): New memory type. (refill_memory_reserve): Use new type for spare memory. This prevents live_cons_p and live_string_p from incorrect detection of uninitialized objects from spare memory as live. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-26 10:29:37 +0000 +++ src/ChangeLog 2012-08-27 04:15:33 +0000 @@ -1,3 +1,11 @@ +2012-08-27 Dmitry Antipov + + Special MEM_TYPE_SPARE to denote reserved memory. + * alloc.c (enum mem_type): New memory type. + (refill_memory_reserve): Use new type for spare memory. + This prevents live_cons_p and live_string_p from incorrect + detection of uninitialized objects from spare memory as live. + 2012-08-26 Paul Eggert Spelling fixes. === modified file 'src/alloc.c' --- src/alloc.c 2012-08-25 04:04:08 +0000 +++ src/alloc.c 2012-08-27 04:15:33 +0000 @@ -305,7 +305,9 @@ and runtime slowdown. Minor but pointless. */ MEM_TYPE_VECTORLIKE, /* Special type to denote vector blocks. */ - MEM_TYPE_VECTOR_BLOCK + MEM_TYPE_VECTOR_BLOCK, + /* Special type to denote reserved memory. */ + MEM_TYPE_SPARE }; static void *lisp_malloc (size_t, enum mem_type); @@ -3816,22 +3818,22 @@ spare_memory[0] = malloc (SPARE_MEMORY); if (spare_memory[1] == 0) spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block), - MEM_TYPE_CONS); + MEM_TYPE_SPARE); if (spare_memory[2] == 0) spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block), - MEM_TYPE_CONS); + MEM_TYPE_SPARE); if (spare_memory[3] == 0) spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block), - MEM_TYPE_CONS); + MEM_TYPE_SPARE); if (spare_memory[4] == 0) spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block), - MEM_TYPE_CONS); + MEM_TYPE_SPARE); if (spare_memory[5] == 0) spare_memory[5] = lisp_malloc (sizeof (struct string_block), - MEM_TYPE_STRING); + MEM_TYPE_SPARE); if (spare_memory[6] == 0) spare_memory[6] = lisp_malloc (sizeof (struct string_block), - MEM_TYPE_STRING); + MEM_TYPE_SPARE); if (spare_memory[0] && spare_memory[1] && spare_memory[5]) Vmemory_full = Qnil; #endif