aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mbyte.c
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-03-04 13:10:00 +0100
committerGitHub <noreply@github.com>2023-03-04 20:10:00 +0800
commit6cab36e5b7b0d741abe6c5a7c0e20bad30361034 (patch)
tree8f00dab70b4a63ff572600a6e4824f59b0ae29c6 /src/nvim/mbyte.c
parenta4f443994bb91321b00f29af9e6357df9102ce75 (diff)
downloadrneovim-6cab36e5b7b0d741abe6c5a7c0e20bad30361034.tar.gz
rneovim-6cab36e5b7b0d741abe6c5a7c0e20bad30361034.tar.bz2
rneovim-6cab36e5b7b0d741abe6c5a7c0e20bad30361034.zip
refactor: replace char_u with char or uint8_t (#22400)
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r--src/nvim/mbyte.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index d8be4f4997..35af7479b0 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1930,16 +1930,16 @@ theend:
/// @return true if string "s" is a valid utf-8 string.
/// When "end" is NULL stop at the first NUL. Otherwise stop at "end".
-bool utf_valid_string(const char_u *s, const char_u *end)
+bool utf_valid_string(const char *s, const char *end)
{
- const char_u *p = s;
+ const uint8_t *p = (uint8_t *)s;
- while (end == NULL ? *p != NUL : p < end) {
+ while (end == NULL ? *p != NUL : p < (uint8_t *)end) {
int l = utf8len_tab_zero[*p];
if (l == 0) {
return false; // invalid lead byte
}
- if (end != NULL && p + l > end) {
+ if (end != NULL && p + l > (uint8_t *)end) {
return false; // incomplete byte sequence
}
p++;
@@ -2454,8 +2454,8 @@ char *string_convert(const vimconv_T *const vcp, char *ptr, size_t *lenp)
// set to the number of remaining bytes.
char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, size_t *unconvlenp)
{
- char_u *retval = NULL;
- char_u *d;
+ uint8_t *retval = NULL;
+ uint8_t *d;
int c;
size_t len;
@@ -2475,10 +2475,10 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si
for (size_t i = 0; i < len; i++) {
c = (uint8_t)ptr[i];
if (c < 0x80) {
- *d++ = (char_u)c;
+ *d++ = (uint8_t)c;
} else {
- *d++ = (char_u)(0xc0 + (char_u)((unsigned)c >> 6));
- *d++ = (char_u)(0x80 + (c & 0x3f));
+ *d++ = (uint8_t)(0xc0 + (uint8_t)((unsigned)c >> 6));
+ *d++ = (uint8_t)(0x80 + (c & 0x3f));
}
}
*d = NUL;
@@ -2573,7 +2573,7 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si
}
if (!utf_iscomposing(c)) { // skip composing chars
if (c < 0x100) {
- *d++ = (char_u)c;
+ *d++ = (uint8_t)c;
} else if (vcp->vc_fail) {
xfree(retval);
return NULL;
@@ -2594,7 +2594,7 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si
break;
case CONV_ICONV: // conversion with vcp->vc_fd
- retval = (char_u *)iconv_string(vcp, ptr, len, unconvlenp, lenp);
+ retval = (uint8_t *)iconv_string(vcp, ptr, len, unconvlenp, lenp);
break;
}