Karsten Hopp 5ecd1b
To: vim_dev@googlegroups.com
Karsten Hopp 5ecd1b
Subject: Patch 7.4.248
Karsten Hopp 5ecd1b
Fcc: outbox
Karsten Hopp 5ecd1b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 5ecd1b
Mime-Version: 1.0
Karsten Hopp 5ecd1b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 5ecd1b
Content-Transfer-Encoding: 8bit
Karsten Hopp 5ecd1b
------------
Karsten Hopp 5ecd1b
Karsten Hopp 5ecd1b
Patch 7.4.248
Karsten Hopp 5ecd1b
Problem:    Cannot distinguish between NL and NUL in output of system().
Karsten Hopp 5ecd1b
Solution:   Add systemlist(). (ZyX)
Karsten Hopp 5ecd1b
Files:	    runtime/doc/eval.txt, src/eval.c, src/ex_cmds2.c, src/misc1.c,
Karsten Hopp 5ecd1b
	    src/proto/misc1.pro
Karsten Hopp 5ecd1b
Karsten Hopp 5ecd1b
Karsten Hopp 5ecd1b
*** ../vim-7.4.247/runtime/doc/eval.txt	2014-04-05 18:55:40.471154309 +0200
Karsten Hopp 5ecd1b
--- runtime/doc/eval.txt	2014-04-05 19:03:05.419155281 +0200
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 2001,2006 ****
Karsten Hopp 5ecd1b
--- 2002,2008 ----
Karsten Hopp 5ecd1b
  synconcealed( {lnum}, {col})	List    info about concealing
Karsten Hopp 5ecd1b
  synstack( {lnum}, {col})	List	stack of syntax IDs at {lnum} and {col}
Karsten Hopp 5ecd1b
  system( {expr} [, {input}])	String	output of shell command/filter {expr}
Karsten Hopp 5ecd1b
+ systemlist( {expr} [, {input}])	List	output of shell command/filter {expr}
Karsten Hopp 5ecd1b
  tabpagebuflist( [{arg}])	List	list of buffer numbers in tab page
Karsten Hopp 5ecd1b
  tabpagenr( [{arg}])		Number	number of current or last tab page
Karsten Hopp 5ecd1b
  tabpagewinnr( {tabarg}[, {arg}])
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 5950,5956 ****
Karsten Hopp 5ecd1b
  		valid positions.
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  system({expr} [, {input}])				*system()* *E677*
Karsten Hopp 5ecd1b
! 		Get the output of the shell command {expr}.
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  		When {input} is given and is a string this string is written 
Karsten Hopp 5ecd1b
  		to a file and passed as stdin to the command.  The string is 
Karsten Hopp 5ecd1b
--- 5964,5971 ----
Karsten Hopp 5ecd1b
  		valid positions.
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  system({expr} [, {input}])				*system()* *E677*
Karsten Hopp 5ecd1b
! 		Get the output of the shell command {expr} as a string.  See
Karsten Hopp 5ecd1b
! 		|systemlist()| to get the output as a List.
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  		When {input} is given and is a string this string is written 
Karsten Hopp 5ecd1b
  		to a file and passed as stdin to the command.  The string is 
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 5998,6003 ****
Karsten Hopp 5ecd1b
--- 6013,6028 ----
Karsten Hopp 5ecd1b
  		Use |:checktime| to force a check.
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
+ systemlist({expr} [, {input}])				*systemlist()*
Karsten Hopp 5ecd1b
+ 		Same as |system()|, but returns a |List| with lines (parts of 
Karsten Hopp 5ecd1b
+ 		output separated by NL) with NULs transformed into NLs. Output 
Karsten Hopp 5ecd1b
+ 		is the same as |readfile()| will output with {binary} argument 
Karsten Hopp 5ecd1b
+ 		set to "b".
Karsten Hopp 5ecd1b
+ 
Karsten Hopp 5ecd1b
+ 		Returns an empty string on error, so be careful not to run 
Karsten Hopp 5ecd1b
+ 		into |E706|.
Karsten Hopp 5ecd1b
+ 
Karsten Hopp 5ecd1b
+ 
Karsten Hopp 5ecd1b
  tabpagebuflist([{arg}])					*tabpagebuflist()*
