aboutsummaryrefslogtreecommitdiffstats
path: root/src/connection.c
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2021-01-17 18:02:50 -0500
committerDaniel Stone <daniels@collabora.com>2021-07-31 16:49:54 +0000
commit2f05ceeb4de665c306d01a295b7f30659f8cae96 (patch)
treeb987e5273df7d100ac9d9c275570e6999c663cfd /src/connection.c
parentos-wrappers-test: Make syscall intercepts work with sanitizers (diff)
downloadwayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.tar
wayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.tar.gz
wayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.tar.bz2
wayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.tar.lz
wayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.tar.xz
wayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.tar.zst
wayland-2f05ceeb4de665c306d01a295b7f30659f8cae96.zip
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>
Diffstat (limited to 'src/connection.c')
-rw-r--r--src/connection.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/connection.c b/src/connection.c
index 91d00c5..fc2c7c2 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1275,8 +1275,8 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target,
clock_gettime(CLOCK_REALTIME, &tp);
time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
- fprintf(stderr, "[%10.3f] %s%s%s@%u.%s(",
- time / 1000.0,
+ fprintf(stderr, "[%7u.%03u] %s%s%s@%u.%s(",
+ time / 1000, time % 1000,
discarded ? "discarded " : "",
send ? " -> " : "",
target->interface->name, target->id,
@@ -1295,8 +1295,17 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target,
fprintf(stderr, "%d", closure->args[i].i);
break;
case 'f':
- fprintf(stderr, "%f",
- wl_fixed_to_double(closure->args[i].f));
+ /* The magic number 390625 is 1e8 / 256 */
+ if (closure->args[i].f >= 0) {
+ fprintf(stderr, "%d.%08d",
+ closure->args[i].f / 256,
+ 390625 * (closure->args[i].f % 256));
+ } else {
+
+ fprintf(stderr, "-%d.%08d",
+ closure->args[i].f / -256,
+ -390625 * (closure->args[i].f % 256));
+ }
break;
case 's':
if (closure->args[i].s)