emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103880: Fix more problems found by G


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103880: Fix more problems found by GCC 4.6.0's static checks.
Date: Sun, 10 Apr 2011 09:44:27 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 103880 [merge]
committer: Paul Eggert <address@hidden>
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.
added:
  lib/allocator.c
modified:
  ChangeLog
  lib/allocator.h
  lib/careadlinkat.c
  lib/careadlinkat.h
  lib/gnulib.mk
  lib/stdlib.in.h
  m4/gl-comp.m4
  src/ChangeLog
  src/Makefile.in
  src/callint.c
  src/casetab.c
  src/category.c
  src/charset.c
  src/chartab.c
  src/coding.c
  src/deps.mk
  src/doc.c
  src/editfns.c
  src/eval.c
  src/fns.c
  src/ftfont.c
  src/intervals.c
  src/keyboard.c
  src/lisp.h
  src/m/amdx86-64.h
  src/m/ia64.h
  src/m/ibms390x.h
  src/nsfns.m
  src/syntax.c
  src/sysdep.c
  src/term.c
  src/window.c
  src/xdisp.c
  src/xfns.c
  src/xmenu.c
  src/xterm.c
=== modified file 'ChangeLog'
--- a/ChangeLog 2011-04-07 03:22:10 +0000
+++ b/ChangeLog 2011-04-09 18:42:31 +0000
@@ -1,3 +1,7 @@
+2011-04-09  Paul Eggert  <address@hidden>
+
+       * lib/allocator.c: New file, automatically generated by gnulib.
+
 2011-04-07  Glenn Morris  <address@hidden>
 
        * autogen/update_autogen: Ignore comment diffs in ldefs-boot.el.

=== added file 'lib/allocator.c'
--- a/lib/allocator.c   1970-01-01 00:00:00 +0000
+++ b/lib/allocator.c   2011-04-08 21:53:30 +0000
@@ -0,0 +1,5 @@
+#define _GL_USE_STDLIB_ALLOC 1
+#include <config.h>
+#include "allocator.h"
+#include <stdlib.h>
+struct allocator const stdlib_allocator = { malloc, realloc, free, NULL };

=== modified file 'lib/allocator.h'
--- a/lib/allocator.h   2011-04-05 18:19:19 +0000
+++ b/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 <stddef.h>
 
@@ -30,16 +31,16 @@
      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
+  /* 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'
--- a/lib/careadlinkat.c        2011-04-05 18:19:19 +0000
+++ b/lib/careadlinkat.c        2011-04-10 16:00:46 +0000
@@ -22,19 +22,12 @@
 
 #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)
@@ -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()
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
+   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'
--- a/lib/careadlinkat.h        2011-04-01 06:28:48 +0000
+++ b/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 <fcntl.h>
 #include <unistd.h>
@@ -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()
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
+   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 <fcntl.h>, readlinkat in <unistd.h>.  */
 # define careadlinkatcwd readlinkat
 #else
 /* Define AT_FDCWD independently, so that the careadlinkat module does

=== modified file 'lib/gnulib.mk'
--- a/lib/gnulib.mk     2011-04-06 07:04:00 +0000
+++ b/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'
--- a/lib/stdlib.in.h   2011-02-25 07:36:37 +0000
+++ b/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'
--- a/m4/gl-comp.m4     2011-04-01 06:28:48 +0000
+++ b/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'
--- a/src/ChangeLog     2011-04-10 14:00:13 +0000
+++ b/src/ChangeLog     2011-04-10 16:44:27 +0000
@@ -1,3 +1,86 @@
+2011-04-10  Paul Eggert  <address@hidden>
+
+       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 <limits.h>.
+       (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  <address@hidden>
 
        use ssize_t and size_t for read- and write-like emacs_gnutls_* functions

=== modified file 'src/Makefile.in'
--- a/src/Makefile.in   2011-02-20 10:53:22 +0000
+++ b/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'
--- a/src/callint.c     2011-04-01 15:16:50 +0000
+++ b/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'
--- a/src/casetab.c     2011-03-15 07:04:00 +0000
+++ b/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'
--- a/src/category.c    2011-03-08 07:39:53 +0000
+++ b/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'
--- a/src/charset.c     2011-03-27 02:12:36 +0000
+++ b/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'
--- a/src/chartab.c     2011-03-27 08:15:26 +0000
+++ b/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'
--- a/src/coding.c      2011-04-09 16:35:19 +0000
+++ b/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'
--- a/src/deps.mk       2011-04-01 06:38:52 +0000
+++ b/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'
--- a/src/doc.c 2011-03-21 16:42:16 +0000
+++ b/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'
--- a/src/editfns.c     2011-04-09 16:35:19 +0000
+++ b/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'
--- a/src/eval.c        2011-04-05 20:01:08 +0000
+++ b/src/eval.c        2011-04-08 23:28:52 +0000
@@ -18,6 +18,7 @@
 
 
 #include <config.h>
+#include <limits.h>
 #include <setjmp.h>
 #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'
--- a/src/fns.c 2011-04-06 04:34:35 +0000
+++ b/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'
--- a/src/ftfont.c      2011-04-09 17:40:29 +0000
+++ b/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'
--- a/src/intervals.c   2011-04-04 16:47:31 +0000
+++ b/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'
--- a/src/keyboard.c    2011-04-08 15:51:28 +0000
+++ b/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'
--- a/src/lisp.h        2011-04-09 16:35:19 +0000
+++ b/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'
--- a/src/m/amdx86-64.h 2011-02-16 01:35:20 +0000
+++ b/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'
--- a/src/m/ia64.h      2011-02-16 01:35:20 +0000
+++ b/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'
--- a/src/m/ibms390x.h  2011-01-25 04:08:28 +0000
+++ b/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'
--- a/src/nsfns.m       2011-02-17 10:19:29 +0000
+++ b/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'
--- a/src/syntax.c      2011-04-04 07:53:20 +0000
+++ b/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'
--- a/src/sysdep.c      2011-04-01 06:28:48 +0000
+++ b/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'
--- a/src/term.c        2011-04-08 18:53:26 +0000
+++ b/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'
--- a/src/window.c      2011-04-08 15:37:15 +0000
+++ b/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'
--- a/src/xdisp.c       2011-04-09 16:35:19 +0000
+++ b/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'
--- a/src/xfns.c        2011-04-02 02:06:43 +0000
+++ b/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'
--- a/src/xmenu.c       2011-04-09 17:40:29 +0000
+++ b/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'
--- a/src/xterm.c       2011-04-09 17:40:29 +0000
+++ b/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)
 {


reply via email to

[Prev in Thread] Current Thread [Next in Thread]