Sorry, It was wrong. I updated patch
https://gist.github.com/mattn/d47e7d3bfe5ade4be86062b565a4bfca
On Wednesday, October 12, 2016 at 11:19:06 PM UTC+9, Bram Moolenaar wrote:
> +strsave_for_argv(char_u *string)
>
> I would call the argument "argv" and the escaped result "argv_escaped".
renamed strsave_for_argv to escape_arg, string to arg, escaped_string to
arg_escaped.
>
> + has_spaces = 1;
>
> Use TRUE and FALSE instead of 1 and 0.
okay, thank you.
> + if (*p == '\n')
> + ++length;
>
> But the "\n" is not escaped, thus this is not needed.
Yes, removed.
> + if (escaped_string == NULL)
> + return escaped_string;
>
> Can return NULL.
this too.
> + else
> + if (*p == '\\')
>
> Should be one line.
ditto
> 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).
ditto
> + /* 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.
Yes, I was confused. Totally, fixed implementation. But terminating quote is
right. See test code.
> +func s:test_list_args(msg, out)
>
> Use "cmd" instead of "msg".
fixed too
> + call job_start([s:python, '-c', a:msg], {'callback':
> {ch,msg->execute('let s:out.=msg."\n"')}})
>
> Why append the "\n"?
For the separator, but not required at least. Then removed.
> + 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.
Please look carefully. "hello\"world\n"
Double quote in the quote should be escaped with backslash on Vim script as you
know.
Thanks.
- mattn
--
--
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/d/optout.