summaryrefslogtreecommitdiff
path: root/src/search.c
Commit message (Collapse)AuthorAgeFilesLines
* New unwind-protect flavors to better type-check C callbacks.Paul Eggert2013-07-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also lessens the need to write wrappers for callbacks, and the need for make_save_pointer. * alloca.c (free_save_value): * atimer.c (run_all_atimers): Now extern. * alloc.c (safe_alloca_unwind): * atimer.c (unwind_stop_other_atimers): * keyboard.c (cancel_hourglass_unwind) [HAVE_WINDOW_SYSTEM]: * menu.c (cleanup_popup_menu) [HAVE_NS]: * minibuf.c (choose_minibuf_frame_1): * process.c (make_serial_process_unwind): * xdisp.h (pop_message_unwind): * xselect.c (queue_selection_requests_unwind): Remove no-longer-needed wrapper. All uses replaced by the wrappee. * alloca.c (record_xmalloc): Prefer record_unwind_protect_ptr to record_unwind_protect with make_save_pointer. * alloca.c (Fgarbage_collect): Prefer record_unwind_protect_void to passing a dummy. * buffer.c (restore_buffer): * window.c (restore_window_configuration): * xfns.c, w32fns.c (do_unwind_create_frame) New wrapper. All record-unwind uses of wrappee changed. * buffer.c (set_buffer_if_live): * callproc.c (call_process_cleanup, delete_temp_file): * coding.c (code_conversion_restore): * dired.c (directory_files_internal_w32_unwind) [WINDOWSNT]: * editfns.c (save_excursion_restore) (subst_char_in_region_unwind, subst_char_in_region_unwind_1) (save_restriction_restore): * eval.c (restore_stack_limits, un_autoload): * fns.c (require_unwind): * keyboard.c (recursive_edit_unwind, tracking_off): * lread.c (record_load_unwind, load_warn_old_style_backquotes): * macros.c (pop_kbd_macro, restore_menu_items): * nsfns.m (unwind_create_frame): * print.c (print_unwind): * process.c (start_process_unwind): * search.c (unwind_set_match_data): * window.c (select_window_norecord, select_frame_norecord): * xdisp.c (unwind_with_echo_area_buffer, unwind_format_mode_line) (fast_set_selected_frame): * xfns.c, w32fns.c (unwind_create_tip_frame): Return void, not a dummy Lisp_Object. All uses changed. * buffer.h (set_buffer_if_live): Move decl here from lisp.h. * callproc.c (call_process_kill): * fileio.c (restore_point_unwind, decide_coding_unwind) (build_annotations_unwind): * insdel.c (Fcombine_after_change_execute_1): * keyboard.c (read_char_help_form_unwind): * menu.c (unuse_menu_items): * minibuf.c (run_exit_minibuf_hook, read_minibuf_unwind): * sound.c (sound_cleanup): * xdisp.c (unwind_redisplay): * xfns.c (clean_up_dialog): * xselect.c (x_selection_request_lisp_error, x_catch_errors_unwind): Accept no args and return void, instead of accepting and returning a dummy Lisp_Object. All uses changed. * cygw32.c (fchdir_unwind): * fileio.c (close_file_unwind): * keyboard.c (restore_kboard_configuration): * lread.c (readevalllop_1): * process.c (wait_reading_process_output_unwind): Accept int and return void, rather than accepting an Emacs integer and returning a dummy object. In some cases this fixes an unlikely bug when the corresponding int is outside Emacs integer range. All uses changed. * dired.c (directory_files_internal_unwind): * fileio.c (do_auto_save_unwind): * gtkutil.c (pop_down_dialog): * insdel.c (reset_var_on_error): * lread.c (load_unwind): * xfns.c (clean_up_file_dialog): * xmenu.c, nsmenu.m (pop_down_menu): * xmenu.c (cleanup_widget_value_tree): * xselect.c (wait_for_property_change_unwind): Accept pointer and return void, rather than accepting an Emacs save value encapsulating the pointer and returning a dummy object. All uses changed. * editfns.c (Fformat): Update the saved pointer directly via set_unwind_protect_ptr rather than indirectly via make_save_pointer. * eval.c (specpdl_func): Remove. All uses replaced by definiens. (unwind_body): New function. (record_unwind_protect): First arg is now a function returning void, not a dummy Lisp_Object. (record_unwind_protect_ptr, record_unwind_protect_int) (record_unwind_protect_void): New functions. (unbind_to): Support SPECPDL_UNWIND_PTR etc. * fileio.c (struct auto_save_unwind): New type. (do_auto_save_unwind): Use it. (do_auto_save_unwind_1): Remove; subsumed by new do_auto_save_unwind. * insdel.c (struct rvoe_arg): New type. (reset_var_on_error): Use it. * lisp.h (SPECPDL_UNWIND_PTR, SPECPDL_UNWIND_INT, SPECPDL_UNWIND_VOID): New constants. (specbinding_func): Remove; there are now several such functions. (union specbinding): New members unwind_ptr, unwind_int, unwind_void. (set_unwind_protect_ptr): New function. * xselect.c: Remove unnecessary forward decls, to simplify maintenance.
* Syntax cleanup, mostly replacing macros with functions.Paul Eggert2013-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the need for the syntax_temp hack. * search.c: Include syntax.h after buffer.h, since syntax.h uses BVAR. * syntax.c (SYNTAX_INLINE): New macro. (SYNTAX_FLAGS_COMSTART_FIRST, SYNTAX_FLAGS_COMSTART_SECOND) (SYNTAX_FLAGS_COMEND_FIRST, SYNTAX_FLAGS_COMEND_SECOND) (SYNTAX_FLAGS_PREFIX, SYNTAX_FLAGS_COMMENT_STYLEB) (SYNTAX_FLAGS_COMMENT_STYLEC, SYNTAX_FLAGS_COMMENT_STYLEC2) (SYNTAX_FLAGS_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_STYLE) (SYNTAX_COMEND_FIRST): Now functions, not macros. (ST_COMMENT_STYLE, ST_STRING_STYLE, INTERVALS_AT_ONCE): Now constants, not macros. (syntax_temp) [!__GNUC__]: Remove. (SYNTAX_PREFIX): Remove; all uses replaced by syntax_prefix_flag_p. (syntax_prefix_flag_p): Move implementation of SYNTAX_PREFIX here. (SET_RAW_SYNTAX_ENTRY, SET_RAW_SYNTAX_ENTRY_RANGE, SYNTAX_MATCH) (SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT): Move here from syntax.h; now functions, not macros. Except for the last function, these are static since only syntax.c uses them. (syntax_multibyte): Rename from SYNTAX_WITH_MULTIBYTE_CHECK. All uses changed. Now a function, not a macro; use this fact to simplify the code. (scan_lists, scan_sexps_forward): Remove workarounds for ancient compiler bugs; no longer relevant. * syntax.h: Use INLINE_HEADER_BEGIN, INLINE_HEADER_END. (SYNTAX_INLINE): New macro. (struct gl_state_s, gl_state): Move earlier, so that it's in scope for the new functions. Use bool for boolean member. (SYNTAX_ENTRY, SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH) (SYNTAX_TABLE_BYTE_TO_CHAR, UPDATE_SYNTAX_TABLE_FORWARD) (UPDATE_SYNTAX_TABLE_BACKWARD, UPDATE_SYNTAX_TABLE) (SETUP_BUFFER_SYNTAX_TABLE): Now extern inline functions, not macros. (CURRENT_SYNTAX_TABLE, SYNTAX_ENTRY_INT): Remove; all uses replaced by implementation. (syntax_temp) [!__GNUC__]: Remove decl. (SETUP_SYNTAX_TABLE_FOR_OBJECT): New decl.
* * src/search.c (looking_at_1): Only set last_thing_searched if the matchStefan Monnier2013-05-211-6/+6
| | | | | | changed the match-data. Fixes: debbugs:14281
* Prefer < to > in range checks such as 0 <= i && i < N.Paul Eggert2013-04-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to visualize quantities on a number line. This patch doesn't apply to all such range checks, only to the range checks affected by the 2013-03-24 change. This patch reverts most of the 2013-03-24 change. * alloc.c (xpalloc, Fgarbage_collect): * ccl.c (ccl_driver, resolve_symbol_ccl_program): * character.c (string_escape_byte8): * charset.c (read_hex): * data.c (cons_to_unsigned): * dispnew.c (update_frame_1): * doc.c (Fsubstitute_command_keys): * doprnt.c (doprnt): * editfns.c (hi_time, decode_time_components): * fileio.c (file_offset): * fns.c (larger_vector, make_hash_table, Fmake_hash_table): * font.c (font_intern_prop): * frame.c (x_set_alpha): * gtkutil.c (get_utf8_string): * indent.c (check_display_width): * keymap.c (Fkey_description): * lisp.h (FIXNUM_OVERFLOW_P, vcopy): * lread.c (read1): * minibuf.c (read_minibuf_noninteractive): * process.c (wait_reading_process_output): * search.c (Freplace_match): * window.c (get_phys_cursor_glyph): * xdisp.c (redisplay_internal): * xsmfns.c (smc_save_yourself_CB): Prefer < to > for range checks. * dispnew.c (sit_for): Don't mishandle NaNs. This fixes a bug introduced in the 2013-03-24 change. * editfns.c (decode_time_components): Don't hoist comparison. This fixes another bug introduced in the 2013-03-24 change.
* Reorder conditions that are written backwardsAndreas Schwab2013-03-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are written backwards. * blockinput.h (input_blocked_p): Likewise. * bytecode.c (exec_byte_code): Likewise. * callproc.c (call_process_kill, call_process_cleanup) (Fcall_process): Likewise. * ccl.c (ccl_driver, resolve_symbol_ccl_program) (Fccl_execute_on_string): Likewise. * character.c (string_escape_byte8): Likewise. * charset.c (read_hex): Likewise. * cm.c (calccost): Likewise. * data.c (cons_to_unsigned): Likewise. * dired.c (directory_files_internal, file_name_completion): Likewise. * dispnew.c (scrolling_window, update_frame_1, Fsleep_for) (sit_for): Likewise. * doc.c (Fsubstitute_command_keys): Likewise. * doprnt.c (doprnt): Likewise. * editfns.c (hi_time, decode_time_components, Fformat): Likewise. * emacsgtkfixed.c: Likewise. * fileio.c (file_offset, Fwrite_region): Likewise. * floatfns.c (Fexpt, fmod_float): Likewise. * fns.c (larger_vector, make_hash_table, Fmake_hash_table): Likewise. * font.c (font_intern_prop): Likewise. * frame.c (x_set_alpha): Likewise. * gtkutil.c (get_utf8_string): Likewise. * indent.c (check_display_width): Likewise. * intervals.c (create_root_interval, rotate_right, rotate_left) (split_interval_right, split_interval_left) (adjust_intervals_for_insertion, delete_node) (interval_deletion_adjustment, adjust_intervals_for_deletion) (merge_interval_right, merge_interval_left, copy_intervals) (set_intervals_multibyte_1): Likewise. * keyboard.c (gobble_input, append_tool_bar_item): Likewise. * keymap.c (Fkey_description): Likewise. * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise. * lread.c (openp, read_integer, read1, string_to_number): Likewise. * menu.c (ensure_menu_items): Likewise. * minibuf.c (read_minibuf_noninteractive): Likewise. * print.c (printchar, strout): Likewise. * process.c (create_process, Faccept_process_output) (wait_reading_process_output, read_process_output, send_process) (wait_reading_process_output): Likewise. * profiler.c (make_log, handle_profiler_signal): Likewise. * regex.c (re_exec): Likewise. * regex.h: Likewise. * search.c (looking_at_1, Freplace_match): Likewise. * sysdep.c (get_child_status, procfs_ttyname) (procfs_get_total_memory): Likewise. * systime.h (EMACS_TIME_VALID_P): Likewise. * term.c (dissociate_if_controlling_tty): Likewise. * window.c (get_phys_cursor_glyph): Likewise. * xdisp.c (init_iterator, redisplay_internal, redisplay_window) (try_window_reusing_current_matrix, try_window_id, pint2hrstr): Likewise. * xfns.c (Fx_window_property): Likewise. * xmenu.c (set_frame_menubar): Likewise. * xselect.c (x_get_window_property, x_handle_dnd_message): Likewise. * xsmfns.c (smc_save_yourself_CB): Likewise. * xterm.c (x_scroll_bar_set_handle): Likewise.
* region-cache.c, scroll.c, search.c: Use bool for booleans.Paul Eggert2013-03-081-31/+33
| | | | | | | | | | | | * lisp.h (compile_pattern): * scroll.c (do_scrolling, do_direct_scrolling): * search.c (struct regexp_cache, compile_pattern_1) (compile_pattern, string_match_1, search_command) (trivial_regexp_p, search_buffer, Freplace_match, match_limit) (search_regs_saved, Fregexp_quote): Use bool for boolean. * region-cache.c (region_cache_forward, region_cache_backward): Fix comments to match code: these functions return int, not boolean.
* * search.c (find_newline): Accept start and end byte positionsDmitry Antipov2013-03-081-9/+10
| | | | | | | | | | | | | | | | as arguments and allow -1 if not known. (find_newline_no_quit): Likewise for start position. * lisp.h (find_newline, find_newline_no_quit): Adjust prototype. * bidi.c (bidi_find_paragraph_start): Pass byte position to find_newline_no_quit, thus eliminating CHAR_TO_BYTE. * editfns.c (Fconstrain_to_field): Break long line. Adjust call to find_newline. * indent.c (vmotion): Adjust calls to find_newline_no_quit. Use DEC_BOTH to start next search from the previous buffer position, where appropriate. * xdisp.c (back_to_previous_line_start, forward_to_next_line_start) (get_visually_first_element, move_it_vertically_backward): Likewise. Obtain byte position from the display iterator, where appropriate.
* Rename find_next_newline to find_newline_no_quit.Eli Zaretskii2013-03-061-4/+6
| | | | | | | | | | | | src/search.c (find_newline_no_quit): Rename from find_next_newline. Add commentary. src/lisp.h (find_newline_no_quit): Rename prototype. src/xdisp.c (back_to_previous_line_start) (forward_to_next_line_start, get_visually_first_element) (move_it_vertically_backward): Callers of find_newline_no_quit changed. src/indent.c (vmotion): Callers of find_newline_no_quit changed. src/bidi.c (bidi_find_paragraph_start): Callers of find_newline_no_quit changed.
* * lisp.h (find_next_newline_no_quit): Rename to find_next_newline.Dmitry Antipov2013-03-061-1/+1
| | | | | | | * xdisp.c (back_to_previous_line_start, forward_to_next_line_start) (get_visually_first_element, move_it_vertically_backward): Ajust users. * bidi.c (bidi_find_paragraph_start): Likewise. * indent.c (vmotion): Likewise.
* * search.c (find_newline): Return byte position in bytepos.Dmitry Antipov2013-02-201-18/+33
| | | | | | | | | | | | | | Adjust comment. (find_next_newline_no_quit, find_before_next_newline): Add bytepos argument. * lisp.h (find_newline, find_next_newline_no_quit) (find_before_next_newline): Adjust prototypes. * bidi.c (bidi_find_paragraph_start): * editfns.c (Fconstrain_to_field, Fline_end_position): * indent.c (compute_motion, vmotion): * xdisp.c (back_to_previous_line_start, forward_to_next_line_start): (get_visually_first_element, move_it_vertically_backward): Adjust users and avoid calls to CHAR_TO_BYTE where appropriate.
* * composite.c (fill_gstring_header): Remove useless prototype.Dmitry Antipov2013-02-151-9/+11
| | | | | | | | | | | | | Break long line. * lisp.h (message_dolog, compile_pattern): Adjust prototype. * print.c (PRINTDECLARE, print_object): * search.c (compile_pattern, fast_looking_at, search_buffer): (simple_search, boyer_moore, Freplace_match): * xdisp.c (c_string_pos, number_of_chars, message_dolog): (get_overlay_arrow_glyph_row, display_mode_element): (decode_mode_spec_coding, message3): * xfaces.c (face_at_string_position): Use bool for booleans. Adjust comments.
* Tune by using memchr and memrchr.Paul Eggert2013-02-111-91/+81
| | | | | | | | | | | | | | | * .bzrignore: Add string.h. * admin/merge-gnulib (GNULIB_MODULES): Add memrchr. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * lib/memrchr.c, lib/string.in.h, m4/memrchr.m4, m4/string_h.m4: New files, from gnulib. * src/doc.c (Fsnarf_documentation): * src/fileio.c (Fsubstitute_in_file_name): * src/search.c (find_newline, scan_newline): * src/xdisp.c (pos_visible_p, display_count_lines): Use memchr and memrchr rather than scanning byte-by-byte. * src/search.c (find_newline): Rename from scan_buffer. Omit first arg TARGET, as it's always '\n'. All callers changed.
* * search.c (scan_buffer): Calculate end byte position just once.Dmitry Antipov2013-02-081-11/+11
| | | | | | | | | (scan_newline): Do not recalculate start_byte. (search_command): Use eassert. * syntax.c (struct lisp_parse_state): New member location_byte. (scan_sexps_forward): Record from_byte and avoid redundant character to byte position calculation ... (Fparse_partial_sexp): ... here. Break too long line.
* Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.caPaul Eggert2013-01-021-2/+2
|\
| * Update copyright notices for 2013.Paul Eggert2013-01-011-2/+2
| |
* | Merge from emacs-24; up to 2012-12-01T13:25:13Z!cyd@gnu.orgGlenn Morris2012-12-211-2/+5
|\ \ | |/
| * search.c (search_buffer): Improve a comment.Kenichi Handa2012-12-151-1/+3
| |
| * search.c (search_buffer): Improve a comment.Kenichi Handa2012-12-151-2/+3
| |
* | Avoid calls to CHAR_TO_BYTE if byte position is known.Dmitry Antipov2012-12-201-1/+1
|/ | | | | | | | | | | | | | | | * editfns.c (make_buffer_string_both): Use move_gap_both. (Fbuffer_string): Use make_buffer_string_both. * marker.c (buf_charpos_to_bytepos): Convert to eassert. Adjust comment. (buf_bytepos_to_charpos): Likewise. (charpos_to_bytepos): Remove. * fileio.c (Finsert_file_contents): Use move_gap_both. * search.c (Freplace_match): Likewise. * process.c (process_send_region): Likewise. Use convenient names for byte positions. * lisp.h (charpos_to_bytepos): Remove prototype. * indent.c (scan_for_column): Use CHAR_TO_BYTE. * insdel.c (move_gap): Likewise.
* Fix bug #13084 with crashes during search.Eli Zaretskii2012-12-111-1/+15
| | | | | src/search.c (search_buffer): Check the inverse translations of each character in pattern when the buffer being searched is unibyte.
* keyboard.c, keymap.c: Use bool for booleans.Paul Eggert2012-10-101-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dispnew.c (sit_for): Distinguish between 3-way display_option and boolean do_display. * keyboard.c (single_kboard, this_command_key_count_reset) (waiting_for_input, echoing, immediate_quit, input_pending) (interrupt_input, interrupts_deferred, pop_kboard) (temporarily_switch_to_single_kboard, ignore_mouse_drag_p) (command_loop_1, adjust_point_for_property) (safe_run_hooks_error, input_polling_used, read_char): (help_char_p, readable_events, kbd_buffer_events_waiting) (kbd_buffer_get_event, timer_check_2, make_lispy_event) (lucid_event_type_list_p, get_input_pending): (gobble_input, menu_separator_name_p, menu_bar_item) (parse_menu_item, parse_tool_bar_item, read_char_x_menu_prompt) (read_char_minibuf_menu_prompt, access_keymap_keyremap) (keyremap_step, test_undefined, read_key_sequence) (detect_input_pending, detect_input_pending_ignore_squeezables) (detect_input_pending_run_timers, requeued_events_pending_p) (quit_throw_to_read_char, Fset_input_interrupt_mode): * keymap.c (get_keymap, keymap_parent, keymap_memberp) (access_keymap_1, access_keymap, map_keymap, get_keyelt) (Fdefine_key, Flookup_key, struct accessible_keymaps_data) (accessible_keymaps_1, Fkey_description, push_key_description): (shadow_lookup, struct where_is_internal_data) (where_is_internal, Fwhere_is_internal, where_is_internal_1) (Fdescribe_buffer_bindings, describe_map_tree, struct describe_map_elt) (describe_map, describe_vector): * menu.c (single_menu_item): * nsmenu.m (ns_update_menubar): * process.c (wait_reading_process_output): * search.c (scan_buffer, scan_newline): Use bool for boolean. * keyboard.c (timers_run, swallow_events) (detect_input_pending_run_timers): * process.c (wait_reading_process_output): Use unsigned for counter where wraparound-on-overflow is desired, since unsigned is guaranteed to have that behavior and signed is not. (read_char): Use ptrdiff_t for string length. (get_input_pending): Remove first argument, since it was always the same pointer-to-int (now pointer-to-boolean) &input_pending, and behave as if it had that value. Return new value of input_pending. All callers changed. * keyboard.h (struct kboard): Use unsigned : 1 for boolean member immediate_echo. Use ptrdiff_t for echo_after_prompt, since it's a string length. * keymap.c (push_key_description): Omit last arg, which was always 1. All callers changed.
* Simplify and avoid signal-handling races.Paul Eggert2012-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * nt/inc/ms-w32.h (emacs_raise): New macro. * src/alloc.c (die): * src/sysdep.c (emacs_abort) [HAVE_NTGUI]: Avoid recursive loop if there's a fatal error in the function itself. * src/atimer.c (pending_atimers): * src/blockinput.h: Don't include "atimer.h"; no longer needed. (interrupt_input_pending): Remove. All uses removed. pending_signals now counts both atimers and ordinary interrupts. This is less racy than having three separate pending-signal flags. (block_input, unblock_input, totally_unblock_input, unblock_input_to) (input_blocked_p): Rename from their upper-case counterparts BLOCK_INPUT, UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT, UNBLOCK_INPUT_TO, INPUT_BLOCKED_P, and turn into functions. All uses changed. This makes it easier to access volatile variables more accurately. (BLOCK_INPUT_RESIGNAL): Remove. All uses replaced by unblock_input (). (input_blocked_p): Prefer this to 'interrupt_input_blocked', as that's more reliable if the code is buggy and sets interrupt_input_blocked to a negative value. All uses changed. * src/atimer.c (deliver_alarm_signal): Remove. No need to deliver this to the parent; any thread can handle this signal now. All uses replaced by underlying handler. * src/atimer.c (turn_on_atimers): * src/dispnew.c (handle_window_change_signal): * src/emacs.c (handle_danger_signal): * src/keyboard.c (kbd_buffer_get_event): Don't reestablish signal handler; not needed with sigaction. * src/blockinput.h (UNBLOCK_INPUT_TO, TOTALLY_UNBLOCK_INPUT) (UNBLOCK_INPUT_TO): Rework to avoid unnecessary accesses to volatile variables. (UNBLOCK_INPUT_TO): Now a function. (totally_unblock_input, unblock_input): New decls. * src/data.c (handle_arith_signal, deliver_arith_signal): Move to sysdep.c (init_data): Remove. Necessary stuff now done in init_signal. * src/emacs.c, src/xdisp.c: Include "atimer.h", since we invoke atimer functions. * src/emacs.c (handle_fatal_signal, deliver_fatal_signal): Move to sysdep.c. (fatal_error_code): Remove; no longer needed. (terminate_due_to_signal): Rename from fatal_error_backtrace, since it doesn't always backtrace. All uses changed. No need to reset signal to default, since sigaction and/or die does that for us now. Use emacs_raise (FOO), not kill (getpid (), FOO). (main): Check more-accurately whether we're dumping. Move fatal-error setup to sysdep.c * src/floatfns.c: Do not include "syssignal.h"; no longer needed. * src/gtkutil.c (xg_get_file_name, xg_get_font): Remove no-longer-needed signal-mask manipulation. * src/keyboard.c, src/process.c (POLL_FOR_INPUT): Don't depend on USE_ASYNC_EVENTS, a symbol that is never defined. * src/keyboard.c (read_avail_input): Remove. All uses replaced by gobble_input. (Ftop_level): Use TOTALLY_UNBLOCK_INPUT rather than open code. (kbd_buffer_store_event_hold, gobble_input): (record_asynch_buffer_change) [USABLE_SIGIO]: (store_user_signal_events): No need to mess with signal mask. (gobble_input): If blocking input and there are terminals, simply set pending_signals to 1 and return. All hooks changed to not worry about whether input is blocked. (process_pending_signals): Clear pending_signals before processing them, in case a signal comes in while we're processing. By convention callers now test pending_signals before calling us. (UNBLOCK_INPUT_TO, unblock_input, totally_unblock_input): New functions, to support changes to blockinput.h. (handle_input_available_signal): Now extern. (reinvoke_input_signal): Remove. All uses replaced by handle_async_input. (quit_count): Now volatile, since a signal handler uses it. (handle_interrupt): Now takes bool IN_SIGNAL_HANDLER as arg. All callers changed. Block SIGINT only if not already blocked. Clear sigmask reliably, even if Fsignal returns, which it can. Omit unnecessary accesses to volatile var. (quit_throw_to_read_char): No need to restore sigmask. * src/keyboard.c (gobble_input, handle_user_signal): * src/process.c (wait_reading_process_output): Call signal-handling code rather than killing ourselves. * src/lisp.h: Include <float.h>, for... (IEEE_FLOATING_POINT): New macro, moved here to avoid duplication. (pending_signals): Now volatile. (syms_of_data): Now const if IEEE floating point. (handle_input_available_signal) [USABLE_SIGIO]: (terminate_due_to_signal, record_child_status_change): New decls. * src/process.c (create_process): Avoid disaster if memory is exhausted while we're processing a vfork, by tightening the critical section around the vfork. (send_process_frame, process_sent_to, handle_pipe_signal) (deliver_pipe_signal): Remove. No longer needed, as Emacs now ignores SIGPIPE. (send_process): No need for setjmp/longjmp any more, since the SIGPIPE stuff is now gone. Instead, report an error if errno is EPIPE. (record_child_status_change): Now extern. PID and W are now args. Return void, not bool. All callers changed. * src/sysdep.c (wait_debugging) [(BSD_SYSTEM || HPUX) && !defined (__GNU__)]: Remove. All uses removed. This bug should be fixed now in a different way. (wait_for_termination_1): Use waitpid rather than sigsuspend, and record the child status change directly. This avoids the need to futz with the signal mask. (process_fatal_action): Move here from emacs.c. (emacs_sigaction_flags): New function, containing much of what used to be in emacs_sigaction_init. (emacs_sigaction_init): Use it. Block nonfatal system signals that are caught by emacs, to make races less likely. (deliver_process_signal): Rename from handle_on_main_thread. All uses changed. (BACKTRACE_LIMIT_MAX): Now at top level. (thread_backtrace_buffer, threadback_backtrace_pointers): New static vars. (deliver_thread_signal, deliver_fatal_thread_signal): New functions, for more-accurate delivery of thread-specific signals. (handle_fatal_signal, deliver_fatal_signal): Move here from emacs.c. (deliver_arith_signal): Handle in this thread, not in the main thread, since it's triggered by this thread. (maybe_fatal_sig): New function. (init_signals): New arg DUMPING so that we can be more accurate about whether we're dumping. Caller changed. Treat thread-specific signals differently from process-general signals. Block all signals while handling fatal error; that's safer. xsignal from SIGFPE only on non-IEEE hosts, treating it as fatal on IEEE hosts. When batch, ignore SIGHUP, SIGINT, SIGTERM if they were already ignored. Ignore SIGPIPE unless batch. (emacs_backtrace): Output backtrace for the appropriate thread, which is not necessarily the main thread. * src/syssignal.h: Include <stdbool.h>. (emacs_raise): New macro. * src/xterm.c (x_connection_signal): Remove; no longer needed now that we use sigaction. (x_connection_closed): No need to mess with sigmask now. (x_initialize): No need to reset SIGPIPE handler here, since init_signals does this for us now. Fixes: debbugs:12471
* Misc doc fixes.Chong Yidong2012-09-221-16/+13
| | | | | | | | | | | | | | | | | | | | | * searching.texi (Replacing Match): Minor clarification. * lisp/repeat.el (repeat): Doc fix. * lisp/simple.el (shell-command-on-region): Doc fix. * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Doc fix. * cmds.c (Fforward_char, Fbackward_char): Doc fix. * editfns.c (Fline_beginning_position): Doc fix. (Fline_end_position): Doc fix. * minibuf.c (Finternal_complete_buffer): Doc fix. * search.c (Freplace_match): Doc fix. Fixes: debbugs:12325 debbugs:12391 debbugs:12416 debbugs:12414 debbugs:10909 debbugs:12348
* Fix bug #12196 with infloop when cache-long-line-scans is non-nil.Eli Zaretskii2012-09-171-8/+16
| | | | | | src/search.c (scan_buffer): Use character positions in calls to region_cache_forward and region_cache_backward, not byte positions.
* Port better to POSIX hosts lacking _setjmp.Paul Eggert2012-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (HAVE__SETJMP, HAVE_SIGSETJMP): New symbols. (_setjmp, _longjmp): Remove. * src/lisp.h: Include <setjmp.h> here, since we use its symbols here. All instances of '#include <setjmp.h>' removed, if the only reason for the instance was because "lisp.h" was included. (sys_jmp_buf, sys_setjmp, sys_longjmp): New symbols. Unless otherwise specified, replace all uses of jmp_buf, _setjmp, and _longjmp with the new symbols. Emacs already uses _setjmp if available, so this change affects only POSIXish hosts that have sigsetjmp but not _setjmp, such as some versions of Solaris and Unixware. (Also, POSIX-2008 marks _setjmp as obsolescent.) * src/image.c (_setjmp, _longjmp) [HAVE_PNG && !HAVE__SETJMP]: New macros. (png_load_body) [HAVE_PNG]: (PNG_LONGJMP) [HAVE_PNG && PNG_LIBPNG_VER < 10500]: (PNG_JMPBUF) [HAVE_PNG && PNG_LIBPNG_VER >= 10500]: Use _setjmp and _longjmp rather than sys_setjmp and sys_longjmp, since PNG requires jmp_buf. This is the only exception to the general rule that we now use sys_setjmp and sys_longjmp. This exception is OK since this code does not change the signal mask or longjmp out of a signal handler. Fixes: debbugs:12446
* Simplify redefinition of 'abort' (Bug#12316).Paul Eggert2012-09-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | Do not try to redefine the 'abort' function. Instead, redo the code so that it calls 'emacs_abort' rather than 'abort'. This removes the need for the NO_ABORT configure-time macro and makes it easier to change the abort code to do a backtrace. * configure.ac (NO_ABRT): Remove. * admin/CPP-DEFINES (NO_ABORT): Remove. * nt/inc/ms-w32.h (w32_abort) [HAVE_NTGUI]: Remove. * src/.gdbinit: Just stop at emacs_abort, not at w32_abort or abort. * src/emacs.c (abort) [!DOS_NT && !NO_ABORT]: Remove; sysdep.c's emacs_abort now takes its place. * src/lisp.h (emacs_abort): New decl. All calls from Emacs code to 'abort' changed to use 'emacs_abort'. * src/msdos.c (dos_abort) [defined abort]: Remove; not used. (abort) [!defined abort]: Rename to ... (emacs_abort): ... new name. * src/sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking the place of the old 'abort' in emacs.c. * src/w32.c, src/w32fns.c (abort): Do not #undef. * src/w32.c (emacs_abort): Rename from w32_abort.
* * lisp.h (set_char_table_extras): Rename from char_table_set_extras.Paul Eggert2012-08-171-3/+3
| | | | | | | (set_char_table_contents): Rename from char_table_set_contents. (set_sub_char_table_contents): Rename from sub_char_table_sub_contents. All uses changed. See the end of <http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00549.html>.
* Simple interface to set Lisp_Object fields of chararcter tables.Dmitry Antipov2012-08-161-6/+6
| | | | | | | | * lisp.h (CSET): New macro. (char_table_set_extras, char_table_set_contents) (sub_char_table_set_contents): New function. * casetab.c, category.c, chartab.c, fns.c, fontset.c, search.c: * syntax.c: Adjust users.
* * search.c (Freplace_match): Treat \? in the replacement text literally.Lawrence Mitchell2012-08-051-1/+4
| | | | Fixes: debbugs:8161
* Fix failure to compile on Windows due to ↵Eli Zaretskii2012-07-271-2/+2
| | | | | | | | | 2012-07-27T06:04:35Z!dmantipov@yandex.ru. src/lisp.h (enum constype): Use CONSTYPE_HEAP and CONSTYPE_PURE for enumeration constants, as PURE and HEAP are too general, and clash with other headers and sources, such as gmalloc.c and the MS-Windows system headers. All users changed.
* Utility function to make a list from specified amount of objects.Dmitry Antipov2012-07-271-2/+2
| | | | | | | | | | | | | | | | | | * lisp.h (enum constype): New datatype. (listn): New prototype. * alloc.c (listn): New function. (Fmemory_use_count, syms_of_alloc): Use it. * buffer.c (syms_of_buffer): Likewise. * callint.c (syms_of_callint): Likewise. * charset.c (define_charset_internal): Likewise. * coding.c (syms_of_coding): Likewise. * keymap.c (syms_of_keymap): Likewise. * search.c (syms_of_search): Likewise. * syntax.c (syms_of_syntax): Likewise. * w32.c (init_environment): Likewise. * w32fns.c (Fw32_battery_status, syms_of_w32fns): Likewise. * xdisp.c (syms_of_xdisp): Likewise. * xfns.c (syms_of_xfns): Likewise.
* Avoid call to strlen in fast_c_string_match_ignore_case.Dmitry Antipov2012-07-111-2/+2
| | | | | | * search.c (fast_c_string_match_ignore_case): Change to use length argument. Adjust users accordingly. * lisp.h (fast_c_string_match_ignore_case): Adjust prototype.
* Optimize pure C strings initialization.Dmitry Antipov2012-07-101-2/+2
| | | | | | | | | | | | | * lisp.h (make_pure_string): Fix prototype. (build_pure_c_string): New function, defined as static inline. This provides a better opportunity to optimize away calls to strlen when the function is called with compile-time constant argument. * alloc.c (make_pure_c_string): Fix comment. Change to add nchars argument, adjust users accordingly. Use build_pure_c_string where appropriate. * buffer.c, coding.c, data.c, dbusbind.c, fileio.c, fontset.c, frame.c, * keyboard.c, keymap.c, lread.c, search.c, syntax.c, w32fns.c, xdisp.c, * xfaces.c, xfns.c, xterm.c: Use build_pure_c_string where appropriate.
* More xmalloc and related cleanup.Paul Eggert2012-07-051-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | * alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c: * callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c: * font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c: * gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c: * nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c: * regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c: * sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c: * xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c: * xterm.c: Omit needless casts involving void * pointers and allocation. Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))", as the former is more robust if P's type is changed. Prefer xzalloc to xmalloc + memset 0. Simplify malloc-or-realloc to realloc. Don't worry about xmalloc returning a null pointer. Prefer xstrdup to xmalloc + strcpy. * editfns.c (Fmessage_box): Grow message_text by at least 80 when growing it. * keyboard.c (apply_modifiers_uncached): Prefer local array to alloca of a constant.
* Cleanup xmalloc.Dmitry Antipov2012-07-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * admin/coccinelle/xzalloc.cocci: Semantic patch to convert calls to xmalloc with following memset to xzalloc. * src/lisp.h (xzalloc): New prototype. Omit needless casts. * src/alloc.c (xzalloc): New function. Omit needless casts. * src/charset.c: Omit needless casts. Convert all calls to malloc with following memset to xzalloc. * src/dispnew.c: Likewise. * src/fringe.c: Likewise. * src/image.c: Likewise. * src/sound.c: Likewise. * src/term.c: Likewise. * src/w32fns.c: Likewise. * src/w32font.c: Likewise. * src/w32term.c: Likewise. * src/xfaces.c: Likewise. * src/xfns.c: Likewise. * src/xterm.c: Likewise. * src/atimer.c: Omit needless casts. * src/buffer.c: Likewise. * src/callproc.c: Likewise. * src/ccl.c: Likewise. * src/coding.c: Likewise. * src/composite.c: Likewise. * src/doc.c: Likewise. * src/doprnt.c: Likewise. * src/editfns.c: Likewise. * src/emacs.c: Likewise. * src/eval.c: Likewise. * src/filelock.c: Likewise. * src/fns.c: Likewise. * src/gtkutil.c: Likewise. * src/keyboard.c: Likewise. * src/lisp.h: Likewise. * src/lread.c: Likewise. * src/minibuf.c: Likewise. * src/msdos.c: Likewise. * src/print.c: Likewise. * src/process.c: Likewise. * src/region-cache.c: Likewise. * src/search.c: Likewise. * src/sysdep.c: Likewise. * src/termcap.c: Likewise. * src/terminal.c: Likewise. * src/tparam.c: Likewise. * src/w16select.c: Likewise. * src/w32.c: Likewise. * src/w32reg.c: Likewise. * src/w32select.c: Likewise. * src/w32uniscribe.c: Likewise. * src/widget.c: Likewise. * src/xdisp.c: Likewise. * src/xmenu.c: Likewise. * src/xrdb.c: Likewise. * src/xselect.c: Likewise.
* Fix compilation with --enable-gcc-warnings and -O1Dmitry Antipov2012-07-041-1/+2
| | | | | | | | | | optimization level. * configure.in: If --enable-gcc-warnings, disable -Wunsafe-loop-optimizations for -O1 optimization level. * src/doprnt.c (doprnt): Change type of tem to int, initialize to avoid compiler warning. Add eassert. * src/search.c (simple_search): Initialize match_byte to avoid compiler warning. Add eassert.
* Switch from NO_RETURN to C11's _Noreturn.Paul Eggert2012-06-241-2/+1
| | | | Fixes: debbugs:11750
* * buffer.h (FETCH_MULTIBYTE_CHAR): Define as inline.Andreas Schwab2012-06-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (BUF_FETCH_MULTIBYTE_CHAR): Likewise. * character.c (_fetch_multibyte_char_p): Remove. * alloc.c: Include "character.h" before "buffer.h". * bidi.c: Likewise. * buffer.c: Likewise. * bytecode.c: Likewise. * callint.c: Likewise. * callproc.c: Likewise. * casefiddle.c: Likewise. * casetab.c: Likewise. * category.c: Likewise. * cmds.c: Likewise. * coding.c: Likewise. * composite.c: Likewise. * dired.c: Likewise. * dispnew.c: Likewise. * doc.c: Likewise. * dosfns.c: Likewise. * editfns.c: Likewise. * emacs.c: Likewise. * fileio.c: Likewise. * filelock.c: Likewise. * font.c: Likewise. * fontset.c: Likewise. * fringe.c: Likewise. * indent.c: Likewise. * insdel.c: Likewise. * intervals.c: Likewise. * keyboard.c: Likewise. * keymap.c: Likewise. * lread.c: Likewise. * macros.c: Likewise. * marker.c: Likewise. * minibuf.c: Likewise. * nsfns.m: Likewise. * nsmenu.m: Likewise. * print.c: Likewise. * process.c: Likewise. * regex.c: Likewise. * region-cache.c: Likewise. * search.c: Likewise. * syntax.c: Likewise. * term.c: Likewise. * textprop.c: Likewise. * undo.c: Likewise. * unexsol.c: Likewise. * w16select.c: Likewise. * w32fns.c: Likewise. * w32menu.c: Likewise. * window.c: Likewise. * xdisp.c: Likewise. * xfns.c: Likewise. * xmenu.c: Likewise. * xml.c: Likewise. * xselect.c: Likewise.
* Merge from emacs-24; up to 2012-04-24T21:47:24Z!michael.albinus@gmx.deChong Yidong2012-05-311-20/+0
|\
| * Don't call r_alloc_inhibit_buffer_relocation from search.c.Eli Zaretskii2012-05-291-20/+0
| | | | | | | | | | | | | | src/search.c (search_buffer): Remove calls to r_alloc_inhibit_buffer_relocation, as it is now called by maybe_unify_char, which was the cause of relocation of buffer text in bug#11519.
* | Merge from emacs-24; up to 2012-04-24T08:35:02Z!lekktu@gmail.comGlenn Morris2012-05-261-0/+22
|\ \ | |/
| * Fix bug #11519 with relocation of buffer text during regex search.Eli Zaretskii2012-05-231-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | src/lisp.h [REL_ALLOC]: Add prototypes for external functions defined on ralloc.c. src/buffer.c [REL_ALLOC]: Remove prototypes of r_alloc_reset_variable, r_alloc, r_re_alloc, and r_alloc_free, they are now on lisp.h. src/ralloc.c (r_alloc_inhibit_buffer_relocation): New function. src/search.c (search_buffer): Use it to inhibit relocation of buffer text while re_search_2 is doing its job, because re_search_2 is passed C pointers to buffer text.
* | Merge from trunk.Paul Eggert2012-05-251-191/+0
|\ \
| * | Move word search functions from search.c to isearch.el (bug#10145, bug#11381).Juri Linkov2012-05-171-181/+0
| |/ | | | | | | | | | | | | | | | | | | * lisp/isearch.el (word-search-regexp, word-search-backward) (word-search-forward, word-search-backward-lax) (word-search-forward-lax): Move functions from search.c. * src/search.c (Fword_search_regexp, Fword_search_backward) (Fword_search_forward, Fword_search_backward_lax) (Fword_search_forward_lax): Move functions to isearch.el.
* | Merge from trunk.Paul Eggert2012-04-091-4/+5
|\ \ | |/
| * Small doc and elisp manual fixes related to searching Glenn Morris2012-03-261-4/+5
| | | | | | | | | | | | | | | | | | * doc/lispref/searching.texi (String Search): Add xref to Emacs manual. Copyedits. Mention the function word-search-regexp. (Searching and Case): Add xref to Emacs manual. Copyedits. * src/search.c (Fword_search_backward_lax, Fword_search_forward_lax): Doc fixes.
* | Merge from trunk.Paul Eggert2012-02-101-2/+6
|\ \ | |/
| * Document negative repeat counts for search-forward and search-backward.Chong Yidong2012-01-261-2/+6
| | | | | | | | | | | | | | * doc/lispref/searching.texi (String Search): Document negative repeat count. * src/search.c (Fsearch_forward, Fsearch_backward): Document negative repeat counts (Bug#10507).
* | Merge from trunk.Paul Eggert2012-01-091-6/+6
|\ \ | |/
| * Fix bug #6540 with a crash while inserting non-ASCII text under ↵Eli Zaretskii2012-01-071-4/+4
| | | | | | | | | | | | | | cache-long-line-scans. src/search.c (scan_buffer): Pass character positions to know_region_cache, not byte positions. (Bug#6540)