aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/strings.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-12 03:21:21 +0200
committerGitHub <noreply@github.com>2017-04-12 03:21:21 +0200
commitdd391bfca1f37093ba556f5da6a7f3eb81147fc0 (patch)
tree853aea222ea79998c63a0ef2e17e3e44101166e6 /src/nvim/strings.c
parent2d72d85b23761383ac7838faed2f7b53bdce8817 (diff)
parent7c4e5dfd2722b8c25641cbbc66c5b0133d0e2f03 (diff)
downloadrneovim-dd391bfca1f37093ba556f5da6a7f3eb81147fc0.tar.gz
rneovim-dd391bfca1f37093ba556f5da6a7f3eb81147fc0.tar.bz2
rneovim-dd391bfca1f37093ba556f5da6a7f3eb81147fc0.zip
Merge #6497 from justinmk/win-quot
win: system('...'): special-case cmd.exe
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r--src/nvim/strings.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 87e066d80a..8a1a3beddd 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -198,8 +198,16 @@ char_u *vim_strsave_shellescape(const char_u *string,
/* First count the number of extra bytes required. */
size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL
for (const char_u *p = string; *p != NUL; mb_ptr_adv(p)) {
- if (*p == '\'')
- length += 3; /* ' => '\'' */
+#ifdef WIN32
+ if (!p_ssl) {
+ if (*p == '"') {
+ length++; // " -> ""
+ }
+ } else
+#endif
+ if (*p == '\'') {
+ length += 3; // ' => '\''
+ }
if ((*p == '\n' && (csh_like || do_newline))
|| (*p == '!' && (csh_like || do_special))) {
++length; /* insert backslash */
@@ -216,10 +224,25 @@ char_u *vim_strsave_shellescape(const char_u *string,
escaped_string = xmalloc(length);
d = escaped_string;
- /* add opening quote */
+ // add opening quote
+#ifdef WIN32
+ if (!p_ssl) {
+ *d++ = '"';
+ } else
+#endif
*d++ = '\'';
for (const char_u *p = string; *p != NUL; ) {
+#ifdef WIN32
+ if (!p_ssl) {
+ if (*p == '"') {
+ *d++ = '"';
+ *d++ = '"';
+ p++;
+ continue;
+ }
+ } else
+#endif
if (*p == '\'') {
*d++ = '\'';
*d++ = '\\';
@@ -246,7 +269,12 @@ char_u *vim_strsave_shellescape(const char_u *string,
MB_COPY_CHAR(p, d);
}
- /* add terminating quote and finish with a NUL */
+ // add terminating quote and finish with a NUL
+# ifdef WIN32
+ if (!p_ssl) {
+ *d++ = '"';
+ } else
+# endif
*d++ = '\'';
*d = NUL;