diff options
author | Dundar Göc <gocdundar@gmail.com> | 2022-08-26 23:11:25 +0200 |
---|---|---|
committer | dundargoc <gocdundar@gmail.com> | 2022-10-15 13:18:46 +0200 |
commit | 04cdea5f4ac49fa62cc4091a5c26791b80b4cc4c (patch) | |
tree | 10e5be3cf91cee35ad2150e78b2d6aaa4ce5aa13 /src/nvim/tag.c | |
parent | 433818351bc82550a1cb658f5d2ff060b9014d3c (diff) | |
download | rneovim-04cdea5f4ac49fa62cc4091a5c26791b80b4cc4c.tar.gz rneovim-04cdea5f4ac49fa62cc4091a5c26791b80b4cc4c.tar.bz2 rneovim-04cdea5f4ac49fa62cc4091a5c26791b80b4cc4c.zip |
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src/nvim/tag.c')
-rw-r--r-- | src/nvim/tag.c | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 2ac3fed8b7..7c465ac909 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -58,7 +58,7 @@ typedef struct tag_pointers { char_u *command; // first char of command // filled in by parse_match(): char_u *command_end; // first char after command - char_u *tag_fname; // file name of the tags file. This is used + char *tag_fname; // file name of the tags file. This is used // when 'tr' is set. char_u *tagkind; // "kind:" value char_u *tagkind_end; // end of tagkind @@ -1212,30 +1212,30 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl char *const mfp = name_only ? xstrdup(res_name) : xmalloc(len + 2); if (!name_only) { - char_u *p = (char_u *)mfp; + char *p = mfp; *p++ = MT_GL_OTH + 1; // mtt *p++ = TAG_SEP; // no tag file name STRCPY(p, res_name); - p += STRLEN(p); + p += strlen(p); *p++ = TAB; STRCPY(p, res_fname); - p += STRLEN(p); + p += strlen(p); *p++ = TAB; STRCPY(p, res_cmd); - p += STRLEN(p); + p += strlen(p); if (has_extra) { STRCPY(p, ";\""); - p += STRLEN(p); + p += strlen(p); if (res_kind) { *p++ = TAB; STRCPY(p, res_kind); - p += STRLEN(p); + p += strlen(p); } TV_DICT_ITER(TV_LIST_ITEM_TV(li)->vval.v_dict, di, { @@ -1260,11 +1260,11 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl *p++ = TAB; STRCPY(p, dict_key); - p += STRLEN(p); + p += strlen(p); STRCPY(p, ":"); - p += STRLEN(p); + p += strlen(p); STRCPY(p, tv->vval.v_string); - p += STRLEN(p); + p += strlen(p); }); } } @@ -1316,9 +1316,9 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc char *buf_ffname) { FILE *fp; - char_u *lbuf; // line buffer + char *lbuf; // line buffer int lbuf_size = LSIZE; // length of lbuf - char_u *tag_fname; // name of tag file + char *tag_fname; // name of tag file tagname_T tn; // info for get_tagfname() int first_file; // trying first tag file tagptrs_T tagp; @@ -1328,7 +1328,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc int is_static; // current tag line is static int is_current; // file name matches bool eof = false; // found end-of-file - char_u *p; + char *p; char_u *s; int i; int tag_file_sorted = NUL; // !_TAG_FILE_SORTED value @@ -1617,7 +1617,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc // Adjust the search file offset to the correct position search_info.curr_offset_used = search_info.curr_offset; vim_fseek(fp, search_info.curr_offset, SEEK_SET); - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); if (!eof && search_info.curr_offset != 0) { // The explicit cast is to work around a bug in gcc 3.4.2 // (repeated below). @@ -1627,12 +1627,12 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc vim_fseek(fp, search_info.low_offset, SEEK_SET); search_info.curr_offset = search_info.low_offset; } - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } // skip empty and blank lines - while (!eof && vim_isblankline((char *)lbuf)) { + while (!eof && vim_isblankline(lbuf)) { search_info.curr_offset = vim_ftell(fp); - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } if (eof) { // Hit end of file. Skip backwards. @@ -1646,7 +1646,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc // skip empty and blank lines do { - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } while (!eof && vim_isblankline((char *)lbuf)); if (eof) { @@ -1656,16 +1656,16 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc line_read_in: if (vimconv.vc_type != CONV_NONE) { - char_u *conv_line; + char *conv_line; int len; // Convert every line. Converting the pattern from 'enc' to // the tags file encoding doesn't work, because characters are // not recognized. - conv_line = (char_u *)string_convert(&vimconv, (char *)lbuf, NULL); + conv_line = string_convert(&vimconv, lbuf, NULL); if (conv_line != NULL) { // Copy or swap lbuf and conv_line. - len = (int)STRLEN(conv_line) + 1; + len = (int)strlen(conv_line) + 1; if (len > lbuf_size) { xfree(lbuf); lbuf = conv_line; @@ -1691,14 +1691,14 @@ line_read_in: // Read header line. if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0) { - tag_file_sorted = lbuf[18]; + tag_file_sorted = (uint8_t)lbuf[18]; } if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) { // Prepare to convert every line from the specified // encoding to 'encoding'. for (p = lbuf + 20; *p > ' ' && *p < 127; p++) {} *p = NUL; - convert_setup(&vimconv, (char *)lbuf + 20, p_enc); + convert_setup(&vimconv, lbuf + 20, p_enc); } // Read the next line. Unrecognized flags are ignored. @@ -1779,8 +1779,8 @@ parse_line: // This speeds up tag searching a lot! if (orgpat.headlen) { CLEAR_FIELD(tagp); - tagp.tagname = (char *)lbuf; - tagp.tagname_end = (char_u *)vim_strchr((char *)lbuf, TAB); + tagp.tagname = lbuf; + tagp.tagname_end = (char_u *)vim_strchr(lbuf, TAB); if (tagp.tagname_end == NULL) { // Corrupted tag line. line_error = true; @@ -1898,8 +1898,7 @@ parse_line: i = OK; } } else { - i = parse_tag_line(lbuf, - &tagp); + i = parse_tag_line((char_u *)lbuf, &tagp); } if (i == FAIL) { line_error = true; @@ -1992,11 +1991,11 @@ parse_line: len = (size_t)(tagp.tagname_end - (char_u *)tagp.tagname); mfp = xmalloc(sizeof(char) + len + 10 + ML_EXTRA + 1); - p = (char_u *)mfp; + p = mfp; STRCPY(p, tagp.tagname); p[len] = '@'; STRCPY(p + len + 1, help_lang); - snprintf((char *)p + len + 1 + ML_EXTRA, STRLEN(p) + len + 1 + ML_EXTRA, "%06d", + snprintf(p + len + 1 + ML_EXTRA, strlen(p) + len + 1 + ML_EXTRA, "%06d", help_heuristic(tagp.tagname, match_re ? matchoff : 0, !match_no_ic) + help_pri); @@ -2033,7 +2032,7 @@ parse_line: } } } else { - size_t tag_fname_len = STRLEN(tag_fname); + size_t tag_fname_len = strlen(tag_fname); // Save the tag in a buffer. // Use 0x02 to separate fields (Can't use NUL, because the // hash key is terminated by NUL). @@ -2041,10 +2040,10 @@ parse_line: // other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL> // without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL> // Here <mtt> is the "mtt" value plus 1 to avoid NUL. - len = tag_fname_len + STRLEN(lbuf) + 3; + len = tag_fname_len + strlen(lbuf) + 3; mfp = xmalloc(sizeof(char) + len + 1); - p = (char_u *)mfp; - p[0] = (char_u)(mtt + 1); + p = mfp; + p[0] = (char)(mtt + 1); STRCPY(p + 1, tag_fname); #ifdef BACKSLASH_IN_FILENAME // Ignore differences in slashes, avoid adding @@ -2052,7 +2051,7 @@ parse_line: slash_adjust(p + 1); #endif p[tag_fname_len + 1] = TAG_SEP; - s = p + 1 + tag_fname_len + 1; + s = (char_u *)p + 1 + tag_fname_len + 1; STRCPY(s, lbuf); } @@ -2154,7 +2153,7 @@ findtag_end: *mfp = (char)(*mfp - 1); // change the TAG_SEP back to NUL - for (p = (char_u *)mfp + 1; *p != NUL; p++) { + for (p = mfp + 1; *p != NUL; p++) { if (*p == TAG_SEP) { *p = NUL; } @@ -2395,14 +2394,14 @@ static bool test_for_static(tagptrs_T *tagp) return false; } -// Returns the length of a matching tag line. -static size_t matching_line_len(const char_u *const lbuf) +/// @return the length of a matching tag line. +static size_t matching_line_len(const char *const lbuf) { - const char_u *p = lbuf + 1; + const char *p = lbuf + 1; // does the same thing as parse_match() - p += STRLEN(p) + 1; - return (size_t)(p - lbuf) + STRLEN(p); + p += strlen(p) + 1; + return (size_t)(p - lbuf) + strlen(p); } /// Parse a line from a matching tag. Does not change the line itself. @@ -2422,8 +2421,8 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) char *p; char *pc, *pt; - tagp->tag_fname = (char_u *)lbuf + 1; - lbuf += STRLEN(tagp->tag_fname) + 2; + tagp->tag_fname = lbuf + 1; + lbuf += strlen(tagp->tag_fname) + 2; // Find search pattern and the file name for non-etags. retval = parse_tag_line((char_u *)lbuf, tagp); @@ -2494,7 +2493,7 @@ static char_u *tag_full_fname(tagptrs_T *tagp) int c = *tagp->fname_end; *tagp->fname_end = NUL; char_u *fullname = - (char_u *)expand_tag_fname((char *)tagp->fname, (char *)tagp->tag_fname, false); + (char_u *)expand_tag_fname((char *)tagp->fname, tagp->tag_fname, false); *tagp->fname_end = (char_u)c; return fullname; @@ -2526,7 +2525,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) char_u *full_fname = NULL; const bool old_KeyTyped = KeyTyped; // getting the file may reset it const int l_g_do_tagpreview = g_do_tagpreview; - const size_t len = matching_line_len(lbuf_arg) + 1; + const size_t len = matching_line_len((char *)lbuf_arg) + 1; char_u *lbuf = xmalloc(len); memmove(lbuf, lbuf_arg, len); @@ -2563,7 +2562,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) // Expand file name, when needed (for environment variables). // If 'tagrelative' option set, may change file name. - fname = expand_tag_fname(fname, (char *)tagp.tag_fname, true); + fname = expand_tag_fname(fname, tagp.tag_fname, true); tofree_fname = (char_u *)fname; // free() it later // Check if the file with the tag exists before abandoning the current |