Karsten Hopp 5ecd1b
  		The result is a |List|, where each item is the number of the
Karsten Hopp 5ecd1b
  		buffer associated with each window in the current tab page.
Karsten Hopp 5ecd1b
*** ../vim-7.4.247/src/eval.c	2014-04-05 18:55:40.479154309 +0200
Karsten Hopp 5ecd1b
--- src/eval.c	2014-04-05 19:42:37.675160463 +0200
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 726,731 ****
Karsten Hopp 5ecd1b
--- 726,732 ----
Karsten Hopp 5ecd1b
  static void f_synstack __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
  static void f_synconcealed __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
  static void f_system __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
+ static void f_systemlist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
  static void f_tabpagebuflist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
  static void f_tabpagenr __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
  static void f_tabpagewinnr __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 837,842 ****
Karsten Hopp 5ecd1b
--- 838,844 ----
Karsten Hopp 5ecd1b
  static int search_cmn __ARGS((typval_T *argvars, pos_T *match_pos, int *flagsp));
Karsten Hopp 5ecd1b
  static void setwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off));
Karsten Hopp 5ecd1b
  static int write_list __ARGS((FILE *fd, list_T *list, int binary));
Karsten Hopp 5ecd1b
+ static void get_cmd_output_as_rettv __ARGS((typval_T *argvars, typval_T *rettv, int retlist));
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  #ifdef EBCDIC
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 8139,8144 ****
Karsten Hopp 5ecd1b
--- 8141,8147 ----
Karsten Hopp 5ecd1b
      {"synconcealed",	2, 2, f_synconcealed},
Karsten Hopp 5ecd1b
      {"synstack",	2, 2, f_synstack},
Karsten Hopp 5ecd1b
      {"system",		1, 2, f_system},
Karsten Hopp 5ecd1b
+     {"systemlist",	1, 2, f_systemlist},
Karsten Hopp 5ecd1b
      {"tabpagebuflist",	0, 1, f_tabpagebuflist},
Karsten Hopp 5ecd1b
      {"tabpagenr",	0, 1, f_tabpagenr},
Karsten Hopp 5ecd1b
      {"tabpagewinnr",	1, 2, f_tabpagewinnr},
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 18232,18244 ****
Karsten Hopp 5ecd1b
  #endif
Karsten Hopp 5ecd1b
  }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
- /*
Karsten Hopp 5ecd1b
-  * "system()" function
Karsten Hopp 5ecd1b
-  */
Karsten Hopp 5ecd1b
      static void
Karsten Hopp 5ecd1b
! f_system(argvars, rettv)
Karsten Hopp 5ecd1b
      typval_T	*argvars;
Karsten Hopp 5ecd1b
      typval_T	*rettv;
Karsten Hopp 5ecd1b
  {
Karsten Hopp 5ecd1b
      char_u	*res = NULL;
Karsten Hopp 5ecd1b
      char_u	*p;
Karsten Hopp 5ecd1b
--- 18235,18245 ----
Karsten Hopp 5ecd1b
  #endif
Karsten Hopp 5ecd1b
  }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
      static void
Karsten Hopp 5ecd1b
! get_cmd_output_as_rettv(argvars, rettv, retlist)
Karsten Hopp 5ecd1b
      typval_T	*argvars;
Karsten Hopp 5ecd1b
      typval_T	*rettv;
