diff options
| author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-12-21 12:00:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-21 19:00:05 +0800 |
| commit | ec1738a6ed08dd3a89fd07950fa2dcc55a72b705 (patch) | |
| tree | 2df3877a3d10926a2fcb17b4e2ff07fd70d03ceb /src/nvim | |
| parent | c24605a5a08873d0c7161941b0c7d0aba63d1ccc (diff) | |
| download | rneovim-ec1738a6ed08dd3a89fd07950fa2dcc55a72b705.tar.gz rneovim-ec1738a6ed08dd3a89fd07950fa2dcc55a72b705.tar.bz2 rneovim-ec1738a6ed08dd3a89fd07950fa2dcc55a72b705.zip | |
refactor: replace char_u with char 16 - remove STRNCMP (#21208)
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src/nvim')
| -rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
| -rw-r--r-- | src/nvim/cmdexpand.c | 10 | ||||
| -rw-r--r-- | src/nvim/edit.c | 52 | ||||
| -rw-r--r-- | src/nvim/eval.c | 2 | ||||
| -rw-r--r-- | src/nvim/ex_cmds.c | 7 | ||||
| -rw-r--r-- | src/nvim/ex_docmd.c | 6 | ||||
| -rw-r--r-- | src/nvim/ex_getln.c | 2 | ||||
| -rw-r--r-- | src/nvim/getchar.c | 14 | ||||
| -rw-r--r-- | src/nvim/hardcopy.c | 12 | ||||
| -rw-r--r-- | src/nvim/indent_c.c | 472 | ||||
| -rw-r--r-- | src/nvim/insexpand.c | 18 | ||||
| -rw-r--r-- | src/nvim/keycodes.c | 28 | ||||
| -rw-r--r-- | src/nvim/mapping.c | 74 | ||||
| -rw-r--r-- | src/nvim/normal.c | 2 | ||||
| -rw-r--r-- | src/nvim/option.c | 4 | ||||
| -rw-r--r-- | src/nvim/os/input.c | 2 | ||||
| -rw-r--r-- | src/nvim/os/shell.c | 2 | ||||
| -rw-r--r-- | src/nvim/os/users.c | 2 | ||||
| -rw-r--r-- | src/nvim/regexp.c | 16 | ||||
| -rw-r--r-- | src/nvim/spell.c | 80 | ||||
| -rw-r--r-- | src/nvim/spell_defs.h | 4 | ||||
| -rw-r--r-- | src/nvim/spellfile.c | 38 | ||||
| -rw-r--r-- | src/nvim/spellsuggest.c | 212 | ||||
| -rw-r--r-- | src/nvim/strings.c | 4 | ||||
| -rw-r--r-- | src/nvim/vim.h | 1 | ||||
| -rw-r--r-- | src/nvim/viml/parser/expressions.c | 2 |
26 files changed, 534 insertions, 534 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index e828b294b9..90fdaf9d3b 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -318,7 +318,7 @@ typedef struct { typedef struct mapblock mapblock_T; struct mapblock { mapblock_T *m_next; // next mapblock in list - uint8_t *m_keys; // mapped from, lhs + char *m_keys; // mapped from, lhs char *m_str; // mapped to, rhs char *m_orig_str; // rhs as entered by the user LuaRef m_luaref; // lua function reference as rhs diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index d1a56feef4..c964c96dd7 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -2960,7 +2960,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp) if (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_SHELLCMD) { - char_u upseg[5]; + char upseg[5]; upseg[0] = PATHSEP; upseg[1] = '.'; @@ -2977,7 +2977,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp) // go down a directory c = (int)p_wc; KeyTyped = true; // in case the key was mapped - } else if (STRNCMP(xp->xp_pattern, upseg + 1, 3) == 0 + } else if (strncmp(xp->xp_pattern, upseg + 1, 3) == 0 && c == K_DOWN) { // If in a direct ancestor, strip off one ../ to go down int found = false; @@ -3024,9 +3024,9 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp) if (!found) { j = i; - } else if (STRNCMP(cclp->cmdbuff + j, upseg, 4) == 0) { + } else if (strncmp(cclp->cmdbuff + j, upseg, 4) == 0) { j += 4; - } else if (STRNCMP(cclp->cmdbuff + j, upseg + 1, 3) == 0 + } else if (strncmp(cclp->cmdbuff + j, upseg + 1, 3) == 0 && j == i) { j += 3; } else { @@ -3037,7 +3037,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp) // TODO(tarruda): this is only for DOS/Unix systems - need to put in // machine-specific stuff here and in upseg init cmdline_del(cclp, j); - put_on_cmdline(upseg + 1, 3, false); + put_on_cmdline((char_u *)upseg + 1, 3, false); } else if (cclp->cmdpos > i) { cmdline_del(cclp, i); } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 09836e747f..5df52ab56e 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2777,7 +2777,7 @@ static bool echeck_abbr(int c) return false; } - return check_abbr(c, (char_u *)get_cursor_line_ptr(), curwin->w_cursor.col, + return check_abbr(c, get_cursor_line_ptr(), curwin->w_cursor.col, curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0); } @@ -3018,11 +3018,11 @@ bool cindent_on(void) /// @param line_is_empty when true, accept keys with '0' before them. bool in_cinkeys(int keytyped, int when, bool line_is_empty) { - uint8_t *look; + char *look; int try_match; int try_match_word; - uint8_t *p; - uint8_t *line; + char *p; + char *line; bool icase; if (keytyped == NUL) { @@ -3031,9 +3031,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } if (*curbuf->b_p_inde != NUL) { - look = (uint8_t *)curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys' + look = curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys' } else { - look = (uint8_t *)curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys' + look = curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys' } while (*look) { // Find out if we want to try a match with this key, depending on @@ -3086,9 +3086,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // cursor. } else if (*look == 'e') { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) { - p = (uint8_t *)get_cursor_line_ptr(); - if ((uint8_t *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4 - && STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) { + p = get_cursor_line_ptr(); + if (skipwhite(p) == p + curwin->w_cursor.col - 4 + && strncmp(p + curwin->w_cursor.col - 4, "else", 4) == 0) { return true; } } @@ -3099,12 +3099,12 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // class::method for C++). } else if (*look == ':') { if (try_match && keytyped == ':') { - p = (uint8_t *)get_cursor_line_ptr(); + p = get_cursor_line_ptr(); if (cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel()) { return true; } // Need to get the line again after cin_islabel(). - p = (uint8_t *)get_cursor_line_ptr(); + p = get_cursor_line_ptr(); if (curwin->w_cursor.col > 2 && p[curwin->w_cursor.col - 1] == ':' && p[curwin->w_cursor.col - 2] == ':') { @@ -3112,7 +3112,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) const bool i = cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel(); - p = (uint8_t *)get_cursor_line_ptr(); + p = get_cursor_line_ptr(); p[curwin->w_cursor.col - 1] = ':'; if (i) { return true; @@ -3151,22 +3151,22 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } else { icase = false; } - p = (uint8_t *)vim_strchr((char *)look, ','); + p = vim_strchr(look, ','); if (p == NULL) { - p = look + strlen((char *)look); + p = look + strlen(look); } if ((try_match || try_match_word) && curwin->w_cursor.col >= (colnr_T)(p - look)) { bool match = false; if (keytyped == KEY_COMPLETE) { - uint8_t *n, *s; + char *n, *s; // Just completed a word, check if it starts with "look". // search back for the start of a word. - line = (uint8_t *)get_cursor_line_ptr(); + line = get_cursor_line_ptr(); for (s = line + curwin->w_cursor.col; s > line; s = n) { - n = mb_prevptr((char_u *)line, (char_u *)s); + n = (char *)mb_prevptr((char_u *)line, (char_u *)s); if (!vim_iswordp((char_u *)n)) { break; } @@ -3174,22 +3174,22 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); if (s + (p - look) <= line + curwin->w_cursor.col && (icase - ? mb_strnicmp((char *)s, (char *)look, (size_t)(p - look)) - : STRNCMP(s, look, p - look)) == 0) { + ? mb_strnicmp(s, look, (size_t)(p - look)) + : strncmp(s, look, (size_t)(p - look))) == 0) { match = true; } } else { // TODO(@brammool): multi-byte - if (keytyped == (int)p[-1] + if (keytyped == (int)(uint8_t)p[-1] || (icase && keytyped < 256 && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { - line = (uint8_t *)get_cursor_pos_ptr(); + line = get_cursor_pos_ptr(); assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); if ((curwin->w_cursor.col == (colnr_T)(p - look) - || !vim_iswordc(line[-(p - look) - 1])) + || !vim_iswordc((uint8_t)line[-(p - look) - 1])) && (icase - ? mb_strnicmp((char *)line - (p - look), (char *)look, (size_t)(p - look)) - : STRNCMP(line - (p - look), look, p - look)) == 0) { + ? mb_strnicmp(line - (p - look), look, (size_t)(p - look)) + : strncmp(line - (p - look), look, (size_t)(p - look))) == 0) { match = true; } } @@ -3210,7 +3210,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // Ok, it's a boring generic character. } else { - if (try_match && *look == keytyped) { + if (try_match && (uint8_t)(*look) == keytyped) { return true; } if (*look != NUL) { @@ -3219,7 +3219,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } // Skip over ", ". - look = (uint8_t *)skip_to_option_part((char *)look); + look = skip_to_option_part(look); } return false; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8734700305..d9081680ae 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3838,7 +3838,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate) if (p[1] != '*') { flags |= FSK_SIMPLIFY; } - extra = trans_special((const char_u **)&p, strlen(p), (char_u *)name, flags, false, NULL); + extra = trans_special((const char **)&p, strlen(p), (char_u *)name, flags, false, NULL); if (extra != 0) { name += extra; if (name >= rettv->vval.v_string + len) { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index e6e6176669..5eb5359e90 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1367,12 +1367,13 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp) { bool is_fish_shell = #if defined(UNIX) - STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0; + strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0; #else false; #endif - bool is_pwsh = STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0 - || STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "powershell", 10) == 0; + bool is_pwsh = strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0 + || strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "powershell", + 10) == 0; size_t len = strlen(cmd) + 1; // At least enough space for cmd + NULL. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3a28d557e3..b99df64a3d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6631,7 +6631,7 @@ enum { /// Check "str" for starting with a special cmdline variable. /// If found return one of the SPEC_ values and set "*usedlen" to the length of /// the variable. Otherwise return -1 and "*usedlen" is unchanged. -ssize_t find_cmdline_var(const char_u *src, size_t *usedlen) +ssize_t find_cmdline_var(const char *src, size_t *usedlen) FUNC_ATTR_NONNULL_ALL { static char *(spec_str[]) = { @@ -6655,7 +6655,7 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen) for (size_t i = 0; i < ARRAY_SIZE(spec_str); i++) { size_t len = strlen(spec_str[i]); - if (STRNCMP(src, spec_str[i], len) == 0) { + if (strncmp(src, spec_str[i], len) == 0) { *usedlen = len; assert(i <= SSIZE_MAX); return (ssize_t)i; @@ -6711,7 +6711,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T } // Check if there is something to do. - ssize_t spec_idx = find_cmdline_var(src, usedlen); + ssize_t spec_idx = find_cmdline_var((char *)src, usedlen); if (spec_idx < 0) { // no match *usedlen = 1; return NULL; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index bd77df1704..97f4c6261b 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3929,7 +3929,7 @@ static int ccheck_abbr(int c) spos = 0; } - return check_abbr(c, (char_u *)ccline.cmdbuff, ccline.cmdpos, spos); + return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos); } /// Escape special characters in "fname", depending on "what": diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index fa4d2942f6..db4d640f46 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1968,7 +1968,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) // Only consider an entry if the first character matches and it is // for the current state. // Skip ":lmap" mappings if keys were mapped. - if (mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State) + if ((uint8_t)mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State) && ((mp->m_mode & MODE_LANGMAP) == 0 || typebuf.tb_maplen == 0)) { int nomap = nolmaplen; int modifiers = 0; @@ -1994,7 +1994,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) } modifiers = 0; } - if (mp->m_keys[mlen] != c2) { + if ((uint8_t)mp->m_keys[mlen] != c2) { break; } } @@ -2002,7 +2002,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) // Don't allow mapping the first byte(s) of a multi-byte char. // Happens when mapping <M-a> and then changing 'encoding'. // Beware that 0x80 is escaped. - char_u *p1 = mp->m_keys; + char_u *p1 = (char_u *)mp->m_keys; char_u *p2 = (char_u *)mb_unescape((const char **)&p1); if (p2 != NULL && MB_BYTE2LEN(tb_c1) > utfc_ptr2len((char *)p2)) { @@ -2020,8 +2020,8 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) // mapping starts with K_SNR. uint8_t *s = typebuf.tb_noremap + typebuf.tb_off; if (*s == RM_SCRIPT - && (mp->m_keys[0] != K_SPECIAL - || mp->m_keys[1] != KS_EXTRA + && ((uint8_t)mp->m_keys[0] != K_SPECIAL + || (uint8_t)mp->m_keys[1] != KS_EXTRA || mp->m_keys[2] != KE_SNR)) { continue; } @@ -2212,7 +2212,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) vgetc_busy = 0; may_garbage_collect = false; - save_m_keys = xstrdup((char *)mp->m_keys); + save_m_keys = xstrdup(mp->m_keys); if (save_m_luaref == LUA_NOREF) { save_m_str = xstrdup(mp->m_str); } @@ -2266,7 +2266,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) if (save_m_noremap != REMAP_YES) { noremap = save_m_noremap; - } else if (strncmp(map_str, save_m_keys != NULL ? save_m_keys : (char *)mp->m_keys, + } else if (strncmp(map_str, save_m_keys != NULL ? save_m_keys : mp->m_keys, (size_t)keylen) != 0) { noremap = REMAP_YES; } else { diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 3e43eca92c..0240761483 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -232,7 +232,7 @@ struct prt_ps_resource_S { char_u filename[MAXPATHL + 1]; PrtResourceType type; char_u title[256]; - char_u version[256]; + char version[256]; }; struct prt_dsc_comment_S { @@ -243,7 +243,7 @@ struct prt_dsc_comment_S { struct prt_dsc_line_S { int type; - char_u *string; + char *string; int len; }; @@ -251,7 +251,7 @@ struct prt_dsc_line_S { // couple of KB of comments! #define PRT_FILE_BUFFER_LEN (2048) struct prt_resfile_buffer_S { - char_u buffer[PRT_FILE_BUFFER_LEN]; + char buffer[PRT_FILE_BUFFER_LEN]; int len; int line_start; int line_end; @@ -1550,8 +1550,8 @@ static int prt_resfile_strncmp(int offset, const char *string, int len) if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset))) { return 1; } - return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset], - string, len); + return strncmp(&prt_resfile.buffer[prt_resfile.line_start + offset], + string, (size_t)len); } static int prt_resfile_skip_nonws(int offset) @@ -1751,7 +1751,7 @@ static bool prt_check_resource(const struct prt_ps_resource_S *resource, const c FUNC_ATTR_NONNULL_ALL { // Version number m.n should match, the revision number does not matter - if (STRNCMP(resource->version, version, strlen(version)) != 0) { + if (strncmp(resource->version, version, strlen(version)) != 0) { semsg(_("E621: \"%s\" resource file has wrong version"), resource->name); return false; diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 18f301f96e..ca08f67e32 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -131,7 +131,7 @@ static pos_T *find_start_rawstring(int ind_maxcomment) // XXX // Skip to the end of a "string" and a 'c' character. // If there is no string or character, return argument unmodified. -static const char_u *skip_string(const char_u *p) +static const char *skip_string(const char *p) { int i; @@ -172,7 +172,7 @@ static const char_u *skip_string(const char_u *p) const ptrdiff_t delim_len = paren - delim; for (p += 3; *p; p++) { - if (p[0] == ')' && STRNCMP(p + 1, delim, delim_len) == 0 + if (p[0] == ')' && strncmp(p + 1, delim, (size_t)delim_len) == 0 && p[delim_len + 1] == '"') { p += delim_len + 1; break; @@ -197,7 +197,7 @@ int is_pos_in_string(const char_u *line, colnr_T col) const char_u *p; for (p = line; *p && (colnr_T)(p - line) < col; p++) { - p = skip_string(p); + p = (char_u *)skip_string((char *)p); } return !((colnr_T)(p - line) <= col); } @@ -213,12 +213,12 @@ bool cin_is_cinword(const char *line) bool retval = false; size_t cinw_len = strlen(curbuf->b_p_cinw) + 1; - char_u *cinw_buf = xmalloc(cinw_len); + char *cinw_buf = xmalloc(cinw_len); line = skipwhite((char *)line); for (char *cinw = curbuf->b_p_cinw; *cinw;) { - size_t len = copy_option_part(&cinw, (char *)cinw_buf, cinw_len, ","); - if (STRNCMP(line, cinw_buf, len) == 0 + size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); + if (strncmp(line, cinw_buf, len) == 0 && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) { retval = true; break; @@ -350,7 +350,7 @@ bool cin_islabel(void) // XXX // Exclude "default" from labels, since it should be indented // like a switch label. Same for C++ scope declarations. - if (cin_isdefault(s)) { + if (cin_isdefault((char *)s)) { return false; } if (cin_isscopedecl(s)) { @@ -408,7 +408,7 @@ static int cin_isinit(void) s = cin_skipcomment((char_u *)get_cursor_line_ptr()); - if (cin_starts_with(s, "typedef")) { + if (cin_starts_with((char *)s, "typedef")) { s = cin_skipcomment(s + 7); } @@ -417,7 +417,7 @@ static int cin_isinit(void) for (i = 0; i < (int)ARRAY_SIZE(skip); i++) { l = (int)strlen(skip[i]); - if (cin_starts_with(s, skip[i])) { + if (cin_starts_with((char *)s, skip[i])) { s = cin_skipcomment(s + l); l = 0; break; @@ -428,11 +428,11 @@ static int cin_isinit(void) } } - if (cin_starts_with(s, "enum")) { + if (cin_starts_with((char *)s, "enum")) { return true; } - if (cin_ends_in(s, (char_u *)"=", (char_u *)"{")) { + if (cin_ends_in((char *)s, "=", "{")) { return true; } @@ -445,7 +445,7 @@ static int cin_isinit(void) bool cin_iscase(const char_u *s, bool strict) { s = cin_skipcomment(s); - if (cin_starts_with(s, "case")) { + if (cin_starts_with((char *)s, "case")) { for (s += 4; *s; s++) { s = cin_skipcomment(s); if (*s == NUL) { @@ -473,34 +473,34 @@ bool cin_iscase(const char_u *s, bool strict) return false; } - if (cin_isdefault(s)) { + if (cin_isdefault((char *)s)) { return true; } return false; } // Recognize a "default" switch label. -static int cin_isdefault(const char_u *s) +static int cin_isdefault(const char *s) { - return STRNCMP(s, "default", 7) == 0 - && *(s = cin_skipcomment(s + 7)) == ':' + return strncmp(s, "default", 7) == 0 + && *(s = (char *)cin_skipcomment((char_u *)s + 7)) == ':' && s[1] != ':'; } /// Recognize a scope declaration label set in 'cinscopedecls'. bool cin_isscopedecl(const char_u *p) { - const char_u *s = cin_skipcomment(p); + const char *s = (char *)cin_skipcomment(p); const size_t cinsd_len = strlen(curbuf->b_p_cinsd) + 1; - char_u *cinsd_buf = xmalloc(cinsd_len); + char *cinsd_buf = xmalloc(cinsd_len); bool found = false; for (char *cinsd = curbuf->b_p_cinsd; *cinsd;) { - const size_t len = copy_option_part(&cinsd, (char *)cinsd_buf, cinsd_len, ","); - if (STRNCMP(s, cinsd_buf, len) == 0) { - const char_u *skip = cin_skipcomment(s + len); + const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ","); + if (strncmp(s, cinsd_buf, len) == 0) { + const char_u *skip = cin_skipcomment((char_u *)s + len); if (*skip == ':' && skip[1] != ':') { found = true; break; @@ -517,19 +517,19 @@ bool cin_isscopedecl(const char_u *p) #define FIND_NAMESPACE_LIM 20 // Recognize a "namespace" scope declaration. -static bool cin_is_cpp_namespace(const char_u *s) +static bool cin_is_cpp_namespace(const char *s) { const char_u *p; bool has_name = false; bool has_name_start = false; - s = cin_skipcomment(s); + s = (char *)cin_skipcomment((char_u *)s); - if (STRNCMP(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc(s[6]))) { - s = cin_skipcomment((char_u *)skipwhite((char *)s + 6)); + if (strncmp(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) { + s = (char *)cin_skipcomment((char_u *)skipwhite((char *)s + 6)); } - if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9]))) { + if (strncmp(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc((uint8_t)s[9]))) { p = cin_skipcomment((char_u *)skipwhite((char *)s + 9)); while (*p != NUL) { if (ascii_iswhite(*p)) { @@ -610,25 +610,25 @@ static int get_indent_nolabel(linenr_T lnum) // XXX // Also return a pointer to the text (after the label) in "pp". // label: if (asdf && asdfasdf) // ^ -static int skip_label(linenr_T lnum, const char_u **pp) +static int skip_label(linenr_T lnum, const char **pp) { - const char_u *l; + const char *l; int amount; pos_T cursor_save; cursor_save = curwin->w_cursor; curwin->w_cursor.lnum = lnum; - l = (char_u *)get_cursor_line_ptr(); + l = get_cursor_line_ptr(); // XXX - if (cin_iscase(l, false) || cin_isscopedecl(l) || cin_islabel()) { + if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l) || cin_islabel()) { amount = get_indent_nolabel(lnum); - l = after_label((char_u *)get_cursor_line_ptr()); + l = (char *)after_label((char_u *)get_cursor_line_ptr()); if (l == NULL) { // just in case - l = (char_u *)get_cursor_line_ptr(); + l = get_cursor_line_ptr(); } } else { amount = get_indent(); - l = (char_u *)get_cursor_line_ptr(); + l = get_cursor_line_ptr(); } *pp = l; @@ -643,38 +643,38 @@ static int skip_label(linenr_T lnum, const char_u **pp) // Returns zero when it doesn't look like a declaration. static int cin_first_id_amount(void) { - char_u *line, *p, *s; + char *line, *p, *s; int len; pos_T fp; colnr_T col; - line = (char_u *)get_cursor_line_ptr(); - p = (char_u *)skipwhite((char *)line); - len = (int)((char_u *)skiptowhite((char *)p) - p); - if (len == 6 && STRNCMP(p, "static", 6) == 0) { - p = (char_u *)skipwhite((char *)p + 6); - len = (int)((char_u *)skiptowhite((char *)p) - p); - } - if (len == 6 && STRNCMP(p, "struct", 6) == 0) { - p = (char_u *)skipwhite((char *)p + 6); - } else if (len == 4 && STRNCMP(p, "enum", 4) == 0) { - p = (char_u *)skipwhite((char *)p + 4); - } else if ((len == 8 && STRNCMP(p, "unsigned", 8) == 0) - || (len == 6 && STRNCMP(p, "signed", 6) == 0)) { - s = (char_u *)skipwhite((char *)p + len); - if ((STRNCMP(s, "int", 3) == 0 && ascii_iswhite(s[3])) - || (STRNCMP(s, "long", 4) == 0 && ascii_iswhite(s[4])) - || (STRNCMP(s, "short", 5) == 0 && ascii_iswhite(s[5])) - || (STRNCMP(s, "char", 4) == 0 && ascii_iswhite(s[4]))) { + line = get_cursor_line_ptr(); + p = skipwhite(line); + len = (int)(skiptowhite(p) - p); + if (len == 6 && strncmp(p, "static", 6) == 0) { + p = skipwhite(p + 6); + len = (int)(skiptowhite(p) - p); + } + if (len == 6 && strncmp(p, "struct", 6) == 0) { + p = skipwhite(p + 6); + } else if (len == 4 && strncmp(p, "enum", 4) == 0) { + p = skipwhite(p + 4); + } else if ((len == 8 && strncmp(p, "unsigned", 8) == 0) + || (len == 6 && strncmp(p, "signed", 6) == 0)) { + s = skipwhite(p + len); + if ((strncmp(s, "int", 3) == 0 && ascii_iswhite(s[3])) + || (strncmp(s, "long", 4) == 0 && ascii_iswhite(s[4])) + || (strncmp(s, "short", 5) == 0 && ascii_iswhite(s[5])) + || (strncmp(s, "char", 4) == 0 && ascii_iswhite(s[4]))) { p = s; } } for (len = 0; vim_isIDc(p[len]); len++) {} - if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode(p)) { + if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode((char_u *)p)) { return 0; } - p = (char_u *)skipwhite((char *)p + len); + p = skipwhite(p + len); fp.lnum = curwin->w_cursor.lnum; fp.col = (colnr_T)(p - line); getvcol(curwin, &fp, &col, NULL, NULL); @@ -743,9 +743,9 @@ static int cin_ispreproc(const char_u *s) /// continuation line of a preprocessor statement. Decrease "*lnump" to the /// start and return the line in "*pp". /// Put the amount of indent in "*amount". -static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount) +static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount) { - const char_u *line = *pp; + const char_u *line = (char_u *)(*pp); linenr_T lnum = *lnump; int retval = false; int candidate_amount = *amount; @@ -770,7 +770,7 @@ static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount) } if (lnum != *lnump) { - *pp = (char_u *)ml_get(*lnump); + *pp = ml_get(*lnump); } if (retval) { *amount = candidate_amount; @@ -809,17 +809,17 @@ static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma) s = cin_skipcomment(s); - if (*s == '{' || (*s == '}' && !cin_iselse(s))) { + if (*s == '{' || (*s == '}' && !cin_iselse((char *)s))) { found_start = *s; } if (!found_start) { - is_else = cin_iselse(s); + is_else = cin_iselse((char *)s); } while (*s) { // skip over comments, "" strings and 'c'haracters - s = skip_string(cin_skipcomment(s)); + s = (char_u *)skip_string((char *)cin_skipcomment(s)); if (*s == '}' && n_open > 0) { n_open--; } @@ -852,7 +852,7 @@ static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma) /// lines here. /// @param[in] first_lnum Where to start looking. /// @param[in] min_lnum The line before which we will not be looking. -static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_lnum) +static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnum) { const char_u *s; linenr_T lnum = first_lnum; @@ -864,7 +864,7 @@ static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_l if (sp == NULL) { s = (char_u *)ml_get(lnum); } else { - s = *sp; + s = (char_u *)(*sp); } curwin->w_cursor.lnum = lnum; @@ -956,28 +956,28 @@ static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_l done: if (lnum != first_lnum && sp != NULL) { - *sp = (char_u *)ml_get(first_lnum); + *sp = ml_get(first_lnum); } return retval; } -static int cin_isif(const char_u *p) +static int cin_isif(const char *p) { - return STRNCMP(p, "if", 2) == 0 && !vim_isIDc(p[2]); + return strncmp(p, "if", 2) == 0 && !vim_isIDc((uint8_t)p[2]); } -static int cin_iselse(const char_u *p) +static int cin_iselse(const char *p) { if (*p == '}') { // accept "} else" - p = cin_skipcomment(p + 1); + p = (char *)cin_skipcomment((char_u *)p + 1); } - return STRNCMP(p, "else", 4) == 0 && !vim_isIDc(p[4]); + return strncmp(p, "else", 4) == 0 && !vim_isIDc((uint8_t)p[4]); } -static int cin_isdo(const char_u *p) +static int cin_isdo(const char *p) { - return STRNCMP(p, "do", 2) == 0 && !vim_isIDc(p[2]); + return strncmp(p, "do", 2) == 0 && !vim_isIDc((uint8_t)p[2]); } // Check if this is a "while" that should have a matching "do". @@ -993,7 +993,7 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX if (*p == '}') { // accept "} while (cond);" p = cin_skipcomment(p + 1); |