]> code.delx.au - gnu-emacs/commitdiff
Merge from mainline.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Apr 2011 06:17:52 +0000 (23:17 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Apr 2011 06:17:52 +0000 (23:17 -0700)
71 files changed:
ChangeLog
Makefile.in
configure.in
lib/gnulib.mk
lib/inttypes.in.h [new file with mode: 0644]
lib/strtoimax.c [new file with mode: 0644]
lib/strtol.c [new file with mode: 0644]
lib/strtoul.c [new file with mode: 0644]
lib/strtoull.c [new file with mode: 0644]
lib/strtoumax.c [new file with mode: 0644]
lib/verify.h [new file with mode: 0644]
m4/gl-comp.m4
m4/inttypes.m4 [new file with mode: 0644]
m4/strtoull.m4 [new file with mode: 0644]
m4/strtoumax.m4 [new file with mode: 0644]
src/ChangeLog
src/alloc.c
src/bidi.c
src/buffer.c
src/buffer.h
src/bytecode.c
src/callint.c
src/ccl.c
src/character.c
src/charset.c
src/chartab.c
src/coding.c
src/composite.c
src/data.c
src/dbusbind.c
src/dispnew.c
src/disptab.h
src/doc.c
src/fns.c
src/font.c
src/font.h
src/frame.c
src/frame.h
src/fringe.c
src/gnutls.c
src/gtkutil.c
src/image.c
src/indent.c
src/intervals.c
src/intervals.h
src/keyboard.c
src/keymap.c
src/lisp.h
src/lread.c
src/m/amdx86-64.h
src/m/ia64.h
src/m/ibms390x.h
src/minibuf.c
src/print.c
src/process.c
src/process.h
src/region-cache.c
src/syntax.c
src/sysdep.c
src/termhooks.h
src/textprop.c
src/w32font.c
src/w32menu.c
src/window.c
src/window.h
src/xdisp.c
src/xfaces.c
src/xfns.c
src/xmenu.c
src/xrdb.c
src/xselect.c

index 3a729327bf399c9eb84ffcd39be58bb59014e705..f67a5bf0b55167ea919546ce7e51844b0a366f82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-04-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * configure.in: Suppress unnecessary checks for size_t.
+       (AC_TYPE_SIZE_T): Define an empty macro, to suppress obsolescent test.
+       (size_t): Do not check for this, and do not typedef.  This code
+       is never exercised now.
+
+       * Makefile.in (GNULIB_MODULES): Add strtoumax.
+       This is needed for the new integer-reading code in lread.c.
+       It automatically pulls in the following gnulib files, which
+       are used on old-fashioned platforms that don't have strtoumax:
+       lib/inttypes.in.h, lib/strtoimax.c, lib/strtol.c, lib/strtoul.c,
+       lib/strtoull.c, lib/strtoumax.c, lib/verify.h, m4/inttypes.m4,
+       m4/strtoull.m4, m4/strtoumax.m4.
+       * .bzrignore: Add lib/inttypes.h.
+
 2011-04-24  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * configure.in: Check for GnuTLS certificate verify callbacks.
index d828649e7aa6329e0e310904da002d43b0ba44db..e5828b3519915729e949a7bea0fd4b702baba6f5 100644 (file)
@@ -333,7 +333,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4
 GNULIB_MODULES = \
   careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu \
   ignore-value intprops lstat mktime readlink \
-  socklen stdio strftime symlink sys_stat
+  socklen stdio strftime strtoumax symlink sys_stat
 GNULIB_TOOL_FLAGS = \
  --import --no-changelog --no-vc-files --makefile-name=gnulib.mk
 sync-from-gnulib: $(gnulib_srcdir)
index b4b4330fd177a25b145b64da30a985bf30863414..546abbe05a53a17ab3f10702a714bb1a2f27b6e6 100644 (file)
@@ -987,6 +987,9 @@ else
   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
 fi
 
+# Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better.
+AC_DEFUN([AC_TYPE_SIZE_T])
+
 dnl Do this early because it can frob feature test macros for Unix-98 &c.
 AC_SYS_LARGEFILE
 
@@ -3036,8 +3039,6 @@ if test $emacs_cv_langinfo_codeset = yes; then
     [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
 fi
 
-AC_CHECK_TYPES(size_t)
-
 AC_TYPE_MBSTATE_T
 
 AC_CACHE_CHECK([for C restricted array declarations], emacs_cv_c_restrict_arr,
@@ -3563,10 +3564,6 @@ extern "C"
 void *alloca (size_t);
 #endif
 
-#ifndef HAVE_SIZE_T
-typedef unsigned size_t;
-#endif
-
 #ifndef HAVE_STRCHR
 #define strchr(a, b) index (a, b)
 #endif
index 868249dda27a145e68c15ead7fbeeaa4b596b603..d79f3c2b5713a7830d33f4d4ee8a677c2ce1aaba 100644 (file)
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdio strftime symlink sys_stat
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdio strftime strtoumax symlink sys_stat
 
 
 MOSTLYCLEANFILES += core *.stackdump
@@ -174,6 +174,48 @@ EXTRA_DIST += intprops.h
 
 ## end   gnulib module intprops
 
+## begin gnulib module inttypes-h
+
+BUILT_SOURCES += inttypes.h
+
+# We need the following in order to create <inttypes.h> when the system
+# doesn't have one that works with the given compiler.
+inttypes.h: inttypes.in.h $(top_builddir)/config.status $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_INTTYPES_H''@|$(NEXT_INTTYPES_H)|g' \
+             -e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \
+             -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
+             -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
+             -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
+             -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \
+             -e 's/@''GNULIB_IMAXABS''@/$(GNULIB_IMAXABS)/g' \
+             -e 's/@''GNULIB_IMAXDIV''@/$(GNULIB_IMAXDIV)/g' \
+             -e 's/@''GNULIB_STRTOIMAX''@/$(GNULIB_STRTOIMAX)/g' \
+             -e 's/@''GNULIB_STRTOUMAX''@/$(GNULIB_STRTOUMAX)/g' \
+             -e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \
+             -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
+             -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
+             -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
+             -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
+             -e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \
+             -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
+             -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/inttypes.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += inttypes.h inttypes.h-t
+
+EXTRA_DIST += inttypes.in.h
+
+## end   gnulib module inttypes-h
+
 ## begin gnulib module lstat
 
 
@@ -532,6 +574,15 @@ EXTRA_libgnu_a_SOURCES += strftime.c
 
 ## end   gnulib module strftime
 
+## begin gnulib module strtoumax
+
+
+EXTRA_DIST += strtoimax.c strtol.c strtoul.c strtoull.c strtoumax.c
+
+EXTRA_libgnu_a_SOURCES += strtoimax.c strtol.c strtoul.c strtoull.c strtoumax.c
+
+## end   gnulib module strtoumax
+
 ## begin gnulib module symlink
 
 
@@ -785,6 +836,12 @@ EXTRA_DIST += unistd.in.h
 
 ## end   gnulib module unistd
 
+## begin gnulib module verify
+
+libgnu_a_SOURCES += verify.h
+
+## end   gnulib module verify
+
 ## begin gnulib module warn-on-use
 
 BUILT_SOURCES += warn-on-use.h
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
new file mode 100644 (file)
index 0000000..7abf394
--- /dev/null
@@ -0,0 +1,1110 @@
+/* Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Written by Paul Eggert, Bruno Haible, Derek Price.
+   This file is part of gnulib.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/*
+ * ISO C 99 <inttypes.h> for platforms that lack it.
+ * <http://www.opengroup.org/susv3xbd/inttypes.h.html>
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Include the original <inttypes.h> if it exists, and if this file
+   has not been included yet or if this file includes gnulib stdint.h
+   which in turn includes this file.
+   The include_next requires a split double-inclusion guard.  */
+#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+# if @HAVE_INTTYPES_H@
+#  @INCLUDE_NEXT@ @NEXT_INTTYPES_H@
+# endif
+#endif
+
+#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+#define INTTYPES_H
+
+/* Include <stdint.h> or the gnulib replacement.
+   But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <stdint.h>
+#endif
+/* Get CHAR_BIT.  */
+#include <limits.h>
+
+#if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX)
+# error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
+#endif
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* 7.8.1 Macros for format specifiers */
+
+#if ! defined __cplusplus || defined __STDC_FORMAT_MACROS
+
+# if defined _TNS_R_TARGET
+   /* Tandem NonStop R series and compatible platforms released before
+      July 2005 support %Ld but not %lld.  */
+#  define _LONG_LONG_FORMAT_PREFIX "L"
+# else
+#  define _LONG_LONG_FORMAT_PREFIX "ll"
+# endif
+
+# if !defined PRId8 || @PRI_MACROS_BROKEN@
+#  undef PRId8
+#  ifdef INT8_MAX
+#   define PRId8 "d"
+#  endif
+# endif
+# if !defined PRIi8 || @PRI_MACROS_BROKEN@
+#  undef PRIi8
+#  ifdef INT8_MAX
+#   define PRIi8 "i"
+#  endif
+# endif
+# if !defined PRIo8 || @PRI_MACROS_BROKEN@
+#  undef PRIo8
+#  ifdef UINT8_MAX
+#   define PRIo8 "o"
+#  endif
+# endif
+# if !defined PRIu8 || @PRI_MACROS_BROKEN@
+#  undef PRIu8
+#  ifdef UINT8_MAX
+#   define PRIu8 "u"
+#  endif
+# endif
+# if !defined PRIx8 || @PRI_MACROS_BROKEN@
+#  undef PRIx8
+#  ifdef UINT8_MAX
+#   define PRIx8 "x"
+#  endif
+# endif
+# if !defined PRIX8 || @PRI_MACROS_BROKEN@
+#  undef PRIX8
+#  ifdef UINT8_MAX
+#   define PRIX8 "X"
+#  endif
+# endif
+# if !defined PRId16 || @PRI_MACROS_BROKEN@
+#  undef PRId16
+#  ifdef INT16_MAX
+#   define PRId16 "d"
+#  endif
+# endif
+# if !defined PRIi16 || @PRI_MACROS_BROKEN@
+#  undef PRIi16
+#  ifdef INT16_MAX
+#   define PRIi16 "i"
+#  endif
+# endif
+# if !defined PRIo16 || @PRI_MACROS_BROKEN@
+#  undef PRIo16
+#  ifdef UINT16_MAX
+#   define PRIo16 "o"
+#  endif
+# endif
+# if !defined PRIu16 || @PRI_MACROS_BROKEN@
+#  undef PRIu16
+#  ifdef UINT16_MAX
+#   define PRIu16 "u"
+#  endif
+# endif
+# if !defined PRIx16 || @PRI_MACROS_BROKEN@
+#  undef PRIx16
+#  ifdef UINT16_MAX
+#   define PRIx16 "x"
+#  endif
+# endif
+# if !defined PRIX16 || @PRI_MACROS_BROKEN@
+#  undef PRIX16
+#  ifdef UINT16_MAX
+#   define PRIX16 "X"
+#  endif
+# endif
+# if !defined PRId32 || @PRI_MACROS_BROKEN@
+#  undef PRId32
+#  ifdef INT32_MAX
+#   define PRId32 "d"
+#  endif
+# endif
+# if !defined PRIi32 || @PRI_MACROS_BROKEN@
+#  undef PRIi32
+#  ifdef INT32_MAX
+#   define PRIi32 "i"
+#  endif
+# endif
+# if !defined PRIo32 || @PRI_MACROS_BROKEN@
+#  undef PRIo32
+#  ifdef UINT32_MAX
+#   define PRIo32 "o"
+#  endif
+# endif
+# if !defined PRIu32 || @PRI_MACROS_BROKEN@
+#  undef PRIu32
+#  ifdef UINT32_MAX
+#   define PRIu32 "u"
+#  endif
+# endif
+# if !defined PRIx32 || @PRI_MACROS_BROKEN@
+#  undef PRIx32
+#  ifdef UINT32_MAX
+#   define PRIx32 "x"
+#  endif
+# endif
+# if !defined PRIX32 || @PRI_MACROS_BROKEN@
+#  undef PRIX32
+#  ifdef UINT32_MAX
+#   define PRIX32 "X"
+#  endif
+# endif
+# ifdef INT64_MAX
+#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
+#   define _PRI64_PREFIX "l"
+#  elif defined _MSC_VER || defined __MINGW32__
+#   define _PRI64_PREFIX "I64"
+#  elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+#   define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
+#  endif
+#  if !defined PRId64 || @PRI_MACROS_BROKEN@
+#   undef PRId64
+#   define PRId64 _PRI64_PREFIX "d"
+#  endif
+#  if !defined PRIi64 || @PRI_MACROS_BROKEN@
+#   undef PRIi64
+#   define PRIi64 _PRI64_PREFIX "i"
+#  endif
+# endif
+# ifdef UINT64_MAX
+#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
+#   define _PRIu64_PREFIX "l"
+#  elif defined _MSC_VER || defined __MINGW32__
+#   define _PRIu64_PREFIX "I64"
+#  elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+#   define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
+#  endif
+#  if !defined PRIo64 || @PRI_MACROS_BROKEN@
+#   undef PRIo64
+#   define PRIo64 _PRIu64_PREFIX "o"
+#  endif
+#  if !defined PRIu64 || @PRI_MACROS_BROKEN@
+#   undef PRIu64
+#   define PRIu64 _PRIu64_PREFIX "u"
+#  endif
+#  if !defined PRIx64 || @PRI_MACROS_BROKEN@
+#   undef PRIx64
+#   define PRIx64 _PRIu64_PREFIX "x"
+#  endif
+#  if !defined PRIX64 || @PRI_MACROS_BROKEN@
+#   undef PRIX64
+#   define PRIX64 _PRIu64_PREFIX "X"
+#  endif
+# endif
+
+# if !defined PRIdLEAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIdLEAST8
+#  define PRIdLEAST8 "d"
+# endif
+# if !defined PRIiLEAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIiLEAST8
+#  define PRIiLEAST8 "i"
+# endif
+# if !defined PRIoLEAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIoLEAST8
+#  define PRIoLEAST8 "o"
+# endif
+# if !defined PRIuLEAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIuLEAST8
+#  define PRIuLEAST8 "u"
+# endif
+# if !defined PRIxLEAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIxLEAST8
+#  define PRIxLEAST8 "x"
+# endif
+# if !defined PRIXLEAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIXLEAST8
+#  define PRIXLEAST8 "X"
+# endif
+# if !defined PRIdLEAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIdLEAST16
+#  define PRIdLEAST16 "d"
+# endif
+# if !defined PRIiLEAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIiLEAST16
+#  define PRIiLEAST16 "i"
+# endif
+# if !defined PRIoLEAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIoLEAST16
+#  define PRIoLEAST16 "o"
+# endif
+# if !defined PRIuLEAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIuLEAST16
+#  define PRIuLEAST16 "u"
+# endif
+# if !defined PRIxLEAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIxLEAST16
+#  define PRIxLEAST16 "x"
+# endif
+# if !defined PRIXLEAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIXLEAST16
+#  define PRIXLEAST16 "X"
+# endif
+# if !defined PRIdLEAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIdLEAST32
+#  define PRIdLEAST32 "d"
+# endif
+# if !defined PRIiLEAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIiLEAST32
+#  define PRIiLEAST32 "i"
+# endif
+# if !defined PRIoLEAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIoLEAST32
+#  define PRIoLEAST32 "o"
+# endif
+# if !defined PRIuLEAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIuLEAST32
+#  define PRIuLEAST32 "u"
+# endif
+# if !defined PRIxLEAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIxLEAST32
+#  define PRIxLEAST32 "x"
+# endif
+# if !defined PRIXLEAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIXLEAST32
+#  define PRIXLEAST32 "X"
+# endif
+# ifdef INT64_MAX
+#  if !defined PRIdLEAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIdLEAST64
+#   define PRIdLEAST64 PRId64
+#  endif
+#  if !defined PRIiLEAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIiLEAST64
+#   define PRIiLEAST64 PRIi64
+#  endif
+# endif
+# ifdef UINT64_MAX
+#  if !defined PRIoLEAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIoLEAST64
+#   define PRIoLEAST64 PRIo64
+#  endif
+#  if !defined PRIuLEAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIuLEAST64
+#   define PRIuLEAST64 PRIu64
+#  endif
+#  if !defined PRIxLEAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIxLEAST64
+#   define PRIxLEAST64 PRIx64
+#  endif
+#  if !defined PRIXLEAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIXLEAST64
+#   define PRIXLEAST64 PRIX64
+#  endif
+# endif
+
+# if !defined PRIdFAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIdFAST8
+#  if INT_FAST8_MAX > INT32_MAX
+#   define PRIdFAST8 PRId64
+#  else
+#   define PRIdFAST8 "d"
+#  endif
+# endif
+# if !defined PRIiFAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIiFAST8
+#  if INT_FAST8_MAX > INT32_MAX
+#   define PRIiFAST8 PRIi64
+#  else
+#   define PRIiFAST8 "i"
+#  endif
+# endif
+# if !defined PRIoFAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIoFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define PRIoFAST8 PRIo64
+#  else
+#   define PRIoFAST8 "o"
+#  endif
+# endif
+# if !defined PRIuFAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIuFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define PRIuFAST8 PRIu64
+#  else
+#   define PRIuFAST8 "u"
+#  endif
+# endif
+# if !defined PRIxFAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIxFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define PRIxFAST8 PRIx64
+#  else
+#   define PRIxFAST8 "x"
+#  endif
+# endif
+# if !defined PRIXFAST8 || @PRI_MACROS_BROKEN@
+#  undef PRIXFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define PRIXFAST8 PRIX64
+#  else
+#   define PRIXFAST8 "X"
+#  endif
+# endif
+# if !defined PRIdFAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIdFAST16
+#  if INT_FAST16_MAX > INT32_MAX
+#   define PRIdFAST16 PRId64
+#  else
+#   define PRIdFAST16 "d"
+#  endif
+# endif
+# if !defined PRIiFAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIiFAST16
+#  if INT_FAST16_MAX > INT32_MAX
+#   define PRIiFAST16 PRIi64
+#  else
+#   define PRIiFAST16 "i"
+#  endif
+# endif
+# if !defined PRIoFAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIoFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define PRIoFAST16 PRIo64
+#  else
+#   define PRIoFAST16 "o"
+#  endif
+# endif
+# if !defined PRIuFAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIuFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define PRIuFAST16 PRIu64
+#  else
+#   define PRIuFAST16 "u"
+#  endif
+# endif
+# if !defined PRIxFAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIxFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define PRIxFAST16 PRIx64
+#  else
+#   define PRIxFAST16 "x"
+#  endif
+# endif
+# if !defined PRIXFAST16 || @PRI_MACROS_BROKEN@
+#  undef PRIXFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define PRIXFAST16 PRIX64
+#  else
+#   define PRIXFAST16 "X"
+#  endif
+# endif
+# if !defined PRIdFAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIdFAST32
+#  if INT_FAST32_MAX > INT32_MAX
+#   define PRIdFAST32 PRId64
+#  else
+#   define PRIdFAST32 "d"
+#  endif
+# endif
+# if !defined PRIiFAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIiFAST32
+#  if INT_FAST32_MAX > INT32_MAX
+#   define PRIiFAST32 PRIi64
+#  else
+#   define PRIiFAST32 "i"
+#  endif
+# endif
+# if !defined PRIoFAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIoFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define PRIoFAST32 PRIo64
+#  else
+#   define PRIoFAST32 "o"
+#  endif
+# endif
+# if !defined PRIuFAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIuFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define PRIuFAST32 PRIu64
+#  else
+#   define PRIuFAST32 "u"
+#  endif
+# endif
+# if !defined PRIxFAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIxFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define PRIxFAST32 PRIx64
+#  else
+#   define PRIxFAST32 "x"
+#  endif
+# endif
+# if !defined PRIXFAST32 || @PRI_MACROS_BROKEN@
+#  undef PRIXFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define PRIXFAST32 PRIX64
+#  else
+#   define PRIXFAST32 "X"
+#  endif
+# endif
+# ifdef INT64_MAX
+#  if !defined PRIdFAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIdFAST64
+#   define PRIdFAST64 PRId64
+#  endif
+#  if !defined PRIiFAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIiFAST64
+#   define PRIiFAST64 PRIi64
+#  endif
+# endif
+# ifdef UINT64_MAX
+#  if !defined PRIoFAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIoFAST64
+#   define PRIoFAST64 PRIo64
+#  endif
+#  if !defined PRIuFAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIuFAST64
+#   define PRIuFAST64 PRIu64
+#  endif
+#  if !defined PRIxFAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIxFAST64
+#   define PRIxFAST64 PRIx64
+#  endif
+#  if !defined PRIXFAST64 || @PRI_MACROS_BROKEN@
+#   undef PRIXFAST64
+#   define PRIXFAST64 PRIX64
+#  endif
+# endif
+
+# if !defined PRIdMAX || @PRI_MACROS_BROKEN@
+#  undef PRIdMAX
+#  if @INT32_MAX_LT_INTMAX_MAX@
+#   define PRIdMAX PRId64
+#  else
+#   define PRIdMAX "ld"
+#  endif
+# endif
+# if !defined PRIiMAX || @PRI_MACROS_BROKEN@
+#  undef PRIiMAX
+#  if @INT32_MAX_LT_INTMAX_MAX@
+#   define PRIiMAX PRIi64
+#  else
+#   define PRIiMAX "li"
+#  endif
+# endif
+# if !defined PRIoMAX || @PRI_MACROS_BROKEN@
+#  undef PRIoMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define PRIoMAX PRIo64
+#  else
+#   define PRIoMAX "lo"
+#  endif
+# endif
+# if !defined PRIuMAX || @PRI_MACROS_BROKEN@
+#  undef PRIuMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define PRIuMAX PRIu64
+#  else
+#   define PRIuMAX "lu"
+#  endif
+# endif
+# if !defined PRIxMAX || @PRI_MACROS_BROKEN@
+#  undef PRIxMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define PRIxMAX PRIx64
+#  else
+#   define PRIxMAX "lx"
+#  endif
+# endif
+# if !defined PRIXMAX || @PRI_MACROS_BROKEN@
+#  undef PRIXMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define PRIXMAX PRIX64
+#  else
+#   define PRIXMAX "lX"
+#  endif
+# endif
+
+# if !defined PRIdPTR || @PRI_MACROS_BROKEN@
+#  undef PRIdPTR
+#  ifdef INTPTR_MAX
+#   define PRIdPTR @PRIPTR_PREFIX@ "d"
+#  endif
+# endif
+# if !defined PRIiPTR || @PRI_MACROS_BROKEN@
+#  undef PRIiPTR
+#  ifdef INTPTR_MAX
+#   define PRIiPTR @PRIPTR_PREFIX@ "i"
+#  endif
+# endif
+# if !defined PRIoPTR || @PRI_MACROS_BROKEN@
+#  undef PRIoPTR
+#  ifdef UINTPTR_MAX
+#   define PRIoPTR @PRIPTR_PREFIX@ "o"
+#  endif
+# endif
+# if !defined PRIuPTR || @PRI_MACROS_BROKEN@
+#  undef PRIuPTR
+#  ifdef UINTPTR_MAX
+#   define PRIuPTR @PRIPTR_PREFIX@ "u"
+#  endif
+# endif
+# if !defined PRIxPTR || @PRI_MACROS_BROKEN@
+#  undef PRIxPTR
+#  ifdef UINTPTR_MAX
+#   define PRIxPTR @PRIPTR_PREFIX@ "x"
+#  endif
+# endif
+# if !defined PRIXPTR || @PRI_MACROS_BROKEN@
+#  undef PRIXPTR
+#  ifdef UINTPTR_MAX
+#   define PRIXPTR @PRIPTR_PREFIX@ "X"
+#  endif
+# endif
+
+# if !defined SCNd8 || @PRI_MACROS_BROKEN@
+#  undef SCNd8
+#  ifdef INT8_MAX
+#   define SCNd8 "hhd"
+#  endif
+# endif
+# if !defined SCNi8 || @PRI_MACROS_BROKEN@
+#  undef SCNi8
+#  ifdef INT8_MAX
+#   define SCNi8 "hhi"
+#  endif
+# endif
+# if !defined SCNo8 || @PRI_MACROS_BROKEN@
+#  undef SCNo8
+#  ifdef UINT8_MAX
+#   define SCNo8 "hho"
+#  endif
+# endif
+# if !defined SCNu8 || @PRI_MACROS_BROKEN@
+#  undef SCNu8
+#  ifdef UINT8_MAX
+#   define SCNu8 "hhu"
+#  endif
+# endif
+# if !defined SCNx8 || @PRI_MACROS_BROKEN@
+#  undef SCNx8
+#  ifdef UINT8_MAX
+#   define SCNx8 "hhx"
+#  endif
+# endif
+# if !defined SCNd16 || @PRI_MACROS_BROKEN@
+#  undef SCNd16
+#  ifdef INT16_MAX
+#   define SCNd16 "hd"
+#  endif
+# endif
+# if !defined SCNi16 || @PRI_MACROS_BROKEN@
+#  undef SCNi16
+#  ifdef INT16_MAX
+#   define SCNi16 "hi"
+#  endif
+# endif
+# if !defined SCNo16 || @PRI_MACROS_BROKEN@
+#  undef SCNo16
+#  ifdef UINT16_MAX
+#   define SCNo16 "ho"
+#  endif
+# endif
+# if !defined SCNu16 || @PRI_MACROS_BROKEN@
+#  undef SCNu16
+#  ifdef UINT16_MAX
+#   define SCNu16 "hu"
+#  endif
+# endif
+# if !defined SCNx16 || @PRI_MACROS_BROKEN@
+#  undef SCNx16
+#  ifdef UINT16_MAX
+#   define SCNx16 "hx"
+#  endif
+# endif
+# if !defined SCNd32 || @PRI_MACROS_BROKEN@
+#  undef SCNd32
+#  ifdef INT32_MAX
+#   define SCNd32 "d"
+#  endif
+# endif
+# if !defined SCNi32 || @PRI_MACROS_BROKEN@
+#  undef SCNi32
+#  ifdef INT32_MAX
+#   define SCNi32 "i"
+#  endif
+# endif
+# if !defined SCNo32 || @PRI_MACROS_BROKEN@
+#  undef SCNo32
+#  ifdef UINT32_MAX
+#   define SCNo32 "o"
+#  endif
+# endif
+# if !defined SCNu32 || @PRI_MACROS_BROKEN@
+#  undef SCNu32
+#  ifdef UINT32_MAX
+#   define SCNu32 "u"
+#  endif
+# endif
+# if !defined SCNx32 || @PRI_MACROS_BROKEN@
+#  undef SCNx32
+#  ifdef UINT32_MAX
+#   define SCNx32 "x"
+#  endif
+# endif
+# ifdef INT64_MAX
+#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
+#   define _SCN64_PREFIX "l"
+#  elif defined _MSC_VER || defined __MINGW32__
+#   define _SCN64_PREFIX "I64"
+#  elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+#   define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
+#  endif
+#  if !defined SCNd64 || @PRI_MACROS_BROKEN@
+#   undef SCNd64
+#   define SCNd64 _SCN64_PREFIX "d"
+#  endif
+#  if !defined SCNi64 || @PRI_MACROS_BROKEN@
+#   undef SCNi64
+#   define SCNi64 _SCN64_PREFIX "i"
+#  endif
+# endif
+# ifdef UINT64_MAX
+#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
+#   define _SCNu64_PREFIX "l"
+#  elif defined _MSC_VER || defined __MINGW32__
+#   define _SCNu64_PREFIX "I64"
+#  elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+#   define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
+#  endif
+#  if !defined SCNo64 || @PRI_MACROS_BROKEN@
+#   undef SCNo64
+#   define SCNo64 _SCNu64_PREFIX "o"
+#  endif
+#  if !defined SCNu64 || @PRI_MACROS_BROKEN@
+#   undef SCNu64
+#   define SCNu64 _SCNu64_PREFIX "u"
+#  endif
+#  if !defined SCNx64 || @PRI_MACROS_BROKEN@
+#   undef SCNx64
+#   define SCNx64 _SCNu64_PREFIX "x"
+#  endif
+# endif
+
+# if !defined SCNdLEAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNdLEAST8
+#  define SCNdLEAST8 "hhd"
+# endif
+# if !defined SCNiLEAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNiLEAST8
+#  define SCNiLEAST8 "hhi"
+# endif
+# if !defined SCNoLEAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNoLEAST8
+#  define SCNoLEAST8 "hho"
+# endif
+# if !defined SCNuLEAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNuLEAST8
+#  define SCNuLEAST8 "hhu"
+# endif
+# if !defined SCNxLEAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNxLEAST8
+#  define SCNxLEAST8 "hhx"
+# endif
+# if !defined SCNdLEAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNdLEAST16
+#  define SCNdLEAST16 "hd"
+# endif
+# if !defined SCNiLEAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNiLEAST16
+#  define SCNiLEAST16 "hi"
+# endif
+# if !defined SCNoLEAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNoLEAST16
+#  define SCNoLEAST16 "ho"
+# endif
+# if !defined SCNuLEAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNuLEAST16
+#  define SCNuLEAST16 "hu"
+# endif
+# if !defined SCNxLEAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNxLEAST16
+#  define SCNxLEAST16 "hx"
+# endif
+# if !defined SCNdLEAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNdLEAST32
+#  define SCNdLEAST32 "d"
+# endif
+# if !defined SCNiLEAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNiLEAST32
+#  define SCNiLEAST32 "i"
+# endif
+# if !defined SCNoLEAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNoLEAST32
+#  define SCNoLEAST32 "o"
+# endif
+# if !defined SCNuLEAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNuLEAST32
+#  define SCNuLEAST32 "u"
+# endif
+# if !defined SCNxLEAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNxLEAST32
+#  define SCNxLEAST32 "x"
+# endif
+# ifdef INT64_MAX
+#  if !defined SCNdLEAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNdLEAST64
+#   define SCNdLEAST64 SCNd64
+#  endif
+#  if !defined SCNiLEAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNiLEAST64
+#   define SCNiLEAST64 SCNi64
+#  endif
+# endif
+# ifdef UINT64_MAX
+#  if !defined SCNoLEAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNoLEAST64
+#   define SCNoLEAST64 SCNo64
+#  endif
+#  if !defined SCNuLEAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNuLEAST64
+#   define SCNuLEAST64 SCNu64
+#  endif
+#  if !defined SCNxLEAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNxLEAST64
+#   define SCNxLEAST64 SCNx64
+#  endif
+# endif
+
+# if !defined SCNdFAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNdFAST8
+#  if INT_FAST8_MAX > INT32_MAX
+#   define SCNdFAST8 SCNd64
+#  elif INT_FAST8_MAX == 0x7fff
+#   define SCNdFAST8 "hd"
+#  elif INT_FAST8_MAX == 0x7f
+#   define SCNdFAST8 "hhd"
+#  else
+#   define SCNdFAST8 "d"
+#  endif
+# endif
+# if !defined SCNiFAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNiFAST8
+#  if INT_FAST8_MAX > INT32_MAX
+#   define SCNiFAST8 SCNi64
+#  elif INT_FAST8_MAX == 0x7fff
+#   define SCNiFAST8 "hi"
+#  elif INT_FAST8_MAX == 0x7f
+#   define SCNiFAST8 "hhi"
+#  else
+#   define SCNiFAST8 "i"
+#  endif
+# endif
+# if !defined SCNoFAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNoFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define SCNoFAST8 SCNo64
+#  elif UINT_FAST8_MAX == 0xffff
+#   define SCNoFAST8 "ho"
+#  elif UINT_FAST8_MAX == 0xff
+#   define SCNoFAST8 "hho"
+#  else
+#   define SCNoFAST8 "o"
+#  endif
+# endif
+# if !defined SCNuFAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNuFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define SCNuFAST8 SCNu64
+#  elif UINT_FAST8_MAX == 0xffff
+#   define SCNuFAST8 "hu"
+#  elif UINT_FAST8_MAX == 0xff
+#   define SCNuFAST8 "hhu"
+#  else
+#   define SCNuFAST8 "u"
+#  endif
+# endif
+# if !defined SCNxFAST8 || @PRI_MACROS_BROKEN@
+#  undef SCNxFAST8
+#  if UINT_FAST8_MAX > UINT32_MAX
+#   define SCNxFAST8 SCNx64
+#  elif UINT_FAST8_MAX == 0xffff
+#   define SCNxFAST8 "hx"
+#  elif UINT_FAST8_MAX == 0xff
+#   define SCNxFAST8 "hhx"
+#  else
+#   define SCNxFAST8 "x"
+#  endif
+# endif
+# if !defined SCNdFAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNdFAST16
+#  if INT_FAST16_MAX > INT32_MAX
+#   define SCNdFAST16 SCNd64
+#  elif INT_FAST16_MAX == 0x7fff
+#   define SCNdFAST16 "hd"
+#  else
+#   define SCNdFAST16 "d"
+#  endif
+# endif
+# if !defined SCNiFAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNiFAST16
+#  if INT_FAST16_MAX > INT32_MAX
+#   define SCNiFAST16 SCNi64
+#  elif INT_FAST16_MAX == 0x7fff
+#   define SCNiFAST16 "hi"
+#  else
+#   define SCNiFAST16 "i"
+#  endif
+# endif
+# if !defined SCNoFAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNoFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define SCNoFAST16 SCNo64
+#  elif UINT_FAST16_MAX == 0xffff
+#   define SCNoFAST16 "ho"
+#  else
+#   define SCNoFAST16 "o"
+#  endif
+# endif
+# if !defined SCNuFAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNuFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define SCNuFAST16 SCNu64
+#  elif UINT_FAST16_MAX == 0xffff
+#   define SCNuFAST16 "hu"
+#  else
+#   define SCNuFAST16 "u"
+#  endif
+# endif
+# if !defined SCNxFAST16 || @PRI_MACROS_BROKEN@
+#  undef SCNxFAST16
+#  if UINT_FAST16_MAX > UINT32_MAX
+#   define SCNxFAST16 SCNx64
+#  elif UINT_FAST16_MAX == 0xffff
+#   define SCNxFAST16 "hx"
+#  else
+#   define SCNxFAST16 "x"
+#  endif
+# endif
+# if !defined SCNdFAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNdFAST32
+#  if INT_FAST32_MAX > INT32_MAX
+#   define SCNdFAST32 SCNd64
+#  else
+#   define SCNdFAST32 "d"
+#  endif
+# endif
+# if !defined SCNiFAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNiFAST32
+#  if INT_FAST32_MAX > INT32_MAX
+#   define SCNiFAST32 SCNi64
+#  else
+#   define SCNiFAST32 "i"
+#  endif
+# endif
+# if !defined SCNoFAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNoFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define SCNoFAST32 SCNo64
+#  else
+#   define SCNoFAST32 "o"
+#  endif
+# endif
+# if !defined SCNuFAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNuFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define SCNuFAST32 SCNu64
+#  else
+#   define SCNuFAST32 "u"
+#  endif
+# endif
+# if !defined SCNxFAST32 || @PRI_MACROS_BROKEN@
+#  undef SCNxFAST32
+#  if UINT_FAST32_MAX > UINT32_MAX
+#   define SCNxFAST32 SCNx64
+#  else
+#   define SCNxFAST32 "x"
+#  endif
+# endif
+# ifdef INT64_MAX
+#  if !defined SCNdFAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNdFAST64
+#   define SCNdFAST64 SCNd64
+#  endif
+#  if !defined SCNiFAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNiFAST64
+#   define SCNiFAST64 SCNi64
+#  endif
+# endif
+# ifdef UINT64_MAX
+#  if !defined SCNoFAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNoFAST64
+#   define SCNoFAST64 SCNo64
+#  endif
+#  if !defined SCNuFAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNuFAST64
+#   define SCNuFAST64 SCNu64
+#  endif
+#  if !defined SCNxFAST64 || @PRI_MACROS_BROKEN@
+#   undef SCNxFAST64
+#   define SCNxFAST64 SCNx64
+#  endif
+# endif
+
+# if !defined SCNdMAX || @PRI_MACROS_BROKEN@
+#  undef SCNdMAX
+#  if @INT32_MAX_LT_INTMAX_MAX@
+#   define SCNdMAX SCNd64
+#  else
+#   define SCNdMAX "ld"
+#  endif
+# endif
+# if !defined SCNiMAX || @PRI_MACROS_BROKEN@
+#  undef SCNiMAX
+#  if @INT32_MAX_LT_INTMAX_MAX@
+#   define SCNiMAX SCNi64
+#  else
+#   define SCNiMAX "li"
+#  endif
+# endif
+# if !defined SCNoMAX || @PRI_MACROS_BROKEN@
+#  undef SCNoMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define SCNoMAX SCNo64
+#  else
+#   define SCNoMAX "lo"
+#  endif
+# endif
+# if !defined SCNuMAX || @PRI_MACROS_BROKEN@
+#  undef SCNuMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define SCNuMAX SCNu64
+#  else
+#   define SCNuMAX "lu"
+#  endif
+# endif
+# if !defined SCNxMAX || @PRI_MACROS_BROKEN@
+#  undef SCNxMAX
+#  if @UINT32_MAX_LT_UINTMAX_MAX@
+#   define SCNxMAX SCNx64
+#  else
+#   define SCNxMAX "lx"
+#  endif
+# endif
+
+# if !defined SCNdPTR || @PRI_MACROS_BROKEN@
+#  undef SCNdPTR
+#  ifdef INTPTR_MAX
+#   define SCNdPTR @PRIPTR_PREFIX@ "d"
+#  endif
+# endif
+# if !defined SCNiPTR || @PRI_MACROS_BROKEN@
+#  undef SCNiPTR
+#  ifdef INTPTR_MAX
+#   define SCNiPTR @PRIPTR_PREFIX@ "i"
+#  endif
+# endif
+# if !defined SCNoPTR || @PRI_MACROS_BROKEN@
+#  undef SCNoPTR
+#  ifdef UINTPTR_MAX
+#   define SCNoPTR @PRIPTR_PREFIX@ "o"
+#  endif
+# endif
+# if !defined SCNuPTR || @PRI_MACROS_BROKEN@
+#  undef SCNuPTR
+#  ifdef UINTPTR_MAX
+#   define SCNuPTR @PRIPTR_PREFIX@ "u"
+#  endif
+# endif
+# if !defined SCNxPTR || @PRI_MACROS_BROKEN@
+#  undef SCNxPTR
+#  ifdef UINTPTR_MAX
+#   define SCNxPTR @PRIPTR_PREFIX@ "x"
+#  endif
+# endif
+
+#endif
+
+/* 7.8.2 Functions for greatest-width integer types */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if @GNULIB_IMAXABS@
+# if !@HAVE_DECL_IMAXABS@
+extern intmax_t imaxabs (intmax_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef imaxabs
+# if HAVE_RAW_DECL_IMAXABS
+_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
+                 "use gnulib module imaxabs for portability");
+# endif
+#endif
+
+#if @GNULIB_IMAXDIV@
+# if !@HAVE_DECL_IMAXDIV@
+#  if !GNULIB_defined_imaxdiv_t
+typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
+#   define GNULIB_defined_imaxdiv_t 1
+#  endif
+extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef imaxdiv
+# if HAVE_RAW_DECL_IMAXDIV
+_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
+                 "use gnulib module imaxdiv for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOIMAX@
+# if !@HAVE_DECL_STRTOIMAX@
+#  undef strtoimax
+extern intmax_t strtoimax (const char *, char **, int) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoimax
+# if HAVE_RAW_DECL_STRTOIMAX
+_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
+                 "use gnulib module strtoimax for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOUMAX@
+# if !@HAVE_DECL_STRTOUMAX@
+#  undef strtoumax
+extern uintmax_t strtoumax (const char *, char **, int) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoumax
+# if HAVE_RAW_DECL_STRTOUMAX
+_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
+                 "use gnulib module strtoumax for portability");
+# endif
+#endif
+
+/* Don't bother defining or declaring wcstoimax and wcstoumax, since
+   wide-character functions like this are hardly ever useful.  */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
new file mode 100644 (file)
index 0000000..497d155
--- /dev/null
@@ -0,0 +1,75 @@
+/* Convert string representation of a number into an intmax_t value.
+
+   Copyright (C) 1999, 2001-2004, 2006, 2009-2011 Free Software Foundation,
+   Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+/* Verify interface.  */
+#include <inttypes.h>
+
+#include <stdlib.h>
+
+#include "verify.h"
+
+#ifdef UNSIGNED
+# ifndef HAVE_DECL_STRTOULL
+"this configure-time declaration test was not run"
+# endif
+# if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG_INT
+unsigned long long int strtoull (char const *, char **, int);
+# endif
+
+#else
+
+# ifndef HAVE_DECL_STRTOLL
+"this configure-time declaration test was not run"
+# endif
+# if !HAVE_DECL_STRTOLL && HAVE_LONG_LONG_INT
+long long int strtoll (char const *, char **, int);
+# endif
+#endif
+
+#ifdef UNSIGNED
+# define Have_long_long HAVE_UNSIGNED_LONG_LONG_INT
+# define Int uintmax_t
+# define Unsigned unsigned
+# define strtoimax strtoumax
+# define strtol strtoul
+# define strtoll strtoull
+#else
+# define Have_long_long HAVE_LONG_LONG_INT
+# define Int intmax_t
+# define Unsigned
+#endif
+
+Int
+strtoimax (char const *ptr, char **endptr, int base)
+{
+#if Have_long_long
+  verify (sizeof (Int) == sizeof (Unsigned long int)
+          || sizeof (Int) == sizeof (Unsigned long long int));
+
+  if (sizeof (Int) != sizeof (Unsigned long int))
+    return strtoll (ptr, endptr, base);
+#else
+  verify (sizeof (Int) == sizeof (Unsigned long int));
+#endif
+
+  return strtol (ptr, endptr, base);
+}
diff --git a/lib/strtol.c b/lib/strtol.c
new file mode 100644 (file)
index 0000000..6c15d11
--- /dev/null
@@ -0,0 +1,433 @@
+/* Convert string representation of a number into an integer value.
+
+   Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2011 Free Software
+   Foundation, Inc.
+
+   NOTE: The canonical source of this file is maintained with the GNU C
+   Library.  Bugs can be reported to bug-glibc@gnu.org.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 3 of the License, or any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef _LIBC
+# define USE_NUMBER_GROUPING
+#else
+# include <config.h>
+#endif
+
+#include <ctype.h>
+#include <errno.h>
+#ifndef __set_errno
+# define __set_errno(Val) errno = (Val)
+#endif
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef USE_NUMBER_GROUPING
+# include "../locale/localeinfo.h"
+#endif
+
+/* Nonzero if we are defining `strtoul' or `strtoull', operating on
+   unsigned integers.  */
+#ifndef UNSIGNED
+# define UNSIGNED 0
+# define INT LONG int
+#else
+# define INT unsigned LONG int
+#endif
+
+/* Determine the name.  */
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# if UNSIGNED
+#  ifdef USE_WIDE_CHAR
+#   ifdef QUAD
+#    define strtol __wcstoull_l
+#   else
+#    define strtol __wcstoul_l
+#   endif
+#  else
+#   ifdef QUAD
+#    define strtol __strtoull_l
+#   else
+#    define strtol __strtoul_l
+#   endif
+#  endif
+# else
+#  ifdef USE_WIDE_CHAR
+#   ifdef QUAD
+#    define strtol __wcstoll_l
+#   else
+#    define strtol __wcstol_l
+#   endif
+#  else
+#   ifdef QUAD
+#    define strtol __strtoll_l
+#   else
+#    define strtol __strtol_l
+#   endif
+#  endif
+# endif
+#else
+# if UNSIGNED
+#  ifdef USE_WIDE_CHAR
+#   ifdef QUAD
+#    define strtol wcstoull
+#   else
+#    define strtol wcstoul
+#   endif
+#  else
+#   ifdef QUAD
+#    define strtol strtoull
+#   else
+#    define strtol strtoul
+#   endif
+#  endif
+# else
+#  ifdef USE_WIDE_CHAR
+#   ifdef QUAD
+#    define strtol wcstoll
+#   else
+#    define strtol wcstol
+#   endif
+#  else
+#   ifdef QUAD
+#    define strtol strtoll
+#   endif
+#  endif
+# endif
+#endif
+
+/* If QUAD is defined, we are defining `strtoll' or `strtoull',
+   operating on `long long int's.  */
+#ifdef QUAD
+# define LONG long long
+# define STRTOL_LONG_MIN LLONG_MIN
+# define STRTOL_LONG_MAX LLONG_MAX
+# define STRTOL_ULONG_MAX ULLONG_MAX
+
+/* The extra casts in the following macros work around compiler bugs,
+   e.g., in Cray C 5.0.3.0.  */
+
+/* True if negative values of the signed integer type T use two's
+   complement, ones' complement, or signed magnitude representation,
+   respectively.  Much GNU code assumes two's complement, but some
+   people like to be portable to all possible C hosts.  */
+# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
+# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
+# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
+
+/* True if the arithmetic type T is signed.  */
+# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* The maximum and minimum values for the integer type T.  These
+   macros have undefined behavior if T is signed and has padding bits.
+   If this is a problem for you, please let us know how to fix it for
+   your host.  */
+# define TYPE_MINIMUM(t) \
+   ((t) (! TYPE_SIGNED (t) \
+         ? (t) 0 \
+         : TYPE_SIGNED_MAGNITUDE (t) \
+         ? ~ (t) 0 \
+         : ~ TYPE_MAXIMUM (t)))
+# define TYPE_MAXIMUM(t) \
+   ((t) (! TYPE_SIGNED (t) \
+         ? (t) -1 \
+         : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+
+# ifndef ULLONG_MAX
+#  define ULLONG_MAX TYPE_MAXIMUM (unsigned long long)
+# endif
+# ifndef LLONG_MAX
+#  define LLONG_MAX TYPE_MAXIMUM (long long int)
+# endif
+# ifndef LLONG_MIN
+#  define LLONG_MIN TYPE_MINIMUM (long long int)
+# endif
+
+# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
+   /* Work around gcc bug with using this constant.  */
+   static const unsigned long long int maxquad = ULLONG_MAX;
+#  undef STRTOL_ULONG_MAX
+#  define STRTOL_ULONG_MAX maxquad
+# endif
+#else
+# define LONG long
+# define STRTOL_LONG_MIN LONG_MIN
+# define STRTOL_LONG_MAX LONG_MAX
+# define STRTOL_ULONG_MAX ULONG_MAX
+#endif
+
+
+/* We use this code also for the extended locale handling where the
+   function gets as an additional argument the locale which has to be
+   used.  To access the values we have to redefine the _NL_CURRENT
+   macro.  */
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# undef _NL_CURRENT
+# define _NL_CURRENT(category, item) \
+  (current->values[_NL_ITEM_INDEX (item)].string)
+# define LOCALE_PARAM , loc
+# define LOCALE_PARAM_PROTO , __locale_t loc
+#else
+# define LOCALE_PARAM
+# define LOCALE_PARAM_PROTO
+#endif
+
+#ifdef USE_WIDE_CHAR
+# include <wchar.h>
+# include <wctype.h>
+# define L_(Ch) L##Ch
+# define UCHAR_TYPE wint_t
+# define STRING_TYPE wchar_t
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define ISSPACE(Ch) __iswspace_l ((Ch), loc)
+#  define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
+#  define TOUPPER(Ch) __towupper_l ((Ch), loc)
+# else
+#  define ISSPACE(Ch) iswspace (Ch)
+#  define ISALPHA(Ch) iswalpha (Ch)
+#  define TOUPPER(Ch) towupper (Ch)
+# endif
+#else
+# define L_(Ch) Ch
+# define UCHAR_TYPE unsigned char
+# define STRING_TYPE char
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define ISSPACE(Ch) __isspace_l ((Ch), loc)
+#  define ISALPHA(Ch) __isalpha_l ((Ch), loc)
+#  define TOUPPER(Ch) __toupper_l ((Ch), loc)
+# else
+#  define ISSPACE(Ch) isspace (Ch)
+#  define ISALPHA(Ch) isalpha (Ch)
+#  define TOUPPER(Ch) toupper (Ch)
+# endif
+#endif
+
+#define INTERNAL(X) INTERNAL1(X)
+#define INTERNAL1(X) __##X##_internal
+#define WEAKNAME(X) WEAKNAME1(X)
+
+#ifdef USE_NUMBER_GROUPING
+/* This file defines a function to check for correct grouping.  */
+# include "grouping.h"
+#endif
+
+
+
+/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
+   If BASE is 0 the base is determined by the presence of a leading
+   zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
+   If BASE is < 2 or > 36, it is reset to 10.
+   If ENDPTR is not NULL, a pointer to the character after the last
+   one converted is stored in *ENDPTR.  */
+
+INT
+INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
+                   int base, int group LOCALE_PARAM_PROTO)
+{
+  int negative;
+  register unsigned LONG int cutoff;
+  register unsigned int cutlim;
+  register unsigned LONG int i;
+  register const STRING_TYPE *s;
+  register UCHAR_TYPE c;
+  const STRING_TYPE *save, *end;
+  int overflow;
+
+#ifdef USE_NUMBER_GROUPING
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+  struct locale_data *current = loc->__locales[LC_NUMERIC];
+# endif
+  /* The thousands character of the current locale.  */
+  wchar_t thousands = L'\0';
+  /* The numeric grouping specification of the current locale,
+     in the format described in <locale.h>.  */
+  const char *grouping;
+
+  if (group)
+    {
+      grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
+      if (*grouping <= 0 || *grouping == CHAR_MAX)
+        grouping = NULL;
+      else
+        {
+          /* Figure out the thousands separator character.  */
+# if defined _LIBC || defined _HAVE_BTOWC
+          thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP));
+          if (thousands == WEOF)
+            thousands = L'\0';
+# endif
+          if (thousands == L'\0')
+            grouping = NULL;
+        }
+    }
+  else
+    grouping = NULL;
+#endif
+
+  if (base < 0 || base == 1 || base > 36)
+    {
+      __set_errno (EINVAL);
+      return 0;
+    }
+
+  save = s = nptr;
+
+  /* Skip white space.  */
+  while (ISSPACE (*s))
+    ++s;
+  if (*s == L_('\0'))
+    goto noconv;
+
+  /* Check for a sign.  */
+  if (*s == L_('-'))
+    {
+      negative = 1;
+      ++s;
+    }
+  else if (*s == L_('+'))
+    {
+      negative = 0;
+      ++s;
+    }
+  else
+    negative = 0;
+
+  /* Recognize number prefix and if BASE is zero, figure it out ourselves.  */
+  if (*s == L_('0'))
+    {
+      if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X'))
+        {
+          s += 2;
+          base = 16;
+        }
+      else if (base == 0)
+        base = 8;
+    }
+  else if (base == 0)
+    base = 10;
+
+  /* Save the pointer so we can check later if anything happened.  */
+  save = s;
+
+#ifdef USE_NUMBER_GROUPING
+  if (group)
+    {
+      /* Find the end of the digit string and check its grouping.  */
+      end = s;
+      for (c = *end; c != L_('\0'); c = *++end)
+        if ((wchar_t) c != thousands
+            && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9'))
+            && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base))
+          break;
+      if (*s == thousands)
+        end = s;
+      else
+        end = correctly_grouped_prefix (s, end, thousands, grouping);
+    }
+  else
+#endif
+    end = NULL;
+
+  cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base;
+  cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base;
+
+  overflow = 0;
+  i = 0;
+  for (c = *s; c != L_('\0'); c = *++s)
+    {
+      if (s == end)
+        break;
+      if (c >= L_('0') && c <= L_('9'))
+        c -= L_('0');
+      else if (ISALPHA (c))
+        c = TOUPPER (c) - L_('A') + 10;
+      else
+        break;
+      if ((int) c >= base)
+        break;
+      /* Check for overflow.  */
+      if (i > cutoff || (i == cutoff && c > cutlim))
+        overflow = 1;
+      else
+        {
+          i *= (unsigned LONG int) base;
+          i += c;
+        }
+    }
+
+  /* Check if anything actually happened.  */
+  if (s == save)
+    goto noconv;
+
+  /* Store in ENDPTR the address of one character
+     past the last character we converted.  */
+  if (endptr != NULL)
+    *endptr = (STRING_TYPE *) s;
+
+#if !UNSIGNED
+  /* Check for a value that is within the range of
+     `unsigned LONG int', but outside the range of `LONG int'.  */
+  if (overflow == 0
+      && i > (negative
+              ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
+              : (unsigned LONG int) STRTOL_LONG_MAX))
+    overflow = 1;
+#endif
+
+  if (overflow)
+    {
+      __set_errno (ERANGE);
+#if UNSIGNED
+      return STRTOL_ULONG_MAX;
+#else
+      return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX;
+#endif
+    }
+
+  /* Return the result of the appropriate sign.  */
+  return negative ? -i : i;
+
+noconv:
+  /* We must handle a special case here: the base is 0 or 16 and the
+     first two characters are '0' and 'x', but the rest are no
+     hexadecimal digits.  This is no error case.  We return 0 and
+     ENDPTR points to the `x`.  */
+  if (endptr != NULL)
+    {
+      if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
+          && save[-2] == L_('0'))
+        *endptr = (STRING_TYPE *) &save[-1];
+      else
+        /*  There was no number to convert.  */
+        *endptr = (STRING_TYPE *) nptr;
+    }
+
+  return 0L;
+}
+\f
+/* External user entry point.  */
+
+
+INT
+#ifdef weak_function
+weak_function
+#endif
+strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr,
+        int base LOCALE_PARAM_PROTO)
+{
+  return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
+}
diff --git a/lib/strtoul.c b/lib/strtoul.c
new file mode 100644 (file)
index 0000000..6fa6d0c
--- /dev/null
@@ -0,0 +1,19 @@
+/* Copyright (C) 1991, 1997, 2009-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#define UNSIGNED        1
+
+#include "strtol.c"
diff --git a/lib/strtoull.c b/lib/strtoull.c
new file mode 100644 (file)
index 0000000..bf25995
--- /dev/null
@@ -0,0 +1,26 @@
+/* Function to parse an `unsigned long long int' from text.
+   Copyright (C) 1995-1997, 1999, 2009-2011 Free Software Foundation, Inc.
+   NOTE: The canonical source of this file is maintained with the GNU C
+   Library.  Bugs can be reported to bug-glibc@gnu.org.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 3 of the License, or any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#define QUAD 1
+
+#include "strtoul.c"
+
+#ifdef _LIBC
+strong_alias (__strtoull_internal, __strtouq_internal)
+weak_alias (strtoull, strtouq)
+#endif
diff --git a/lib/strtoumax.c b/lib/strtoumax.c
new file mode 100644 (file)
index 0000000..dc395d6
--- /dev/null
@@ -0,0 +1,2 @@
+#define UNSIGNED 1
+#include "strtoimax.c"
diff --git a/lib/verify.h b/lib/verify.h
new file mode 100644 (file)
index 0000000..6bca43f
--- /dev/null
@@ -0,0 +1,202 @@
+/* Compile-time assert-like macros.
+
+   Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */
+
+#ifndef VERIFY_H
+# define VERIFY_H 1
+
+/* Define HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the
+   C1X draft N1548 section 6.7.10.  This is supported by GCC 4.6.0 and
+   later, in C mode, and its use here generates easier-to-read diagnostics
+   when verify (R) fails.
+
+   Define HAVE_STATIC_ASSERT to 1 if static_assert works as per the
+   C1X draft N1548 section 7.2 or the C++0X draft N3242 section 7.(4).
+   This will likely be supported by future GCC versions, in C++ mode.
+
+   For now, use this only with GCC.  Eventually whether _Static_assert
+   and static_assert works should be determined by 'configure'.  */
+# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
+#  define HAVE__STATIC_ASSERT 1
+# endif
+/* The condition (99 < __GNUC__) is temporary, until we know about the
+   first G++ release that supports static_assert.  */
+# if (99 < __GNUC__) && defined __cplusplus
+#  define HAVE_STATIC_ASSERT 1
+# endif
+
+/* Each of these macros verifies that its argument R is nonzero.  To
+   be portable, R should be an integer constant expression.  Unlike
+   assert (R), there is no run-time overhead.
+
+   There are two macros, since no single macro can be used in all
+   contexts in C.  verify_true (R) is for scalar contexts, including
+   integer constant expression contexts.  verify (R) is for declaration
+   contexts, e.g., the top level.
+
+   Symbols ending in "__" are private to this header.
+
+   If _Static_assert works, verify (R) uses it directly.  Similarly,
+   verify_true (R) works by packaging a _Static_assert inside a struct
+   that is an operand of sizeof.
+
+   The code below uses several ideas for C++ compilers, and for C
+   compilers that do not support _Static_assert:
+
+   * The first step is ((R) ? 1 : -1).  Given an expression R, of
+     integral or boolean or floating-point type, this yields an
+     expression of integral type, whose value is later verified to be
+     constant and nonnegative.
+
+   * Next this expression W is wrapped in a type
+     struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
+     If W is negative, this yields a compile-time error.  No compiler can
+     deal with a bit-field of negative size.
+
+     One might think that an array size check would have the same
+     effect, that is, that the type struct { unsigned int dummy[W]; }
+     would work as well.  However, inside a function, some compilers
+     (such as C++ compilers and GNU C) allow local parameters and
+     variables inside array size expressions.  With these compilers,
+     an array size check would not properly diagnose this misuse of
+     the verify macro:
+
+       void function (int n) { verify (n < 0); }
+
+   * For the verify macro, the struct verify_type__ will need to
+     somehow be embedded into a declaration.  To be portable, this
+     declaration must declare an object, a constant, a function, or a
+     typedef name.  If the declared entity uses the type directly,
+     such as in
+
+       struct dummy {...};
+       typedef struct {...} dummy;
+       extern struct {...} *dummy;
+       extern void dummy (struct {...} *);
+       extern struct {...} *dummy (void);
+
+     two uses of the verify macro would yield colliding declarations
+     if the entity names are not disambiguated.  A workaround is to
+     attach the current line number to the entity name:
+
+       #define _GL_CONCAT0(x, y) x##y
+       #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+       extern struct {...} * _GL_CONCAT (dummy, __LINE__);
+
+     But this has the problem that two invocations of verify from
+     within the same macro would collide, since the __LINE__ value
+     would be the same for both invocations.  (The GCC __COUNTER__
+     macro solves this problem, but is not portable.)
+
+     A solution is to use the sizeof operator.  It yields a number,
+     getting rid of the identity of the type.  Declarations like
+
+       extern int dummy [sizeof (struct {...})];
+       extern void dummy (int [sizeof (struct {...})]);
+       extern int (*dummy (void)) [sizeof (struct {...})];
+
+     can be repeated.
+
+   * Should the implementation use a named struct or an unnamed struct?
+     Which of the following alternatives can be used?
+
+       extern int dummy [sizeof (struct {...})];
+       extern int dummy [sizeof (struct verify_type__ {...})];
+       extern void dummy (int [sizeof (struct {...})]);
+       extern void dummy (int [sizeof (struct verify_type__ {...})]);
+       extern int (*dummy (void)) [sizeof (struct {...})];
+       extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
+
+     In the second and sixth case, the struct type is exported to the
+     outer scope; two such declarations therefore collide.  GCC warns
+     about the first, third, and fourth cases.  So the only remaining
+     possibility is the fifth case:
+
+       extern int (*dummy (void)) [sizeof (struct {...})];
+
+   * GCC warns about duplicate declarations of the dummy function if
+     -Wredundant_decls is used.  GCC 4.3 and later have a builtin
+     __COUNTER__ macro that can let us generate unique identifiers for
+     each dummy function, to suppress this warning.
+
+   * This implementation exploits the fact that older versions of GCC,
+     which do not support _Static_assert, also do not warn about the
+     last declaration mentioned above.
+
+   * In C++, any struct definition inside sizeof is invalid.
+     Use a template type to work around the problem.  */
+
+/* Concatenate two preprocessor tokens.  */
+# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+# define _GL_CONCAT0(x, y) x##y
+
+/* _GL_COUNTER is an integer, preferably one that changes each time we
+   use it.  Use __COUNTER__ if it works, falling back on __LINE__
+   otherwise.  __LINE__ isn't perfect, but it's better than a
+   constant.  */
+# if defined __COUNTER__ && __COUNTER__ != __COUNTER__
+#  define _GL_COUNTER __COUNTER__
+# else
+#  define _GL_COUNTER __LINE__
+# endif
+
+/* Generate a symbol with the given prefix, making it unique if
+   possible.  */
+# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
+
+/* Verify requirement R at compile-time, as an integer constant expression.
+   Return 1.  */
+
+# ifdef __cplusplus
+template <int w>
+  struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
+#  define verify_true(R) \
+     (!!sizeof (verify_type__<(R) ? 1 : -1>))
+# elif HAVE__STATIC_ASSERT
+#  define verify_true(R) \
+     (!!sizeof \
+      (struct { \
+        _Static_assert (R, "verify_true (" #R ")"); \
+        int verify_dummy__; \
+       }))
+# elif HAVE_STATIC_ASSERT
+#  define verify_true(R) \
+     (!!sizeof \
+      (struct { \
+        static_assert (R, "verify_true (" #R ")"); \
+        int verify_dummy__; \
+       }))
+# else
+#  define verify_true(R) \
+     (!!sizeof \
+      (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
+# endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+   trailing ';'.  */
+
+# if HAVE__STATIC_ASSERT
+#  define verify(R) _Static_assert (R, "verify (" #R ")")
+# elif HAVE_STATIC_ASSERT
+#  define verify(R) static_assert (R, "verify (" #R ")")
+# else
+#  define verify(R) \
+    extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)]
+# endif
+
+#endif
index 3ca40ee39bd1883fc428ec6fbb8155cef8b98c22..16f62236e27ac72dddb859ca772b42c891cb1b18 100644 (file)
@@ -43,6 +43,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module ignore-value:
   # Code from module include_next:
   # Code from module intprops:
+  # Code from module inttypes-h:
   # Code from module lstat:
   # Code from module mktime:
   # Code from module multiarch:
@@ -56,11 +57,13 @@ AC_DEFUN([gl_EARLY],
   # Code from module stdio:
   # Code from module stdlib:
   # Code from module strftime:
+  # Code from module strtoumax:
   # Code from module symlink:
   # Code from module sys_stat:
   # Code from module time:
   # Code from module time_r:
   # Code from module unistd:
+  # Code from module verify:
   # Code from module warn-on-use:
 ])
 
@@ -108,6 +111,8 @@ AC_DEFUN([gl_INIT],
   AC_REQUIRE([AC_C_INLINE])
   # Code from module include_next:
   # Code from module intprops:
+  # Code from module inttypes-h:
+  gl_INTTYPES_H
   # Code from module lstat:
   gl_FUNC_LSTAT
   gl_SYS_STAT_MODULE_INDICATOR([lstat])
@@ -138,6 +143,9 @@ AC_DEFUN([gl_INIT],
   gl_STDLIB_H
   # Code from module strftime:
   gl_FUNC_GNU_STRFTIME
+  # Code from module strtoumax:
+  gl_FUNC_STRTOUMAX
+  gl_INTTYPES_MODULE_INDICATOR([strtoumax])
   # Code from module symlink:
   gl_FUNC_SYMLINK
   gl_UNISTD_MODULE_INDICATOR([symlink])
@@ -151,6 +159,7 @@ AC_DEFUN([gl_INIT],
   gl_TIME_MODULE_INDICATOR([time_r])
   # Code from module unistd:
   gl_UNISTD_H
+  # Code from module verify:
   # Code from module warn-on-use:
   # End of code from modules
   m4_ifval(gl_LIBSOURCES_LIST, [
@@ -313,6 +322,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/gettext.h
   lib/ignore-value.h
   lib/intprops.h
+  lib/inttypes.in.h
   lib/lstat.c
   lib/md5.c
   lib/md5.h
@@ -327,11 +337,17 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/stdlib.in.h
   lib/strftime.c
   lib/strftime.h
+  lib/strtoimax.c
+  lib/strtol.c
+  lib/strtoul.c
+  lib/strtoull.c
+  lib/strtoumax.c
   lib/symlink.c
   lib/sys_stat.in.h
   lib/time.in.h
   lib/time_r.c
   lib/unistd.in.h
+  lib/verify.h
   m4/00gnulib.m4
   m4/c-strtod.m4
   m4/extensions.m4
@@ -340,6 +356,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/getopt.m4
   m4/gnulib-common.m4
   m4/include_next.m4
+  m4/inttypes.m4
   m4/longlong.m4
   m4/lstat.m4
   m4/md5.m4
@@ -356,6 +373,8 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/stdio_h.m4
   m4/stdlib_h.m4
   m4/strftime.m4
+  m4/strtoull.m4
+  m4/strtoumax.m4
   m4/symlink.m4
   m4/sys_stat_h.m4
   m4/time_h.m4
diff --git a/m4/inttypes.m4 b/m4/inttypes.m4
new file mode 100644 (file)
index 0000000..920f72d
--- /dev/null
@@ -0,0 +1,65 @@
+# inttypes.m4 serial 19
+dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Derek Price, Bruno Haible.
+dnl Test whether <inttypes.h> is supported or must be substituted.
+
+AC_DEFUN([gl_INTTYPES_H],
+[
+  AC_REQUIRE([gl_STDINT_H])
+  AC_CHECK_HEADERS_ONCE([inttypes.h])
+
+  dnl Override <inttypes.h> always, so that the portability warnings work.
+  AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
+  gl_CHECK_NEXT_HEADERS([inttypes.h])
+
+  AC_REQUIRE([gl_MULTIARCH])
+
+  dnl Ensure that <stdint.h> defines the limit macros, since gnulib's
+  dnl <inttypes.h> relies on them.  This macro is only needed when a
+  dnl C++ compiler is in use; it has no effect for a C compiler.
+  dnl Also be careful to define __STDC_LIMIT_MACROS only when gnulib's
+  dnl <inttypes.h> is going to be created, and to avoid redefinition warnings
+  dnl if the __STDC_LIMIT_MACROS is already defined through the CPPFLAGS.
+  AC_DEFINE([GL_TRIGGER_STDC_LIMIT_MACROS], [1],
+    [Define to make the limit macros in <stdint.h> visible.])
+  AH_VERBATIM([__STDC_LIMIT_MACROS_ZZZ],
+[/* Ensure that <stdint.h> defines the limit macros, since gnulib's
+   <inttypes.h> relies on them.  */
+#if defined __cplusplus && !defined __STDC_LIMIT_MACROS && GL_TRIGGER_STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS 1
+#endif
+])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use.
+  gl_WARN_ON_USE_PREPARE([[#include <inttypes.h>
+    ]], [imaxabs imaxdiv strtoimax strtoumax])
+])
+
+AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+])
+
+AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
+[
+  GNULIB_IMAXABS=0;      AC_SUBST([GNULIB_IMAXABS])
+  GNULIB_IMAXDIV=0;      AC_SUBST([GNULIB_IMAXDIV])
+  GNULIB_STRTOIMAX=0;    AC_SUBST([GNULIB_STRTOIMAX])
+  GNULIB_STRTOUMAX=0;    AC_SUBST([GNULIB_STRTOUMAX])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_DECL_IMAXABS=1;   AC_SUBST([HAVE_DECL_IMAXABS])
+  HAVE_DECL_IMAXDIV=1;   AC_SUBST([HAVE_DECL_IMAXDIV])
+  HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
+  HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
+  INT64_MAX_EQ_LONG_MAX='defined _LP64';  AC_SUBST([INT64_MAX_EQ_LONG_MAX])
+  PRI_MACROS_BROKEN=0;   AC_SUBST([PRI_MACROS_BROKEN])
+  PRIPTR_PREFIX=__PRIPTR_PREFIX;  AC_SUBST([PRIPTR_PREFIX])
+  UINT64_MAX_EQ_ULONG_MAX='defined _LP64';  AC_SUBST([UINT64_MAX_EQ_ULONG_MAX])
+])
diff --git a/m4/strtoull.m4 b/m4/strtoull.m4
new file mode 100644 (file)
index 0000000..abf607f
--- /dev/null
@@ -0,0 +1,25 @@
+# strtoull.m4 serial 6
+dnl Copyright (C) 2002, 2004, 2006, 2008-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRTOULL],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  dnl We don't need (and can't compile) the replacement strtoull
+  dnl unless the type 'unsigned long long int' exists.
+  AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
+  if test "$ac_cv_type_unsigned_long_long_int" = yes; then
+    AC_REPLACE_FUNCS([strtoull])
+    if test $ac_cv_func_strtoull = no; then
+      HAVE_STRTOULL=0
+      gl_PREREQ_STRTOULL
+    fi
+  fi
+])
+
+# Prerequisites of lib/strtoull.c.
+AC_DEFUN([gl_PREREQ_STRTOULL], [
+  :
+])
diff --git a/m4/strtoumax.m4 b/m4/strtoumax.m4
new file mode 100644 (file)
index 0000000..3ca38cd
--- /dev/null
@@ -0,0 +1,27 @@
+# strtoumax.m4 serial 9
+dnl Copyright (C) 2002-2004, 2006, 2009-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRTOUMAX],
+[
+  AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
+
+  AC_CHECK_DECLS_ONCE([strtoumax])
+  if test "$ac_cv_have_decl_strtoumax" != yes; then
+    HAVE_DECL_STRTOUMAX=0
+
+    AC_REPLACE_FUNCS([strtoumax])
+    if test $ac_cv_func_strtoumax = no; then
+      gl_PREREQ_STRTOUMAX
+    fi
+  fi
+])
+
+# Prerequisites of lib/strtoumax.c.
+AC_DEFUN([gl_PREREQ_STRTOUMAX], [
+  AC_CHECK_DECLS([strtoull])
+  AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
+  gl_FUNC_STRTOULL
+])
index 1985cdc376821b8e3fe482bcbe163e09c375b3d4..6614375a7c6fd0fe0690844b8ec3e8aaf2016fac 100644 (file)
@@ -1,3 +1,187 @@
+2011-04-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       lisp.h: Fix a problem with aliasing and vector headers.
+       GCC 4.6.0 optimizes based on type-based alias analysis.  For
+       example, if b is of type struct buffer * and v of type struct
+       Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
+       != &v->size, and therefore "v->size = 1; b->size = 2; return
+       v->size;" must therefore return 1.  This assumption is incorrect
+       for Emacs, since it type-puns struct Lisp_Vector * with many other
+       types.  To fix this problem, this patch adds a new type struct
+       vectorlike_header that documents the constraints on layout of vectors
+       and pseudovectors, and helps optimizing compilers not get fooled
+       by Emacs's type punning.  It also adds the macros XSETTYPED_PVECTYPE
+       XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
+       * lisp.h (XSETTYPED_PVECTYPE): New macro, specifying the name of
+       the size member.
+       (XSETPVECTYPE): Rewrite in terms of new macro.
+       (XSETPVECTYPESIZE): New macro, specifying both type and size.
+       This is a bit clearer, and further avoids the possibility of
+       undesirable aliasing.
+       (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size.
+       (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR.
+       (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE,
+       since Lisp_Subr is a special case (no "next" field).
+       (ASIZE): Now uses header.size rather than size.  All
+       previous uses of XVECTOR (foo)->size replaced to use this macro,
+       to avoid the hassle of writing XVECTOR (foo)->header.size.
+       (struct vectorlike_header): New type.
+       (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the
+       object, to help avoid aliasing.
+       (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP.
+       (SUBRP): Likewise, since Lisp_Subr is a special case.
+       * lisp.h (struct Lisp_Vector, struct Lisp_Char_Table):
+       (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector):
+       (struct Lisp_Hash_Table): Combine first two members into a single
+       struct vectorlike_header member.  All uses of "size" and "next" members
+       changed to be "header.size" and "header.next".
+       * buffer.h (struct buffer): Likewise.
+       * font.h (struct font_spec, struct font_entity, struct font): Likewise.
+       * frame.h (struct frame): Likewise.
+       * process.h (struct Lisp_Process): Likewise.
+       * termhooks.h (struct terminal): Likewise.
+       * window.c (struct save_window_data, struct saved_window): Likewise.
+       * window.h (struct window): Likewise.
+       * alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
+       Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
+       * buffer.c (init_buffer_once): Likewise.
+       * lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
+       special case.
+       * process.c (Fformat_network_address): Use local var for size,
+       for brevity.
+
+       * bytecode.c (exec_byte_code): Don't use XVECTOR before CHECK_VECTOR.
+
+       Make the Lisp reader and string-to-float more consistent.
+       * data.c (atof): Remove decl; no longer used or needed.
+       (digit_to_number): Move to lread.c.
+       (Fstring_to_number): Use new string_to_number function, to be
+       consistent with how the Lisp reader treats infinities and NaNs.
+       Do not assume that floating-point numbers represent EMACS_INT
+       without losing information; this is not true on most 64-bit hosts.
+       Avoid double-rounding errors, by insisting on integers when
+       parsing non-base-10 numbers, as the documentation specifies.
+       * lisp.h (string_to_number): New decl, replacing ...
+       (isfloat_string): Remove.
+       * lread.c: Include <inttypes.h>, for uintmax_t and strtoumax.
+       (read1): Do not accept +. and -. as integers; this
+       appears to have been a coding error.  Similarly, do not accept
+       strings like +-1e0 as floating point numbers.  Do not report
+       overflow for integer overflows unless the base is not 10 which
+       means we have no simple and reliable way to continue.
+       Break out the floating-point parsing into a new
+       function string_to_number, so that Fstring_to_number parses
+       floating point numbers consistently with the Lisp reader.
+       (digit_to_number): Moved here from data.c.  Make it static inline.
+       (E_CHAR, EXP_INT): Remove, replacing with ...
+       (E_EXP): New macro, to solve the "1.0e+" problem mentioned below.
+       (string_to_number): New function, replacing isfloat_string.
+       This function checks for valid syntax and produces the resulting
+       Lisp float number too.  Rework it so that string-to-number
+       no longer mishandles examples like "1.0e+".  Use strtoumax,
+       so that overflow for non-base-10 numbers is reported only when
+       there's no portable and simple way to convert to floating point.
+
+       * textprop.c (set_text_properties_1): Rewrite for clarity,
+       and to avoid GCC warning about integer overflow.
+
+       * intervals.h (struct interval): Use EMACS_INT for members
+       where EMACS_UINT might cause problems.  See
+       <http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00514.html>.
+       (CHECK_TOTAL_LENGTH): Remove cast to EMACS_INT; no longer needed.
+       * intervals.c (interval_deletion_adjustment): Now returns EMACS_INT.
+       All uses changed.
+       (offset_intervals): Tell GCC not to worry about length overflow
+       when negating a negative length.
+
+       * alloc.c (overrun_check_malloc, overrun_check_realloc): Now static.
+       (overrun_check_free): Likewise.
+
+       * alloc.c (SDATA_SIZE) [!GC_CHECK_STRING_BYTES]: Avoid runtime check
+       in the common case where SDATA_DATA_OFFSET is a multiple of Emacs
+       word size.
+
+       * gnutls.c: Fix problems found by GCC 4.6.0 on Ubuntu 10.10.
+       (gnutls_make_error): Rename local to avoid shadowing.
+       (gnutls_emacs_global_deinit): ifdef out; not used.
+       (Fgnutls_boot): Use const for pointer to readonly storage.
+       Comment out unused local.  Fix pointer signedness problems.
+
+       * lread.c (openp): Don't stuff size_t into an 'int'.
+       Use <= on length, not < on length + 1, to avoid GCC 4.6.0 warning
+       about possible signed overflow.
+
+       * gtkutil.c: Fix problems found by GCC 4.6.0 on Ubuntu 10.10.
+       (GDK_KEY_g): Don't define if already defined.
+       (xg_prepare_tooltip): Avoid pointer signedness problem.
+       (xg_set_toolkit_scroll_bar_thumb): Redo to avoid two casts.
+
+       * process.c (Fnetwork_interface_info): Avoid left-shift undefined
+       behavior with 1 << 31.  GCC 4.6.0 warns about this on 32-bit hosts.
+
+       * xfns.c (Fx_window_property): Simplify a bit,
+       to make a bit faster and to avoid GCC 4.6.0 warning.
+       * xselect.c (x_get_window_property, x_handle_dnd_message): Likewise.
+
+       * fns.c (internal_equal): Don't assume size_t fits in int.
+
+       * alloc.c (compact_small_strings): Tighten assertion a little.
+
+       Replace pEd with more-general pI, and fix some printf arg casts.
+       * lisp.h (pI): New macro, generalizing old pEd macro to other
+       conversion specifiers.  For example, use "...%"pI"d..." rather
+       than "...%"pEd"...".
+       (pEd): Remove.  All uses replaced with similar uses of pI.
+       * src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h: Likewise.
+       * alloc.c (check_pure_size): Don't overflow by converting size to int.
+       * bidi.c (bidi_dump_cached_states): Use pI to avoid cast.
+       * data.c (Fnumber_to_string): Use pI instead of if-then-else-abort.
+       * dbusbind.c (xd_append_arg): Use pI to avoid cast.
+       (Fdbus_method_return_internal, Fdbus_method_error_internal): Likewise.
+       * font.c (font_unparse_xlfd): Avoid potential buffer overrun on
+       64-bit hosts.
+       (font_unparse_xlfd, font_unparse_fcname): Use pI to avoid casts.
+       * keyboard.c (record_char, modify_event_symbol): Use pI to avoid casts.
+       * print.c (safe_debug_print, print_object): Likewise.
+       (print_object): Don't overflow by converting EMACS_INT or EMACS_UINT
+       to int.
+       Use pI instead of if-then-else-abort.  Use %p to avoid casts,
+       avoiding the 0 flag, which is not portable.
+       * process.c (Fmake_network_process): Use pI to avoid cast.
+       * region-cache.c (pp_cache): Likewise.
+       * xdisp.c (decode_mode_spec): Likewise.
+       * xrdb.c (x_load_resources) [USE_MOTIF]: Use pI to avoid undefined
+       behavior on 64-bit hosts with printf arg.
+       * xselect.c (x_queue_event): Use %p to avoid casts, avoiding 0 flag.
+       (x_stop_queuing_selection_requests): Likewise.
+       (x_get_window_property): Don't truncate byte count to an 'int'
+       when tracing.
+
+       * frame.c (frame_name_fnn_p): Get rid of strtol, which isn't right
+       here, since it parses constructs like leading '-' and spaces,
+       which are not wanted; and it overflows with large numbers.
+       Instead, simply match F[0-9]+, which is what is wanted anyway.
+
+       * alloc.c: Remove unportable assumptions about struct layout.
+       (SDATA_SELECTOR, SDATA_DATA_OFFSET): New macros.
+       (SDATA_OF_STRING, SDATA_SIZE, allocate_string_data):
+       (allocate_vectorlike, make_pure_vector): Use the new macros,
+       plus offsetof, to remove unportable assumptions about struct layout.
+       These assumptions hold on all porting targets that I know of, but
+       they are not guaranteed, they're easy to remove, and removing them
+       makes further changes easier.
+
+       * alloc.c (BLOCK BYTES): Fix typo by changing "ablock" to "ablocks".
+       This doesn't fix a bug but makes the code clearer.
+       (string_overrun_cookie): Now const.  Use initializers that
+       don't formally overflow signed char, to avoid warnings.
+       (allocate_string_data) [GC_CHECK_STRING_OVERRUN]: Fix typo that
+       can cause Emacs to crash when string overrun checking is enabled.
+       (allocate_buffer): Don't assume sizeof (struct buffer) is a
+       multiple of sizeof (EMACS_INT); it need not be, if
+       alignof(EMACS_INT) < sizeof (EMACS_INT).
+       (check_sblock, check_string_bytes, check_string_free_list): Protoize.
+
 2011-04-25  Dan Nicolaescu  <dann@ics.uci.edu>
 
        * alloc.c (check_sblock, check_string_bytes)
index be640b6a52cf6a3b36219b4caf85cf8c2bbccedd..842088f4e92c77efc2b8b3367354018c4cfa1f64 100644 (file)
@@ -146,9 +146,9 @@ static pthread_mutex_t alloc_mutex;
 #define UNMARK_STRING(S)       ((S)->size &= ~ARRAY_MARK_FLAG)
 #define STRING_MARKED_P(S)     (((S)->size & ARRAY_MARK_FLAG) != 0)
 
-#define VECTOR_MARK(V)         ((V)->size |= ARRAY_MARK_FLAG)
-#define VECTOR_UNMARK(V)       ((V)->size &= ~ARRAY_MARK_FLAG)
-#define VECTOR_MARKED_P(V)     (((V)->size & ARRAY_MARK_FLAG) != 0)
+#define VECTOR_MARK(V)         ((V)->header.size |= ARRAY_MARK_FLAG)
+#define VECTOR_UNMARK(V)       ((V)->header.size &= ~ARRAY_MARK_FLAG)
+#define VECTOR_MARKED_P(V)     (((V)->header.size & ARRAY_MARK_FLAG) != 0)
 
 /* Value is the number of bytes of S, a pointer to a struct Lisp_String.
    Be careful during GC, because S->size contains the mark bit for
@@ -555,7 +555,7 @@ static int check_depth;
 
 /* Like malloc, but wraps allocated block with header and trailer.  */
 
-POINTER_TYPE *
+static POINTER_TYPE *
 overrun_check_malloc (size_t size)
 {
   register unsigned char *val;
@@ -579,7 +579,7 @@ overrun_check_malloc (size_t size)
 /* Like realloc, but checks old block for overrun, and wraps new block
    with header and trailer.  */
 
-POINTER_TYPE *
+static POINTER_TYPE *
 overrun_check_realloc (POINTER_TYPE *block, size_t size)
 {
   register unsigned char *val = (unsigned char *) block;
@@ -617,7 +617,7 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size)
 
 /* Like free, but checks block for overrun.  */
 
-void
+static void
 overrun_check_free (POINTER_TYPE *block)
 {
   unsigned char *val = (unsigned char *) block;
@@ -835,7 +835,7 @@ lisp_free (POINTER_TYPE *block)
    nothing else.  */
 #define BLOCK_PADDING 0
 #define BLOCK_BYTES \
-  (BLOCK_ALIGN - sizeof (struct ablock *) - BLOCK_PADDING)
+  (BLOCK_ALIGN - sizeof (struct ablocks *) - BLOCK_PADDING)
 
 /* Internal data structures and constants.  */
 
@@ -1055,8 +1055,9 @@ allocate_buffer (void)
   struct buffer *b
     = (struct buffer *) lisp_malloc (sizeof (struct buffer),
                                     MEM_TYPE_BUFFER);
-  b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
-  XSETPVECTYPE (b, PVEC_BUFFER);
+  XSETPVECTYPESIZE (b, PVEC_BUFFER,
+                   ((sizeof (struct buffer) + sizeof (EMACS_INT) - 1)
+                    / sizeof (EMACS_INT)));
   return b;
 }
 
@@ -1516,23 +1517,26 @@ struct sdata
 
 #define SDATA_NBYTES(S)        (S)->nbytes
 #define SDATA_DATA(S)  (S)->data
+#define SDATA_SELECTOR(member) member
 
 #else /* not GC_CHECK_STRING_BYTES */
 
   union
   {
-    /* When STRING in non-null.  */
+    /* When STRING is non-null.  */
     unsigned char data[1];
 
     /* When STRING is null.  */
     EMACS_INT nbytes;
   } u;
 
-
 #define SDATA_NBYTES(S)        (S)->u.nbytes
 #define SDATA_DATA(S)  (S)->u.data
+#define SDATA_SELECTOR(member) u.member
 
 #endif /* not GC_CHECK_STRING_BYTES */
+
+#define SDATA_DATA_OFFSET offsetof (struct sdata, SDATA_SELECTOR (data))
 };
 
 
@@ -1608,18 +1612,7 @@ static EMACS_INT total_string_size;
    a pointer to the `u.data' member of its sdata structure; the
    structure starts at a constant offset in front of that.  */
 
-#ifdef GC_CHECK_STRING_BYTES
-
-#define SDATA_OF_STRING(S) \
-     ((struct sdata *) ((S)->data - sizeof (struct Lisp_String *) \
-                       - sizeof (EMACS_INT)))
-
-#else /* not GC_CHECK_STRING_BYTES */
-
-#define SDATA_OF_STRING(S) \
-     ((struct sdata *) ((S)->data - sizeof (struct Lisp_String *)))
-
-#endif /* not GC_CHECK_STRING_BYTES */
+#define SDATA_OF_STRING(S) ((struct sdata *) ((S)->data - SDATA_DATA_OFFSET))
 
 
 #ifdef GC_CHECK_STRING_OVERRUN
@@ -1629,8 +1622,8 @@ static EMACS_INT total_string_size;
    presence of this cookie during GC.  */
 
 #define GC_STRING_OVERRUN_COOKIE_SIZE  4
-static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
-  { 0xde, 0xad, 0xbe, 0xef };
+static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
+  { '\xde', '\xad', '\xbe', '\xef' };
 
 #else
 #define GC_STRING_OVERRUN_COOKIE_SIZE 0
@@ -1643,18 +1636,25 @@ static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
 #ifdef GC_CHECK_STRING_BYTES
 
 #define SDATA_SIZE(NBYTES)                     \
-     ((sizeof (struct Lisp_String *)           \
+     ((SDATA_DATA_OFFSET                       \
        + (NBYTES) + 1                          \
-       + sizeof (EMACS_INT)                    \
        + sizeof (EMACS_INT) - 1)               \
       & ~(sizeof (EMACS_INT) - 1))
 
 #else /* not GC_CHECK_STRING_BYTES */
 
-#define SDATA_SIZE(NBYTES)                     \
-     ((sizeof (struct Lisp_String *)           \
-       + (NBYTES) + 1                          \
-       + sizeof (EMACS_INT) - 1)               \
+/* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is
+   less than the size of that member.  The 'max' is not needed when
+   SDATA_DATA_OFFSET is a multiple of sizeof (EMACS_INT), because then the
+   alignment code reserves enough space.  */
+
+#define SDATA_SIZE(NBYTES)                                   \
+     ((SDATA_DATA_OFFSET                                     \
+       + (SDATA_DATA_OFFSET % sizeof (EMACS_INT) == 0        \
+         ? NBYTES                                            \
+         : max (NBYTES, sizeof (EMACS_INT) - 1))             \
+       + 1                                                   \
+       + sizeof (EMACS_INT) - 1)                             \
       & ~(sizeof (EMACS_INT) - 1))
 
 #endif /* not GC_CHECK_STRING_BYTES */
@@ -1682,9 +1682,6 @@ init_strings (void)
 
 static int check_string_bytes_count;
 
-static void check_string_bytes (int);
-static void check_sblock (struct sblock *);
-
 #define CHECK_STRING_BYTES(S)  STRING_BYTES (S)
 
 
@@ -1875,7 +1872,7 @@ allocate_string_data (struct Lisp_String *s,
 
   if (nbytes > LARGE_STRING_BYTES)
     {
-      size_t size = sizeof *b - sizeof (struct sdata) + needed;
+      size_t size = offsetof (struct sblock, first_data) + needed;
 
 #ifdef DOUG_LEA_MALLOC
       /* Prevent mmap'ing the chunk.  Lisp data may not be mmap'ed
@@ -1936,7 +1933,8 @@ allocate_string_data (struct Lisp_String *s,
   s->size_byte = nbytes;
   s->data[nbytes] = '\0';
 #ifdef GC_CHECK_STRING_OVERRUN
-  memcpy (data + needed, string_overrun_cookie, GC_STRING_OVERRUN_COOKIE_SIZE);
+  memcpy ((char *) data + needed, string_overrun_cookie,
+         GC_STRING_OVERRUN_COOKIE_SIZE);
 #endif
 
   /* If S had already data assigned, mark that as free by setting its
@@ -2150,7 +2148,7 @@ compact_small_strings (void)
              /* Copy, and update the string's `data' pointer.  */
              if (from != to)
                {
-                 xassert (tb != b || to <= from);
+                 xassert (tb != b || to < from);
                  memmove (to, from, nbytes + GC_STRING_EXTRA);
                  to->string->data = SDATA_DATA (to);
                }
@@ -2246,10 +2244,8 @@ LENGTH must be a number.  INIT matters only in whether it is t or nil.  */)
      slot `size' of the struct Lisp_Bool_Vector.  */
   val = Fmake_vector (make_number (length_in_elts + 1), Qnil);
 
-  /* Get rid of any bits that would cause confusion.  */
-  XVECTOR (val)->size = 0;     /* No Lisp_Object to trace in there.  */
-  /* Use  XVECTOR (val) rather than `p' because p->size is not TRT. */
-  XSETPVECTYPE (XVECTOR (val), PVEC_BOOL_VECTOR);
+  /* No Lisp_Object to trace in there.  */
+  XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0);
 
   p = XBOOL_VECTOR (val);
   p->size = XFASTINT (length);
@@ -2804,7 +2800,8 @@ allocate_vectorlike (EMACS_INT len)
   /* This gets triggered by code which I haven't bothered to fix.  --Stef  */
   /* eassert (!handling_signal); */
 
-  nbytes = sizeof *p + (len - 1) * sizeof p->contents[0];
+  nbytes = (offsetof (struct Lisp_Vector, contents)
+           + len * sizeof p->contents[0]);
   p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
 
 #ifdef DOUG_LEA_MALLOC
@@ -2815,7 +2812,7 @@ allocate_vectorlike (EMACS_INT len)
   consing_since_gc += nbytes;
   vector_cells_consed += len;
 
-  p->next = all_vectors;
+  p->header.next.vector = all_vectors;
   all_vectors = p;
 
   MALLOC_UNBLOCK_INPUT;
@@ -2831,7 +2828,7 @@ struct Lisp_Vector *
 allocate_vector (EMACS_INT nslots)
 {
   struct Lisp_Vector *v = allocate_vectorlike (nslots);
-  v->size = nslots;
+  v->header.size = nslots;
   return v;
 }
 
@@ -2845,11 +2842,10 @@ allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag)
   EMACS_INT i;
 
   /* Only the first lisplen slots will be traced normally by the GC.  */
-  v->size = lisplen;
   for (i = 0; i < lisplen; ++i)
     v->contents[i] = Qnil;
 
-  XSETPVECTYPE (v, tag);       /* Add the appropriate tag.  */
+  XSETPVECTYPESIZE (v, tag, lisplen);
   return v;
 }
 
@@ -4572,8 +4568,9 @@ void
 check_pure_size (void)
 {
   if (pure_bytes_used_before_overflow)
-    message ("emacs:0:Pure Lisp storage overflow (approx. %d bytes needed)",
-            (int) (pure_bytes_used + pure_bytes_used_before_overflow));
+    message (("emacs:0:Pure Lisp storage overflow (approx. %"pI"d"
+             " bytes needed)"),
+            pure_bytes_used + pure_bytes_used_before_overflow);
 }
 
 
@@ -4732,11 +4729,12 @@ make_pure_vector (EMACS_INT len)
 {
   Lisp_Object new;
   struct Lisp_Vector *p;
-  size_t size = sizeof *p + (len - 1) * sizeof (Lisp_Object);
+  size_t size = (offsetof (struct Lisp_Vector, contents)
+                + len * sizeof (Lisp_Object));
 
   p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike);
   XSETVECTOR (new, p);
-  XVECTOR (new)->size = len;
+  XVECTOR (new)->header.size = len;
   return new;
 }
 
