Shorten pointer printing code using a small helper function.
* src/print.c (print_pointer): New helper function. (print_vectorlike): Use it.
This commit is contained in:
parent
fc92c2d894
commit
26fde487cb
1 changed files with 20 additions and 22 deletions
38
src/print.c
38
src/print.c
|
@ -1365,6 +1365,22 @@ data_from_funcptr (void (*funcptr) (void))
|
||||||
interchangeably, so it's OK to assume that here too. */
|
interchangeably, so it's OK to assume that here too. */
|
||||||
return (void const *) funcptr;
|
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
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -1803,31 +1819,13 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
|
||||||
dynlib_addr (ptr, &file, &symbol);
|
dynlib_addr (ptr, &file, &symbol);
|
||||||
|
|
||||||
if (symbol == NULL)
|
if (symbol == NULL)
|
||||||
{
|
print_pointer (printcharfun, buf, "at", data_from_funcptr (ptr));
|
||||||
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
|
else
|
||||||
print_c_string (symbol, printcharfun);
|
print_c_string (symbol, printcharfun);
|
||||||
|
|
||||||
void *data = module_function_data (function);
|
void *data = module_function_data (function);
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
print_pointer (printcharfun, buf, " with data", data);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue