Skip to content

Commit

Permalink
updated for version 7.3.816
Browse files Browse the repository at this point in the history
Problem:    Can't compute a hash.
Solution:   Add the sha256() function. (Tyru, Hirohito Higashi)
  • Loading branch information
brammool committed Feb 13, 2013
1 parent d7c5fc2 commit 36a614b
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 9 deletions.
6 changes: 6 additions & 0 deletions runtime/doc/eval.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,7 @@ settabvar( {nr}, {varname}, {val}) set {varname} in tab page {nr} to {val}
settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window
{winnr} in tab page {tabnr} to {val}
setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val}
sha256( {string}) String SHA256 checksum of {string}
shellescape( {string} [, {special}])
String escape {string} for use as shell
command argument
Expand Down Expand Up @@ -5336,6 +5337,11 @@ setwinvar({nr}, {varname}, {val}) *setwinvar()*
:call setwinvar(1, "&list", 0)
:call setwinvar(2, "myvar", "foobar")
sha256({string}) *sha256()*
Returns a String with 64 hex charactes, which is the SHA256
checksum of {string}.
{only available when compiled with the |+cryptv| feature}

shellescape({string} [, {special}]) *shellescape()*
Escape {string} for use as a shell command argument.
On MS-Windows and MS-DOS, when 'shellslash' is not set, it
Expand Down
24 changes: 24 additions & 0 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,9 @@ static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
static void f_settabvar __ARGS((typval_T *argvars, typval_T *rettv));
static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_CRYPT
static void f_sha256 __ARGS((typval_T *argvars, typval_T *rettv));
#endif /* FEAT_CRYPT */
static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
static void f_shiftwidth __ARGS((typval_T *argvars, typval_T *rettv));
static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
Expand Down Expand Up @@ -8055,6 +8058,9 @@ static struct fst
{"settabvar", 3, 3, f_settabvar},
{"settabwinvar", 4, 4, f_settabwinvar},
{"setwinvar", 3, 3, f_setwinvar},
#ifdef FEAT_CRYPT
{"sha256", 1, 1, f_sha256},
#endif
{"shellescape", 1, 2, f_shellescape},
{"shiftwidth", 0, 0, f_shiftwidth},
{"simplify", 1, 1, f_simplify},
Expand Down Expand Up @@ -16710,6 +16716,24 @@ setwinvar(argvars, rettv, off)
}
}

#ifdef FEAT_CRYPT
/*
* "sha256({string})" function
*/
static void
f_sha256(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
char_u *p;

p = get_tv_string(&argvars[0]);
rettv->vval.v_string = vim_strsave(
sha256_bytes(p, (int)STRLEN(p), NULL, 0));
rettv->v_type = VAR_STRING;
}
#endif /* FEAT_CRYPT */

/*
* "shellescape({string})" function
*/
Expand Down
1 change: 1 addition & 0 deletions src/proto/sha256.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
void sha256_start __ARGS((context_sha256_T *ctx));
void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, UINT32_T length));
void sha256_finish __ARGS((context_sha256_T *ctx, char_u digest[32]));
char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
char_u *sha256_key __ARGS((char_u *buf, char_u *salt, int salt_len));
int sha256_self_test __ARGS((void));
void sha2_seed __ARGS((char_u *header, int header_len, char_u *salt, int salt_len));
Expand Down
3 changes: 1 addition & 2 deletions src/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,13 @@ sha256_finish(ctx, digest)
#endif /* FEAT_CRYPT || FEAT_PERSISTENT_UNDO */

#if defined(FEAT_CRYPT) || defined(PROTO)
static char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
static unsigned int get_some_time __ARGS((void));

/*
* Returns hex digest of "buf[buf_len]" in a static array.
* if "salt" is not NULL also do "salt[salt_len]".
*/
static char_u *
char_u *
sha256_bytes(buf, buf_len, salt, salt_len)
char_u *buf;
int buf_len;
Expand Down
3 changes: 2 additions & 1 deletion src/testdir/Make_amiga.mak
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test71.out test72.out test73.out test74.out test75.out \
test76.out test77.out test78.out test79.out test80.out \
test81.out test82.out test83.out test84.out test88.out \
test89.out
test89.out test90.out

.SUFFIXES: .in .out

Expand Down Expand Up @@ -138,3 +138,4 @@ test83.out: test83.in
test84.out: test84.in
test88.out: test88.in
test89.out: test89.in
test90.out: test90.in
2 changes: 1 addition & 1 deletion src/testdir/Make_dos.mak
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test74.out test75.out test76.out test77.out test78.out \
test79.out test80.out test81.out test82.out test83.out \
test84.out test85.out test86.out test87.out test88.out \
test89.out
test89.out test90.out

SCRIPTS32 = test50.out test70.out

Expand Down
2 changes: 1 addition & 1 deletion src/testdir/Make_ming.mak
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test74.out test75.out test76.out test77.out test78.out \
test79.out test80.out test81.out test82.out test83.out \
test84.out test85.out test86.out test87.out test88.out \
test89.out
test89.out test90.out

SCRIPTS32 = test50.out test70.out

Expand Down
2 changes: 1 addition & 1 deletion src/testdir/Make_os2.mak
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test71.out test72.out test73.out test74.out test75.out \
test76.out test77.out test78.out test79.out test80.out \
test81.out test82.out test83.out test84.out test88.out \
test89.out
test89.out test90.out

.SUFFIXES: .in .out

Expand Down
5 changes: 3 additions & 2 deletions src/testdir/Make_vms.mms
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
# Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
#
# Last change: 2012 Dec 05
# Last change: 2013 Feb 13
#
# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
# Edit the lines in the Configuration section below to select.
Expand Down Expand Up @@ -76,7 +76,8 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
test66.out test67.out test68.out test69.out \
test71.out test72.out test74.out test75.out test76.out \
test77.out test78.out test79.out test80.out test81.out \
test82.out test83.out test84.out test88.out test89.out
test82.out test83.out test84.out test88.out test89.out \
test90.out

# Known problems:
# Test 30: a problem around mac format - unknown reason
Expand Down
2 changes: 1 addition & 1 deletion src/testdir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test74.out test75.out test76.out test77.out test78.out \
test79.out test80.out test81.out test82.out test83.out \
test84.out test85.out test86.out test87.out test88.out \
test89.out
test89.out test90.out

SCRIPTS_GUI = test16.out

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
816,
/**/
815,
/**/
Expand Down

0 comments on commit 36a614b

Please sign in to comment.