@@ -4774,7 +4772,7 @@ Does not copy symbols.  Copies strings without text properties.  */)
       register EMACS_INT i;
       EMACS_INT size;
 
-      size = XVECTOR (obj)->size;
+      size = ASIZE (obj);
       if (size & PSEUDOVECTOR_FLAG)
        size &= PSEUDOVECTOR_SIZE_MASK;
       vec = XVECTOR (make_pure_vector (size));
@@ -4898,7 +4896,7 @@ returns nil, because real GC can't be done.  */)
              }
          }
 
-       nextb = nextb->next;
+       nextb = nextb->header.next.buffer;
       }
   }
 
@@ -5053,7 +5051,7 @@ returns nil, because real GC can't be done.  */)
           undo_list any more, we can finally mark the list.  */
        mark_object (nextb->BUFFER_INTERNAL_FIELD (undo_list));
 
-       nextb = nextb->next;
+       nextb = nextb->header.next.buffer;
       }
   }
 
@@ -5227,7 +5225,7 @@ static size_t mark_object_loop_halt;
 static void
 mark_vectorlike (struct Lisp_Vector *ptr)
 {
-  register EMACS_UINT size = ptr->size;
+  register EMACS_UINT size = ptr->header.size;
   register EMACS_UINT i;
 
   eassert (!VECTOR_MARKED_P (ptr));
@@ -5250,7 +5248,7 @@ mark_vectorlike (struct Lisp_Vector *ptr)
 static void
 mark_char_table (struct Lisp_Vector *ptr)
 {
-  register EMACS_UINT size = ptr->size & PSEUDOVECTOR_SIZE_MASK;
+  register EMACS_UINT size = ptr->header.size & PSEUDOVECTOR_SIZE_MASK;
   register EMACS_UINT i;
 
   eassert (!VECTOR_MARKED_P (ptr));
@@ -5363,7 +5361,7 @@ mark_object (Lisp_Object arg)
          if (po != &buffer_defaults && po != &buffer_local_symbols)
            {
              struct buffer *b;
-             for (b = all_buffers; b && b != po; b = b->next)
+             for (b = all_buffers; b && b != po; b = b->header.next.buffer)
                ;
              if (b == NULL)
                abort ();
@@ -5379,7 +5377,7 @@ mark_object (Lisp_Object arg)
           recursion there.  */
        {
          register struct Lisp_Vector *ptr = XVECTOR (obj);
-         register EMACS_UINT size = ptr->size;
+         register EMACS_UINT size = ptr->header.size;
          register EMACS_UINT i;
 
          CHECK_LIVE (live_vector_p);
@@ -6011,10 +6009,10 @@ gc_sweep (void)
       if (!VECTOR_MARKED_P (buffer))
        {
          if (prev)
-           prev->next = buffer->next;
+           prev->header.next = buffer->header.next;
          else
-           all_buffers = buffer->next;
-         next = buffer->next;
+           all_buffers = buffer->header.next.buffer;
+         next = buffer->header.next.buffer;
          lisp_free (buffer);
          buffer = next;
        }
@@ -6022,7 +6020,7 @@ gc_sweep (void)
        {
          VECTOR_UNMARK (buffer);
          UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer));
-         prev = buffer, buffer = buffer->next;
+         prev = buffer, buffer = buffer->header.next.buffer;
        }
   }
 
@@ -6035,10 +6033,10 @@ gc_sweep (void)
       if (!VECTOR_MARKED_P (vector))
        {
          if (prev)
-           prev->next = vector->next;
+           prev->header.next = vector->header.next;
          else
-           all_vectors = vector->next;
-         next = vector->next;
+           all_vectors = vector->header.next.vector;
+         next = vector->header.next.vector;
          lisp_free (vector);
          n_vectors--;
          vector = next;
@@ -6047,11 +6045,11 @@ gc_sweep (void)
       else
        {
          VECTOR_UNMARK (vector);
-         if (vector->size & PSEUDOVECTOR_FLAG)
-           total_vector_size += (PSEUDOVECTOR_SIZE_MASK & vector->size);
+         if (vector->header.size & PSEUDOVECTOR_FLAG)
+           total_vector_size += PSEUDOVECTOR_SIZE_MASK & vector->header.size;
          else
-           total_vector_size += vector->size;
-         prev = vector, vector = vector->next;
+           total_vector_size += vector->header.size;
+         prev = vector, vector = vector->header.next.vector;
        }
   }
 
index 447abb48469736536011620062d7b7704c7b91d5..88c45e24a14270312b83b3ed922c210013095a6c 100644 (file)
@@ -1807,6 +1807,6 @@ bidi_dump_cached_states (void)
   fputs ("\n", stderr);
   fputs ("pos ", stderr);
   for (i = 0; i < bidi_cache_idx; i++)
-    fprintf (stderr, "%*ld", ndigits, (long)bidi_cache[i].charpos);
+    fprintf (stderr, "%*"pI"d", ndigits, bidi_cache[i].charpos);
   fputs ("\n", stderr);
 }
