From 87ff2682d7856c508311eeab5bd65c2505fc61d3 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 30 Oct 2016 23:18:29 -0400 Subject: Use int as the standard type for boolean options. All options are accessed by passing char_u pointers around, casting the pointer to the right pointer type for the specific option, and then dereferencing that pointer. This dance works fine on little-endian systems when some bool options are int types (as in Vim) and some are bool types (as would make more sense), but on big-endian systems *(int *)varp when varp is pointing to a bool will read random memory. Therefore, all boolean options must remain a consistent type and int is currently the easiest to choose. --- src/nvim/option.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 81919c00d2..5f338ea65f 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2527,7 +2527,7 @@ did_set_string_option ( else if (varp == &p_sbo) { if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) errmsg = e_invarg; - } else if (varp == &p_ambw || (bool *)varp == &p_emoji) { + } else if (varp == &p_ambw || (int *)varp == &p_emoji) { // 'ambiwidth' if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) { errmsg = e_invarg; @@ -3720,7 +3720,7 @@ set_bool_option ( did_set_title(FALSE); } else if ((int *)varp == &p_icon) { did_set_title(TRUE); - } else if ((bool *)varp == &curbuf->b_changed) { + } else if ((int *)varp == &curbuf->b_changed) { if (!value) save_file_ff(curbuf); /* Buffer is unchanged */ redraw_titles(); @@ -3750,10 +3750,10 @@ set_bool_option ( else if ((int *)varp == &curwin->w_p_wrap) { if (curwin->w_p_wrap) curwin->w_leftcol = 0; - } else if ((bool *)varp == &p_ea) { + } else if ((int *)varp == &p_ea) { if (p_ea && !old_value) win_equal(curwin, false, 0); - } else if ((bool *)varp == &p_acd) { + } else if ((int *)varp == &p_acd) { /* Change directories when the 'acd' option is set now. */ do_autochdir(); } @@ -4513,7 +4513,7 @@ get_option_value ( else { /* Special case: 'modified' is b_changed, but we also want to consider * it set when 'ff' or 'fenc' changed. */ - if ((bool *)varp == &curbuf->b_changed) + if ((int *)varp == &curbuf->b_changed) *numval = curbufIsChanged(); else *numval = *(int *)varp; @@ -4885,8 +4885,8 @@ showoneopt ( varp = get_varp_scope(p, opt_flags); /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ - if ((p->flags & P_BOOL) && ((bool *)varp == &curbuf->b_changed - ? !curbufIsChanged() : !*(bool *)varp)) + if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed + ? !curbufIsChanged() : !*(int *)varp)) MSG_PUTS("no"); else if ((p->flags & P_BOOL) && *(int *)varp < 0) MSG_PUTS("--"); -- cgit