diff src/vim9script.c @ 26992:8433e5c87651 v8.2.4025

patch 8.2.4025: error for import not ending in .vim does not work for .vimrc Commit: https://github.com/vim/vim/commit/834d41853e12b9022f60b08c32480928c2a9e48f Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 7 13:38:24 2022 +0000 patch 8.2.4025: error for import not ending in .vim does not work for .vimrc Problem: Error for import not ending in .vim does not work for .vimrc. Solution: Check that .vim is the end. (closes https://github.com/vim/vim/issues/9484)
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 Jan 2022 14:45:04 +0100
parents bef1f0167251
children 268f6a3511df
line wrap: on
line diff
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -474,10 +474,14 @@ handle_import(
 	    semsg(_(e_trailing_characters_str), expr_end);
 	    goto erret;
 	}
-
-	if (end == NULL)
+	if (end == NULL || end[4] != NUL)
 	{
-	    semsg(_(e_imported_script_must_end_in_dot_vim_str), p);
+	    semsg(_(e_imported_script_must_use_as_or_end_in_dot_vim_str), p);
+	    goto erret;
+	}
+	if (end == p)
+	{
+	    semsg(_(e_cannot_import_dot_vim_without_using_as), p);
 	    goto erret;
 	}
 	as_name = vim_strnsave(p, end - p);