[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 26fde48: Shorten pointer printing code using a small helper funct
From: |
Philipp Stephani |
Subject: |
master 26fde48: Shorten pointer printing code using a small helper function. |
Date: |
Sun, 5 Jan 2020 11:12:37 -0500 (EST) |
branch: master
commit 26fde487cb3740cdc678e76c62f1320d47b4d6f5
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Shorten pointer printing code using a small helper function.
* src/print.c (print_pointer): New helper function.
(print_vectorlike): Use it.
---
src/print.c | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/print.c b/src/print.c
index b373aaf..634169d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1365,6 +1365,22 @@ data_from_funcptr (void (*funcptr) (void))
interchangeably, so it's OK to assume that here too. */
return (void const *) funcptr;
}
+
+/* Print the value of the pointer PTR. */
+
+static void
+print_pointer (Lisp_Object printcharfun, char *buf, const char *prefix,
+ const void *ptr)
+{
+ uintptr_t ui = (uintptr_t) ptr;
+
+ /* In theory this assignment could lose info on pre-C99 hosts, but
+ in practice it doesn't. */
+ uintmax_t up = ui;
+
+ int len = sprintf (buf, "%s 0x%" PRIxMAX, prefix, up);
+ strout (buf, len, len, printcharfun);
+}
#endif
static bool
@@ -1803,33 +1819,15 @@ print_vectorlike (Lisp_Object obj, Lisp_Object
printcharfun, bool escapeflag,
dynlib_addr (ptr, &file, &symbol);
if (symbol == NULL)
- {
- uintptr_t ui = (uintptr_t) data_from_funcptr (ptr);
-
- /* In theory this assignment could lose info on pre-C99
- hosts, but in practice it doesn't. */
- uintmax_t up = ui;
-
- int len = sprintf (buf, "at 0x%"PRIxMAX, up);
- strout (buf, len, len, printcharfun);
- }
- else
+ print_pointer (printcharfun, buf, "at", data_from_funcptr (ptr));
+ else
print_c_string (symbol, printcharfun);
void *data = module_function_data (function);
if (data != NULL)
- {
- uintptr_t ui = (uintptr_t) data;
-
- /* In theory this assignment could lose info on pre-C99
- hosts, but in practice it doesn't. */
- uintmax_t up = ui;
-
- int len = sprintf (buf, " with data 0x%"PRIxMAX, up);
- strout (buf, len, len, printcharfun);
- }
+ print_pointer (printcharfun, buf, " with data", data);
- if (file != NULL)
+ if (file != NULL)
{
print_c_string (" from ", printcharfun);
print_c_string (file, printcharfun);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 26fde48: Shorten pointer printing code using a small helper function.,
Philipp Stephani <=