Karsten Hopp 5ecd1b
+     int		retlist;
Karsten Hopp 5ecd1b
  {
Karsten Hopp 5ecd1b
      char_u	*res = NULL;
Karsten Hopp 5ecd1b
      char_u	*p;
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 18246,18254 ****
Karsten Hopp 5ecd1b
      char_u	buf[NUMBUFLEN];
Karsten Hopp 5ecd1b
      int		err = FALSE;
Karsten Hopp 5ecd1b
      FILE	*fd;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
      if (check_restricted() || check_secure())
Karsten Hopp 5ecd1b
! 	goto done;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
      if (argvars[1].v_type != VAR_UNKNOWN)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
--- 18247,18258 ----
Karsten Hopp 5ecd1b
      char_u	buf[NUMBUFLEN];
Karsten Hopp 5ecd1b
      int		err = FALSE;
Karsten Hopp 5ecd1b
      FILE	*fd;
Karsten Hopp 5ecd1b
+     list_T	*list = NULL;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
+     rettv->v_type = VAR_STRING;
Karsten Hopp 5ecd1b
+     rettv->vval.v_string = NULL;
Karsten Hopp 5ecd1b
      if (check_restricted() || check_secure())
Karsten Hopp 5ecd1b
! 	goto errret;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
      if (argvars[1].v_type != VAR_UNKNOWN)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 18259,18272 ****
Karsten Hopp 5ecd1b
  	if ((infile = vim_tempname('i')) == NULL)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
  	    EMSG(_(e_notmp));
Karsten Hopp 5ecd1b
! 	    goto done;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  	fd = mch_fopen((char *)infile, WRITEBIN);
Karsten Hopp 5ecd1b
  	if (fd == NULL)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
  	    EMSG2(_(e_notopen), infile);
Karsten Hopp 5ecd1b
! 	    goto done;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
  	if (argvars[1].v_type == VAR_LIST)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
--- 18263,18276 ----
Karsten Hopp 5ecd1b
  	if ((infile = vim_tempname('i')) == NULL)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
  	    EMSG(_(e_notmp));
Karsten Hopp 5ecd1b
! 	    goto errret;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  	fd = mch_fopen((char *)infile, WRITEBIN);
Karsten Hopp 5ecd1b
  	if (fd == NULL)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
  	    EMSG2(_(e_notopen), infile);
Karsten Hopp 5ecd1b
! 	    goto errret;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
  	if (argvars[1].v_type == VAR_LIST)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 18279,18285 ****
Karsten Hopp 5ecd1b
  	    if (p == NULL)
Karsten Hopp 5ecd1b
  	    {
Karsten Hopp 5ecd1b
  		fclose(fd);
Karsten Hopp 5ecd1b
! 		goto done;		/* type error; errmsg already given */
Karsten Hopp 5ecd1b
  	    }
Karsten Hopp 5ecd1b
  	    if (fwrite(p, STRLEN(p), 1, fd) != 1)
Karsten Hopp 5ecd1b
  		err = TRUE;
Karsten Hopp 5ecd1b
--- 18283,18289 ----
Karsten Hopp 5ecd1b
  	    if (p == NULL)
Karsten Hopp 5ecd1b
  	    {
Karsten Hopp 5ecd1b
  		fclose(fd);
Karsten Hopp 5ecd1b
! 		goto errret;		/* type error; errmsg already given */
Karsten Hopp 5ecd1b
  	    }
Karsten Hopp 5ecd1b
  	    if (fwrite(p, STRLEN(p), 1, fd) != 1)
Karsten Hopp 5ecd1b
  		err = TRUE;
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 18289,18340 ****
Karsten Hopp 5ecd1b
  	if (err)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
  	    EMSG(_("E677: Error writing temp file"));
Karsten Hopp 5ecd1b
! 	    goto done;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
!     res = get_cmd_output(get_tv_string(&argvars[0]), infile,
Karsten Hopp 5ecd1b
! 						 SHELL_SILENT | SHELL_COOKED);
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! #ifdef USE_CR
Karsten Hopp 5ecd1b
!     /* translate <CR> into <NL> */
Karsten Hopp 5ecd1b
!     if (res != NULL)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
! 	char_u	*s;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
! 	for (s = res; *s; ++s)
Karsten Hopp 5ecd1b
! 	{
Karsten Hopp 5ecd1b
! 	    if (*s == CAR)
Karsten Hopp 5ecd1b
! 		*s = NL;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
! #else
Karsten Hopp 5ecd1b
! # ifdef USE_CRNL
Karsten Hopp 5ecd1b
!     /* translate <CR><NL> into <NL> */
Karsten Hopp 5ecd1b
!     if (res != NULL)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
! 	char_u	*s, *d;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
! 	d = res;
Karsten Hopp 5ecd1b
! 	for (s = res; *s; ++s)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
! 	    if (s[0] == CAR && s[1] == NL)
Karsten Hopp 5ecd1b
! 		++s;
Karsten Hopp 5ecd1b
! 	    *d++ = *s;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
- 	*d = NUL;
Karsten Hopp 5ecd1b
-     }
Karsten Hopp 5ecd1b
  # endif
Karsten Hopp 5ecd1b
  #endif
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
! done:
Karsten Hopp 5ecd1b
      if (infile != NULL)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
  	mch_remove(infile);
Karsten Hopp 5ecd1b
  	vim_free(infile);
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
!     rettv->v_type = VAR_STRING;
Karsten Hopp 5ecd1b
!     rettv->vval.v_string = res;
Karsten Hopp 5ecd1b
  }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  /*
Karsten Hopp 5ecd1b
--- 18293,18420 ----
Karsten Hopp 5ecd1b
  	if (err)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
  	    EMSG(_("E677: Error writing temp file"));
Karsten Hopp 5ecd1b
! 	    goto errret;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
!     if (retlist)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
! 	int		len;
Karsten Hopp 5ecd1b
! 	listitem_T	*li;
Karsten Hopp 5ecd1b
! 	char_u		*s = NULL;
Karsten Hopp 5ecd1b
! 	char_u		*start;
Karsten Hopp 5ecd1b
! 	char_u		*end;
Karsten Hopp 5ecd1b
! 	char_u		*p;
Karsten Hopp 5ecd1b
! 	int		i;
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! 	res = get_cmd_output(get_tv_string(&argvars[0]), infile,
Karsten Hopp 5ecd1b
! 					   SHELL_SILENT | SHELL_COOKED, &len;;
Karsten Hopp 5ecd1b
! 	if (res == NULL)
Karsten Hopp 5ecd1b
! 	    goto errret;
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! 	list = list_alloc();
Karsten Hopp 5ecd1b
! 	if (list == NULL)
Karsten Hopp 5ecd1b
! 	    goto errret;
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! 	for (i = 0; i < len; ++i)
Karsten Hopp 5ecd1b
! 	{
Karsten Hopp 5ecd1b
! 	    start = res + i;
Karsten Hopp 5ecd1b
! 	    for (end = start; i < len && *end != NL; ++end)
Karsten Hopp 5ecd1b
! 		++i;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
! 	    s = vim_strnsave(start, (int)(end - start));
Karsten Hopp 5ecd1b
! 	    if (s == NULL)
Karsten Hopp 5ecd1b
! 		goto errret;
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! 	    for (p = s, end = s + (end - start); p < end; ++p)
Karsten Hopp 5ecd1b
! 		if (*p == NUL)
Karsten Hopp 5ecd1b
! 		    *p = NL;
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! 	    li = listitem_alloc();
Karsten Hopp 5ecd1b
! 	    if (li == NULL)
Karsten Hopp 5ecd1b
! 	    {
Karsten Hopp 5ecd1b
! 		vim_free(s);
Karsten Hopp 5ecd1b
! 		goto errret;
Karsten Hopp 5ecd1b
! 	    }
Karsten Hopp 5ecd1b
! 	    li->li_tv.v_type = VAR_STRING;
Karsten Hopp 5ecd1b
! 	    li->li_tv.vval.v_string = s;
Karsten Hopp 5ecd1b
! 	    list_append(list, li);
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
+ 
Karsten Hopp 5ecd1b
+ 	rettv->v_type = VAR_LIST;
Karsten Hopp 5ecd1b
+ 	rettv->vval.v_list = list;
Karsten Hopp 5ecd1b
+ 	list = NULL;
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
!     else
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
! 	res = get_cmd_output(get_tv_string(&argvars[0]), infile,
Karsten Hopp 5ecd1b
! 					   SHELL_SILENT | SHELL_COOKED, NULL);
Karsten Hopp 5ecd1b
! #ifdef USE_CR
Karsten Hopp 5ecd1b
! 	/* translate <CR> into <NL> */
Karsten Hopp 5ecd1b
! 	if (res != NULL)
Karsten Hopp 5ecd1b
! 	{
Karsten Hopp 5ecd1b
! 	    char_u	*s;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
! 	    for (s = res; *s; ++s)
Karsten Hopp 5ecd1b
! 	    {
Karsten Hopp 5ecd1b
! 		if (*s == CAR)
Karsten Hopp 5ecd1b
! 		    *s = NL;
Karsten Hopp 5ecd1b
! 	    }
Karsten Hopp 5ecd1b
! 	}
Karsten Hopp 5ecd1b
! #else
Karsten Hopp 5ecd1b
! # ifdef USE_CRNL
Karsten Hopp 5ecd1b
! 	/* translate <CR><NL> into <NL> */
Karsten Hopp 5ecd1b
! 	if (res != NULL)
Karsten Hopp 5ecd1b
  	{
Karsten Hopp 5ecd1b
! 	    char_u	*s, *d;
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! 	    d = res;
Karsten Hopp 5ecd1b
! 	    for (s = res; *s; ++s)
Karsten Hopp 5ecd1b
! 	    {
Karsten Hopp 5ecd1b
! 		if (s[0] == CAR && s[1] == NL)
Karsten Hopp 5ecd1b
! 		    ++s;
Karsten Hopp 5ecd1b
! 		*d++ = *s;
Karsten Hopp 5ecd1b
! 	    }
Karsten Hopp 5ecd1b
! 	    *d = NUL;
Karsten Hopp 5ecd1b
  	}