index 46e8ddf1538351ffa658bf557970bde63a376097..d9949045444c90a9cd30e03604f0b89ead6fc9e7 100644 (file)
@@ -43,7 +43,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 struct buffer *current_buffer;         /* the current buffer */
 
 /* First buffer in chain of all buffers (in reverse order of creation).
-   Threaded through ->next.  */
+   Threaded through ->header.next.buffer.  */
 
 struct buffer *all_buffers;
 
@@ -359,7 +359,7 @@ even if it is dead.  The return value is never nil.  */)
   b->prevent_redisplay_optimizations_p = 1;
 
   /* Put this on the chain of all buffers including killed ones.  */
-  b->next = all_buffers;
+  b->header.next.buffer = all_buffers;
   all_buffers = b;
 
   /* An ordinary buffer normally doesn't need markers
@@ -588,7 +588,7 @@ CLONE nil means the indirect buffer's state is reset to default values.  */)
   BVAR (b, width_table) = Qnil;
 
   /* Put this on the chain of all buffers including killed ones.  */
-  b->next = all_buffers;
+  b->header.next.buffer = all_buffers;
   all_buffers = b;
 
   name = Fcopy_sequence (name);
@@ -1458,7 +1458,7 @@ with SIGHUP.  */)
 
       GCPRO1 (buffer);
 
