patch 9.1.1509: patch 9.1.1505 was not good

Problem:  Patch 9.1.1505 was not good
Solution: Revert "patch 9.1.1505: not possible to return completion type
          for :ex command" and instead add the getcompletiontype()
          function (Hirohito Higashi).

related: #17606
closes: #17662

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 044f389..f2a51ea 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4303,9 +4303,9 @@
 }
 
 /*
- * Get the current command-line completion type.
+ * Get the command-line completion type.
  */
-    static char_u *
+    char_u *
 get_cmdline_completion(expand_T *xpc)
 {
     int		xp_context;
@@ -4354,40 +4354,16 @@
     void
 f_getcmdcompltype(typval_T *argvars UNUSED, typval_T *rettv)
 {
-    if (check_for_opt_string_arg(argvars, 0) == FAIL)
-	 return;
+    cmdline_info_T *p;
 
     rettv->v_type = VAR_STRING;
+    rettv->vval.v_string = NULL;
 
-    if (argvars[0].v_type != VAR_UNKNOWN)
-    {
-	 char_u		*pat;
-	 expand_T	xpc;
-	 int		cmdline_len;
+    p = get_ccline_ptr();
+    if (cmdline_star > 0 || p == NULL || p->xpc == NULL)
+	return;
 
-	pat = tv_get_string(&argvars[0]);
-	ExpandInit(&xpc);
-
-	cmdline_len = (int)STRLEN(pat);
-	set_cmd_context(&xpc, pat, cmdline_len, cmdline_len, FALSE);
-	xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
-	xpc.xp_col = cmdline_len;
-
-	rettv->v_type = VAR_STRING;
-	rettv->vval.v_string = get_cmdline_completion(&xpc);
-
-	ExpandCleanup(&xpc);
-    }
-    else
-    {
-	 cmdline_info_T *p;
-
-	 p = get_ccline_ptr();
-	 if (cmdline_star > 0 || p == NULL || p->xpc == NULL)
-	     return;
-
-	 rettv->vval.v_string = get_cmdline_completion(p->xpc);
-    }
+    rettv->vval.v_string = get_cmdline_completion(p->xpc);
 }
 
 /*