comparison src/misc2.c @ 19793:607e5d7968b9 v8.2.0453

patch 8.2.0453: trailing space in job_start() command causes empty argument Commit: https://github.com/vim/vim/commit/7851b1ca992222880df1314684a790f293e11896 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 26 16:27:38 2020 +0100 patch 8.2.0453: trailing space in job_start() command causes empty argument Problem: Trailing space in job_start() command causes empty argument. Solution: Ignore trailing space. (closes https://github.com/vim/vim/issues/5851)
author Bram Moolenaar <Bram@vim.org>
date Thu, 26 Mar 2020 16:30:03 +0100
parents a961efb326e5
children 435726a03481
comparison
equal deleted inserted replaced
19792:6bef434ae7ba 19793:607e5d7968b9
4240 /* 4240 /*
4241 * Do this loop twice: 4241 * Do this loop twice:
4242 * 1: find number of arguments 4242 * 1: find number of arguments
4243 * 2: separate them and build argv[] 4243 * 2: separate them and build argv[]
4244 */ 4244 */
4245 for (i = 0; i < 2; ++i) 4245 for (i = 1; i <= 2; ++i)
4246 { 4246 {
4247 p = skipwhite(cmd); 4247 p = skipwhite(cmd);
4248 inquote = FALSE; 4248 inquote = FALSE;
4249 *argc = 0; 4249 *argc = 0;
4250 for (;;) 4250 while (*p != NUL)
4251 { 4251 {
4252 if (i == 1) 4252 if (i == 2)
4253 (*argv)[*argc] = (char *)p; 4253 (*argv)[*argc] = (char *)p;
4254 ++*argc; 4254 ++*argc;
4255 d = p; 4255 d = p;
4256 while (*p != NUL && (inquote || (*p != ' ' && *p != TAB))) 4256 while (*p != NUL && (inquote || (*p != ' ' && *p != TAB)))
4257 { 4257 {
4264 { 4264 {
4265 // First pass: skip over "\ " and "\"". 4265 // First pass: skip over "\ " and "\"".
4266 // Second pass: Remove the backslash. 4266 // Second pass: Remove the backslash.
4267 ++p; 4267 ++p;
4268 } 4268 }
4269 if (i == 1) 4269 if (i == 2)
4270 *d++ = *p; 4270 *d++ = *p;
4271 } 4271 }
4272 ++p; 4272 ++p;
4273 } 4273 }
4274 if (*p == NUL) 4274 if (*p == NUL)
4275 { 4275 {
4276 if (i == 1) 4276 if (i == 2)
4277 *d++ = NUL; 4277 *d++ = NUL;
4278 break; 4278 break;
4279 } 4279 }
4280 if (i == 1) 4280 if (i == 2)
4281 *d++ = NUL; 4281 *d++ = NUL;
4282 p = skipwhite(p + 1); 4282 p = skipwhite(p + 1);
4283 } 4283 }
4284 if (*argv == NULL) 4284 if (*argv == NULL)
4285 { 4285 {