-      for (other = all_buffers; other; other = other->next)
+      for (other = all_buffers; other; other = other->header.next.buffer)
        /* all_buffers contains dead buffers too;
           don't re-kill them.  */
        if (other->base_buffer == b && !NILP (BVAR (other, name)))
@@ -2099,7 +2099,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
 
   { /* This is probably harder to make work.  */
     struct buffer *other;
-    for (other = all_buffers; other; other = other->next)
+    for (other = all_buffers; other; other = other->header.next.buffer)
       if (other->base_buffer == other_buffer
          || other->base_buffer == current_buffer)
        error ("One of the buffers to swap has indirect buffers");
@@ -2476,7 +2476,7 @@ current buffer is cleared.  */)
 
   /* Copy this buffer's new multibyte status
      into all of its indirect buffers.  */
-  for (other = all_buffers; other; other = other->next)
+  for (other = all_buffers; other; other = other->header.next.buffer)
     if (other->base_buffer == current_buffer && !NILP (BVAR (other, name)))
       {
        BVAR (other, enable_multibyte_characters)
@@ -4178,7 +4178,7 @@ static int last_overlay_modification_hooks_used;
 static void
 add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
 {
-  int oldsize = XVECTOR (last_overlay_modification_hooks)->size;
+  int oldsize = ASIZE (last_overlay_modification_hooks);
 
   if (last_overlay_modification_hooks_used == oldsize)
     last_overlay_modification_hooks = larger_vector
@@ -4973,9 +4973,9 @@ init_buffer_once (void)
   buffer_local_symbols.text = &buffer_local_symbols.own_text;
   BUF_INTERVALS (&buffer_defaults) = 0;
   BUF_INTERVALS (&buffer_local_symbols) = 0;
-  XSETPVECTYPE (&buffer_defaults, PVEC_BUFFER);
+  XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, 0);
   XSETBUFFER (Vbuffer_defaults, &buffer_defaults);
-  XSETPVECTYPE (&buffer_local_symbols, PVEC_BUFFER);
+  XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, 0);
   XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols);
 
   /* Set up the default values of various buffer slots.  */
index 2963aa382ca33a1db8e4492040af21a6c720b60c..2f33065cd1a24728d10e47b28056f5c83cf66c1a 100644 (file)
@@ -499,14 +499,13 @@ struct buffer
 
      Check out mark_buffer (alloc.c) to see why.  */
 
-  EMACS_UINT size;
-
-  /* Next buffer, in chain of all buffers including killed buffers.
+  /* HEADER.NEXT is the next buffer, in chain of all buffers,
+     including killed buffers.
      This chain is used only for garbage collection, in order to
      collect killed buffers properly.
      Note that vectors and most pseudovectors are all on one chain,
      but buffers are on a separate chain of their own.  */
-  struct buffer *next;
+  struct vectorlike_header header;
 
   /* This structure holds the coordinates of the buffer contents
      in ordinary buffers.  In indirect buffers, this is not used.  */
index 581e16678a6cd57326ec061cfebc99093c2c2da3..c3cd3d430720ead25156ada46795922ae1605b3d 100644 (file)
@@ -444,7 +444,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
   /* Lisp_Object v1, v2; */
   Lisp_Object *vectorp;
 #ifdef BYTE_CODE_SAFE
-  int const_length = XVECTOR (vector)->size;
+  int const_length;
   Lisp_Object *stacke;
   int bytestr_length;
 #endif
@@ -466,6 +466,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
   CHECK_VECTOR (vector);
   CHECK_NUMBER (maxdepth);
 
+#ifdef BYTE_CODE_SAFE
+  const_length = ASIZE (vector);
+#endif
+
   if (STRING_MULTIBYTE (bytestr))
     /* BYTESTR must have been produced by Emacs 20.2 or the earlier
        because they produced a raw 8-bit string for byte-code and now
index cddd92c8a94f5d50ef4a6fe94eae2b4196abe435..2cc3a7cb537001ef2f9cfcebc13b1d5fa9ab542e 100644 (file)
@@ -294,7 +294,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
   else
     {
       CHECK_VECTOR (keys);
-      key_count = XVECTOR (keys)->size;
+      key_count = ASIZE (keys);
     }
 
   /* Save this now, since use of minibuffer will clobber it. */
index 66e0f2c6169dcd1fa63b14f13ac23c67080877a5..83afd7bc80024021a40ab1bb47dbbc344206b0e7 100644 (file)
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1903,7 +1903,7 @@ setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog)
       if (! VECTORP (ccl_prog))
        return -1;
       vp = XVECTOR (ccl_prog);
-      ccl->size = vp->size;
+      ccl->size = vp->header.size;
       ccl->prog = vp->contents;
       ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]);
       ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]);
