• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révisionc2d8b596dd0f35910e6711f68b71b03a183cc112 (tree)
l'heure2020-10-18 02:00:05
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.1857: Vim9: using job_status() on an unused var gives an error

Commit: https://github.com/vim/vim/commit/218450ad5ea1f9f033b06754a29502d86100ff65
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 17 18:51:52 2020 +0200

patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Problem: Vim9: using job_status() on an unused var gives an error.
Solution: Return "fail". (closes https://github.com/vim/vim/issues/7158)

Change Summary

Modification

diff -r c1bb78e32bf1 -r c2d8b596dd0f src/job.c
--- a/src/job.c Sat Oct 17 17:45:05 2020 +0200
+++ b/src/job.c Sat Oct 17 19:00:05 2020 +0200
@@ -1894,12 +1894,21 @@
18941894 void
18951895 f_job_status(typval_T *argvars, typval_T *rettv)
18961896 {
1897- job_T *job = get_job_arg(&argvars[0]);
1897+ if (argvars[0].v_type == VAR_JOB && argvars[0].vval.v_job == NULL)
1898+ {
1899+ // A job that never started returns "fail".
1900+ rettv->v_type = VAR_STRING;
1901+ rettv->vval.v_string = vim_strsave((char_u *)"fail");
1902+ }
1903+ else
1904+ {
1905+ job_T *job = get_job_arg(&argvars[0]);
18981906
1899- if (job != NULL)
1900- {
1901- rettv->v_type = VAR_STRING;
1902- rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
1907+ if (job != NULL)
1908+ {
1909+ rettv->v_type = VAR_STRING;
1910+ rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
1911+ }
19031912 }
19041913 }
19051914
diff -r c1bb78e32bf1 -r c2d8b596dd0f src/testdir/test_vim9_assign.vim
--- a/src/testdir/test_vim9_assign.vim Sat Oct 17 17:45:05 2020 +0200
+++ b/src/testdir/test_vim9_assign.vim Sat Oct 17 19:00:05 2020 +0200
@@ -74,7 +74,11 @@
7474
7575 if has('channel')
7676 var chan1: channel
77+ assert_equal('fail', ch_status(chan1))
78+
7779 var job1: job
80+ assert_equal('fail', job_status(job1))
81+
7882 # calling job_start() is in test_vim9_fails.vim, it causes leak reports
7983 endif
8084 if has('float')
diff -r c1bb78e32bf1 -r c2d8b596dd0f src/version.c
--- a/src/version.c Sat Oct 17 17:45:05 2020 +0200
+++ b/src/version.c Sat Oct 17 19:00:05 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1857,
755+/**/
754756 1856,
755757 /**/
756758 1855,
Afficher sur ancien navigateur de dépôt.