Karsten Hopp 5ecd1b
  # endif
Karsten Hopp 5ecd1b
  #endif
Karsten Hopp 5ecd1b
+ 	rettv->vval.v_string = res;
Karsten Hopp 5ecd1b
+ 	res = NULL;
Karsten Hopp 5ecd1b
+     }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
! errret:
Karsten Hopp 5ecd1b
      if (infile != NULL)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
  	mch_remove(infile);
Karsten Hopp 5ecd1b
  	vim_free(infile);
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
!     if (res != NULL)
Karsten Hopp 5ecd1b
! 	vim_free(res);
Karsten Hopp 5ecd1b
!     if (list != NULL)
Karsten Hopp 5ecd1b
! 	list_free(list, TRUE);
Karsten Hopp 5ecd1b
! }
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! /*
Karsten Hopp 5ecd1b
!  * "system()" function
Karsten Hopp 5ecd1b
!  */
Karsten Hopp 5ecd1b
!     static void
Karsten Hopp 5ecd1b
! f_system(argvars, rettv)
Karsten Hopp 5ecd1b
!     typval_T	*argvars;
Karsten Hopp 5ecd1b
!     typval_T	*rettv;
Karsten Hopp 5ecd1b
! {
Karsten Hopp 5ecd1b
!     get_cmd_output_as_rettv(argvars, rettv, FALSE);
Karsten Hopp 5ecd1b
! }
Karsten Hopp 5ecd1b
! 
Karsten Hopp 5ecd1b
! /*
Karsten Hopp 5ecd1b
!  * "systemlist()" function
Karsten Hopp 5ecd1b
!  */
Karsten Hopp 5ecd1b
!     static void
Karsten Hopp 5ecd1b
! f_systemlist(argvars, rettv)
Karsten Hopp 5ecd1b
!     typval_T	*argvars;
Karsten Hopp 5ecd1b
!     typval_T	*rettv;
Karsten Hopp 5ecd1b
! {
Karsten Hopp 5ecd1b
!     get_cmd_output_as_rettv(argvars, rettv, TRUE);
Karsten Hopp 5ecd1b
  }
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  /*
Karsten Hopp 5ecd1b
*** ../vim-7.4.247/src/ex_cmds2.c	2013-11-09 03:31:45.000000000 +0100
Karsten Hopp 5ecd1b
--- src/ex_cmds2.c	2014-04-05 19:20:25.023157552 +0200
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 4341,4347 ****
Karsten Hopp 5ecd1b
      /* Find all available locales by running command "locale -a".  If this
Karsten Hopp 5ecd1b
       * doesn't work we won't have completion. */