index 8bab709480b6e5bb403fae61a4911c01df250283..64ea2625abb2bcba5498241b19cc4e64f2a54a6a 100644 (file)
@@ -356,7 +356,7 @@ c_string_width (const unsigned char *str, EMACS_INT len, int precision,
        {
          val = DISP_CHAR_VECTOR (dp, c);
          if (VECTORP (val))
-           thiswidth = XVECTOR (val)->size;
+           thiswidth = ASIZE (val);
          else
            thiswidth = CHAR_WIDTH (c);
        }
@@ -445,7 +445,7 @@ lisp_string_width (Lisp_Object string, int precision,
            {
              val = DISP_CHAR_VECTOR (dp, c);
              if (VECTORP (val))
-               thiswidth = XVECTOR (val)->size;
+               thiswidth = ASIZE (val);
              else
                thiswidth = CHAR_WIDTH (c);
            }
index e7435c292e2ad8a6622afb235ef555d1bfddbc81..52c2ebdcc4e18aba62e64b310e95b5a1c89baaba 100644 (file)
@@ -999,7 +999,7 @@ usage: (define-charset-internal ...)  */)
     {
       CHECK_NUMBER (val);
       if (XINT (val) < '0' || XINT (val) > 127)
-       error ("Invalid iso-final-char: %"pEd, XINT (val));
+       error ("Invalid iso-final-char: %"pI"d", XINT (val));
       charset.iso_final = XINT (val);
     }
 
@@ -1021,7 +1021,7 @@ usage: (define-charset-internal ...)  */)
     {
       CHECK_NATNUM (val);
       if ((XINT (val) > 0 && XINT (val) <= 128) || XINT (val) >= 256)
-       error ("Invalid emacs-mule-id: %"pEd, XINT (val));
+       error ("Invalid emacs-mule-id: %"pI"d", XINT (val));
       charset.emacs_mule_id = XINT (val);
     }
 
@@ -1439,10 +1439,10 @@ check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Obje
   CHECK_CHARACTER (final_char);
 
   if (XINT (dimension) > 3)
-    error ("Invalid DIMENSION %"pEd", it should be 1, 2, or 3",
+    error ("Invalid DIMENSION %"pI"d, it should be 1, 2, or 3",
           XINT (dimension));
   if (XINT (chars) != 94 && XINT (chars) != 96)
-    error ("Invalid CHARS %"pEd", it should be 94 or 96", XINT (chars));
+    error ("Invalid CHARS %"pI"d, 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'..`~'",
           (int)XINT (final_char));
index eb72d973c8770c41e5bd7d2d37effdc459812c87..2f40ceee6ce06ce632da20c98d2eb8eb9d224f86 100644 (file)
@@ -146,7 +146,7 @@ Lisp_Object
 copy_char_table (Lisp_Object table)
 {
   Lisp_Object copy;
-  int size = XCHAR_TABLE (table)->size & PSEUDOVECTOR_SIZE_MASK;
+  int size = XCHAR_TABLE (table)->header.size & PSEUDOVECTOR_SIZE_MASK;
   int i;
 
   copy = Fmake_vector (make_number (size), Qnil);
index 221ada5115891edd9f7d53be9966bc1c8d3af266..c14a41036ac4a19b151fb9391bdcbaff96260d10 100644 (file)
@@ -7125,7 +7125,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit,
              components = COMPOSITION_COMPONENTS (prop);
              if (VECTORP (components))
                {
-                 len = XVECTOR (components)->size;
+                 len = ASIZE (components);
                  for (i = 0; i < len; i++)
                    *buf++ = XINT (AREF (components, i));
                }
@@ -9037,14 +9037,14 @@ Return the corresponding character.  */)
 
       if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF
          || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC)
-       error ("Invalid code: %"pEd, ch);
+       error ("Invalid code: %"pI"d", ch);
       c = ch;
       SJIS_TO_JIS (c);
       charset = charset_kanji;
     }
   c = DECODE_CHAR (charset, c);
   if (c < 0)
-    error ("Invalid code: %"pEd, ch);
+    error ("Invalid code: %"pI"d", ch);
   return make_number (c);
 }
 
@@ -9111,13 +9111,13 @@ Return the corresponding character.  */)
       int b2 = ch & 0x7F;
       if (b1 < 0xA1 || b1 > 0xFE
          || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE)
-       error ("Invalid code: %"pEd, ch);
+       error ("Invalid code: %"pI"d", ch);
       c = ch;
       charset = charset_big5;
     }
   c = DECODE_CHAR (charset, c);
   if (c < 0)
-    error ("Invalid code: %"pEd, ch);
+    error ("Invalid code: %"pI"d", ch);
   return make_number (c);
 }
 
@@ -9289,7 +9289,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 %"pEd"th argument", XFASTINT (target_idx) + 1);
+    error ("Invalid %"pI"dth argument", XFASTINT (target_idx) + 1);
   if (CONSP (target))
     target = XCAR (target);
 
@@ -9765,7 +9765,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: %"pEd, XINT (XCDR (val)));
+           error ("Invalid graphic register number: %"pI"d", XINT (XCDR (val)));
          XSETCAR (val, make_number (id));
        }
 
index fab7cb86ba8492705863a33c987b0365d39c4620..f069acce1c0aedc5f497ab6da0fe3b8fa09f605f 100644 (file)
@@ -293,7 +293,7 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
     }
   else if (VECTORP (components) || CONSP (components))
     {
-      EMACS_UINT len = XVECTOR (key)->size;
+      EMACS_UINT len = ASIZE (key);
 
       /* The number of elements should be odd.  */
       if ((len % 2) == 0)
@@ -326,8 +326,8 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
                    : COMPOSITION_WITH_RULE_ALTCHARS));
   cmp->hash_index = hash_index;
   glyph_len = (cmp->method == COMPOSITION_WITH_RULE_ALTCHARS
-              ? (XVECTOR (key)->size + 1) / 2
-              : XVECTOR (key)->size);
+              ? (ASIZE (key) + 1) / 2
+              : ASIZE (key));
   cmp->glyph_len = glyph_len;
   cmp->offsets = (short *) xmalloc (sizeof (short) * glyph_len * 2);
   cmp->font = NULL;
index c9250a67bf0b89d982be32744af2ecaa4defb1ac..577ae777d893f2c4ecd741b6b670f2cd58d5944d 100644 (file)
@@ -48,10 +48,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
 
-#if !defined (atof)
-extern double atof (const char *);
-#endif /* !atof */
-
 Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
 static Lisp_Object Qsubr;
 Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
@@ -1393,7 +1389,7 @@ for this variable.  */)
              {
                struct buffer *b;
 
-               for (b = all_buffers; b; b = b->next)
+               for (b = all_buffers; b; b = b->header.next.buffer)
                  if (!PER_BUFFER_VALUE_P (b, idx))
                    PER_BUFFER_VALUE (b, offset) = value;
              }
@@ -2097,9 +2093,9 @@ or a byte-code object.  IDX starts at 0.  */)
     {
       int size = 0;
       if (VECTORP (array))
-       size = XVECTOR (array)->size;
+       size = ASIZE (array);
       else if (COMPILEDP (array))
-       size = XVECTOR (array)->size & PSEUDOVECTOR_SIZE_MASK;
+       size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK;
       else
        wrong_type_argument (Qarrayp, array);
 
@@ -2124,7 +2120,7 @@ bool-vector.  IDX starts at 0.  */)
 
   if (VECTORP (array))
     {
-      if (idxval < 0 || idxval >= XVECTOR (array)->size)
+      if (idxval < 0 || idxval >= ASIZE (array))
        args_out_of_range (array, idx);
       XVECTOR (array)->contents[idxval] = newelt;
     }
@@ -2374,35 +2370,10 @@ NUMBER may be an integer or a floating point number.  */)
       return build_string (pigbuf);
     }
 
-  if (sizeof (int) == sizeof (EMACS_INT))
-    sprintf (buffer, "%d", (int) XINT (number));
-  else if (sizeof (long) == sizeof (EMACS_INT))
-    sprintf (buffer, "%ld", (long) XINT (number));
-  else
-    abort ();
+  sprintf (buffer, "%"pI"d", XINT (number));
   return build_string (buffer);
 }
 
-INLINE static int
-digit_to_number (int character, int base)
-{
-  int digit;
-
-  if (character >= '0' && character <= '9')
-    digit = character - '0';
-  else if (character >= 'a' && character <= 'z')
-    digit = character - 'a' + 10;
-  else if (character >= 'A' && character <= 'Z')
-    digit = character - 'A' + 10;
-  else
-    return -1;
-
-  if (digit >= base)
-    return -1;
-  else
-    return digit;
-}
-
 DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0,
        doc: /* Parse STRING as a decimal number and return the number.
 This parses both integers and floating point numbers.
@@ -2415,7 +2386,6 @@ If the base used is not 10, STRING is always parsed as integer.  */)
 {
   register char *p;
   register int b;
-  int sign = 1;
   Lisp_Object val;
 
   CHECK_STRING (string);
@@ -2430,40 +2400,13 @@ If the base used is not 10, STRING is always parsed as integer.  */)
        xsignal1 (Qargs_out_of_range, base);
     }
 
-  /* Skip any whitespace at the front of the number.  Some versions of
-     atoi do this anyway, so we might as well make Emacs lisp consistent.  */
   p = SSDATA (string);
   while (*p == ' ' || *p == '\t')
     p++;
 
-  if (*p == '-')
-    {
-      sign = -1;
-      p++;
-    }
-  else if (*p == '+')
-    p++;
-
-  if (isfloat_string (p, 1) && b == 10)
-    val = make_float (sign * atof (p));
-  else
-    {
-      double v = 0;
-
-      while (1)
-       {
-         int digit = digit_to_number (*p++, b);
-         if (digit < 0)
-           break;
-         v = v * b + digit;
-       }
-
-      val = make_fixnum_or_float (sign * v);
-    }
-
-  return val;
+  val = string_to_number (p, b, 1);
+  return NILP (val) ? make_number (0) : val;
 }
-
 \f
 enum arithop
   {
index 792414b23d8f49b4968183717281db62c683c191..4c0b9bd017af7b3c6a3442b378f5b93965c5d2da 100644 (file)
@@ -506,7 +506,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter)
        CHECK_NUMBER (object);
        {
          dbus_uint64_t val = XUINT (object);
-         XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
+         XD_DEBUG_MESSAGE ("%c %"pI"u", dtype, XUINT (object));
          if (!dbus_message_iter_append_basic (iter, dtype, &val))
            XD_SIGNAL2 (build_string ("Unable to append argument"), object);
          return;
@@ -1377,7 +1377,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS)  */)
   CHECK_STRING (service);
   GCPRO3 (bus, serial, service);
 
-  XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA (service));
+  XD_DEBUG_MESSAGE ("%"pI"u %s ", XUINT (serial), SDATA (service));
 
   /* Open a connection to the bus.  */
   connection = xd_initialize (bus, TRUE);
@@ -1465,7 +1465,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS)  */)
   CHECK_STRING (service);
   GCPRO3 (bus, serial, service);
 
-  XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA (service));
+  XD_DEBUG_MESSAGE ("%"pI"u %s ", XUINT (serial), SDATA (service));
 
   /* Open a connection to the bus.  */
   connection = xd_initialize (bus, TRUE);
index 5b8eaf4fa340cf5f61d8e822ea5c5d4fffaf2754..13e920166c5ff25c6029304134348a16154a8802 100644 (file)
@@ -6073,7 +6073,7 @@ pass nil for VARIABLE.  */)
     state = frame_and_buffer_state;
 
   vecp = XVECTOR (state)->contents;
-  end = vecp + XVECTOR (state)->size;
+  end = vecp + ASIZE (state);
 
   FOR_EACH_FRAME (tail, frame)
     {
@@ -6124,8 +6124,8 @@ pass nil for VARIABLE.  */)
   /* Reallocate the vector if data has grown to need it,
      or if it has shrunk a lot.  */
   if (! VECTORP (state)
-      || n > XVECTOR (state)->size
-      || n + 20 < XVECTOR (state)->size / 2)
+      || n > ASIZE (state)
+      || n + 20 < ASIZE (state) / 2)
     /* Add 20 extra so we grow it less often.  */
     {
       state = Fmake_vector (make_number (n + 20), Qlambda);
@@ -6155,11 +6155,11 @@ pass nil for VARIABLE.  */)
   /* Fill up the vector with lambdas (always at least one).  */
   *vecp++ = Qlambda;
   while (vecp - XVECTOR (state)->contents
-        < XVECTOR (state)->size)
+        < ASIZE (state))
     *vecp++ = Qlambda;
   /* Make sure we didn't overflow the vector.  */
   if (vecp - XVECTOR (state)->contents
-      > XVECTOR (state)->size)
+      > ASIZE (state))
     abort ();
   return Qt;
 }
index be611cb8a9034d733ab5879c5505a454d896b029..e70079d2098e94618e91b8bdaff8f09a218d873a 100644 (file)
@@ -54,7 +54,7 @@ extern Lisp_Object Qdisplay_table;
 /* Return the current length of the GLYPH table,
    or 0 if the table isn't currently valid.  */
 #define GLYPH_TABLE_LENGTH  \
-  ((VECTORP (Vglyph_table)) ? XVECTOR (Vglyph_table)->size : 0)
+  ((VECTORP (Vglyph_table)) ? ASIZE (Vglyph_table) : 0)
 
 /* Return the current base (for indexing) of the GLYPH table,
    or 0 if the table isn't currently valid.  */
@@ -95,4 +95,3 @@ extern Lisp_Object Qdisplay_table;
 
 #define SET_GLYPH_FROM_CHAR(glyph, c) \
   SET_GLYPH (glyph, c, DEFAULT_FACE_ID)
-
index 4b75deaba5c2a9e8fd5e1ba2dce9a53fe5607fdf..d27fa3f792d5a80d95414fb37fefac334c9496c6 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -156,7 +156,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
   if (0 > lseek (fd, position - offset, 0))
     {
       emacs_close (fd);
-      error ("Position %"pEd" out of range in doc string file \"%s\"",
+      error ("Position %"pI"d out of range in doc string file \"%s\"",
             position, name);
     }
 
@@ -673,7 +673,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 %"pEd, pos);
+               error ("DOC file invalid at position %"pI"d", pos);
            }
        }
       pos += end - buf;
@@ -789,7 +789,7 @@ a new string, without any text properties, is returned.  */)
        do_remap:
          tem = Fwhere_is_internal (name, keymap, Qt, Qnil, Qnil);
 
-         if (VECTORP (tem) && XVECTOR (tem)->size > 1
+         if (VECTORP (tem) && ASIZE (tem) > 1
              && EQ (AREF (tem, 0), Qremap) && SYMBOLP (AREF (tem, 1))
              && follow_remap)
            {
index c057f64469cef41a746a07b53835caf5091713b8..a128b9292c69cc9db504595005b1dbdc5c98ddf7 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -1072,7 +1072,7 @@ an error is signaled.  */)
       EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0);
 
       if (converted < chars)
-       error ("Can't convert the %"pEd"th character to unibyte", converted);
+       error ("Can't convert the %"pI"dth character to unibyte", converted);
       string = make_unibyte_string ((char *) str, chars);
       xfree (str);
     }
@@ -2063,14 +2063,12 @@ internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int
        /* Boolvectors are compared much like strings.  */
        if (BOOL_VECTOR_P (o1))
          {
-           int size_in_chars
-             = ((XBOOL_VECTOR (o1)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
-                / BOOL_VECTOR_BITS_PER_CHAR);
-
            if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size)
              return 0;
            if (memcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data,
-                       size_in_chars))
+                       ((XBOOL_VECTOR (o1)->size
+                         + BOOL_VECTOR_BITS_PER_CHAR - 1)
+                        / BOOL_VECTOR_BITS_PER_CHAR)))
              return 0;
            return 1;
          }
@@ -3683,9 +3681,9 @@ copy_hash_table (struct Lisp_Hash_Table *h1)
   struct Lisp_Vector *next;
 
   h2 = allocate_hash_table ();
-  next = h2->vec_next;
+  next = h2->header.next.vector;
   memcpy (h2, h1, sizeof *h2);
-  h2->vec_next = next;
+  h2->header.next.vector = next;
   h2->key_and_value = Fcopy_sequence (h1->key_and_value);
   h2->hash = Fcopy_sequence (h1->hash);
   h2->next = Fcopy_sequence (h1->next);
@@ -4028,7 +4026,7 @@ sweep_weak_hash_tables (void)
       marked = 0;
       for (h = weak_hash_tables; h; h = h->next_weak)
        {
-         if (h->size & ARRAY_MARK_FLAG)
+         if (h->header.size & ARRAY_MARK_FLAG)
            marked |= sweep_weak_table (h, 0);
        }
     }
@@ -4039,7 +4037,7 @@ sweep_weak_hash_tables (void)
     {
       next = h->next_weak;
 
-      if (h->size & ARRAY_MARK_FLAG)
+      if (h->header.size & ARRAY_MARK_FLAG)
        {
          /* TABLE is marked as used.  Sweep its contents.  */
          if (h->count > 0)
@@ -4155,7 +4153,7 @@ sxhash_bool_vector (Lisp_Object vec)
   unsigned hash = XBOOL_VECTOR (vec)->size;
   int i, n;
 
-  n = min (SXHASH_MAX_LEN, XBOOL_VECTOR (vec)->vector_size);
+  n = min (SXHASH_MAX_LEN, XBOOL_VECTOR (vec)->header.size);
   for (i = 0; i < n; ++i)
     hash = SXHASH_COMBINE (hash, XBOOL_VECTOR (vec)->data[i]);
 
index f4950d391896dc8a4448cb15128fc8c9c1a7ef29..edbdc95853954e074b827f8d890c3faea63b880d 100644 (file)
@@ -253,7 +253,7 @@ font_intern_prop (const char *str, int len, int force_symbol)
   /* The following code is copied from the function intern (in
      lread.c), and modified to suite our purpose.  */
   obarray = Vobarray;
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
     obarray = check_obarray (obarray);
   parse_str_as_multibyte ((unsigned char *) str, len, &nchars, &nbytes);
   if (len == nchars || len != nbytes)
@@ -1271,9 +1271,9 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
     f[XLFD_SPACING_INDEX] = "*", len += 2;
   if (INTEGERP (AREF (font,  FONT_AVGWIDTH_INDEX)))
     {
-      f[XLFD_AVGWIDTH_INDEX] = p = alloca (11);
-      len += sprintf (p, "%ld",
-                      (long) XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1;
+      f[XLFD_AVGWIDTH_INDEX] = p = alloca (22);
+      len += sprintf (p, "%"pI"d",
+                     XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1;
     }
   else
     f[XLFD_AVGWIDTH_INDEX] = "*", len += 2;
@@ -1598,7 +1598,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
     }
 
   if (INTEGERP (AREF (font, FONT_DPI_INDEX)))
-    len += sprintf (work, ":dpi=%ld", (long)XINT (AREF (font, FONT_DPI_INDEX)));
+    len += sprintf (work, ":dpi=%"pI"d", XINT (AREF (font, FONT_DPI_INDEX)));
   if (INTEGERP (AREF (font, FONT_SPACING_INDEX)))
     len += strlen (":spacing=100");
   if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX)))
@@ -1611,7 +1611,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
       if (STRINGP (value))
        len += SBYTES (value);
       else if (INTEGERP (value))
-       len += sprintf (work, "%ld", (long) XINT (value));
+       len += sprintf (work, "%"pI"d", XINT (value));
       else if (SYMBOLP (value))
        len += (NILP (value) ? 5 : 4); /* for "false" or "true" */
     }
@@ -1638,10 +1638,9 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
       p += sprintf (p, ":%s=%s", style_names[i],
                    SDATA (SYMBOL_NAME (styles[i])));
   if (INTEGERP (AREF (font, FONT_DPI_INDEX)))
-    p += sprintf (p, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX)));
+    p += sprintf (p, ":dpi=%"pI"d", XINT (AREF (font, FONT_DPI_INDEX)));
   if (INTEGERP (AREF (font, FONT_SPACING_INDEX)))
-    p += sprintf (p, ":spacing=%ld",
-                  (long) XINT (AREF (font, FONT_SPACING_INDEX)));
+    p += sprintf (p, ":spacing=%"pI"d", XINT (AREF (font, FONT_SPACING_INDEX)));
   if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX)))
     {
       if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0)
index 7b43c2f99e7295104cc24029183e25f3e3d46e6a..4b3ceed1dd39d7c2e6897a78308fc0d738d67619 100644 (file)
@@ -254,8 +254,7 @@ extern Lisp_Object Qja, Qko;
 
 struct font_spec
 {
-  EMACS_UINT size;
-  struct Lisp_Vector *next;
+  struct vectorlike_header header;
   Lisp_Object props[FONT_SPEC_MAX];
 };
 
@@ -263,8 +262,7 @@ struct font_spec
 
 struct font_entity
 {
-  EMACS_UINT size;
-  struct Lisp_Vector *next;
+  struct vectorlike_header header;
   Lisp_Object props[FONT_ENTITY_MAX];
 };
 
@@ -277,8 +275,7 @@ struct font_entity
 
 struct font
 {
-  EMACS_UINT size;
-  struct Lisp_Vector *next;
+  struct vectorlike_header header;
 
   /* All Lisp_Object components must come first.
      That ensures they are all aligned normally.  */
index 9024a2fb5e22353fe1b4294c462babcf622c7a21..b106c568e48f0ef5265a94841f4731de3ee8d42c 100644 (file)
@@ -2154,16 +2154,12 @@ store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val)
 static int
 frame_name_fnn_p (char *str, EMACS_INT len)
 {
-  if (len > 1 && str[0] == 'F')
+  if (len > 1 && str[0] == 'F' && '0' <= str[1] && str[1] <= '9')
     {
-      char *end_ptr;
-      long int n;
-      errno = 0;
-      n = strtol (str + 1, &end_ptr, 10);
-
-      if (end_ptr == str + len
-         && INT_MIN <= n && n <= INT_MAX
-         && ((LONG_MIN < n && n < LONG_MAX) || errno != ERANGE))
+      char *p = str + 2;
+      while ('0' <= *p && *p <= '9')
+       p++;
+      if (p == str + len)
        return 1;
     }
   return 0;
index 944a3270ae5be7423404e03a7168142bddf5a14f..e73370340f1887ffb07226d9aa289dad24de92d3 100644 (file)
@@ -82,8 +82,7 @@ struct font_driver_list;
 
 struct frame
 {
-  EMACS_UINT size;
-  struct Lisp_Vector *next;
+  struct vectorlike_header header;
 
   /* All Lisp_Object components must come first.
      That ensures they are all aligned normally.  */
index bc6b493584ca07a3bb8ad2db04cae0a1c2b5efd2..f2d61225be792eed4b4216384df3a733f2044306 100644 (file)
@@ -1531,7 +1531,7 @@ If BITMAP already exists, the existing definition is replaced.  */)
   if (STRINGP (bits))
     h = SCHARS (bits);
   else if (VECTORP (bits))
-    h = XVECTOR (bits)->size;
+    h = ASIZE (bits);
   else
     wrong_type_argument (Qsequencep, bits);
 
index 975fe655072f16a65d49b8cf9bf92c2ddb44efe6..ea0a98570351abfcb45e0cf550ed4a6c19978585 100644 (file)
@@ -249,9 +249,9 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err)
    simply the integer value of the error.  GNUTLS_E_SUCCESS is mapped
    to Qt.  */
 static Lisp_Object
-gnutls_make_error (int error)
+gnutls_make_error (int err)
 {
-  switch (error)
+  switch (err)
     {
     case GNUTLS_E_SUCCESS:
       return Qt;
@@ -263,7 +263,7 @@ gnutls_make_error (int error)
       return Qgnutls_e_invalid_session;
     }
 
-  return make_number (error);
+  return make_number (err);
 }
 
 DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0,
@@ -383,6 +383,7 @@ emacs_gnutls_global_init (void)
   return gnutls_make_error (ret);
 }
 
+#if 0
 /* Deinitializes global GnuTLS state.
 See also `gnutls-global-init'.  */
 static Lisp_Object
@@ -395,6 +396,7 @@ emacs_gnutls_global_deinit (void)
 
   return gnutls_make_error (GNUTLS_E_SUCCESS);
 }
+#endif
 
 DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0,
        doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST.
@@ -461,7 +463,7 @@ one trustfile (usually a CA bundle).  */)
   gnutls_certificate_credentials_t x509_cred;
   gnutls_anon_client_credentials_t anon_cred;
   Lisp_Object global_init;
-  charpriority_string_ptr = "NORMAL"; /* default priority string.  */
+  char const *priority_string_ptr = "NORMAL"; /* default priority string.  */
   Lisp_Object tail;
   int peer_verification;
   char* c_hostname;
@@ -470,7 +472,7 @@ one trustfile (usually a CA bundle).  */)
   Lisp_Object priority_string;
   Lisp_Object trustfiles;
   Lisp_Object keyfiles;
-  Lisp_Object callbacks;
+  /* Lisp_Object callbacks; */
   Lisp_Object loglevel;
   Lisp_Object hostname;
   Lisp_Object verify_flags;
@@ -485,7 +487,7 @@ one trustfile (usually a CA bundle).  */)
   priority_string       = Fplist_get (proplist, Qgnutls_bootprop_priority);
   trustfiles            = Fplist_get (proplist, Qgnutls_bootprop_trustfiles);
   keyfiles              = Fplist_get (proplist, Qgnutls_bootprop_keyfiles);
-  callbacks             = Fplist_get (proplist, Qgnutls_bootprop_callbacks);
+  /* callbacks          = Fplist_get (proplist, Qgnutls_bootprop_callbacks); */
   loglevel              = Fplist_get (proplist, Qgnutls_bootprop_loglevel);
   verify_flags          = Fplist_get (proplist, Qgnutls_bootprop_verify_flags);
   verify_error          = Fplist_get (proplist, Qgnutls_bootprop_verify_error);
@@ -596,10 +598,10 @@ one trustfile (usually a CA bundle).  */)
           if (STRINGP (trustfile))
             {
               GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ",
-                           SDATA (trustfile));
+                           SSDATA (trustfile));
               ret = gnutls_certificate_set_x509_trust_file
                 (x509_cred,
-                 SDATA (trustfile),
+                 SSDATA (trustfile),
                  file_format);
 
               if (ret < GNUTLS_E_SUCCESS)
