changeset 2266:ae2e615a7320 vim73

Fix tiny build, move functions to undo.c.
author Bram Moolenaar <bram@vim.org>
date Mon, 14 Jun 2010 01:39:13 +0200
parents b7cb69ab616d
children c08f91142c41
files runtime/doc/todo.txt src/fileio.c src/proto/fileio.pro src/undo.c
diffstat 4 files changed, 63 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1088,19 +1088,19 @@ Vim 7.3:
 - using NSIS 2.46: install on Windows 7 works, but no "Edit with Vim" menu.
    Use register_shell_extension()? (George Reilly, 2010 May 26)
    Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
-- Update for crypt code to use salt. (Mohsin May 30)
-    Make the strengthen_key value 10000, equivalent to crypting 10 Kbyte of
-    text.
 - Also crypt the swap file, each block separately.  Change mf_write() and
     mf_read().
     - How to get b_p_key to these functions?  -> Store buf_T pointer in mfp.
-    - Generate a seed for the swapfile, put it in block 0.
+    - Generate a salt and seed for the swapfile, put it in block 0.
     - For each block, use password + seed + byte offset to crypt/decrypt.
     - When changing the password need to read back with the old password and
       write again with the new one.
     - Fill the gaps in the block with random bytes, otherwise it's easy to
       check for correct password by finding NUL bytes.
     - Verify recovery works.
+- Patch for conceal feature and 'foldcolumn'. (Dominique Pelle, 2010 Jun 10,
+  second patch)
+- patch for conceal feature and 'modifiable'. (Dominique Pelle, 2010 Jun 9)
 - undofile: keep markers where the file was written/read, so that it's easy to
   go back to a saved version of the file:  ":earlier 1f" (f for file)?
   Also add ":earlier 1d" (d for day).
@@ -1108,9 +1108,6 @@ Vim 7.3:
   Show "file saved" marker in :undolist
   Function to get undo tree: undotree().  List of lists.  Each entry is a
   dictionary: {'nr': 2, 'time': 1234, 'saved': 1}
-- Patch for conceal feature and 'foldcolumn'. (Dominique Pelle, 2010 Jun 10,
-  second patch)
-- patch for conceal feature and 'modifiable'. (Dominique Pelle, 2010 Jun 9)
 - Remove support for GTK 1?  Patch by James Vega, Jun 11.
 Patches to include:
 - Patch for Lisp support with ECL (Mikael Jansson, 2008 Oct 25)
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3011,63 +3011,6 @@ prepare_crypt_write(buf, lenp)
 
 #endif  /* FEAT_CRYPT */
 