Karsten Hopp 5ecd1b
      char_u *locale_a = get_cmd_output((char_u *)"locale -a",
Karsten Hopp 5ecd1b
! 							NULL, SHELL_SILENT);
Karsten Hopp 5ecd1b
      if (locale_a == NULL)
Karsten Hopp 5ecd1b
  	return NULL;
Karsten Hopp 5ecd1b
      ga_init2(&locales_ga, sizeof(char_u *), 20);
Karsten Hopp 5ecd1b
--- 4341,4347 ----
Karsten Hopp 5ecd1b
      /* Find all available locales by running command "locale -a".  If this
Karsten Hopp 5ecd1b
       * doesn't work we won't have completion. */
Karsten Hopp 5ecd1b
      char_u *locale_a = get_cmd_output((char_u *)"locale -a",
Karsten Hopp 5ecd1b
! 						    NULL, SHELL_SILENT, NULL);
Karsten Hopp 5ecd1b
      if (locale_a == NULL)
Karsten Hopp 5ecd1b
  	return NULL;
Karsten Hopp 5ecd1b
      ga_init2(&locales_ga, sizeof(char_u *), 20);
Karsten Hopp 5ecd1b
*** ../vim-7.4.247/src/misc1.c	2014-04-01 21:00:45.436733663 +0200
Karsten Hopp 5ecd1b
--- src/misc1.c	2014-04-05 19:21:36.603157708 +0200
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 10665,10671 ****
Karsten Hopp 5ecd1b
      else
