Yasuhiro Matsumoto wrote:

> On Wednesday, October 5, 2016 at 9:05:11 PM UTC+9, mattn wrote:
> > On Wednesday, October 5, 2016 at 5:49:32 AM UTC+9, Bram Moolenaar wrote:
> > > Thanks for diving into this.  But I think this needs more testing, since
> > > it's quite different from what we have before.
> > > 
> > > I think the "escaping" value needs to be reset after
> > >       for (i = 0; i < escaping; i++)
> > > Looks like you get there with a sequence \""
> > 
> > No, \n"" should be \\n\"\". i.e. second double-quote should be \". I'll add 
> > test in later.
> 
> Updated patch. Added few tests.
> 
> https://gist.github.com/mattn/d47e7d3bfe5ade4be86062b565a4bfca

A few more remarks:

+strsave_for_argv(char_u *string)

I would call the argument "argv" and the escaped result "argv_escaped".

+           has_spaces = 1;

Use TRUE and FALSE instead of 1 and 0.

+       if (*p == '\n')
+           ++length;

But the "\n" is not escaped, thus this is not needed.

+    if (escaped_string == NULL)
+       return escaped_string;

Can return NULL.

+       else
+       if (*p == '\\')

Should be one line.

Also, there is no test for a backslash in the text.  It would also need
to test for two or three backslashes.  And one or two backslashes
followed by a double quote.

I would rename "p" to "s" (stands for source).

+    /* add terminating quote and finish with a NUL */
+    if (has_spaces)
+    {
+       for (i = 0; i < escaping; i++)
+           *d++ = '\\';
+       *d++ = '"';
+    }
+    *d = NUL;

Adding backslashes before the terminating quote looks strange.  If this
is correct it should be covered by a test.

+func s:test_list_args(msg, out)

Use "cmd" instead of "msg".

+    call job_start([s:python, '-c', a:msg], {'callback': {ch,msg->execute('let 
s:out.=msg."\n"')}})

Why append the "\n"?

+  call s:test_list_args('print(''hello"world'')', "hello\"world\n")

This seems wrong.  The argument is hello"world but it results in an
extra backslash.

-- 
BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
ANOTHER MONK:    And St.  Attila raised his hand grenade up on high saying "O
                 Lord bless this thy hand grenade that with it thou mayest
                 blow thine enemies to tiny bits, in thy mercy. "and the Lord
                 did grin and people did feast upon the lambs and sloths and
                 carp and anchovies and orang-utans and breakfast cereals and
                 fruit bats and...
BROTHER MAYNARD: Skip a bit brother ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui