patch 9.2.0365: using int as bool

Problem:  using int as bool
Solution: refactor: use bool type for internal flags in buf_T
          (Hirohito Higashi)

Change the type of 23 internal state flag fields in buf_T from int
to bool for improved type clarity and code readability.

These fields are pure boolean flags that are never accessed via the
option system's varp (which uses *(int *)varp = value), never compared
with int fields holding non-0/1 values, and never use tristate values.

Converted fields:
- State flags: b_dev_valid, b_saving, b_mod_set, b_new_change,
  b_marks_read, b_modified_was_set, b_did_filetype, b_keep_filetype,
  b_au_did_filetype, b_u_synced, b_scanned, b_p_initialized
- Characteristic flags: b_has_textprop, b_may_swap, b_did_warn,
  b_help, b_spell, b_shortname, b_has_sign_column, b_netbeans_file,
  b_was_netbeans_file, b_write_to_channel, b_diff_failed

All TRUE/FALSE assignments to these fields have been updated to
true/false accordingly. The type of temporary save variables
(e.g. help_save in tag.c) has also been adjusted to bool.

Option value fields (b_p_XXX) are kept as int because they are
accessed via the option system and some use tristate (-1) semantics.
Fields compared with int option values (b_start_eof, b_start_eol,
b_start_bomb) are also kept as int to preserve comparison integrity.

closes: #20020

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi
2026-04-19 20:10:20 +00:00
committed by Christian Brabandt
parent 618a327ce6
commit 1966a1c896
27 changed files with 116 additions and 114 deletions
+5 -5
View File
@@ -1160,7 +1160,7 @@ buf_write(
got_int = FALSE;
// Mark the buffer as 'being saved' to prevent changed buffer warnings
buf->b_saving = TRUE;
buf->b_saving = true;
// If we are not appending or filtering, the file exists, and the
// 'writebackup', 'backup' or 'patchmode' option is set, need a backup.
@@ -1407,13 +1407,13 @@ buf_write(
// may try again with 'shortname' set
if (!(buf->b_shortname || buf->b_p_sn))
{
buf->b_shortname = TRUE;
buf->b_shortname = true;
did_set_shortname = TRUE;
continue;
}
// setting shortname didn't help
if (did_set_shortname)
buf->b_shortname = FALSE;
buf->b_shortname = false;
break;
}
#endif
@@ -2543,7 +2543,7 @@ fail:
nofail:
// Done saving, we accept changed buffer warnings again
buf->b_saving = FALSE;
buf->b_saving = false;
vim_free(backup);
if (buffer != smallbuf)
@@ -2661,7 +2661,7 @@ nofail:
#ifdef FEAT_VIMINFO
// Make sure marks will be written out to the viminfo file later, even when
// the file is new.
curbuf->b_marks_read = TRUE;
curbuf->b_marks_read = true;
#endif
got_int |= prev_got_int;