diff.c: change return type to bool

Co-authored-by: Wayne Rowcliffe (@war1025)
This commit is contained in:
Charles Joachim
2016-01-28 15:20:35 -05:00
parent 7609a96a35
commit b3bdf9f356

View File

@@ -1531,37 +1531,37 @@ int diff_check(win_T *wp, linenr_T lnum)
return maxcount - dp->df_count[idx];
}
/// Compare two entries in diff "*dp" and return TRUE if they are equal.
/// Compare two entries in diff "dp" and return true if they are equal.
///
/// @param dp
/// @param idx1 First entry in diff "*dp"
/// @param idx2 Second entry in diff "*dp"
/// @param dp diff
/// @param idx1 first entry in diff "dp"
/// @param idx2 second entry in diff "dp"
///
/// @return return TRUE if two entires are equal.
static int diff_equal_entry(diff_T *dp, int idx1, int idx2)
/// @return true if two entires are equal.
static bool diff_equal_entry(diff_T *dp, int idx1, int idx2)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1)
{
if (dp->df_count[idx1] != dp->df_count[idx2]) {
return FALSE;
return false;
}
if (diff_check_sanity(curtab, dp) == FAIL) {
return FALSE;
return false;
}
int i;
for (i = 0; i < dp->df_count[idx1]; ++i) {
for (int i = 0; i < dp->df_count[idx1]; i++) {
char_u *line = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx1],
dp->df_lnum[idx1] + i, FALSE));
dp->df_lnum[idx1] + i, false));
int cmp = diff_cmp(line, ml_get_buf(curtab->tp_diffbuf[idx2],
dp->df_lnum[idx2] + i, FALSE));
dp->df_lnum[idx2] + i, false));
xfree(line);
if (cmp != 0) {
return FALSE;
return false;
}
}
return TRUE;
return true;
}
/// Compare strings "s1" and "s2" according to 'diffopt'.
@@ -1830,28 +1830,30 @@ int diffopt_changed(void)
return OK;
}
/// Return TRUE if 'diffopt' contains "horizontal".
///
/// @return TRUE if 'diffopt' contains "horizontal"
int diffopt_horizontal(void)
/// Check that "diffopt" contains "horizontal".
bool diffopt_horizontal(void)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return (diff_flags & DIFF_HORIZONTAL) != 0;
}
/// Find the difference within a changed line.
///
/// @param startp first char of the change
/// @param endp last char of the change
/// @param wp window whose current buffer to check
/// @param lnum line number to check within the buffer
/// @param startp first char of the change
/// @param endp last char of the change
///
/// @returns TRUE if the line was added, no other buffer has it.
int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
/// @return true if the line was added, no other buffer has it.
bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
char_u *line_new;
int si_org;
int si_new;
int ei_org;
int ei_new;
int added = TRUE;
bool added = true;
// Make a copy of the line, the next ml_get() will invalidate it.
char_u *line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE));
@@ -1860,7 +1862,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
if (idx == DB_COUNT) {
// cannot happen
xfree(line_org);
return FALSE;
return false;
}
// search for a change that includes "lnum" in the list of diffblocks.
@@ -1873,7 +1875,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
if ((dp == NULL) || (diff_check_sanity(curtab, dp) == FAIL)) {
xfree(line_org);
return FALSE;
return false;
}
int off = lnum - dp->df_lnum[idx];
@@ -1884,7 +1886,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
if (off >= dp->df_count[i]) {
continue;
}
added = FALSE;
added = false;
line_new = ml_get_buf(curtab->tp_diffbuf[i],
dp->df_lnum[i] + off, FALSE);
@@ -1956,21 +1958,22 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
return added;
}
/// Return TRUE if line "lnum" is not close to a diff block, this line should
/// Check that line "lnum" is not close to a diff block, this line should
/// be in a fold.
///
/// @param wp
/// @param lnum
/// @param wp window containing the buffer to check
/// @param lnum line number to check within the buffer
///
/// @return FALSE if there are no diff blocks at all in this window.
int diff_infold(win_T *wp, linenr_T lnum)
/// @return false if there are no diff blocks at all in this window.
bool diff_infold(win_T *wp, linenr_T lnum)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1)
{
int other = FALSE;
bool other = false;
diff_T *dp;
// Return if 'diff' isn't set.
if (!wp->w_p_diff) {
return FALSE;
return false;
}
int idx = -1;
@@ -1979,13 +1982,13 @@ int diff_infold(win_T *wp, linenr_T lnum)
if (curtab->tp_diffbuf[i] == wp->w_buffer) {
idx = i;
} else if (curtab->tp_diffbuf[i] != NULL) {
other = TRUE;
other = true;
}
}
// return here if there are no diffs in the window
if ((idx == -1) || !other) {
return FALSE;
return false;
}
if (curtab->tp_diff_invalid) {
@@ -1995,7 +1998,7 @@ int diff_infold(win_T *wp, linenr_T lnum)
// Return if there are no diff blocks. All lines will be folded.
if (curtab->tp_first_diff == NULL) {
return TRUE;
return true;
}
for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) {
@@ -2006,10 +2009,10 @@ int diff_infold(win_T *wp, linenr_T lnum)
// If this change ends before the line we have a match.
if (dp->df_lnum[idx] + dp->df_count[idx] + diff_context > lnum) {
return FALSE;
return false;
}
}
return TRUE;
return true;
}
/// "dp" and "do" commands.
@@ -2372,12 +2375,11 @@ static void diff_fold_update(diff_T *dp, int skip_idx)
}
}
/// Checks if the buffer is in diff-mode.
/// Checks that the buffer is in diff-mode.
///
/// @param buf The buffer to check.
///
/// @return TRUE if buffer "buf" is in diff-mode.
/// @param buf buffer to check.
bool diff_mode_buf(buf_T *buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1)
{
FOR_ALL_TABS(tp) {
if (diff_buf_idx_tp(buf, tp) != DB_COUNT) {