aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.c
diff options
context:
space:
mode:
authorPaul Eggert2019-07-13 10:41:46 -0700
committerPaul Eggert2019-07-13 16:53:21 -0700
commit1178f98f2c0973dd1f8a66cbb4de20c0d7af3271 (patch)
tree0d85660fe6133895571ac48b6f1403cd8cdd58d9 /src/fns.c
parenta8ffbb20da67b20a85ddca38e20c609144c3bef3 (diff)
downloademacs-1178f98f2c0973dd1f8a66cbb4de20c0d7af3271.tar.gz
emacs-1178f98f2c0973dd1f8a66cbb4de20c0d7af3271.zip
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.c19
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. */)
5040#include "sha256.h" 5040#include "sha256.h"
5041#include "sha512.h" 5041#include "sha512.h"
5042 5042
5043static Lisp_Object 5043/* Store into HEXBUF an unterminated hexadecimal character string
5044make_digest_string (Lisp_Object digest, int digest_size) 5044 representing DIGEST, which is binary data of size DIGEST_SIZE bytes.
5045 HEXBUF might equal DIGEST. */
5046void
5047hexbuf_digest (char *hexbuf, void const *digest, int digest_size)
5045{ 5048{
5046 unsigned char *p = SDATA (digest); 5049 unsigned char const *p = digest;
5047 5050
5048 for (int i = digest_size - 1; i >= 0; i--) 5051 for (int i = digest_size - 1; i >= 0; i--)
5049 { 5052 {
5050 static char const hexdigit[16] = "0123456789abcdef"; 5053 static char const hexdigit[16] = "0123456789abcdef";
5051 int p_i = p[i]; 5054 int p_i = p[i];
5052 p[2 * i] = hexdigit[p_i >> 4]; 5055 hexbuf[2 * i] = hexdigit[p_i >> 4];
5053 p[2 * i + 1] = hexdigit[p_i & 0xf]; 5056 hexbuf[2 * i + 1] = hexdigit[p_i & 0xf];
5054 } 5057 }
5058}
5059
5060static Lisp_Object
5061make_digest_string (Lisp_Object digest, int digest_size)
5062{
5063 hexbuf_digest (SSDATA (digest), SDATA (digest), digest_size);
5055 return digest; 5064 return digest;
5056} 5065}
5057 5066