Merge pull request #4103 from cacplate/pr-3695

charset.c: change return type to bool
This commit is contained in:
Björn Linse 2016-02-09 18:18:53 +01:00
commit 3be74ac634

View File

@ -799,32 +799,35 @@ unsigned int win_linetabsize(win_T *wp, char_u *line, colnr_T len)
return (unsigned int)col;
}
/// Return TRUE if 'c' is a normal identifier character:
///
/// Check that "c" is a normal identifier character:
/// Letters and characters from the 'isident' option.
///
/// @param c
///
/// @return TRUE if 'c' is a normal identifier character.
int vim_isIDc(int c)
/// @param c character to check
bool vim_isIDc(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return c > 0 && c < 0x100 && (chartab[c] & CT_ID_CHAR);
}
/// return TRUE if 'c' is a keyword character: Letters and characters from
/// 'iskeyword' option for current buffer.
///
/// Check that "c" is a keyword character:
/// Letters and characters from 'iskeyword' option for current buffer.
/// For multi-byte characters mb_get_class() is used (builtin rules).
///
/// @param c
///
/// @return TRUE if 'c' is a keyword character.
int vim_iswordc(int c)
/// @param c character to check
bool vim_iswordc(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return vim_iswordc_buf(c, curbuf);
}
int vim_iswordc_buf(int c, buf_T *buf)
/// Check that "c" is a keyword character:
/// Letters and characters from 'iskeyword' option for given buffer.
/// For multi-byte characters mb_get_class() is used (builtin rules).
///
/// @param c character to check
/// @param buf buffer whose keywords to use
bool vim_iswordc_buf(int c, buf_T *buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(2)
{
if (c >= 0x100) {
if (enc_dbcs != 0) {
@ -840,10 +843,11 @@ int vim_iswordc_buf(int c, buf_T *buf)
/// Just like vim_iswordc() but uses a pointer to the (multi-byte) character.
///
/// @param p
/// @param p pointer to the multi-byte character
///
/// @return TRUE if 'p' points to a keyword character.
int vim_iswordp(char_u *p)
/// @return true if "p" points to a keyword character.
bool vim_iswordp(char_u *p)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
if (has_mbyte && (MB_BYTE2LEN(*p) > 1)) {
return mb_get_class(p) >= 2;
@ -851,7 +855,15 @@ int vim_iswordp(char_u *p)
return GET_CHARTAB(curbuf, *p) != 0;
}
int vim_iswordp_buf(char_u *p, buf_T *buf)
/// Just like vim_iswordc_buf() but uses a pointer to the (multi-byte)
/// character.
///
/// @param p pointer to the multi-byte character
/// @param buf buffer whose keywords to use
///
/// @return true if "p" points to a keyword character.
bool vim_iswordp_buf(char_u *p, buf_T *buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
if (has_mbyte && (MB_BYTE2LEN(*p) > 1)) {
return mb_get_class(p) >= 2;
@ -859,26 +871,24 @@ int vim_iswordp_buf(char_u *p, buf_T *buf)
return GET_CHARTAB(buf, *p) != 0;
}
/// return TRUE if 'c' is a valid file-name character
/// Check that "c" is a valid file-name character.
/// Assume characters above 0x100 are valid (multi-byte).
///
/// @param c
///
/// @return TRUE if 'c' is a valid file name character.
int vim_isfilec(int c)
/// @param c character to check
bool vim_isfilec(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return c >= 0x100 || (c > 0 && (chartab[c] & CT_FNAME_CHAR));
}
/// return TRUE if 'c' is a valid file-name character or a wildcard character
/// Check that "c" is a valid file-name character or a wildcard character
/// Assume characters above 0x100 are valid (multi-byte).
/// Explicitly interpret ']' as a wildcard character as path_has_wildcard("]")
/// returns false.
///
/// @param c
///
/// @return TRUE if 'c' is a valid file-name character or wildcard character.
int vim_isfilec_or_wc(int c)
/// @param c character to check
bool vim_isfilec_or_wc(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
char_u buf[2];
buf[0] = (char_u)c;
@ -886,14 +896,12 @@ int vim_isfilec_or_wc(int c)
return vim_isfilec(c) || c == ']' || path_has_wildcard(buf);
}
/// return TRUE if 'c' is a printable character
/// Assume characters above 0x100 are printable (multi-byte), except for
/// Unicode.
/// Check that "c" is a printable character.
/// Assume characters above 0x100 are printable for double-byte encodings.
///
/// @param c
///
/// @return TRUE if 'c' a printable character.
int vim_isprintc(int c)
/// @param c character to check
bool vim_isprintc(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (enc_utf8 && (c >= 0x100)) {
return utf_printable(c);
@ -901,16 +909,17 @@ int vim_isprintc(int c)
return c >= 0x100 || (c > 0 && (chartab[c] & CT_PRINT_CHAR));
}
/// Strict version of vim_isprintc(c), don't return TRUE if "c" is the head
/// Strict version of vim_isprintc(c), don't return true if "c" is the head
/// byte of a double-byte character.
///
/// @param c
/// @param c character to check
///
/// @return TRUE if 'c' is a printable character.
int vim_isprintc_strict(int c)
/// @return true if "c" is a printable character.
bool vim_isprintc_strict(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if ((enc_dbcs != 0) && (c < 0x100) && (MB_BYTE2LEN(c) > 1)) {
return FALSE;
return false;
}
if (enc_utf8 && (c >= 0x100)) {
@ -921,7 +930,7 @@ int vim_isprintc_strict(int c)
/// like chartabsize(), but also check for line breaks on the screen
///
/// @param line
/// @param line
/// @param s
/// @param col
///
@ -1144,35 +1153,33 @@ static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp)
return n;
}
/// Return TRUE if virtual column "vcol" is in the rightmost column of window
/// "wp".
/// Check that virtual column "vcol" is in the rightmost column of window "wp".
///
/// @param wp
/// @param vcol
///
/// @return TRUE if the virtual column is in the rightmost column.
int in_win_border(win_T *wp, colnr_T vcol)
/// @param wp window
/// @param vcol column number
bool in_win_border(win_T *wp, colnr_T vcol)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1)
{
int width1; // width of first line (after line number)
int width2; // width of further lines
if (wp->w_width == 0) {
// there is no border
return FALSE;
return false;
}
width1 = wp->w_width - win_col_off(wp);
if ((int)vcol < width1 - 1) {
return FALSE;
return false;
}
if ((int)vcol == width1 - 1) {
return TRUE;
return true;
}
width2 = width1 + win_col_off2(wp);
if (width2 <= 0) {
return FALSE;
return false;
}
return (vcol - width1) % width2 == width2 - 1;
}
@ -1571,10 +1578,14 @@ static char_u latin1lower[257] =
"\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"
"\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
int vim_islower(int c)
/// Check that the character is lower-case
///
/// @param c character to check
bool vim_islower(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
if (c <= '@') {
return FALSE;
return false;
}
if (c >= 0x80) {
@ -1588,7 +1599,7 @@ int vim_islower(int c)
}
// islower() can't handle these chars and may crash
return FALSE;
return false;
}
if (enc_latin1like) {
@ -1598,10 +1609,14 @@ int vim_islower(int c)
return islower(c);
}
int vim_isupper(int c)
/// Check that the character is upper-case
///
/// @param c character to check
bool vim_isupper(int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
if (c <= '@') {
return FALSE;
return false;
}
if (c >= 0x80) {
@ -1614,8 +1629,8 @@ int vim_isupper(int c)
return iswupper(c);
}
// islower() can't handle these chars and may crash
return FALSE;
// isupper() can't handle these chars and may crash
return false;
}
if (enc_latin1like) {
@ -1744,12 +1759,10 @@ long getdigits_long(char_u **pp)
return (long)number;
}
/// Return TRUE if "lbuf" is empty or only contains blanks.
/// Check that "lbuf" is empty or only contains blanks.
///
/// @param lbuf
///
/// @return TRUE if `lbuf` is empty or only contains blanks.
int vim_isblankline(char_u *lbuf)
/// @param lbuf line buffer to check
bool vim_isblankline(char_u *lbuf)
{
char_u *p = skipwhite(lbuf);
return *p == NUL || *p == '\r' || *p == '\n';
@ -1922,8 +1935,8 @@ int hex2nr(int c)
return c - '0';
}
/// Return true if "str" starts with a backslash that should be removed.
/// For WIN32 this is only done when the character after the
/// Check that "str" starts with a backslash that should be removed.
/// For Windows this is only done when the character after the
/// backslash is not a normal file name character.
/// '$' is a valid file name character, we don't remove the backslash before
/// it. This means it is not possible to use an environment variable after a
@ -1934,10 +1947,9 @@ int hex2nr(int c)
/// character, assume that all multi-byte characters are valid file name
/// characters.
///
/// @param str
///
/// @return true if `str` starts with a backslash that should be removed.
/// @param str file path string to check
bool rem_backslash(const char_u *str)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
#ifdef BACKSLASH_IN_FILENAME
return str[0] == '\\'