Karsten Hopp 5ecd1b
  #endif
Karsten Hopp 5ecd1b
  	buffer = get_cmd_output(cmd, NULL,
Karsten Hopp 5ecd1b
! 				      (flags & EW_SILENT) ? SHELL_SILENT : 0);
Karsten Hopp 5ecd1b
      vim_free(cmd);
Karsten Hopp 5ecd1b
      if (buffer == NULL)
Karsten Hopp 5ecd1b
  	return 0;
Karsten Hopp 5ecd1b
--- 10665,10671 ----
Karsten Hopp 5ecd1b
      else
Karsten Hopp 5ecd1b
  #endif
Karsten Hopp 5ecd1b
  	buffer = get_cmd_output(cmd, NULL,
Karsten Hopp 5ecd1b
! 				(flags & EW_SILENT) ? SHELL_SILENT : 0, NULL);
Karsten Hopp 5ecd1b
      vim_free(cmd);
Karsten Hopp 5ecd1b
      if (buffer == NULL)
Karsten Hopp 5ecd1b
  	return 0;
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 10765,10777 ****
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  /*
Karsten Hopp 5ecd1b
   * Get the stdout of an external command.
Karsten Hopp 5ecd1b
   * Returns an allocated string, or NULL for error.
Karsten Hopp 5ecd1b
   */
Karsten Hopp 5ecd1b
      char_u *
Karsten Hopp 5ecd1b
! get_cmd_output(cmd, infile, flags)
Karsten Hopp 5ecd1b
      char_u	*cmd;
Karsten Hopp 5ecd1b
      char_u	*infile;	/* optional input file name */
Karsten Hopp 5ecd1b
      int		flags;		/* can be SHELL_SILENT */
