summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-04-18 17:34:42 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-04-18 17:34:42 -0700
commit6d5a990afd8265c6470e52f2b4eae4f36691a743 (patch)
treed3889a3344a3788577f82b732987ef0d824dfc61
parentfb105e4c184e2aa9a6a11ed5b19f6011241be047 (diff)
downloademacs-6d5a990afd8265c6470e52f2b4eae4f36691a743.tar.gz
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. * 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. (x_stop_queuing_selection_requests): Likewise. (x_get_window_property): Don't truncate byte count to an 'int' when tracing.
-rw-r--r--src/ChangeLog31
-rw-r--r--src/alloc.c5
-rw-r--r--src/bidi.c2
-rw-r--r--src/charset.c8
-rw-r--r--src/coding.c12
-rw-r--r--src/data.c7
-rw-r--r--src/dbusbind.c6
-rw-r--r--src/doc.c4
-rw-r--r--src/fns.c2
-rw-r--r--src/font.c15
-rw-r--r--src/intervals.c2
-rw-r--r--src/keyboard.c8
-rw-r--r--src/lisp.h4
-rw-r--r--src/m/amdx86-64.h2
-rw-r--r--src/m/ia64.h2
-rw-r--r--src/m/ibms390x.h2
-rw-r--r--src/print.c38
-rw-r--r--src/process.c2
-rw-r--r--src/region-cache.c8
-rw-r--r--src/sysdep.c2
-rw-r--r--src/xdisp.c6
-rw-r--r--src/xfns.c2
-rw-r--r--src/xrdb.c4
-rw-r--r--src/xselect.c10
24 files changed, 101 insertions, 83 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6174d5cdec7..2b7ad802d79 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,33 @@
-2011-04-18 Paul Eggert <eggert@cs.ucla.edu>
+2011-04-19 Paul Eggert <eggert@cs.ucla.edu>
+
+ 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.
+ * 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.
+ (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,
diff --git a/src/alloc.c b/src/alloc.c
index f2aeaa938eb..423c1f167db 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4563,8 +4563,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);
}
diff --git a/src/bidi.c b/src/bidi.c
index 447abb48469..88c45e24a14 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -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);
}
diff --git a/src/charset.c b/src/charset.c
index c4699dcb0a7..9a7a56d9379 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -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];
diff --git a/src/coding.c b/src/coding.c
index b49070e5e16..38e41e7a99e 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -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));
}
diff --git a/src/data.c b/src/data.c
index c9250a67bf0..8ece1905243 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2374,12 +2374,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);
}
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 792414b23d8..4c0b9bd017a 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -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);
diff --git a/src/doc.c b/src/doc.c
index 354aff84979..74e06cce6b3 100644
--- 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;
diff --git a/src/fns.c b/src/fns.c
index c057f64469c..3771820753e 100644
--- 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);
}
diff --git a/src/font.c b/src/font.c
index 7fe0815d80e..2a8cf2e48a7 100644
--- a/src/font.c
+++ b/src/font.c
@@ -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)
diff --git a/src/intervals.c b/src/intervals.c
index 7ce1796d8eb..3e73110845d 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -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;
diff --git a/src/keyboard.c b/src/keyboard.c
index c601649ebca..b0ae1b1868d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.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
{
@@ -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);
}
diff --git a/src/lisp.h b/src/lisp.h
index 581835dd32b..893c00d5137 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -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
diff --git a/src/m/amdx86-64.h b/src/m/amdx86-64.h
index dbca9b5b838..50fcf8e7872 100644
--- a/src/m/amdx86-64.h
+++ b/src/m/amdx86-64.h
@@ -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 */
diff --git a/src/m/ia64.h b/src/m/ia64.h
index a1374d7c224..7a8866a9503 100644
--- a/src/m/ia64.h
+++ b/src/m/ia64.h
@@ -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
diff --git a/src/m/ibms390x.h b/src/m/ibms390x.h
index 14228b61e56..04092d6e1ac 100644
--- a/src/m/ibms390x.h
+++ b/src/m/ibms390x.h
@@ -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 */
diff --git a/src/print.c b/src/print.c
index 6a331cb11f2..d837a533818 100644
--- a/src/print.c
+++ b/src/print.c
@@ -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));
}
@@ -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=%08p 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);
diff --git a/src/process.c b/src/process.c
index d8851c56cf0..8fbd8ac92e2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -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
diff --git a/src/region-cache.c b/src/region-cache.c
index a0b85039e74..d701f4d71b0 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -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));
}
}
diff --git a/src/sysdep.c b/src/sysdep.c
index 45e80ac0155..a57b8c0382d 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -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);
diff --git a/src/xdisp.c b/src/xdisp.c
index eaab8dac18d..e6aa05b4973 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -19564,7 +19564,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;
}
}
@@ -19595,9 +19595,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;
}
}
diff --git a/src/xfns.c b/src/xfns.c
index 51aca3e9670..7a575150687 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -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;
}
diff --git a/src/xrdb.c b/src/xrdb.c
index b01e344edf2..b490afdabaa 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -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);
}
diff --git a/src/xselect.c b/src/xselect.c
index 2d656cfec9a..edf00226404 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -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 %08p", 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 %08p", 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 %08p", 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));