diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-07-13 10:41:46 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-07-13 16:53:21 -0700 |
commit | 1178f98f2c0973dd1f8a66cbb4de20c0d7af3271 (patch) | |
tree | 0d85660fe6133895571ac48b6f1403cd8cdd58d9 /src/fns.c | |
parent | a8ffbb20da67b20a85ddca38e20c609144c3bef3 (diff) | |
download | emacs-1178f98f2c0973dd1f8a66cbb4de20c0d7af3271.tar.gz |
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.
Diffstat (limited to 'src/fns.c')
-rw-r--r-- | src/fns.c | 19 |
1 files changed, 14 insertions, 5 deletions
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; } |