diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-05 20:51:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-05 20:51:38 +0200 |
commit | 1328bde9d406aa1292e92673fa8a026889424e79 (patch) | |
tree | a0415264993e4c6bc6ecf5d982aa20032b5d5af4 /src/channel.c | |
parent | c6d71532dda0b3a244907bb5d1826f9340f7571d (diff) |
patch 8.2.2944: Vim9: no error when using job or channel as a stringv8.2.2944
Problem: Vim9: no error when using job or channel as a string.
Solution: Be more strict about conversion to string. (closes #8312)
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/channel.c b/src/channel.c index fa329bdba3..2a93e2578c 100644 --- a/src/channel.c +++ b/src/channel.c @@ -5015,4 +5015,22 @@ f_ch_status(typval_T *argvars, typval_T *rettv) rettv->vval.v_string = vim_strsave((char_u *)channel_status(channel, part)); } +/* + * Get a string with information about the channel in "varp" in "buf". + * "buf" must be at least NUMBUFLEN long. + */ + char_u * +channel_to_string_buf(typval_T *varp, char_u *buf) +{ + channel_T *channel = varp->vval.v_channel; + char *status = channel_status(channel, -1); + + if (channel == NULL) + vim_snprintf((char *)buf, NUMBUFLEN, "channel %s", status); + else + vim_snprintf((char *)buf, NUMBUFLEN, + "channel %d %s", channel->ch_id, status); + return buf; +} + #endif // FEAT_JOB_CHANNEL |