[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103841: Fix more problems found by G
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103841: Fix more problems found by GCC 4.6.0's static checks. |
Date: |
Tue, 05 Apr 2011 22:19:39 -0700 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103841 [merge]
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2011-04-05 22:19:39 -0700
message:
Fix more problems found by GCC 4.6.0's static checks.
added:
lib/allocator.h
lib/careadlinkat.c
lib/careadlinkat.h
m4/ssize_t.m4
modified:
ChangeLog
Makefile.in
configure.in
lib-src/ChangeLog
lib-src/emacsclient.c
lib-src/make-docfile.c
lib/gnulib.mk
m4/gl-comp.m4
src/ChangeLog
src/alloc.c
src/buffer.c
src/bytecode.c
src/casefiddle.c
src/coding.c
src/composite.c
src/composite.h
src/deps.mk
src/dired.c
src/eval.c
src/fileio.c
src/filelock.c
src/fns.c
src/font.c
src/fontset.c
src/gtkutil.c
src/image.c
src/indent.c
src/intervals.c
src/keyboard.c
src/lisp.h
src/lread.c
src/menu.c
src/minibuf.c
src/print.c
src/process.c
src/search.c
src/sound.c
src/syntax.c
src/sysdep.c
src/term.c
src/textprop.c
src/xdisp.c
src/xfaces.c
src/xfns.c
src/xfont.c
src/xmenu.c
src/xselect.c
src/xterm.c
=== modified file 'ChangeLog'
--- a/ChangeLog 2011-04-06 02:13:16 +0000
+++ b/ChangeLog 2011-04-06 05:19:39 +0000
@@ -1,3 +1,14 @@
+2011-04-06 Paul Eggert <address@hidden>
+
+ Fix more problems found by GCC 4.6.0's static checks.
+
+ * configure.in (ATTRIBUTE_FORMAT, ATTRIBUTE_FORMAT_PRINTF): New macros.
+
+ Replace 2 copies of readlink code with 1 gnulib version (Bug#8401).
+ * Makefile.in (GNULIB_MODULES): Add careadlinkat.
+ * lib/allocator.h, lib/careadlinkat.c, lib/careadlinkat.h:
+ * m4/ssize_t.m4: New files, automatically generated from gnulib.
+
2011-04-06 Glenn Morris <address@hidden>
* autogen/update_autogen: Handle loaddefs-like files as well.
=== modified file 'Makefile.in'
--- a/Makefile.in 2011-03-31 04:24:03 +0000
+++ b/Makefile.in 2011-04-01 20:19:36 +0000
@@ -331,7 +331,7 @@
# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
# as per $(gnulib_srcdir)/DEPENDENCIES.
GNULIB_MODULES = \
- crypto/md5 dtoastr filemode getloadavg getopt-gnu \
+ careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu \
ignore-value intprops lstat mktime readlink \
socklen stdio strftime symlink sys_stat
GNULIB_TOOL_FLAGS = \
=== modified file 'configure.in'
--- a/configure.in 2011-03-31 04:24:03 +0000
+++ b/configure.in 2011-04-05 19:59:08 +0000
@@ -3581,6 +3581,20 @@
#define EXTERNALLY_VISIBLE
#endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+ ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
+#else
+# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+ ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+#endif
+
/* Some versions of GNU/Linux define noinline in their headers. */
#ifdef noinline
#undef noinline
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2011-03-30 00:39:12 +0000
+++ b/lib-src/ChangeLog 2011-04-06 05:19:39 +0000
@@ -1,3 +1,12 @@
+2011-04-06 Paul Eggert <address@hidden>
+
+ Fix more problems found by GCC 4.6.0's static checks.
+
+ * emacsclient.c (message): Mark it as a printf-like function.
+
+ * make-docfile.c (IF_LINT): New macro, copied from emacsclient.c.
+ (write_c_args): Use it to suppress GCC warning.
+
2011-03-30 Paul Eggert <address@hidden>
Fix a problem found by GCC 4.6.0's static checks.
=== modified file 'lib-src/emacsclient.c'
--- a/lib-src/emacsclient.c 2011-03-27 02:27:11 +0000
+++ b/lib-src/emacsclient.c 2011-04-05 19:59:58 +0000
@@ -487,6 +487,7 @@
/* Display a normal or error message.
On Windows, use a message box if compiled as a Windows app. */
+static void message (int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF (2, 3);
static void
message (int is_error, const char *format, ...)
{
=== modified file 'lib-src/make-docfile.c'
--- a/lib-src/make-docfile.c 2011-02-25 22:21:01 +0000
+++ b/lib-src/make-docfile.c 2011-04-01 20:28:50 +0000
@@ -66,6 +66,13 @@
#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
#endif
+/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
static int scan_file (char *filename);
static int scan_lisp_file (const char *filename, const char *mode);
static int scan_c_file (char *filename, const char *mode);
@@ -481,7 +488,7 @@
{
register char *p;
int in_ident = 0;
- char *ident_start;
+ char *ident_start IF_LINT (= NULL);
size_t ident_length = 0;
fprintf (out, "(fn");
=== added file 'lib/allocator.h'
--- a/lib/allocator.h 1970-01-01 00:00:00 +0000
+++ b/lib/allocator.h 2011-04-05 18:19:19 +0000
@@ -0,0 +1,53 @@
+/* Memory allocators such as malloc+free.
+
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef _GL_ALLOCATOR_H
+
+#include <stddef.h>
+
+/* An object describing a memory allocator family. */
+
+struct allocator
+{
+ /* Do not use GCC attributes such as __attribute__ ((malloc)) with
+ the function types pointed at by these members, because these
+ attributes do not work with pointers to functions. See
+ <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>. */
+
+ /* Call MALLOC to allocate memory, like 'malloc'. On failure MALLOC
+ should return NULL, though not necessarily set errno. When given
+ a zero size it may return NULL even if successful. */
+ void *(*malloc) (size_t);
+
+ /* If nonnull, call REALLOC to reallocate memory, like 'realloc'.
+ On failure REALLOC 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);
+
+ /* Call FREE to free memory, like 'free'. */
+ void (*free) (void *);
+
+ /* If nonnull, call DIE if MALLOC or REALLOC fails. DIE should not
+ return. DIE can be used by code that detects memory overflow
+ while calculating sizes to be passed to MALLOC or REALLOC. */
+ void (*die) (void);
+};
+
+#endif
=== added file 'lib/careadlinkat.c'
--- a/lib/careadlinkat.c 1970-01-01 00:00:00 +0000
+++ b/lib/careadlinkat.c 2011-04-05 18:19:19 +0000
@@ -0,0 +1,175 @@
+/* Read symbolic links into a buffer without size limitation, relative to fd.
+
+ Copyright (C) 2001, 2003-2004, 2007, 2009-2011 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#include <config.h>
+
+#include "careadlinkat.h"
+
+#include "allocator.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* 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)
+#endif
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
+
+#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. */
+ssize_t
+careadlinkatcwd (int fd, char const *filename, char *buffer,
+ size_t buffer_size)
+{
+ (void) fd;
+ 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
+ working directory, as in openat.
+
+ If the link is small enough to fit into BUFFER put it there.
+ BUFFER's size is BUFFER_SIZE, and BUFFER can be null
+ if BUFFER_SIZE is zero.
+
+ If the link is not small, put it into a dynamically allocated
+ buffer managed by ALLOC. It is the caller's responsibility to free
+ 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.
+
+ If successful, return the buffer address; otherwise return NULL and
+ set errno. */
+
+char *
+careadlinkat (int fd, char const *filename,
+ char *buffer, size_t buffer_size,
+ struct allocator const *alloc,
+ ssize_t (*preadlinkat) (int, char const *, char *, size_t))
+{
+ char *buf;
+ size_t buf_size;
+ size_t buf_size_max =
+ SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+ char stack_buf[1024];
+
+ if (! alloc)
+ alloc = &standard_allocator;
+
+ if (! buffer_size)
+ {
+ /* Allocate the initial buffer on the stack. This way, in the
+ common case of a symlink of small size, we get away with a
+ single small malloc() instead of a big malloc() followed by a
+ shrinking realloc(). */
+ buffer = stack_buf;
+ buffer_size = sizeof stack_buf;
+ }
+
+ buf = buffer;
+ buf_size = buffer_size;
+
+ do
+ {
+ /* Attempt to read the link into the current buffer. */
+ ssize_t link_length = preadlinkat (fd, filename, buf, buf_size);
+ size_t link_size;
+ if (link_length < 0)
+ {
+ /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1
+ with errno == ERANGE if the buffer is too small. */
+ int readlinkat_errno = errno;
+ if (readlinkat_errno != ERANGE)
+ {
+ if (buf != buffer)
+ {
+ alloc->free (buf);
+ errno = readlinkat_errno;
+ }
+ return NULL;
+ }
+ }
+
+ link_size = link_length;
+
+ if (link_size < buf_size)
+ {
+ buf[link_size++] = '\0';
+
+ if (buf == stack_buf)
+ {
+ char *b = (char *) alloc->malloc (link_size);
+ if (! b)
+ break;
+ memcpy (b, buf, link_size);
+ buf = b;
+ }
+ else if (link_size < buf_size && buf != buffer && alloc->realloc)
+ {
+ /* Shrink BUF before returning it. */
+ char *b = (char *) alloc->realloc (buf, link_size);
+ if (b)
+ buf = b;
+ }
+
+ return buf;
+ }
+
+ if (buf != buffer)
+ alloc->free (buf);
+
+ if (buf_size <= buf_size_max / 2)
+ buf_size *= 2;
+ else if (buf_size < buf_size_max)
+ buf_size = buf_size_max;
+ else
+ break;
+ buf = (char *) alloc->malloc (buf_size);
+ }
+ while (buf);
+
+ if (alloc->die)
+ alloc->die ();
+ errno = ENOMEM;
+ return NULL;
+}
=== added file 'lib/careadlinkat.h'
--- a/lib/careadlinkat.h 1970-01-01 00:00:00 +0000
+++ b/lib/careadlinkat.h 2011-04-01 06:28:48 +0000
@@ -0,0 +1,67 @@
+/* Read symbolic links into a buffer without size limitation, relative to fd.
+
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#ifndef _GL_CAREADLINKAT_H
+
+#include <fcntl.h>
+#include <unistd.h>
+
+struct allocator;
+
+/* 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
+ working directory, as in openat.
+
+ If the link is small enough to fit into BUFFER put it there.
+ BUFFER's size is BUFFER_SIZE, and BUFFER can be null
+ if BUFFER_SIZE is zero.
+
+ If the link is not small, put it into a dynamically allocated
+ 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.
+
+ If successful, return the buffer address; otherwise return NULL and
+ set errno. */
+
+char *careadlinkat (int fd, char const *filename,
+ char *buffer, size_t buffer_size,
+ struct allocator const *alloc,
+ ssize_t (*preadlinkat) (int, char const *,
+ char *, size_t));
+
+/* Suitable values for careadlinkat's FD and PREADLINKAT arguments,
+ when doing a plain readlink. */
+#if HAVE_READLINKAT
+# define careadlinkatcwd readlinkat
+#else
+/* Define AT_FDCWD independently, so that the careadlinkat module does
+ not depend on the fcntl-h module. The value does not matter, since
+ careadlinkatcwd ignores it, but we might as well use the same value
+ as fcntl-h. */
+# ifndef AT_FDCWD
+# define AT_FDCWD (-3041965)
+# endif
+ssize_t careadlinkatcwd (int fd, char const *filename,
+ char *buffer, size_t buffer_size);
+#endif
+
+#endif /* _GL_CAREADLINKAT_H */
=== modified file 'lib/gnulib.mk'
--- a/lib/gnulib.mk 2011-03-21 05:34:48 +0000
+++ b/lib/gnulib.mk 2011-04-01 06:28:48 +0000
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=.
--makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files
crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat
mktime readlink socklen stdio strftime symlink sys_stat
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=.
--makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files
careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value
intprops lstat mktime readlink socklen stdio strftime symlink sys_stat
MOSTLYCLEANFILES += core *.stackdump
@@ -69,6 +69,14 @@
## end gnulib module c++defs
+## begin gnulib module careadlinkat
+
+libgnu_a_SOURCES += careadlinkat.c
+
+EXTRA_DIST += allocator.h careadlinkat.h
+
+## end gnulib module careadlinkat
+
## begin gnulib module crypto/md5
=== modified file 'm4/gl-comp.m4'
--- a/m4/gl-comp.m4 2011-03-21 05:34:48 +0000
+++ b/m4/gl-comp.m4 2011-04-01 06:28:48 +0000
@@ -28,6 +28,7 @@
AC_REQUIRE([AC_PROG_RANLIB])
# Code from module arg-nonnull:
# Code from module c++defs:
+ # Code from module careadlinkat:
# Code from module crypto/md5:
# Code from module dosname:
# Code from module dtoastr:
@@ -46,6 +47,7 @@
# Code from module multiarch:
# Code from module readlink:
# Code from module socklen:
+ # Code from module ssize_t:
# Code from module stat:
# Code from module stdbool:
# Code from module stddef:
@@ -79,6 +81,8 @@
gl_source_base='lib'
# Code from module arg-nonnull:
# Code from module c++defs:
+ # Code from module careadlinkat:
+ AC_CHECK_FUNCS_ONCE([readlinkat])
# Code from module crypto/md5:
gl_MD5
# Code from module dosname:
@@ -115,6 +119,8 @@
gl_UNISTD_MODULE_INDICATOR([readlink])
# Code from module socklen:
gl_TYPE_SOCKLEN_T
+ # Code from module ssize_t:
+ gt_TYPE_SSIZE_T
# Code from module stat:
gl_FUNC_STAT
gl_SYS_STAT_MODULE_INDICATOR([stat])
@@ -287,6 +293,9 @@
build-aux/arg-nonnull.h
build-aux/c++defs.h
build-aux/warn-on-use.h
+ lib/allocator.h
+ lib/careadlinkat.c
+ lib/careadlinkat.h
lib/dosname.h
lib/dtoastr.c
lib/filemode.c
@@ -335,6 +344,7 @@
m4/multiarch.m4
m4/readlink.m4
m4/socklen.m4
+ m4/ssize_t.m4
m4/st_dm_mode.m4
m4/stat.m4
m4/stdbool.m4
=== added file 'm4/ssize_t.m4'
--- a/m4/ssize_t.m4 1970-01-01 00:00:00 +0000
+++ b/m4/ssize_t.m4 2011-04-01 06:28:48 +0000
@@ -0,0 +1,23 @@
+# ssize_t.m4 serial 5 (gettext-0.18.2)
+dnl Copyright (C) 2001-2003, 2006, 2010-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Test whether ssize_t is defined.
+
+AC_DEFUN([gt_TYPE_SSIZE_T],
+[
+ AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/types.h>]],
+ [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
+ return !x;]])],
+ [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
+ if test $gt_cv_ssize_t = no; then
+ AC_DEFINE([ssize_t], [int],
+ [Define as a signed type of the same size as size_t.])
+ fi
+])
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2011-04-04 01:10:13 +0000
+++ b/src/ChangeLog 2011-04-06 05:19:39 +0000
@@ -1,3 +1,167 @@
+2011-04-06 Paul Eggert <address@hidden>
+
+ Fix more problems found by GCC 4.6.0's static checks.
+
+ * xmenu.c (Fx_popup_dialog): Don't assume string is free of formats.
+
+ * menu.c (Fx_popup_menu): Don't assume error_name lacks printf formats.
+
+ * lisp.h (message, message_nolog, fatal): Mark as printf-like.
+
+ * xdisp.c (vmessage): Mark as a printf-like function.
+
+ * term.c (vfatal, maybe_fatal): Mark as printf-like functions.
+
+ * sound.c (sound_warning): Don't crash if arg contains a printf format.
+
+ * image.c (tiff_error_handler, tiff_warning_handler): Mark as
+ printf-like functions.
+ (tiff_load): Add casts to remove these marks before passing them
+ to system-supplied API.
+
+ * eval.c (Fsignal): Remove excess argument to 'fatal'.
+
+ * coding.c (EMIT_ONE_BYTE, EMIT_TWO_BYTES): Use unsigned, not int.
+ This avoids several warnings with gcc -Wstrict-overflow.
+ (DECODE_COMPOSITION_RULE): If the rule is invalid, goto invalid_code
+ directly, rather than having caller test rule sign. This avoids
+ some unnecessary tests.
+ * composite.h (COMPOSITION_ENCODE_RULE_VALID): New macro.
+ (COMPOSITION_ENCODE_RULE): Arguments now must be valid. This
+ affects only one use, in DECODE_COMPOSITION_RULE, which is changed.
+
+ * xfont.c (xfont_text_extents): Remove var that was set but not used.
+ (xfont_open): Avoid unnecessary tests.
+
+ * composite.c (composition_gstring_put_cache): Use unsigned integer.
+
+ * composite.h, composite.c (composition_gstring_put_cache):
+ Use EMACS_INT, not int, for length.
+
+ * composite.h (COMPOSITION_DECODE_REFS): New macro,
+ breaking out part of COMPOSITION_DECODE_RULE.
+ (COMPOSITION_DECODE_RULE): Use it.
+ * composite.c (get_composition_id): Remove unused local vars,
+ by using the new macro.
+
+ * textprop.c (set_text_properties_1): Change while to do-while,
+ since the condition is always true at first.
+
+ * intervals.c (graft_intervals_into_buffer): Mark var as used.
+ (interval_deletion_adjustment): Return unsigned value.
+ All uses changed.
+
+ * process.c (list_processes_1, create_pty, read_process_output):
+ (exec_sentinel): Remove vars that were set but not used.
+ (create_pty): Remove unnecessary "volatile"s.
+ (Fnetwork_interface_info): Avoid possibility of int overflow.
+ (read_process_output): Do adaptive read buffering even if carryover.
+ (read_process_output): Simplify nbytes computation if buffered.
+
+ * bytecode.c (exec_byte_code): Rename local to avoid shadowing.
+
+ * syntax.c (scan_words): Remove var that was set but not used.
+ (update_syntax_table): Use unsigned instead of int.
+
+ * lread.c (lisp_file_lexically_bound_p): Use ints rather than endptrs.
+ (lisp_file_lexically_bound_p, read1): Use unsigned instead of int.
+ (safe_to_load_p): Make the end-of-loop test the inverse of the in-loop.
+
+ * print.c (print_error_message): Avoid int overflow.
+
+ * font.c (font_list_entities): Redo for clarity,
+ so that reader need not know FONT_DPI_INDEX + 1 == FONT_SPACING_INDEX.
+
+ * font.c (font_find_for_lface, Ffont_get_glyphs): Remove unused vars.
+ (font_score): Avoid potential overflow in diff calculation.
+
+ * fns.c (substring_both): Remove var that is set but not used.
+ (sxhash): Redo loop for clarity and to avoid wraparound warning.
+
+ * eval.c (funcall_lambda): Rename local to avoid shadowing.
+
+ * alloc.c (mark_object_loop_halt, mark_object): Use size_t, not int.
+ Otherwise, GCC 4.6.0 optimizes the loop check away since the check
+ can always succeed if overflow has undefined behavior.
+
+ * search.c (boyer_moore, wordify): Remove vars set but not used.
+ (wordify): Omit three unnecessary tests.
+
+ * indent.c (MULTIBYTE_BYTES_WIDTH): Don't compute wide_column.
+ All callers changed. This avoids the need for an unused var.
+
+ * casefiddle.c (casify_region): Remove var that is set but not used.
+
+ * dired.c (file_name_completion): Remove var that is set but not used.
+
+ * fileio.c (Finsert_file_contents): Make EOF condition clearer.
+
+ * fileio.c (Finsert_file_contents): Avoid signed integer overflow.
+ (Finsert_file_contents): Remove unnecessary code checking fd.
+
+ * minibuf.c (read_minibuf_noninteractive): Use size_t for sizes.
+ Check for integer overflow on size calculations.
+
+ * buffer.c (Fprevious_overlay_change): Remove var that is set
+ but not used.
+
+ * keyboard.c (menu_bar_items, read_char_minibuf_menu_prompt):
+ Remove vars that are set but not used.
+ (timer_check_2): Don't assume timer-list and idle-timer-list are lists.
+ (timer_check_2): Mark vars as initialized.
+
+ * gtkutil.c (xg_get_file_with_chooser): Mark var as initialized.
+
+ * image.c (lookup_image): Remove var that is set but not used.
+ (xbm_load): Use parse_p, for gcc -Werror=unused-but-set-variable.
+
+ * fontset.c (Finternal_char_font, Ffontset_info): Remove vars
+ that are set but not used.
+
+ * xfns.c (make_invisible_cursor): Don't return garbage
+ if XCreateBitmapFromData fails (Bug#8410).
+
+ * xselect.c (x_get_local_selection, x_handle_property_notify):
+ Remove vars that are set but not used.
+
+ * xfns.c (x_create_tip_frame): Remove var that is set but not used.
+ (make_invisible_cursor): Initialize a possibly-uninitialized variable.
+
+ * xterm.c (x_scroll_bar_to_input_event) [!USE_GTK]:
+ Remove var that is set but not used.
+ (scroll_bar_windows_size): Now size_t, not int.
+ (x_send_scroll_bar_event): Use size_t, not int, for sizes.
+ Check for overflow.
+
+ * xfaces.c (realize_named_face): Remove vars that are set but not used.
+ (map_tty_color) [!defined MSDOS]: Likewise.
+
+ * term.c (tty_write_glyphs): Use size_t; this avoids overflow warning.
+
+ * coding.c: Remove vars that are set but not used.
+ (DECODE_COMPOSITION_RULE): Remove 2nd arg, which is unused.
+ All callers changed.
+ (decode_coding_utf_8, decode_coding_utf_16 decode_coding_emacs_mule):
+ (decode_coding_iso_2022, encode_coding_sjis, encode_coding_big5):
+ (decode_coding_charset): Remove vars that are set but not used.
+
+ * bytecode.c (Fbyte_code) [!defined BYTE_CODE_SAFE]: Remove var
+ that is set but not used.
+
+ * print.c (print_object): Remove var that is set but not used.
+
+ Replace 2 copies of readlink code with 1 gnulib version (Bug#8401).
+ The gnulib version avoids calling malloc in the usual case,
+ and on 64-bit hosts doesn't have some arbitrary 32-bit limits.
+ * fileio.c (Ffile_symlink_p): Use emacs_readlink.
+ * filelock.c (current_lock_owner): Likewise.
+ * lisp.h (READLINK_BUFSIZE, emacs_readlink): New function.
+ * sysdep.c: Include allocator.h, careadlinkat.h.
+ (emacs_no_realloc_allocator): New static constant.
+ (emacs_readlink): New function.
+ * deps.mk (sysdep.o): Depend on ../lib/allocator.h and on
+ ../lib/careadlinkat.h.
+
2011-04-04 Stefan Monnier <address@hidden>
* keyboard.c (safe_run_hook_funcall): Fix last change (don't stop at the
=== modified file 'src/alloc.c'
--- a/src/alloc.c 2011-03-31 04:24:03 +0000
+++ b/src/alloc.c 2011-04-03 05:41:46 +0000
@@ -5221,7 +5221,7 @@
links of a list, in mark_object. In debugging,
the call to abort will hit a breakpoint.
Normally this is zero and the check never goes off. */
-static int mark_object_loop_halt;
+static size_t mark_object_loop_halt;
static void
mark_vectorlike (struct Lisp_Vector *ptr)
@@ -5278,7 +5278,7 @@
void *po;
struct mem_node *m;
#endif
- int cdr_count = 0;
+ size_t cdr_count = 0;
loop:
=== modified file 'src/buffer.c'
--- a/src/buffer.c 2011-03-31 04:24:03 +0000
+++ b/src/buffer.c 2011-04-02 07:36:27 +0000
@@ -4047,7 +4047,6 @@
the value is (point-min). */)
(Lisp_Object pos)
{
- int noverlays;
EMACS_INT prevpos;
Lisp_Object *overlay_vec;
int len;
@@ -4065,8 +4064,8 @@
/* Put all the overlays we want in a vector in overlay_vec.
Store the length in len.
prevpos gets the position of the previous change. */
- noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len,
- (EMACS_INT *) 0, &prevpos, 1);
+ overlays_at (XINT (pos), 1, &overlay_vec, &len,
+ (EMACS_INT *) 0, &prevpos, 1);
xfree (overlay_vec);
return make_number (prevpos);
=== modified file 'src/bytecode.c'
--- a/src/bytecode.c 2011-04-01 15:16:50 +0000
+++ b/src/bytecode.c 2011-04-04 07:55:46 +0000
@@ -447,8 +447,8 @@
#ifdef BYTE_CODE_SAFE
int const_length = XVECTOR (vector)->size;
Lisp_Object *stacke;
-#endif
int bytestr_length;
+#endif
struct byte_stack stack;
Lisp_Object *top;
Lisp_Object result;
@@ -475,7 +475,9 @@
convert them back to the originally intended unibyte form. */
bytestr = Fstring_as_unibyte (bytestr);
+#ifdef BYTE_CODE_SAFE
bytestr_length = SBYTES (bytestr);
+#endif
vectorp = XVECTOR (vector)->contents;
stack.byte_string = bytestr;
@@ -936,12 +938,12 @@
case Bsave_window_excursion: /* Obsolete since 24.1. */
{
- register int count = SPECPDL_INDEX ();
+ register int count1 = SPECPDL_INDEX ();
record_unwind_protect (Fset_window_configuration,
Fcurrent_window_configuration (Qnil));
BEFORE_POTENTIAL_GC ();
TOP = Fprogn (TOP);
- unbind_to (count, TOP);
+ unbind_to (count1, TOP);
AFTER_POTENTIAL_GC ();
break;
}
=== modified file 'src/casefiddle.c'
--- a/src/casefiddle.c 2011-03-15 21:14:06 +0000
+++ b/src/casefiddle.c 2011-04-03 00:33:43 +0000
@@ -200,7 +200,7 @@
register int inword = flag == CASE_DOWN;
register int multibyte = !NILP (BVAR (current_buffer,
enable_multibyte_characters));
EMACS_INT start, end;
- EMACS_INT start_byte, end_byte;
+ EMACS_INT start_byte;
/* Position of first and last changes. */
EMACS_INT first = -1, last IF_LINT (= 0);
@@ -222,7 +222,6 @@
modify_region (current_buffer, start, end, 0);
record_change (start, end - start);
start_byte = CHAR_TO_BYTE (start);
- end_byte = CHAR_TO_BYTE (end);
SETUP_BUFFER_SYNTAX_TABLE(); /* For syntax_prefix_flag_p. */
=== modified file 'src/coding.c'
--- a/src/coding.c 2011-03-29 23:35:49 +0000
+++ b/src/coding.c 2011-04-05 06:41:53 +0000
@@ -753,7 +753,7 @@
produced_chars++; \
if (multibytep) \
{ \
- int ch = (c); \
+ unsigned ch = (c); \
if (ch >= 0x80) \
ch = BYTE8_TO_CHAR (ch); \
CHAR_STRING_ADVANCE (ch, dst); \
@@ -770,7 +770,7 @@
produced_chars += 2; \
if (multibytep) \
{ \
- int ch; \
+ unsigned ch; \
\
ch = (c1); \
if (ch >= 0x80) \
@@ -1296,13 +1296,10 @@
int consumed_chars = 0, consumed_chars_base = 0;
int multibytep = coding->src_multibyte;
enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
- Lisp_Object attr, charset_list;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
- CODING_GET_INFO (coding, attr, charset_list);
-
if (bom != utf_without_bom)
{
int c1, c2, c3;
@@ -1610,13 +1607,10 @@
enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
int surrogate = CODING_UTF_16_SURROGATE (coding);
- Lisp_Object attr, charset_list;
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr1 = -1, byte_after_cr2 = -1;
- CODING_GET_INFO (coding, attr, charset_list);
-
if (bom == utf_with_bom)
{
int c, c1, c2;
@@ -1736,11 +1730,8 @@
enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
int produced_chars = 0;
- Lisp_Object attrs, charset_list;
int c;
- CODING_GET_INFO (coding, attrs, charset_list);
-
if (bom != utf_without_bom)
{
ASSURE_DESTINATION (safe_room);
@@ -2342,7 +2333,6 @@
= coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
- Lisp_Object attrs, charset_list;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
@@ -2351,8 +2341,6 @@
int byte_after_cr = -1;
struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
- CODING_GET_INFO (coding, attrs, charset_list);
-
if (cmp_status->state != COMPOSING_NO)
{
int i;
@@ -3265,15 +3253,14 @@
*/
/* Decode a composition rule C1 and maybe one more byte from the
- source, and set RULE to the encoded composition rule, NBYTES to the
- length of the composition rule. If the rule is invalid, set RULE
- to some negative value. */
+ source, and set RULE to the encoded composition rule. If the rule
+ is invalid, goto invalid_code. */
-#define DECODE_COMPOSITION_RULE(rule, nbytes) \
+#define DECODE_COMPOSITION_RULE(rule) \
do { \
rule = c1 - 32; \
if (rule < 0) \
- break; \
+ goto invalid_code; \
if (rule < 81) /* old format (before ver.21) */ \
{
\
int gref = (rule) / 9; \
@@ -3281,17 +3268,16 @@
if (gref == 4) gref = 10; \
if (nref == 4) nref = 10; \
rule = COMPOSITION_ENCODE_RULE (gref, nref); \
- nbytes = 1; \
}
\
else /* new format (after ver.21) */ \
{
\
int b; \
\
ONE_MORE_BYTE (b); \
+ if (! COMPOSITION_ENCODE_RULE_VALID (rule - 81, b - 32)) \
+ goto invalid_code; \
rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \
- if (rule >= 0) \
- rule += 0x100; /* to destinguish it from the old format */ \
- nbytes = 2; \
+ rule += 0x100; /* Distinguish it from the old format. */ \
}
\
} while (0)
@@ -3476,7 +3462,7 @@
struct charset *charset;
int c;
struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding);
- Lisp_Object attrs, charset_list;
+ Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
@@ -3485,10 +3471,7 @@
int byte_after_cr = -1;
int i;
- CODING_GET_INFO (coding, attrs, charset_list);
setup_iso_safe_charsets (attrs);
- /* Charset list may have been changed. */
- charset_list = CODING_ATTR_CHARSET_LIST (attrs);
coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs));
if (cmp_status->state != COMPOSING_NO)
@@ -3558,11 +3541,9 @@
|| cmp_status->state == COMPOSING_COMPONENT_RULE)
&& c1 != ISO_CODE_ESC)
{
- int rule, nbytes;
+ int rule;
- DECODE_COMPOSITION_RULE (rule, nbytes);
- if (rule < 0)
- goto invalid_code;
+ DECODE_COMPOSITION_RULE (rule);
STORE_COMPOSITION_RULE (rule);
continue;
}
@@ -4878,13 +4859,12 @@
int produced_chars = 0;
Lisp_Object attrs, charset_list, val;
int ascii_compatible;
- struct charset *charset_roman, *charset_kanji, *charset_kana;
+ struct charset *charset_kanji, *charset_kana;
struct charset *charset_kanji2;
int c;
CODING_GET_INFO (coding, attrs, charset_list);
- val = charset_list;
- charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
+ val = XCDR (charset_list);
charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val)));
@@ -4970,12 +4950,11 @@
int produced_chars = 0;
Lisp_Object attrs, charset_list, val;
int ascii_compatible;
- struct charset *charset_roman, *charset_big5;
+ struct charset *charset_big5;
int c;
CODING_GET_INFO (coding, attrs, charset_list);
- val = charset_list;
- charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
+ val = XCDR (charset_list);
charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
@@ -5433,7 +5412,8 @@
= coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
- Lisp_Object attrs, charset_list, valids;
+ Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
+ Lisp_Object valids;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
@@ -5441,7 +5421,6 @@
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
- CODING_GET_INFO (coding, attrs, charset_list);
valids = AREF (attrs, coding_attr_charset_valids);
while (1)
=== modified file 'src/composite.c'
--- a/src/composite.c 2011-03-19 01:02:49 +0000
+++ b/src/composite.c 2011-04-05 05:11:14 +0000
@@ -354,7 +354,7 @@
for (i = 1; i < glyph_len; i += 2)
{
- int rule, gref, nref, xoff, yoff;
+ int rule, gref, nref;
int this_width;
float this_left;
@@ -376,7 +376,7 @@
| |
6---7---8 -- descent
*/
- COMPOSITION_DECODE_RULE (rule, gref, nref, xoff, yoff);
+ COMPOSITION_DECODE_REFS (rule, gref, nref);
this_left = (leftmost
+ (gref % 3) * (rightmost - leftmost) / 2.0
- (nref % 3) * this_width / 2.0);
@@ -661,22 +661,22 @@
}
Lisp_Object
-composition_gstring_put_cache (Lisp_Object gstring, int len)
+composition_gstring_put_cache (Lisp_Object gstring, EMACS_INT len)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
unsigned hash;
Lisp_Object header, copy;
- int i;
+ EMACS_INT i;
header = LGSTRING_HEADER (gstring);
hash = h->hashfn (h, header);
if (len < 0)
{
- len = LGSTRING_GLYPH_LEN (gstring);
- for (i = 0; i < len; i++)
- if (NILP (LGSTRING_GLYPH (gstring, i)))
+ EMACS_UINT j, glyph_len = LGSTRING_GLYPH_LEN (gstring);
+ for (j = 0; j < glyph_len; j++)
+ if (NILP (LGSTRING_GLYPH (gstring, j)))
break;
- len = i;
+ len = j;
}
copy = Fmake_vector (make_number (len + 2), Qnil);
=== modified file 'src/composite.h'
--- a/src/composite.h 2011-01-25 04:08:28 +0000
+++ b/src/composite.h 2011-04-05 06:41:53 +0000
@@ -126,27 +126,37 @@
->contents[(n) * 2 - 1])
/* Decode encoded composition rule RULE_CODE into GREF (global
- reference point code), NREF (new reference point code), XOFF
- (horizontal offset) YOFF (vertical offset). Don't check RULE_CODE,
+ reference point code), NREF (new ref. point code). Don't check RULE_CODE;
always set GREF and NREF to valid values. By side effect,
RULE_CODE is modified. */
-#define COMPOSITION_DECODE_RULE(rule_code, gref, nref, xoff, yoff) \
+#define COMPOSITION_DECODE_REFS(rule_code, gref, nref) \
do { \
- xoff = (rule_code) >> 16; \
- yoff = ((rule_code) >> 8) & 0xFF; \
rule_code &= 0xFF; \
gref = (rule_code) / 12; \
if (gref > 12) gref = 11; \
nref = (rule_code) % 12; \
} while (0)
+/* Like COMPOSITION_DECODE_REFS (RULE_CODE, GREF, NREF), but also
+ decode RULE_CODE into XOFF and YOFF (vertical offset). */
+
+#define COMPOSITION_DECODE_RULE(rule_code, gref, nref, xoff, yoff) \
+ do { \
+ xoff = (rule_code) >> 16; \
+ yoff = ((rule_code) >> 8) & 0xFF; \
+ COMPOSITION_DECODE_REFS (rule_code, gref, nref); \
+ } while (0)
+
+/* Nonzero if the global reference point GREF and new reference point NREF are
+ valid. */
+#define COMPOSITION_ENCODE_RULE_VALID(gref, nref) \
+ ((unsigned) (gref) < 12 && (unsigned) (nref) < 12)
+
/* Return encoded composition rule for the pair of global reference
- point GREF and new reference point NREF. If arguments are invalid,
- return -1. */
+ point GREF and new reference point NREF. Arguments must be valid. */
#define COMPOSITION_ENCODE_RULE(gref, nref) \
- ((unsigned) (gref) < 12 && (unsigned) (nref) < 12 \
- ? (gref) * 12 + (nref) : -1)
+ ((gref) * 12 + (nref))
/* Data structure that records information about a composition
currently used in some buffers or strings.
@@ -281,7 +291,7 @@
else \
ASET ((g), LGLYPH_IX_CODE, make_number (val)); \
} while (0)
-
+
#define LGLYPH_SET_WIDTH(g, val) ASET ((g), LGLYPH_IX_WIDTH, make_number (val))
#define LGLYPH_SET_LBEARING(g, val) ASET ((g), LGLYPH_IX_LBEARING, make_number
(val))
#define LGLYPH_SET_RBEARING(g, val) ASET ((g), LGLYPH_IX_RBEARING, make_number
(val))
@@ -300,7 +310,7 @@
struct face;
struct font_metrics;
-extern Lisp_Object composition_gstring_put_cache (Lisp_Object, int);
+extern Lisp_Object composition_gstring_put_cache (Lisp_Object, EMACS_INT);
extern Lisp_Object composition_gstring_from_id (int);
extern int composition_gstring_p (Lisp_Object);
extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT,
@@ -321,4 +331,3 @@
EXFUN (Fcomposition_get_gstring, 4);
#endif /* not EMACS_COMPOSITE_H */
-
=== modified file 'src/deps.mk'
--- a/src/deps.mk 2011-03-19 22:46:50 +0000
+++ b/src/deps.mk 2011-04-01 06:38:52 +0000
@@ -187,6 +187,7 @@
process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \
frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \
globals.h $(config_h) composite.h sysselect.h gnutls.h \
+ ../lib/allocator.h ../lib/careadlinkat.h \
../lib/unistd.h ../lib/ignore-value.h
term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \
cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \
=== modified file 'src/dired.c'
--- a/src/dired.c 2011-03-15 21:14:06 +0000
+++ b/src/dired.c 2011-04-03 00:32:58 +0000
@@ -639,8 +639,6 @@
{
Lisp_Object regexps;
- Lisp_Object zero;
- XSETFASTINT (zero, 0);
/* Ignore this element if it fails to match all the regexps. */
if (completion_ignore_case)
=== modified file 'src/eval.c'
--- a/src/eval.c 2011-04-02 13:11:16 +0000
+++ b/src/eval.c 2011-04-05 20:01:08 +0000
@@ -1757,7 +1757,7 @@
data = Fcons (error_symbol, data);
string = Ferror_message_string (data);
- fatal ("%s", SDATA (string), 0);
+ fatal ("%s", SDATA (string));
}
/* Internal version of Fsignal that never returns.
@@ -3206,26 +3206,26 @@
optional = 1;
else
{
- Lisp_Object val;
+ Lisp_Object arg;
if (rest)
{
- val = Flist (nargs - i, &arg_vector[i]);
+ arg = Flist (nargs - i, &arg_vector[i]);
i = nargs;
}
else if (i < nargs)
- val = arg_vector[i++];
+ arg = arg_vector[i++];
else if (!optional)
xsignal2 (Qwrong_number_of_arguments, fun, make_number (nargs));
else
- val = Qnil;
+ arg = Qnil;
/* Bind the argument. */
if (!NILP (lexenv) && SYMBOLP (next))
/* Lexically bind NEXT by adding it to the lexenv alist. */
- lexenv = Fcons (Fcons (next, val), lexenv);
+ lexenv = Fcons (Fcons (next, arg), lexenv);
else
/* Dynamically bind NEXT. */
- specbind (next, val);
+ specbind (next, arg);
}
}
=== modified file 'src/fileio.c'
--- a/src/fileio.c 2011-03-25 17:37:15 +0000
+++ b/src/fileio.c 2011-04-03 00:32:10 +0000
@@ -2579,9 +2579,8 @@
{
Lisp_Object handler;
char *buf;
- int bufsize;
- int valsize;
Lisp_Object val;
+ char readlink_buf[READLINK_BUFSIZE];
CHECK_STRING (filename);
filename = Fexpand_file_name (filename, Qnil);
@@ -2594,36 +2593,15 @@
filename = ENCODE_FILE (filename);
- bufsize = 50;
- buf = NULL;
- do
- {
- bufsize *= 2;
- buf = (char *) xrealloc (buf, bufsize);
- memset (buf, 0, bufsize);
-
- errno = 0;
- valsize = readlink (SSDATA (filename), buf, bufsize);
- if (valsize == -1)
- {
-#ifdef ERANGE
- /* HP-UX reports ERANGE if buffer is too small. */
- if (errno == ERANGE)
- valsize = bufsize;
- else
-#endif
- {
- xfree (buf);
- return Qnil;
- }
- }
- }
- while (valsize >= bufsize);
-
- val = make_string (buf, valsize);
+ buf = emacs_readlink (SSDATA (filename), readlink_buf);
+ if (! buf)
+ return Qnil;
+
+ val = build_string (buf);
if (buf[0] == '/' && strchr (buf, ':'))
val = concat2 (build_string ("/:"), val);
- xfree (buf);
+ if (buf != readlink_buf)
+ xfree (buf);
val = DECODE_FILE (val);
return val;
}
@@ -3225,7 +3203,6 @@
if (stat (SSDATA (filename), &st) < 0)
#endif /* WINDOWSNT */
{
- if (fd >= 0) emacs_close (fd);
badopen:
if (NILP (visit))
report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
@@ -3261,9 +3238,16 @@
record_unwind_protect (close_file_unwind, make_number (fd));
- /* Can happen on any platform that uses long as type of off_t, but allows
- file sizes to exceed 2Gb, so give a suitable message. */
- if (! not_regular && st.st_size < 0)
+
+ /* Arithmetic overflow can occur if an Emacs integer cannot represent the
+ file size, or if the calculations below overflow. The calculations below
+ double the file size twice, so check that it can be multiplied by 4
+ safely.
+
+ Also check whether the size is negative, which can happen on a platform
+ that allows file sizes greater than the maximum off_t value. */
+ if (! not_regular
+ && ! (0 <= st.st_size && st.st_size <= MOST_POSITIVE_FIXNUM / 4))
error ("Maximum buffer size exceeded");
/* Prevent redisplay optimizations. */
@@ -3290,18 +3274,6 @@
{
XSETINT (end, st.st_size);
- /* Arithmetic overflow can occur if an Emacs integer cannot
- represent the file size, or if the calculations below
- overflow. The calculations below double the file size
- twice, so check that it can be multiplied by 4 safely. */
- if (XINT (end) != st.st_size
- /* Actually, it should test either INT_MAX or LONG_MAX
- depending on which one is used for EMACS_INT. But in
- any case, in practice, this test is redundant with the
- one above.
- || st.st_size > INT_MAX / 4 */)
- error ("Maximum buffer size exceeded");
-
/* The file size returned from stat may be zero, but data
may be readable nonetheless, for example when this is a
file in the /proc filesystem. */
@@ -3635,6 +3607,7 @@
EMACS_INT bufpos;
unsigned char *decoded;
EMACS_INT temp;
+ EMACS_INT this = 0;
int this_count = SPECPDL_INDEX ();
int multibyte = ! NILP (BVAR (current_buffer,
enable_multibyte_characters));
Lisp_Object conversion_buffer;
@@ -3661,7 +3634,6 @@
/* try is reserved in some compilers (Microsoft C) */
EMACS_INT trytry = min (total - how_much,
READ_BUF_SIZE - unprocessed);
- EMACS_INT this;
/* Allow quitting out of the actual I/O. */
immediate_quit = 1;
@@ -3670,11 +3642,7 @@
immediate_quit = 0;
if (this <= 0)
- {
- if (this < 0)
- how_much = this;
- break;
- }
+ break;
how_much += this;
@@ -3697,7 +3665,7 @@
/* At this point, HOW_MUCH should equal TOTAL, or should be <= 0
if we couldn't read the file. */
- if (how_much < 0)
+ if (this < 0)
error ("IO error reading %s: %s",
SDATA (orig_filename), emacs_strerror (errno));
=== modified file 'src/filelock.c'
--- a/src/filelock.c 2011-03-15 01:19:50 +0000
+++ b/src/filelock.c 2011-04-01 06:28:48 +0000
@@ -396,36 +396,16 @@
static int
current_lock_owner (lock_info_type *owner, char *lfname)
{
- int len, ret;
+ int ret;
+ size_t len;
int local_owner = 0;
char *at, *dot, *colon;
- char *lfinfo = 0;
- int bufsize = 50;
- /* Read arbitrarily-long contents of symlink. Similar code in
- file-symlink-p in fileio.c. */
- do
- {
- bufsize *= 2;
- lfinfo = (char *) xrealloc (lfinfo, bufsize);
- errno = 0;
- len = readlink (lfname, lfinfo, bufsize);
-#ifdef ERANGE
- /* HP-UX reports ERANGE if the buffer is too small. */
- if (len == -1 && errno == ERANGE)
- len = bufsize;
-#endif
- }
- while (len >= bufsize);
+ char readlink_buf[READLINK_BUFSIZE];
+ char *lfinfo = emacs_readlink (lfname, readlink_buf);
/* If nonexistent lock file, all is well; otherwise, got strange error. */
- if (len == -1)
- {
- xfree (lfinfo);
- return errno == ENOENT ? 0 : -1;
- }
-
- /* Link info exists, so `len' is its length. Null terminate. */
- lfinfo[len] = 0;
+ if (!lfinfo)
+ return errno == ENOENT ? 0 : -1;
/* Even if the caller doesn't want the owner info, we still have to
read it to determine return value, so allocate it. */
@@ -441,7 +421,8 @@
dot = strrchr (lfinfo, '.');
if (!at || !dot)
{
- xfree (lfinfo);
+ if (lfinfo != readlink_buf)
+ xfree (lfinfo);
return -1;
}
len = at - lfinfo;
@@ -467,7 +448,8 @@
owner->host[len] = 0;
/* We're done looking at the link info. */
- xfree (lfinfo);
+ if (lfinfo != readlink_buf)
+ xfree (lfinfo);
/* On current host? */
if (STRINGP (Fsystem_name ())
=== modified file 'src/fns.c'
--- a/src/fns.c 2011-03-31 04:24:03 +0000
+++ b/src/fns.c 2011-04-06 04:34:35 +0000
@@ -1247,17 +1247,10 @@
{
Lisp_Object res;
EMACS_INT size;
- EMACS_INT size_byte;
CHECK_VECTOR_OR_STRING (string);
- if (STRINGP (string))
- {
- size = SCHARS (string);
- size_byte = SBYTES (string);
- }
- else
- size = ASIZE (string);
+ size = STRINGP (string) ? SCHARS (string) : ASIZE (string);
if (!(0 <= from && from <= to && to <= size))
args_out_of_range_3 (string, make_number (from), make_number (to));
@@ -4226,9 +4219,9 @@
{
double val = XFLOAT_DATA (obj);
unsigned char *p = (unsigned char *) &val;
- unsigned char *e = p + sizeof val;
- for (hash = 0; p < e; ++p)
- hash = SXHASH_COMBINE (hash, *p);
+ size_t i;
+ for (hash = 0, i = 0; i < sizeof val; i++)
+ hash = SXHASH_COMBINE (hash, p[i]);
break;
}
=== modified file 'src/font.c'
--- a/src/font.c 2011-03-27 02:12:36 +0000
+++ b/src/font.c 2011-04-04 06:29:11 +0000
@@ -2076,12 +2076,11 @@
for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++)
if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i]))
{
- int diff = (XINT (AREF (entity, i)) >> 8) - (XINT (spec_prop[i]) >> 8);
-
+ EMACS_INT diff = ((XINT (AREF (entity, i)) >> 8)
+ - (XINT (spec_prop[i]) >> 8));
if (diff < 0)
diff = - diff;
- if (diff > 0)
- score |= min (diff, 127) << sort_shift_bits[i];
+ score |= min (diff, 127) << sort_shift_bits[i];
}
/* Score the size. Maximum difference is 127. */
@@ -2698,14 +2697,12 @@
for (i = FONT_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; i++)
ASET (scratch_font_spec, i, AREF (spec, i));
for (i = FONT_WEIGHT_INDEX; i < FONT_EXTRA_INDEX; i++)
- {
- ASET (scratch_font_spec, i, Qnil);
- if (! NILP (AREF (spec, i)))
- need_filtering = 1;
- if (i == FONT_DPI_INDEX)
- /* Skip FONT_SPACING_INDEX */
- i++;
- }
+ if (i != FONT_SPACING_INDEX)
+ {
+ ASET (scratch_font_spec, i, Qnil);
+ if (! NILP (AREF (spec, i)))
+ need_filtering = 1;
+ }
ASET (scratch_font_spec, FONT_SPACING_INDEX, AREF (spec,
FONT_SPACING_INDEX));
ASET (scratch_font_spec, FONT_EXTRA_INDEX, AREF (spec, FONT_EXTRA_INDEX));
@@ -3071,7 +3068,7 @@
{
Lisp_Object work;
Lisp_Object frame, entities, val;
- Lisp_Object size, foundry[3], *family, registry[3], adstyle[3];
+ Lisp_Object foundry[3], *family, registry[3], adstyle[3];
int pixel_size;
int i, j, k, l;
@@ -3102,7 +3099,6 @@
work = Fcopy_font_spec (spec);
ASET (work, FONT_TYPE_INDEX, AREF (spec, FONT_TYPE_INDEX));
XSETFRAME (frame, f);
- size = AREF (spec, FONT_SIZE_INDEX);
pixel_size = font_pixel_size (f, spec);
if (pixel_size == 0 && INTEGERP (attrs[LFACE_HEIGHT_INDEX]))
{
@@ -4723,10 +4719,9 @@
Lisp_Object g;
int c = XFASTINT (chars[i]);
unsigned code;
- EMACS_INT cod;
struct font_metrics metrics;
- cod = code = font->driver->encode_char (font, c);
+ code = font->driver->encode_char (font, c);
if (code == FONT_INVALID_CODE)
continue;
g = Fmake_vector (make_number (LGLYPH_SIZE), Qnil);
=== modified file 'src/fontset.c'
--- a/src/fontset.c 2011-03-10 01:48:47 +0000
+++ b/src/fontset.c 2011-04-02 02:25:18 +0000
@@ -1815,7 +1815,6 @@
int c;
struct frame *f;
struct face *face;
- int cs_id;
if (NILP (position))
{
@@ -1824,11 +1823,10 @@
f = XFRAME (selected_frame);
face_id = lookup_basic_face (f, DEFAULT_FACE_ID);
pos = -1;
- cs_id = -1;
}
else
{
- Lisp_Object window, charset;
+ Lisp_Object window;
struct window *w;
CHECK_NUMBER_COERCE_MARKER (position);
@@ -1850,11 +1848,6 @@
f = XFRAME (w->frame);
face_id = face_at_buffer_position (w, pos, -1, -1, &dummy,
pos + 100, 0, -1);
- charset = Fget_char_property (position, Qcharset, Qnil);
- if (CHARSETP (charset))
- cs_id = XINT (CHARSET_SYMBOL_ID (charset));
- else
- cs_id = -1;
}
if (! CHAR_VALID_P (c, 0))
return Qnil;
@@ -1900,7 +1893,6 @@
format is the same as above. */)
(Lisp_Object fontset, Lisp_Object frame)
{
- FRAME_PTR f;
Lisp_Object *realized[2], fontsets[2], tables[2];
Lisp_Object val, elt;
int c, i, j, k;
@@ -1908,7 +1900,6 @@
(*check_window_system_func) ();
fontset = check_fontset_name (fontset, &frame);
- f = XFRAME (frame);
/* Recode fontsets realized on FRAME from the base fontset FONTSET
in the table `realized'. */
=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c 2011-03-26 01:23:15 +0000
+++ b/src/gtkutil.c 2011-04-02 02:39:52 +0000
@@ -1704,7 +1704,7 @@
{
char msgbuf[1024];
- GtkWidget *filewin, *wtoggle, *wbox, *wmessage;
+ GtkWidget *filewin, *wtoggle, *wbox, *wmessage IF_LINT (= NULL);
GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
GtkFileChooserAction action = (mustmatch_p ?
GTK_FILE_CHOOSER_ACTION_OPEN :
=== modified file 'src/image.c'
--- a/src/image.c 2011-03-31 04:24:03 +0000
+++ b/src/image.c 2011-04-05 20:06:52 +0000
@@ -1708,7 +1708,6 @@
int
lookup_image (struct frame *f, Lisp_Object spec)
{
- struct image_cache *c;
struct image *img;
unsigned hash;
EMACS_TIME now;
@@ -1718,8 +1717,6 @@
xassert (FRAME_WINDOW_P (f));
xassert (valid_image_p (spec));
- c = FRAME_IMAGE_CACHE (f);
-
/* Look up SPEC in the hash table of the image cache. */
hash = sxhash (spec, 0);
img = search_image_cache (f, spec, hash);
@@ -2878,6 +2875,7 @@
/* Parse the image specification. */
memcpy (fmt, xbm_format, sizeof fmt);
parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm);
+ (void) parsed_p;
xassert (parsed_p);
/* Get specified width, and height. */
@@ -6716,6 +6714,8 @@
}
+static void tiff_error_handler (const char *, const char *, va_list)
+ ATTRIBUTE_FORMAT_PRINTF (2, 0);
static void
tiff_error_handler (const char *title, const char *format, va_list ap)
{
@@ -6728,6 +6728,8 @@
}
+static void tiff_warning_handler (const char *, const char *, va_list)
+ ATTRIBUTE_FORMAT_PRINTF (2, 0);
static void
tiff_warning_handler (const char *title, const char *format, va_list ap)
{
@@ -6759,8 +6761,8 @@
specified_file = image_spec_value (img->spec, QCfile, NULL);
specified_data = image_spec_value (img->spec, QCdata, NULL);
- fn_TIFFSetErrorHandler (tiff_error_handler);
- fn_TIFFSetWarningHandler (tiff_warning_handler);
+ fn_TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler);
+ fn_TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler);
if (NILP (specified_data))
{
=== modified file 'src/indent.c'
--- a/src/indent.c 2011-03-31 01:37:51 +0000
+++ b/src/indent.c 2011-04-03 01:00:03 +0000
@@ -271,14 +271,13 @@
DP is a display table or NULL.
- This macro is used in current_column_1, Fmove_to_column, and
+ This macro is used in scan_for_column and in
compute_motion. */
#define MULTIBYTE_BYTES_WIDTH(p, dp, bytes, width) \
do { \
int ch; \
\
- wide_column = 0; \
ch = STRING_CHAR_AND_LENGTH (p, bytes); \
if (BYTES_BY_CHAR_HEAD (*p) != bytes) \
width = bytes * 4; \
@@ -288,8 +287,6 @@
width = XVECTOR (DISP_CHAR_VECTOR (dp, ch))->size; \
else \
width = CHAR_WIDTH (ch); \
- if (width > 1) \
- wide_column = width; \
}
\
} while (0)
@@ -666,7 +663,7 @@
{
/* Start of multi-byte form. */
unsigned char *ptr;
- int bytes, width, wide_column;
+ int bytes, width;
ptr = BYTE_POS_ADDR (scan_byte);
MULTIBYTE_BYTES_WIDTH (ptr, dp, bytes, width);
@@ -1657,14 +1654,14 @@
{
/* Start of multi-byte form. */
unsigned char *ptr;
- int mb_bytes, mb_width, wide_column;
+ int mb_bytes, mb_width;
pos_byte--; /* rewind POS_BYTE */
ptr = BYTE_POS_ADDR (pos_byte);
MULTIBYTE_BYTES_WIDTH (ptr, dp, mb_bytes, mb_width);
pos_byte += mb_bytes;
- if (wide_column)
- wide_column_end_hpos = hpos + wide_column;
+ if (mb_width > 1 && BYTES_BY_CHAR_HEAD (*ptr) == mb_bytes)
+ wide_column_end_hpos = hpos + mb_width;
hpos += mb_width;
}
else if (VECTORP (charvec))
=== modified file 'src/intervals.c'
--- a/src/intervals.c 2011-03-21 05:34:48 +0000
+++ b/src/intervals.c 2011-04-04 16:47:31 +0000
@@ -1312,7 +1312,7 @@
Do this by recursing down TREE to the interval in question, and
deleting the appropriate amount of text. */
-static EMACS_INT
+static EMACS_UINT
interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
register EMACS_INT amount)
{
@@ -1324,7 +1324,7 @@
/* Left branch */
if (relative_position < LEFT_TOTAL_LENGTH (tree))
{
- EMACS_INT subtract = interval_deletion_adjustment (tree->left,
+ EMACS_UINT subtract = interval_deletion_adjustment (tree->left,
relative_position,
amount);
tree->total_length -= subtract;
@@ -1335,7 +1335,7 @@
else if (relative_position >= (TOTAL_LENGTH (tree)
- RIGHT_TOTAL_LENGTH (tree)))
{
- EMACS_INT subtract;
+ EMACS_UINT subtract;
relative_position -= (tree->total_length
- RIGHT_TOTAL_LENGTH (tree));
@@ -1377,7 +1377,7 @@
adjust_intervals_for_deletion (struct buffer *buffer,
EMACS_INT start, EMACS_INT length)
{
- register EMACS_INT left_to_delete = length;
+ register EMACS_UINT left_to_delete = length;
register INTERVAL tree = BUF_INTERVALS (buffer);
Lisp_Object parent;
EMACS_INT offset;
@@ -1677,7 +1677,7 @@
EMACS_INT length, struct buffer *buffer,
int inherit)
{
- register INTERVAL under, over, this, prev;
+ register INTERVAL under, over, this;
register INTERVAL tree;
EMACS_INT over_used;
@@ -1767,7 +1767,8 @@
/* This call may have some effect because previous_interval may
update `position' fields of intervals. Thus, don't ignore it
for the moment. Someone please tell me the truth (K.Handa). */
- prev = previous_interval (under);
+ INTERVAL prev = previous_interval (under);
+ (void) prev;
#if 0
/* But, this code surely has no effect. And, anyway,
END_NONSTICKY_P is unreliable now. */
=== modified file 'src/keyboard.c'
--- a/src/keyboard.c 2011-04-04 01:10:13 +0000
+++ b/src/keyboard.c 2011-04-05 06:45:27 +0000
@@ -4234,7 +4234,8 @@
timer_check_2 (void)
{
EMACS_TIME nexttime;
- EMACS_TIME now, idleness_now;
+ EMACS_TIME now;
+ EMACS_TIME idleness_now IF_LINT (= {0});
Lisp_Object timers, idle_timers, chosen_timer;
struct gcpro gcpro1, gcpro2, gcpro3;
@@ -4271,10 +4272,12 @@
Lisp_Object *vector;
Lisp_Object timer = Qnil, idle_timer = Qnil;
EMACS_TIME timer_time, idle_timer_time;
- EMACS_TIME difference, timer_difference, idle_timer_difference;
+ EMACS_TIME difference;
+ EMACS_TIME timer_difference IF_LINT (= {0});
+ EMACS_TIME idle_timer_difference IF_LINT (= {0});
/* Skip past invalid timers and timers already handled. */
- if (!NILP (timers))
+ if (CONSP (timers))
{
timer = XCAR (timers);
if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
@@ -4292,7 +4295,7 @@
continue;
}
}
- if (!NILP (idle_timers))
+ if (CONSP (idle_timers))
{
timer = XCAR (idle_timers);
if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
@@ -4315,7 +4318,7 @@
based on the next ordinary timer.
TIMER_DIFFERENCE is the distance in time from NOW to when
this timer becomes ripe (negative if it's already ripe). */
- if (!NILP (timers))
+ if (CONSP (timers))
{
timer = XCAR (timers);
vector = XVECTOR (timer)->contents;
@@ -4327,7 +4330,7 @@
/* Set IDLE_TIMER, IDLE_TIMER_TIME and IDLE_TIMER_DIFFERENCE
based on the next idle timer. */
- if (!NILP (idle_timers))
+ if (CONSP (idle_timers))
{
idle_timer = XCAR (idle_timers);
vector = XVECTOR (idle_timer)->contents;
@@ -4341,7 +4344,7 @@
and set CHOSEN_TIMER, VECTOR and DIFFERENCE accordingly.
Also step down the list where we found that timer. */
- if (! NILP (timers) && ! NILP (idle_timers))
+ if (CONSP (timers) && CONSP (idle_timers))
{
EMACS_TIME temp;
EMACS_SUB_TIME (temp, timer_difference, idle_timer_difference);
@@ -4358,7 +4361,7 @@
difference = idle_timer_difference;
}
}
- else if (! NILP (timers))
+ else if (CONSP (timers))
{
chosen_timer = timer;
timers = XCDR (timers);
@@ -7358,8 +7361,6 @@
Lisp_Object def, tail;
- Lisp_Object result;
-
int mapno;
Lisp_Object oquit;
@@ -7420,8 +7421,6 @@
/* Look up in each map the dummy prefix key `menu-bar'. */
- result = Qnil;
-
for (mapno = nmaps - 1; mapno >= 0; mapno--)
if (!NILP (maps[mapno]))
{
@@ -8495,7 +8494,6 @@
int notfirst = 0;
int i = nlength;
Lisp_Object obj;
- int ch;
Lisp_Object orig_defn_macro;
/* Loop over elements of map. */
@@ -8665,8 +8663,6 @@
return obj;
else if (XINT (obj) == -2)
return obj;
- else
- ch = XINT (obj);
if (! EQ (obj, menu_prompt_more_char)
&& (!INTEGERP (menu_prompt_more_char)
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2011-04-01 15:16:50 +0000
+++ b/src/lisp.h 2011-04-06 04:58:58 +0000
@@ -1016,7 +1016,7 @@
/* Interned state of the symbol. This is an enumerator from
enum symbol_interned. */
unsigned interned : 2;
-
+
/* Non-zero means that this variable has been explicitly declared
special (with `defvar' etc), and shouldn't be lexically bound. */
unsigned declared_special : 1;
@@ -2627,8 +2627,8 @@
extern Lisp_Object current_message (void);
extern void set_message (const char *s, Lisp_Object, EMACS_INT, int);
extern void clear_message (int, int);
-extern void message (const char *, ...);
-extern void message_nolog (const char *, ...);
+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);
@@ -3348,6 +3348,8 @@
extern int emacs_close (int);
extern int emacs_read (int, char *, unsigned int);
extern int emacs_write (int, const char *, unsigned int);
+enum { READLINK_BUFSIZE = 1024 };
+extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]);
#ifndef HAVE_MEMSET
extern void *memset (void *, int, size_t);
#endif
@@ -3392,7 +3394,8 @@
extern int *char_ins_del_vector;
extern void mark_ttys (void);
extern void syms_of_term (void);
-extern void fatal (const char *msgid, ...) NO_RETURN;
+extern void fatal (const char *msgid, ...)
+ NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 2);
/* Defined in terminal.c */
EXFUN (Fframe_terminal, 1);
=== modified file 'src/lread.c'
--- a/src/lread.c 2011-04-01 15:16:50 +0000
+++ b/src/lread.c 2011-04-04 07:48:36 +0000
@@ -818,7 +818,8 @@
while (in_file_vars)
{
- char var[100], *var_end, val[100], *val_end;
+ char var[100], val[100];
+ unsigned i;
ch = READCHAR;
@@ -826,19 +827,18 @@
while (ch == ' ' || ch == '\t')
ch = READCHAR;
- var_end = var;
+ i = 0;
while (ch != ':' && ch != '\n' && ch != EOF)
{
- if (var_end < var + sizeof var - 1)
- *var_end++ = ch;
+ if (i < sizeof var - 1)
+ var[i++] = ch;
UPDATE_BEG_END_STATE (ch);
ch = READCHAR;
}
- while (var_end > var
- && (var_end[-1] == ' ' || var_end[-1] == '\t'))
- var_end--;
- *var_end = '\0';
+ while (i > 0 && (var[i - 1] == ' ' || var[i - 1] == '\t'))
+ i--;
+ var[i] = '\0';
if (ch == ':')
{
@@ -848,22 +848,21 @@
while (ch == ' ' || ch == '\t')
ch = READCHAR;
- val_end = val;
+ i = 0;
while (ch != ';' && ch != '\n' && ch != EOF && in_file_vars)
{
- if (val_end < val + sizeof val - 1)
- *val_end++ = ch;
+ if (i < sizeof val - 1)
+ val[i++] = ch;
UPDATE_BEG_END_STATE (ch);
ch = READCHAR;
}
if (! in_file_vars)
/* The value was terminated by an end-marker, which
remove. */
- val_end -= 3;
- while (val_end > val
- && (val_end[-1] == ' ' || val_end[-1] == '\t'))
- val_end--;
- *val_end = '\0';
+ i -= 3;
+ while (i > 0 && (val[i - 1] == ' ' || val[i - 1] == '\t'))
+ i--;
+ val[i] = '\0';
if (strcmp (var, "lexical-binding") == 0)
/* This is it... */
@@ -908,7 +907,7 @@
if (i == 4)
version = buf[i];
- if (i == nbytes
+ if (i >= nbytes
|| fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
buf + i) < 0)
safe_p = 0;
@@ -2320,7 +2319,7 @@
read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
{
register int c;
- int uninterned_symbol = 0;
+ unsigned uninterned_symbol = 0;
int multibyte;
*pch = 0;
=== modified file 'src/menu.c'
--- a/src/menu.c 2011-03-29 06:58:36 +0000
+++ b/src/menu.c 2011-04-05 20:25:23 +0000
@@ -1340,7 +1340,7 @@
UNGCPRO;
- if (error_name) error (error_name);
+ if (error_name) error ("%s", error_name);
return selection;
}
=== modified file 'src/minibuf.c'
--- a/src/minibuf.c 2011-03-31 04:24:03 +0000
+++ b/src/minibuf.c 2011-04-02 07:40:13 +0000
@@ -229,7 +229,7 @@
Lisp_Object defalt,
int allow_props, int inherit_input_method)
{
- int size, len;
+ size_t size, len;
char *line, *s;
Lisp_Object val;
@@ -244,6 +244,8 @@
&& (len = strlen (line),
len == size - 1 && line[len - 1] != '\n'))
{
+ if ((size_t) -1 / 2 < size)
+ memory_full ();
size *= 2;
line = (char *) xrealloc (line, size);
}
=== modified file 'src/print.c'
--- a/src/print.c 2011-03-31 04:24:03 +0000
+++ b/src/print.c 2011-04-04 06:52:29 +0000
@@ -929,7 +929,7 @@
else
write_string_1 ("peculiar error", -1, stream);
- for (i = 0; CONSP (tail); tail = XCDR (tail), i++)
+ for (i = 0; CONSP (tail); tail = XCDR (tail), i = 1)
{
Lisp_Object obj;
@@ -1407,7 +1407,7 @@
print_string (obj, printcharfun);
else
{
- register EMACS_INT i, i_byte;
+ register EMACS_INT i_byte;
struct gcpro gcpro1;
unsigned char *str;
EMACS_INT size_byte;
@@ -1431,7 +1431,7 @@
str = SDATA (obj);
size_byte = SBYTES (obj);
- for (i = 0, i_byte = 0; i_byte < size_byte;)
+ for (i_byte = 0; i_byte < size_byte;)
{
/* Here, we must convert each multi-byte form to the
corresponding character code before handing it to PRINTCHAR.
*/
=== modified file 'src/process.c'
--- a/src/process.c 2011-03-27 02:32:40 +0000
+++ b/src/process.c 2011-04-04 09:06:52 +0000
@@ -1344,11 +1344,7 @@
symbol = XCAR (p->status);
if (EQ (symbol, Qsignal))
- {
- Lisp_Object tem;
- tem = Fcar (Fcdr (p->status));
- Fprinc (symbol, Qnil);
- }
+ Fprinc (symbol, Qnil);
else if (NETCONN1_P (p) || SERIALCONN1_P (p))
{
if (EQ (symbol, Qexit))
@@ -2150,10 +2146,7 @@
create_pty (Lisp_Object process)
{
int inchannel, outchannel;
-
- /* Use volatile to protect variables from being clobbered by longjmp. */
- volatile int forkin, forkout;
- volatile int pty_flag = 0;
+ int pty_flag = 0;
inchannel = outchannel = -1;
@@ -2169,11 +2162,11 @@
#ifdef O_NOCTTY
/* Don't let this terminal become our controlling terminal
(in case we don't have one). */
- forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
+ int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
#else
- forkout = forkin = emacs_open (pty_name, O_RDWR, 0);
+ int forkout = emacs_open (pty_name, O_RDWR, 0);
#endif
- if (forkin < 0)
+ if (forkout < 0)
report_file_error ("Opening pty", Qnil);
#if defined (DONT_REOPEN_PTY)
/* In the case that vfork is defined as fork, the parent process
@@ -2181,8 +2174,6 @@
tty options setup. So we setup tty before forking. */
child_setup_tty (forkout);
#endif /* DONT_REOPEN_PTY */
-#else
- forkin = forkout = -1;
#endif /* not USG, or USG_SUBTTY_WORKS */
pty_flag = 1;
}
@@ -3958,7 +3949,7 @@
const struct ifflag_def *fp;
int fnum;
- any++;
+ any = 1;
for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++)
{
if (flags & fp->flag_bit)
@@ -3986,7 +3977,7 @@
register struct Lisp_Vector *p = XVECTOR (hwaddr);
int n;
- any++;
+ any = 1;
for (n = 0; n < 6; n++)
p->contents[n] = make_number (((unsigned char
*)&rq.ifr_hwaddr.sa_data[0])[n]);
elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr);
@@ -3998,7 +3989,7 @@
#if defined(SIOCGIFNETMASK) && (defined(HAVE_STRUCT_IFREQ_IFR_NETMASK) ||
defined(HAVE_STRUCT_IFREQ_IFR_ADDR))
if (ioctl (s, SIOCGIFNETMASK, &rq) == 0)
{
- any++;
+ any = 1;
#ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK
elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask));
#else
@@ -4012,7 +4003,7 @@
#if defined(SIOCGIFBRDADDR) && defined(HAVE_STRUCT_IFREQ_IFR_BROADADDR)
if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0)
{
- any++;
+ any = 1;
elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof
(rq.ifr_broadaddr));
}
#endif
@@ -4022,7 +4013,7 @@
#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ_IFR_ADDR)
if (ioctl (s, SIOCGIFADDR, &rq) == 0)
{
- any++;
+ any = 1;
elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr));
}
#endif
@@ -5171,15 +5162,22 @@
}
else
#endif
- if (proc_buffered_char[channel] < 0)
{
+ int buffered = 0 <= proc_buffered_char[channel];
+ if (buffered)
+ {
+ chars[carryover] = proc_buffered_char[channel];
+ proc_buffered_char[channel] = -1;
+ }
#ifdef HAVE_GNUTLS
if (XPROCESS (proc)->gnutls_p)
nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
- chars + carryover, readmax);
+ chars + carryover + buffered,
+ readmax - buffered);
else
#endif
- nbytes = emacs_read (channel, chars + carryover, readmax);
+ nbytes = emacs_read (channel, chars + carryover + buffered,
+ readmax - buffered);
#ifdef ADAPTIVE_READ_BUFFERING
if (nbytes > 0 && p->adaptive_read_buffering)
{
@@ -5193,7 +5191,7 @@
delay += READ_OUTPUT_DELAY_INCREMENT * 2;
}
}
- else if (delay > 0 && (nbytes == readmax))
+ else if (delay > 0 && nbytes == readmax - buffered)
{
delay -= READ_OUTPUT_DELAY_INCREMENT;
if (delay == 0)
@@ -5207,22 +5205,8 @@
}
}
#endif
- }
- else
- {
- chars[carryover] = proc_buffered_char[channel];
- proc_buffered_char[channel] = -1;
-#ifdef HAVE_GNUTLS
- if (XPROCESS (proc)->gnutls_p)
- nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
- chars + carryover + 1, readmax - 1);
- else
-#endif
- nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
- if (nbytes < 0)
- nbytes = 1;
- else
- nbytes = nbytes + 1;
+ nbytes += buffered;
+ nbytes += buffered && nbytes <= 0;
}
p->decoding_carryover = 0;
@@ -5249,15 +5233,17 @@
outstream = p->filter;
if (!NILP (outstream))
{
- Lisp_Object obuffer, okeymap;
Lisp_Object text;
int outer_running_asynch_code = running_asynch_code;
int waiting = waiting_for_user_input_p;
/* No need to gcpro these, because all we do with them later
is test them for EQness, and none of them should be a string. */
+#if 0
+ Lisp_Object obuffer, okeymap;
XSETBUFFER (obuffer, current_buffer);
okeymap = BVAR (current_buffer, keymap);
+#endif
/* We inhibit quit here instead of just catching it so that
hitting ^G when a filter happens to be running won't screw
@@ -6540,7 +6526,7 @@
static void
exec_sentinel (Lisp_Object proc, Lisp_Object reason)
{
- Lisp_Object sentinel, obuffer, odeactivate, okeymap;
+ Lisp_Object sentinel, odeactivate;
register struct Lisp_Process *p = XPROCESS (proc);
int count = SPECPDL_INDEX ();
int outer_running_asynch_code = running_asynch_code;
@@ -6552,8 +6538,11 @@
/* No need to gcpro these, because all we do with them later
is test them for EQness, and none of them should be a string. */
odeactivate = Vdeactivate_mark;
+#if 0
+ Lisp_Object obuffer, okeymap;
XSETBUFFER (obuffer, current_buffer);
okeymap = BVAR (current_buffer, keymap);
+#endif
/* There's no good reason to let sentinels change the current
buffer, and many callers of accept-process-output, sit-for, and
=== modified file 'src/search.c'
--- a/src/search.c 2011-03-28 22:41:01 +0000
+++ b/src/search.c 2011-04-03 04:21:50 +0000
@@ -1674,7 +1674,6 @@
int translate_prev_byte1 = 0;
int translate_prev_byte2 = 0;
int translate_prev_byte3 = 0;
- int translate_prev_byte4 = 0;
/* The general approach is that we are going to maintain that we know
the first (closest to the present position, in whatever direction
@@ -1730,11 +1729,7 @@
{
translate_prev_byte2 = str[cblen - 3];
if (cblen > 3)
- {
- translate_prev_byte3 = str[cblen - 4];
- if (cblen > 4)
- translate_prev_byte4 = str[cblen - 5];
- }
+ translate_prev_byte3 = str[cblen - 4];
}
}
@@ -2091,7 +2086,7 @@
static Lisp_Object
wordify (Lisp_Object string, int lax)
{
- register unsigned char *p, *o;
+ register unsigned char *o;
register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0;
Lisp_Object val;
int prev_c = 0;
@@ -2099,7 +2094,6 @@
int whitespace_at_end;
CHECK_STRING (string);
- p = SDATA (string);
len = SCHARS (string);
for (i = 0, i_byte = 0; i < len; )
@@ -2111,7 +2105,7 @@
if (SYNTAX (c) != Sword)
{
punct_count++;
- if (i > 0 && SYNTAX (prev_c) == Sword)
+ if (SYNTAX (prev_c) == Sword)
word_count++;
}
@@ -2124,10 +2118,11 @@
whitespace_at_end = 0;
}
else
- whitespace_at_end = 1;
-
- if (!word_count)
- return empty_unibyte_string;
+ {
+ whitespace_at_end = 1;
+ if (!word_count)
+ return empty_unibyte_string;
+ }
adjust = - punct_count + 5 * (word_count - 1)
+ ((lax && !whitespace_at_end) ? 2 : 4);
@@ -2155,7 +2150,7 @@
memcpy (o, SDATA (string) + i_byte_orig, i_byte - i_byte_orig);
o += i_byte - i_byte_orig;
}
- else if (i > 0 && SYNTAX (prev_c) == Sword && --word_count)
+ else if (SYNTAX (prev_c) == Sword && --word_count)
{
*o++ = '\\';
*o++ = 'W';
=== modified file 'src/sound.c'
--- a/src/sound.c 2011-03-18 06:42:43 +0000
+++ b/src/sound.c 2011-04-05 20:08:03 +0000
@@ -344,7 +344,7 @@
static void
sound_warning (const char *msg)
{
- message (msg);
+ message ("%s", msg);
}
=== modified file 'src/syntax.c'
--- a/src/syntax.c 2011-03-27 08:21:49 +0000
+++ b/src/syntax.c 2011-04-04 07:53:20 +0000
@@ -175,7 +175,8 @@
Lisp_Object object)
{
Lisp_Object tmp_table;
- int cnt = 0, invalidate = 1;
+ unsigned cnt = 0;
+ int invalidate = 1;
INTERVAL i;
if (init)
@@ -1219,7 +1220,7 @@
register EMACS_INT from_byte = CHAR_TO_BYTE (from);
register enum syntaxcode code;
int ch0, ch1;
- Lisp_Object func, script, pos;
+ Lisp_Object func, pos;
immediate_quit = 1;
QUIT;
@@ -1259,7 +1260,6 @@
}
else
{
- script = CHAR_TABLE_REF (Vchar_script_table, ch0);
while (1)
{
if (from == end) break;
@@ -1310,7 +1310,6 @@
}
else
{
- script = CHAR_TABLE_REF (Vchar_script_table, ch1);
while (1)
{
if (from == beg)
=== modified file 'src/sysdep.c'
--- a/src/sysdep.c 2011-03-27 02:27:11 +0000
+++ b/src/sysdep.c 2011-04-01 06:28:48 +0000
@@ -31,6 +31,8 @@
#endif /* HAVE_LIMITS_H */
#include <unistd.h>
+#include <allocator.h>
+#include <careadlinkat.h>
#include <ignore-value.h>
#include "lisp.h"
@@ -1866,6 +1868,22 @@
}
return (bytes_written);
}
+
+static struct allocator const emacs_norealloc_allocator =
+ { xmalloc, NULL, xfree, memory_full };
+
+/* Get the symbolic link value of FILENAME. Return a pointer to a
+ NUL-terminated string. If readlink fails, return NULL and set
+ errno. If the value fits in INITIAL_BUF, return INITIAL_BUF.
+ Otherwise, allocate memory and return a pointer to that memory. If
+ memory allocation fails, diagnose and fail without returning. If
+ successful, store the length of the symbolic link into *LINKLEN. */
+char *
+emacs_readlink (char const *filename, char initial_buf[READLINK_BUFSIZE])
+{
+ return careadlinkat (AT_FDCWD, filename, initial_buf, READLINK_BUFSIZE,
+ &emacs_norealloc_allocator, careadlinkatcwd);
+}
#ifdef USG
/*
=== modified file 'src/term.c'
--- a/src/term.c 2011-03-27 08:15:26 +0000
+++ b/src/term.c 2011-04-06 04:58:58 +0000
@@ -85,8 +85,10 @@
static void dissociate_if_controlling_tty (int fd);
static void delete_tty (struct terminal *);
static void maybe_fatal (int must_succeed, struct terminal *terminal,
- const char *str1, const char *str2, ...) NO_RETURN;
-static void vfatal (const char *str, va_list ap) NO_RETURN;
+ const char *str1, const char *str2, ...)
+ NO_RETURN ATTRIBUTE_FORMAT_PRINTF (4, 5);
+static void vfatal (const char *str, va_list ap)
+ NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0);
#define OUTPUT(tty, a) \
@@ -707,6 +709,7 @@
{
unsigned char *conversion_buffer;
struct coding_system *coding;
+ size_t n, stringlen;
struct tty_display_info *tty = FRAME_TTY (f);
@@ -734,13 +737,12 @@
the tail. */
coding->mode &= ~CODING_MODE_LAST_BLOCK;
- while (len > 0)
+ for (stringlen = len; stringlen != 0; stringlen -= n)
{
/* Identify a run of glyphs with the same face. */
int face_id = string->face_id;
- int n;
- for (n = 1; n < len; ++n)
+ for (n = 1; n < stringlen; ++n)
if (string[n].face_id != face_id)
break;
@@ -748,7 +750,7 @@
tty_highlight_if_desired (tty);
turn_on_face (f, face_id);
- if (n == len)
+ if (n == stringlen)
/* This is the last run. */
coding->mode |= CODING_MODE_LAST_BLOCK;
conversion_buffer = encode_terminal_code (string, n, coding);
@@ -762,7 +764,6 @@
fwrite (conversion_buffer, 1, coding->produced, tty->termscript);
UNBLOCK_INPUT;
}
- len -= n;
string += n;
/* Turn appearance modes off. */
=== modified file 'src/textprop.c'
--- a/src/textprop.c 2011-03-18 16:42:05 +0000
+++ b/src/textprop.c 2011-04-04 19:30:48 +0000
@@ -1379,8 +1379,8 @@
i = next_interval (i);
}
- /* We are starting at the beginning of an interval, I */
- while (len > 0)
+ /* We are starting at the beginning of an interval I. LEN is positive. */
+ do
{
if (i == 0)
abort ();
@@ -1412,6 +1412,7 @@
i = next_interval (i);
}
+ while (len > 0);
}
DEFUN ("remove-text-properties", Fremove_text_properties,
=== modified file 'src/xdisp.c'
--- a/src/xdisp.c 2011-04-02 23:53:55 +0000
+++ b/src/xdisp.c 2011-04-05 20:11:37 +0000
@@ -774,6 +774,7 @@
static void handle_stop (struct it *);
static void handle_stop_backwards (struct it *, EMACS_INT);
static int single_display_spec_intangible_p (Lisp_Object);
+static void vmessage (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0);
static void ensure_echo_area_buffers (void);
static Lisp_Object unwind_with_echo_area_buffer (Lisp_Object);
static Lisp_Object with_echo_area_buffer_unwind_data (struct window *);
=== modified file 'src/xfaces.c'
--- a/src/xfaces.c 2011-03-19 18:49:31 +0000
+++ b/src/xfaces.c 2011-04-01 17:41:46 +0000
@@ -5444,7 +5444,6 @@
Lisp_Object lface = lface_from_face_name (f, symbol, 0);
Lisp_Object attrs[LFACE_VECTOR_SIZE];
Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
- struct face *new_face;
/* The default face must exist and be fully specified. */
get_lface_attributes_no_remap (f, Qdefault, attrs, 1);
@@ -5464,7 +5463,7 @@
merge_face_vectors (f, symbol_attrs, attrs, 0);
/* Realize the face. */
- new_face = realize_face (c, attrs, id);
+ realize_face (c, attrs, id);
}
@@ -5761,21 +5760,16 @@
{
Lisp_Object frame, color, def;
int foreground_p = idx == LFACE_FOREGROUND_INDEX;
- unsigned long default_pixel, default_other_pixel, pixel;
+ unsigned long default_pixel =
+ foreground_p ? FACE_TTY_DEFAULT_FG_COLOR : FACE_TTY_DEFAULT_BG_COLOR;
+ unsigned long pixel = default_pixel;
+#ifdef MSDOS
+ unsigned long default_other_pixel =
+ foreground_p ? FACE_TTY_DEFAULT_BG_COLOR : FACE_TTY_DEFAULT_FG_COLOR;
+#endif
xassert (idx == LFACE_FOREGROUND_INDEX || idx == LFACE_BACKGROUND_INDEX);
- if (foreground_p)
- {
- pixel = default_pixel = FACE_TTY_DEFAULT_FG_COLOR;
- default_other_pixel = FACE_TTY_DEFAULT_BG_COLOR;
- }
- else
- {
- pixel = default_pixel = FACE_TTY_DEFAULT_BG_COLOR;
- default_other_pixel = FACE_TTY_DEFAULT_FG_COLOR;
- }
-
XSETFRAME (frame, f);
color = face->lface[idx];
=== modified file 'src/xfns.c'
--- a/src/xfns.c 2011-03-15 17:13:02 +0000
+++ b/src/xfns.c 2011-04-02 02:06:43 +0000
@@ -855,19 +855,20 @@
static char const no_data[] = { 0 };
Pixmap pix;
XColor col;
- Cursor c;
+ Cursor c = 0;
x_catch_errors (dpy);
pix = XCreateBitmapFromData (dpy, FRAME_X_DISPLAY_INFO (f)->root_window,
no_data, 1, 1);
if (! x_had_errors_p (dpy) && pix != None)
{
+ Cursor pixc;
col.pixel = 0;
col.red = col.green = col.blue = 0;
col.flags = DoRed | DoGreen | DoBlue;
- c = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0);
- if (x_had_errors_p (dpy) || c == None)
- c = 0;
+ pixc = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0);
+ if (! x_had_errors_p (dpy) && pixc != None)
+ c = pixc;
XFreePixmap (dpy, pix);
}
@@ -4579,7 +4580,6 @@
struct frame *f;
Lisp_Object frame;
Lisp_Object name;
- long window_prompting = 0;
int width, height;
int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3;
@@ -4757,7 +4757,7 @@
f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
- window_prompting = x_figure_window_size (f, parms, 0);
+ x_figure_window_size (f, parms, 0);
{
XSetWindowAttributes attrs;
=== modified file 'src/xfont.c'
--- a/src/xfont.c 2011-03-19 02:45:11 +0000
+++ b/src/xfont.c 2011-04-05 05:14:06 +0000
@@ -844,22 +844,25 @@
font->average_width = XINT (val) / 10;
if (font->average_width < 0)
font->average_width = - font->average_width;
- if (font->average_width == 0
- && encoding->ascii_compatible_p)
+ else
{
- int width = font->space_width, n = pcm != NULL;
+ if (font->average_width == 0
+ && encoding->ascii_compatible_p)
+ {
+ int width = font->space_width, n = pcm != NULL;
- for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++)
- if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL)
- width += pcm->width, n++;
- if (n > 0)
- font->average_width = width / n;
+ for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++)
+ if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL)
+ width += pcm->width, n++;
+ if (n > 0)
+ font->average_width = width / n;
+ }
+ if (font->average_width == 0)
+ /* No easy way other than this to get a reasonable
+ average_width. */
+ font->average_width
+ = (xfont->min_bounds.width + xfont->max_bounds.width) / 2;
}
- if (font->average_width == 0)
- /* No easy way other than this to get a reasonable
- average_width. */
- font->average_width
- = (xfont->min_bounds.width + xfont->max_bounds.width) / 2;
}
BLOCK_INPUT;
@@ -966,11 +969,11 @@
{
XFontStruct *xfont = ((struct xfont_info *) font)->xfont;
int width = 0;
- int i, first, x;
+ int i, first;
if (metrics)
memset (metrics, 0, sizeof (struct font_metrics));
- for (i = 0, x = 0, first = 1; i < nglyphs; i++)
+ for (i = 0, first = 1; i < nglyphs; i++)
{
XChar2b char2b;
static XCharStruct *pcm;
=== modified file 'src/xmenu.c'
--- a/src/xmenu.c 2011-03-26 01:23:15 +0000
+++ b/src/xmenu.c 2011-04-05 20:26:55 +0000
@@ -341,7 +341,7 @@
unbind_to (specpdl_count, Qnil);
discard_menu_items ();
- if (error_name) error (error_name);
+ if (error_name) error ("%s", error_name);
return selection;
}
#endif
=== modified file 'src/xselect.c'
--- a/src/xselect.c 2011-03-24 04:17:44 +0000
+++ b/src/xselect.c 2011-04-02 02:02:18 +0000
@@ -391,7 +391,7 @@
x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
int local_request)
{
Lisp_Object local_value;
- Lisp_Object handler_fn, value, type, check;
+ Lisp_Object handler_fn, value, check;
int count;
local_value = assq_no_quit (selection_symbol, Vselection_alist);
@@ -469,7 +469,6 @@
check = value;
if (CONSP (value)
&& SYMBOLP (XCAR (value)))
- type = XCAR (value),
check = XCDR (value);
if (STRINGP (check)
@@ -1203,9 +1202,9 @@
void
x_handle_property_notify (XPropertyEvent *event)
{
- struct prop_location *prev = 0, *rest = property_change_wait_list;
+ struct prop_location *rest;
- while (rest)
+ for (rest = property_change_wait_list; rest; rest = rest->next)
{
if (!rest->arrived
&& rest->property == event->atom
@@ -1226,9 +1225,6 @@
return;
}
-
- prev = rest;
- rest = rest->next;
}
}
=== modified file 'src/xterm.c'
--- a/src/xterm.c 2011-03-27 08:15:26 +0000
+++ b/src/xterm.c 2011-04-01 20:14:03 +0000
@@ -4165,7 +4165,7 @@
x_send_scroll_bar_event and x_scroll_bar_to_input_event. */
static struct window **scroll_bar_windows;
-static int scroll_bar_windows_size;
+static size_t scroll_bar_windows_size;
/* Send a client message with message type Xatom_Scrollbar for a
@@ -4180,7 +4180,7 @@
XClientMessageEvent *ev = (XClientMessageEvent *) &event;
struct window *w = XWINDOW (window);
struct frame *f = XFRAME (w->frame);
- int i;
+ size_t i;
BLOCK_INPUT;
@@ -4201,10 +4201,12 @@
if (i == scroll_bar_windows_size)
{
- int new_size = max (10, 2 * scroll_bar_windows_size);
+ size_t new_size = max (10, 2 * scroll_bar_windows_size);
size_t nbytes = new_size * sizeof *scroll_bar_windows;
size_t old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows;
+ if ((size_t) -1 / sizeof *scroll_bar_windows < new_size)
+ memory_full ();
scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows,
nbytes);
memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes);
@@ -4240,14 +4242,12 @@
{
XClientMessageEvent *ev = (XClientMessageEvent *) event;
Lisp_Object window;
- struct frame *f;
struct window *w;
w = scroll_bar_windows[ev->data.l[0]];
scroll_bar_windows[ev->data.l[0]] = NULL;
XSETWINDOW (window, w);
- f = XFRAME (w->frame);
ievent->kind = SCROLL_BAR_CLICK_EVENT;
ievent->frame_or_window = window;
@@ -4255,7 +4255,8 @@
#ifdef USE_GTK
ievent->timestamp = CurrentTime;
#else
- ievent->timestamp = XtLastTimestampProcessed (FRAME_X_DISPLAY (f));
+ ievent->timestamp =
+ XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (w->frame)));
#endif
ievent->part = ev->data.l[1];
ievent->code = ev->data.l[2];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103841: Fix more problems found by GCC 4.6.0's static checks.,
Paul Eggert <=