1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-28 19:42:02 +00:00

Fix more problems found by GCC 4.6.0's static checks.

This commit is contained in:
Paul Eggert 2011-04-10 09:44:27 -07:00
commit b2ded58d7e
37 changed files with 345 additions and 176 deletions

View File

@ -1,3 +1,7 @@
2011-04-09 Paul Eggert <eggert@cs.ucla.edu>
* lib/allocator.c: New file, automatically generated by gnulib.
2011-04-07 Glenn Morris <rgm@gnu.org>
* autogen/update_autogen: Ignore comment diffs in ldefs-boot.el.

5
lib/allocator.c Normal file
View File

@ -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 };

View File

@ -18,6 +18,7 @@
/* Written by Paul Eggert. */
#ifndef _GL_ALLOCATOR_H
#define _GL_ALLOCATOR_H
#include <stddef.h>
@ -30,16 +31,16 @@ struct allocator
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 @@ struct allocator
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 */

View File

@ -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 @@ static struct allocator const standard_allocator =
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 @@ careadlinkat (int fd, char const *filename,
char stack_buf[1024];
if (! alloc)
alloc = &standard_allocator;
alloc = &stdlib_allocator;
if (! buffer_size)
{
@ -138,16 +134,16 @@ careadlinkat (int fd, char const *filename,
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 @@ careadlinkat (int fd, char const *filename,
buf_size = buf_size_max;
else
break;
buf = (char *) alloc->malloc (buf_size);
buf = (char *) alloc->allocate (buf_size);
}
while (buf);

View File

@ -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 @@ struct allocator;
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 *careadlinkat (int fd, char const *filename,
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

View File

@ -21,6 +21,14 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
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 @@ EXTRA_DIST += $(top_srcdir)/./c++defs.h
libgnu_a_SOURCES += careadlinkat.c
EXTRA_DIST += allocator.h careadlinkat.h
EXTRA_DIST += careadlinkat.h
## end gnulib module careadlinkat

View File

@ -255,9 +255,14 @@ _GL_WARN_ON_USE (ptsname, "grantpt is not portable - "
# 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_RPL (malloc, void *, (size_t size));
_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 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
#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_RPL (realloc, void *, (void *ptr, size_t size));
_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 - "

View File

@ -26,6 +26,7 @@ AC_DEFUN([gl_EARLY],
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 @@ AC_DEFUN([gl_INIT],
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 @@ AC_DEFUN([gl_FILE_LIST], [
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

View File

@ -1,3 +1,86 @@
2011-04-10 Paul Eggert <eggert@cs.ucla.edu>
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 <meyering@redhat.com>
use ssize_t and size_t for read- and write-like emacs_gnutls_* functions

View File

@ -354,7 +354,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
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)

View File

@ -269,8 +269,8 @@ invoke it. If KEYS is omitted or nil, the return value of
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 @@ invoke it. If KEYS is omitted or nil, the return value of
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));
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 < (count + 1); i++)
for (i = 0; i < nargs; i++)
{
args[i] = Qnil;
visargs[i] = Qnil;
@ -476,8 +475,8 @@ invoke it. If KEYS is omitted or nil, the return value of
}
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 @@ invoke it. If KEYS is omitted or nil, the return value of
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 @@ invoke it. If KEYS is omitted or nil, the return value of
/* 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 @@ invoke it. If KEYS is omitted or nil, the return value of
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);
}

View File

@ -191,7 +191,8 @@ set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt)
{
if (NATNUMP (elt))
{
int from, to;
int from;
unsigned to;
if (CONSP (c))
{
@ -200,7 +201,7 @@ set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt)
}
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 @@ shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt)
{
if (NATNUMP (elt))
{
int from, to;
int from;
unsigned to;
if (CONSP (c))
{
@ -225,7 +227,7 @@ shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt)
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));

View File

@ -128,7 +128,7 @@ the current buffer's category table. */)
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 @@ then delete CATEGORY from the category set instead of adding it. */)
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;

View File

@ -317,7 +317,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
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 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
}
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 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
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 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
{
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 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
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 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co
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 @@ usage: (define-charset-internal ...) */)
{
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 @@ usage: (define-charset-internal ...) */)
{
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_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Obje
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);
}
}

View File

