From 1178f98f2c0973dd1f8a66cbb4de20c0d7af3271 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 13 Jul 2019 10:41:46 -0700 Subject: Avoid interleaving stderr in dump_fingerprint * src/fns.c (hexbuf_digest): New function, containing most of the old make_digest_string. (make_digest_string): Use it. * src/pdumper.c (dump_fingerprint): Rewrite to use a single fprintf call, to avoid interleaving on GNU/Linux. --- src/fns.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/fns.c') diff --git a/src/fns.c b/src/fns.c index 6a7c3477282..54dafe07ac8 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5040,18 +5040,27 @@ returns nil, then (funcall TEST x1 x2) also returns nil. */) #include "sha256.h" #include "sha512.h" -static Lisp_Object -make_digest_string (Lisp_Object digest, int digest_size) +/* Store into HEXBUF an unterminated hexadecimal character string + representing DIGEST, which is binary data of size DIGEST_SIZE bytes. + HEXBUF might equal DIGEST. */ +void +hexbuf_digest (char *hexbuf, void const *digest, int digest_size) { - unsigned char *p = SDATA (digest); + unsigned char const *p = digest; for (int i = digest_size - 1; i >= 0; i--) { static char const hexdigit[16] = "0123456789abcdef"; int p_i = p[i]; - p[2 * i] = hexdigit[p_i >> 4]; - p[2 * i + 1] = hexdigit[p_i & 0xf]; + hexbuf[2 * i] = hexdigit[p_i >> 4]; + hexbuf[2 * i + 1] = hexdigit[p_i & 0xf]; } +} + +static Lisp_Object +make_digest_string (Lisp_Object digest, int digest_size) +{ + hexbuf_digest (SSDATA (digest), SDATA (digest), digest_size); return digest; } -- cgit v1.2.1