@@ -618,10 +620,10 @@ one trustfile (usually a CA bundle).  */)
           if (STRINGP (keyfile))
             {
               GNUTLS_LOG2 (1, max_log_level, "setting the keyfile: ",
-                           SDATA (keyfile));
+                           SSDATA (keyfile));
               ret = gnutls_certificate_set_x509_crl_file
                 (x509_cred,
-                 SDATA (keyfile),
+                 SSDATA (keyfile),
                  file_format);
 
               if (ret < GNUTLS_E_SUCCESS)
@@ -717,19 +719,19 @@ one trustfile (usually a CA bundle).  */)
 
   if (ret < GNUTLS_E_SUCCESS)
     return gnutls_make_error (ret);
-  
+
   if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID)
-    message ("%s certificate could not be verified.", 
+    message ("%s certificate could not be verified.",
              c_hostname);
+
  if (peer_verification & GNUTLS_CERT_REVOKED)
    GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):",
                 c_hostname);
+
  if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND)
    GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:",
                 c_hostname);
+
  if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA)
    GNUTLS_LOG2 (1, max_log_level, "certificate signer is not a CA:",
                 c_hostname);
@@ -771,7 +773,7 @@ one trustfile (usually a CA bundle).  */)
       if (ret < GNUTLS_E_SUCCESS)
         return gnutls_make_error (ret);
 
-      gnutls_verify_cert_list = 
+      gnutls_verify_cert_list =
         gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size);
 
       if (NULL == gnutls_verify_cert_list)
index 4b53915c4165222679f11ebed9198e3c7bbcefcd..9d3bfe6a89cae29e2840ae9039a459cd2dc24101 100644 (file)
@@ -81,8 +81,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
   gdk_window_get_geometry (w, a, b, c, d, 0)
 #define gdk_x11_window_lookup_for_display(d, w) \
   gdk_xid_table_lookup_for_display (d, w)
+#ifndef GDK_KEY_g
 #define GDK_KEY_g GDK_g
 #endif
+#endif
 
 #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
 
@@ -703,7 +705,7 @@ xg_prepare_tooltip (FRAME_PTR f,
      hierarchy-changed.  */
   gtk_tooltip_set_custom (x->ttip_widget, widget);
 
-  gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string));
+  gtk_tooltip_set_text (x->ttip_widget, SSDATA (encoded_string));
   gtk_widget_get_preferred_size (GTK_WIDGET (x->ttip_window), NULL, &req);
   if (width) *width = req.width;
   if (height) *height = req.height;
@@ -3527,6 +3529,7 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
       gdouble shown;
       gdouble top;
       int size, value;
+      int old_size;
       int new_step;
       int changed = 0;
 
@@ -3559,15 +3562,19 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
       /* Assume all lines are of equal size.  */
       new_step = size / max (1, FRAME_LINES (f));
 
-      if ((int) gtk_adjustment_get_page_size (adj) != size
-          || (int) gtk_adjustment_get_step_increment (adj) != new_step)
-        {
-          gtk_adjustment_set_page_size (adj, size);
-          gtk_adjustment_set_step_increment (adj, new_step);
-          /* Assume a page increment is about 95% of the page size  */
-          gtk_adjustment_set_page_increment (adj,(int) (0.95*size));
-          changed = 1;
-        }
+      old_size = gtk_adjustment_get_page_size (adj);
+      if (old_size != size)
+       {
+         int old_step = gtk_adjustment_get_step_increment (adj);
+         if (old_step != new_step)
+           {
+             gtk_adjustment_set_page_size (adj, size);
+             gtk_adjustment_set_step_increment (adj, new_step);
+             /* Assume a page increment is about 95% of the page size  */
+             gtk_adjustment_set_page_increment (adj,(int) (0.95*size));
+             changed = 1;
+           }
+       }
 
       if (changed || int_gtk_range_get_value (GTK_RANGE (wscroll)) != value)
       {
index fb555725b823b2acac691e9ed76045ac1efd2ff3..6feeb75afd6f22b186b208187f22701269826620 100644 (file)
@@ -2359,7 +2359,7 @@ xbm_image_p (Lisp_Object object)
          int i;
 
          /* Number of elements of the vector must be >= height.  */
-         if (XVECTOR (data)->size < height)
+         if (ASIZE (data) < height)
            return 0;
 
          /* Each string or bool-vector in data must be large enough
@@ -8398,7 +8398,7 @@ gs_image_p (Lisp_Object object)
     }
   else if (VECTORP (tem))
     {
-      if (XVECTOR (tem)->size != 4)
+      if (ASIZE (tem) != 4)
        return 0;
       for (i = 0; i < 4; ++i)
        if (!INTEGERP (XVECTOR (tem)->contents[i]))
index 094f6dabd55708b97a2cfb8af740e3272d7f07af..0fdc45a33a4fc1dd33045e08ab4b7f34e8b738d7 100644 (file)
@@ -93,7 +93,7 @@ character_width (int c, struct Lisp_Char_Table *dp)
   /* Everything can be handled by the display table, if it's
      present and the element is right.  */
   if (dp && (elt = DISP_CHAR_VECTOR (dp, c), VECTORP (elt)))
-    return XVECTOR (elt)->size;
+    return ASIZE (elt);
 
   /* Some characters are special.  */
   if (c == '\n' || c == '\t' || c == '\015')
@@ -121,7 +121,7 @@ disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *w
 {
   int i;
 
-  if (widthtab->size != 256)
+  if (widthtab->header.size != 256)
     abort ();
 
   for (i = 0; i < 256; i++)
@@ -143,7 +143,7 @@ recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab)
   if (!VECTORP (BVAR (buf, width_table)))
     BVAR (buf, width_table) = Fmake_vector (make_number (256), make_number (0));
   widthtab = XVECTOR (BVAR (buf, width_table));
-  if (widthtab->size != 256)
+  if (widthtab->header.size != 256)
     abort ();
 
   for (i = 0; i < 256; i++)
@@ -284,7 +284,7 @@ skip_invisible (EMACS_INT pos, EMACS_INT *next_boundary_p, EMACS_INT to, Lisp_Ob
     else                                                               \
       {                                                                        \
        if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, ch)))             \
-         width = XVECTOR (DISP_CHAR_VECTOR (dp, ch))->size;            \
+         width = ASIZE (DISP_CHAR_VECTOR (dp, ch));                    \
        else                                                            \
          width = CHAR_WIDTH (ch);                                      \
       }                                                                        \
@@ -766,7 +766,7 @@ string_display_width (string, beg, end)
 
       c = *--ptr;
       if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
-       col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
+       col += ASIZE (DISP_CHAR_VECTOR (dp, c));
       else if (c >= 040 && c < 0177)
        col++;
       else if (c == '\n')
@@ -1127,7 +1127,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
        : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
   int selective_rlen
     = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp))
-       ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0);
+       ? ASIZE (DISP_INVIS_VECTOR (dp)) : 0);
   /* The next location where the `invisible' property changes, or an
      overlay starts or ends.  */
   EMACS_INT next_boundary = from;
index 7ce1796d8ebdf72bb60ce313cb4cd9c38bc2814b..e72bc146d1685901b78dc703e49f41d29406fb3a 100644 (file)
@@ -39,6 +39,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <setjmp.h>
+#include <intprops.h>
 #include "lisp.h"
 #include "intervals.h"
 #include "buffer.h"
@@ -778,7 +779,7 @@ update_interval (register INTERVAL i, EMACS_INT pos)
              i = i->right;             /* Move to the right child */
            }
          else if (NULL_PARENT (i))
-           error ("Point %"pEd" after end of properties", pos);
+           error ("Point %"pI"d after end of properties", pos);
          else
             i = INTERVAL_PARENT (i);
          continue;
@@ -1313,7 +1314,7 @@ delete_interval (register INTERVAL i)
    Do this by recursing down TREE to the interval in question, and
    deleting the appropriate amount of text.  */
 
-static EMACS_UINT
+static EMACS_INT
 interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
                              register EMACS_INT amount)
 {
@@ -1325,9 +1326,9 @@ interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
   /* Left branch */
   if (relative_position < LEFT_TOTAL_LENGTH (tree))
     {
-      EMACS_UINT subtract = interval_deletion_adjustment (tree->left,
-                                                         relative_position,
-                                                         amount);
+      EMACS_INT subtract = interval_deletion_adjustment (tree->left,
+                                                        relative_position,
+                                                        amount);
       tree->total_length -= subtract;
       CHECK_TOTAL_LENGTH (tree);
       return subtract;
@@ -1336,7 +1337,7 @@ interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
   else if (relative_position >= (TOTAL_LENGTH (tree)
                                 - RIGHT_TOTAL_LENGTH (tree)))
     {
-      EMACS_UINT subtract;
+      EMACS_INT subtract;
 
       relative_position -= (tree->total_length
                            - RIGHT_TOTAL_LENGTH (tree));
@@ -1378,7 +1379,7 @@ static void
 adjust_intervals_for_deletion (struct buffer *buffer,
                               EMACS_INT start, EMACS_INT length)
 {
-  register EMACS_UINT left_to_delete = length;
+  register EMACS_INT left_to_delete = length;
   register INTERVAL tree = BUF_INTERVALS (buffer);
   Lisp_Object parent;
   EMACS_INT offset;
@@ -1435,7 +1436,10 @@ offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length)
   if (length > 0)
     adjust_intervals_for_insertion (BUF_INTERVALS (buffer), start, length);
   else
-    adjust_intervals_for_deletion (buffer, start, -length);
+    {
+      IF_LINT (if (length < - TYPE_MAXIMUM (EMACS_INT)) abort ();)
+      adjust_intervals_for_deletion (buffer, start, -length);
+    }
 }
 \f
 /* Merge interval I with its lexicographic successor. The resulting
index 6cf5c89374b0dbf9b3a09fafe155801c9165562a..720598fe7a60fdc75406b060d5f2cc4d0dfaf34f 100644 (file)
@@ -27,8 +27,8 @@ struct interval
 {
   /* The first group of entries deal with the tree structure.  */
 
-  EMACS_UINT total_length;      /* Length of myself and both children.  */
-  EMACS_UINT position;         /* Cache of interval's character position.  */
+  EMACS_INT total_length;       /* Length of myself and both children.  */
+  EMACS_INT position;          /* Cache of interval's character position.  */
                                /* This field is usually updated
                                   simultaneously with an interval
                                   traversal, there is no guarantee
@@ -164,7 +164,7 @@ struct interval
 #define CHECK_TOTAL_LENGTH(i)               \
   do                                        \
     {                                       \
-      if ((EMACS_INT) (i)->total_length < 0) \
+      if ((i)->total_length < 0)            \
        abort ();                            \
     }                                       \
   while (0)
index c601649ebcae06473afc46ae60253448558fe038..86b1afc86ab9910471329beed828dd03cfe17586 100644 (file)
@@ -134,7 +134,7 @@ static Lisp_Object raw_keybuf;
 static int raw_keybuf_count;
 
 #define GROW_RAW_KEYBUF                                                        \
- if (raw_keybuf_count == XVECTOR (raw_keybuf)->size)                   \
+ if (raw_keybuf_count == ASIZE (raw_keybuf))                           \
    raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil)  \
 
 /* Number of elements of this_command_keys
@@ -2898,7 +2898,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
       if ((STRINGP (KVAR (current_kboard, Vkeyboard_translate_table))
           && SCHARS (KVAR (current_kboard, Vkeyboard_translate_table)) > (unsigned) XFASTINT (c))
          || (VECTORP (KVAR (current_kboard, Vkeyboard_translate_table))
-             && XVECTOR (KVAR (current_kboard, Vkeyboard_translate_table))->size > (unsigned) XFASTINT (c))
+             && ASIZE (KVAR (current_kboard, Vkeyboard_translate_table)) > (unsigned) XFASTINT (c))
          || (CHAR_TABLE_P (KVAR (current_kboard, Vkeyboard_translate_table))
              && CHARACTERP (c)))
        {
@@ -3313,7 +3313,7 @@ record_char (Lisp_Object c)
          if (XUINT (c) < 0x100)
            putc (XINT (c), dribble);
          else
-           fprintf (dribble, " 0x%x", (int) XUINT (c));
+           fprintf (dribble, " 0x%"pI"x", XUINT (c));
        }
       else
        {
@@ -4198,7 +4198,7 @@ timer_start_idle (void)
 
       timer = XCAR (timers);
 
-      if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
+      if (!VECTORP (timer) || ASIZE (timer) != 8)
        continue;
       XVECTOR (timer)->contents[0] = Qnil;
     }
@@ -4293,7 +4293,7 @@ timer_check_2 (void)
       if (CONSP (timers))
        {
          timer = XCAR (timers);
-         if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
+         if (!VECTORP (timer) || ASIZE (timer) != 8)
            {
              timers = XCDR (timers);
              continue;
@@ -4311,7 +4311,7 @@ timer_check_2 (void)
       if (CONSP (idle_timers))
        {
          timer = XCAR (idle_timers);
-         if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
+         if (!VECTORP (timer) || ASIZE (timer) != 8)
            {
              idle_timers = XCDR (idle_timers);
              continue;
@@ -5459,7 +5459,7 @@ make_lispy_event (struct input_event *event)
                /* Find the menu bar item under `column'.  */
                item = Qnil;
                items = FRAME_MENU_BAR_ITEMS (f);
-               for (i = 0; i < XVECTOR (items)->size; i += 4)
+               for (i = 0; i < ASIZE (items); i += 4)
                  {
                    Lisp_Object pos, string;
                    string = AREF (items, i + 1);
@@ -5652,7 +5652,7 @@ make_lispy_event (struct input_event *event)
                                      Qmouse_click, Vlispy_mouse_stem,
                                      NULL,
                                      &mouse_syms,
-                                     XVECTOR (mouse_syms)->size);
+                                     ASIZE (mouse_syms));
          if (event->modifiers & drag_modifier)
            return Fcons (head,
                          Fcons (start_pos,
@@ -5823,7 +5823,7 @@ make_lispy_event (struct input_event *event)
                                    Qmouse_click,
                                    Vlispy_mouse_stem,
                                    NULL, &mouse_syms,
-                                   XVECTOR (mouse_syms)->size);
+                                   ASIZE (mouse_syms));
        return Fcons (head, Fcons (position, Qnil));
       }
 
@@ -5943,7 +5943,7 @@ make_lispy_event (struct input_event *event)
                                    Qmouse_click, Vlispy_mouse_stem,
                                    NULL,
                                    &mouse_syms,
-                                   XVECTOR (mouse_syms)->size);
+                                   ASIZE (mouse_syms));
 
        if (event->modifiers & drag_modifier)
          return Fcons (head,
@@ -6422,7 +6422,7 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
   else
     {
       if (! VECTORP (*symbol_table)
-         || XVECTOR (*symbol_table)->size != table_size)
+         || ASIZE (*symbol_table) != table_size)
        {
          Lisp_Object size;
 
@@ -6443,8 +6443,8 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
        {
          int len = SBYTES (name_alist_or_stem);
          char *buf = (char *) alloca (len + 50);
-          sprintf (buf, "%s-%ld", SDATA (name_alist_or_stem),
-                   (long) XINT (symbol_int) + 1);
+          sprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem),
+                   XINT (symbol_int) + 1);
          value = intern (buf);
        }
       else if (name_table != 0 && name_table[symbol_num])
@@ -6462,7 +6462,7 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
       if (NILP (value))
        {
          char buf[20];
-         sprintf (buf, "key-%ld", (long)symbol_num);
+         sprintf (buf, "key-%"pI"d", symbol_num);
          value = intern (buf);
        }
 
@@ -7479,7 +7479,7 @@ menu_bar_items (Lisp_Object old)
   /* Add nil, nil, nil, nil at the end.  */
   {
     int i = menu_bar_items_index;
-    if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
+    if (i + 4 > ASIZE (menu_bar_items_vector))
       menu_bar_items_vector =
        larger_vector (menu_bar_items_vector, 2 * i, Qnil);
     /* Add this item.  */
@@ -7551,7 +7551,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
   if (i == menu_bar_items_index)
     {
       /* If vector is too small, get a bigger one.  */
-      if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
+      if (i + 4 > ASIZE (menu_bar_items_vector))
        menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
       /* Add this item.  */
       XVECTOR (menu_bar_items_vector)->contents[i++] = key;
@@ -8219,7 +8219,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
        }
       else if (EQ (ikey, QCimage)
               && (CONSP (value)
-                  || (VECTORP (value) && XVECTOR (value)->size == 4)))
+                  || (VECTORP (value) && ASIZE (value) == 4)))
        /* Value is either a single image specification or a vector
           of 4 such specifications for the different button states.  */
        PROP (TOOL_BAR_ITEM_IMAGES) = value;
@@ -8323,10 +8323,10 @@ append_tool_bar_item (void)
 
   /* Enlarge tool_bar_items_vector if necessary.  */
   if (ntool_bar_items + TOOL_BAR_ITEM_NSLOTS
-      >= XVECTOR (tool_bar_items_vector)->size)
+      >= ASIZE (tool_bar_items_vector))
     tool_bar_items_vector
       = larger_vector (tool_bar_items_vector,
-                      2 * XVECTOR (tool_bar_items_vector)->size, Qnil);
+                      2 * ASIZE (tool_bar_items_vector), Qnil);
 
   /* Append entries from tool_bar_item_properties to the end of
      tool_bar_items_vector.  */
@@ -8648,7 +8648,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
                }
 
              /* Move past this element.  */
-             if (idx >= 0 && idx + 1 >= XVECTOR (vector)->size)
+             if (idx >= 0 && idx + 1 >= ASIZE (vector))
                /* Handle reaching end of dense table.  */
                idx = -1;
              if (idx >= 0)
@@ -9926,7 +9926,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
              /* Treat uppercase keys as shifted.  */
              || (INTEGERP (key)
                  && (KEY_TO_CHAR (key)
-                     < XCHAR_TABLE (BVAR (current_buffer, downcase_table))->size)
+                     < XCHAR_TABLE (BVAR (current_buffer, downcase_table))->header.size)
                  && uppercasep (KEY_TO_CHAR (key))))
            {
              Lisp_Object new_key
@@ -10292,7 +10292,7 @@ give to the command you invoke, if it asks for an argument.  */)
     this_single_command_key_start = 0;
 
     keys = XVECTOR (saved_keys)->contents;
-    for (i = 0; i < XVECTOR (saved_keys)->size; i++)
+    for (i = 0; i < ASIZE (saved_keys); i++)
       add_command_key (keys[i]);
 
     for (i = 0; i < SCHARS (function); i++)
@@ -10585,7 +10585,7 @@ KEEP-RECORD is non-nil.  */)
 
   if (NILP (keep_record))
     {
-      for (i = 0; i < XVECTOR (recent_keys)->size; ++i)
+      for (i = 0; i < ASIZE (recent_keys); ++i)
        XVECTOR (recent_keys)->contents[i] = Qnil;
       total_keys = 0;
       recent_keys_index = 0;
index 8713bcf1279309ead6040598f7c41b528603f3e2..79481833bde448d999e9f914c0f4ff456f942398 100644 (file)
@@ -359,7 +359,7 @@ Return PARENT.  PARENT should be nil or another keymap.  */)
                                XCDR (XCAR (list)));
 
       if (VECTORP (XCAR (list)))
-       for (i = 0; i < XVECTOR (XCAR (list))->size; i++)
+       for (i = 0; i < ASIZE (XCAR (list)); i++)
          if (CONSP (XVECTOR (XCAR (list))->contents[i]))
            fix_submap_inheritance (keymap, make_number (i),
                                    XVECTOR (XCAR (list))->contents[i]);
@@ -2226,7 +2226,7 @@ spaces are put between sequence elements, etc.  */)
   if (STRINGP (list))
     size = SCHARS (list);
   else if (VECTORP (list))
-    size = XVECTOR (list)->size;
+    size = ASIZE (list);
   else if (CONSP (list))
     size = XINT (Flength (list));
   else
@@ -3125,7 +3125,7 @@ key             binding\n\
 
          elt = XCAR (list);
          elt_prefix = Fcar (elt);
-         if (XVECTOR (elt_prefix)->size >= 1)
+         if (ASIZE (elt_prefix) >= 1)
            {
              tem = Faref (elt_prefix, make_number (0));
              if (EQ (tem, Qmenu_bar))
@@ -3168,7 +3168,7 @@ key             binding\n\
          /* If the sequence by which we reach this keymap is zero-length,
             then the shadow map for this keymap is just SHADOW.  */
          if ((STRINGP (elt_prefix) && SCHARS (elt_prefix) == 0)
-             || (VECTORP (elt_prefix) && XVECTOR (elt_prefix)->size == 0))
+             || (VECTORP (elt_prefix) && ASIZE (elt_prefix) == 0))
            ;
          /* If the sequence by which we reach this keymap actually has
             some elements, then the sequence's definition in SHADOW is
@@ -3592,7 +3592,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
   if (CHAR_TABLE_P (vector))
     stop = MAX_5_BYTE_CHAR + 1, to = MAX_CHAR + 1;
   else
-    stop = to = XVECTOR (vector)->size;
+    stop = to = ASIZE (vector);
 
   for (i = from; ; i++)
     {
index 07b2cb0b1ef2ca820ba26f28bab6e15f4421b468..4b7973939ef34cfe8cd7bfa85247b235d5d3d1e2 100644 (file)
@@ -38,7 +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"
+#define pI "l"
 #endif
 #ifndef EMACS_UINT
 #define EMACS_UINT unsigned long
@@ -47,7 +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"
+#define pI ""
 #endif
 #ifndef EMACS_UINT
 #define EMACS_UINT unsigned int
@@ -601,17 +601,26 @@ extern Lisp_Object make_number (EMACS_INT);
 
 /* Pseudovector types.  */
 
-#define XSETPVECTYPE(v,code) ((v)->size |= PSEUDOVECTOR_FLAG | (code))
+#define XSETPVECTYPE(v, code) XSETTYPED_PVECTYPE(v, header.size, code)
+#define XSETTYPED_PVECTYPE(v, size_member, code) \
+  ((v)->size_member |= PSEUDOVECTOR_FLAG | (code))
+#define XSETPVECTYPESIZE(v, code, sizeval) \
+  ((v)->header.size = PSEUDOVECTOR_FLAG | (code) | (sizeval))
 #define XSETPSEUDOVECTOR(a, b, code) \
+  XSETTYPED_PSEUDOVECTOR(a, b,       \
+                        ((struct vectorlike_header *) XPNTR (a))->size, \
+                        code)
+#define XSETTYPED_PSEUDOVECTOR(a, b, size, code)                       \
   (XSETVECTOR (a, b),                                                  \
-   eassert ((XVECTOR (a)->size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK)) \
+   eassert ((size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK))              \
            == (PSEUDOVECTOR_FLAG | (code))))
 #define XSETWINDOW_CONFIGURATION(a, b) \
   (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW_CONFIGURATION))
 #define XSETPROCESS(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_PROCESS))
 #define XSETWINDOW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW))
 #define XSETTERMINAL(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_TERMINAL))
-#define XSETSUBR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUBR))
+#define XSETSUBR(a, b) \
+  XSETTYPED_PSEUDOVECTOR (a, b, XSUBR (a)->size, PVEC_SUBR)
 #define XSETCOMPILED(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_COMPILED))
 #define XSETBUFFER(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BUFFER))
 #define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE))
@@ -621,7 +630,7 @@ extern Lisp_Object make_number (EMACS_INT);
 /* Convenience macros for dealing with Lisp arrays.  */
 
 #define AREF(ARRAY, IDX)       XVECTOR ((ARRAY))->contents[IDX]
-#define ASIZE(ARRAY)           XVECTOR ((ARRAY))->size
+#define ASIZE(ARRAY)           XVECTOR ((ARRAY))->header.size
 /* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
 #define ASET(ARRAY, IDX, VAL)  \
   (eassert ((IDX) == (IDX)),                           \
@@ -778,10 +787,21 @@ struct Lisp_String
     unsigned char *data;
   };
 
-struct Lisp_Vector
+/* Header of vector-like objects.  This type documents the constraints on
+   layout of vectors and pseudovectors, and helps optimizing compilers not get
+   fooled by Emacs's type punning.  */
+struct vectorlike_header
   {
     EMACS_UINT size;
-    struct Lisp_Vector *next;
+    union {
+      struct buffer *buffer;
+      struct Lisp_Vector *vector;
+    } next;
+  };
+
+struct Lisp_Vector
+  {
+    struct vectorlike_header header;
     Lisp_Object contents[1];
   };
 
@@ -817,7 +837,7 @@ struct Lisp_Vector
 /* Return the number of "extra" slots in the char table CT.  */
 
 #define CHAR_TABLE_EXTRA_SLOTS(CT)     \
-  (((CT)->size & PSEUDOVECTOR_SIZE_MASK) - CHAR_TABLE_STANDARD_SLOTS)
+  (((CT)->header.size & PSEUDOVECTOR_SIZE_MASK) - CHAR_TABLE_STANDARD_SLOTS)
 
 #ifdef __GNUC__
 
