diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-07-25 17:44:23 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-07-25 17:44:23 -0400 |
commit | 9550beda61ea74a2a9738e9c10423fa817b7b897 (patch) | |
tree | 8975561b90ab99f1349ffd1eae06173e1e4e7f71 /src/nvim/eval.c | |
parent | 4dadadd0015b6efb31869cca52d6bae36762c36e (diff) | |
parent | 7b1d46f39d9a21b77931b857d28a2a2fe7b284d0 (diff) | |
download | rneovim-9550beda61ea74a2a9738e9c10423fa817b7b897.tar.gz rneovim-9550beda61ea74a2a9738e9c10423fa817b7b897.tar.bz2 rneovim-9550beda61ea74a2a9738e9c10423fa817b7b897.zip |
Merge pull request #975 from aktau/remove-gettimeofday
remove gettimeofday() usage
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 77f327c124..069715ffee 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6490,6 +6490,7 @@ static struct fst { {"settabvar", 3, 3, f_settabvar}, {"settabwinvar", 4, 4, f_settabwinvar}, {"setwinvar", 3, 3, f_setwinvar}, + {"sha256", 1, 1, f_sha256}, {"shellescape", 1, 2, f_shellescape}, {"shiftwidth", 0, 0, f_shiftwidth}, {"simplify", 1, 1, f_simplify}, @@ -13102,6 +13103,17 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off) } } +/// f_sha256 - sha256({string}) function +static void f_sha256(typval_T *argvars, typval_T *rettv) +{ + char_u *p = get_tv_string(&argvars[0]); + const char_u *hash = sha256_bytes(p, (int) STRLEN(p) , NULL, 0); + + // make a copy of the hash (sha256_bytes returns a static buffer) + rettv->vval.v_string = (char_u *) xstrdup((char *) hash); + rettv->v_type = VAR_STRING; +} + /* * "shellescape({string})" function */ |