changeset 2563:5769dc787ec5 vim73

Fix: in compatible mode, in an empty buffer, ":r file" triggered an error message.
author Bram Moolenaar <bram@vim.org>
date Sat, 14 Aug 2010 14:32:54 +0200
parents 19f4f5ee3d1f
children f85004953416
files src/fileio.c
diffstat 1 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -317,20 +317,14 @@ readfile(fname, sfname, from, lines_to_s
     char_u	conv_rest[CONV_RESTLEN];
     int		conv_restlen = 0;	/* nr of bytes in conv_rest[] */
 #endif
-
 #ifdef FEAT_AUTOCMD
-    /* Remember the initial values of curbuf, curbuf->b_ffname and
-     * curbuf->b_fname to detect whether they are altered as a result of
-     * executing nasty autocommands.  Also check if "fname" and "sfname"
-     * point to one of these values. */
-    buf_T   *old_curbuf = curbuf;
-    char_u  *old_b_ffname = curbuf->b_ffname;
-    char_u  *old_b_fname = curbuf->b_fname;
-    int     using_b_ffname = (fname == curbuf->b_ffname)
-					      || (sfname == curbuf->b_ffname);
-    int     using_b_fname = (fname == curbuf->b_fname)
-					       || (sfname == curbuf->b_fname);
-#endif
+    buf_T	*old_curbuf;
+    char_u	*old_b_ffname;
+    char_u	*old_b_fname;
+    int		using_b_ffname;
+    int		using_b_fname;
+#endif
+
     write_no_eol_lnum = 0;	/* in case it was set by the previous read */
 
     /*
@@ -349,6 +343,19 @@ readfile(fname, sfname, from, lines_to_s
 	    return FAIL;
     }
 
+#ifdef FEAT_AUTOCMD
+    /* Remember the initial values of curbuf, curbuf->b_ffname and
+     * curbuf->b_fname to detect whether they are altered as a result of
+     * executing nasty autocommands.  Also check if "fname" and "sfname"
+     * point to one of these values. */
+    old_curbuf = curbuf;
+    old_b_ffname = curbuf->b_ffname;
+    old_b_fname = curbuf->b_fname;
+    using_b_ffname = (fname == curbuf->b_ffname)
+					      || (sfname == curbuf->b_ffname);
+    using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname);
+#endif
+
     /* After reading a file the cursor line changes but we don't want to
      * display the line. */
     ex_no_reprint = TRUE;