@ -392,7 +392,8 @@ sub_char_table_set_range (Lisp_Object *table, int depth, int min_char, int from,
*table = val;
else
{
int i, j;
int i;
unsigned j;
depth++;
if (! SUB_CHAR_TABLE_P (*table))
@ -404,7 +405,7 @@ sub_char_table_set_range (Lisp_Object *table, int depth, int min_char, int from,
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 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
{
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);
}

View File

@ -9024,14 +9024,15 @@ Return the corresponding character. */)
{
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 @@ Return the corresponding character. */)
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 @@ Return the corresponding character. */)
{
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 @@ Return the corresponding character. */)
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 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */)
|| (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 @@ usage: (define-coding-system-internal ...) */)
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));
}

View File

@ -82,7 +82,6 @@ dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \
# 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)

View File

@ -154,7 +154,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
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 @@ the same file name is found in the `doc-directory'. */)
; /* 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;

View File

@ -3674,7 +3674,7 @@ usage: (format STRING &rest OBJECTS) */)
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]));

View File

@ -18,6 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <limits.h>
#include <setjmp.h>
#include "lisp.h"
#include "blockinput.h"
@ -30,6 +31,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#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 @@ internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform,
|| (CONSP (tem)
&& (SYMBOLP (XCAR (tem))
|| CONSP (XCAR (tem))))))
error ("Invalid condition handler", tem);
error ("Invalid condition handler");
}
c.tag = Qnil;
@ -1976,33 +1981,39 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions,
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);

View File

@ -1076,7 +1076,7 @@ an error is signaled. */)
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);
}

View File

@ -160,11 +160,13 @@ static struct
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 @@ static Lisp_Object
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 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra)
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)

View File

@ -777,7 +777,7 @@ update_interval (register INTERVAL i, EMACS_INT pos)
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;

View File

@ -3090,7 +3090,6 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
/* 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 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
(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;
}

View File

@ -38,6 +38,7 @@ extern void check_cons_list (void);
#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 @@ extern void check_cons_list (void);
#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 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 *, ...) 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 Lisp_Object internal_with_output_to_temp_buffer
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 Lisp_Object internal_condition_case_n (Lisp_Object (*) (size_t, Lisp_Obje
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);

View File

@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* 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 */

View File

@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define the type to use. */
#define EMACS_INT long
#define pEd "ld"
#define EMACS_UINT unsigned long
#ifdef REL_ALLOC

View File

@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* 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 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
#define XPNTR(a) XUINT (a)

View File

@ -483,7 +483,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
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 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
if (FRAME_ICONIFIED_P (f))
[[view window] setMiniwindowTitle: str];
else
else
{
NSString *fstr;
@ -1021,8 +1021,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
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 @@ and GNUstep implementations ("distributor-specific release
(Lisp_Object script)
{
Lisp_Object result;
long status;
int status;
CHECK_STRING (script);
check_ns ();
@ -2330,7 +2330,7 @@ The return value is a list of integers (LEFT TOP WIDTH HEIGHT), which
{
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 @@ The return value is a list of integers (LEFT TOP WIDTH HEIGHT), which
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 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
check_window_system_func = check_ns;
}

View File

@ -1541,7 +1541,8 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
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 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
}
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 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
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)

View File

@ -2361,7 +2361,8 @@ serial_configure (struct Lisp_Process *p,
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. */

View File

@ -86,7 +86,7 @@ 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 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);

View File

@ -3801,7 +3801,7 @@ See Info node `(elisp)Splitting Windows' for more details and examples. */)
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 @@ See Info node `(elisp)Splitting Windows' for more details and examples. */)
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))
{

View File

@ -8408,10 +8408,19 @@ vmessage (const char *m, va_list ap)
{
if (m)
{
EMACS_INT len;
char *buf = FRAME_MESSAGE_BUF (f);
size_t bufsize = FRAME_MESSAGE_BUF_SIZE (f);
int len;
len = doprnt (FRAME_MESSAGE_BUF (f),
FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap);
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 @@ message (const char *m, ...)
}
#if 0
/* The non-logging version of message. */
void
@ -8449,6 +8459,7 @@ message_nolog (const char *m, ...)
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 @@ decode_mode_spec (struct window *w, register int c, int field_width,
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)

View File

@ -215,7 +215,7 @@ check_x_display_info (Lisp_Object object)
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;
}

View File

@ -966,6 +966,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
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 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
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 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
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],

View File

@ -7539,8 +7539,6 @@ x_error_catcher (Display *display, XErrorEvent *event)
Calling x_uncatch_errors resumes the normal error handling. */
void x_check_errors (Display *dpy, const char *format);
void
x_catch_errors (Display *dpy)
{