aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-10-30 23:18:29 -0400
committerJames McCoy <jamessan@jamessan.com>2016-11-02 10:06:26 -0400
commit87ff2682d7856c508311eeab5bd65c2505fc61d3 (patch)
treea25e72c29a2a8dc12310962d897a96fdf92f38c1 /src/nvim/option.c
parent349fa0048b7d45875daf96eefca0da163cd3a82f (diff)
downloadrneovim-87ff2682d7856c508311eeab5bd65c2505fc61d3.tar.gz
rneovim-87ff2682d7856c508311eeab5bd65c2505fc61d3.tar.bz2
rneovim-87ff2682d7856c508311eeab5bd65c2505fc61d3.zip
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.
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c14
1 files changed, 7 insertions, 7 deletions
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("--");