From: Paul Eggert Date: Tue, 29 Mar 2011 23:35:49 +0000 (-0700) Subject: Merge from mainline. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~460^2~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8289296548281f6fa4c8b6b1ee9ead764c4c9aa3;p=emacs.git Merge from mainline. --- 8289296548281f6fa4c8b6b1ee9ead764c4c9aa3 diff --cc src/ChangeLog index 6ba04202854,1e77a6439e1..4e84f9510dd --- a/src/ChangeLog +++ b/src/ChangeLog @@@ -1,73 -1,79 +1,145 @@@ +2011-03-29 Paul Eggert + + * xdisp.c (try_window_reusing_current_matrix, x_produce_glyphs): + (note_mode_line_or_margin_highlight, note_mouse_highlight): + Omit unused local vars. + * window.c (shrink_windows): Omit unused local var. + * menu.c (digest_single_submenu): Omit unused local var. + * dispnew.c (update_window) [PERIODIC_PREEMPTION_CHECKING]: + Omit unused local var. + - 2011-03-27 Paul Eggert - + * keyboard.c (parse_modifiers_uncached, parse_modifiers): + Don't assume string length fits in int. + (keyremap_step, read_key_sequence): Use size_t for sizes. + (read_key_sequence): Don't check last_real_key_start redundantly. + + * callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA + instead of alloca (Bug#8344). + + * eval.c (Fbacktrace): Don't assume nargs fits in int. + (Fbacktrace_frame): Don't assume nframes fits in int. + + * syntax.c (scan_sexps_forward): Avoid pointer wraparound. + + * xterm.c (x_make_frame_visible, same_x_server): Redo to avoid overflow + concerns. + + * term.c (produce_glyphless_glyph): Remove unnecessary test. + + * cm.c (calccost): Turn while-do into do-while, for clarity. + + * keyboard.c (syms_of_keyboard): Use the same style as later + in this function when indexing through an array. This also + works around GCC bug 48267. + + * image.c (tiff_load): Fix off-by-one image count (Bug#8336). + + * xselect.c (x_check_property_data): Return correct size (Bug#8335). + + * chartab.c (sub_char_table_ref_and_range): Redo for slight + efficiency gain, and to bypass a gcc -Wstrict-overflow warning. + + * keyboard.c, keyboard.h (num_input_events): Now size_t. + This avoids undefined behavior on integer overflow, and is a bit + more convenient anyway since it is compared to a size_t variable. + + Variadic C functions now count arguments with size_t, not int. + This avoids an unnecessary limitation on 64-bit machines, which + caused (substring ...) to crash on large vectors (Bug#8344). + * lisp.h (struct Lisp_Subr.function.aMANY): Now takes size_t, not int. + (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call): Likewise. + All variadic functions changed accordingly. + (struct gcpro.nvars): Now size_t, not int. All uses changed. + * data.c (arith_driver, float_arith_driver): Likewise. + * editfns.c (general_insert_function): Likewise. + * eval.c (struct backtrace.nargs, interactive_p) + (internal_condition_case_n, run_hook_with_args, apply_lambda) + (funcall_lambda, mark_backtrace): Likewise. + * fns.c (concat): Likewise. + * frame.c (x_set_frame_parameters): Likewise. + * fns.c (get_key_arg): Now accepts and returns size_t, and returns + 0 if not found, not -1. All callers changed. + - 2011-03-26 Paul Eggert - + * alloc.c (garbage_collect): Don't assume stack size fits in int. + (stack_copy_size): Now size_t, not int. + (stack_copy, stack_copy_size): Define only if MAX_SAVE_STACK > 0. + + 2011-03-28 Juanma Barranquero + + * coding.c (encode_designation_at_bol): Remove parameter `charbuf_end', + unused since 2002-03-01T01:17:24Z!handa@m17n.org and 2008-02-01T16:01:31Z!miles@gnu.org. + All callers changed. + + * lisp.h (multibyte_char_to_unibyte): + * character.c (multibyte_char_to_unibyte): Remove parameter `rev_tbl', + unused since 2002-03-01T01:16:34Z!handa@m17n.org and 2008-02-01T16:01:31Z!miles@gnu.org. + * character.h (CHAR_TO_BYTE8): + * cmds.c (internal_self_insert): + * editfns.c (general_insert_function): + * keymap.c (push_key_description): + * search.c (Freplace_match): + * xdisp.c (message_dolog, set_message_1): All callers changed. + + 2011-03-28 Stefan Monnier + + * keyboard.c (safe_run_hook_funcall): New function. + (safe_run_hooks_1, safe_run_hooks_error, safe_run_hooks): On error, + don't set the hook to nil, but remove the offending function instead. + (Qcommand_hook_internal): Remove, unused. + (syms_of_keyboard): Don't initialize Qcommand_hook_internal nor define + Vcommand_hook_internal. + + * eval.c (enum run_hooks_condition): Remove. + (funcall_nil, funcall_not): New functions. + (run_hook_with_args): Call each function through a `funcall' argument. + Remove `cond' argument, now redundant. + (Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success) + (Frun_hook_with_args_until_failure): Adjust accordingly. + (run_hook_wrapped_funcall, Frun_hook_wrapped): New functions. + + 2011-03-28 Juanma Barranquero + + * dispextern.h (string_buffer_position): Remove declaration. + + * print.c (strout): Remove parameter `multibyte', unused since + 1999-08-21T19:30:21Z!gerd@gnu.org. All callers changed. + + * search.c (boyer_moore): Remove parameters `len', `pos' and `lim', + never used since function introduction in 1998-02-08T21:33:56Z!rms@gnu.org. + All callers changed. + + * w32.c (_wsa_errlist): Use braces for struct initializers. + + * xdisp.c (string_buffer_position_lim): Remove parameter `w', + never used since function introduction in 2001-03-09T18:41:50Z!gerd@gnu.org. + All callers changed. + (string_buffer_position): Likewise. Also, make static (it's never + used outside xdisp.c). + (cursor_row_p): Remove parameter `w', unused since + 2000-10-17T16:08:57Z!gerd@gnu.org. All callers changed. + (decode_mode_spec): Remove parameter `precision', introduced during + Gerd Moellmann's rewrite at 1999-07-21T21:43:52Z!gerd@gnu.org, but never used. + All callers changed. + + 2011-03-27 Jan Djärv + + * nsterm.m (syms_of_nsterm): Use doc: for ns-auto-hide-menu-bar. + + 2011-03-27 Anders Lindgren + + * nsterm.m (ns_menu_bar_is_hidden): New variable. + (ns_constrain_all_frames, ns_menu_bar_should_be_hidden) + (ns_update_auto_hide_menu_bar): New functions. + (ns_update_begin): Call ns_update_auto_hide_menu_bar. + (applicationDidBecomeActive): Call ns_update_auto_hide_menu_bar and + ns_constrain_all_frames. + (constrainFrameRect): Return at once if ns_menu_bar_should_be_hidden. + (syms_of_nsterm): DEFVAR ns-auto-hide-menu-bar, init to Qnil. + + 2011-03-27 Jan Djärv + + * nsmenu.m (runDialogAt): Remove argument to timer_check. + 2011-03-27 Glenn Morris * syssignal.h: Replace RETSIGTYPE with void. diff --cc src/eval.c index 982fec66bbf,75874367f2c..c3f9cd158f7 --- a/src/eval.c +++ b/src/eval.c @@@ -37,12 -37,12 +37,12 @@@ struct backtrac { struct backtrace *next; Lisp_Object *function; - Lisp_Object *args; /* Points to vector of args. */ - int nargs; /* Length of vector. - If nargs is UNEVALLED, args points to slot holding - list of unevalled args. */ + Lisp_Object *args; /* Points to vector of args. */ + size_t nargs; /* Length of vector. + If nargs is (size_t) UNEVALLED, args points - to slot holding list of unevalled args */ ++ to slot holding list of unevalled args. */ char evalargs; - /* Nonzero means call value of debugger when done with this operation. */ + /* Nonzero means call value of debugger when done with this operation. */ char debug_on_exit; }; @@@ -553,10 -553,10 +553,10 @@@ interactive_p (int exclude_subrs_p looking at several frames for special forms. Skip past them. */ while (btp && (EQ (*btp->function, Qbytecode) - || btp->nargs == UNEVALLED)) + || btp->nargs == (size_t) UNEVALLED)) btp = btp->next; - /* btp now points at the frame of the innermost function that isn't + /* `btp' now points at the frame of the innermost function that isn't a special form, ignoring frames for Finteractive_p and/or Fbytecode at the top. If this frame is for a built-in function (such as load or eval-region) return nil. */ @@@ -2190,8 -2187,9 +2187,9 @@@ DEFUN ("eval", Feval, Seval, 1, 1, 0 CHECK_CONS_LIST (); - if (XINT (numargs) < XSUBR (fun)->min_args || - (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) + if (XINT (numargs) < XSUBR (fun)->min_args - || (XSUBR (fun)->max_args >= 0 ++ || (0 <= XSUBR (fun)->max_args + && XSUBR (fun)->max_args < XINT (numargs))) xsignal2 (Qwrong_number_of_arguments, original_fun, numargs); else if (XSUBR (fun)->max_args == UNEVALLED) @@@ -2201,9 -2199,9 +2199,9 @@@ } else if (XSUBR (fun)->max_args == MANY) { - /* Pass a vector of evaluated arguments */ + /* Pass a vector of evaluated arguments. */ Lisp_Object *vals; - register int argnum = 0; + register size_t argnum = 0; USE_SAFE_ALLOCA; SAFE_ALLOCA_LISP (vals, XINT (numargs)); @@@ -2373,11 -2371,11 +2371,11 @@@ usage: (apply FUNCTION &rest ARGUMENTS { if (numargs < XSUBR (fun)->min_args || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) - goto funcall; /* Let funcall get the error */ + goto funcall; /* Let funcall get the error. */ - else if (XSUBR (fun)->max_args > numargs) + else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs) { /* Avoid making funcall cons up a yet another new vector of arguments - by explicitly supplying nil's for optional values */ + by explicitly supplying nil's for optional values. */ SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args); for (i = numargs; i < XSUBR (fun)->max_args;) funcall_args[++i] = Qnil; @@@ -2415,9 -2413,16 +2413,12 @@@ /* Run hook variables in various ways. */ - enum run_hooks_condition {to_completion, until_success, until_failure}; - static Lisp_Object run_hook_with_args (size_t, Lisp_Object *, - enum run_hooks_condition); -Lisp_Object run_hook_with_args (int, Lisp_Object *, - Lisp_Object (*funcall) - (int nargs, Lisp_Object *args)); - + static Lisp_Object -funcall_nil (int nargs, Lisp_Object *args) ++funcall_nil (size_t nargs, Lisp_Object *args) + { + Ffuncall (nargs, args); + return Qnil; + } DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0, doc: /* Run each hook in HOOKS. @@@ -2463,9 -2468,9 +2464,9 @@@ as that may change Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args HOOK &rest ARGS) */) - (int nargs, Lisp_Object *args) + (size_t nargs, Lisp_Object *args) { - return run_hook_with_args (nargs, args, to_completion); + return run_hook_with_args (nargs, args, funcall_nil); } DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, @@@ -2483,9 -2488,15 +2484,15 @@@ However, if they all return nil, we ret Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args-until-success HOOK &rest ARGS) */) - (int nargs, Lisp_Object *args) + (size_t nargs, Lisp_Object *args) { - return run_hook_with_args (nargs, args, until_success); + return run_hook_with_args (nargs, args, Ffuncall); + } + + static Lisp_Object -funcall_not (int nargs, Lisp_Object *args) ++funcall_not (size_t nargs, Lisp_Object *args) + { + return NILP (Ffuncall (nargs, args)) ? Qt : Qnil; } DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, @@@ -2502,11 -2513,35 +2509,35 @@@ Then we return nil. However, if they a Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */) - (int nargs, Lisp_Object *args) + (size_t nargs, Lisp_Object *args) { - return run_hook_with_args (nargs, args, until_failure); + return NILP (run_hook_with_args (nargs, args, funcall_not)) ? Qt : Qnil; + } + + static Lisp_Object -run_hook_wrapped_funcall (int nargs, Lisp_Object *args) ++run_hook_wrapped_funcall (size_t nargs, Lisp_Object *args) + { + Lisp_Object tmp = args[0], ret; + args[0] = args[1]; + args[1] = tmp; + ret = Ffuncall (nargs, args); + args[1] = args[0]; + args[0] = tmp; + return ret; + } + + DEFUN ("run-hook-wrapped", Frun_hook_wrapped, Srun_hook_wrapped, 2, MANY, 0, + doc: /* Run HOOK, passing each function through WRAP-FUNCTION. + I.e. instead of calling each function FUN directly with arguments ARGS, + it calls WRAP-FUNCTION with arguments FUN and ARGS. + As soon as a call to WRAP-FUNCTION returns non-nil, `run-hook-wrapped' + aborts and returns that value. + usage: (run-hook-wrapped HOOK WRAP-FUNCTION &rest ARGS) */) - (int nargs, Lisp_Object *args) ++ (size_t nargs, Lisp_Object *args) + { + return run_hook_with_args (nargs, args, run_hook_wrapped_funcall); } - + /* ARGS[0] should be a hook symbol. Call each of the functions in the hook value, passing each of them as arguments all the rest of ARGS (all NARGS - 1 elements). @@@ -2515,11 -2549,11 +2545,11 @@@ The caller (or its caller, etc) must gcpro all of ARGS, except that it isn't necessary to gcpro ARGS[0]. */ - static Lisp_Object + Lisp_Object -run_hook_with_args (int nargs, Lisp_Object *args, - Lisp_Object (*funcall) (int nargs, Lisp_Object *args)) +run_hook_with_args (size_t nargs, Lisp_Object *args, - enum run_hooks_condition cond) ++ Lisp_Object (*funcall) (size_t nargs, Lisp_Object *args)) { - Lisp_Object sym, val, ret; + Lisp_Object sym, val, ret = Qnil; struct gcpro gcpro1, gcpro2, gcpro3; /* If we are dying or still initializing, @@@ -3320,14 -3346,13 +3343,14 @@@ Output stream used is value of `standar else { tem = *backlist->function; - Fprin1 (tem, Qnil); /* This can QUIT */ + Fprin1 (tem, Qnil); /* This can QUIT. */ write_string ("(", -1); - if (backlist->nargs == MANY) + if (backlist->nargs == (size_t) MANY) { + int i; for (tail = *backlist->args, i = 0; !NILP (tail); - tail = Fcdr (tail), i++) + tail = Fcdr (tail), i = 1) { if (i) write_string (" ", -1); Fprin1 (Fcar (tail), Qnil); diff --cc src/keyboard.c index 6c706590dc4,3fea3df07d5..86a2b3e8abd --- a/src/keyboard.c +++ b/src/keyboard.c @@@ -1815,20 -1814,63 +1814,63 @@@ adjust_point_for_property (EMACS_INT la static Lisp_Object safe_run_hooks_1 (void) { - return Frun_hooks (1, &Vinhibit_quit); + eassert (CONSP (Vinhibit_quit)); + return call0 (XCDR (Vinhibit_quit)); } - /* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */ + /* Subroutine for safe_run_hooks: handle an error by clearing out the function + from the hook. */ static Lisp_Object - safe_run_hooks_error (Lisp_Object data) + safe_run_hooks_error (Lisp_Object error_data) + { + Lisp_Object hook + = CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit; + Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil; + Lisp_Object args[4]; + args[0] = build_string ("Error in %s (%s): %s"); + args[1] = hook; + args[2] = fun; + args[3] = error_data; + Fmessage (4, args); + if (SYMBOLP (hook)) + { + Lisp_Object val; + int found = 0; + Lisp_Object newval = Qnil; + for (val = find_symbol_value (hook); CONSP (val); val = XCDR (val)) + if (EQ (fun, XCAR (val))) + found = 1; + else + newval = Fcons (XCAR (val), newval); + if (found) + return Fset (hook, Fnreverse (newval)); + /* Not found in the local part of the hook. Let's look at the global + part. */ + newval = Qnil; + for (val = (NILP (Fdefault_boundp (hook)) ? Qnil + : Fdefault_value (hook)); + CONSP (val); val = XCDR (val)) + if (EQ (fun, XCAR (val))) + found = 1; + else + newval = Fcons (XCAR (val), newval); + if (found) + return Fset_default (hook, Fnreverse (newval)); + } + return Qnil; + } + + static Lisp_Object -safe_run_hook_funcall (int nargs, Lisp_Object *args) ++safe_run_hook_funcall (size_t nargs, Lisp_Object *args) { - Lisp_Object args[3]; - args[0] = build_string ("Error in %s: %s"); - args[1] = Vinhibit_quit; - args[2] = data; - Fmessage (3, args); - return Fset (Vinhibit_quit, Qnil); + eassert (nargs == 1); + if (CONSP (Vinhibit_quit)) + XSETCDR (Vinhibit_quit, args[0]); + else + Vinhibit_quit = Fcons (Vinhibit_quit, args[0]); + + return internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error); } /* If we get an error while running the hook, cause the hook variable diff --cc src/lisp.h index edf6130e5b5,a3c4d48b49c..85838d111db --- a/src/lisp.h +++ b/src/lisp.h @@@ -2830,6 -2830,9 +2830,9 @@@ EXFUN (Frun_hooks, MANY) EXFUN (Frun_hook_with_args, MANY); EXFUN (Frun_hook_with_args_until_failure, MANY); extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object); -extern Lisp_Object run_hook_with_args (int nargs, Lisp_Object *args, ++extern Lisp_Object run_hook_with_args (size_t nargs, Lisp_Object *args, + Lisp_Object (*funcall) - (int nargs, Lisp_Object *args)); ++ (size_t nargs, Lisp_Object *args)); EXFUN (Fprogn, UNEVALLED); EXFUN (Finteractive_p, 0); EXFUN (Fthrow, 2) NO_RETURN;