Merge: Make the Lisp reader and string-to-float more consistent.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Apr 2011 06:26:24 +0000 (23:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Apr 2011 06:26:24 +0000 (23:26 -0700)
28 files changed:
src/ChangeLog
src/alloc.c
src/bidi.c
src/charset.c
src/coding.c
src/data.c
src/dbusbind.c
src/doc.c
src/fns.c
src/font.c
src/frame.c
src/gnutls.c
src/gtkutil.c
src/intervals.c
src/keyboard.c
src/lisp.h
src/lread.c
src/m/amdx86-64.h
src/m/ia64.h
src/m/ibms390x.h
src/print.c
src/process.c
src/region-cache.c
src/sysdep.c
src/xdisp.c
src/xfns.c
src/xrdb.c
src/xselect.c

index c232c24..e78faa3 100644 (file)
        This function checks for valid syntax and produces the resulting
        Lisp float number too.
 
+       * 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-19  Eli Zaretskii  <eliz@gnu.org>
 
        * syntax.h (SETUP_SYNTAX_TABLE_FOR_OBJECT): Fix setting of
index 412527b..8be6371 100644 (file)
@@ -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,7 +1055,8 @@ allocate_buffer (void)
   struct buffer *b
     = (struct buffer *) lisp_malloc (sizeof (struct buffer),
                                     MEM_TYPE_BUFFER);
-  b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
+  b->size = ((sizeof (struct buffer) + sizeof (EMACS_INT) - 1)
+            / sizeof (EMACS_INT));
   XSETPVECTYPE (b, PVEC_BUFFER);
   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)
 
 
@@ -1706,8 +1703,7 @@ string_bytes (struct Lisp_String *s)
 /* Check validity of Lisp strings' string_bytes member in B.  */
 
 static void
-check_sblock (b)
-     struct sblock *b;
+check_sblock (struct sblock *b)
 {
   struct sdata *from, *end, *from_end;
 
@@ -1740,8 +1736,7 @@ check_sblock (b)
    recently allocated strings.  Used for hunting a bug.  */
 
 static void
-check_string_bytes (all_p)
-     int all_p;
+check_string_bytes (int all_p)
 {
   if (all_p)
     {
@@ -1769,7 +1764,7 @@ check_string_bytes (all_p)
    This may catch buffer overrun from a previous string.  */
 
 static void
-check_string_free_list ()
+check_string_free_list (void)
 {
   struct Lisp_String *s;
 
@@ -1877,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
@@ -1938,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
@@ -2152,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);
                }
@@ -2806,7 +2802,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
@@ -4574,8 +4571,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);
 }
 
 
@@ -4734,7 +4732,8 @@ 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);
index 447abb4..88c45e2 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 c4699dc..9a7a56d 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_NATNUM (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) > '~')
     {
       unsigned char str[MAX_MULTIBYTE_LENGTH + 1];
index b49070e..38e41e7 100644 (file)
@@ -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 c3ee3e3..486816c 100644 (file)
@@ -2370,12 +2370,7 @@ 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);
 }
 
index 792414b..4c0b9bd 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 354aff8..74e06cc 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);
     }
 
@@ -671,7 +671,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;
index c057f64..2019039 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;
          }
index 7fe0815..2a8cf2e 100644 (file)
@@ -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 9024a2f..b106c56 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 f4f2b9b..38932c9 100644 (file)
@@ -140,9 +140,9 @@ emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf,
    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;
@@ -154,7 +154,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,
@@ -274,6 +274,7 @@ gnutls_emacs_global_init (void)
   return gnutls_make_error (ret);
 }
 
+#if 0
 /* Deinitializes global GnuTLS state.
 See also `gnutls-global-init'.  */
 static Lisp_Object
@@ -286,6 +287,7 @@ gnutls_emacs_global_deinit (void)
 
   return gnutls_make_error (GNUTLS_E_SUCCESS);
 }
+#endif
 
 static void
 gnutls_log_function (int level, const char* string)
@@ -341,14 +343,14 @@ 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;
 
   /* Placeholders for the property list elements.  */
   Lisp_Object priority_string;
   Lisp_Object trustfiles;
   Lisp_Object keyfiles;
-  Lisp_Object callbacks;
+  /* Lisp_Object callbacks; */
   Lisp_Object loglevel;
 
   CHECK_PROCESS (proc);
@@ -358,7 +360,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);
 
   state = XPROCESS (proc)->gnutls_state;
@@ -444,10 +446,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)
@@ -466,10 +468,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)
index 4b53915..9d3bfe6 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 7ce1796..3e73110 100644 (file)
@@ -778,7 +778,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;
index c601649..b0ae1b1 100644 (file)
@@ -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
        {
@@ -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);
        }
 
index 6080007..8d333a3 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
index 776d4ce..421f889 100644 (file)
@@ -1411,16 +1411,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 +1454,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;
index dbca9b5..50fcf8e 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 a1374d7..7a8866a 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 14228b6..04092d6 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 6a331cb..2c9aa9d 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
@@ -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))
            {
@@ -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 ('>');
        }
@@ -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) XVECTOR (obj)->size);
        else
          sprintf (buf, "(0x%02x)", (int) XTYPE (obj));
        strout (buf, -1, -1, printcharfun);
index d8851c5..f25d10d 100644 (file)
@@ -3041,7 +3041,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 +3723,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 a0b8503..d701f4d 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 45e80ac..a57b8c0 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 574c84f..19fc36a 100644 (file)
@@ -19574,7 +19574,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;
          }
       }
@@ -19605,9 +19605,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;
          }
       }
index 51aca3e..f3dc493 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 b01e344..b490afd 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 2d656cf..db00649 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);
@@ -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);
@@ -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];