@@ -882,12 +902,11 @@ struct Lisp_Sub_Char_Table;
 
 struct Lisp_Char_Table
   {
-    /* This is the vector's size field, which also holds the
+    /* HEADER.SIZE is the vector's size field, which also holds the
        pseudovector type information.  It holds the size, too.
        The size counts the defalt, parent, purpose, ascii,
        contents, and extras slots.  */
-    EMACS_UINT size;
-    struct Lisp_Vector *next;
+    struct vectorlike_header header;
 
     /* This holds a default value,
        which is used whenever the value for a specific character is nil.  */
@@ -914,10 +933,9 @@ struct Lisp_Char_Table
 
 struct Lisp_Sub_Char_Table
   {
-    /* This is the vector's size field, which also holds the
+    /* HEADER.SIZE is the vector's size field, which also holds the
        pseudovector type information.  It holds the size, too.  */
-    EMACS_INT size;
-    struct Lisp_Vector *next;
+    struct vectorlike_header header;
 
     /* Depth of this sub char-table.  It should be 1, 2, or 3.  A sub
        char-table of depth 1 contains 16 elements, and each element
@@ -936,10 +954,9 @@ struct Lisp_Sub_Char_Table
 /* A boolvector is a kind of vectorlike, with contents are like a string.  */
 struct Lisp_Bool_Vector
   {
-    /* This is the vector's size field.  It doesn't have the real size,
+    /* HEADER.SIZE is the vector's size field.  It doesn't have the real size,
        just the subtype information.  */
-    EMACS_UINT vector_size;
-    struct Lisp_Vector *next;
+    struct vectorlike_header header;
     /* This is the size in bits.  */
     EMACS_UINT size;
     /* This contains the actual bits, packed into bytes.  */
@@ -952,7 +969,7 @@ struct Lisp_Bool_Vector
 
    This type is treated in most respects as a pseudovector,
    but since we never dynamically allocate or free them,
-   we don't need a next-vector field.  */
+   we don't need a struct vectorlike_header and its 'next' field.  */
 
 struct Lisp_Subr
   {
@@ -1099,9 +1116,8 @@ struct Lisp_Symbol
 
 struct Lisp_Hash_Table
 {
-  /* Vector fields.  The hash table code doesn't refer to these.  */
-  EMACS_UINT size;
-  struct Lisp_Vector *vec_next;
+  /* This is for Lisp; the hash table code does not refer to it.  */
+  struct vectorlike_header header;
 
   /* Function used to compare keys.  */
   Lisp_Object test;
@@ -1202,7 +1218,7 @@ struct Lisp_Hash_Table
 
 /* Value is the size of hash table H.  */
 
-#define HASH_TABLE_SIZE(H) XVECTOR ((H)->next)->size
+#define HASH_TABLE_SIZE(H) ASIZE ((H)->next)
 
 /* Default size for hash tables if not specified.  */
 
@@ -1620,7 +1636,7 @@ typedef struct {
 #define CONSP(x) (XTYPE ((x)) == Lisp_Cons)
 
 #define FLOATP(x) (XTYPE ((x)) == Lisp_Float)
-#define VECTORP(x)    (VECTORLIKEP (x) && !(XVECTOR (x)->size & PSEUDOVECTOR_FLAG))
+#define VECTORP(x) (VECTORLIKEP (x) && !(ASIZE (x) & PSEUDOVECTOR_FLAG))
 #define OVERLAYP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Overlay)
 #define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker)
 #define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value)
@@ -1633,8 +1649,14 @@ typedef struct {
 
 /* True if object X is a pseudovector whose code is CODE.  */
 #define PSEUDOVECTORP(x, code)                                 \
+  TYPED_PSEUDOVECTORP(x, vectorlike_header, code)
+
+/* True if object X, with internal type struct T *, is a pseudovector whose
+   code is CODE.  */
+#define TYPED_PSEUDOVECTORP(x, t, code)                                \
   (VECTORLIKEP (x)                                             \
-   && (((XVECTOR (x)->size & (PSEUDOVECTOR_FLAG | (code))))    \
+   && (((((struct t *) XPNTR (x))->size                                \
+        & (PSEUDOVECTOR_FLAG | (code))))                       \
        == (PSEUDOVECTOR_FLAG | (code))))
 
 /* Test for specific pseudovector types.  */
@@ -1642,7 +1664,7 @@ typedef struct {
 #define PROCESSP(x) PSEUDOVECTORP (x, PVEC_PROCESS)
 #define WINDOWP(x) PSEUDOVECTORP (x, PVEC_WINDOW)
 #define TERMINALP(x) PSEUDOVECTORP (x, PVEC_TERMINAL)
-#define SUBRP(x) PSEUDOVECTORP (x, PVEC_SUBR)
+#define SUBRP(x) TYPED_PSEUDOVECTORP (x, Lisp_Subr, PVEC_SUBR)
 #define COMPILEDP(x) PSEUDOVECTORP (x, PVEC_COMPILED)
 #define BUFFERP(x) PSEUDOVECTORP (x, PVEC_BUFFER)
 #define CHAR_TABLE_P(x) PSEUDOVECTORP (x, PVEC_CHAR_TABLE)
@@ -2785,7 +2807,7 @@ extern Lisp_Object oblookup (Lisp_Object, const char *, EMACS_INT, EMACS_INT);
   } while (0)
 extern int openp (Lisp_Object, Lisp_Object, Lisp_Object,
                   Lisp_Object *, Lisp_Object);
-extern int isfloat_string (const char *, int);
+Lisp_Object string_to_number (char const *, int, int);
 extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
                          Lisp_Object);
 extern void dir_warning (const char *, Lisp_Object);
index d32f0b6a7e2a95f8b9f95f3e1a602962741cb995..7ffc98b254fe07ca667fd0f561a0f2db3a83e80e 100644 (file)
@@ -19,6 +19,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include <config.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -1411,16 +1412,16 @@ int
 openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate)
 {
   register int fd;
-  int fn_size = 100;
+  EMACS_INT fn_size = 100;
   char buf[100];
   register char *fn = buf;
   int absolute = 0;
-  int want_size;
+  EMACS_INT want_length;
   Lisp_Object filename;
   struct stat st;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   Lisp_Object string, tail, encoded_fn;
-  int max_suffix_len = 0;
+  EMACS_INT max_suffix_len = 0;
 
   CHECK_STRING (str);
 
@@ -1454,11 +1455,11 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
            continue;
        }
 
-      /* Calculate maximum size of any filename made from
+      /* Calculate maximum length of any filename made from
         this path element/specified file name and any possible suffix.  */
-      want_size = max_suffix_len + SBYTES (filename) + 1;
-      if (fn_size < want_size)
-       fn = (char *) alloca (fn_size = 100 + want_size);
+      want_length = max_suffix_len + SBYTES (filename);
+      if (fn_size <= want_length)
+       fn = (char *) alloca (fn_size = 100 + want_length);
 
       /* Loop over suffixes.  */
       for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes;
@@ -2429,7 +2430,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
            {
              Lisp_Object tmp;
              tmp = read_vector (readcharfun, 0);
-             if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS)
+             if (ASIZE (tmp) < CHAR_TABLE_STANDARD_SLOTS)
                error ("Invalid size char-table");
              XSETPVECTYPE (XVECTOR (tmp), PVEC_CHAR_TABLE);
              return tmp;
@@ -2448,7 +2449,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
                  depth = XINT (AREF (tmp, 0));
                  if (depth < 1 || depth > 3)
                    error ("Invalid depth in char-table");
-                 size = XVECTOR (tmp)->size - 2;
+                 size = ASIZE (tmp) - 2;
                  if (chartab_size [depth] != size)
                    error ("Invalid size char-table");
                  XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE);
@@ -2498,7 +2499,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
             build them using function calls.  */
          Lisp_Object tmp;
          tmp = read_vector (readcharfun, 1);
-         return Fmake_byte_code (XVECTOR (tmp)->size,
+         return Fmake_byte_code (ASIZE (tmp),
                                  XVECTOR (tmp)->contents);
        }
       if (c == '(')
@@ -3005,86 +3006,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 
        if (!quoted && !uninterned_symbol)
          {
-           register char *p1;
-           p1 = read_buffer;
-           if (*p1 == '+' || *p1 == '-') p1++;
-           /* Is it an integer? */
-           if (p1 != p)
-             {
-               while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++;
-               /* Integers can have trailing decimal points.  */
-               if (p1 > read_buffer && p1 < p && *p1 == '.') p1++;
-               if (p1 == p)
-                 /* It is an integer. */
-                 {
-                   if (p1[-1] == '.')
-                     p1[-1] = '\0';
-                   {
-                     /* EMACS_INT n = atol (read_buffer); */
-                     char *endptr = NULL;
-                     EMACS_INT n = (errno = 0,
-                                    strtol (read_buffer, &endptr, 10));
-                     if (errno == ERANGE && endptr)
-                       {
-                         Lisp_Object args
-                           = Fcons (make_string (read_buffer,
-                                                 endptr - read_buffer),
-                                    Qnil);
-                         xsignal (Qoverflow_error, args);
-                       }
-                     return make_fixnum_or_float (n);
-                   }
-                 }
-             }
-           if (isfloat_string (read_buffer, 0))
-             {
-               /* Compute NaN and infinities using 0.0 in a variable,
-                  to cope with compilers that think they are smarter
-                  than we are.  */
-               double zero = 0.0;
-
-               double value;
-
-               /* Negate the value ourselves.  This treats 0, NaNs,
-                  and infinity properly on IEEE floating point hosts,
-                  and works around a common bug where atof ("-0.0")
-                  drops the sign.  */
-               int negative = read_buffer[0] == '-';
-
-               /* The only way p[-1] can be 'F' or 'N', after isfloat_string
-                  returns 1, is if the input ends in e+INF or e+NaN.  */
-               switch (p[-1])
-                 {
-                 case 'F':
-                   value = 1.0 / zero;
-                   break;
-                 case 'N':
-                   value = zero / zero;
-
-                   /* If that made a "negative" NaN, negate it.  */
-
-                   {
-                     int i;
-                     union { double d; char c[sizeof (double)]; } u_data, u_minus_zero;
-
-                     u_data.d = value;
-                     u_minus_zero.d = - 0.0;
-                     for (i = 0; i < sizeof (double); i++)
-                       if (u_data.c[i] & u_minus_zero.c[i])
-                         {
-                           value = - value;
-                           break;
-                         }
-                   }
-                   /* Now VALUE is a positive NaN.  */
-                   break;
-                 default:
-                   value = atof (read_buffer + negative);
-                   break;
-                 }
-
-               return make_float (negative ? - value : value);
-             }
+           Lisp_Object result = string_to_number (read_buffer, 10, 0);
+           if (! NILP (result))
+             return result;
          }
        {
          Lisp_Object name, result;
@@ -3242,74 +3166,179 @@ substitute_in_interval (INTERVAL interval, Lisp_Object arg)
 }
 
 \f
+static inline int
+digit_to_number (int character, int base)
+{
+  int digit;
+
+  if ('0' <= character && character <= '9')
+    digit = character - '0';
+  else if ('a' <= character && character <= 'z')
+    digit = character - 'a' + 10;
+  else if ('A' <= character && character <= 'Z')
+    digit = character - 'A' + 10;
+  else
+    return -1;
+
+  return digit < base ? digit : -1;
+}
+
 #define LEAD_INT 1
 #define DOT_CHAR 2
 #define TRAIL_INT 4
-#define E_CHAR 8
-#define EXP_INT 16
+#define E_EXP 16
 
-int
-isfloat_string (const char *cp, int ignore_trailing)
+
+/* Convert STRING to a number, assuming base BASE.  Return a fixnum if CP has
+   integer syntax and fits in a fixnum, else return the nearest float if CP has
+   either floating point or integer syntax and BASE is 10, else return nil.  If
+   IGNORE_TRAILING is nonzero, consider just the longest prefix of CP that has
+   valid floating point syntax.  Signal an overflow if BASE is not 10 and the
+   number has integer syntax but does not fit.  */
+
+Lisp_Object
+string_to_number (char const *string, int base, int ignore_trailing)
 {
   int state;
-  const char *start = cp;
+  char const *cp = string;
+  int leading_digit;
+  int float_syntax = 0;
+  double value = 0;
+
+  /* Compute NaN and infinities using a variable, to cope with compilers that
+     think they are smarter than we are.  */
+  double zero = 0;
+
+  /* Negate the value ourselves.  This treats 0, NaNs, and infinity properly on
+     IEEE floating point hosts, and works around a formerly-common bug where
+     atof ("-0.0") drops the sign.  */
+  int negative = *cp == '-';
+
+  int signedp = negative || *cp == '+';
+  cp += signedp;
 
   state = 0;
-  if (*cp == '+' || *cp == '-')
-    cp++;
 
-  if (*cp >= '0' && *cp <= '9')
+  leading_digit = digit_to_number (*cp, base);
+  if (0 <= leading_digit)
     {
       state |= LEAD_INT;
-      while (*cp >= '0' && *cp <= '9')
-       cp++;
+      do
+       ++cp;
+      while (0 <= digit_to_number (*cp, base));
     }
   if (*cp == '.')
     {
       state |= DOT_CHAR;
       cp++;
     }
-  if (*cp >= '0' && *cp <= '9')
-    {
-      state |= TRAIL_INT;
-      while (*cp >= '0' && *cp <= '9')
-       cp++;
-    }
-  if (*cp == 'e' || *cp == 'E')
-    {
-      state |= E_CHAR;
-      cp++;
-      if (*cp == '+' || *cp == '-')
-       cp++;
-    }
 
-  if (*cp >= '0' && *cp <= '9')
+  if (base == 10)
     {
-      state |= EXP_INT;
-      while (*cp >= '0' && *cp <= '9')
-       cp++;
-    }
-  else if (cp == start)
-    ;
-  else if (cp[-1] == '+' && cp[0] == 'I' && cp[1] == 'N' && cp[2] == 'F')
-    {
-      state |= EXP_INT;
-      cp += 3;
+      if ('0' <= *cp && *cp <= '9')
+       {
+         state |= TRAIL_INT;
+         do
+           cp++;
+         while ('0' <= *cp && *cp <= '9');
+       }
+      if (*cp == 'e' || *cp == 'E')
+       {
+         char const *ecp = cp;
+         cp++;
+         if (*cp == '+' || *cp == '-')
+           cp++;
+         if ('0' <= *cp && *cp <= '9')
+           {
+             state |= E_EXP;
+             do
+               cp++;
+             while ('0' <= *cp && *cp <= '9');
+           }
+         else if (cp[-1] == '+'
+                  && cp[0] == 'I' && cp[1] == 'N' && cp[2] == 'F')
+           {
+             state |= E_EXP;
+             cp += 3;
+             value = 1.0 / zero;
+           }
+         else if (cp[-1] == '+'
+                  && cp[0] == 'N' && cp[1] == 'a' && cp[2] == 'N')
+           {
+             state |= E_EXP;
+             cp += 3;
+             value = zero / zero;
+
+             /* If that made a "negative" NaN, negate it.  */
+             {
+               int i;
+               union { double d; char c[sizeof (double)]; }
+                 u_data, u_minus_zero;
+               u_data.d = value;
+               u_minus_zero.d = -0.0;
+               for (i = 0; i < sizeof (double); i++)
+                 if (u_data.c[i] & u_minus_zero.c[i])
+                   {
+                     value = -value;
+                     break;
+                   }
+             }
+             /* Now VALUE is a positive NaN.  */
+           }
+         else
+           cp = ecp;
+       }
+
+      float_syntax = ((state & (DOT_CHAR|TRAIL_INT)) == (DOT_CHAR|TRAIL_INT)
+                     || state == (LEAD_INT|E_EXP));
     }
-  else if (cp[-1] == '+' && cp[0] == 'N' && cp[1] == 'a' && cp[2] == 'N')
+
+  /* Return nil if the number uses invalid syntax.  If IGNORE_TRAILING, accept
+     any prefix that matches.  Otherwise, the entire string must match.  */
+  if (! (ignore_trailing
+        ? ((state & LEAD_INT) != 0 || float_syntax)
+        : (!*cp && ((state & ~DOT_CHAR) == LEAD_INT || float_syntax))))
+    return Qnil;
+
+  /* If the number uses integer and not float syntax, and is in C-language
+     range, use its value, preferably as a fixnum.  */
+  if (0 <= leading_digit && ! float_syntax)
     {
-      state |= EXP_INT;
-      cp += 3;
+      uintmax_t n;
+
+      /* Fast special case for single-digit integers.  This also avoids a
+        glitch when BASE is 16 and IGNORE_TRAILING is nonzero, because in that
+        case some versions of strtoumax accept numbers like "0x1" that Emacs
+        does not allow.  */
+      if (digit_to_number (string[signedp + 1], base) < 0)
+       return make_number (negative ? -leading_digit : leading_digit);
+
+      errno = 0;
+      n = strtoumax (string + signedp, NULL, base);
+      if (errno == ERANGE)
+       {
+         /* Unfortunately there's no simple and accurate way to convert
+            non-base-10 numbers that are out of C-language range.  */
+         if (base != 10)
+           xsignal (Qoverflow_error, list1 (build_string (string)));
+       }
+      else if (n <= (negative ? -MOST_NEGATIVE_FIXNUM : MOST_POSITIVE_FIXNUM))
+       {
+         EMACS_INT signed_n = n;
+         return make_number (negative ? -signed_n : signed_n);
+       }
+      else
+       value = n;
     }
 
-  return ((ignore_trailing
-          || *cp == 0 || *cp == ' ' || *cp == '\t' || *cp == '\n'
-          || *cp == '\r' || *cp == '\f')
-         && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
-             || state == (DOT_CHAR|TRAIL_INT)
-             || state == (LEAD_INT|E_CHAR|EXP_INT)
-             || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
-             || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
+  /* Either the number uses float syntax, or it does not fit into a fixnum.
+     Convert it from string to floating point, unless the value is already
+     known because it is an infinity, a NAN, or its absolute value fits in
+     uintmax_t.  */
+  if (! value)
+    value = atof (string + signedp);
+
+  return make_float (negative ? -value : value);
 }
 
 \f
@@ -3327,7 +3356,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag)
   len = Flength (tem);
   vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
 
-  size = XVECTOR (vector)->size;
+  size = ASIZE (vector);
   ptr = XVECTOR (vector)->contents;
   for (i = 0; i < size; i++)
     {
@@ -3592,7 +3621,7 @@ static int hash_string (const char *ptr, int len);
 Lisp_Object
 check_obarray (Lisp_Object obarray)
 {
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
     {
       /* If Vobarray is now invalid, force it to be valid.  */
       if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
@@ -3612,7 +3641,7 @@ intern (const char *str)
   Lisp_Object obarray;
 
   obarray = Vobarray;
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
     obarray = check_obarray (obarray);
   tem = oblookup (obarray, str, len, len);
   if (SYMBOLP (tem))
@@ -3628,7 +3657,7 @@ intern_c_string (const char *str)
   Lisp_Object obarray;
 
   obarray = Vobarray;
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
     obarray = check_obarray (obarray);
   tem = oblookup (obarray, str, len, len);
   if (SYMBOLP (tem))
@@ -3801,10 +3830,10 @@ oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_I
   Lisp_Object bucket, tem;
 
   if (!VECTORP (obarray)
-      || (obsize = XVECTOR (obarray)->size) == 0)
+      || (obsize = ASIZE (obarray)) == 0)
     {
       obarray = check_obarray (obarray);
-      obsize = XVECTOR (obarray)->size;
+      obsize = ASIZE (obarray);
     }
   /* This is sometimes needed in the middle of GC.  */
   obsize &= ~ARRAY_MARK_FLAG;
@@ -3852,7 +3881,7 @@ map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Ob
   register int i;
   register Lisp_Object tail;
   CHECK_VECTOR (obarray);
-  for (i = XVECTOR (obarray)->size - 1; i >= 0; i--)
+  for (i = ASIZE (obarray) - 1; i >= 0; i--)
     {
       tail = XVECTOR (obarray)->contents[i];
       if (SYMBOLP (tail))
@@ -3932,7 +3961,7 @@ defsubr (struct Lisp_Subr *sname)
 {
   Lisp_Object sym;
   sym = intern_c_string (sname->symbol_name);
-  XSETPVECTYPE (sname, PVEC_SUBR);
+  XSETTYPED_PVECTYPE (sname, size, PVEC_SUBR);
   XSETSUBR (XSYMBOL (sym)->function, sname);
 }
 
index dbca9b5b8381f7a2907ce77c19038789e2635ad5..50fcf8e78729e416d9859bd13deccdc128e389cc 100644 (file)
@@ -28,7 +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 pI                     "l"
 #define EMACS_UINT              unsigned long
 
 /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
index a1374d7c224646de8fd5ef5e573f06746192284f..7a8866a9503ddf8c6fe260e1e222b90c53190b77 100644 (file)
@@ -28,7 +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 pI                     "l"
 #define EMACS_UINT             unsigned long
 
 #ifdef REL_ALLOC
index 14228b61e56462af631b8a24e6d3eeaa888439f2..04092d6e1acfc2eaed101c158912bc01b99369a9 100644 (file)
@@ -24,7 +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 pI "l"
 #define EMACS_UINT unsigned long
 
 /* On the 64 bit architecture, we can use 60 bits for addresses */
index 6316ba514b9a019b7801057c439fb7cb0c361896..3f8bd8352111e63439f50854338d5797852e700c 100644 (file)
@@ -1227,7 +1227,7 @@ is used to further constrain the set of candidates.  */)
   if (type == obarray_table)
     {
       collection = check_obarray (collection);
-      obsize = XVECTOR (collection)->size;
+      obsize = ASIZE (collection);
       bucket = XVECTOR (collection)->contents[idx];
     }
 
@@ -1490,7 +1490,7 @@ with a space are ignored unless STRING itself starts with a space.  */)
   if (type == 2)
     {
       collection = check_obarray (collection);
-      obsize = XVECTOR (collection)->size;
+      obsize = ASIZE (collection);
       bucket = XVECTOR (collection)->contents[idx];
     }
 
@@ -1804,7 +1804,7 @@ the values STRING, PREDICATE and `lambda'.  */)
 
       if (completion_ignore_case && !SYMBOLP (tem))
        {
-         for (i = XVECTOR (collection)->size - 1; i >= 0; i--)
+         for (i = ASIZE (collection) - 1; i >= 0; i--)
            {
              tail = XVECTOR (collection)->contents[i];
              if (SYMBOLP (tail))
index 6a331cb11f29b9a7301566e6c239c6e780d77b65..f0624d5d16e4c8be961d5de5c852472b5f69f5e7 100644 (file)
@@ -808,10 +808,9 @@ safe_debug_print (Lisp_Object arg)
   if (valid > 0)
     debug_print (arg);
   else
-    fprintf (stderr, "#<%s_LISP_OBJECT 0x%08lx>\r\n",
+    fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
             !valid ? "INVALID" : "SOME",
-            (unsigned long) XHASH (arg)
-            );
+            XHASH (arg));
 }
 
 \f
@@ -1199,7 +1198,7 @@ print_preprocess (Lisp_Object obj)
          goto loop;
 
        case Lisp_Vectorlike:
-         size = XVECTOR (obj)->size;
+         size = ASIZE (obj);
          if (size & PSEUDOVECTOR_FLAG)
            size &= PSEUDOVECTOR_SIZE_MASK;
          for (i = 0; i < size; i++)
@@ -1338,11 +1337,11 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
          Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil);
          if (INTEGERP (num))
            {
-             int n = XINT (num);
+             EMACS_INT n = XINT (num);
              if (n < 0)
                { /* Add a prefix #n= if OBJ has not yet been printed;
                     that is, its status field is nil.  */
-                 sprintf (buf, "#%d=", -n);
+                 sprintf (buf, "#%"pI"d=", -n);
                  strout (buf, -1, -1, printcharfun);
                  /* OBJ is going to be printed.  Remember that fact.  */
                  Fputhash (obj, make_number (- n), Vprint_number_table);
@@ -1350,7 +1349,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
              else
                {
                  /* Just print #n# if OBJ has already been printed.  */
-                 sprintf (buf, "#%d#", n);
+                 sprintf (buf, "#%"pI"d#", n);
                  strout (buf, -1, -1, printcharfun);
                  return;
                }
@@ -1363,12 +1362,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
   switch (XTYPE (obj))
     {
     case_Lisp_Int:
-      if (sizeof (int) == sizeof (EMACS_INT))
-       sprintf (buf, "%d", (int) XINT (obj));
-      else if (sizeof (long) == sizeof (EMACS_INT))
-       sprintf (buf, "%ld", (long) XINT (obj));
-      else
-       abort ();
+      sprintf (buf, "%"pI"d", XINT (obj));
       strout (buf, -1, -1, printcharfun);
       break;
 
@@ -1701,7 +1695,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
 
          PRINTCHAR ('#');
          PRINTCHAR ('&');
-         sprintf (buf, "%ld", (long) XBOOL_VECTOR (obj)->size);
+         sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size);
          strout (buf, -1, -1, printcharfun);
          PRINTCHAR ('\"');
 
@@ -1754,7 +1748,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
       else if (WINDOWP (obj))
        {
          strout ("#<window ", -1, -1, printcharfun);
-         sprintf (buf, "%ld", (long) XFASTINT (XWINDOW (obj)->sequence_number));
+         sprintf (buf, "%"pI"d", XFASTINT (XWINDOW (obj)->sequence_number));
          strout (buf, -1, -1, printcharfun);
          if (!NILP (XWINDOW (obj)->buffer))
            {
@@ -1792,7 +1786,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
              strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun);
              PRINTCHAR (' ');
              sprintf (buf, "%ld/%ld", (long) h->count,
-                      (long) XVECTOR (h->next)->size);
+                      (long) ASIZE (h->next));
              strout (buf, -1, -1, printcharfun);
            }
          sprintf (buf, " 0x%lx", (unsigned long) h);
@@ -1803,7 +1797,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
            #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
          /* Always print the size. */
          sprintf (buf, "#s(hash-table size %ld",
-                  (long) XVECTOR (h->next)->size);
+                  (long) ASIZE (h->next));
          strout (buf, -1, -1, printcharfun);
 
          if (!NILP (h->test))
@@ -1881,7 +1875,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
                   ? "#<frame " : "#<dead frame "),
                  -1, -1, printcharfun);
          print_string (XFRAME (obj)->name, printcharfun);
-         sprintf (buf, " 0x%lx", (unsigned long) (XFRAME (obj)));
+         sprintf (buf, " %p", XFRAME (obj));
          strout (buf, -1, -1, printcharfun);
          PRINTCHAR ('>');
        }
@@ -1915,7 +1909,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
        }
       else
        {
-         EMACS_INT size = XVECTOR (obj)->size;
+         EMACS_INT size = ASIZE (obj);
          if (COMPILEDP (obj))
            {
              PRINTCHAR ('#');
@@ -1978,7 +1972,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
            strout ("in no buffer", -1, -1, printcharfun);
          else
            {
-             sprintf (buf, "at %ld", (long)marker_position (obj));
+             sprintf (buf, "at %"pI"d", marker_position (obj));
              strout (buf, -1, -1, printcharfun);
              strout (" in ", -1, -1, printcharfun);
              print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun);
@@ -1992,9 +1986,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
            strout ("in no buffer", -1, -1, printcharfun);
          else
            {
-             sprintf (buf, "from %ld to %ld in ",
-                      (long)marker_position (OVERLAY_START (obj)),
-                      (long)marker_position (OVERLAY_END   (obj)));
+             sprintf (buf, "from %"pI"d to %"pI"d in ",
+                      marker_position (OVERLAY_START (obj)),
+                      marker_position (OVERLAY_END   (obj)));
              strout (buf, -1, -1, printcharfun);
              print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name),
                            printcharfun);
@@ -2010,8 +2004,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
 
        case Lisp_Misc_Save_Value:
          strout ("#<save_value ", -1, -1, printcharfun);
-         sprintf(buf, "ptr=0x%08lx int=%d",
-                 (unsigned long) XSAVE_VALUE (obj)->pointer,
+         sprintf(buf, "ptr=%p int=%d",
+                 XSAVE_VALUE (obj)->pointer,
                  XSAVE_VALUE (obj)->integer);
          strout (buf, -1, -1, printcharfun);
          PRINTCHAR ('>');
@@ -2031,7 +2025,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
        if (MISCP (obj))
          sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj));
        else if (VECTORLIKEP (obj))
-         sprintf (buf, "(PVEC 0x%08x)", (int) XVECTOR (obj)->size);
+         sprintf (buf, "(PVEC 0x%08lx)", (unsigned long) ASIZE (obj));
        else
          sprintf (buf, "(0x%02x)", (int) XTYPE (obj));
        strout (buf, -1, -1, printcharfun);
index 4253286196c60bfbf414fc7987415d16b175cd2a..1544522ff55fd3ac29d13568226b288c24eacd4b 100644 (file)
@@ -1188,25 +1188,26 @@ Returns nil if format of ADDRESS is invalid.  */)
   if (VECTORP (address))  /* AF_INET or AF_INET6 */
     {
       register struct Lisp_Vector *p = XVECTOR (address);
+      EMACS_UINT size = p->header.size;
       Lisp_Object args[10];
       int nargs, i;
 
-      if (p->size == 4 || (p->size == 5 && !NILP (omit_port)))
+      if (size == 4 || (size == 5 && !NILP (omit_port)))
        {
          args[0] = build_string ("%d.%d.%d.%d");
          nargs = 4;
        }
-      else if (p->size == 5)
+      else if (size == 5)
        {
          args[0] = build_string ("%d.%d.%d.%d:%d");
          nargs = 5;
        }
-      else if (p->size == 8 || (p->size == 9 && !NILP (omit_port)))
+      else if (size == 8 || (size == 9 && !NILP (omit_port)))
        {
          args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x");
          nargs = 8;
        }
-      else if (p->size == 9)
+      else if (size == 9)
        {
          args[0] = build_string ("[%x:%x:%x:%x:%x:%x:%x:%x]:%d");
          nargs = 9;
@@ -2064,13 +2065,13 @@ get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp)
   if (VECTORP (address))
     {
       p = XVECTOR (address);
-      if (p->size == 5)
+      if (p->header.size == 5)
        {
          *familyp = AF_INET;
          return sizeof (struct sockaddr_in);
        }
 #ifdef AF_INET6
-      else if (p->size == 9)
+      else if (p->header.size == 9)
        {
          *familyp = AF_INET6;
          return sizeof (struct sockaddr_in6);
@@ -2089,7 +2090,7 @@ get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp)
       struct sockaddr *sa;
       *familyp = XINT (XCAR (address));
       p = XVECTOR (XCDR (address));
-      return p->size + sizeof (sa->sa_family);
+      return p->header.size + sizeof (sa->sa_family);
     }
   return 0;
 }
@@ -3041,7 +3042,7 @@ usage: (make-network-process &rest ARGS)  */)
        portstring = "0";
       else if (INTEGERP (service))
        {
-         sprintf (portbuf, "%ld", (long) XINT (service));
+         sprintf (portbuf, "%"pI"d", XINT (service));
          portstring = portbuf;
        }
       else
@@ -3723,9 +3724,9 @@ FLAGS is the current flags of the interface.  */)
              flags -= fp->flag_bit;
            }
        }
-      for (fnum = 0; flags && fnum < 32; fnum++)
+      for (fnum = 0; flags && fnum < 32; flags >>= 1, fnum++)
        {
-         if (flags & (1 << fnum))
+         if (flags & 1)
            {
              elt = Fcons (make_number (fnum), elt);
            }
index 0348f211bb9856e2bb64d9661560563a9eb804f0..4866a8c1022cdd30438e6c08d6250606fcb00b68 100644 (file)
@@ -29,13 +29,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* This structure records information about a subprocess
    or network connection.
 
-   Every field in this structure except for the first two
+   Every field in this structure except for the header
    must be a Lisp_Object, for GC's sake.  */
 
 struct Lisp_Process
   {
-    EMACS_UINT size;
-    struct Lisp_Vector *v_next;
+    struct vectorlike_header header;
+
     /* Name of subprocess terminal.  */
     Lisp_Object tty_name;
     /* Name of this process */
index a0b85039e7467a9574278c8a13ee0b66cd9c4b39..d701f4d71b014df0c158f32e86847f9b9fa026e1 100644 (file)
@@ -790,9 +790,9 @@ pp_cache (struct region_cache *c)
   EMACS_INT end_u = c->buffer_end - c->end_unchanged;
 
   fprintf (stderr,
-           "basis: %ld..%ld    modified: %ld..%ld\n",
-           (long)c->buffer_beg, (long)c->buffer_end,
-           (long)beg_u, (long)end_u);
+           "basis: %"pI"d..%"pI"d    modified: %"pI"d..%"pI"d\n",
+           c->buffer_beg, c->buffer_end,
+           beg_u, end_u);
 
   for (i = 0; i < c->cache_len; i++)
     {
@@ -806,6 +806,6 @@ pp_cache (struct region_cache *c)
              : (pos == end_u) ? '-'
              : ' '),
             stderr);
-      fprintf (stderr, "%ld : %d\n", (long)pos, BOUNDARY_VALUE (c, i));
+      fprintf (stderr, "%"pI"d : %d\n", pos, BOUNDARY_VALUE (c, i));
     }
 }
index 9013a897dd0cb957c6748df43078d857ee7e563e..cff6d50f51093202dcf974ea6b9ec67c7a2f3e31 100644 (file)
@@ -981,7 +981,7 @@ text property.  */)
        break;
       }
 
-  if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match))
+  if (val < ASIZE (Vsyntax_code_object) && NILP (match))
     return XVECTOR (Vsyntax_code_object)->contents[val];
   else
     /* Since we can't use a shared object, let's make a new one.  */
@@ -3372,7 +3372,7 @@ init_syntax_once (void)
 
   /* Create objects which can be shared among syntax tables.  */
   Vsyntax_code_object = Fmake_vector (make_number (Smax), Qnil);
-  for (i = 0; i < XVECTOR (Vsyntax_code_object)->size; i++)
+  for (i = 0; i < ASIZE (Vsyntax_code_object); i++)
     XVECTOR (Vsyntax_code_object)->contents[i]
       = Fcons (make_number (i), Qnil);
 
index 4b3a78e154e1f61cd31c768d4c6ef9adbd0ef1bd..ca7de4f54bb4c5d0c79a9bd19e9b6d72ba6d0641 100644 (file)
@@ -2383,7 +2383,7 @@ serial_configure (struct Lisp_Process *p,
   CHECK_NUMBER (tem);
   err = cfsetspeed (&attr, XINT (tem));
   if (err != 0)
-    error ("cfsetspeed(%"pEd") failed: %s", XINT (tem),
+    error ("cfsetspeed(%"pI"d) failed: %s", XINT (tem),
           emacs_strerror (errno));
   childp2 = Fplist_put (childp2, QCspeed, tem);
 
index c6b1084f347dc9aea36694a812c0867dcbe27ad3..3a49b49aedeb97b0855f1727665da17c806e75cd 100644 (file)
@@ -322,10 +322,8 @@ struct w32_display_info;
 /* Terminal-local parameters. */
 struct terminal
 {
-  /* The first two fields are really the header of a vector */
-  /* The terminal code does not refer to them.  */
-  EMACS_UINT size;
-  struct Lisp_Vector *vec_next;
+  /* This is for Lisp; the terminal code does not refer to it.  */
+  struct vectorlike_header header;
 
   /* Parameter alist of this terminal.  */
   Lisp_Object param_alist;
index a224c121e211f693c654c43992ecd021c097f6b6..aad090c5b41a6ae1feaa95e60a7ebe2c5522edd0 100644 (file)
@@ -1348,15 +1348,18 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
   register EMACS_INT s, len;
   INTERVAL unchanged;
 
-  s = XINT (start);
-  len = XINT (end) - s;
-  if (len == 0)
-    return;
-  if (len < 0)
+  if (XINT (start) < XINT (end))
     {
-      s = s + len;
-      len = - len;
+      s = XINT (start);
+      len = XINT (end) - s;
     }
+  else if (XINT (end) < XINT (start))
+    {
+      s = XINT (end);
+      len = XINT (start) - s;
+    }
+  else
+    return;
 
   if (i == 0)
     i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);
index d86107bc6d50e94ae9dd63f87b244922cc5e5ed3..985370c15c14aef91daea77f3982c92855231e07 100644 (file)
@@ -165,7 +165,7 @@ intern_font_name (char * string)
 
   /* The following code is copied from the function intern (in lread.c).  */
   obarray = Vobarray;
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
     obarray = check_obarray (obarray);
   tem = oblookup (obarray, SDATA (str), len, len);
   if (SYMBOLP (tem))
@@ -2581,4 +2581,3 @@ versions of Windows) characters.  */);
   w32font_driver.type = Qgdi;
   register_font_driver (&w32font_driver, NULL);
 }
-
index f092ff87bf2898fa8f348c97685eda5b54879e8c..c8c6a319b4008ae43c1b2ff0ffc096712b442412 100644 (file)
@@ -427,11 +427,11 @@ 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_start = (int *) alloca (ASIZE (items) * sizeof (int *));
+      submenu_end = (int *) alloca (ASIZE (items) * sizeof (int *));
+      submenu_n_panes = (int *) alloca (ASIZE (items) * sizeof (int));
       submenu_top_level_items
-       = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
+       = (int *) alloca (ASIZE (items) * sizeof (int *));
       init_menu_items ();
       for (i = 0; i < ASIZE (items); i += 4)
        {
index 5d059535614f4666289a0d4c62a8aa405c854fec..b56ed84bc6116c4d1d995f91cfbee3c4e6efe9fe 100644 (file)
@@ -5794,8 +5794,7 @@ zero means top of window, negative means relative to bottom of window.  */)
 
 struct save_window_data
   {
-    EMACS_UINT size;
-    struct Lisp_Vector *next_from_Lisp_Vector_struct;
+    struct vectorlike_header header;
     Lisp_Object selected_frame;
     Lisp_Object current_window;
     Lisp_Object current_buffer;
@@ -5817,10 +5816,7 @@ struct save_window_data
 /* This is saved as a Lisp_Vector  */
 struct saved_window
 {
-  /* these first two must agree with struct Lisp_Vector in lisp.h */
-  EMACS_UINT size;
-  struct Lisp_Vector *next_from_Lisp_Vector_struct;
-
+  struct vectorlike_header header;
   Lisp_Object window;
   Lisp_Object buffer, start, pointm, mark;
   Lisp_Object left_col, top_line, total_cols, total_lines;
@@ -6001,7 +5997,7 @@ the return value is nil.  Otherwise the value is t.  */)
         dead.  */
       delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f)));
 
-      for (k = 0; k < saved_windows->size; k++)
+      for (k = 0; k < saved_windows->header.size; k++)
        {
          p = SAVED_WINDOW_N (saved_windows, k);
          w = XWINDOW (p->window);
@@ -6884,10 +6880,10 @@ compare_window_configurations (Lisp_Object c1, Lisp_Object c2, int ignore_positi
     return 0;
 
   /* Verify that the two confis have the same number of windows.  */
-  if (sw1->size != sw2->size)
+  if (sw1->header.size != sw2->header.size)
     return 0;
 
-  for (i = 0; i < sw1->size; i++)
+  for (i = 0; i < sw1->header.size; i++)
     {
       struct saved_window *p1, *p2;
       int w1_is_current, w2_is_current;
index 65d554a55014d485e0f552deb262da44cdbbed21..b1f6560445ecc78cdd88045c5a811ebc365ab2c5 100644 (file)
@@ -88,10 +88,9 @@ struct cursor_pos
 
 struct window
   {
-    /* The first two fields are really the header of a vector */
-    /* The window code does not refer to them.  */
-    EMACS_UINT size;
-    struct Lisp_Vector *vec_next;
+    /* This is for Lisp; the terminal code does not refer to it.  */
+    struct vectorlike_header header;
+
     /* The frame this window is on.  */
     Lisp_Object frame;
     /* t if this window is a minibuffer window.  */
index 219f414c9e89d7c520b884d4aa7e0f5e3d4f772a..6d3c142f62a25fd4a108cafddc8b5847600e8049 100644 (file)
@@ -3705,7 +3705,7 @@ setup_for_ellipsis (struct it *it, int len)
     {
       struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
       it->dpvec = v->contents;
-      it->dpend = v->contents + v->size;
+      it->dpend = v->contents + v->header.size;
     }
   else
     {
@@ -5659,11 +5659,11 @@ get_next_display_element (struct it *it)
              /* Return the first character from the display table
                 entry, if not empty.  If empty, don't display the
                 current character.  */
-             if (v->size)
+             if (v->header.size)
                {
                  it->dpvec_char_len = it->len;
                  it->dpvec = v->contents;
-                 it->dpend = v->contents + v->size;
+                 it->dpend = v->contents + v->header.size;
                  it->current.dpvec_index = 0;
                  it->dpvec_face_id = -1;
                  it->saved_face_id = it->face_id;
@@ -18124,7 +18124,7 @@ display_menu_bar (struct window *w)
 
   /* Display all items of the menu bar.  */
   items = FRAME_MENU_BAR_ITEMS (it.f);
-  for (i = 0; i < XVECTOR (items)->size; i += 4)
+  for (i = 0; i < ASIZE (items); i += 4)
     {
       Lisp_Object string;
 
@@ -19562,7 +19562,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
               so get us a 2-digit number that is close.  */
            if (total == 100)
              total = 99;
-           sprintf (decode_mode_spec_buf, "%2ld%%", (long)total);
+           sprintf (decode_mode_spec_buf, "%2"pI"d%%", total);
            return decode_mode_spec_buf;
          }
       }
@@ -19593,9 +19593,9 @@ decode_mode_spec (struct window *w, register int c, int field_width,
            if (total == 100)
              total = 99;
            if (toppos <= BUF_BEGV (b))
-             sprintf (decode_mode_spec_buf, "Top%2ld%%", (long)total);
+             sprintf (decode_mode_spec_buf, "Top%2"pI"d%%", total);
            else
-             sprintf (decode_mode_spec_buf, "%2ld%%", (long)total);
+             sprintf (decode_mode_spec_buf, "%2"pI"d%%", total);
            return decode_mode_spec_buf;
          }
       }
@@ -24816,7 +24816,7 @@ on_hot_spot_p (Lisp_Object hot_spot, int x, int y)
        {
          struct Lisp_Vector *v = XVECTOR (XCDR (hot_spot));
          Lisp_Object *poly = v->contents;
-         int n = v->size;
+         int n = v->header.size;
          int i;
          int inside = 0;
          Lisp_Object lx, ly;
index 8e68b05cd876a362960fcabfa2a65f4b91d9fb45..a26289e8a886a33b3ea744bf132a6be181613af8 100644 (file)
@@ -1848,7 +1848,7 @@ the WIDTH times as wide as FACE on FRAME.  */)
 
 #define LFACEP(LFACE)                                  \
      (VECTORP (LFACE)                                  \
-      && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE    \
+      && ASIZE (LFACE) == LFACE_VECTOR_SIZE            \
       && EQ (AREF (LFACE, 0), Qface))
 #endif
 
index 51aca3e96705a0b62ba4a8c9a01e535df928aa6a..f3dc493ff8514d90dfd7afd39f876753e684e6f6 100644 (file)
@@ -216,7 +216,7 @@ check_x_display_info (Lisp_Object object)
       struct terminal *t = get_terminal (object, 1);
 
       if (t->type != output_x_window)
-        error ("Terminal %"pEd" is not an X display", XINT (object));
+        error ("Terminal %"pI"d is not an X display", XINT (object));
 
       dpyinfo = t->display_info.x;
     }
@@ -4352,7 +4352,7 @@ no value of TYPE (always string in the MS Windows case).  */)
              property and those are indeed in 32 bit quantities if format is
              32.  */
 
-          if (actual_format == 32 && actual_format < BITS_PER_LONG)
+          if (32 < BITS_PER_LONG && actual_format == 32)
             {
               unsigned long i;
               int  *idata = (int *) tmp_data;
index 938e5696b21f1f8971fa8956ff2c9b5c37b1fff5..2d6185c16e5b4f0eb3ffc38af3d533e3806bb4e5 100644 (file)
@@ -1011,7 +1011,7 @@ 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;
-      subitems = XVECTOR (items)->size / 4;
+      subitems = ASIZE (items) / 4;
       submenu_start = (int *) alloca (subitems * sizeof (int *));
       submenu_end = (int *) alloca (subitems * sizeof (int *));
       submenu_n_panes = (int *) alloca (subitems * sizeof (int));
@@ -1097,7 +1097,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
       /* Now GC cannot happen during the lifetime of the widget_value,
         so it's safe to store data from a Lisp_String.  */
       wv = first_wv->contents;
-      for (i = 0; i < XVECTOR (items)->size; i += 4)
+      for (i = 0; i < ASIZE (items); i += 4)
        {
          Lisp_Object string;
          string = XVECTOR (items)->contents[i + 1];
@@ -1123,7 +1123,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
       first_wv = wv;
 
       items = FRAME_MENU_BAR_ITEMS (f);
-      for (i = 0; i < XVECTOR (items)->size; i += 4)
+      for (i = 0; i < ASIZE (items); i += 4)
        {
          Lisp_Object string;
 
index b01e344edf214235e80350265e1f47ec20c1e9e0..b490afdabaa8eb7a421c49852c9b410eb53c5d8b 100644 (file)
@@ -536,10 +536,10 @@ x_load_resources (Display *display, const char *xrm_string,
      dialog from `double-click-time'.  */
   if (INTEGERP (Vdouble_click_time) && XINT (Vdouble_click_time) > 0)
     {
-      sprintf (line, "%s*fsb*DirList.doubleClickInterval: %d",
+      sprintf (line, "%s*fsb*DirList.doubleClickInterval: %"pI"d",
               myclass, XFASTINT (Vdouble_click_time));
       XrmPutLineResource (&rdb, line);
-      sprintf (line, "%s*fsb*ItemsList.doubleClickInterval: %d",
+      sprintf (line, "%s*fsb*ItemsList.doubleClickInterval: %"pI"d",
               myclass, XFASTINT (Vdouble_click_time));
       XrmPutLineResource (&rdb, line);
     }
index 2d656cfec9aac4b9d2a8f33012d3afe3f6757a44..f11fc40fce8c3623e4d92ad1a718054530f0050a 100644 (file)
@@ -169,7 +169,7 @@ x_queue_event (struct input_event *event)
     {
       if (!memcmp (&queue_tmp->event, event, sizeof (*event)))
        {
-         TRACE1 ("DECLINE DUP SELECTION EVENT %08lx", (unsigned long)queue_tmp);
+         TRACE1 ("DECLINE DUP SELECTION EVENT %p", queue_tmp);
          x_decline_selection_request (event);
          return;
        }
@@ -180,7 +180,7 @@ x_queue_event (struct input_event *event)
 
   if (queue_tmp != NULL)
     {
-      TRACE1 ("QUEUE SELECTION EVENT %08lx", (unsigned long)queue_tmp);
+      TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
       queue_tmp->event = *event;
       queue_tmp->next = selection_queue;
       selection_queue = queue_tmp;
@@ -213,7 +213,7 @@ x_stop_queuing_selection_requests (void)
   while (selection_queue != NULL)
     {
       struct selection_event_queue *queue_tmp = selection_queue;
-      TRACE1 ("RESTORE SELECTION EVENT %08lx", (unsigned long)queue_tmp);
+      TRACE1 ("RESTORE SELECTION EVENT %p", queue_tmp);
       kbd_buffer_unget_event (&queue_tmp->event);
       selection_queue = queue_tmp->next;
       xfree ((char *)queue_tmp);
@@ -423,7 +423,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, in
       int size;
       int i;
       pairs = XCDR (target_type);
-      size = XVECTOR (pairs)->size;
+      size = ASIZE (pairs);
       /* If the target is MULTIPLE, then target_type looks like
          (MULTIPLE . [[SELECTION1 TARGET1] [SELECTION2 TARGET2] ... ])
         We modify the second element of each pair in the vector and
@@ -1261,12 +1261,12 @@ copy_multiple_data (obj)
     return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
 
   CHECK_VECTOR (obj);
-  vec = Fmake_vector (size = XVECTOR (obj)->size, Qnil);
+  vec = Fmake_vector (size = ASIZE (obj), Qnil);
   for (i = 0; i < size; i++)
     {
       Lisp_Object vec2 = XVECTOR (obj)->contents [i];
       CHECK_VECTOR (vec2);
-      if (XVECTOR (vec2)->size != 2)
+      if (ASIZE (vec2) != 2)
        /* ??? Confusing error message */
        signal_error ("Vectors must be of length 2", vec2);
       XVECTOR (vec)->contents [i] = Fmake_vector (2, Qnil);
@@ -1444,7 +1444,7 @@ x_get_window_property (Display *display, Window window, Atom property,
   while (bytes_remaining)
     {
 #ifdef TRACE_SELECTION
-      int last = bytes_remaining;
+      unsigned long last = bytes_remaining;
 #endif
       result
        = XGetWindowProperty (display, window, property,
@@ -1454,7 +1454,7 @@ x_get_window_property (Display *display, Window window, Atom property,
                              actual_type_ret, actual_format_ret,
                              actual_size_ret, &bytes_remaining, &tmp_data);
 
-      TRACE2 ("Read %ld bytes from property %s",
+      TRACE2 ("Read %lu bytes from property %s",
              last - bytes_remaining,
              XGetAtomName (display, property));
 
@@ -1477,7 +1477,7 @@ x_get_window_property (Display *display, Window window, Atom property,
          The bytes and offsets passed to XGetWindowProperty refers to the
          property and those are indeed in 32 bit quantities if format is 32.  */
 
-      if (*actual_format_ret == 32 && *actual_format_ret < BITS_PER_LONG)
+      if (32 < BITS_PER_LONG && *actual_format_ret == 32)
         {
           unsigned long i;
           int  *idata = (int *) ((*data_ret) + offset);
@@ -1878,7 +1878,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
        /* This vector is an ATOM set */
        {
          if (NILP (type)) type = QATOM;
-         *size_ret = XVECTOR (obj)->size;
+         *size_ret = ASIZE (obj);
          *format_ret = 32;
          *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom));
          for (i = 0; i < *size_ret; i++)
@@ -1893,7 +1893,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
        /* This vector is an ATOM_PAIR set */
        {
          if (NILP (type)) type = QATOM_PAIR;
-         *size_ret = XVECTOR (obj)->size;
+         *size_ret = ASIZE (obj);
          *format_ret = 32;
          *data_ret = (unsigned char *)
            xmalloc ((*size_ret) * sizeof (Atom) * 2);
@@ -1901,7 +1901,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
            if (VECTORP (XVECTOR (obj)->contents [i]))
              {
                Lisp_Object pair = XVECTOR (obj)->contents [i];
-               if (XVECTOR (pair)->size != 2)
+               if (ASIZE (pair) != 2)
                  signal_error (
        "Elements of the vector must be vectors of exactly two elements",
                                pair);
@@ -1923,7 +1923,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
        /* This vector is an INTEGER set, or something like it */
        {
           int data_size = 2;
-         *size_ret = XVECTOR (obj)->size;
+         *size_ret = ASIZE (obj);
          if (NILP (type)) type = QINTEGER;
          *format_ret = 16;
          for (i = 0; i < *size_ret; i++)
@@ -1976,7 +1976,7 @@ clean_local_selection_data (Lisp_Object obj)
   if (VECTORP (obj))
     {
       int i;
-      int size = XVECTOR (obj)->size;
+      int size = ASIZE (obj);
       Lisp_Object copy;
       if (size == 1)
        return clean_local_selection_data (XVECTOR (obj)->contents [0]);
@@ -2432,7 +2432,7 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, struct x_disp
      function expects them to be of size int (i.e. 32).  So to be able to
      use that function, put the data in the form it expects if format is 32. */
 
-  if (event->format == 32 && event->format < BITS_PER_LONG)
+  if (32 < BITS_PER_LONG && event->format == 32)
     {
       for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */
         idata[i] = (int) event->data.l[i];