home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.816 < prev    next >
Encoding:
Internet Message Format  |  2013-02-12  |  12.2 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.816
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.816
  11. Problem:    Can't compute a hash.
  12. Solution:   Add the sha256() function. (Tyru, Hirohito Higashi)
  13. Files:        runtime/doc/eval.txt, src/eval.c, src/proto/sha256.pro,
  14.         src/sha256.c, src/testdir/test90.in, src/testdir/test90.ok,
  15.         src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
  16.         src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
  17.         src/testdir/Make_vms.mms, src/testdir/Makefile
  18.  
  19. *** ../vim-7.3.815/runtime/doc/eval.txt    2013-01-23 17:15:25.000000000 +0100
  20. --- runtime/doc/eval.txt    2013-02-13 17:32:52.000000000 +0100
  21. ***************
  22. *** 1920,1925 ****
  23. --- 1931,1937 ----
  24.   settabwinvar( {tabnr}, {winnr}, {varname}, {val})    set {varname} in window
  25.                       {winnr} in tab page {tabnr} to {val}
  26.   setwinvar( {nr}, {varname}, {val})    set {varname} in window {nr} to {val}
  27. + sha256( {string})        String    SHA256 checksum of {string}
  28.   shellescape( {string} [, {special}])
  29.                   String    escape {string} for use as shell
  30.                       command argument
  31. ***************
  32. *** 5312,5317 ****
  33. --- 5337,5347 ----
  34.               :call setwinvar(1, "&list", 0)
  35.               :call setwinvar(2, "myvar", "foobar")
  36.   
  37. + sha256({string})                        *sha256()*
  38. +         Returns a String with 64 hex charactes, which is the SHA256
  39. +         checksum of {string}.
  40. +         {only available when compiled with the |+cryptv| feature}
  41.   shellescape({string} [, {special}])            *shellescape()*
  42.           Escape {string} for use as a shell command argument.
  43.           On MS-Windows and MS-DOS, when 'shellslash' is not set, it
  44. *** ../vim-7.3.815/src/eval.c    2013-01-30 14:55:34.000000000 +0100
  45. --- src/eval.c    2013-02-13 17:24:40.000000000 +0100
  46. ***************
  47. *** 688,693 ****
  48. --- 688,696 ----
  49.   static void f_settabvar __ARGS((typval_T *argvars, typval_T *rettv));
  50.   static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
  51.   static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
  52. + #ifdef FEAT_CRYPT
  53. + static void f_sha256 __ARGS((typval_T *argvars, typval_T *rettv));
  54. + #endif /* FEAT_CRYPT */
  55.   static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
  56.   static void f_shiftwidth __ARGS((typval_T *argvars, typval_T *rettv));
  57.   static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
  58. ***************
  59. *** 8055,8060 ****
  60. --- 8058,8066 ----
  61.       {"settabvar",    3, 3, f_settabvar},
  62.       {"settabwinvar",    4, 4, f_settabwinvar},
  63.       {"setwinvar",    3, 3, f_setwinvar},
  64. + #ifdef FEAT_CRYPT
  65. +     {"sha256",        1, 1, f_sha256},
  66. + #endif
  67.       {"shellescape",    1, 2, f_shellescape},
  68.       {"shiftwidth",    0, 0, f_shiftwidth},
  69.       {"simplify",    1, 1, f_simplify},
  70. ***************
  71. *** 16710,16715 ****
  72. --- 16716,16739 ----
  73.       }
  74.   }
  75.   
  76. + #ifdef FEAT_CRYPT
  77. + /*
  78. +  * "sha256({string})" function
  79. +  */
  80. +     static void
  81. + f_sha256(argvars, rettv)
  82. +     typval_T    *argvars;
  83. +     typval_T    *rettv;
  84. + {
  85. +     char_u    *p;
  86. +     p = get_tv_string(&argvars[0]);
  87. +     rettv->vval.v_string = vim_strsave(
  88. +                     sha256_bytes(p, (int)STRLEN(p), NULL, 0));
  89. +     rettv->v_type = VAR_STRING;
  90. + }
  91. + #endif /* FEAT_CRYPT */
  92.   /*
  93.    * "shellescape({string})" function
  94.    */
  95. *** ../vim-7.3.815/src/proto/sha256.pro    2010-08-15 21:57:28.000000000 +0200
  96. --- src/proto/sha256.pro    2013-02-13 17:25:08.000000000 +0100
  97. ***************
  98. *** 2,7 ****
  99. --- 2,8 ----
  100.   void sha256_start __ARGS((context_sha256_T *ctx));
  101.   void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, UINT32_T length));
  102.   void sha256_finish __ARGS((context_sha256_T *ctx, char_u digest[32]));
  103. + char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
  104.   char_u *sha256_key __ARGS((char_u *buf, char_u *salt, int salt_len));
  105.   int sha256_self_test __ARGS((void));
  106.   void sha2_seed __ARGS((char_u *header, int header_len, char_u *salt, int salt_len));
  107. *** ../vim-7.3.815/src/sha256.c    2012-11-20 17:18:56.000000000 +0100
  108. --- src/sha256.c    2013-02-13 17:25:04.000000000 +0100
  109. ***************
  110. *** 273,286 ****
  111.   #endif /* FEAT_CRYPT || FEAT_PERSISTENT_UNDO */
  112.   
  113.   #if defined(FEAT_CRYPT) || defined(PROTO)
  114. - static char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
  115.   static unsigned int get_some_time __ARGS((void));
  116.   
  117.   /*
  118.    * Returns hex digest of "buf[buf_len]" in a static array.
  119.    * if "salt" is not NULL also do "salt[salt_len]".
  120.    */
  121. !     static char_u *
  122.   sha256_bytes(buf, buf_len, salt, salt_len)
  123.       char_u *buf;
  124.       int    buf_len;
  125. --- 273,285 ----
  126.   #endif /* FEAT_CRYPT || FEAT_PERSISTENT_UNDO */
  127.   
  128.   #if defined(FEAT_CRYPT) || defined(PROTO)
  129.   static unsigned int get_some_time __ARGS((void));
  130.   
  131.   /*
  132.    * Returns hex digest of "buf[buf_len]" in a static array.
  133.    * if "salt" is not NULL also do "salt[salt_len]".
  134.    */
  135. !     char_u *
  136.   sha256_bytes(buf, buf_len, salt, salt_len)
  137.       char_u *buf;
  138.       int    buf_len;
  139. *** ../vim-7.3.815/src/testdir/test90.in    2013-02-13 17:33:42.000000000 +0100
  140. --- src/testdir/test90.in    2013-02-13 17:20:13.000000000 +0100
  141. ***************
  142. *** 0 ****
  143. --- 1,53 ----
  144. + Tests for sha256() function.    vim: set ft=vim et ts=2 sw=2 :
  145. + STARTTEST
  146. + :so small.vim
  147. + :if !has('cryptv') || !exists('*sha256')
  148. +    e! test.ok
  149. +    wq! test.out
  150. + :endif
  151. + :"
  152. + :let testcase='test for empty string: '
  153. + :if sha256("") ==# 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
  154. + : let res='ok'
  155. + :else
  156. + : let res='ng'
  157. + :endif
  158. + :$put =testcase.res
  159. + :"
  160. + :let testcase='test for 1 char: '
  161. + :if sha256("a") ==# 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'
  162. + : let res='ok'
  163. + :else
  164. + : let res='ng'
  165. + :endif
  166. + :$put =testcase.res
  167. + :"
  168. + :let testcase='test for 3 chars: '
  169. + :if sha256("abc") ==# 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
  170. + : let res='ok'
  171. + :else
  172. + : let res='ng'
  173. + :endif
  174. + :$put =testcase.res
  175. + :"
  176. + :let testcase='test for contains meta char: '
  177. + :if sha256("foo\nbar") ==# '807eff6267f3f926a21d234f7b0cf867a86f47e07a532f15e8cc39ed110ca776'
  178. + : let res='ok'
  179. + :else
  180. + : let res='ng'
  181. + :endif
  182. + :$put =testcase.res
  183. + :"
  184. + :let testcase='test for contains non-ascii char: '
  185. + :if sha256("\xde\xad\xbe\xef") ==# '5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953'
  186. + : let res='ok'
  187. + :else
  188. + : let res='ng'
  189. + :endif
  190. + :$put =testcase.res
  191. + "
  192. + :/^start:/,$wq! test.out
  193. + ENDTEST
  194. + start:
  195. *** ../vim-7.3.815/src/testdir/test90.ok    2013-02-13 17:33:42.000000000 +0100
  196. --- src/testdir/test90.ok    2013-02-13 17:20:36.000000000 +0100
  197. ***************
  198. *** 0 ****
  199. --- 1,6 ----
  200. + start:
  201. + test for empty string: ok
  202. + test for 1 char: ok
  203. + test for 3 chars: ok
  204. + test for contains meta char: ok
  205. + test for contains non-ascii char: ok
  206. *** ../vim-7.3.815/src/testdir/Make_amiga.mak    2013-02-13 15:44:22.000000000 +0100
  207. --- src/testdir/Make_amiga.mak    2013-02-13 17:21:15.000000000 +0100
  208. ***************
  209. *** 32,38 ****
  210.           test71.out test72.out test73.out test74.out test75.out \
  211.           test76.out test77.out test78.out test79.out test80.out \
  212.           test81.out test82.out test83.out test84.out test88.out \
  213. !         test89.out
  214.   
  215.   .SUFFIXES: .in .out
  216.   
  217. --- 32,38 ----
  218.           test71.out test72.out test73.out test74.out test75.out \
  219.           test76.out test77.out test78.out test79.out test80.out \
  220.           test81.out test82.out test83.out test84.out test88.out \
  221. !         test89.out test90.out
  222.   
  223.   .SUFFIXES: .in .out
  224.   
  225. ***************
  226. *** 138,140 ****
  227. --- 138,141 ----
  228.   test84.out: test84.in
  229.   test88.out: test88.in
  230.   test89.out: test89.in
  231. + test90.out: test90.in
  232. *** ../vim-7.3.815/src/testdir/Make_dos.mak    2013-02-13 15:44:22.000000000 +0100
  233. --- src/testdir/Make_dos.mak    2013-02-13 17:21:22.000000000 +0100
  234. ***************
  235. *** 31,37 ****
  236.           test74.out test75.out test76.out test77.out test78.out \
  237.           test79.out test80.out test81.out test82.out test83.out \
  238.           test84.out test85.out test86.out test87.out test88.out \
  239. !         test89.out
  240.   
  241.   SCRIPTS32 =    test50.out test70.out
  242.   
  243. --- 31,37 ----
  244.           test74.out test75.out test76.out test77.out test78.out \
  245.           test79.out test80.out test81.out test82.out test83.out \
  246.           test84.out test85.out test86.out test87.out test88.out \
  247. !         test89.out test90.out
  248.   
  249.   SCRIPTS32 =    test50.out test70.out
  250.   
  251. *** ../vim-7.3.815/src/testdir/Make_ming.mak    2013-02-13 15:44:22.000000000 +0100
  252. --- src/testdir/Make_ming.mak    2013-02-13 17:21:24.000000000 +0100
  253. ***************
  254. *** 51,57 ****
  255.           test74.out test75.out test76.out test77.out test78.out \
  256.           test79.out test80.out test81.out test82.out test83.out \
  257.           test84.out test85.out test86.out test87.out test88.out \
  258. !         test89.out
  259.   
  260.   SCRIPTS32 =    test50.out test70.out
  261.   
  262. --- 51,57 ----
  263.           test74.out test75.out test76.out test77.out test78.out \
  264.           test79.out test80.out test81.out test82.out test83.out \
  265.           test84.out test85.out test86.out test87.out test88.out \
  266. !         test89.out test90.out
  267.   
  268.   SCRIPTS32 =    test50.out test70.out
  269.   
  270. *** ../vim-7.3.815/src/testdir/Make_os2.mak    2013-02-13 15:44:22.000000000 +0100
  271. --- src/testdir/Make_os2.mak    2013-02-13 17:21:27.000000000 +0100
  272. ***************
  273. *** 32,38 ****
  274.           test71.out test72.out test73.out test74.out test75.out \
  275.           test76.out test77.out test78.out test79.out test80.out \
  276.           test81.out test82.out test83.out test84.out test88.out \
  277. !         test89.out
  278.   
  279.   .SUFFIXES: .in .out
  280.   
  281. --- 32,38 ----
  282.           test71.out test72.out test73.out test74.out test75.out \
  283.           test76.out test77.out test78.out test79.out test80.out \
  284.           test81.out test82.out test83.out test84.out test88.out \
  285. !         test89.out test90.out
  286.   
  287.   .SUFFIXES: .in .out
  288.   
  289. *** ../vim-7.3.815/src/testdir/Make_vms.mms    2013-02-13 15:44:22.000000000 +0100
  290. --- src/testdir/Make_vms.mms    2013-02-13 17:21:32.000000000 +0100
  291. ***************
  292. *** 4,10 ****
  293.   # Authors:    Zoltan Arpadffy, <arpadffy@polarhome.com>
  294.   #        Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
  295.   #
  296. ! # Last change:  2012 Dec 05
  297.   #
  298.   # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
  299.   # Edit the lines in the Configuration section below to select.
  300. --- 4,10 ----
  301.   # Authors:    Zoltan Arpadffy, <arpadffy@polarhome.com>
  302.   #        Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
  303.   #
  304. ! # Last change:  2013 Feb 13
  305.   #
  306.   # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
  307.   # Edit the lines in the Configuration section below to select.
  308. ***************
  309. *** 76,82 ****
  310.        test66.out test67.out test68.out test69.out \
  311.        test71.out test72.out test74.out test75.out test76.out \
  312.        test77.out test78.out test79.out test80.out test81.out \
  313. !      test82.out test83.out test84.out test88.out test89.out
  314.   
  315.   # Known problems:
  316.   # Test 30: a problem around mac format - unknown reason
  317. --- 76,83 ----
  318.        test66.out test67.out test68.out test69.out \
  319.        test71.out test72.out test74.out test75.out test76.out \
  320.        test77.out test78.out test79.out test80.out test81.out \
  321. !      test82.out test83.out test84.out test88.out test89.out \
  322. !      test90.out
  323.   
  324.   # Known problems:
  325.   # Test 30: a problem around mac format - unknown reason
  326. *** ../vim-7.3.815/src/testdir/Makefile    2013-02-13 15:44:22.000000000 +0100
  327. --- src/testdir/Makefile    2013-02-13 17:20:58.000000000 +0100
  328. ***************
  329. *** 28,34 ****
  330.           test74.out test75.out test76.out test77.out test78.out \
  331.           test79.out test80.out test81.out test82.out test83.out \
  332.           test84.out test85.out test86.out test87.out test88.out \
  333. !         test89.out
  334.   
  335.   SCRIPTS_GUI = test16.out
  336.   
  337. --- 28,34 ----
  338.           test74.out test75.out test76.out test77.out test78.out \
  339.           test79.out test80.out test81.out test82.out test83.out \
  340.           test84.out test85.out test86.out test87.out test88.out \
  341. !         test89.out test90.out
  342.   
  343.   SCRIPTS_GUI = test16.out
  344.   
  345. *** ../vim-7.3.815/src/version.c    2013-02-13 17:06:06.000000000 +0100
  346. --- src/version.c    2013-02-13 17:33:04.000000000 +0100
  347. ***************
  348. *** 727,728 ****
  349. --- 727,730 ----
  350.   {   /* Add new patch number below this line */
  351. + /**/
  352. +     816,
  353.   /**/
  354.  
  355. -- 
  356.    Another bucket of what can only be described as human ordure hits ARTHUR.
  357. ARTHUR: ... Right!  (to the KNIGHTS) That settles it!
  358.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  359.  
  360.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  361. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  362. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  363.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  364.