Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 103887. ------------------------------------------------------------ revno: 103887 committer: Leo Liu branch nick: trunk timestamp: Mon 2011-04-11 11:44:54 +0800 message: Enable ido to kill virtual buffers diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-10 21:31:14 +0000 +++ lisp/ChangeLog 2011-04-11 03:44:54 +0000 @@ -1,3 +1,9 @@ +2011-04-11 Leo Liu + + * ido.el (ido-buffer-internal): Allow method 'kill for virtual + buffers. + (ido-kill-buffer-at-head): Support killing virtual buffers. + 2011-04-10 Chong Yidong * minibuffer.el (completion-show-inline-help): New var. === modified file 'lisp/ido.el' --- lisp/ido.el 2011-03-29 08:25:31 +0000 +++ lisp/ido.el 2011-04-11 03:44:54 +0000 @@ -2176,9 +2176,7 @@ (ido-current-directory nil) (ido-directory-nonreadable nil) (ido-directory-too-big nil) - (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing - ido-use-virtual-buffers)) + (ido-use-virtual-buffers ido-use-virtual-buffers) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -3917,10 +3915,10 @@ (let ((enable-recursive-minibuffers t) (buf (ido-name (car ido-matches))) (nextbuf (cadr ido-matches))) - (when (get-buffer buf) + (cond + ((get-buffer buf) ;; If next match names a buffer use the buffer object; buffer - ;; name may be changed by packages such as uniquify; mindful - ;; of virtual buffers. + ;; name may be changed by packages such as uniquify. (when (and nextbuf (get-buffer nextbuf)) (setq nextbuf (get-buffer nextbuf))) (if (null (kill-buffer buf)) @@ -3934,7 +3932,13 @@ (setq ido-default-item nextbuf ido-text-init ido-text ido-exit 'refresh) - (exit-minibuffer)))))) + (exit-minibuffer))) + ;; Handle virtual buffers + ((assoc buf ido-virtual-buffers) + (setq recentf-list + (delete (cdr (assoc buf ido-virtual-buffers)) recentf-list)) + (setq ido-cur-list (delete buf ido-cur-list)) + (setq ido-rescan t)))))) ;;; DELETE CURRENT FILE (defun ido-delete-file-at-head () ------------------------------------------------------------ revno: 103886 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2011-04-10 22:18:19 -0300 message: * lisp/gnus/registry.el: Require CL before using defmacro*. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-04-11 00:28:41 +0000 +++ lisp/gnus/ChangeLog 2011-04-11 01:18:19 +0000 @@ -1,3 +1,7 @@ +2011-04-11 Stefan Monnier + + * registry.el: Require CL before using defmacro*. + 2011-04-11 Katsumi Yamaoka * gnus-art.el (article-treat-date): Assume that === modified file 'lisp/gnus/registry.el' --- lisp/gnus/registry.el 2011-04-07 22:48:21 +0000 +++ lisp/gnus/registry.el 2011-04-11 01:18:19 +0000 @@ -77,14 +77,14 @@ ;;; Code: +(eval-when-compile (require 'cl)) + (eval-when-compile (when (null (ignore-errors (require 'ert))) (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) (ignore-errors (require 'ert)) - -(eval-when-compile (require 'cl)) (eval-and-compile (or (ignore-errors (progn (require 'eieio) ------------------------------------------------------------ revno: 103885 committer: Katsumi Yamaoka branch nick: trunk timestamp: Mon 2011-04-11 00:28:41 +0000 message: gnus-art.el (article-treat-date): Assume that gnus-article-date-headers may be a group parameter. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-04-07 23:59:27 +0000 +++ lisp/gnus/ChangeLog 2011-04-11 00:28:41 +0000 @@ -1,3 +1,8 @@ +2011-04-11 Katsumi Yamaoka + + * gnus-art.el (article-treat-date): Assume that + gnus-article-date-headers may be a group parameter. + 2011-04-07 Teodor Zlatanov * gnus-registry.el (gnus-registry-handle-action): More debugging. === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2011-03-22 13:40:41 +0000 +++ lisp/gnus/gnus-art.el 2011-04-11 00:28:41 +0000 @@ -3407,7 +3407,11 @@ (setq ended t))))) (defun article-treat-date () - (article-date-ut gnus-article-date-headers t)) + (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer) + (with-current-buffer gnus-summary-buffer + gnus-article-date-headers) + gnus-article-date-headers) + t)) (defun article-date-ut (&optional type highlight date-position) "Convert DATE date to TYPE in the current article. ------------------------------------------------------------ revno: 103884 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-04-10 17:31:14 -0400 message: Fix bad interaction between icomplete and completion inline help (Bug#5849). * lisp/minibuffer.el (completion-show-inline-help): New var. (completion--do-completion, minibuffer-complete) (minibuffer-force-complete, minibuffer-complete-word): Inhibit minibuffer messages if completion-show-inline-help is nil. * lisp/icomplete.el (icomplete-mode): Bind completion-show-inline-help to avoid interference from inline help. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-10 16:33:22 +0000 +++ lisp/ChangeLog 2011-04-10 21:31:14 +0000 @@ -1,3 +1,13 @@ +2011-04-10 Chong Yidong + + * minibuffer.el (completion-show-inline-help): New var. + (completion--do-completion, minibuffer-complete) + (minibuffer-force-complete, minibuffer-complete-word): Inhibit + minibuffer messages if completion-show-inline-help is nil. + + * icomplete.el (icomplete-mode): Bind completion-show-inline-help + to avoid interference from inline help (Bug#5849). + 2011-04-10 Leo Liu * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Fix === modified file 'lisp/icomplete.el' --- lisp/icomplete.el 2011-01-26 08:36:39 +0000 +++ lisp/icomplete.el 2011-04-10 21:31:14 +0000 @@ -179,8 +179,11 @@ (if icomplete-mode ;; The following is not really necessary after first time - ;; no great loss. - (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup) - (remove-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup))) + (progn + (setq completion-show-inline-help nil) + (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup)) + (remove-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup) + (setq completion-show-inline-help t))) ;;;_ > icomplete-simple-completing-p () (defun icomplete-simple-completing-p () === modified file 'lisp/minibuffer.el' --- lisp/minibuffer.el 2011-04-05 21:19:42 +0000 +++ lisp/minibuffer.el 2011-04-10 21:31:14 +0000 @@ -381,6 +381,9 @@ ;; is on, the field doesn't cover the entire minibuffer contents. (delete-region (minibuffer-prompt-end) (point-max))) +(defvar completion-show-inline-help t + "If non-nil, print helpful inline messages during completion.") + (defcustom completion-auto-help t "Non-nil means automatically provide help for invalid completion input. If the value is t the *Completion* buffer is displayed whenever completion @@ -568,8 +571,9 @@ (cond ((null comp) (minibuffer-hide-completions) - (unless completion-fail-discreetly - (ding) (minibuffer-message "No match")) + (when (and (not completion-fail-discreetly) completion-show-inline-help) + (ding) + (minibuffer-message "No match")) (minibuffer--bitset nil nil nil)) ((eq t comp) (minibuffer-hide-completions) @@ -639,9 +643,10 @@ (minibuffer-hide-completions)) ;; Show the completion table, if requested. ((not exact) - (if (case completion-auto-help - (lazy (eq this-command last-command)) - (t completion-auto-help)) + (if (cond ((null completion-show-inline-help) t) + ((eq completion-auto-help 'lazy) + (eq this-command last-command)) + (t completion-auto-help)) (minibuffer-completion-help) (minibuffer-message "Next char not unique"))) ;; If the last exact completion and this one were the same, it @@ -683,9 +688,11 @@ t) (t (case (completion--do-completion) (#b000 nil) - (#b001 (minibuffer-message "Sole completion") + (#b001 (if completion-show-inline-help + (minibuffer-message "Sole completion")) t) - (#b011 (minibuffer-message "Complete, but not unique") + (#b011 (if completion-show-inline-help + (minibuffer-message "Complete, but not unique")) t) (t t))))) @@ -743,7 +750,9 @@ (end (field-end)) (all (completion-all-sorted-completions))) (if (not (consp all)) - (minibuffer-message (if all "No more completions" "No completions")) + (if completion-show-inline-help + (minibuffer-message + (if all "No more completions" "No completions"))) (setq completion-cycling t) (goto-char end) (insert (car all)) @@ -931,9 +940,11 @@ (interactive) (case (completion--do-completion 'completion--try-word-completion) (#b000 nil) - (#b001 (minibuffer-message "Sole completion") + (#b001 (if completion-show-inline-help + (minibuffer-message "Sole completion")) t) - (#b011 (minibuffer-message "Complete, but not unique") + (#b011 (if completion-show-inline-help + (minibuffer-message "Complete, but not unique")) t) (t t))) ------------------------------------------------------------ revno: 103883 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-10 23:43:08 +0300 message: Fix write-region and its subroutines for buffers > 2GB. src/fileio.c (a_write, e_write): Modify declaration of arguments and local variables to support buffers larger than 2GB. (Fcopy_file): Use EMACS_INT for return value of emacs_read. src/sysdep.c (emacs_write, emacs_read): Use ssize_t for last argument, local variables, and return value. src/lisp.h: Update prototypes of emacs_write and emacs_read. src/sound.c (vox_write): Use ssize_t for return value of emacs_write. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-10 19:47:49 +0000 +++ src/ChangeLog 2011-04-10 20:43:08 +0000 @@ -1,3 +1,17 @@ +2011-04-10 Eli Zaretskii + + Fix write-region and its subroutines for buffers > 2GB. + * fileio.c (a_write, e_write): Modify declaration of arguments and + local variables to support buffers larger than 2GB. + (Fcopy_file): Use EMACS_INT for return value of emacs_read. + + * sysdep.c (emacs_write, emacs_read): Use ssize_t for last + argument, local variables, and return value. + + * lisp.h: Update prototypes of emacs_write and emacs_read. + + * sound.c (vox_write): Use ssize_t for return value of emacs_write. + 2011-04-10 Paul Eggert * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. === modified file 'src/fileio.c' --- src/fileio.c 2011-04-09 16:35:19 +0000 +++ src/fileio.c 2011-04-10 20:43:08 +0000 @@ -143,9 +143,10 @@ Lisp_Object Qcar_less_than_car; -static int a_write (int, Lisp_Object, int, int, +static int a_write (int, Lisp_Object, EMACS_INT, EMACS_INT, Lisp_Object *, struct coding_system *); -static int e_write (int, Lisp_Object, int, int, struct coding_system *); +static int e_write (int, Lisp_Object, EMACS_INT, EMACS_INT, + struct coding_system *); void @@ -1805,7 +1806,8 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists, Lisp_Object keep_time, Lisp_Object preserve_uid_gid, Lisp_Object preserve_selinux_context) { - int ifd, ofd, n; + int ifd, ofd; + EMACS_INT n; char buf[16 * 1024]; struct stat st, out_st; Lisp_Object handler; @@ -4792,11 +4794,13 @@ The return value is negative in case of system call failure. */ static int -a_write (int desc, Lisp_Object string, int pos, register int nchars, Lisp_Object *annot, struct coding_system *coding) +a_write (int desc, Lisp_Object string, EMACS_INT pos, + register EMACS_INT nchars, Lisp_Object *annot, + struct coding_system *coding) { Lisp_Object tem; - int nextpos; - int lastpos = pos + nchars; + EMACS_INT nextpos; + EMACS_INT lastpos = pos + nchars; while (NILP (*annot) || CONSP (*annot)) { @@ -4836,7 +4840,8 @@ are indexes to the string STRING. */ static int -e_write (int desc, Lisp_Object string, int start, int end, struct coding_system *coding) +e_write (int desc, Lisp_Object string, EMACS_INT start, EMACS_INT end, + struct coding_system *coding) { if (STRINGP (string)) { @@ -4867,8 +4872,8 @@ } else { - int start_byte = CHAR_TO_BYTE (start); - int end_byte = CHAR_TO_BYTE (end); + EMACS_INT start_byte = CHAR_TO_BYTE (start); + EMACS_INT end_byte = CHAR_TO_BYTE (end); coding->src_multibyte = (end - start) < (end_byte - start_byte); if (CODING_REQUIRE_ENCODING (coding)) === modified file 'src/lisp.h' --- src/lisp.h 2011-04-09 18:42:31 +0000 +++ src/lisp.h 2011-04-10 20:43:08 +0000 @@ -3346,8 +3346,8 @@ extern void seed_random (long); extern int emacs_open (const char *, int, int); extern int emacs_close (int); -extern int emacs_read (int, char *, unsigned int); -extern int emacs_write (int, const char *, unsigned int); +extern ssize_t emacs_read (int, char *, ssize_t); +extern ssize_t emacs_write (int, const char *, ssize_t); enum { READLINK_BUFSIZE = 1024 }; extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]); #ifndef HAVE_MEMSET === modified file 'src/sound.c' --- src/sound.c 2011-04-05 20:08:03 +0000 +++ src/sound.c 2011-04-10 20:43:08 +0000 @@ -897,7 +897,7 @@ static void vox_write (struct sound_device *sd, const char *buffer, int nbytes) { - int nwritten = emacs_write (sd->fd, buffer, nbytes); + ssize_t nwritten = emacs_write (sd->fd, buffer, nbytes); if (nwritten < 0) sound_perror ("Error writing to sound device"); } === modified file 'src/sysdep.c' --- src/sysdep.c 2011-04-07 03:34:05 +0000 +++ src/sysdep.c 2011-04-10 20:43:08 +0000 @@ -1825,10 +1825,10 @@ return rtnval; } -int -emacs_read (int fildes, char *buf, unsigned int nbyte) +ssize_t +emacs_read (int fildes, char *buf, ssize_t nbyte) { - register int rtnval; + register ssize_t rtnval; while ((rtnval = read (fildes, buf, nbyte)) == -1 && (errno == EINTR)) @@ -1836,10 +1836,10 @@ return (rtnval); } -int -emacs_write (int fildes, const char *buf, unsigned int nbyte) +ssize_t +emacs_write (int fildes, const char *buf, ssize_t nbyte) { - register int rtnval, bytes_written; + register ssize_t rtnval, bytes_written; bytes_written = 0; ------------------------------------------------------------ revno: 103882 committer: Paul Eggert branch nick: trunk timestamp: Sun 2011-04-10 12:47:49 -0700 message: * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-10 19:12:28 +0000 +++ src/ChangeLog 2011-04-10 19:47:49 +0000 @@ -1,5 +1,7 @@ 2011-04-10 Paul Eggert + * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. + Fix more problems found by GCC 4.6.0's static checks. * xdisp.c (vmessage): Use a better test for character truncation. === modified file 'src/xdisp.c' --- src/xdisp.c 2011-04-10 02:27:15 +0000 +++ src/xdisp.c 2011-04-10 19:47:49 +0000 @@ -8417,10 +8417,13 @@ /* Do any truncation at a character boundary. */ if (! (0 <= len && len < bufsize)) - for (len = strnlen (buf, bufsize); - len && ! CHAR_HEAD_P (buf[len - 1]); - len--) - continue; + { + char *end = memchr (buf, 0, bufsize); + for (len = end ? end - buf : bufsize; + len && ! CHAR_HEAD_P (buf[len - 1]); + len--) + continue; + } message2 (FRAME_MESSAGE_BUF (f), len, 0); } ------------------------------------------------------------ revno: 103881 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-10 22:12:28 +0300 message: src/ChangeLog: Fix address in eliz's last entry. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-10 16:44:27 +0000 +++ src/ChangeLog 2011-04-10 19:12:28 +0000 @@ -105,7 +105,7 @@ * xselect.c (x_decline_selection_request) (x_reply_selection_request): Avoid type-punned deref of X events. -2011-04-09 Eli Zaretskii +2011-04-09 Eli Zaretskii Fix some uses of `int' instead of EMACS_INT. * search.c (string_match_1, fast_string_match) ------------------------------------------------------------ revno: 103880 [merge] committer: Paul Eggert branch nick: trunk timestamp: Sun 2011-04-10 09:44:27 -0700 message: Fix more problems found by GCC 4.6.0's static checks. diff: === modified file 'ChangeLog' --- ChangeLog 2011-04-07 03:22:10 +0000 +++ ChangeLog 2011-04-09 18:42:31 +0000 @@ -1,3 +1,7 @@ +2011-04-09 Paul Eggert + + * lib/allocator.c: New file, automatically generated by gnulib. + 2011-04-07 Glenn Morris * autogen/update_autogen: Ignore comment diffs in ldefs-boot.el. === added file 'lib/allocator.c' --- lib/allocator.c 1970-01-01 00:00:00 +0000 +++ lib/allocator.c 2011-04-08 21:53:30 +0000 @@ -0,0 +1,5 @@ +#define _GL_USE_STDLIB_ALLOC 1 +#include +#include "allocator.h" +#include +struct allocator const stdlib_allocator = { malloc, realloc, free, NULL }; === modified file 'lib/allocator.h' --- lib/allocator.h 2011-04-05 18:19:19 +0000 +++ lib/allocator.h 2011-04-09 18:44:05 +0000 @@ -18,6 +18,7 @@ /* Written by Paul Eggert. */ #ifndef _GL_ALLOCATOR_H +#define _GL_ALLOCATOR_H #include @@ -30,16 +31,16 @@ attributes do not work with pointers to functions. See . */ - /* Call MALLOC to allocate memory, like 'malloc'. On failure MALLOC + /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE should return NULL, though not necessarily set errno. When given a zero size it may return NULL even if successful. */ - void *(*malloc) (size_t); + void *(*allocate) (size_t); - /* If nonnull, call REALLOC to reallocate memory, like 'realloc'. - On failure REALLOC should return NULL, though not necessarily set + /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'. + On failure REALLOCATE should return NULL, though not necessarily set errno. When given a zero size it may return NULL even if successful. */ - void *(*realloc) (void *, size_t); + void *(*reallocate) (void *, size_t); /* Call FREE to free memory, like 'free'. */ void (*free) (void *); @@ -50,4 +51,7 @@ void (*die) (void); }; -#endif +/* An allocator using the stdlib functions and a null DIE function. */ +extern struct allocator const stdlib_allocator; + +#endif /* _GL_ALLOCATOR_H */ === modified file 'lib/careadlinkat.c' --- lib/careadlinkat.c 2011-04-05 18:19:19 +0000 +++ lib/careadlinkat.c 2011-04-10 16:00:46 +0000 @@ -22,19 +22,12 @@ #include "careadlinkat.h" -#include "allocator.h" - #include #include #include #include #include -/* Use the system functions, not the gnulib overrides, because this - module does not depend on GNU or POSIX semantics. */ -#undef malloc -#undef realloc - /* Define this independently so that stdint.h is not a prerequisite. */ #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) @@ -44,24 +37,24 @@ # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif +#include "allocator.h" + #if ! HAVE_READLINKAT -/* Ignore FD. Get the symbolic link value of FILENAME and put it into - BUFFER, with size BUFFER_SIZE. This function acts like readlink - but has readlinkat's signature. */ +/* Get the symbolic link value of FILENAME and put it into BUFFER, with + size BUFFER_SIZE. This function acts like readlink but has + readlinkat's signature. */ ssize_t careadlinkatcwd (int fd, char const *filename, char *buffer, size_t buffer_size) { - (void) fd; + /* FD must be AT_FDCWD here, otherwise the caller is using this + function in contexts for which it was not meant for. */ + if (fd != AT_FDCWD) + abort (); return readlink (filename, buffer, buffer_size); } #endif -/* A standard allocator. For now, only careadlinkat needs this, but - perhaps it should be moved to the allocator module. */ -static struct allocator const standard_allocator = - { malloc, realloc, free, NULL }; - /* Assuming the current directory is FD, get the symbolic link value of FILENAME as a null-terminated string and put it into a buffer. If FD is AT_FDCWD, FILENAME is interpreted relative to the current @@ -76,7 +69,10 @@ the returned value if it is nonnull and is not BUFFER. A null ALLOC stands for the standard allocator. - The PREADLINKAT function specifies how to read links. + The PREADLINKAT function specifies how to read links. It operates + like POSIX readlinkat() + + but can assume that its first argument is the same as FD. If successful, return the buffer address; otherwise return NULL and set errno. */ @@ -94,7 +90,7 @@ char stack_buf[1024]; if (! alloc) - alloc = &standard_allocator; + alloc = &stdlib_allocator; if (! buffer_size) { @@ -138,16 +134,16 @@ if (buf == stack_buf) { - char *b = (char *) alloc->malloc (link_size); + char *b = (char *) alloc->allocate (link_size); if (! b) break; memcpy (b, buf, link_size); buf = b; } - else if (link_size < buf_size && buf != buffer && alloc->realloc) + else if (link_size < buf_size && buf != buffer && alloc->reallocate) { /* Shrink BUF before returning it. */ - char *b = (char *) alloc->realloc (buf, link_size); + char *b = (char *) alloc->reallocate (buf, link_size); if (b) buf = b; } @@ -164,7 +160,7 @@ buf_size = buf_size_max; else break; - buf = (char *) alloc->malloc (buf_size); + buf = (char *) alloc->allocate (buf_size); } while (buf); === modified file 'lib/careadlinkat.h' --- lib/careadlinkat.h 2011-04-01 06:28:48 +0000 +++ lib/careadlinkat.h 2011-04-09 18:44:05 +0000 @@ -18,6 +18,7 @@ /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ #ifndef _GL_CAREADLINKAT_H +#define _GL_CAREADLINKAT_H #include #include @@ -37,7 +38,10 @@ buffer managed by ALLOC. It is the caller's responsibility to free the returned value if it is nonnull and is not BUFFER. - The PREADLINKAT function specifies how to read links. + The PREADLINKAT function specifies how to read links. It operates + like POSIX readlinkat() + + but can assume that its first argument is the same as FD. If successful, return the buffer address; otherwise return NULL and set errno. */ @@ -49,8 +53,10 @@ char *, size_t)); /* Suitable values for careadlinkat's FD and PREADLINKAT arguments, - when doing a plain readlink. */ + when doing a plain readlink: + Pass FD = AT_FDCWD and PREADLINKAT = careadlinkatcwd. */ #if HAVE_READLINKAT +/* AT_FDCWD is declared in , readlinkat in . */ # define careadlinkatcwd readlinkat #else /* Define AT_FDCWD independently, so that the careadlinkat module does === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-04-06 07:04:00 +0000 +++ lib/gnulib.mk 2011-04-08 21:53:30 +0000 @@ -21,6 +21,14 @@ libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) EXTRA_libgnu_a_SOURCES = +## begin gnulib module allocator + +libgnu_a_SOURCES += allocator.c + +EXTRA_DIST += allocator.h + +## end gnulib module allocator + ## begin gnulib module arg-nonnull # The BUILT_SOURCES created by this Makefile snippet are not used via #include @@ -73,7 +81,7 @@ libgnu_a_SOURCES += careadlinkat.c -EXTRA_DIST += allocator.h careadlinkat.h +EXTRA_DIST += careadlinkat.h ## end gnulib module careadlinkat === modified file 'lib/stdlib.in.h' --- lib/stdlib.in.h 2011-02-25 07:36:37 +0000 +++ lib/stdlib.in.h 2011-04-08 21:53:30 +0000 @@ -255,9 +255,14 @@ # endif #endif +/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not + rely on GNU or POSIX semantics for malloc and realloc (for example, + by never specifying a zero size), so it does not need malloc or + realloc to be redefined. */ #if @GNULIB_MALLOC_POSIX@ # if @REPLACE_MALLOC@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ + || _GL_USE_STDLIB_ALLOC) # undef malloc # define malloc rpl_malloc # endif @@ -267,7 +272,7 @@ _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); # endif _GL_CXXALIASWARN (malloc); -#elif defined GNULIB_POSIXCHECK +#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef malloc /* Assume malloc is always declared. */ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " @@ -531,7 +536,8 @@ #if @GNULIB_REALLOC_POSIX@ # if @REPLACE_REALLOC@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ + || _GL_USE_STDLIB_ALLOC) # undef realloc # define realloc rpl_realloc # endif @@ -541,7 +547,7 @@ _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); # endif _GL_CXXALIASWARN (realloc); -#elif defined GNULIB_POSIXCHECK +#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef realloc /* Assume realloc is always declared. */ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " === modified file 'm4/gl-comp.m4' --- m4/gl-comp.m4 2011-04-01 06:28:48 +0000 +++ m4/gl-comp.m4 2011-04-08 21:53:30 +0000 @@ -26,6 +26,7 @@ m4_pattern_allow([^gl_LIBOBJS$])dnl a variable m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable AC_REQUIRE([AC_PROG_RANLIB]) + # Code from module allocator: # Code from module arg-nonnull: # Code from module c++defs: # Code from module careadlinkat: @@ -79,6 +80,7 @@ m4_pushdef([gl_LIBSOURCES_DIR], []) gl_COMMON gl_source_base='lib' + # Code from module allocator: # Code from module arg-nonnull: # Code from module c++defs: # Code from module careadlinkat: @@ -293,6 +295,7 @@ build-aux/arg-nonnull.h build-aux/c++defs.h build-aux/warn-on-use.h + lib/allocator.c lib/allocator.h lib/careadlinkat.c lib/careadlinkat.h === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-10 14:00:13 +0000 +++ src/ChangeLog 2011-04-10 16:44:27 +0000 @@ -1,3 +1,86 @@ +2011-04-10 Paul Eggert + + Fix more problems found by GCC 4.6.0's static checks. + + * xdisp.c (vmessage): Use a better test for character truncation. + + * charset.c (load_charset_map): <, not <=, for optimization, + and to avoid potential problems with integer overflow. + * chartab.c (sub_char_table_set_range, char_table_set_range): Likewise. + * casetab.c (set_identity, shuffle): Likewise. + * editfns.c (Fformat): Likewise. + * syntax.c (skip_chars): Likewise. + + * xmenu.c (set_frame_menubar): Allocate smaller local vectors. + This also lets GCC 4.6.0 generate slightly better loop code. + + * callint.c (Fcall_interactively): <, not <=, for optimization. + (Fcall_interactively): Count the number of arguments produced, + not the number of arguments given. This is simpler and lets GCC + 4.6.0 generate slightly better code. + + * ftfont.c: Distingish more carefully between FcChar8 and char. + The previous code passed unsigned char * to a functions like + strlen and xstrcasecmp that expect char *, which does not + conform to the C standard. + (get_adstyle_property, ftfont_pattern_entity): Use FcChar8 for + arguments to FcPatternGetString, and explicitly cast FcChar8 * to + char * when the C standard requires it. + + * keyboard.c (read_char): Remove unused var. + + * eval.c: Port to Windows vsnprintf (Bug#8435). + Include . + (SIZE_MAX): Define if the headers do not. + (verror): Do not give up if vsnprintf returns a negative count. + Instead, grow the buffer. This ports to Windows vsnprintf, which + does not conform to C99. Problem reported by Eli Zaretskii. + Also, simplify the allocation scheme, by avoiding the need for + calling realloc, and removing the ALLOCATED variable. + + * eval.c (verror): Initial buffer size is 4000 (not 200) bytes. + + Remove invocations of doprnt, as Emacs now uses vsnprintf. + But keep the doprint source code for now, as we might revamp it + and use it again (Bug#8435). + * lisp.h (doprnt): Remove. + * Makefile.in (base_obj): Remove doprnt.o. + * deps.mk (doprnt.o): Remove. + + error: Print 32- and 64-bit integers portably (Bug#8435). + Without this change, on typical 64-bit hosts error ("...%d...", N) + was used to print both 32- and 64-bit integers N, which relied on + undefined behavior. + * lisp.h, src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h (pEd): + New macro. + * lisp.h (error, verror): Mark as printf-like functions. + * eval.c (verror): Use vsnprintf, not doprnt, to do the real work. + Report overflow in size calculations when allocating printf buffer. + Do not truncate output string at its first null byte. + * xdisp.c (vmessage): Use vsnprintf, not doprnt, to do the real work. + Truncate the output at a character boundary, since vsnprintf does not + do that. + * charset.c (check_iso_charset_parameter): Convert internal + character to string before calling 'error', since %c now has the + printf meaning. + * coding.c (Fdecode_sjis_char, Fdecode_big5_char): Avoid int + overflow when computing char to be passed to 'error'. Do not + pass Lisp_Object to 'error'; pass the integer instead. + * nsfns.m (Fns_do_applescript): Use int, not long, since it's + formatted with plain %d. + + * eval.c (internal_lisp_condition_case): Don't pass spurious arg. + + * keyboard.c (access_keymap_keyremap): Print func name, not garbage. + + * coding.c (Fdecode_sjis_char): Don't assume CODE fits in int. + + * xterm.c (x_catch_errors): Remove duplicate declaration. + + * term.c (maybe_fatal): Mark its 3rd arg as a printf format, too. + + * xdisp.c, lisp.h (message_nolog): Remove; unused. + 2011-04-10 Jim Meyering use ssize_t and size_t for read- and write-like emacs_gnutls_* functions === modified file 'src/Makefile.in' --- src/Makefile.in 2011-02-20 10:53:22 +0000 +++ src/Makefile.in 2011-04-07 03:49:25 +0000 @@ -354,7 +354,7 @@ syntax.o $(UNEXEC_OBJ) bytecode.o \ process.o gnutls.o callproc.o \ region-cache.o sound.o atimer.o \ - doprnt.o intervals.o textprop.o composite.o xml.o \ + intervals.o textprop.o composite.o xml.o \ $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) obj = $(base_obj) $(NS_OBJC_OBJ) === modified file 'src/callint.c' --- src/callint.c 2011-04-01 15:16:50 +0000 +++ src/callint.c 2011-04-09 20:19:05 +0000 @@ -269,8 +269,8 @@ recorded as a call to the function named callint_argfuns[varies[i]]. */ int *varies; - register size_t i, j; - size_t count; + register size_t i; + size_t nargs; int foo; char prompt1[100]; char *tem1; @@ -445,30 +445,29 @@ else break; } - /* Count the number of arguments the interactive spec would have - us give to the function. */ + /* Count the number of arguments, which is one plus the number of arguments + the interactive spec would have us give to the function. */ tem = string; - for (j = 0; *tem;) + for (nargs = 1; *tem; ) { /* 'r' specifications ("point and mark as 2 numeric args") produce *two* arguments. */ if (*tem == 'r') - j += 2; + nargs += 2; else - j++; + nargs++; tem = strchr (tem, '\n'); if (tem) ++tem; else break; } - count = j; - - args = (Lisp_Object *) alloca ((count + 1) * sizeof (Lisp_Object)); - visargs = (Lisp_Object *) alloca ((count + 1) * sizeof (Lisp_Object)); - varies = (int *) alloca ((count + 1) * sizeof (int)); - - for (i = 0; i < (count + 1); i++) + + args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); + visargs = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); + varies = (int *) alloca (nargs * sizeof (int)); + + for (i = 0; i < nargs; i++) { args[i] = Qnil; visargs[i] = Qnil; @@ -476,8 +475,8 @@ } GCPRO5 (prefix_arg, function, *args, *visargs, up_event); - gcpro3.nvars = (count + 1); - gcpro4.nvars = (count + 1); + gcpro3.nvars = nargs; + gcpro4.nvars = nargs; if (!NILP (enable)) specbind (Qenable_recursive_minibuffers, Qt); @@ -809,14 +808,14 @@ if (arg_from_tty || !NILP (record_flag)) { visargs[0] = function; - for (i = 1; i < count + 1; i++) + for (i = 1; i < nargs; i++) { if (varies[i] > 0) visargs[i] = Fcons (intern (callint_argfuns[varies[i]]), Qnil); else visargs[i] = quotify_arg (args[i]); } - Vcommand_history = Fcons (Flist (count + 1, visargs), + Vcommand_history = Fcons (Flist (nargs, visargs), Vcommand_history); /* Don't keep command history around forever. */ if (INTEGERP (Vhistory_length) && XINT (Vhistory_length) > 0) @@ -829,7 +828,7 @@ /* If we used a marker to hold point, mark, or an end of the region, temporarily, convert it to an integer now. */ - for (i = 1; i <= count; i++) + for (i = 1; i < nargs; i++) if (varies[i] >= 1 && varies[i] <= 4) XSETINT (args[i], marker_position (args[i])); @@ -846,7 +845,7 @@ specbind (Qcommand_debug_status, Qnil); temporarily_switch_to_single_kboard (NULL); - val = Ffuncall (count + 1, args); + val = Ffuncall (nargs, args); UNGCPRO; return unbind_to (speccount, val); } === modified file 'src/casetab.c' --- src/casetab.c 2011-03-15 07:04:00 +0000 +++ src/casetab.c 2011-04-09 22:31:34 +0000 @@ -191,7 +191,8 @@ { if (NATNUMP (elt)) { - int from, to; + int from; + unsigned to; if (CONSP (c)) { @@ -200,7 +201,7 @@ } else from = to = XINT (c); - for (; from <= to; from++) + for (to++; from < to; from++) CHAR_TABLE_SET (table, from, make_number (from)); } } @@ -215,7 +216,8 @@ { if (NATNUMP (elt)) { - int from, to; + int from; + unsigned to; if (CONSP (c)) { @@ -225,7 +227,7 @@ else from = to = XINT (c); - for (; from <= to; from++) + for (to++; from < to; from++) { Lisp_Object tem = Faref (table, elt); Faset (table, elt, make_number (from)); === modified file 'src/category.c' --- src/category.c 2011-03-08 07:39:53 +0000 +++ src/category.c 2011-04-07 03:34:05 +0000 @@ -128,7 +128,7 @@ table = check_category_table (table); if (!NILP (CATEGORY_DOCSTRING (table, XFASTINT (category)))) - error ("Category `%c' is already defined", XFASTINT (category)); + error ("Category `%c' is already defined", (int) XFASTINT (category)); if (!NILP (Vpurify_flag)) docstring = Fpurecopy (docstring); CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring; @@ -373,7 +373,7 @@ table = check_category_table (table); if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category)))) - error ("Undefined category: %c", XFASTINT (category)); + error ("Undefined category: %c", (int) XFASTINT (category)); set_value = NILP (reset) ? Qt : Qnil; === modified file 'src/charset.c' --- src/charset.c 2011-03-27 02:12:36 +0000 +++ src/charset.c 2011-04-09 20:46:34 +0000 @@ -317,7 +317,7 @@ for (i = 0; i < n_entries; i++) { unsigned from, to; - int from_index, to_index; + int from_index, to_index, lim_index; int from_c, to_c; int idx = i % 0x10000; @@ -339,6 +339,7 @@ } if (from_index < 0 || to_index < 0) continue; + lim_index = to_index + 1; if (to_c > max_char) max_char = to_c; @@ -348,10 +349,10 @@ if (control_flag == 1) { if (charset->method == CHARSET_METHOD_MAP) - for (; from_index <= to_index; from_index++, from_c++) + for (; from_index < lim_index; from_index++, from_c++) ASET (vec, from_index, make_number (from_c)); else - for (; from_index <= to_index; from_index++, from_c++) + for (; from_index < lim_index; from_index++, from_c++) CHAR_TABLE_SET (Vchar_unify_table, CHARSET_CODE_OFFSET (charset) + from_index, make_number (from_c)); @@ -360,7 +361,7 @@ { if (charset->method == CHARSET_METHOD_MAP && CHARSET_COMPACT_CODES_P (charset)) - for (; from_index <= to_index; from_index++, from_c++) + for (; from_index < lim_index; from_index++, from_c++) { unsigned code = INDEX_TO_CODE_POINT (charset, from_index); @@ -368,17 +369,17 @@ CHAR_TABLE_SET (table, from_c, make_number (code)); } else - for (; from_index <= to_index; from_index++, from_c++) + for (; from_index < lim_index; from_index++, from_c++) { if (NILP (CHAR_TABLE_REF (table, from_c))) CHAR_TABLE_SET (table, from_c, make_number (from_index)); } } else if (control_flag == 3) - for (; from_index <= to_index; from_index++, from_c++) + for (; from_index < lim_index; from_index++, from_c++) SET_TEMP_CHARSET_WORK_DECODER (from_c, from_index); else if (control_flag == 4) - for (; from_index <= to_index; from_index++, from_c++) + for (; from_index < lim_index; from_index++, from_c++) SET_TEMP_CHARSET_WORK_ENCODER (from_c, from_index); else /* control_flag == 0 */ { @@ -493,7 +494,7 @@ unbind_to (count, Qnil); if (fd < 0 || ! (fp = fdopen (fd, "r"))) - error ("Failure in loading charset map: %S", SDATA (mapfile)); + error ("Failure in loading charset map: %s", SDATA (mapfile)); /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is large (larger than MAX_ALLOCA). */ @@ -1000,7 +1001,7 @@ { CHECK_NUMBER (val); if (XINT (val) < '0' || XINT (val) > 127) - error ("Invalid iso-final-char: %d", XINT (val)); + error ("Invalid iso-final-char: %"pEd, XINT (val)); charset.iso_final = XINT (val); } @@ -1022,7 +1023,7 @@ { CHECK_NATNUM (val); if ((XINT (val) > 0 && XINT (val) <= 128) || XINT (val) >= 256) - error ("Invalid emacs-mule-id: %d", XINT (val)); + error ("Invalid emacs-mule-id: %"pEd, XINT (val)); charset.emacs_mule_id = XINT (val); } @@ -1440,11 +1441,17 @@ CHECK_NATNUM (final_char); if (XINT (dimension) > 3) - error ("Invalid DIMENSION %d, it should be 1, 2, or 3", XINT (dimension)); + error ("Invalid DIMENSION %"pEd", it should be 1, 2, or 3", + XINT (dimension)); if (XINT (chars) != 94 && XINT (chars) != 96) - error ("Invalid CHARS %d, it should be 94 or 96", XINT (chars)); + error ("Invalid CHARS %"pEd", it should be 94 or 96", XINT (chars)); if (XINT (final_char) < '0' || XINT (final_char) > '~') - error ("Invalid FINAL-CHAR %c, it should be `0'..`~'", XINT (chars)); + { + unsigned char str[MAX_MULTIBYTE_LENGTH + 1]; + int len = CHAR_STRING (XINT (chars), str); + str[len] = '\0'; + error ("Invalid FINAL-CHAR %s, it should be `0'..`~'", str); + } } === modified file 'src/chartab.c' --- src/chartab.c 2011-03-27 08:15:26 +0000 +++ src/chartab.c 2011-04-09 22:34:16 +0000 @@ -392,7 +392,8 @@ *table = val; else { - int i, j; + int i; + unsigned j; depth++; if (! SUB_CHAR_TABLE_P (*table)) @@ -404,7 +405,7 @@ i = CHARTAB_IDX (from, depth, min_char); j = CHARTAB_IDX (to, depth, min_char); min_char += chartab_chars[depth] * i; - for (; i <= j; i++, min_char += chartab_chars[depth]) + for (j++; i < j; i++, min_char += chartab_chars[depth]) sub_char_table_set_range (XSUB_CHAR_TABLE (*table)->contents + i, depth, min_char, from, to, val); } @@ -416,16 +417,16 @@ { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); Lisp_Object *contents = tbl->contents; - int i, min_char; + int i; if (from == to) char_table_set (table, from, val); else { - for (i = CHARTAB_IDX (from, 0, 0), min_char = i * chartab_chars[0]; - min_char <= to; - i++, min_char += chartab_chars[0]) - sub_char_table_set_range (contents + i, 0, min_char, from, to, val); + unsigned lim = to / chartab_chars[0] + 1; + for (i = CHARTAB_IDX (from, 0, 0); i < lim; i++) + sub_char_table_set_range (contents + i, 0, i * chartab_chars[0], + from, to, val); if (ASCII_CHAR_P (from)) tbl->ascii = char_table_ascii (table); } === modified file 'src/coding.c' --- src/coding.c 2011-04-09 16:35:19 +0000 +++ src/coding.c 2011-04-09 18:42:31 +0000 @@ -9024,14 +9024,15 @@ { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; + EMACS_INT ch; int c; CHECK_NATNUM (code); - c = XFASTINT (code); + ch = XFASTINT (code); CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); attrs = AREF (spec, 0); - if (ASCII_BYTE_P (c) + if (ASCII_BYTE_P (ch) && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) return code; @@ -9040,26 +9041,31 @@ charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); - if (c <= 0x7F) - charset = charset_roman; - else if (c >= 0xA0 && c < 0xDF) - { + if (ch <= 0x7F) + { + c = ch; + charset = charset_roman; + } + else if (ch >= 0xA0 && ch < 0xDF) + { + c = ch - 0x80; charset = charset_kana; - c -= 0x80; } else { - int c1 = c >> 8, c2 = c & 0xFF; + EMACS_INT c1 = ch >> 8; + int c2 = ch & 0xFF; if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); + c = ch; SJIS_TO_JIS (c); charset = charset_kanji; } c = DECODE_CHAR (charset, c); if (c < 0) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); return make_number (c); } @@ -9099,14 +9105,15 @@ { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_big5, *charset; + EMACS_INT ch; int c; CHECK_NATNUM (code); - c = XFASTINT (code); + ch = XFASTINT (code); CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); attrs = AREF (spec, 0); - if (ASCII_BYTE_P (c) + if (ASCII_BYTE_P (ch) && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) return code; @@ -9114,19 +9121,24 @@ charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); - if (c <= 0x7F) - charset = charset_roman; + if (ch <= 0x7F) + { + c = ch; + charset = charset_roman; + } else { - int b1 = c >> 8, b2 = c & 0x7F; + EMACS_INT b1 = ch >> 8; + int b2 = ch & 0x7F; if (b1 < 0xA1 || b1 > 0xFE || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); + c = ch; charset = charset_big5; } - c = DECODE_CHAR (charset, (unsigned )c); + c = DECODE_CHAR (charset, c); if (c < 0) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); return make_number (c); } @@ -9298,7 +9310,7 @@ || (EQ (operation, Qinsert_file_contents) && CONSP (target) && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) - error ("Invalid %dth argument", XFASTINT (target_idx) + 1); + error ("Invalid %"pEd"th argument", XFASTINT (target_idx) + 1); if (CONSP (target)) target = XCAR (target); @@ -9774,7 +9786,7 @@ CHECK_CHARSET_GET_ID (tmp1, id); CHECK_NATNUM_CDR (val); if (XINT (XCDR (val)) >= 4) - error ("Invalid graphic register number: %d", XINT (XCDR (val))); + error ("Invalid graphic register number: %"pEd, XINT (XCDR (val))); XSETCAR (val, make_number (id)); } === modified file 'src/deps.mk' --- src/deps.mk 2011-04-01 06:38:52 +0000 +++ src/deps.mk 2011-04-07 03:49:25 +0000 @@ -82,7 +82,6 @@ # doc.o's dependency on buildobj.h is in src/Makefile.in. doc.o: doc.c lisp.h $(config_h) buffer.h keyboard.h keymap.h \ character.h systime.h coding.h composite.h ../lib/unistd.h globals.h -doprnt.o: doprnt.c character.h lisp.h globals.h ../lib/unistd.h $(config_h) dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \ msdos.h dosfns.h dispextern.h charset.h coding.h atimer.h systime.h \ lisp.h $(config_h) === modified file 'src/doc.c' --- src/doc.c 2011-03-21 16:42:16 +0000 +++ src/doc.c 2011-04-07 03:34:05 +0000 @@ -154,7 +154,7 @@ if (0 > lseek (fd, position - offset, 0)) { emacs_close (fd); - error ("Position %ld out of range in doc string file \"%s\"", + error ("Position %"pEd" out of range in doc string file \"%s\"", position, name); } @@ -669,7 +669,7 @@ ; /* Just a source file name boundary marker. Ignore it. */ else - error ("DOC file invalid at position %d", pos); + error ("DOC file invalid at position %"pEd, pos); } } pos += end - buf; === modified file 'src/editfns.c' --- src/editfns.c 2011-04-09 16:35:19 +0000 +++ src/editfns.c 2011-04-09 22:39:14 +0000 @@ -3674,7 +3674,7 @@ if (!info) info = (struct info *) alloca (nbytes); memset (info, 0, nbytes); - for (i = 0; i <= nargs; i++) + for (i = 0; i < nargs + 1; i++) info[i].start = -1; if (!discarded) SAFE_ALLOCA (discarded, char *, SBYTES (args[0])); === modified file 'src/eval.c' --- src/eval.c 2011-04-05 20:01:08 +0000 +++ src/eval.c 2011-04-08 23:28:52 +0000 @@ -18,6 +18,7 @@ #include +#include #include #include "lisp.h" #include "blockinput.h" @@ -30,6 +31,10 @@ #include "xterm.h" #endif +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + /* This definition is duplicated in alloc.c and keyboard.c. */ /* Putting it in lisp.h makes cc bomb out! */ @@ -1401,7 +1406,7 @@ || (CONSP (tem) && (SYMBOLP (XCAR (tem)) || CONSP (XCAR (tem)))))) - error ("Invalid condition handler", tem); + error ("Invalid condition handler"); } c.tag = Qnil; @@ -1976,33 +1981,39 @@ void verror (const char *m, va_list ap) { - char buf[200]; - EMACS_INT size = 200; - int mlen; + char buf[4000]; + size_t size = sizeof buf; + size_t size_max = + min (MOST_POSITIVE_FIXNUM, min (INT_MAX, SIZE_MAX - 1)) + 1; char *buffer = buf; - int allocated = 0; + int used; Lisp_Object string; - mlen = strlen (m); - while (1) { - EMACS_INT used; - used = doprnt (buffer, size, m, m + mlen, ap); - if (used < size) - break; - size *= 2; - if (allocated) - buffer = (char *) xrealloc (buffer, size); - else + used = vsnprintf (buffer, size, m, ap); + + if (used < 0) { - buffer = (char *) xmalloc (size); - allocated = 1; + /* Non-C99 vsnprintf, such as w32, returns -1 when SIZE is too small. + Guess a larger USED to work around the incompatibility. */ + used = (size <= size_max / 2 ? 2 * size + : size < size_max ? size_max - 1 + : size_max); } + else if (used < size) + break; + if (size_max <= used) + memory_full (); + size = used + 1; + + if (buffer != buf) + xfree (buffer); + buffer = (char *) xmalloc (size); } - string = build_string (buffer); - if (allocated) + string = make_string (buffer, used); + if (buffer != buf) xfree (buffer); xsignal1 (Qerror, string); === modified file 'src/fns.c' --- src/fns.c 2011-04-06 04:34:35 +0000 +++ src/fns.c 2011-04-07 03:34:05 +0000 @@ -1076,7 +1076,7 @@ EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0); if (converted < chars) - error ("Can't convert the %dth character to unibyte", converted); + error ("Can't convert the %"pEd"th character to unibyte", converted); string = make_unibyte_string ((char *) str, chars); xfree (str); } === modified file 'src/ftfont.c' --- src/ftfont.c 2011-04-09 17:40:29 +0000 +++ src/ftfont.c 2011-04-09 19:14:12 +0000 @@ -160,11 +160,13 @@ static Lisp_Object get_adstyle_property (FcPattern *p) { - unsigned char *str, *end; + FcChar8 *fcstr; + char *str, *end; Lisp_Object adstyle; - if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch) + if (FcPatternGetString (p, FC_STYLE, 0, &fcstr) != FcResultMatch) return Qnil; + str = (char *) fcstr; for (end = str; *end && *end != ' '; end++); if (*end) { @@ -189,19 +191,20 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) { Lisp_Object key, cache, entity; - unsigned char *file, *str; + FcChar8 *str; + char *file; int idx; int numeric; double dbl; FcBool b; - if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch) + if (FcPatternGetString (p, FC_FILE, 0, &str) != FcResultMatch) return Qnil; if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch) return Qnil; - key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)), - make_number (idx)); + file = (char *) str; + key = Fcons (make_unibyte_string (file, strlen (file)), make_number (idx)); cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); entity = XCAR (cache); if (! NILP (entity)) @@ -219,10 +222,16 @@ ASET (entity, FONT_TYPE_INDEX, Qfreetype); ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); - if (FcPatternGetString (p, FC_FOUNDRY, 0, (FcChar8 **) &str) == FcResultMatch) - ASET (entity, FONT_FOUNDRY_INDEX, font_intern_prop (str, strlen (str), 1)); - if (FcPatternGetString (p, FC_FAMILY, 0, (FcChar8 **) &str) == FcResultMatch) - ASET (entity, FONT_FAMILY_INDEX, font_intern_prop (str, strlen (str), 1)); + if (FcPatternGetString (p, FC_FOUNDRY, 0, &str) == FcResultMatch) + { + char *s = (char *) str; + ASET (entity, FONT_FOUNDRY_INDEX, font_intern_prop (s, strlen (s), 1)); + } + if (FcPatternGetString (p, FC_FAMILY, 0, &str) == FcResultMatch) + { + char *s = (char *) str; + ASET (entity, FONT_FAMILY_INDEX, font_intern_prop (s, strlen (s), 1)); + } if (FcPatternGetInteger (p, FC_WEIGHT, 0, &numeric) == FcResultMatch) { if (numeric >= FC_WEIGHT_REGULAR && numeric < FC_WEIGHT_MEDIUM) === modified file 'src/intervals.c' --- src/intervals.c 2011-04-04 16:47:31 +0000 +++ src/intervals.c 2011-04-07 03:34:05 +0000 @@ -777,7 +777,7 @@ i = i->right; /* Move to the right child */ } else if (NULL_PARENT (i)) - error ("Point %d after end of properties", pos); + error ("Point %"pEd" after end of properties", pos); else i = INTERVAL_PARENT (i); continue; === modified file 'src/keyboard.c' --- src/keyboard.c 2011-04-08 15:51:28 +0000 +++ src/keyboard.c 2011-04-09 19:12:39 +0000 @@ -3090,7 +3090,6 @@ /* Process the help character specially if enabled */ if (!NILP (Vhelp_form) && help_char_p (c)) { - Lisp_Object tem0; int count = SPECPDL_INDEX (); help_form_saved_window_configs @@ -8777,7 +8776,8 @@ (To ignore it safely, we would need to gcpro a bunch of other variables.) */ if (! (VECTORP (next) || STRINGP (next))) - error ("Function %s returns invalid key sequence", tem); + error ("Function %s returns invalid key sequence", + SSDATA (SYMBOL_NAME (tem))); } return next; } === modified file 'src/lisp.h' --- src/lisp.h 2011-04-09 16:35:19 +0000 +++ src/lisp.h 2011-04-09 18:42:31 +0000 @@ -38,6 +38,7 @@ #ifndef EMACS_INT #define EMACS_INT long #define BITS_PER_EMACS_INT BITS_PER_LONG +#define pEd "ld" #endif #ifndef EMACS_UINT #define EMACS_UINT unsigned long @@ -46,6 +47,7 @@ #ifndef EMACS_INT #define EMACS_INT int #define BITS_PER_EMACS_INT BITS_PER_INT +#define pEd "d" #endif #ifndef EMACS_UINT #define EMACS_UINT unsigned int @@ -2628,7 +2630,6 @@ extern void set_message (const char *s, Lisp_Object, EMACS_INT, int); extern void clear_message (int, int); extern void message (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); -extern void message_nolog (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); extern void message1 (const char *); extern void message1_nolog (const char *); extern void message2 (const char *, EMACS_INT, int); @@ -2781,9 +2782,7 @@ extern void float_to_string (char *, double); extern void syms_of_print (void); -/* Defined in doprnt.c */ -extern EMACS_INT doprnt (char *, int, const char *, const char *, va_list); - +/* Defined in lread.c. */ extern Lisp_Object Qvariable_documentation, Qstandard_input; extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; extern Lisp_Object initial_obarray; @@ -2873,8 +2872,9 @@ extern void specbind (Lisp_Object, Lisp_Object); extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); extern Lisp_Object unbind_to (int, Lisp_Object); -extern void error (const char *, ...) NO_RETURN; -extern void verror (const char *, va_list) NO_RETURN; +extern void error (const char *, ...) NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 2); +extern void verror (const char *, va_list) + NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0); extern void do_autoload (Lisp_Object, Lisp_Object); extern Lisp_Object un_autoload (Lisp_Object); EXFUN (Ffetch_bytecode, 1); === modified file 'src/m/amdx86-64.h' --- src/m/amdx86-64.h 2011-02-16 01:35:20 +0000 +++ src/m/amdx86-64.h 2011-04-07 03:34:05 +0000 @@ -28,6 +28,7 @@ /* Define the type to use. */ #define EMACS_INT long +#define pEd "ld" #define EMACS_UINT unsigned long /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ === modified file 'src/m/ia64.h' --- src/m/ia64.h 2011-02-16 01:35:20 +0000 +++ src/m/ia64.h 2011-04-07 03:34:05 +0000 @@ -28,6 +28,7 @@ /* Define the type to use. */ #define EMACS_INT long +#define pEd "ld" #define EMACS_UINT unsigned long #ifdef REL_ALLOC === modified file 'src/m/ibms390x.h' --- src/m/ibms390x.h 2011-01-25 04:08:28 +0000 +++ src/m/ibms390x.h 2011-04-07 03:34:05 +0000 @@ -24,6 +24,7 @@ /* Define the type to use. */ #define EMACS_INT long +#define pEd "ld" #define EMACS_UINT unsigned long /* On the 64 bit architecture, we can use 60 bits for addresses */ @@ -31,4 +32,3 @@ /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ #define XPNTR(a) XUINT (a) - === modified file 'src/nsfns.m' --- src/nsfns.m 2011-02-17 10:19:29 +0000 +++ src/nsfns.m 2011-04-07 03:34:05 +0000 @@ -483,7 +483,7 @@ if (!STRINGP (f->icon_name)) encoded_icon_name = encoded_name; else - encoded_icon_name = ENCODE_UTF_8 (f->icon_name); + encoded_icon_name = ENCODE_UTF_8 (f->icon_name); str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)]; @@ -637,7 +637,7 @@ if (FRAME_ICONIFIED_P (f)) [[view window] setMiniwindowTitle: str]; - else + else { NSString *fstr; @@ -1021,8 +1021,8 @@ 0, /* x_set_fullscreen will ignore */ x_set_font_backend, /* generic OK */ x_set_alpha, - 0, /* x_set_sticky */ - 0, /* x_set_tool_bar_position */ + 0, /* x_set_sticky */ + 0, /* x_set_tool_bar_position */ }; @@ -2044,7 +2044,7 @@ (Lisp_Object script) { Lisp_Object result; - long status; + int status; CHECK_STRING (script); check_ns (); @@ -2330,7 +2330,7 @@ { struct ns_display_info *dpyinfo; check_ns (); - + dpyinfo = check_ns_display_info (display); /* We force 24+ bit depths to 24-bit to prevent an overflow. */ return make_number (1 << min (dpyinfo->n_planes, 24)); @@ -2373,7 +2373,7 @@ pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top) - height; } - + /* Ensure in bounds. (Note, screen origin = lower left.) */ if (INTEGERP (left)) *root_x = pt.x; @@ -2655,4 +2655,3 @@ check_window_system_func = check_ns; } - === modified file 'src/syntax.c' --- src/syntax.c 2011-04-04 07:53:20 +0000 +++ src/syntax.c 2011-04-09 22:51:22 +0000 @@ -1541,7 +1541,8 @@ if (c <= c2) { - while (c <= c2) + unsigned lim2 = c2 + 1; + while (c < lim2) fastmap[c++] = 1; if (! ASCII_CHAR_P (c2)) string_has_eight_bit = 1; @@ -1681,7 +1682,8 @@ } if (! ASCII_CHAR_P (c)) { - while (leading_code <= leading_code2) + unsigned lim2 = leading_code2 + 1; + while (leading_code < lim2) fastmap[leading_code++] = 1; if (c <= c2) { @@ -1713,9 +1715,9 @@ for (i = 0; i < n_char_ranges; i += 2) { int c1 = char_ranges[i]; - int c2 = char_ranges[i + 1]; + unsigned lim2 = char_ranges[i + 1] + 1; - for (; c1 <= c2; c1++) + for (; c1 < lim2; c1++) { int b = CHAR_TO_BYTE_SAFE (c1); if (b >= 0) === modified file 'src/sysdep.c' --- src/sysdep.c 2011-04-01 06:28:48 +0000 +++ src/sysdep.c 2011-04-07 03:34:05 +0000 @@ -2361,7 +2361,8 @@ CHECK_NUMBER (tem); err = cfsetspeed (&attr, XINT (tem)); if (err != 0) - error ("cfsetspeed(%d) failed: %s", XINT (tem), emacs_strerror (errno)); + error ("cfsetspeed(%"pEd") failed: %s", XINT (tem), + emacs_strerror (errno)); childp2 = Fplist_put (childp2, QCspeed, tem); /* Configure bytesize. */ === modified file 'src/term.c' --- src/term.c 2011-04-08 18:53:26 +0000 +++ src/term.c 2011-04-09 18:42:31 +0000 @@ -86,7 +86,7 @@ static void delete_tty (struct terminal *); static void maybe_fatal (int must_succeed, struct terminal *terminal, const char *str1, const char *str2, ...) - NO_RETURN ATTRIBUTE_FORMAT_PRINTF (4, 5); + NO_RETURN ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); static void vfatal (const char *str, va_list ap) NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0); === modified file 'src/window.c' --- src/window.c 2011-04-08 15:37:15 +0000 +++ src/window.c 2011-04-09 18:42:31 +0000 @@ -3801,7 +3801,7 @@ error ("Window height %d too small (after splitting)", size_int); if (size_int + window_safe_height > XFASTINT (o->total_lines)) error ("Window height %d too small (after splitting)", - XFASTINT (o->total_lines) - size_int); + (int) (XFASTINT (o->total_lines) - size_int)); if (NILP (o->parent) || NILP (XWINDOW (o->parent)->vchild)) { @@ -3818,7 +3818,7 @@ error ("Window width %d too small (after splitting)", size_int); if (size_int + window_safe_width > XFASTINT (o->total_cols)) error ("Window width %d too small (after splitting)", - XFASTINT (o->total_cols) - size_int); + (int) (XFASTINT (o->total_cols) - size_int)); if (NILP (o->parent) || NILP (XWINDOW (o->parent)->hchild)) { === modified file 'src/xdisp.c' --- src/xdisp.c 2011-04-09 16:35:19 +0000 +++ src/xdisp.c 2011-04-10 02:27:15 +0000 @@ -8408,10 +8408,19 @@ { if (m) { - EMACS_INT len; - - len = doprnt (FRAME_MESSAGE_BUF (f), - FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap); + char *buf = FRAME_MESSAGE_BUF (f); + size_t bufsize = FRAME_MESSAGE_BUF_SIZE (f); + int len; + + memset (buf, 0, bufsize); + len = vsnprintf (buf, bufsize, m, ap); + + /* Do any truncation at a character boundary. */ + if (! (0 <= len && len < bufsize)) + for (len = strnlen (buf, bufsize); + len && ! CHAR_HEAD_P (buf[len - 1]); + len--) + continue; message2 (FRAME_MESSAGE_BUF (f), len, 0); } @@ -8435,6 +8444,7 @@ } +#if 0 /* The non-logging version of message. */ void @@ -8449,6 +8459,7 @@ Vmessage_log_max = old_log_max; va_end (ap); } +#endif /* Display the current message in the current mini-buffer. This is @@ -19503,7 +19514,7 @@ EMACS_INT limit = BUF_BEGV (b); EMACS_INT limit_byte = BUF_BEGV_BYTE (b); EMACS_INT position; - EMACS_INT distance = + EMACS_INT distance = (height * 2 + 30) * line_number_display_limit_width; if (startpos - distance > limit) === modified file 'src/xfns.c' --- src/xfns.c 2011-04-02 02:06:43 +0000 +++ src/xfns.c 2011-04-07 03:34:05 +0000 @@ -215,7 +215,7 @@ struct terminal *t = get_terminal (object, 1); if (t->type != output_x_window) - error ("Terminal %d is not an X display", XINT (object)); + error ("Terminal %"pEd" is not an X display", XINT (object)); dpyinfo = t->display_info.x; } === modified file 'src/xmenu.c' --- src/xmenu.c 2011-04-09 17:40:29 +0000 +++ src/xmenu.c 2011-04-09 20:39:49 +0000 @@ -966,6 +966,7 @@ Lisp_Object *previous_items = (Lisp_Object *) alloca (previous_menu_items_used * sizeof (Lisp_Object)); + EMACS_UINT subitems; /* If we are making a new widget, its contents are empty, do always reinitialize them. */ @@ -1010,21 +1011,21 @@ menu_items = f->menu_bar_vector; menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; - submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); - submenu_end = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); - submenu_n_panes = (int *) alloca (XVECTOR (items)->size * sizeof (int)); - submenu_top_level_items - = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); + subitems = XVECTOR (items)->size / 4; + submenu_start = (int *) alloca (subitems * sizeof (int *)); + submenu_end = (int *) alloca (subitems * sizeof (int *)); + submenu_n_panes = (int *) alloca (subitems * sizeof (int)); + submenu_top_level_items = (int *) alloca (subitems * sizeof (int *)); init_menu_items (); - for (i = 0; i < XVECTOR (items)->size; i += 4) + for (i = 0; i < subitems; i++) { Lisp_Object key, string, maps; last_i = i; - key = XVECTOR (items)->contents[i]; - string = XVECTOR (items)->contents[i + 1]; - maps = XVECTOR (items)->contents[i + 2]; + key = XVECTOR (items)->contents[4 * i]; + string = XVECTOR (items)->contents[4 * i + 1]; + maps = XVECTOR (items)->contents[4 * i + 2]; if (NILP (string)) break; @@ -1051,7 +1052,7 @@ wv->help = Qnil; first_wv = wv; - for (i = 0; i < last_i; i += 4) + for (i = 0; i < last_i; i++) { menu_items_n_panes = submenu_n_panes[i]; wv = digest_single_submenu (submenu_start[i], submenu_end[i], === modified file 'src/xterm.c' --- src/xterm.c 2011-04-09 17:40:29 +0000 +++ src/xterm.c 2011-04-09 18:42:31 +0000 @@ -7539,8 +7539,6 @@ Calling x_uncatch_errors resumes the normal error handling. */ -void x_check_errors (Display *dpy, const char *format); - void x_catch_errors (Display *dpy) { ------------------------------------------------------------ revno: 103879 committer: Leo Liu branch nick: trunk timestamp: Sun 2011-04-10 22:21:26 +0800 message: Fix typo in tabulated-list-print-entry diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-09 20:28:01 +0000 +++ lisp/ChangeLog 2011-04-10 14:21:26 +0000 @@ -1,3 +1,8 @@ +2011-04-10 Leo Liu + + * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Fix + typo. + 2011-04-09 Chong Yidong * image-mode.el (image-toggle-display-image): Signal an error if === modified file 'lisp/emacs-lisp/tabulated-list.el' --- lisp/emacs-lisp/tabulated-list.el 2011-04-06 21:55:08 +0000 +++ lisp/emacs-lisp/tabulated-list.el 2011-04-10 14:21:26 +0000 @@ -271,7 +271,7 @@ ;; Truncate labels if necessary. (and (> width 6) (> (length label) width) - (setq label (concat (substring desc 0 (- width 3)) + (setq label (concat (substring label 0 (- width 3)) "..."))) (if (stringp desc) (insert (propertize label 'help-echo help-echo)) ------------------------------------------------------------ revno: 103878 committer: Jim Meyering branch nick: trunk timestamp: Sun 2011-04-10 16:00:13 +0200 message: use ssize_t and size_t for read- and write-like emacs_gnutls_* functions * gnutls.c (emacs_gnutls_read): Adjust signature to be more read-like: return ssize_t not "int", and use size_t as the buffer length. (emacs_gnutls_write): Likewise, and make the buffer pointer "const". * gnutls.h: Update declarations. * process.c (read_process_output): Use ssize_t, to match. (send_process): Likewise. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-09 20:28:01 +0000 +++ src/ChangeLog 2011-04-10 14:00:13 +0000 @@ -1,3 +1,13 @@ +2011-04-10 Jim Meyering + + use ssize_t and size_t for read- and write-like emacs_gnutls_* functions + * gnutls.c (emacs_gnutls_read): Adjust signature to be more read-like: + return ssize_t not "int", and use size_t as the buffer length. + (emacs_gnutls_write): Likewise, and make the buffer pointer "const". + * gnutls.h: Update declarations. + * process.c (read_process_output): Use ssize_t, to match. + (send_process): Likewise. + 2011-04-09 Chong Yidong * image.c (Fimagemagick_types): Doc fix, and comment cleanup. === modified file 'src/gnutls.c' --- src/gnutls.c 2011-01-25 04:08:28 +0000 +++ src/gnutls.c 2011-04-10 14:00:13 +0000 @@ -70,11 +70,12 @@ } } -int -emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, - unsigned int nbyte) +ssize_t +emacs_gnutls_write (int fildes, struct Lisp_Process *proc, const char *buf, + size_t nbyte) { - register int rtnval, bytes_written; + ssize_t rtnval; + size_t bytes_written; gnutls_session_t state = proc->gnutls_state; if (proc->gnutls_initstage != GNUTLS_STAGE_READY) { @@ -109,11 +110,11 @@ return (bytes_written); } -int +ssize_t emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, - unsigned int nbyte) + size_t nbyte) { - register int rtnval; + ssize_t rtnval; gnutls_session_t state = proc->gnutls_state; if (proc->gnutls_initstage != GNUTLS_STAGE_READY) === modified file 'src/gnutls.h' --- src/gnutls.h 2011-01-25 04:08:28 +0000 +++ src/gnutls.h 2011-04-10 14:00:13 +0000 @@ -50,15 +50,15 @@ #define GNUTLS_LOG2(level, max, string, extra) if (level <= max) { gnutls_log_function2 (level, "(Emacs) " string, extra); } -int -emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, - unsigned int nbyte); -int +ssize_t +emacs_gnutls_write (int fildes, struct Lisp_Process *proc, const char *buf, + size_t nbyte); +ssize_t emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, - unsigned int nbyte); + size_t nbyte); extern void syms_of_gnutls (void); -#endif +#endif #endif === modified file 'src/process.c' --- src/process.c 2011-04-08 18:53:26 +0000 +++ src/process.c 2011-04-10 14:00:13 +0000 @@ -4898,7 +4898,7 @@ static int read_process_output (Lisp_Object proc, register int channel) { - register int nbytes; + register ssize_t nbytes; char *chars; register Lisp_Object outstream; register struct Lisp_Process *p = XPROCESS (proc); @@ -5243,7 +5243,7 @@ { /* Use volatile to protect variables from being clobbered by longjmp. */ struct Lisp_Process *p = XPROCESS (proc); - EMACS_INT rv; + ssize_t rv; struct coding_system *coding; struct gcpro gcpro1; void (*volatile old_sigpipe) (int); ------------------------------------------------------------ revno: 103877 committer: Chong Yidong branch nick: trunk timestamp: Sat 2011-04-09 16:28:01 -0400 message: Cleanups to the ImageMagick code and docstrings. * lisp/image-mode.el (image-toggle-display-image): Signal an error if not in Image mode. (image-transform-mode, image-transform-resize) (image-transform-set-rotation): Doc fix. (image-transform-set-resize): Deleted. (image-transform-set-scale, image-transform-fit-to-height) (image-transform-fit-to-width): Handle image-toggle-display-image and image-transform-resize directly. * src/image.c (Fimagemagick_types): Doc fix, and comment cleanup. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-09 17:40:29 +0000 +++ lisp/ChangeLog 2011-04-09 20:28:01 +0000 @@ -1,3 +1,14 @@ +2011-04-09 Chong Yidong + + * image-mode.el (image-toggle-display-image): Signal an error if + not in Image mode. + (image-transform-mode, image-transform-resize) + (image-transform-set-rotation): Doc fix. + (image-transform-set-resize): Deleted. + (image-transform-set-scale, image-transform-fit-to-height) + (image-transform-fit-to-width): Handle image-toggle-display-image + and image-transform-resize directly. + 2011-04-08 Sho Nakatani * doc-view.el (doc-view-fit-width-to-window) === modified file 'lisp/image-mode.el' --- lisp/image-mode.el 2011-02-19 19:40:59 +0000 +++ lisp/image-mode.el 2011-04-09 20:28:01 +0000 @@ -469,6 +469,8 @@ "Show the image of the image file. Turn the image data into a real image, but only if the whole file was inserted." + (unless (derived-mode-p 'image-mode major-mode) + (error "The buffer is not in Image mode")) (let* ((filename (buffer-file-name)) (data-p (not (and filename (file-readable-p filename) @@ -485,8 +487,7 @@ (type (image-type file-or-data nil data-p)) (image0 (create-animated-image file-or-data type data-p)) (image (append image0 - (image-transform-properties image0) - )) + (image-transform-properties image0))) (props `(display ,image intangible ,image @@ -557,80 +558,86 @@ (defvar image-transform-minor-mode-map (let ((map (make-sparse-keymap))) -; (define-key map [(control ?+)] 'image-scale-in) -; (define-key map [(control ?-)] 'image-scale-out) -; (define-key map [(control ?=)] 'image-scale-none) -;; (define-key map "c f h" 'image-scale-fit-height) -;; (define-key map "c ]" 'image-rotate-right) + ;; (define-key map [(control ?+)] 'image-scale-in) + ;; (define-key map [(control ?-)] 'image-scale-out) + ;; (define-key map [(control ?=)] 'image-scale-none) + ;; (define-key map "c f h" 'image-scale-fit-height) + ;; (define-key map "c ]" 'image-rotate-right) map) - "Minor mode keymap for transforming the view of images Image mode.") + "Minor mode keymap `image-transform-mode'.") (define-minor-mode image-transform-mode - "minor mode for scaleing and rotation" - nil "image-transform" - image-transform-minor-mode-map) + "Minor mode for scaling and rotating images. +This minor mode has no effect unless Emacs is compiled with +ImageMagick support." + nil "image-transform" image-transform-minor-mode-map) -(defvar image-transform-resize nil - "The image resize operation. See the command - `image-transform-set-scale' for more information." ) +(defvar image-transform-resize nil + "The image resize operation. +Its value should be one of the following: + - nil, meaning no resizing. + - `fit-height', meaning to fit the image to the window height. + - `fit-width', meaning to fit the image to the window width. + - A number, which is a scale factor (the default size is 100).") (defvar image-transform-rotation 0.0) - (defun image-transform-properties (display) - "Calculate the display properties for transformations; scaling -and rotation. " - (let* - ((size (image-size display t)) - (height - (cond - ((and (numberp image-transform-resize) (eq 100 image-transform-resize)) - nil) - ((numberp image-transform-resize) - (* image-transform-resize (cdr size))) - ((eq image-transform-resize 'fit-height) - (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) - (t nil))) - (width (if (eq image-transform-resize 'fit-width) - (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))))) - + "Rescale and/or rotate the current image. +The scale factor and rotation angle are given by the variables +`image-transform-resize' and `image-transform-rotation'. This +takes effect only if Emacs is compiled with ImageMagick support." + (let* ((size (image-size display t)) + (height + (cond + ((numberp image-transform-resize) + (unless (= image-transform-resize 100) + (* image-transform-resize (cdr size)))) + ((eq image-transform-resize 'fit-height) + (- (nth 3 (window-inside-pixel-edges)) + (nth 1 (window-inside-pixel-edges)))))) + (width (if (eq image-transform-resize 'fit-width) + (- (nth 2 (window-inside-pixel-edges)) + (nth 0 (window-inside-pixel-edges)))))) + ;;TODO fit-to-* should consider the rotation angle `(,@(if height (list :height height)) ,@(if width (list :width width)) ,@(if (not (equal 0.0 image-transform-rotation)) - (list :rotation image-transform-rotation)) - ;;TODO fit-to-* should consider the rotation angle - ))) + (list :rotation image-transform-rotation))))) (defun image-transform-set-scale (scale) - "SCALE sets the scaling for images. " - (interactive "nscale:") - (image-transform-set-resize (float scale))) + "Prompt for a number, and resize the current image by that amount. +This command has no effect unless Emacs is compiled with +ImageMagick support." + (interactive "nScale: ") + (setq image-transform-resize resize) + (image-toggle-display-image)) (defun image-transform-fit-to-height () - "Fit image height to window height. " + "Fit the current image to the height of the current window. +This command has no effect unless Emacs is compiled with +ImageMagick support." (interactive) - (image-transform-set-resize 'fit-height)) + (setq image-transform-resize 'fit-height) + (image-toggle-display-image)) (defun image-transform-fit-to-width () - "Fit image width to window width. " + "Fit the current image to the width of the current window. +This command has no effect unless Emacs is compiled with +ImageMagick support." (interactive) - (image-transform-set-resize 'fit-width)) - -(defun image-transform-set-resize (resize) - "Set the resize mode for images. The RESIZE value can be the -symbol fit-height which fits the image to the window height. The -symbol fit-width fits the image to the window width. A number -indicates a scaling factor. nil indicates scale to 100%. " - (setq image-transform-resize resize) - (if (eq 'image-mode major-mode) (image-toggle-display-image))) + (setq image-transform-resize 'fit-width) + (image-toggle-display-image)) (defun image-transform-set-rotation (rotation) - "Set the image ROTATION angle. " - (interactive "nrotation:") + "Prompt for an angle ROTATION, and rotate the image by that amount. +ROTATION should be in degrees. This command has no effect unless +Emacs is compiled with ImageMagick support." + (interactive "nRotation angle (in degrees): ") ;;TODO 0 90 180 270 degrees are the only reasonable angles here ;;otherwise combining with rescaling will get very awkward (setq image-transform-rotation (float rotation)) - (if (eq major-mode 'image-mode) (image-toggle-display-image))) + (image-toggle-display-image)) (provide 'image-mode) === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-09 17:40:29 +0000 +++ src/ChangeLog 2011-04-09 20:28:01 +0000 @@ -1,5 +1,9 @@ 2011-04-09 Chong Yidong + * image.c (Fimagemagick_types): Doc fix, and comment cleanup. + +2011-04-09 Chong Yidong + * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use unsigned char, to match FcChar8 type definition. === modified file 'src/image.c' --- src/image.c 2011-04-05 20:06:52 +0000 +++ src/image.c 2011-04-09 20:28:01 +0000 @@ -7370,14 +7370,13 @@ /*********************************************************************** - imagemagick + ImageMagick ***********************************************************************/ #if defined (HAVE_IMAGEMAGICK) -/* The symbol `imagemagick' identifying images of this type. */ - Lisp_Object Qimagemagick; -/* Indices of image specification fields in imagemagick_format, below. */ + +/* Indices of image specification fields in imagemagick_format. */ enum imagemagick_keyword_index { @@ -7418,6 +7417,7 @@ {":rotation", IMAGE_NUMBER_VALUE, 0}, {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} }; + /* Free X resources of imagemagick image IMG which is used on frame F. */ static void @@ -7427,8 +7427,6 @@ x_clear_image (f, img); } - - /* Return non-zero if OBJECT is a valid IMAGEMAGICK image specification. Do this by calling parse_image_spec and supplying the keywords that identify the IMAGEMAGICK format. */ @@ -7457,7 +7455,7 @@ Uses librimagemagick to do most of the image processing. - non-zero when successful. + Return non-zero if successful. */ static int @@ -7504,12 +7502,12 @@ Image * im_image; - /* Handle image index for image types who can contain more than one - image. Interface :index is same as for GIF. First we "ping" the - image to see how many sub-images it contains. Pinging is faster - than loading the image to find out things about it. */ + /* Handle image index for image types who can contain more than one image. + Interface :index is same as for GIF. First we "ping" the image to see how + many sub-images it contains. Pinging is faster than loading the image to + find out things about it. */ - /* `MagickWandGenesis' initializes the imagemagick environment. */ + /* Initialize the imagemagick environment. */ MagickWandGenesis (); image = image_spec_value (img->spec, QCindex, NULL); ino = INTEGERP (image) ? XFASTINT (image) : 0; @@ -7541,7 +7539,7 @@ DestroyMagickWand (ping_wand); /* Now, after pinging, we know how many images are inside the - file. If its not a bundle, just one. */ + file. If it's not a bundle, the number is one. */ if (filename != NULL) { @@ -7572,7 +7570,7 @@ if (status == MagickFalse) goto imagemagick_error; /* If width and/or height is set in the display spec assume we want - to scale to those values. if either h or w is unspecified, the + to scale to those values. If either h or w is unspecified, the unspecified should be calculated from the specified to preserve aspect ratio. */ @@ -7584,17 +7582,13 @@ height = MagickGetImageHeight (image_wand); width = MagickGetImageWidth (image_wand); - if(desired_width != -1 && desired_height == -1) - { - /* w known, calculate h. */ - desired_height = (double) desired_width / width * height; - } - if(desired_width == -1 && desired_height != -1) - { - /* h known, calculate w. */ - desired_width = (double) desired_height / height * width; - } - if(desired_width != -1 && desired_height != -1) + if (desired_width != -1 && desired_height == -1) + /* w known, calculate h. */ + desired_height = (double) desired_width / width * height; + if (desired_width == -1 && desired_height != -1) + /* h known, calculate w. */ + desired_width = (double) desired_height / height * width; + if (desired_width != -1 && desired_height != -1) { status = MagickScaleImage (image_wand, desired_width, desired_height); if (status == MagickFalse) @@ -7604,19 +7598,17 @@ } } - /* crop behaves similar to image slicing in Emacs but is more memory efficient. */ crop = image_spec_value (img->spec, QCcrop, NULL); if (CONSP (crop) && INTEGERP (XCAR (crop))) { - /* After some testing, it seems MagickCropImage is the fastest - crop function in ImageMagick. This crop function seems to do - less copying than the alternatives, but it still reads the - entire image into memory before croping, which is aparently - difficult to avoid when using imagemagick. */ - + /* After some testing, it seems MagickCropImage is the fastest crop + function in ImageMagick. This crop function seems to do less copying + than the alternatives, but it still reads the entire image into memory + before croping, which is aparently difficult to avoid when using + imagemagick. */ int w, h, x, y; w = XFASTINT (XCAR (crop)); crop = XCDR (crop); @@ -7877,12 +7869,10 @@ }; - - DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, - doc: /* Return image file types supported by ImageMagick. -Since ImageMagick recognizes a lot of file-types that clash with Emacs, -such as .c, we want to be able to alter the list at the lisp level. */) + doc: /* Return the image types supported by ImageMagick. +Note that ImageMagick recognizes many file-types that Emacs does not recognize +as images, such as .c. */) (void) { Lisp_Object typelist = Qnil; ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.