patch 8.2.0578: heredoc for interfaces does not support "trim"

Problem:    Heredoc for interfaces does not support "trim".
Solution:   Update the script heredoc support to be same as the :let command.
            (Yegappan Lakshmanan, closes #5916)
diff --git a/src/ex_getln.c b/src/ex_getln.c
index accedb5..9b959fb 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4408,44 +4408,37 @@
  * Returns a pointer to allocated memory with {script} or NULL.
  */
     char_u *
-script_get(exarg_T *eap, char_u *cmd)
+script_get(exarg_T *eap UNUSED, char_u *cmd UNUSED)
 {
-    char_u	*theline;
-    char	*end_pattern = NULL;
-    char	dot[] = ".";
+#ifdef FEAT_EVAL
+    list_T	*l;
+    listitem_T	*li;
+    char_u	*s;
     garray_T	ga;
 
     if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL)
 	return NULL;
+    cmd += 2;
+
+    l = heredoc_get(eap, cmd, TRUE);
+    if (l == NULL)
+	return NULL;
 
     ga_init2(&ga, 1, 0x400);
 
-    if (cmd[2] != NUL)
-	end_pattern = (char *)skipwhite(cmd + 2);
-    else
-	end_pattern = dot;
-
-    for (;;)
+    FOR_ALL_LIST_ITEMS(l, li)
     {
-	theline = eap->getline(
-#ifdef FEAT_EVAL
-	    eap->cstack->cs_looplevel > 0 ? -1 :
-#endif
-	    NUL, eap->cookie, 0, TRUE);
-
-	if (theline == NULL || STRCMP(end_pattern, theline) == 0)
-	{
-	    vim_free(theline);
-	    break;
-	}
-
-	ga_concat(&ga, theline);
+	s = tv_get_string(&li->li_tv);
+	ga_concat(&ga, s);
 	ga_append(&ga, '\n');
-	vim_free(theline);
     }
     ga_append(&ga, NUL);
 
+    list_free(l);
     return (char_u *)ga.ga_data;
+#else
+    return NULL;
+#endif
 }
 
 #if defined(FEAT_EVAL) || defined(PROTO)