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