Paul Eggert [Sat, 9 Jul 2011 07:01:24 +0000 (00:01 -0700)]
* image.c: Integer signedness and overflow and related fixes.
This is not an exhaustive set of fixes, but it's time to
record what I've got.
(lookup_pixel_color, check_image_size): Remove redundant decls.
(check_image_size): Don't assume that arbitrary EMACS_INT values
fit in 'int', or that arbitrary 'double' values fit in 'int'.
(x_alloc_image_color, x_create_x_image_and_pixmap, png_load)
(tiff_load, imagemagick_load_image):
Check for overflow in size calculations.
(x_create_x_image_and_pixmap): Remove unnecessary test for
xmalloc returning NULL; that can't happen.
(xbm_read_bitmap_data): Don't assume sizes fit into 'int'.
(xpm_color_bucket): Use better integer hashing function.
(xpm_cache_color): Don't possibly over-allocate memory.
(struct png_memory_storage, tiff_memory_source, tiff_seek_in_memory)
(gif_memory_source):
Use ptrdiff_t, not int or size_t, to record sizes.
(png_load): Don't assume values greater than 2**31 fit in 'int'.
(our_stdio_fill_input_buffer): Prefer ptrdiff_t to size_t when
either works, as we prefer signed integers.
(tiff_read_from_memory, tiff_write_from_memory):
Return tsize_t, not size_t, since that's what the TIFF API wants.
(tiff_read_from_memory): Don't fail simply because the read would
go past EOF; instead, return a short read.
(tiff_load): Omit no-longer-needed casts.
(Fimagemagick_types): Don't assume size fits into 'int'.
Paul Eggert [Fri, 8 Jul 2011 00:51:25 +0000 (17:51 -0700)]
Improve hashing quality when configured --with-wide-int.
* fns.c (hash_string): New function, taken from sxhash_string.
Do not discard information about ASCII character case; this
discarding is no longer needed.
(sxhash-string): Use it. Change sig to match it. Caller changed.
* lisp.h: Declare it.
* lread.c (hash_string): Remove, since we now use fns.c's version.
The fns.c version returns a wider integer if --with-wide-int is
specified, so this should help the quality of the hashing a bit.
Paul Eggert [Thu, 7 Jul 2011 22:45:25 +0000 (15:45 -0700)]
* emacs.c: Integer overflow minor fix.
(heap_bss_diff): Now uprintmax_t, not unsigned long. All used changed.
Define only if GNU_LINUX.
(main, Fdump_emacs): Set and use heap_bss_diff only if GNU_LINUX.
Paul Eggert [Thu, 7 Jul 2011 22:14:22 +0000 (15:14 -0700)]
* dispnew.c: Integer signedness and overflow fixes.
Remove unnecessary forward decls, that were a maintenance hassle.
(history_tick): Now uprintmax_t, so it's more likely to avoid overflow.
All uses changed.
(adjust_glyph_matrix, realloc_glyph_pool, adjust_frame_message_buffer)
(scrolling_window): Use ptrdiff_t, not int, for byte count.
(prepare_desired_row, line_draw_cost):
Use int, not unsigned, where either works.
(save_current_matrix, restore_current_matrix):
Use ptrdiff_t, not size_t, where either works.
(init_display): Check for overflow more accurately, and without
relying on undefined behavior.
Remove, replacing with the new symbols in lisp.h. All uses changed.
* fileio.c (make_temp_name):
* filelock.c (lock_file_1, lock_file):
* xdisp.c (message_dolog):
Don't assume PRIdMAX etc. works; this isn't portable to pre-C99 hosts.
Use pMd etc. instead.
* lisp.h (printmax_t, uprintmax_t, pMd, pMu): New types and macros,
replacing the pWIDE etc. symbols removed from editfns.c.
Paul Eggert [Thu, 7 Jul 2011 17:42:28 +0000 (10:42 -0700)]
* bidi.c: Integer signedness and overflow fixes.
(bidi_cache_idx, bidi_cache_last_idx, bidi_cache_fetch_state)
(bidi_cache_search, bidi_cache_find_level_change)
(bidi_cache_iterator_state, bidi_cache_find, bidi_find_other_level_edge)
(bidi_dump_cached_states):
Don't arbitrarily limit cache indexes to int; use ptrdiff_t instead.
(bidi_cache_size): Use ptrdiff_t rather than size_t, as we prefer
signed integers.
(elsz): Make it a (signed) constant.
(bidi_cache_iterator_state): Check for size-calculation overflow.
Paul Eggert [Thu, 7 Jul 2011 16:58:24 +0000 (09:58 -0700)]
* alloc.c: Integer signedness and overflow fixes.
Do not impose an arbitrary 32-bit limit on malloc sizes when debugging.
(__malloc_size_t): Default to size_t, not to int.
(pure_size, pure_bytes_used_before_overflow, stack_copy_size)
(Fgarbage_collect, mark_object_loop_halt, mark_object):
Prefer ptrdiff_t to size_t when either would do, as we prefer
signed integers.
(XMALLOC_OVERRUN_CHECK_OVERHEAD): New macro.
(xmalloc_overrun_check_header, xmalloc_overrun_check_trailer):
Now const. Initialize with values that are in range even if char
is signed.
(XMALLOC_PUT_SIZE, XMALLOC_GET_SIZE): Remove, replacing with ...
(xmalloc_put_size, xmalloc_get_size): New functions. All uses changed.
These functions do the right thing with sizes > 2**32.
(check_depth): Now ptrdiff_t, not int.
(overrun_check_malloc, overrun_check_realloc, overrun_check_free):
Adjust to new way of storing sizes. Check for size overflow bugs
in rest of code.
(STRING_BYTES_MAX): Adjust to new overheads. The old code was
slightly wrong anyway, as it missed one instance of
XMALLOC_OVERRUN_CHECK_OVERHEAD.
(refill_memory_reserve): Omit needless cast to size_t.
(mark_object_loop_halt): Mark as externally visible.
Paul Eggert [Thu, 7 Jul 2011 02:24:56 +0000 (19:24 -0700)]
* xselect.c: Integer signedness and overflow fixes.
(Fx_register_dnd_atom, x_handle_dnd_message):
Use ptrdiff_t, not size_t, since we prefer signed.
(Fx_register_dnd_atom): Check for ptrdiff_t (and size_t) overflow.
* xterm.h (struct x_display_info): Use ptrdiff_t, not size_t, for
x_dnd_atoms_size and x_dnd_atoms_length.
Paul Eggert [Thu, 7 Jul 2011 02:14:52 +0000 (19:14 -0700)]
* doprnt.c: Prefer signed to unsigned when either works.
* eval.c (verror):
* doprnt.c (doprnt):
* lisp.h (doprnt):
* xdisp.c (vmessage):
Use ptrdiff_t, not size_t, when using or implementing doprnt,
since the sizes cannot exceed ptrdiff_t bounds anyway, and we
prefer signed arithmetic to avoid comparison confusion.
* doprnt.c (doprnt): Avoid a "+ 1" that can't overflow,
but is a bit tricky.
Paul Eggert [Wed, 6 Jul 2011 21:56:44 +0000 (14:56 -0700)]
Merge: Remove unportable assumption about struct layout (Bug#8884).
* buffer.c (clone_per_buffer_values): Don't assume that
sizeof (struct buffer) is a multiple of sizeof (Lisp_Object).
This isn't true in general, and it's particularly not true
if Emacs is configured with --with-wide-int.
* buffer.h (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER):
New macros, used in the buffer.c change.
Paul Eggert [Wed, 6 Jul 2011 21:53:56 +0000 (14:53 -0700)]
Remove unportable assumption about struct layout (Bug#8884).
* buffer.c (clone_per_buffer_values): Don't assume that
sizeof (struct buffer) is a multiple of sizeof (Lisp_Object).
This isn't true in general, and it's particularly not true
if Emacs is configured with --with-wide-int.
* buffer.h (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER):
New macros, used in the buffer.c change.
* net/network-stream.el (network-stream-open-starttls): Try using
a plain connection even if the server offered STARTTLS, and we
kinda wanted to use it, if Emacs doesn't have any STARTTLS
capability. This should make smtpmail.el work in slightly more
configurations.
Michael Mauger [Wed, 6 Jul 2011 03:51:48 +0000 (23:51 -0400)]
* progmodes/sql.el: Version 3.0
(sql-product-alist): Added product :completion-object,
:completion-column, and :statement attributes.
(sql-mode-menu, sql-interactive-mode-map): Fixed List entries.
(sql-mode-syntax-table): Mark all punctuation.
(sql-font-lock-keywords-builder): Temporarily removed fallback on
ansi keywords.
(sql-regexp-abbrev, sql-regexp-abbrev-list): New functions.
(sql-mode-oracle-font-lock-keywords): Improved.
(sql-oracle-show-reserved-words): New function for development.
(sql-product-font-lock): Simplify for source code buffers.
(sql-product-syntax-table, sql-product-font-lock-syntax-alist):
New functions.
(sql-highlight-product): Set product specific syntax table.
(sql-mode-map): Added statement movement functions.
(sql-ansi-statement-starters, sql-oracle-statement-starters): New
variable.
(sql-statement-regexp, sql-beginning-of-statement)
(sql-end-of-statement, sql-signum): New functions.
(sql-buffer-live-p, sql=find-sqli-buffer): Added CONNECTION
parameter.
(sql-show-sqli-buffer): Bug fix.
(sql-interactive-mode): Store connection data as buffer local.
(sql-connect): Added NEW-NAME parameter. Redesigned interaction
with sql-interactive-mode.
(sql-save-connection): Save buffer local settings.
(sql-connection-menu-filter): Changed menu entry name.
(sql-product-interactive): Bug fix.
(sql-preoutput-hold): New variable.
(sql-interactive-remove-continuation-prompt): Bug fixes.
(sql-debug-redirect): New variable.
(sql-str-literal): New function.
(sql-redirect, sql-redirect-one, sql-redirect-value, sql-execute):
Redesigned.
(sql-oracle-save-settings, sql-oracle-restore-settings)
(sql-oracle-list-all, sql-oracle-list-table): New functions.
(sql-completion-object, sql-completion-column)
(sql-completion-sqlbuf): New variables.
(sql-build-completions-1, sql-build-completions)
(sql-try-completion): New functions.
(sql-read-table-name): Use them.
(sql-contains-names): New buffer local variable.
(sql-list-all, sql-list-table): Use it.
(sql-oracle-completion-types): New variable.
(sql-oracle-completion-object, sql-sqlite-completion-object)
(sql-postgres-completion-object): New functions.
gnus.texi (Filtering New Groups): Clarify how simple the "options -n" format is.
(Agent Expiry): Remove mention of `gnus-request-expire-articles', which is internal.
gnus.texi (Expiring Mail): Document gnus-auto-expirable-marks.
nnir.el (nnir-notmuch-program, nnir-notmuch-additional-switches, nnir-notmuch-remove-prefix, nnir-engines, nnir-run-notmuch): New nnir `notmuch' backend.
mm-decode.el (mm-text-html-renderer): Doc fix.
gnus-msg.el (gnus-bug): Fix the MML tag.
pop3.el (pop3-open-server): -ERR is a valid response to CAPA.
gnus-start.el (gnus-get-unread-articles): Don't connect to the secondary methods if started with `gnus-no-server'.
gnus-group.el (gnus-read-ephemeral-bug-group): Allow fetching several bug reports at once.
Ken Manheimer [Tue, 5 Jul 2011 18:54:08 +0000 (14:54 -0400)]
* allout.el (allout-post-undo-hook): New allout outline-change event hook
to signal undo activity.
(allout-post-command-business): Run allout-post-undo-hook if an undo just
occurred.
(allout-after-copy-or-kill-hook), (allout-mode): Minor docstring changes.
* allout-widgets.el (allout-widgets-after-undo-function): Ensure the
integrity of the current item's decoration after it has been in the
vicinity of an undo.
(allout-widgets-mode): Include allout-widgets-after-undo-function on the
new allout-post-undo-hook.
Stefan Monnier [Tue, 5 Jul 2011 18:26:33 +0000 (14:26 -0400)]
* lisp/emacs-lisp/lisp-mode.el (lisp-interaction-mode-abbrev-table):
Let define-derived-mode define it.
* lisp/emacs-lisp/derived.el (define-derived-mode): Try to avoid creating
cycles of abbrev-table inheritance.
* emacs-lock.el (emacs-lock-mode): Fix typo in variable name.
Fix check of `emacs-lock-unlockable-modes'.
Coerce true values of `emacs-lock--try-unlocking' to t.
* src/xsettings.c: Use both GConf and GSettings if both are available.
(store_config_changed_event): Add comment.
(dpyinfo_valid, store_font_name_changed, map_tool_bar_style)
(store_tool_bar_style_changed): New functions.
(store_monospaced_changed): Add comment. Call dpyinfo_valid.
(struct xsettings): Move font inside HAVE_XFT.
(GSETTINGS_TOOL_BAR_STYLE, GSETTINGS_FONT_NAME): New defines.
(GSETTINGS_MONO_FONT): Renamed from SYSTEM_MONO_FONT.
Move inside HAVE_XFT.
(something_changed_gsettingsCB): Renamed from something_changedCB.
Check for changes in GSETTINGS_TOOL_BAR_STYLE and GSETTINGS_FONT_NAME
also.
(GCONF_TOOL_BAR_STYLE, GCONF_FONT_NAME): New defines.
(GCONF_MONO_FONT): Renamed from SYSTEM_MONO_FONT. Move inside HAVE_XFT.
(something_changed_gconfCB): Renamed from something_changedCB.
Check for changes in GCONF_TOOL_BAR_STYLE and GCONF_FONT_NAME also.
(parse_settings): Move check for font inside HAVE_XFT.
(read_settings, apply_xft_settings): Add comment.
(read_and_apply_settings): Add comment. Call map_tool_bar_style and
store_tool_bar_style_changed. Move check for font inside HAVE_XFT and
call store_font_name_changed.
(xft_settings_event): Add comment.
(init_gsettings): Add comment. Get values for GSETTINGS_TOOL_BAR_STYLE
and GSETTINGS_FONT_NAME. Move check for fonts within HAVE_XFT.
(init_gconf): Add comment. Get values for GCONF_TOOL_BAR_STYLE
and GCONF_FONT_NAME. Move check for fonts within HAVE_XFT.
(xsettings_initialize): Call init_gsettings last.
(xsettings_get_system_font, xsettings_get_system_normal_font): Add
comment.
Paul Eggert [Tue, 5 Jul 2011 05:27:49 +0000 (22:27 -0700)]
[ChangeLog]
Assume support for memcmp, memcpy, memmove, memset.
This simplifies the code a bit. All current platforms have these,
as they are required for C89. If this turns into a problem we
can add the gnulib modules for these (a 1-line change to Makefile.in).
* configure.in: Don't check for memcmp, memcpy, memmove, memset.
[lib-src/ChangeLog]
Assume support for memcmp, memcpy, memmove, memset.
* etags.c (absolute_filename): Assume memmove exists.
[src/ChangeLog]
Assume support for memcmp, memcpy, memmove, memset.
* lisp.h, sysdep.c (memcmp, memcpy, memmove, memset):
* regex.c (memcmp, memcpy):
Remove; we assume C89 now.
* gmalloc.c (memcpy, memset, memmove): Remove; we assume C89 now.
(__malloc_safe_bcopy): Remove; no longer needed.
Paul Eggert [Tue, 5 Jul 2011 02:51:15 +0000 (19:51 -0700)]
Random fixes. E.g., (random) never returned negative values.
* fns.c (Frandom): Use GET_EMACS_TIME for random seed, and add the
subseconds part to the entropy, as that's a bit more random.
Prefer signed to unsigned, since the signedness doesn't matter and
in general we prefer signed. When given a limit, use a
denominator equal to INTMASK + 1, not to VALMASK + 1, because the
latter isn't right if USE_2_TAGS_FOR_INTS.
* sysdep.c (get_random): Return a value in the range 0..INTMASK,
not 0..VALMASK. Don't discard "excess" bits that random () returns.
Ken Manheimer [Mon, 4 Jul 2011 22:16:10 +0000 (18:16 -0400)]
* allout.el (allout-encrypt-unencrypted-on-saves): Do not provide insecure
exception for current topic. Also note that auto-saves are handled
differently.
(allout-auto-save-temporarily-disabled), (allout-just-did-undo): State
variables for tracking auto-save inhibition situation.
(allout-write-contents-hook-handler): Rename from
'allout-write-file-hook-handler', and describe how it depends on
write-contents-functions sensitivity to non-nil value to prevent file
write.
(allout-auto-save-hook-handler): Remove. auto-save does not check this in
individual buffers, only in the starting buffer, so this is not the right
way for us to inhibit auto-save in a buffer according to its condition.
(allout-mode): Use new allout-write-contents-hook-handler, and only with
write-contents-functions. Remove auto-save provisions - they're
implemented elsewhere.
(allout-before-change-handler): If undo is in progress, note that for
attention of allout-post-command-business.
(allout-post-command-business): If the command we're following was an undo,
check for change in the status of encrypted items and adjust auto-save
inhibitions accordingly.
(allout-toggle-subtree-encryption): Adjust auto-save inhibition according
to whether there are or aren't any plain-text topics pending encryption.
(allout-inhibit-auto-save-info-for-decryption): Adjust buffer-saved-size
and some allout state to inhibit auto-saves if there are plain-text topics
pending encryption.
(allout-maybe-resume-auto-save-info-after-encryption): Adjust
buffer-saved-size and some allout state to not inhibit auto-saves if there
are no longer any plain-text topics pending encryption.
(allout-next-topic-pending-encryption), (allout-encrypt-decrypted): No
longer provide for exemption of the current topic.
Juri Linkov [Mon, 4 Jul 2011 22:11:40 +0000 (01:11 +0300)]
Add 7z operations to delete and save changed members.
* lisp/arc-mode.el (archive-7z-expunge, archive-7z-update):
New defcustoms.
(archive-7z-write-file-member): New function.
(archive-7z-summarize): Fix the number of dashes in the
listing output.
Michael Albinus [Mon, 4 Jul 2011 12:12:38 +0000 (14:12 +0200)]
* net/tramp-cmds.el (tramp-cleanup-this-connection): New command.
* net/tramp-sh.el (tramp-color-escape-sequence-regexp): New defconst.
(tramp-sh-handle-insert-directory, tramp-convert-file-attributes):
Use it.
(tramp-remote-path): Add "/bin" and "/usr/bin". On busyboxes,
`tramp-default-remote-path' does not exist.
(tramp-send-command-and-read): New optional argument NOERROR.
(tramp-open-connection-setup-interactive-shell)
(tramp-get-remote-path, tramp-get-remote-stat): Use it.
(tramp-get-remote-readlink): Do not mask with `ignore-errors'.
(tramp-process-sentinel): Flush also process' connection property.
(tramp-sh-handle-start-file-process): Do not set process
sentinel. It is done now ...
(tramp-maybe-open-connection): ... here. (Bug#8929)
Paul Eggert [Mon, 4 Jul 2011 06:31:40 +0000 (23:31 -0700)]
Merge: timer.el: Use time-date fns rather than rolling our own.
This is simpler and helps future-proof the code.
* emacs-lisp/timer.el (timer-until): Use time-subtract and float-time.
(timer--time-less-p): Use time-less-p.
src/gnutls.c: Remove bogus references to :verify-error.
* gnutls.c (Fgnutls_boot): Don't mention :verify-error.
(syms_of_gnutls): Remove duplicate DEFSYM for
Qgnutls_bootprop_verify_hostname_error, an error for
Qgnutls_bootprop_verify_error (which is no longer used).
* eval.c (find_handler_clause): Remove parameters `sig' and `data',
unused since 2011-01-26T20:02:07Z!monnier@iro.umontreal.ca. All callers changed.
Also (re)move comments that are misplaced or no longer relevant.
nndraft.el (nndraft-update-unread-articles): New function.
(nndraft-request-associate-buffer): Use it to update the number of unread articles for the nndraft groups in the group buffer when saving or killing a draft message.
Bill Wohler [Mon, 4 Jul 2011 00:35:48 +0000 (17:35 -0700)]
* mh-compat.el (mh-window-full-height-p): Add compatibility function
for XEmacs.
* mh-show.el (mh-show-msg): Use it, and avoid compiler warning on
XEmacs.