connection, client: Avoid locale-dependent float printing

Specifically, in the log formed when WAYLAND_DEBUG is set, this commit
ensures that floating point numbers are formatted using '.' instead of
the locale-specific decimal separator. As the debug logs are not
otherwise localized for end-users, and may be parsed by scripts, it is
better to have consistent output here.

The 24.8 fixed point numbers are now represented with 8 digits after
the decimal, since this is both exact and simpler to compute.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
This commit is contained in:
Manuel Stoeckl 2021-01-17 18:02:50 -05:00 committed by Daniel Stone
parent 91d98b622f
commit 2f05ceeb4d
2 changed files with 15 additions and 6 deletions

View file

@ -1381,9 +1381,9 @@ queue_event(struct wl_display *display, int len)
clock_gettime(CLOCK_REALTIME, &tp);
time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
fprintf(stderr, "[%10.3f] discarded [%s]@%d.[event %d]"
fprintf(stderr, "[%7u.%03u] discarded [%s]@%d.[event %d]"
"(%d fd, %d byte)\n",
time / 1000.0,
time / 1000, time % 1000,
zombie ? "zombie" : "unknown",
id, opcode,
num_zombie_fds, size);