On 2011-06-12 00:02 +0800, Paul Eggert wrote: > On 06/11/11 08:24, Eli Zaretskii wrote: > >> Like this: >> >> (sha2 OBJECT &optional BEG END BINARY ALGORITHM) >> >> where ALGORITHM can be sha-224, sha-256, etc. >> >> (We could have ALGORITHM the 3rd argument, if keeping a signature >> compatible with sha1 is not important.) > > Or better yet: > > (crypto-hash-function ALGORITHM OBJECT > &optional START END NOERROR BINARY) crypto-hash-function is very long to type. How about export this to elisp: (sha OBJECT &optional START END BINARY ALGORITHM) where ALGORITHM can be 1 (default), 224, 256, 384, 512, and make sha1 obsolete? In a sense we unify all SHA functions and leave MD5 as is. Please review the attached patch. Thank you. > as was discussed in > and the ensuing thread. The above suggestion removes > the previously-proposed CODING-SYSTEM argument that Stefan > didn't think was needed, which means that people who want > md5's CODING-SYSTEM feature would have to invoke the md5 > function directly. > > The advantage of this approach is that we don't pollute > the Lisp namespace with one function name per algorithm. > > Some other comments: Many thanks for the comments. > Please modify GNULIB_MODULES in Makefile.in to reflect > the new dependencies. This was done in the original patch, no? > No need to use EMACS_UINT for digest_size. Please use > plain 'int'. We prefer to not use unsigned types due > to problems when they're used in comparisons. fixed. > No need to use sizeof (char). It is always 1. I get rid of xmalloc as suggested. > Please write "F (ARGS)" rather than "F(ARGS)". Hopefully fixed. > When creating the digest the code should use make_unibyte_string > rather than make_string. (This comment applies > also to the original.) > > Please don't cast function pointers to void * and back, as > that defeats the purpose of the C type checking. Instead, > just use the unvarnished C types. fixed. On 2011-06-12 08:34 +0800, YAMAMOTO Mitsuharu wrote: [snipped 6 lines] > And perhaps I would allocate a Lisp string with make_uninit_string and > then store the result directly into its contents rather than xmalloc - > make_unibyte_string - xfree, if the size is known in advance. Thanks. Leo