comparison src/crypt.c @ 29320:a74398c432a4 v9.0.0003

patch 9.0.0003: functions are global while they could be local Commit: https://github.com/vim/vim/commit/ee47eaceaa148e07b566ff420f9a3c2edde2fa34 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jun 29 12:55:36 2022 +0100 patch 9.0.0003: functions are global while they could be local Problem: Functions are global while they could be local. Solution: Add "static". Add a few tests. (Yegappan Lakshmanan, closes #10612)
author Bram Moolenaar <Bram@vim.org>
date Wed, 29 Jun 2022 14:00:03 +0200
parents d0241e74bfdb
children 540e85ac14c9
comparison
equal deleted inserted replaced
29319:0f3ce048146b 29320:a74398c432a4
70 void (*encode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len, 70 void (*encode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len,
71 char_u *p2, int last); 71 char_u *p2, int last);
72 void (*decode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len, 72 void (*decode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len,
73 char_u *p2, int last); 73 char_u *p2, int last);
74 } cryptmethod_T; 74 } cryptmethod_T;
75
76 static int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len);
77 static long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
78 static long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
75 79
76 // index is method_nr of cryptstate_T, CRYPT_M_* 80 // index is method_nr of cryptstate_T, CRYPT_M_*
77 static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = { 81 static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
78 // PK_Zip; very weak 82 // PK_Zip; very weak
79 { 83 {
848 STRCAT(IObuff, *buf->b_p_cm == NUL ? p_cm : buf->b_p_cm); 852 STRCAT(IObuff, *buf->b_p_cm == NUL ? p_cm : buf->b_p_cm);
849 STRCAT(IObuff, "]"); 853 STRCAT(IObuff, "]");
850 } 854 }
851 } 855 }
852 856
853 int 857 static int
854 crypt_sodium_init( 858 crypt_sodium_init(
855 cryptstate_T *state UNUSED, 859 cryptstate_T *state UNUSED,
856 char_u *key UNUSED, 860 char_u *key UNUSED,
857 char_u *salt UNUSED, 861 char_u *salt UNUSED,
858 int salt_len UNUSED, 862 int salt_len UNUSED,
1028 1032
1029 /* 1033 /*
1030 * Encrypt "from[len]" into "to[len]". 1034 * Encrypt "from[len]" into "to[len]".
1031 * "from" and "to" can be equal to encrypt in place. 1035 * "from" and "to" can be equal to encrypt in place.
1032 */ 1036 */
1033 long 1037 static long
1034 crypt_sodium_buffer_encode( 1038 crypt_sodium_buffer_encode(
1035 cryptstate_T *state UNUSED, 1039 cryptstate_T *state UNUSED,
1036 char_u *from UNUSED, 1040 char_u *from UNUSED,
1037 size_t len UNUSED, 1041 size_t len UNUSED,
1038 char_u **buf_out UNUSED, 1042 char_u **buf_out UNUSED,
1078 1082
1079 /* 1083 /*
1080 * Decrypt "from[len]" into "to[len]". 1084 * Decrypt "from[len]" into "to[len]".
1081 * "from" and "to" can be equal to encrypt in place. 1085 * "from" and "to" can be equal to encrypt in place.
1082 */ 1086 */
1083 long 1087 static long
1084 crypt_sodium_buffer_decode( 1088 crypt_sodium_buffer_decode(
1085 cryptstate_T *state UNUSED, 1089 cryptstate_T *state UNUSED,
1086 char_u *from UNUSED, 1090 char_u *from UNUSED,
1087 size_t len UNUSED, 1091 size_t len UNUSED,
1088 char_u **buf_out UNUSED, 1092 char_u **buf_out UNUSED,