-/*
- * Like fwrite() but crypt the bytes when 'key' is set.
- * Returns 1 if successful.
- */
-    size_t
-fwrite_crypt(buf, ptr, len, fp)
-    buf_T	*buf UNUSED;
-    char_u	*ptr;
-    size_t	len;
-    FILE	*fp;
-{
-#ifdef FEAT_CRYPT
-    char_u  *copy;
-    char_u  small_buf[100];
-    size_t  i;
-
-    if (*buf->b_p_key == NUL)
-	return fwrite(ptr, len, (size_t)1, fp);
-    if (len < 100)
-	copy = small_buf;  /* no malloc()/free() for short strings */
-    else
-    {
-	copy = lalloc(len, FALSE);
-	if (copy == NULL)
-	    return 0;
-    }
-    crypt_encode(ptr, len, copy);
-    i = fwrite(copy, len, (size_t)1, fp);
-    if (copy != small_buf)
-	vim_free(copy);
-    return i;
-#else
-    return fwrite(ptr, len, (size_t)1, fp);
-#endif
-}
-
-/*
- * Read a string of length "len" from "fd".
- * When 'key' is set decrypt the bytes.
- */
-    char_u *
-read_string_decrypt(buf, fd, len)
-    buf_T   *buf UNUSED;
-    FILE    *fd;
-    int	    len;
-{
-    char_u  *ptr;
-
-    ptr = read_string(fd, len);
-#ifdef FEAT_CRYPT
-    if (ptr != NULL || *buf->b_p_key != NUL)
-	crypt_decode(ptr, len);
-#endif
-    return ptr;
-}
-
-
 #ifdef UNIX
     static void
 set_file_time(fname, atime, mtime)
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -4,8 +4,6 @@ int readfile __ARGS((char_u *fname, char
 int prep_exarg __ARGS((exarg_T *eap, buf_T *buf));
 int prepare_crypt_read __ARGS((FILE *fp));
 char_u *prepare_crypt_write __ARGS((buf_T *buf, int *lenp));
-size_t fwrite_crypt __ARGS((buf_T *buf, char_u *ptr, size_t len, FILE *fp));
-char_u *read_string_decrypt __ARGS((buf_T *buf, FILE *fd, int len));
 int check_file_readonly __ARGS((char_u *fname, int perm));
 int buf_write __ARGS((buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering));
 void msg_add_fname __ARGS((buf_T *buf, char_u *fname));
--- a/src/undo.c
+++ b/src/undo.c
@@ -102,6 +102,8 @@ static void u_freeentry __ARGS((u_entry_
 #ifdef FEAT_PERSISTENT_UNDO
 static void corruption_error __ARGS((char *msg, char_u *file_name));
 static void u_free_uhp __ARGS((u_header_T *uhp));
+static size_t fwrite_crypt __ARGS((buf_T *buf UNUSED, char_u *ptr, size_t len, FILE *fp));
+static char_u *read_string_decrypt __ARGS((buf_T *buf UNUSED, FILE *fd, int len));
 static int serialize_header __ARGS((FILE *fp, buf_T *buf, char_u *hash));
 static int serialize_uhp __ARGS((FILE *fp, buf_T *buf, u_header_T *uhp));
 static u_header_T *unserialize_uhp __ARGS((FILE *fp, char_u *file_name));
@@ -661,7 +663,7 @@ nomem:
     return FAIL;
 }
 
-#ifdef FEAT_PERSISTENT_UNDO
+#if defined(FEAT_PERSISTENT_UNDO) || defined(PROTO)
 
 # define UF_START_MAGIC	    "Vim\237UnDo\345"  /* magic at start of undofile */
 # define UF_START_MAGIC_LEN	9
@@ -801,6 +803,62 @@ u_free_uhp(uhp)
     vim_free(uhp);
 }
 
+/*
+ * Like fwrite() but crypt the bytes when 'key' is set.
+ * Returns 1 if successful.
+ */
+    static size_t
+fwrite_crypt(buf, ptr, len, fp)
+    buf_T	*buf UNUSED;
+    char_u	*ptr;
+    size_t	len;
+    FILE	*fp;
+{
+#ifdef FEAT_CRYPT
+    char_u  *copy;
+    char_u  small_buf[100];
+    size_t  i;
+
+    if (*buf->b_p_key == NUL)
+	return fwrite(ptr, len, (size_t)1, fp);
+    if (len < 100)
+	copy = small_buf;  /* no malloc()/free() for short strings */
+    else
+    {
+	copy = lalloc(len, FALSE);
+	if (copy == NULL)
+	    return 0;
+    }
+    crypt_encode(ptr, len, copy);
+    i = fwrite(copy, len, (size_t)1, fp);
+    if (copy != small_buf)
+	vim_free(copy);
+    return i;
+#else
+    return fwrite(ptr, len, (size_t)1, fp);
+#endif
+}
+
+/*
+ * Read a string of length "len" from "fd".
+ * When 'key' is set decrypt the bytes.
+ */
+    static char_u *
+read_string_decrypt(buf, fd, len)
+    buf_T   *buf UNUSED;
+    FILE    *fd;
+    int	    len;
+{
+    char_u  *ptr;
+
+    ptr = read_string(fd, len);
+#ifdef FEAT_CRYPT
+    if (ptr != NULL || *buf->b_p_key != NUL)
+	crypt_decode(ptr, len);
+#endif
+    return ptr;
+}
+
     static int
 serialize_header(fp, buf, hash)
     FILE	*fp;