diff options
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 9b651b3c12..96ea9b3fe1 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -433,7 +433,7 @@ char_u * mb_init() || STRNCMP(p_enc, "iso-8859-", 9) == 0) { /* Accept any "8bit-" or "iso-8859-" name. */ enc_unicode = 0; - enc_utf8 = FALSE; + enc_utf8 = false; } else if (STRNCMP(p_enc, "2byte-", 6) == 0) { /* Unix: accept any "2byte-" name, assume current locale. */ enc_dbcs_new = DBCS_2BYTE; @@ -441,7 +441,7 @@ char_u * mb_init() i = enc_canon_table[idx].prop; if (i & ENC_UNICODE) { /* Unicode */ - enc_utf8 = TRUE; + enc_utf8 = true; if (i & (ENC_2BYTE | ENC_2WORD)) enc_unicode = 2; else if (i & ENC_4BYTE) @@ -454,14 +454,14 @@ char_u * mb_init() } else { /* Must be 8-bit. */ enc_unicode = 0; - enc_utf8 = FALSE; + enc_utf8 = false; } } else /* Don't know what encoding this is, reject it. */ return e_invarg; if (enc_dbcs_new != 0) { enc_unicode = 0; - enc_utf8 = FALSE; + enc_utf8 = false; } enc_dbcs = enc_dbcs_new; has_mbyte = (enc_dbcs != 0 || enc_utf8); @@ -520,7 +520,7 @@ char_u * mb_init() p = enc_locale(); if (p == NULL || STRCMP(p, p_enc) != 0) { convert_setup(&vimconv, p_enc, (char_u *)"utf-8"); - vimconv.vc_fail = TRUE; + vimconv.vc_fail = true; } free(p); } @@ -580,7 +580,7 @@ char_u * mb_init() (void)init_chartab(); /* When enc_utf8 is set or reset, (de)allocate ScreenLinesUC[] */ - screenalloc(FALSE); + screenalloc(false); /* When using Unicode, set default for 'fileencodings'. */ if (enc_utf8 && !option_was_set((char_u *)"fencs")) @@ -917,15 +917,15 @@ static int dbcs_ptr2len_len(const char_u *p, int size) } /* - * Return TRUE if "c" is in "table[size / sizeof(struct interval)]". + * Return true if "c" is in "table[size / sizeof(struct interval)]". */ -static int intable(struct interval *table, size_t size, int c) +static bool intable(struct interval *table, size_t size, int c) { int mid, bot, top; /* first quick check for Latin1 etc. characters */ if (c < table[0].first) - return FALSE; + return false; /* binary search in table */ bot = 0; @@ -937,9 +937,9 @@ static int intable(struct interval *table, size_t size, int c) else if (table[mid].first > c) top = mid - 1; else - return TRUE; + return true; } - return FALSE; + return false; } /* @@ -1496,15 +1496,15 @@ int mb_cptr2char_adv(char_u **pp) * comes after "p1". For Arabic sometimes "ab" is replaced with "c", which * behaves like a composing character. */ -int utf_composinglike(const char_u *p1, const char_u *p2) +bool utf_composinglike(const char_u *p1, const char_u *p2) { int c2; c2 = utf_ptr2char(p2); if (utf_iscomposing(c2)) - return TRUE; + return true; if (!arabic_maycombine(c2)) - return FALSE; + return false; return arabic_combine(utf_ptr2char(p1), c2); } @@ -1818,11 +1818,11 @@ int utf_char2bytes(int c, char_u *buf) } /* - * Return TRUE if "c" is a composing UTF-8 character. This means it will be + * Return true if "c" is a composing UTF-8 character. This means it will be * drawn on top of the preceding character. * Based on code from Markus Kuhn. */ -int utf_iscomposing(int c) +bool utf_iscomposing(int c) { /* Sorted list of non-overlapping intervals. * Generated by ../runtime/tools/unicode.vim. */ @@ -2022,10 +2022,10 @@ int utf_iscomposing(int c) } /* - * Return TRUE for characters that can be displayed in a normal way. + * Return true for characters that can be displayed in a normal way. * Only for characters of 0x100 and above! */ -int utf_printable(int c) +bool utf_printable(int c) { #ifdef USE_WCHAR_FUNCTIONS /* @@ -2696,7 +2696,7 @@ int utf_toupper(int a) return utf_convert(a, toUpper, (int)sizeof(toUpper)); } -int utf_islower(int a) +bool utf_islower(int a) { /* German sharp s is lower case but has no upper case equivalent. */ return (utf_toupper(a) != a) || a == 0xdf; @@ -2726,7 +2726,7 @@ int utf_tolower(int a) return utf_convert(a, toLower, (int)sizeof(toLower)); } -int utf_isupper(int a) +bool utf_isupper(int a) { return utf_tolower(a) != a; } @@ -3138,7 +3138,6 @@ theend: /* * If the cursor moves on an trail byte, set the cursor on the lead byte. * Thus it moves left if necessary. - * Return TRUE when the cursor was adjusted. */ void mb_adjust_cursor() { @@ -3264,11 +3263,11 @@ char_u * mb_unescape(char_u **pp) } /* - * Return TRUE if the character at "row"/"col" on the screen is the left side + * Return true if the character at "row"/"col" on the screen is the left side * of a double-width character. * Caller must make sure "row" and "col" are not invalid! */ -int mb_lefthalve(int row, int col) +bool mb_lefthalve(int row, int col) { return (*mb_off2cells)(LineOffset[row] + col, LineOffset[row] + screen_Columns) > 1; @@ -3462,20 +3461,20 @@ void * my_iconv_open(char_u *to, char_u *from) char_u tobuf[ICONV_TESTLEN]; char *p; size_t tolen; - static int iconv_ok = -1; + static WorkingStatus iconv_working = kUnknown; - if (iconv_ok == FALSE) + if (iconv_working == kBroken) return (void *)-1; /* detected a broken iconv() previously */ #ifdef DYNAMIC_ICONV /* Check if the iconv.dll can be found. */ - if (!iconv_enabled(TRUE)) + if (!iconv_enabled(true)) return (void *)-1; #endif fd = iconv_open((char *)enc_skip(to), (char *)enc_skip(from)); - if (fd != (iconv_t)-1 && iconv_ok == -1) { + if (fd != (iconv_t)-1 && iconv_working == kUnknown) { /* * Do a dummy iconv() call to check if it actually works. There is a * version of iconv() on Linux that is broken. We can't ignore it, @@ -3487,11 +3486,11 @@ void * my_iconv_open(char_u *to, char_u *from) tolen = ICONV_TESTLEN; (void)iconv(fd, NULL, NULL, &p, &tolen); if (p == NULL) { - iconv_ok = FALSE; + iconv_working = kBroken; iconv_close(fd); fd = (iconv_t)-1; } else - iconv_ok = TRUE; + iconv_working = kWorking; } return (void *)fd; @@ -3647,10 +3646,10 @@ static void * get_iconv_import_func(HINSTANCE hInst, /* * Try opening the iconv.dll and return TRUE if iconv() can be used. */ -int iconv_enabled(int verbose) +bool iconv_enabled(bool verbose) { if (hIconvDLL != 0 && hMsvcrtDLL != 0) - return TRUE; + return true; hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL); if (hIconvDLL == 0) /* sometimes it's called libiconv.dll */ hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL_ALT); @@ -3666,7 +3665,7 @@ int iconv_enabled(int verbose) verbose_leave(); } iconv_end(); - return FALSE; + return false; } iconv = (void *)GetProcAddress(hIconvDLL, "libiconv"); @@ -3684,9 +3683,9 @@ int iconv_enabled(int verbose) EMSG2(_(e_loadfunc), "for libiconv"); verbose_leave(); } - return FALSE; + return false; } - return TRUE; + return true; } void iconv_end() @@ -3722,15 +3721,15 @@ void iconv_end() */ int convert_setup(vimconv_T *vcp, char_u *from, char_u *to) { - return convert_setup_ext(vcp, from, TRUE, to, TRUE); + return convert_setup_ext(vcp, from, true, to, true); } /* * As convert_setup(), but only when from_unicode_is_utf8 is TRUE will all * "from" unicode charsets be considered utf-8. Same for "to". */ -int convert_setup_ext(vimconv_T *vcp, char_u *from, int from_unicode_is_utf8, - char_u *to, int to_unicode_is_utf8) +int convert_setup_ext(vimconv_T *vcp, char_u *from, bool from_unicode_is_utf8, + char_u *to, bool to_unicode_is_utf8) { int from_prop; int to_prop; @@ -3744,7 +3743,7 @@ int convert_setup_ext(vimconv_T *vcp, char_u *from, int from_unicode_is_utf8, # endif vcp->vc_type = CONV_NONE; vcp->vc_factor = 1; - vcp->vc_fail = FALSE; + vcp->vc_fail = false; /* No conversion when one of the names is empty or they are equal. */ if (from == NULL || *from == NUL || to == NULL || *to == NUL |