Skip to content

Commit 789a5c0

Browse files
committed
patch 8.0.0003
Problem: getwinvar() returns wrong Value of boolean and number options, especially non big endian systems. (James McCoy) Solution: Cast the pointer to long or int. (closes #1060)
1 parent b56e7ff commit 789a5c0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/option.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12363,8 +12363,10 @@ get_winbuf_options(int bufopt)
1236312363
{
1236412364
if (opt->flags & P_STRING)
1236512365
dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
12366+
else if (opt->flags & P_NUM)
12367+
dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
1236612368
else
12367-
dict_add_nr_str(d, opt->fullname, *varp, NULL);
12369+
dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
1236812370
}
1236912371
}
1237012372
}

src/testdir/test_bufwintabinfo.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,30 @@ function Test_get_buf_options()
8787
endfunc
8888

8989
function Test_get_win_options()
90+
if has('folding')
91+
set foldlevel=999
92+
endif
93+
set list
9094
let opts = getwinvar(1, '&')
9195
call assert_equal(v:t_dict, type(opts))
9296
call assert_equal(0, opts.linebreak)
97+
call assert_equal(1, opts.list)
98+
if has('folding')
99+
call assert_equal(999, opts.foldlevel)
100+
endif
93101
if has('signs')
94102
call assert_equal('auto', opts.signcolumn)
95103
endif
96104

97105
let opts = gettabwinvar(1, 1, '&')
98106
call assert_equal(v:t_dict, type(opts))
99107
call assert_equal(0, opts.linebreak)
108+
call assert_equal(1, opts.list)
100109
if has('signs')
101110
call assert_equal('auto', opts.signcolumn)
102111
endif
112+
set list&
113+
if has('folding')
114+
set foldlevel=0
115+
endif
103116
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
3,
767769
/**/
768770
2,
769771
/**/

0 commit comments

Comments
 (0)