Hi,

Yesterday while remotely debugging some Vim scripts I discovered 
(actually it is mentioned in the documentation) that remote_expr() 
imposes a limitation on the type of expressions handled: the expression 
must be a string or a list (although the implementation correctly 
handles integers and floats as well).

I am wondering if there is a good reason for this limitation. In the 
attached patch I applied the logic from f_string() on the result of 
expression, thus eliminating the limitation.

Please, comment.

If the patch is to be applied upstream, documentation for remote_expr() 
should be updated.

Cheers,
Lech

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/eval.c b/src/eval.c
index 1637e6d..75c67d1 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1335,6 +1335,7 @@ skip_expr(pp)
  * Top level evaluation function, returning a string.
  * When "convert" is TRUE convert a List into a sequence of lines and convert
  * a Float to a String.
+ * NOTE: the function will not convert a dictionary to string.
  * Return pointer to allocated memory, or NULL for failure.
  */
     char_u *
@@ -1382,6 +1383,30 @@ eval_to_string(arg, nextcmd, convert)
 }
 
 /*
+ * Top level evaluation function, returning a string without a limitation on
+ * the type of the expression.
+ *
+ * Returns pointer to allocated memory or NULL for failure.
+ */
+    char_u *
+eval_to_string2(expr)
+    char_u	*expr;
+{
+    typval_T	tv;
+    char_u	numbuf[NUMBUFLEN];
+    char_u	*tofree = NULL;
+    char_u	*res    = NULL;
+
+    if (eval0(expr, &tv, NULL, TRUE) != FAIL)
+    {
+	res = tv2string(&tv, &tofree, numbuf, 0);
+	if (res != NULL && tofree == NULL)
+	    res = vim_strsave(res);
+    }
+    return res;
+}
+
+/*
  * Call eval_to_string() without using current local variables and using
  * textlock.  When "use_sandbox" is TRUE use the sandbox.
  */
diff --git a/src/main.c b/src/main.c
index 1c262df..8a690d9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4085,7 +4085,7 @@ eval_client_expr_to_string(expr)
      * to be typed.  Do generate errors so that try/catch works. */
     ++emsg_silent;
 
-    res = eval_to_string(expr, NULL, TRUE);
+    res = eval_to_string2(expr);
 
     debug_break_level = save_dbl;
     redir_off = save_ro;
diff --git a/src/proto/eval.pro b/src/proto/eval.pro
index ee2da1b..3a3506f 100644
--- a/src/proto/eval.pro
+++ b/src/proto/eval.pro
@@ -18,6 +18,7 @@ int eval_to_bool __ARGS((char_u *arg, int *error, char_u **nextcmd, int skip));
 char_u *eval_to_string_skip __ARGS((char_u *arg, char_u **nextcmd, int skip));
 int skip_expr __ARGS((char_u **pp));
 char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd, int convert));
+char_u *eval_to_string2 __ARGS((char_u *expr));
 char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd, int use_sandbox));
 int eval_to_number __ARGS((char_u *expr));
 list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));

Raspunde prin e-mail lui