Karsten Hopp 5ecd1b
  {
Karsten Hopp 5ecd1b
      char_u	*tempname;
Karsten Hopp 5ecd1b
      char_u	*command;
Karsten Hopp 5ecd1b
--- 10765,10780 ----
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  /*
Karsten Hopp 5ecd1b
   * Get the stdout of an external command.
Karsten Hopp 5ecd1b
+  * If "ret_len" is NULL replace NUL characters with NL.  When "ret_len" is not
Karsten Hopp 5ecd1b
+  * NULL store the length there.
Karsten Hopp 5ecd1b
   * Returns an allocated string, or NULL for error.
Karsten Hopp 5ecd1b
   */
Karsten Hopp 5ecd1b
      char_u *
Karsten Hopp 5ecd1b
! get_cmd_output(cmd, infile, flags, ret_len)
Karsten Hopp 5ecd1b
      char_u	*cmd;
Karsten Hopp 5ecd1b
      char_u	*infile;	/* optional input file name */
Karsten Hopp 5ecd1b
      int		flags;		/* can be SHELL_SILENT */
Karsten Hopp 5ecd1b
+     int		*ret_len;
Karsten Hopp 5ecd1b
  {
Karsten Hopp 5ecd1b
      char_u	*tempname;
Karsten Hopp 5ecd1b
      char_u	*command;
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 10841,10847 ****
Karsten Hopp 5ecd1b
  	vim_free(buffer);
Karsten Hopp 5ecd1b
  	buffer = NULL;
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
!     else
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
  	/* Change NUL into SOH, otherwise the string is truncated. */
Karsten Hopp 5ecd1b
  	for (i = 0; i < len; ++i)
Karsten Hopp 5ecd1b
--- 10844,10850 ----
Karsten Hopp 5ecd1b
  	vim_free(buffer);
Karsten Hopp 5ecd1b
  	buffer = NULL;
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
!     else if (ret_len == NULL)
Karsten Hopp 5ecd1b
      {
Karsten Hopp 5ecd1b
  	/* Change NUL into SOH, otherwise the string is truncated. */
Karsten Hopp 5ecd1b
  	for (i = 0; i < len; ++i)
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 10850,10855 ****
Karsten Hopp 5ecd1b
--- 10853,10860 ----
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  	buffer[len] = NUL;	/* make sure the buffer is terminated */
Karsten Hopp 5ecd1b
      }
Karsten Hopp 5ecd1b
+     else
Karsten Hopp 5ecd1b
+ 	*ret_len = len;
Karsten Hopp 5ecd1b
  
Karsten Hopp 5ecd1b
  done:
Karsten Hopp 5ecd1b
      vim_free(tempname);
Karsten Hopp 5ecd1b
*** ../vim-7.4.247/src/proto/misc1.pro	2013-11-06 04:01:31.000000000 +0100
Karsten Hopp 5ecd1b
--- src/proto/misc1.pro	2014-04-05 19:06:26.427155720 +0200
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 100,106 ****
Karsten Hopp 5ecd1b
  void remove_duplicates __ARGS((garray_T *gap));
Karsten Hopp 5ecd1b
  int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
Karsten Hopp 5ecd1b
  void addfile __ARGS((garray_T *gap, char_u *f, int flags));
Karsten Hopp 5ecd1b
! char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
Karsten Hopp 5ecd1b
  void FreeWild __ARGS((int count, char_u **files));
Karsten Hopp 5ecd1b
  int goto_im __ARGS((void));
Karsten Hopp 5ecd1b
  /* vim: set ft=c : */
Karsten Hopp 5ecd1b
--- 100,106 ----
Karsten Hopp 5ecd1b
  void remove_duplicates __ARGS((garray_T *gap));
Karsten Hopp 5ecd1b
  int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
Karsten Hopp 5ecd1b
  void addfile __ARGS((garray_T *gap, char_u *f, int flags));
Karsten Hopp 5ecd1b
! char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int *ret_len));
Karsten Hopp 5ecd1b
  void FreeWild __ARGS((int count, char_u **files));
Karsten Hopp 5ecd1b
  int goto_im __ARGS((void));
Karsten Hopp 5ecd1b
  /* vim: set ft=c : */
Karsten Hopp 5ecd1b
*** ../vim-7.4.247/src/version.c	2014-04-05 18:55:40.479154309 +0200
Karsten Hopp 5ecd1b
--- src/version.c	2014-04-05 19:07:12.447155821 +0200
Karsten Hopp 5ecd1b
***************
Karsten Hopp 5ecd1b
*** 736,737 ****
Karsten Hopp 5ecd1b
--- 736,739 ----
Karsten Hopp 5ecd1b
  {   /* Add new patch number below this line */
Karsten Hopp 5ecd1b
+ /**/
Karsten Hopp 5ecd1b
+     248,
Karsten Hopp 5ecd1b
  /**/
Karsten Hopp 5ecd1b
Karsten Hopp 5ecd1b
-- 
Karsten Hopp 5ecd1b
Tips for aliens in New York: Land anywhere.  Central Park, anywhere.
Karsten Hopp 5ecd1b
No one will care or indeed even notice.
Karsten Hopp 5ecd1b
		-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
Karsten Hopp 5ecd1b
Karsten Hopp 5ecd1b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 5ecd1b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 5ecd1b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 5ecd1b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///