|
|
22c937 |
To: vim_dev@googlegroups.com
|
|
|
22c937 |
Subject: Patch 7.4.247
|
|
|
22c937 |
Fcc: outbox
|
|
|
22c937 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
22c937 |
Mime-Version: 1.0
|
|
|
22c937 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c937 |
Content-Transfer-Encoding: 8bit
|
|
|
22c937 |
------------
|
|
|
22c937 |
|
|
|
22c937 |
Patch 7.4.247
|
|
|
22c937 |
Problem: When passing input to system() there is no way to keep NUL and
|
|
|
22c937 |
NL characters separate.
|
|
|
22c937 |
Solution: Optionally use a list for the system() input. (ZyX)
|
|
|
22c937 |
Files: runtime/doc/eval.txt, src/eval.c
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.246/runtime/doc/eval.txt 2014-04-02 22:16:59.995482236 +0200
|
|
|
22c937 |
--- runtime/doc/eval.txt 2014-04-05 18:47:12.907153201 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 5951,5960 ****
|
|
|
22c937 |
|
|
|
22c937 |
system({expr} [, {input}]) *system()* *E677*
|
|
|
22c937 |
Get the output of the shell command {expr}.
|
|
|
22c937 |
! When {input} is given, this string is written to a file and
|
|
|
22c937 |
! passed as stdin to the command. The string is written as-is,
|
|
|
22c937 |
! you need to take care of using the correct line separators
|
|
|
22c937 |
! yourself. Pipes are not used.
|
|
|
22c937 |
Note: Use |shellescape()| or |::S| with |expand()| or
|
|
|
22c937 |
|fnamemodify()| to escape special characters in a command
|
|
|
22c937 |
argument. Newlines in {expr} may cause the command to fail.
|
|
|
22c937 |
--- 5964,5980 ----
|
|
|
22c937 |
|
|
|
22c937 |
system({expr} [, {input}]) *system()* *E677*
|
|
|
22c937 |
Get the output of the shell command {expr}.
|
|
|
22c937 |
!
|
|
|
22c937 |
! When {input} is given and is a string this string is written
|
|
|
22c937 |
! to a file and passed as stdin to the command. The string is
|
|
|
22c937 |
! written as-is, you need to take care of using the correct line
|
|
|
22c937 |
! separators yourself.
|
|
|
22c937 |
! If {input} is given and is a |List| it is written to the file
|
|
|
22c937 |
! in a way |writefile()| does with {binary} set to "b" (i.e.
|
|
|
22c937 |
! with a newline between each list item with newlines inside
|
|
|
22c937 |
! list items converted to NULs).
|
|
|
22c937 |
! Pipes are not used.
|
|
|
22c937 |
!
|
|
|
22c937 |
Note: Use |shellescape()| or |::S| with |expand()| or
|
|
|
22c937 |
|fnamemodify()| to escape special characters in a command
|
|
|
22c937 |
argument. Newlines in {expr} may cause the command to fail.
|
|
|
22c937 |
*** ../vim-7.4.246/src/eval.c 2014-04-02 22:17:00.003482236 +0200
|
|
|
22c937 |
--- src/eval.c 2014-04-05 18:47:50.971153284 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 836,841 ****
|
|
|
22c937 |
--- 836,842 ----
|
|
|
22c937 |
static int searchpair_cmn __ARGS((typval_T *argvars, pos_T *match_pos));
|
|
|
22c937 |
static int search_cmn __ARGS((typval_T *argvars, pos_T *match_pos, int *flagsp));
|
|
|
22c937 |
static void setwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off));
|
|
|
22c937 |
+ static int write_list __ARGS((FILE *fd, list_T *list, int binary));
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef EBCDIC
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 18267,18280 ****
|
|
|
22c937 |
EMSG2(_(e_notopen), infile);
|
|
|
22c937 |
goto done;
|
|
|
22c937 |
}
|
|
|
22c937 |
! p = get_tv_string_buf_chk(&argvars[1], buf);
|
|
|
22c937 |
! if (p == NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
! fclose(fd);
|
|
|
22c937 |
! goto done; /* type error; errmsg already given */
|
|
|
22c937 |
}
|
|
|
22c937 |
- if (fwrite(p, STRLEN(p), 1, fd) != 1)
|
|
|
22c937 |
- err = TRUE;
|
|
|
22c937 |
if (fclose(fd) != 0)
|
|
|
22c937 |
err = TRUE;
|
|
|
22c937 |
if (err)
|
|
|
22c937 |
--- 18268,18289 ----
|
|
|
22c937 |
EMSG2(_(e_notopen), infile);
|
|
|
22c937 |
goto done;
|
|
|
22c937 |
}
|
|
|
22c937 |
! if (argvars[1].v_type == VAR_LIST)
|
|
|
22c937 |
{
|
|
|
22c937 |
! if (write_list(fd, argvars[1].vval.v_list, TRUE) == FAIL)
|
|
|
22c937 |
! err = TRUE;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! else
|
|
|
22c937 |
! {
|
|
|
22c937 |
! p = get_tv_string_buf_chk(&argvars[1], buf);
|
|
|
22c937 |
! if (p == NULL)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! fclose(fd);
|
|
|
22c937 |
! goto done; /* type error; errmsg already given */
|
|
|
22c937 |
! }
|
|
|
22c937 |
! if (fwrite(p, STRLEN(p), 1, fd) != 1)
|
|
|
22c937 |
! err = TRUE;
|
|
|
22c937 |
}
|
|
|
22c937 |
if (fclose(fd) != 0)
|
|
|
22c937 |
err = TRUE;
|
|
|
22c937 |
if (err)
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 19173,19178 ****
|
|
|
22c937 |
--- 19182,19230 ----
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
/*
|
|
|
22c937 |
+ * Write list of strings to file
|
|
|
22c937 |
+ */
|
|
|
22c937 |
+ static int
|
|
|
22c937 |
+ write_list(fd, list, binary)
|
|
|
22c937 |
+ FILE *fd;
|
|
|
22c937 |
+ list_T *list;
|
|
|
22c937 |
+ int binary;
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ listitem_T *li;
|
|
|
22c937 |
+ int c;
|
|
|
22c937 |
+ int ret = OK;
|
|
|
22c937 |
+ char_u *s;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ for (li = list->lv_first; li != NULL; li = li->li_next)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ for (s = get_tv_string(&li->li_tv); *s != NUL; ++s)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (*s == '\n')
|
|
|
22c937 |
+ c = putc(NUL, fd);
|
|
|
22c937 |
+ else
|
|
|
22c937 |
+ c = putc(*s, fd);
|
|
|
22c937 |
+ if (c == EOF)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ ret = FAIL;
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ if (!binary || li->li_next != NULL)
|
|
|
22c937 |
+ if (putc('\n', fd) == EOF)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ ret = FAIL;
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ if (ret == FAIL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ EMSG(_(e_write));
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ return ret;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
+ /*
|
|
|
22c937 |
* "writefile()" function
|
|
|
22c937 |
*/
|
|
|
22c937 |
static void
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 19183,19192 ****
|
|
|
22c937 |
int binary = FALSE;
|
|
|
22c937 |
char_u *fname;
|
|
|
22c937 |
FILE *fd;
|
|
|
22c937 |
- listitem_T *li;
|
|
|
22c937 |
- char_u *s;
|
|
|
22c937 |
int ret = 0;
|
|
|
22c937 |
- int c;
|
|
|
22c937 |
|
|
|
22c937 |
if (check_restricted() || check_secure())
|
|
|
22c937 |
return;
|
|
|
22c937 |
--- 19235,19241 ----
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 19213,19245 ****
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
{
|
|
|
22c937 |
! for (li = argvars[0].vval.v_list->lv_first; li != NULL;
|
|
|
22c937 |
! li = li->li_next)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! for (s = get_tv_string(&li->li_tv); *s != NUL; ++s)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! if (*s == '\n')
|
|
|
22c937 |
! c = putc(NUL, fd);
|
|
|
22c937 |
! else
|
|
|
22c937 |
! c = putc(*s, fd);
|
|
|
22c937 |
! if (c == EOF)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! ret = -1;
|
|
|
22c937 |
! break;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! }
|
|
|
22c937 |
! if (!binary || li->li_next != NULL)
|
|
|
22c937 |
! if (putc('\n', fd) == EOF)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! ret = -1;
|
|
|
22c937 |
! break;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! if (ret < 0)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! EMSG(_(e_write));
|
|
|
22c937 |
! break;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! }
|
|
|
22c937 |
fclose(fd);
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
--- 19262,19269 ----
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
{
|
|
|
22c937 |
! if (write_list(fd, argvars[0].vval.v_list, binary) == FAIL)
|
|
|
22c937 |
! ret = -1;
|
|
|
22c937 |
fclose(fd);
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.246/src/version.c 2014-04-05 12:02:20.751100138 +0200
|
|
|
22c937 |
--- src/version.c 2014-04-05 18:49:24.411153488 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 736,737 ****
|
|
|
22c937 |
--- 736,739 ----
|
|
|
22c937 |
{ /* Add new patch number below this line */
|
|
|
22c937 |
+ /**/
|
|
|
22c937 |
+ 247,
|
|
|
22c937 |
/**/
|
|
|
22c937 |
|
|
|
22c937 |
--
|
|
|
22c937 |
Time is an illusion. Lunchtime doubly so.
|
|
|
22c937 |
-- Ford Prefect, in Douglas Adams'
|
|
|
22c937 |
"The Hitchhiker's Guide to the Galaxy"
|
|
|
22c937 |
|
|
|
22c937 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
22c937 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
22c937 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
22c937 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|