# HG changeset patch
# User ZyX <[email protected]>
# Date 1383995203 -14400
# Sat Nov 09 15:06:43 2013 +0400
# Branch NL-funcs
# Node ID b719d5d95852adc804831af9c524db3640382067
# Parent c25ccecf79b681e79005bb0b8aed9153094ce207
Add readshell() function
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1893,6 +1893,7 @@
List items from {expr} to {max}
readfile( {fname} [, {binary} [, {max}]])
List get list of lines from file {fname}
+readshell( {expr} [, {input}]) List output of shell command/filter {expr}
reltime( [{start} [, {end}]]) List get time value
reltimestr( {time}) String turn time value into a String
remote_expr( {server}, {string} [, {idvar}])
@@ -4742,6 +4743,15 @@
the result is an empty list.
Also see |writefile()|.
+readshell({expr} [, {input}]) *readshell()*
+ Same as |system()|, but returns a |List| with lines (parts of
+ output separated by NL) with NULs transformed into NLs. Output
+ is the same as |readfile()| will output with {binary} argument
+ set to "b".
+
+ Returns an empty string on error, so be careful not to run
+ into |E706|.
+
reltime([{start} [, {end}]]) *reltime()*
Return an item that represents a time value. The format of
the item depends on the system. It can be passed to
@@ -5931,7 +5941,8 @@
is filtered to replace <CR> with <NL> for Macintosh, and
<CR><NL> with <NL> for DOS-like systems.
To avoid the string being truncated at a NUL, all NUL
- characters are replaced with SOH (0x01).
+ characters are replaced with SOH (0x01). See |readshell()| if
+ you want to distinguish NULs and SOHs.
The command executed is constructed using several options:
'shell' 'shellcmdflag' 'shellxquote' {expr} 'shellredir' {tmp}
'shellxquote'
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -644,6 +644,7 @@
#endif
static void f_range __ARGS((typval_T *argvars, typval_T *rettv));
static void f_readfile __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_readshell __ARGS((typval_T *argvars, typval_T *rettv));
static void f_reltime __ARGS((typval_T *argvars, typval_T *rettv));
static void f_reltimestr __ARGS((typval_T *argvars, typval_T *rettv));
static void f_remote_expr __ARGS((typval_T *argvars, typval_T *rettv));
@@ -831,6 +832,7 @@
static int search_cmn __ARGS((typval_T *argvars, pos_T *match_pos, int
*flagsp));
static void setwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off));
static int write_list __ARGS((FILE *fd, list_T *list, int binary));
+static void get_cmd_output_as_rettv __ARGS((typval_T *argvars, typval_T
*rettv, int retlist));
#ifdef EBCDIC
@@ -8082,6 +8084,7 @@
#endif
{"range", 1, 3, f_range},
{"readfile", 1, 3, f_readfile},
+ {"readshell", 1, 2, f_readshell},
{"reltime", 0, 2, f_reltime},
{"reltimestr", 1, 1, f_reltimestr},
{"remote_expr", 2, 3, f_remote_expr},
@@ -15009,6 +15012,17 @@
fclose(fd);
}
+/*
+ * "readshell()" function
+ */
+ static void
+f_readshell(argvars, rettv)
+ typval_T *argvars;
+ typval_T *rettv;
+{
+ get_cmd_output_as_rettv(argvars, rettv, TRUE);
+}
+
#if defined(FEAT_RELTIME)
static int list2proftime __ARGS((typval_T *arg, proftime_T *tm));
@@ -18160,13 +18174,11 @@
#endif
}
-/*
- * "system()" function
- */
- static void
-f_system(argvars, rettv)
- typval_T *argvars;
- typval_T *rettv;
+ static void
+get_cmd_output_as_rettv(argvars, rettv, retlist)
+ typval_T *argvars;
+ typval_T *rettv;
+ int retlist;
{
char_u *res = NULL;
char_u *p;
@@ -18174,9 +18186,10 @@
char_u buf[NUMBUFLEN];
int err = FALSE;
FILE *fd;
+ list_T *list = NULL;
if (check_restricted() || check_secure())
- goto done;
+ goto errret;
if (argvars[1].v_type != VAR_UNKNOWN)
{
@@ -18187,14 +18200,14 @@
if ((infile = vim_tempname('i')) == NULL)
{
EMSG(_(e_notmp));
- goto done;
+ goto errret;
}
fd = mch_fopen((char *)infile, WRITEBIN);
if (fd == NULL)
{
EMSG2(_(e_notopen), infile);
- goto done;
+ goto errret;
}
if (argvars[1].v_type == VAR_LIST)
{
@@ -18207,7 +18220,7 @@
if (p == NULL)
{
fclose(fd);
- goto done; /* type error; errmsg already given */
+ goto errret; /* type error; errmsg already given */
}
if (fwrite(p, STRLEN(p), 1, fd) != 1)
err = TRUE;
@@ -18217,52 +18230,133 @@
if (err)
{
EMSG(_("E677: Error writing temp file"));
- goto done;
- }
- }
-
- res = get_cmd_output(get_tv_string(&argvars[0]), infile,
- SHELL_SILENT | SHELL_COOKED);
+ goto errret;
+ }
+ }
+
+ if (retlist)
+ {
+ int len;
+ listitem_T *li;
+ char_u *s = NULL;
+ char_u *start;
+ char_u *end;
+ char_u *p;
+ int i;
+
+ res = get_cmd_output(get_tv_string(&argvars[0]), infile,
+ SHELL_SILENT | SHELL_COOKED,
+ &len);
+
+ if (res == NULL)
+ goto errret;
+
+ list = list_alloc();
+ if (list == NULL)
+ goto errret;
+
+ for (i = 0 ; i <= len ; ++i)
+ {
+ start = res + i;
+ for (end = start; i < len && *end != NL; ++end)
+ ++i;
+
+ s = vim_strnsave(start, (int) (end - start));
+ if (s == NULL)
+ goto errret;
+
+ for (p = s, end = s + (end - start); p < end; ++p)
+ if (*p == NUL)
+ *p = NL;
+
+ li = listitem_alloc();
+ if (li == NULL)
+ {
+ vim_free(s);
+ goto errret;
+ }
+
+ li->li_tv.v_type = VAR_STRING;
+ li->li_tv.vval.v_string = s;
+
+ list_append(list, li);
+ }
+
+ vim_free(res);
+
+ rettv->v_type = VAR_LIST;
+ rettv->vval.v_list = list;
+ }
+ else
+ {
+ res = get_cmd_output(get_tv_string(&argvars[0]), infile,
+ SHELL_SILENT | SHELL_COOKED,
+ NULL);
#ifdef USE_CR
- /* translate <CR> into <NL> */
- if (res != NULL)
- {
- char_u *s;
-
- for (s = res; *s; ++s)
- {
- if (*s == CAR)
- *s = NL;
- }
- }
+ /* translate <CR> into <NL> */
+ if (res != NULL)
+ {
+ char_u *s;
+
+ for (s = res; *s; ++s)
+ {
+ if (*s == CAR)
+ *s = NL;
+ }
+ }
#else
# ifdef USE_CRNL
- /* translate <CR><NL> into <NL> */
- if (res != NULL)
- {
- char_u *s, *d;
-
- d = res;
- for (s = res; *s; ++s)
- {
- if (s[0] == CAR && s[1] == NL)
- ++s;
- *d++ = *s;
- }
- *d = NUL;
- }
-# endif
-#endif
-
-done:
+ /* translate <CR><NL> into <NL> */
+ if (res != NULL)
+ {
+ char_u *s, *d;
+
+ d = res;
+ for (s = res; *s; ++s)
+ {
+ if (s[0] == CAR && s[1] == NL)
+ ++s;
+ *d++ = *s;
+ }
+ *d = NUL;
+ }
+# endif
+#endif
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = res;
+ }
+
if (infile != NULL)
{
mch_remove(infile);
vim_free(infile);
}
- rettv->v_type = VAR_STRING;
- rettv->vval.v_string = res;
+ return;
+
+errret:
+ if (infile != NULL)
+ {
+ mch_remove(infile);
+ vim_free(infile);
+ }
+ if (res != NULL)
+ vim_free(res);
+ if (list != NULL)
+ list_free(list, TRUE);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+}
+
+/*
+ * "system()" function
+ */
+ static void
+f_system(argvars, rettv)
+ typval_T *argvars;
+ typval_T *rettv;
+{
+ get_cmd_output_as_rettv(argvars, rettv, FALSE);
}
/*
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -4329,7 +4329,8 @@
/* Find all available locales by running command "locale -a". If this
* doesn't work we won't have completion. */
char_u *locale_a = get_cmd_output((char_u *)"locale -a",
- NULL, SHELL_SILENT);
+ NULL, SHELL_SILENT,
+ NULL);
if (locale_a == NULL)
return NULL;
ga_init2(&locales_ga, sizeof(char_u *), 20);
diff --git a/src/misc1.c b/src/misc1.c
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -10720,7 +10720,8 @@
else
#endif
buffer = get_cmd_output(cmd, NULL,
- (flags & EW_SILENT) ? SHELL_SILENT : 0);
+ (flags & EW_SILENT) ? SHELL_SILENT : 0,
+ NULL);
vim_free(cmd);
if (buffer == NULL)
return 0;
@@ -10823,10 +10824,11 @@
* Returns an allocated string, or NULL for error.
*/
char_u *
-get_cmd_output(cmd, infile, flags)
+get_cmd_output(cmd, infile, flags, ret_len)
char_u *cmd;
char_u *infile; /* optional input file name */
int flags; /* can be SHELL_SILENT */
+ int *ret_len;
{
char_u *tempname;
char_u *command;
@@ -10896,7 +10898,7 @@
vim_free(buffer);
buffer = NULL;
}
- else
+ else if (ret_len == NULL)
{
/* Change NUL into SOH, otherwise the string is truncated. */
for (i = 0; i < len; ++i)
@@ -10905,6 +10907,8 @@
buffer[len] = NUL; /* make sure the buffer is terminated */
}
+ else
+ *ret_len = len;
done:
vim_free(tempname);
diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro
--- a/src/proto/misc1.pro
+++ b/src/proto/misc1.pro
@@ -98,7 +98,7 @@
void remove_duplicates __ARGS((garray_T *gap));
int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file,
char_u ***file, int flags));
void addfile __ARGS((garray_T *gap, char_u *f, int flags));
-char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
+char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int
*ret_len));
void FreeWild __ARGS((int count, char_u **files));
int goto_im __ARGS((void));
/* vim: set ft=c : */
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -crN -a vim-small-patches.c25ccecf79b6/runtime/doc/eval.txt vim-small-patches.b719d5d95852/runtime/doc/eval.txt
*** vim-small-patches.c25ccecf79b6/runtime/doc/eval.txt 2013-11-09 15:07:13.565118811 +0400
--- vim-small-patches.b719d5d95852/runtime/doc/eval.txt 2013-11-09 15:07:13.617118813 +0400
***************
*** 1893,1898 ****
--- 1893,1899 ----
List items from {expr} to {max}
readfile( {fname} [, {binary} [, {max}]])
List get list of lines from file {fname}
+ readshell( {expr} [, {input}]) List output of shell command/filter {expr}
reltime( [{start} [, {end}]]) List get time value
reltimestr( {time}) String turn time value into a String
remote_expr( {server}, {string} [, {idvar}])
***************
*** 4742,4747 ****
--- 4743,4757 ----
the result is an empty list.
Also see |writefile()|.
+ readshell({expr} [, {input}]) *readshell()*
+ Same as |system()|, but returns a |List| with lines (parts of
+ output separated by NL) with NULs transformed into NLs. Output
+ is the same as |readfile()| will output with {binary} argument
+ set to "b".
+
+ Returns an empty string on error, so be careful not to run
+ into |E706|.
+
reltime([{start} [, {end}]]) *reltime()*
Return an item that represents a time value. The format of
the item depends on the system. It can be passed to
***************
*** 5931,5937 ****
is filtered to replace <CR> with <NL> for Macintosh, and
<CR><NL> with <NL> for DOS-like systems.
To avoid the string being truncated at a NUL, all NUL
! characters are replaced with SOH (0x01).
The command executed is constructed using several options:
'shell' 'shellcmdflag' 'shellxquote' {expr} 'shellredir' {tmp} 'shellxquote'
--- 5941,5948 ----
is filtered to replace <CR> with <NL> for Macintosh, and
<CR><NL> with <NL> for DOS-like systems.
To avoid the string being truncated at a NUL, all NUL
! characters are replaced with SOH (0x01). See |readshell()| if
! you want to distinguish NULs and SOHs.
The command executed is constructed using several options:
'shell' 'shellcmdflag' 'shellxquote' {expr} 'shellredir' {tmp} 'shellxquote'
diff -crN -a vim-small-patches.c25ccecf79b6/src/eval.c vim-small-patches.b719d5d95852/src/eval.c
*** vim-small-patches.c25ccecf79b6/src/eval.c 2013-11-09 15:07:13.588118812 +0400
--- vim-small-patches.b719d5d95852/src/eval.c 2013-11-09 15:07:13.609118813 +0400
***************
*** 644,649 ****
--- 644,650 ----
#endif
static void f_range __ARGS((typval_T *argvars, typval_T *rettv));
static void f_readfile __ARGS((typval_T *argvars, typval_T *rettv));
+ static void f_readshell __ARGS((typval_T *argvars, typval_T *rettv));
static void f_reltime __ARGS((typval_T *argvars, typval_T *rettv));
static void f_reltimestr __ARGS((typval_T *argvars, typval_T *rettv));
static void f_remote_expr __ARGS((typval_T *argvars, typval_T *rettv));
***************
*** 831,836 ****
--- 832,838 ----
static int search_cmn __ARGS((typval_T *argvars, pos_T *match_pos, int *flagsp));
static void setwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off));
static int write_list __ARGS((FILE *fd, list_T *list, int binary));
+ static void get_cmd_output_as_rettv __ARGS((typval_T *argvars, typval_T *rettv, int retlist));
#ifdef EBCDIC
***************
*** 8082,8087 ****
--- 8084,8090 ----
#endif
{"range", 1, 3, f_range},
{"readfile", 1, 3, f_readfile},
+ {"readshell", 1, 2, f_readshell},
{"reltime", 0, 2, f_reltime},
{"reltimestr", 1, 1, f_reltimestr},
{"remote_expr", 2, 3, f_remote_expr},
***************
*** 15009,15014 ****
--- 15012,15028 ----
fclose(fd);
}
+ /*
+ * "readshell()" function
+ */
+ static void
+ f_readshell(argvars, rettv)
+ typval_T *argvars;
+ typval_T *rettv;
+ {
+ get_cmd_output_as_rettv(argvars, rettv, TRUE);
+ }
+
#if defined(FEAT_RELTIME)
static int list2proftime __ARGS((typval_T *arg, proftime_T *tm));
***************
*** 18160,18172 ****
#endif
}
- /*
- * "system()" function
- */
static void
! f_system(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
char_u *res = NULL;
char_u *p;
--- 18174,18184 ----
#endif
}
static void
! get_cmd_output_as_rettv(argvars, rettv, retlist)
typval_T *argvars;
typval_T *rettv;
+ int retlist;
{
char_u *res = NULL;
char_u *p;
***************
*** 18174,18182 ****
char_u buf[NUMBUFLEN];
int err = FALSE;
FILE *fd;
if (check_restricted() || check_secure())
! goto done;
if (argvars[1].v_type != VAR_UNKNOWN)
{
--- 18186,18195 ----
char_u buf[NUMBUFLEN];
int err = FALSE;
FILE *fd;
+ list_T *list = NULL;
if (check_restricted() || check_secure())
! goto errret;
if (argvars[1].v_type != VAR_UNKNOWN)
{
***************
*** 18187,18200 ****
if ((infile = vim_tempname('i')) == NULL)
{
EMSG(_(e_notmp));
! goto done;
}
fd = mch_fopen((char *)infile, WRITEBIN);
if (fd == NULL)
{
EMSG2(_(e_notopen), infile);
! goto done;
}
if (argvars[1].v_type == VAR_LIST)
{
--- 18200,18213 ----
if ((infile = vim_tempname('i')) == NULL)
{
EMSG(_(e_notmp));
! goto errret;
}
fd = mch_fopen((char *)infile, WRITEBIN);
if (fd == NULL)
{
EMSG2(_(e_notopen), infile);
! goto errret;
}
if (argvars[1].v_type == VAR_LIST)
{
***************
*** 18207,18213 ****
if (p == NULL)
{
fclose(fd);
! goto done; /* type error; errmsg already given */
}
if (fwrite(p, STRLEN(p), 1, fd) != 1)
err = TRUE;
--- 18220,18226 ----
if (p == NULL)
{
fclose(fd);
! goto errret; /* type error; errmsg already given */
}
if (fwrite(p, STRLEN(p), 1, fd) != 1)
err = TRUE;
***************
*** 18217,18268 ****
if (err)
{
EMSG(_("E677: Error writing temp file"));
! goto done;
}
}
! res = get_cmd_output(get_tv_string(&argvars[0]), infile,
! SHELL_SILENT | SHELL_COOKED);
! #ifdef USE_CR
! /* translate <CR> into <NL> */
! if (res != NULL)
{
! char_u *s;
! for (s = res; *s; ++s)
{
! if (*s == CAR)
! *s = NL;
}
- }
#else
# ifdef USE_CRNL
! /* translate <CR><NL> into <NL> */
! if (res != NULL)
! {
! char_u *s, *d;
!
! d = res;
! for (s = res; *s; ++s)
{
! if (s[0] == CAR && s[1] == NL)
! ++s;
! *d++ = *s;
}
- *d = NUL;
- }
# endif
#endif
! done:
if (infile != NULL)
{
mch_remove(infile);
vim_free(infile);
}
rettv->v_type = VAR_STRING;
! rettv->vval.v_string = res;
}
/*
--- 18230,18362 ----
if (err)
{
EMSG(_("E677: Error writing temp file"));
! goto errret;
}
}
! if (retlist)
! {
! int len;
! listitem_T *li;
! char_u *s = NULL;
! char_u *start;
! char_u *end;
! char_u *p;
! int i;
!
! res = get_cmd_output(get_tv_string(&argvars[0]), infile,
! SHELL_SILENT | SHELL_COOKED,
! &len);
!
! if (res == NULL)
! goto errret;
!
! list = list_alloc();
! if (list == NULL)
! goto errret;
!
! for (i = 0 ; i <= len ; ++i)
! {
! start = res + i;
! for (end = start; i < len && *end != NL; ++end)
! ++i;
! s = vim_strnsave(start, (int) (end - start));
! if (s == NULL)
! goto errret;
!
! for (p = s, end = s + (end - start); p < end; ++p)
! if (*p == NUL)
! *p = NL;
!
! li = listitem_alloc();
! if (li == NULL)
! {
! vim_free(s);
! goto errret;
! }
!
! li->li_tv.v_type = VAR_STRING;
! li->li_tv.vval.v_string = s;
!
! list_append(list, li);
! }
!
! vim_free(res);
!
! rettv->v_type = VAR_LIST;
! rettv->vval.v_list = list;
! }
! else
{
! res = get_cmd_output(get_tv_string(&argvars[0]), infile,
! SHELL_SILENT | SHELL_COOKED,
! NULL);
! #ifdef USE_CR
! /* translate <CR> into <NL> */
! if (res != NULL)
{
! char_u *s;
!
! for (s = res; *s; ++s)
! {
! if (*s == CAR)
! *s = NL;
! }
}
#else
# ifdef USE_CRNL
! /* translate <CR><NL> into <NL> */
! if (res != NULL)
{
! char_u *s, *d;
!
! d = res;
! for (s = res; *s; ++s)
! {
! if (s[0] == CAR && s[1] == NL)
! ++s;
! *d++ = *s;
! }
! *d = NUL;
}
# endif
#endif
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = res;
+ }
+
+ if (infile != NULL)
+ {
+ mch_remove(infile);
+ vim_free(infile);
+ }
+ return;
! errret:
if (infile != NULL)
{
mch_remove(infile);
vim_free(infile);
}
+ if (res != NULL)
+ vim_free(res);
+ if (list != NULL)
+ list_free(list, TRUE);
rettv->v_type = VAR_STRING;
! rettv->vval.v_string = NULL;
! }
!
! /*
! * "system()" function
! */
! static void
! f_system(argvars, rettv)
! typval_T *argvars;
! typval_T *rettv;
! {
! get_cmd_output_as_rettv(argvars, rettv, FALSE);
}
/*
diff -crN -a vim-small-patches.c25ccecf79b6/src/ex_cmds2.c vim-small-patches.b719d5d95852/src/ex_cmds2.c
*** vim-small-patches.c25ccecf79b6/src/ex_cmds2.c 2013-11-09 15:07:13.567118811 +0400
--- vim-small-patches.b719d5d95852/src/ex_cmds2.c 2013-11-09 15:07:13.619118813 +0400
***************
*** 4329,4335 ****
/* Find all available locales by running command "locale -a". If this
* doesn't work we won't have completion. */
char_u *locale_a = get_cmd_output((char_u *)"locale -a",
! NULL, SHELL_SILENT);
if (locale_a == NULL)
return NULL;
ga_init2(&locales_ga, sizeof(char_u *), 20);
--- 4329,4336 ----
/* Find all available locales by running command "locale -a". If this
* doesn't work we won't have completion. */
char_u *locale_a = get_cmd_output((char_u *)"locale -a",
! NULL, SHELL_SILENT,
! NULL);
if (locale_a == NULL)
return NULL;
ga_init2(&locales_ga, sizeof(char_u *), 20);
diff -crN -a vim-small-patches.c25ccecf79b6/src/misc1.c vim-small-patches.b719d5d95852/src/misc1.c
*** vim-small-patches.c25ccecf79b6/src/misc1.c 2013-11-09 15:07:13.555118811 +0400
--- vim-small-patches.b719d5d95852/src/misc1.c 2013-11-09 15:07:13.625118813 +0400
***************
*** 10720,10726 ****
else
#endif
buffer = get_cmd_output(cmd, NULL,
! (flags & EW_SILENT) ? SHELL_SILENT : 0);
vim_free(cmd);
if (buffer == NULL)
return 0;
--- 10720,10727 ----
else
#endif
buffer = get_cmd_output(cmd, NULL,
! (flags & EW_SILENT) ? SHELL_SILENT : 0,
! NULL);
vim_free(cmd);
if (buffer == NULL)
return 0;
***************
*** 10823,10832 ****
* Returns an allocated string, or NULL for error.
*/
char_u *
! get_cmd_output(cmd, infile, flags)
char_u *cmd;
char_u *infile; /* optional input file name */
int flags; /* can be SHELL_SILENT */
{
char_u *tempname;
char_u *command;
--- 10824,10834 ----
* Returns an allocated string, or NULL for error.
*/
char_u *
! get_cmd_output(cmd, infile, flags, ret_len)
char_u *cmd;
char_u *infile; /* optional input file name */
int flags; /* can be SHELL_SILENT */
+ int *ret_len;
{
char_u *tempname;
char_u *command;
***************
*** 10896,10902 ****
vim_free(buffer);
buffer = NULL;
}
! else
{
/* Change NUL into SOH, otherwise the string is truncated. */
for (i = 0; i < len; ++i)
--- 10898,10904 ----
vim_free(buffer);
buffer = NULL;
}
! else if (ret_len == NULL)
{
/* Change NUL into SOH, otherwise the string is truncated. */
for (i = 0; i < len; ++i)
***************
*** 10905,10910 ****
--- 10907,10914 ----
buffer[len] = NUL; /* make sure the buffer is terminated */
}
+ else
+ *ret_len = len;
done:
vim_free(tempname);
diff -crN -a vim-small-patches.c25ccecf79b6/src/proto/misc1.pro vim-small-patches.b719d5d95852/src/proto/misc1.pro
*** vim-small-patches.c25ccecf79b6/src/proto/misc1.pro 2013-11-09 15:07:13.589118812 +0400
--- vim-small-patches.b719d5d95852/src/proto/misc1.pro 2013-11-09 15:07:13.625118813 +0400
***************
*** 98,104 ****
void remove_duplicates __ARGS((garray_T *gap));
int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
void addfile __ARGS((garray_T *gap, char_u *f, int flags));
! char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
void FreeWild __ARGS((int count, char_u **files));
int goto_im __ARGS((void));
/* vim: set ft=c : */
--- 98,104 ----
void remove_duplicates __ARGS((garray_T *gap));
int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
void addfile __ARGS((garray_T *gap, char_u *f, int flags));
! char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int *ret_len));
void FreeWild __ARGS((int count, char_u **files));
int goto_im __ARGS((void));
/* vim: set ft=c : */