Paul Eggert [Sun, 4 Sep 2011 18:46:51 +0000 (11:46 -0700)]
* window.c: Integer overflow fixes.
(window_scroll_line_based, Frecenter):
Check that an Emacs fixnum is in range before assigning it to 'int'.
(Frecenter, Fmove_to_window_line): Use EMACS_INT, not int, for
values converted from Emacs fixnums.
(Frecenter): Don't wrap around a line count if it is out of 'int'
range; instead, treat it as an extreme value.
(Fset_window_configuration, compare_window_configurations):
Use ptrdiff_t, not int, for index that might exceed 2 GiB.
Michael Albinus [Sun, 4 Sep 2011 18:14:34 +0000 (20:14 +0200)]
* net/tramp.el (top): Require 'shell. Use `tramp-unload-hook' but
`tramp-cache-unload-hook' where appropriate.
(tramp-methods): Rename `tramp-remote-sh' to
`tramp-remote-shell'. Add `tramp-remote-shell-args'.
(tramp-handle-shell-command): New defun, moved from tramp-sh.el.
* net/tramp-sh.el (top): Don't require 'shell.
(tramp-methods): Add `tramp-remote-shell' and
`tramp-remote-shell-args' entries.
(tramp-sh-file-name-handler-alist): Use `tramp-handle-shell-command'.
(tramp-sh-handle-shell-command): Remove.
(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
Use `tramp-remote-shell'.
Paul Eggert [Sun, 4 Sep 2011 17:27:38 +0000 (10:27 -0700)]
* search.c: Integer overflow fixes
(Freplace_match): Use ptrdiff_t, not int, for indexes that can
exceed INT_MAX. Check that EMACS_INT value is in range before
assigning it to the (possibly-narrower) index.
(match_limit): Don't assume that a fixnum can fit in 'int'.
Paul Eggert [Sun, 4 Sep 2011 17:24:12 +0000 (10:24 -0700)]
* indent.c: Integer overflow fixes.
(position_indentation): Now takes ptrdiff_t, not int.
(Fvertical_motion): Don't wrap around LINES values that don't fit
in 'int'. Instead, treat them as extreme values. This is good
enough for windows, which can't have more than INT_MAX lines anyway.
* progmodes/python.el (python-mode-map): Use correct function to
start python interpreter from menu-bar (as reported by Geert
Kloosterman).
(inferior-python-mode-map): Fix typo.
(python-shell-map): Removed.
Deniz Dogan [Sat, 3 Sep 2011 17:40:08 +0000 (19:40 +0200)]
* lisp/net/rcirc.el (rcirc-print): Simplify code for rcirc-scroll-show-maximum-output. There is no need to walk through all windows to find the right one.
Martin Rudalics [Sat, 3 Sep 2011 10:55:37 +0000 (12:55 +0200)]
Don't delete frame when there's a previous buffer to show (Bug#9419).
* window.el (window-deletable-p): Don't return a non-nil value
when there's a buffer that was shown in the window before.
(Bug#9419)
(display-buffer-pop-up-frame, display-buffer-pop-up-window): Set
window's previous buffers to nil.
Eli Zaretskii [Sat, 3 Sep 2011 08:44:16 +0000 (11:44 +0300)]
Fix display by Rmail of bidirectional text in MIME email messages.
lisp/mail/rmailmm.el (rmail-mime-insert-tagline): Insert an extra
newline before and after the tag line, so it doesn't interfere
with determining the paragraph direction of bidirectional text.
* lisp/window.el (pop-to-buffer-1, pop-to-buffer-same-window): Deleted.
(pop-to-buffer): Change interactive spec. Pass second argument
directly to display-buffer.
(display-buffer): Fix interactive spec. Use functionp to
distinguish between a function and a list of functions.
Fix display-buffer interactive spec, and fixes for pop-to-buffer*.
* lisp/window.el (display-buffer): Restore interactive spec.
(display-buffer-same-window, display-buffer-other-window): New
functions.
(pop-to-buffer-1): New function. Use the above.
(pop-to-buffer, pop-to-buffer-same-window): Use it.
(pop-to-buffer-other-window, pop-to-buffer-other-frame): Deleted.
* lisp/view.el (view-buffer-other-window, view-buffer-other-frame):
Just use pop-to-buffer.
Michael Albinus [Wed, 31 Aug 2011 08:18:20 +0000 (10:18 +0200)]
* net/tramp.el (tramp-root-regexp): Remove.
(tramp-completion-file-name-regexp-unified)
(tramp-completion-file-name-regexp-separate)
(tramp-completion-file-name-regexp-url): Don't use leading volume
letter on win32 systems. (Bug#5303, Bug#9311)
(tramp-drop-volume-letter): Simplify definition. Suggested by
Stefan Monnier <monnier@iro.umontreal.ca>.
Paul Eggert [Wed, 31 Aug 2011 05:50:49 +0000 (22:50 -0700)]
Avoid the use of snprintf.
* font.c (APPEND_SNPRINTF): Remove.
(font_unparse_xlfd):
* xterm.c (x_io_error_quitter):
Use esnprintf, not snprintf. That way, we don't have to worry
about porting to ancient platforms that lack snprintf.
(x_term_init): Use sprintf, not snprintf.
Paul Eggert [Tue, 30 Aug 2011 20:46:59 +0000 (13:46 -0700)]
* configure.in: Remove no-longer used HP patterns.
(opsys): Remove unreachable pattern hppa*-*-linux-gnu*.
Also, remove ia64*-hp-hpux1[1-9]*, as it also sets machine=hp800,
and that can't possibly work now that src/m/hp800.h no longer exists.
Eli Zaretskii [Tue, 30 Aug 2011 17:32:44 +0000 (20:32 +0300)]
Fix bug #9402 with :align-to on TTY frames.
src/xdisp.c (produce_stretch_glyph): No longer static, compiled also
when HAVE_WINDOW_SYSTEM is not defined. Support both GUI and TTY
frames. Call tty_append_glyph in the TTY case. (Bug#9402)
src/term.c (tty_append_glyph): New function.
(produce_stretch_glyph): Static function and its prototype deleted.
src/dispextern.h (produce_stretch_glyph, tty_append_glyph): Add
prototypes.
Chong Yidong [Mon, 29 Aug 2011 22:02:21 +0000 (18:02 -0400)]
Update and edit manual sections on major modes.
* doc/emacs/modes.texi (Choosing Modes): auto-mode-case-fold is now t.
* doc/lispref/modes.texi (Basic Major Modes): New node. Callers updated.
(Major Modes): Document fundamental-mode and major-mode.
(Major Mode Basics): Node deleted; text moved to Major Modes.
(Derived Modes): Document derived-mode-p.
Paul Eggert [Mon, 29 Aug 2011 19:14:47 +0000 (12:14 -0700)]
* print.c (float_to_string): Detect width overflow more reliably.
(print_object): Make sprintf buffer a bit bigger, to avoid potential
buffer overrun. Don't assume list length fits in 'int'. Treat
print length of 0 as 0, not as infinity; to be consistent with other
uses of print length in this function. Don't overflow print length
index. Don't assume hash table size fits in 'long', or that
vectorlike size fits in 'unsigned long'.
Paul Eggert [Mon, 29 Aug 2011 19:07:18 +0000 (12:07 -0700)]
* macros.c (executing_kbd_macro_iterations): Now EMACS_INT, not int.
(Fend_kbd_macro): Don't mishandle MOST_NEGATIVE_FIXNUM by treating
it as a large positive number.
(Fexecute_kbd_macro): Don't assume repeat count fits in int.
* macros.h (executing_kbd_macro_iterations): Now EMACS_INT, not int.
Paul Eggert [Mon, 29 Aug 2011 18:52:26 +0000 (11:52 -0700)]
* frame.c (tty_frame_count): Now printmax_t, not int.
(make_terminal_frame, set_term_frame_name): Print it.
(x_report_frame_params): In X, window IDs are unsigned long,
not signed long, so print them as unsigned.
(validate_x_resource_name): Check for implausibly long names,
and don't assume name length fits in 'int'.
(x_get_resource_string): Don't blindly alloca invocation name;
use SAFE_ALLOCA. Use esprintf, not sprintf, in case result does
not fit in int.
Paul Eggert [Mon, 29 Aug 2011 18:46:42 +0000 (11:46 -0700)]
* font.c (font_unparse_xlfd): Don't blindly alloca long strings.
Don't assume XINT result fits in int, or that XFLOAT_DATA * 10
fits in int, when using sprintf. Use single snprintf to count
length of string rather than counting it via multiple sprintfs;
that's simpler and more reliable.
(APPEND_SPRINTF): New macro.
(font_unparse_fcname): Use it to avoid sprintf buffer overrun.
(generate_otf_features) [0 && HAVE_LIBOTF]: Use esprintf, not
sprintf, in case result does not fit in int.
Paul Eggert [Mon, 29 Aug 2011 15:43:34 +0000 (08:43 -0700)]
sprintf-related integer and memory overflow issues.
* doprnt.c (doprnt): Support printing ptrdiff_t and intmax_t values.
(esprintf, esnprintf, exprintf, evxprintf): New functions.
* keyboard.c (command_loop_level): Now EMACS_INT, not int.
(cmd_error): kbd macro iterations count is now EMACS_INT, not int.
(modify_event_symbol): Do not assume that the length of
name_alist_or_stem is safe to alloca and fits in int.
(Fexecute_extended_command): Likewise for function name and binding.
(Frecursion_depth): Wrap around reliably on integer overflow.
* keymap.c (push_key_description): First arg is now EMACS_INT, not int,
since some callers pass EMACS_INT values.
(Fsingle_key_description): Don't crash if symbol name contains more
than MAX_ALLOCA bytes.
* minibuf.c (minibuf_level): Now EMACS_INT, not int.
(get_minibuffer): Arg is now EMACS_INT, not int.
* lisp.h (get_minibuffer, push_key_description): Reflect API changes.
(esprintf, esnprintf, exprintf, evxprintf): New decls.
* window.h (command_loop_level, minibuf_level): Reflect API changes.
Paul Eggert [Mon, 29 Aug 2011 03:34:25 +0000 (20:34 -0700)]
* image.c (parse_image_spec): Check for nonnegative, not for positive,
when checking :margin (Bug#9390).
(IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR):
Renamed from IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,
so that the name doesn't mislead. All uses changed.
Paul Eggert [Sun, 28 Aug 2011 23:55:41 +0000 (16:55 -0700)]
* etags.c (xmalloc, xrealloc): Accept size_t, not unsigned int,
to avoid potential buffer overflow issues on typical 64-bit hosts.
(whatlen_max): New static var.
(main): Avoid buffer overflow if subsidiary command length is
greater than BUFSIZ or 2*BUFSIZ + 20. Do not use sprintf when its
result might not fit in 'int'.
Paul Eggert [Sun, 28 Aug 2011 23:52:34 +0000 (16:52 -0700)]
Integer and memory overflow issues.
* emacsclient.c (xmalloc): Accept size_t, not unsigned int, to
avoid potential buffer overflow issues on typical 64-bit hosts.
Return void *, not long *.
(get_current_dir_name): Report a failure, instead of looping
forever, if buffer size calculation overflows. Treat malloc
failures like realloc failures, as that has better behavior and is
more consistent. Do not check whether xmalloc returns NULL, as
that's not possible.
(message): Do not arbitrarily truncate message to 2048 bytes when
sending it to stderr; use vfprintf instead.
(get_server_config, set_local_socket)
(start_daemon_and_retry_set_socket): Do not alloca
arbitrarily-large buffers; that's not safe.
(get_server_config, set_local_socket): Do not use sprintf when its
result might not fit in 'int'.
(set_local_socket): Do not assume uid fits in 'int'.