patch 9.0.0269: getscriptinfo() does not include the version

Problem:    getscriptinfo() does not include the version.  Cannot select
            entries by script name.
Solution:   Add the "version" item and the "name" argument. (Yegappan
            Lakshmanan, closes #10962)
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 1382f29..a2b88a6 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1946,17 +1946,35 @@
 			: SOURCING_LNUM;
 }
 
+/*
+ * getscriptinfo() function
+ */
     void
-f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv)
+f_getscriptinfo(typval_T *argvars, typval_T *rettv)
 {
     int		i;
     list_T	*l;
+    char_u	*pat = NULL;
+    regmatch_T	regmatch;
 
     if (rettv_list_alloc(rettv) == FAIL)
 	return;
 
+    if (check_for_opt_dict_arg(argvars, 0) == FAIL)
+	return;
+
     l = rettv->vval.v_list;
 
+    regmatch.regprog = NULL;
+    regmatch.rm_ic = p_ic;
+
+    if (argvars[0].v_type == VAR_DICT)
+    {
+	pat = dict_get_string(argvars[0].vval.v_dict, "name", TRUE);
+	if (pat != NULL)
+	    regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
+    }
+
     for (i = 1; i <= script_items.ga_len; ++i)
     {
 	scriptitem_T	*si = SCRIPT_ITEM(i);
@@ -1965,15 +1983,23 @@
 	if (si->sn_name == NULL)
 	    continue;
 
+	if (pat != NULL && regmatch.regprog != NULL
+		&& !vim_regexec(&regmatch, si->sn_name, (colnr_T)0))
+	    continue;
+
 	if ((d = dict_alloc()) == NULL
 		|| list_append_dict(l, d) == FAIL
 		|| dict_add_string(d, "name", si->sn_name) == FAIL
 		|| dict_add_number(d, "sid", i) == FAIL
 		|| dict_add_number(d, "sourced", si->sn_sourced_sid) == FAIL
+		|| dict_add_number(d, "version", si->sn_version) == FAIL
 		|| dict_add_bool(d, "autoload",
 				si->sn_state == SN_STATE_NOT_LOADED) == FAIL)
 	    return;
     }
+
+    vim_regfree(regmatch.regprog);
+    vim_free(pat);
 }
 
 #endif