diff options
| author | Paul Eggert | 2011-04-18 17:34:42 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-04-18 17:34:42 -0700 |
| commit | c2982e87d382f0b5c00a65e63716c2b43d342881 (patch) | |
| tree | b8f155c52150e3cc85a26299812d139efd86231e /src/font.c | |
| parent | 5e073ec7384c432e42a8affeeb6d6906588f2af9 (diff) | |
| download | emacs-c2982e87d382f0b5c00a65e63716c2b43d342881.tar.gz emacs-c2982e87d382f0b5c00a65e63716c2b43d342881.zip | |
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.
Diffstat (limited to 'src/font.c')
| -rw-r--r-- | src/font.c | 15 |
1 files changed, 7 insertions, 8 deletions
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) | |||
| 1271 | f[XLFD_SPACING_INDEX] = "*", len += 2; | 1271 | f[XLFD_SPACING_INDEX] = "*", len += 2; |
| 1272 | if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | 1272 | if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) |
| 1273 | { | 1273 | { |
| 1274 | f[XLFD_AVGWIDTH_INDEX] = p = alloca (11); | 1274 | f[XLFD_AVGWIDTH_INDEX] = p = alloca (22); |
| 1275 | len += sprintf (p, "%ld", | 1275 | len += sprintf (p, "%"pI"d", |
| 1276 | (long) XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; | 1276 | XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; |
| 1277 | } | 1277 | } |
| 1278 | else | 1278 | else |
| 1279 | f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; | 1279 | f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; |
| @@ -1598,7 +1598,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) | |||
| 1598 | } | 1598 | } |
| 1599 | 1599 | ||
| 1600 | if (INTEGERP (AREF (font, FONT_DPI_INDEX))) | 1600 | if (INTEGERP (AREF (font, FONT_DPI_INDEX))) |
| 1601 | len += sprintf (work, ":dpi=%ld", (long)XINT (AREF (font, FONT_DPI_INDEX))); | 1601 | len += sprintf (work, ":dpi=%"pI"d", XINT (AREF (font, FONT_DPI_INDEX))); |
| 1602 | if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | 1602 | if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) |
| 1603 | len += strlen (":spacing=100"); | 1603 | len += strlen (":spacing=100"); |
| 1604 | if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | 1604 | if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) |
| @@ -1611,7 +1611,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) | |||
| 1611 | if (STRINGP (value)) | 1611 | if (STRINGP (value)) |
| 1612 | len += SBYTES (value); | 1612 | len += SBYTES (value); |
| 1613 | else if (INTEGERP (value)) | 1613 | else if (INTEGERP (value)) |
| 1614 | len += sprintf (work, "%ld", (long) XINT (value)); | 1614 | len += sprintf (work, "%"pI"d", XINT (value)); |
| 1615 | else if (SYMBOLP (value)) | 1615 | else if (SYMBOLP (value)) |
| 1616 | len += (NILP (value) ? 5 : 4); /* for "false" or "true" */ | 1616 | len += (NILP (value) ? 5 : 4); /* for "false" or "true" */ |
| 1617 | } | 1617 | } |
| @@ -1638,10 +1638,9 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) | |||
| 1638 | p += sprintf (p, ":%s=%s", style_names[i], | 1638 | p += sprintf (p, ":%s=%s", style_names[i], |
| 1639 | SDATA (SYMBOL_NAME (styles[i]))); | 1639 | SDATA (SYMBOL_NAME (styles[i]))); |
| 1640 | if (INTEGERP (AREF (font, FONT_DPI_INDEX))) | 1640 | if (INTEGERP (AREF (font, FONT_DPI_INDEX))) |
| 1641 | p += sprintf (p, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX))); | 1641 | p += sprintf (p, ":dpi=%"pI"d", XINT (AREF (font, FONT_DPI_INDEX))); |
| 1642 | if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | 1642 | if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) |
| 1643 | p += sprintf (p, ":spacing=%ld", | 1643 | p += sprintf (p, ":spacing=%"pI"d", XINT (AREF (font, FONT_SPACING_INDEX))); |
| 1644 | (long) XINT (AREF (font, FONT_SPACING_INDEX))); | ||
| 1645 | if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | 1644 | if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) |
| 1646 | { | 1645 | { |
| 1647 | if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) | 1646 | if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) |