diff options
| author | bfredl <bjorn.linse@gmail.com> | 2022-04-27 13:37:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 13:37:56 +0200 |
| commit | ee85d8d7566042df0b988ae28bbbaa7a16bbb5a9 (patch) | |
| tree | 798bbfa96a05e4f28aed2b121ed208e1a393421f /src/nvim/quickfix.c | |
| parent | 8e20c04fa00ba9c8c62ba2a44c3e34d9f9ccd667 (diff) | |
| parent | 4aae0eebb24371aefe4eb71baccf266336684398 (diff) | |
| download | rneovim-ee85d8d7566042df0b988ae28bbbaa7a16bbb5a9.tar.gz rneovim-ee85d8d7566042df0b988ae28bbbaa7a16bbb5a9.tar.bz2 rneovim-ee85d8d7566042df0b988ae28bbbaa7a16bbb5a9.zip | |
Merge pull request #18254 from dundargoc/refactor/remove-char_u
refactor: replace char_u variables and functions with char
Diffstat (limited to 'src/nvim/quickfix.c')
| -rw-r--r-- | src/nvim/quickfix.c | 760 |
1 files changed, 375 insertions, 385 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index a04bbe3d2b..03552a0a19 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -47,7 +47,7 @@ struct dir_stack_T { struct dir_stack_T *next; - char_u *dirname; + char *dirname; }; // For each error the next struct is allocated and linked in a list. @@ -62,14 +62,14 @@ struct qfline_S { int qf_col; ///< column where the error occurred int qf_end_col; ///< column when the error has range or zero int qf_nr; ///< error number - char_u *qf_module; ///< module name for this error - char_u *qf_pattern; ///< search pattern for the error - char_u *qf_text; ///< description of the error - char_u qf_viscol; ///< set to TRUE if qf_col and qf_end_col is + char *qf_module; ///< module name for this error + char *qf_pattern; ///< search pattern for the error + char *qf_text; ///< description of the error + char qf_viscol; ///< set to TRUE if qf_col and qf_end_col is // screen column - char_u qf_cleared; ///< set to TRUE if line has been deleted - char_u qf_type; ///< type of the error (mostly 'E'); 1 for :helpgrep - char_u qf_valid; ///< valid error message detected + char qf_cleared; ///< set to TRUE if line has been deleted + char qf_type; ///< type of the error (mostly 'E'); 1 for :helpgrep + char qf_valid; ///< valid error message detected }; // There is a stack of error lists. @@ -100,15 +100,15 @@ typedef struct qf_list_S { int qf_count; ///< number of errors (0 means empty list) int qf_index; ///< current index in the error list int qf_nonevalid; ///< TRUE if not a single valid entry found - char_u *qf_title; ///< title derived from the command that created - ///< the error list or set by setqflist + char *qf_title; ///< title derived from the command that created + ///< the error list or set by setqflist typval_T *qf_ctx; ///< context set by setqflist/setloclist Callback qf_qftf_cb; ///< 'quickfixtextfunc' callback function struct dir_stack_T *qf_dir_stack; - char_u *qf_directory; + char *qf_directory; struct dir_stack_T *qf_file_stack; - char_u *qf_currfile; + char *qf_currfile; bool qf_multiline; bool qf_multiignore; bool qf_multiscan; @@ -140,24 +140,24 @@ typedef struct efm_S efm_T; struct efm_S { regprog_T *prog; // pre-formatted part of 'errorformat' efm_T *next; // pointer to next (NULL if last) - char_u addr[FMT_PATTERNS]; // indices of used % patterns - char_u prefix; // prefix of this format line: - // 'D' enter directory - // 'X' leave directory - // 'A' start of multi-line message - // 'E' error message - // 'W' warning message - // 'I' informational message - // 'N' note message - // 'C' continuation line - // 'Z' end of multi-line message - // 'G' general, unspecific message - // 'P' push file (partial) message - // 'Q' pop/quit file (partial) message - // 'O' overread (partial) message - char_u flags; // additional flags given in prefix - // '-' do not include this line - // '+' include whole line in message + char addr[FMT_PATTERNS]; // indices of used % patterns + char prefix; // prefix of this format line: + // 'D' enter directory + // 'X' leave directory + // 'A' start of multi-line message + // 'E' error message + // 'W' warning message + // 'I' informational message + // 'N' note message + // 'C' continuation line + // 'Z' end of multi-line message + // 'G' general, unspecific message + // 'P' push file (partial) message + // 'Q' pop/quit file (partial) message + // 'O' overread (partial) message + char flags; // additional flags given in prefix + // '-' do not include this line + // '+' include whole line in message int conthere; // %> used }; @@ -180,13 +180,13 @@ enum { /// State information used to parse lines and add entries to a quickfix/location /// list. typedef struct { - char_u *linebuf; + char *linebuf; size_t linelen; - char_u *growbuf; + char *growbuf; size_t growbufsiz; FILE *fd; typval_T *tv; - char_u *p_str; + char *p_str; list_T *p_list; listitem_T *p_li; buf_T *buf; @@ -196,37 +196,37 @@ typedef struct { } qfstate_T; typedef struct { - char_u *namebuf; - char_u *module; - char_u *errmsg; + char *namebuf; + char *module; + char *errmsg; size_t errmsglen; long lnum; long end_lnum; int col; int end_col; bool use_viscol; - char_u *pattern; + char *pattern; int enr; - char_u type; + char type; bool valid; } qffields_T; /// :vimgrep command arguments typedef struct vgr_args_S { long tomatch; ///< maximum number of matches to find - char_u *spat; ///< search pattern + char *spat; ///< search pattern int flags; ///< search modifier - char_u **fnames; ///< list of files to search + char **fnames; ///< list of files to search int fcount; ///< number of files regmmatch_T regmatch; ///< compiled search pattern - char_u *qf_title; ///< quickfix list title + char *qf_title; ///< quickfix list title } vgr_args_T; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "quickfix.c.generated.h" #endif -static char_u *e_no_more_items = (char_u *)N_("E553: No more items"); +static char *e_no_more_items = N_("E553: No more items"); // Quickfix window check helper macro #define IS_QF_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref == NULL) @@ -255,7 +255,7 @@ static char_u *e_no_more_items = (char_u *)N_("E553: No more items"); // Looking up a buffer can be slow if there are many. Remember the last one // to make this a lot faster if there are multiple matches in the same file. -static char_u *qf_last_bufname = NULL; +static char *qf_last_bufname = NULL; static bufref_T qf_last_bufref = { NULL, 0, 0 }; static char *e_current_quickfix_list_was_changed = @@ -292,7 +292,7 @@ static int qf_init_process_nextline(qf_list_T *qfl, efm_T *fmt_first, qfstate_T (*fields->namebuf || qfl->qf_directory != NULL) ? fields->namebuf : ((qfl->qf_currfile != NULL && fields->valid) - ? qfl->qf_currfile : (char_u *)NULL), + ? qfl->qf_currfile : NULL), fields->module, 0, fields->errmsg, @@ -318,8 +318,8 @@ static int qf_init_process_nextline(qf_list_T *qfl, efm_T *fmt_first, qfstate_T /// @params enc If non-NULL, encoding used to parse errors /// /// @returns -1 for error, number of errors for success. -int qf_init(win_T *wp, const char_u *restrict efile, char_u *restrict errorformat, int newlist, - const char_u *restrict qf_title, char_u *restrict enc) +int qf_init(win_T *wp, const char *restrict efile, char *restrict errorformat, int newlist, + const char *restrict qf_title, char *restrict enc) { qf_info_T *qi = &ql_info; @@ -327,8 +327,8 @@ int qf_init(win_T *wp, const char_u *restrict efile, char_u *restrict errorforma qi = ll_get_or_alloc_list(wp); } - return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat, - newlist, (linenr_T)0, (linenr_T)0, qf_title, enc); + return qf_init_ext(qi, qi->qf_curlist, (char *)efile, curbuf, NULL, errorformat, + newlist, (linenr_T)0, (linenr_T)0, (char *)qf_title, enc); } // Maximum number of bytes allowed per line while reading an errorfile. @@ -336,7 +336,7 @@ static const size_t LINE_MAXLEN = 4096; /// Patterns used. Keep in sync with qf_parse_fmt[]. static struct fmtpattern { - char_u convchar; + char convchar; char *pattern; } fmt_pat[FMT_PATTERNS] = { @@ -361,8 +361,7 @@ static struct fmtpattern { /// See fmt_pat definition above for the list of supported patterns. The /// pattern specifier is supplied in "efmpat". The converted pattern is stored /// in "regpat". Returns a pointer to the location after the pattern. -static char_u *efmpat_to_regpat(const char_u *efmpat, char_u *regpat, efm_T *efminfo, int idx, - int round) +static char *efmpat_to_regpat(const char *efmpat, char *regpat, efm_T *efminfo, int idx, int round) FUNC_ATTR_NONNULL_ALL { if (efminfo->addr[idx]) { @@ -377,7 +376,7 @@ static char_u *efmpat_to_regpat(const char_u *efmpat, char_u *regpat, efm_T *efm semsg(_("E373: Unexpected %%%c in format string"), *efmpat); return NULL; } - efminfo->addr[idx] = (char_u)++ round; + efminfo->addr[idx] = (char)++round; *regpat++ = '\\'; *regpat++ = '('; #ifdef BACKSLASH_IN_FILENAME @@ -405,7 +404,7 @@ static char_u *efmpat_to_regpat(const char_u *efmpat, char_u *regpat, efm_T *efm regpat += 4; } } else { - char_u *srcptr = (char_u *)fmt_pat[idx].pattern; + char *srcptr = fmt_pat[idx].pattern; while ((*regpat = *srcptr++) != NUL) { regpat++; } @@ -418,10 +417,10 @@ static char_u *efmpat_to_regpat(const char_u *efmpat, char_u *regpat, efm_T *efm /// Convert a scanf like format in 'errorformat' to a regular expression. /// Returns a pointer to the location after the pattern. -static char_u *scanf_fmt_to_regpat(const char_u **pefmp, const char_u *efm, int len, char_u *regpat) +static char *scanf_fmt_to_regpat(const char **pefmp, const char *efm, int len, char *regpat) FUNC_ATTR_NONNULL_ALL { - const char_u *efmp = *pefmp; + const char *efmp = *pefmp; if (*efmp == '[' || *efmp == '\\') { if ((*regpat++ = *efmp) == '[') { // %*[^a-z0-9] etc. @@ -453,7 +452,7 @@ static char_u *scanf_fmt_to_regpat(const char_u **pefmp, const char_u *efm, int } /// Analyze/parse an errorformat prefix. -static const char_u *efm_analyze_prefix(const char_u *efmp, efm_T *efminfo) +static const char *efm_analyze_prefix(const char *efmp, efm_T *efminfo) FUNC_ATTR_NONNULL_ALL { if (vim_strchr((char_u *)"+-", *efmp) != NULL) { @@ -471,14 +470,14 @@ static const char_u *efm_analyze_prefix(const char_u *efmp, efm_T *efminfo) // Converts a 'errorformat' string to regular expression pattern -static int efm_to_regpat(const char_u *efm, int len, efm_T *fmt_ptr, char_u *regpat) +static int efm_to_regpat(const char *efm, int len, efm_T *fmt_ptr, char *regpat) FUNC_ATTR_NONNULL_ALL { // Build regexp pattern from current 'errorformat' option - char_u *ptr = regpat; + char *ptr = regpat; *ptr++ = '^'; int round = 0; - for (const char_u *efmp = efm; efmp < efm + len; efmp++) { + for (const char *efmp = efm; efmp < efm + len; efmp++) { if (*efmp == '%') { efmp++; int idx; @@ -488,7 +487,7 @@ static int efm_to_regpat(const char_u *efm, int len, efm_T *fmt_ptr, char_u *reg } } if (idx < FMT_PATTERNS) { - ptr = efmpat_to_regpat(efmp, ptr, fmt_ptr, idx, round); + ptr = efmpat_to_regpat((char *)efmp, ptr, fmt_ptr, idx, round); if (ptr == NULL) { return FAIL; } @@ -551,7 +550,7 @@ static void free_efm_list(efm_T **efm_first) /// Compute the size of the buffer used to convert a 'errorformat' pattern into /// a regular expression pattern. -static size_t efm_regpat_bufsz(char_u *efm) +static size_t efm_regpat_bufsz(char *efm) { size_t sz; @@ -569,7 +568,7 @@ static size_t efm_regpat_bufsz(char_u *efm) } /// Return the length of a 'errorformat' option part (separated by ","). -static int efm_option_part_len(char_u *efm) +static int efm_option_part_len(char *efm) { int len; @@ -585,7 +584,7 @@ static int efm_option_part_len(char_u *efm) /// Parse the 'errorformat' option. Multiple parts in the 'errorformat' option /// are parsed and converted to regular expressions. Returns information about /// the parsed 'errorformat' option. -static efm_T *parse_efm_option(char_u *efm) +static efm_T *parse_efm_option(char *efm) { efm_T *fmt_ptr = NULL; efm_T *fmt_first = NULL; @@ -594,7 +593,7 @@ static efm_T *parse_efm_option(char_u *efm) // Get some space to modify the format string into. size_t sz = efm_regpat_bufsz(efm); - char_u *fmtstr = xmalloc(sz); + char *fmtstr = xmalloc(sz); while (efm[0] != NUL) { // Allocate a new eformat structure and put it at the end of the list @@ -612,11 +611,11 @@ static efm_T *parse_efm_option(char_u *efm) if (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL) { goto parse_efm_error; } - if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) { + if ((fmt_ptr->prog = vim_regcomp((char_u *)fmtstr, RE_MAGIC + RE_STRING)) == NULL) { goto parse_efm_error; } // Advance to next part - efm = skip_to_option_part(efm + len); // skip comma and spaces + efm = (char *)skip_to_option_part((char_u *)efm + len); // skip comma and spaces } if (fmt_first == NULL) { // nothing found @@ -635,7 +634,7 @@ parse_efm_end: } /// Allocate more memory for the line buffer used for parsing lines. -static char_u *qf_grow_linebuf(qfstate_T *state, size_t newsz) +static char *qf_grow_linebuf(qfstate_T *state, size_t newsz) { // If the line exceeds LINE_MAXLEN exclude the last // byte since it's not a NL character. @@ -654,15 +653,15 @@ static char_u *qf_grow_linebuf(qfstate_T *state, size_t newsz) static int qf_get_next_str_line(qfstate_T *state) { // Get the next line from the supplied string - char_u *p_str = state->p_str; - char_u *p; + char *p_str = state->p_str; + char *p; size_t len; if (*p_str == NUL) { // Reached the end of the string return QF_END_OF_INPUT; } - p = vim_strchr(p_str, '\n'); + p = (char *)vim_strchr((char_u *)p_str, '\n'); if (p != NULL) { len = (size_t)(p - p_str) + 1; } else { @@ -672,7 +671,7 @@ static int qf_get_next_str_line(qfstate_T *state) if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { - state->linebuf = IObuff; + state->linebuf = (char *)IObuff; state->linelen = len; } memcpy(state->linebuf, p_str, state->linelen); @@ -708,7 +707,7 @@ static int qf_get_next_list_line(qfstate_T *state) if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { - state->linebuf = IObuff; + state->linebuf = (char *)IObuff; state->linelen = len; } @@ -722,21 +721,21 @@ static int qf_get_next_list_line(qfstate_T *state) /// Get the next string from state->buf. static int qf_get_next_buf_line(qfstate_T *state) { - char_u *p_buf = NULL; + char *p_buf = NULL; size_t len; // Get the next line from the supplied buffer if (state->buflnum > state->lnumlast) { return QF_END_OF_INPUT; } - p_buf = ml_get_buf(state->buf, state->buflnum, false); + p_buf = (char *)ml_get_buf(state->buf, state->buflnum, false); state->buflnum += 1; len = STRLEN(p_buf); if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { - state->linebuf = IObuff; + state->linebuf = (char *)IObuff; state->linelen = len; } STRLCPY(state->linebuf, p_buf, state->linelen + 1); @@ -775,7 +774,7 @@ retry: for (;;) { errno = 0; - if (fgets((char *)state->growbuf + growbuflen, + if (fgets(state->growbuf + growbuflen, (int)(state->growbufsiz - growbuflen), state->fd) == NULL) { if (errno == EINTR) { continue; @@ -815,19 +814,20 @@ retry: state->linebuf = state->growbuf; state->linelen = growbuflen; } else { - state->linebuf = IObuff; + state->linebuf = (char *)IObuff; } // Convert a line if it contains a non-ASCII character - if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) { - char_u *line = string_convert(&state->vc, state->linebuf, &state->linelen); + if (state->vc.vc_type != CONV_NONE && has_non_ascii((char_u *)state->linebuf)) { + char *line = (char *)string_convert(&state->vc, (char_u *)state->linebuf, &state->linelen); if (line != NULL) { if (state->linelen < IOSIZE) { STRLCPY(state->linebuf, line, state->linelen + 1); xfree(line); } else { xfree(state->growbuf); - state->linebuf = state->growbuf = line; + state->linebuf = line; + state->growbuf = line; state->growbufsiz = state->linelen < LINE_MAXLEN ? state->linelen : LINE_MAXLEN; } @@ -872,7 +872,7 @@ static int qf_get_nextline(qfstate_T *state) #endif } - remove_bom(state->linebuf); + remove_bom((char_u *)state->linebuf); return QF_OK; } @@ -907,12 +907,12 @@ static qf_list_T *qf_get_list(qf_info_T *qi, int idx) /// Parse a line and get the quickfix fields. /// Return the QF_ status. -static int qf_parse_line(qf_list_T *qfl, char_u *linebuf, size_t linelen, efm_T *fmt_first, +static int qf_parse_line(qf_list_T *qfl, char *linebuf, size_t linelen, efm_T *fmt_first, qffields_T *fields) { efm_T *fmt_ptr; int idx = 0; - char_u *tail = NULL; + char *tail = NULL; int status; restofline: @@ -929,7 +929,7 @@ restofline: // match or no match. fields->valid = true; for (; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next) { - idx = fmt_ptr->prefix; + idx = (char_u)fmt_ptr->prefix; status = qf_parse_get_fields(linebuf, linelen, fmt_ptr, fields, qfl->qf_multiline, qfl->qf_multiscan, &tail); @@ -1014,24 +1014,24 @@ static void qf_free_fields(qffields_T *pfields) // Setup the state information used for parsing lines and populating a // quickfix list. -static int qf_setup_state(qfstate_T *pstate, char_u *restrict enc, const char_u *restrict efile, +static int qf_setup_state(qfstate_T *pstate, char *restrict enc, const char *restrict efile, typval_T *tv, buf_T *buf, linenr_T lnumfirst, linenr_T lnumlast) FUNC_ATTR_NONNULL_ARG(1) { pstate->vc.vc_type = CONV_NONE; if (enc != NULL && *enc != NUL) { - convert_setup(&pstate->vc, enc, p_enc); + convert_setup(&pstate->vc, (char_u *)enc, p_enc); } if (efile != NULL - && (pstate->fd = os_fopen((const char *)efile, "r")) == NULL) { + && (pstate->fd = os_fopen(efile, "r")) == NULL) { semsg(_(e_openerrf), efile); return FAIL; } if (tv != NULL) { if (tv->v_type == VAR_STRING) { - pstate->p_str = tv->vval.v_string; + pstate->p_str = (char *)tv->vval.v_string; } else if (tv->v_type == VAR_LIST) { pstate->p_li = tv_list_first(tv->vval.v_list); } @@ -1071,9 +1071,9 @@ static void qf_cleanup_state(qfstate_T *pstate) /// @param lnumlast last line number to use /// /// @return -1 for error, number of errors for success. -static int qf_init_ext(qf_info_T *qi, int qf_idx, const char_u *restrict efile, buf_T *buf, - typval_T *tv, char_u *restrict errorformat, bool newlist, linenr_T lnumfirst, - linenr_T lnumlast, const char_u *restrict qf_title, char_u *restrict enc) +static int qf_init_ext(qf_info_T *qi, int qf_idx, const char *restrict efile, buf_T *buf, + typval_T *tv, char *restrict errorformat, bool newlist, linenr_T lnumfirst, + linenr_T lnumlast, const char *restrict qf_title, char *restrict enc) FUNC_ATTR_NONNULL_ARG(1) { qf_list_T *qfl; @@ -1082,8 +1082,8 @@ static int qf_init_ext(qf_info_T *qi, int qf_idx, const char_u *restrict efile, qfline_T *old_last = NULL; bool adding = false; static efm_T *fmt_first = NULL; - char_u *efm; - static char_u *last_efm = NULL; + char *efm; + static char *last_efm = NULL; int retval = -1; // default: return error flag int status; @@ -1091,8 +1091,7 @@ static int qf_init_ext(qf_info_T *qi, int qf_idx, const char_u *restrict efile, XFREE_CLEAR(qf_last_bufname); qf_alloc_fields(&fields); - if (qf_setup_state(&state, enc, efile, tv, buf, - lnumfirst, lnumlast) == FAIL) { + if (qf_setup_state(&state, enc, efile, tv, buf, lnumfirst, lnumlast) == FAIL) { goto qf_init_end; } @@ -1113,7 +1112,7 @@ static int qf_init_ext(qf_info_T *qi, int qf_idx, const char_u *restrict efile, // Use the local value of 'errorformat' if it's set. if (errorformat == p_efm && tv == NULL && buf && *buf->b_p_efm != NUL) { - efm = buf->b_p_efm; + efm = (char *)buf->b_p_efm; } else { efm = errorformat; } @@ -1128,7 +1127,7 @@ static int qf_init_ext(qf_info_T *qi, int qf_idx, const char_u *restrict efile, // parse the current 'efm' fmt_first = parse_efm_option(efm); if (fmt_first != NULL) { - last_efm = vim_strsave(efm); + last_efm = xstrdup(efm); } } @@ -1191,14 +1190,14 @@ qf_init_end: /// Set the title of the specified quickfix list. Frees the previous title. /// Prepends ':' to the title. -static void qf_store_title(qf_list_T *qfl, const char_u *title) +static void qf_store_title(qf_list_T *qfl, const char *title) FUNC_ATTR_NONNULL_ARG(1) { XFREE_CLEAR(qfl->qf_title); if (title != NULL) { size_t len = STRLEN(title) + 1; - char_u *p = xmallocz(len); + char *p = xmallocz(len); qfl->qf_title = p; STRLCPY(p, title, len + 1); @@ -1209,11 +1208,11 @@ static void qf_store_title(qf_list_T *qfl, const char_u *title) /// that created the quickfix list with the ":" prefix. /// Create a quickfix list title string by prepending ":" to a user command. /// Returns a pointer to a static buffer with the title. -static char_u *qf_cmdtitle(char_u *cmd) +static char *qf_cmdtitle(char *cmd) { - static char_u qftitle_str[IOSIZE]; + static char qftitle_str[IOSIZE]; - snprintf((char *)qftitle_str, IOSIZE, ":%s", (char *)cmd); + snprintf((char *)qftitle_str, IOSIZE, ":%s", cmd); return qftitle_str; } @@ -1228,7 +1227,7 @@ static qf_list_T *qf_get_curlist(qf_info_T *qi) /// Prepare for adding a new quickfix list. If the current list is in the /// middle of the stack, then all the following lists are freed and then /// the new list is added. -static void qf_new_list(qf_info_T *qi, const char_u *qf_title) +static void qf_new_list(qf_info_T *qi, const char *qf_title) { int i; qf_list_T *qfl; @@ -1262,22 +1261,22 @@ static void qf_new_list(qf_info_T *qi, const char_u *qf_title) /// Return the matched value in "fields->namebuf". static int qf_parse_fmt_f(regmatch_T *rmp, int midx, qffields_T *fields, int prefix) { - char_u c; + char c; if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) { return QF_FAIL; } // Expand ~/file and $HOME/file to full path. - c = *rmp->endp[midx]; + c = (char)(*rmp->endp[midx]); *rmp->endp[midx] = NUL; - expand_env(rmp->startp[midx], fields->namebuf, CMDBUFFSIZE); - *rmp->endp[midx] = c; + expand_env(rmp->startp[midx], (char_u *)fields->namebuf, CMDBUFFSIZE); + *rmp->endp[midx] = (char_u)c; // For separate filename patterns (%O, %P and %Q), the specified file // should exist. if (vim_strchr((char_u *)"OPQ", prefix) != NULL - && !os_path_exists(fields->namebuf)) { + && !os_path_exists((char_u *)fields->namebuf)) { return QF_FAIL; } @@ -1346,13 +1345,13 @@ static int qf_parse_fmt_t(regmatch_T *rmp, int midx, qffields_T *fields) if (rmp->startp[midx] == NULL) { return QF_FAIL; } - fields->type = *rmp->startp[midx]; + fields->type = (char)(*rmp->startp[midx]); return QF_OK; } /// Parse the match for '%+' format pattern. The whole matching line is included /// in the error string. Return the matched line in "fields->errmsg". -static void qf_parse_fmt_plus(const char_u *linebuf, size_t linelen, qffields_T *fields) +static void qf_parse_fmt_plus(const char *linebuf, size_t linelen, qffields_T *fields) FUNC_ATTR_NONNULL_ALL { if (linelen >= fields->errmsglen) { @@ -1384,12 +1383,12 @@ static int qf_parse_fmt_m(regmatch_T *rmp, int midx, qffields_T *fields) /// Parse the match for rest of a single-line file message ('%r') pattern. /// Return the matched value in "tail". -static int qf_parse_fmt_r(regmatch_T *rmp, int midx, char_u **tail) +static int qf_parse_fmt_r(regmatch_T *rmp, int midx, char **tail) { if (rmp->startp[midx] == NULL) { return QF_FAIL; } - *tail = rmp->startp[midx]; + *tail = (char *)rmp->startp[midx]; return QF_OK; } @@ -1397,13 +1396,13 @@ static int qf_parse_fmt_r(regmatch_T *rmp, int midx, char_u **tail) /// Return the matched value in "fields->col". static int qf_parse_fmt_p(regmatch_T *rmp, int midx, qffields_T *fields) { - char_u *match_ptr; + char *match_ptr; if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) { return QF_FAIL; } fields->col = 0; - for (match_ptr = rmp->startp[midx]; match_ptr != rmp->endp[midx]; + for (match_ptr = (char *)rmp->startp[midx]; (char_u *)match_ptr != rmp->endp[midx]; match_ptr++) { fields->col++; if (*match_ptr == TAB) { @@ -1492,10 +1491,10 @@ static int (*qf_parse_fmt[FMT_PATTERNS])(regmatch_T *, int, qffields_T *) = { /// fmt_ptr contains the 'efm' format specifiers/prefixes that have a match. /// Returns QF_OK if all the matches are successfully parsed. On failure, /// returns QF_FAIL or QF_NOMEM. -static int qf_parse_match(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, regmatch_T *regmatch, - qffields_T *fields, int qf_multiline, int qf_multiscan, char_u **tail) +static int qf_parse_match(char *linebuf, size_t linelen, efm_T *fmt_ptr, regmatch_T *regmatch, + qffields_T *fields, int qf_multiline, int qf_multiscan, char **tail) { - char_u idx = fmt_ptr->prefix; + char idx = fmt_ptr->prefix; int i; int midx; int status; @@ -1541,8 +1540,8 @@ static int qf_parse_match(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, regma /// 'fmt_ptr->prog' and return the matching values in 'fields'. /// Returns QF_OK if the efm format matches completely and the fields are /// successfully copied. Otherwise returns QF_FAIL or QF_NOMEM. -static int qf_parse_get_fields(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, qffields_T *fields, - int qf_multiline, int qf_multiscan, char_u **tail) +static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qffields_T *fields, + int qf_multiline, int qf_multiscan, char **tail) { regmatch_T regmatch; int status = QF_FAIL; @@ -1570,7 +1569,7 @@ static int qf_parse_get_fields(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, // Always ignore case when looking for a matching error. regmatch.rm_ic = true; regmatch.regprog = fmt_ptr->prog; - r = vim_regexec(®match, linebuf, (colnr_T)0); + r = vim_regexec(®match, (char_u *)linebuf, (colnr_T)0); fmt_ptr->prog = regmatch.regprog; if (r) { status = qf_parse_match(linebuf, linelen, fmt_ptr, ®match, fields, @@ -1602,19 +1601,18 @@ static int qf_parse_dir_pfx(int idx, qffields_T *fields, qf_list_T *qfl) } /// Parse global file name error format prefixes (%O, %P and %Q). -static int qf_parse_file_pfx(int idx, qffields_T *fields, qf_list_T *qfl, char_u *tail) +static int qf_parse_file_pfx(int idx, qffields_T *fields, qf_list_T *qfl, char *tail) { fields->valid = false; - if (*fields->namebuf == NUL || os_path_exists(fields->namebuf)) { + if (*fields->namebuf == NUL || os_path_exists((char_u *)fields->namebuf)) { if (*fields->namebuf && idx == 'P') { - qfl->qf_currfile = qf_push_dir(fields->namebuf, &qfl->qf_file_stack, - true); + qfl->qf_currfile = qf_push_dir(fields->namebuf, &qfl->qf_file_stack, true); } else if (idx == 'Q') { qfl->qf_currfile = qf_pop_dir(&qfl->qf_file_stack); } *fields->namebuf = NUL; if (tail && *tail) { - STRMOVE(IObuff, skipwhite(tail)); + STRMOVE(IObuff, skipwhite((char_u *)tail)); qfl->qf_multiscan = true; return QF_MULTISCAN; } @@ -1625,7 +1623,7 @@ static int qf_parse_file_pfx(int idx, qffields_T *fields, qf_list_T *qfl, char_u /// Parse a non-error line (a line which doesn't match any of the error /// format in 'efm'). -static int qf_parse_line_nomatch(char_u *linebuf, size_t linelen, qffields_T *fields) +static int qf_parse_line_nomatch(char *linebuf, size_t linelen, qffields_T *fields) { fields->namebuf[0] = NUL; // no match found, remove file name fields->lnum = 0; // don't jump to this line @@ -1840,9 +1838,9 @@ void check_quickfix_busy(void) /// @param valid valid entry /// /// @returns QF_OK or QF_FAIL. -static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, char_u *module, int bufnum, - char_u *mesg, long lnum, long end_lnum, int col, int end_col, - char_u vis_col, char_u *pattern, int nr, char_u type, char_u valid) +static int qf_add_entry(qf_list_T *qfl, char *dir, char *fname, char *module, int bufnum, + char *mesg, long lnum, long end_lnum, int col, int end_col, char vis_col, + char *pattern, int nr, char type, char valid) { qfline_T *qfp = xmalloc(sizeof(qfline_T)); qfline_T **lastp; // pointer to qf_last or NULL @@ -1858,7 +1856,7 @@ static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, char_u *modu } else { qfp->qf_fnum = qf_get_fnum(qfl, dir, fname); } - qfp->qf_text = vim_strsave(mesg); + qfp->qf_text = xstrdup(mesg); qfp->qf_lnum = lnum; qfp->qf_end_lnum = end_lnum; qfp->qf_col = col; @@ -1867,12 +1865,12 @@ static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, char_u *modu if (pattern == NULL || *pattern == NUL) { qfp->qf_pattern = NULL; } else { - qfp->qf_pattern = vim_strsave(pattern); + qfp->qf_pattern = xstrdup(pattern); } if (module == NULL || *module == NUL) { qfp->qf_module = NULL; } else { - qfp->qf_module = vim_strsave(module); + qfp->qf_module = xstrdup(module); } qfp->qf_nr = nr; if (type != 1 && !vim_isprintc(type)) { // only printable chars allowed @@ -2030,7 +2028,7 @@ static int copy_loclist(qf_list_T *from_qfl, qf_list_T *to_qfl) to_qfl->qf_last = NULL; to_qfl->qf_ptr = NULL; if (from_qfl->qf_title != NULL) { - to_qfl->qf_title = vim_strsave(from_qfl->qf_title); + to_qfl->qf_title = xstrdup(from_qfl->qf_title); } else { to_qfl->qf_title = NULL; } @@ -2104,10 +2102,10 @@ void copy_loclist_stack(win_T *from, win_T *to) /// Get buffer number for file "directory/fname". /// Also sets the b_has_qf_entry flag. -static int qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname) +static int qf_get_fnum(qf_list_T *qfl, char *directory, char *fname) { - char_u *ptr = NULL; - char_u *bufname; + char *ptr = NULL; + char *bufname; buf_T *buf; if (fname == NULL || *fname == NUL) { // no file name return 0; @@ -2119,19 +2117,19 @@ static int qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname) } slash_adjust(fname); #endif - if (directory != NULL && !vim_isAbsName(fname)) { - ptr = (char_u *)concat_fnames((char *)directory, (char *)fname, true); + if (directory != NULL && !vim_isAbsName((char_u *)fname)) { + ptr = concat_fnames(directory, fname, true); // Here we check if the file really exists. // This should normally be true, but if make works without // "leaving directory"-messages we might have missed a // directory change. - if (!os_path_exists(ptr)) { + if (!os_path_exists((char_u *)ptr)) { xfree(ptr); directory = qf_guess_filepath(qfl, fname); if (directory) { - ptr = (char_u *)concat_fnames((char *)directory, (char *)fname, true); + ptr = concat_fnames(directory, fname, true); } else { - ptr = vim_strsave(fname); + ptr = xstrdup(fname); } } // Use concatenated directory name and file name. @@ -2147,8 +2145,8 @@ static int qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname) xfree(ptr); } else { xfree(qf_last_bufname); - buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT); - qf_last_bufname = (bufname == ptr) ? bufname : vim_strsave(bufname); + buf = buflist_new((char_u *)bufname, NULL, (linenr_T)0, BLN_NOOPT); + qf_last_bufname = (bufname == ptr) ? bufname : xstrdup(bufname); set_bufref(&qf_last_bufref, buf); } if (buf == NULL) { @@ -2161,7 +2159,7 @@ static int qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname) // Push dirbuf onto the directory stack and return pointer to actual dir or // NULL on error. -static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, bool is_file_stack) +static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_file_stack) { struct dir_stack_T *ds_ptr; @@ -2172,10 +2170,10 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, bool i *stackptr = ds_new; // store directory on the stack - if (vim_isAbsName(dirbuf) + if (vim_isAbsName((char_u *)dirbuf) || (*stackptr)->next == NULL || (*stackptr && is_file_stack)) { - (*stackptr)->dirname = vim_strsave(dirbuf); + (*stackptr)->dirname = xstrdup(dirbuf); } else { // Okay we don't have an absolute path. // dirbuf must be a subdir of one of the directories on the stack. @@ -2184,9 +2182,8 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, bool i (*stackptr)->dirname = NULL; while (ds_new) { xfree((*stackptr)->dirname); - (*stackptr)->dirname = (char_u *)concat_fnames((char *)ds_new->dirname, - (char *)dirbuf, TRUE); - if (os_isdir((*stackptr)->dirname)) { + (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, true); + if (os_isdir((char_u *)(*stackptr)->dirname)) { break; } @@ -2204,7 +2201,7 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, bool i // Nothing found -> it must be on top level if (ds_new == NULL) { xfree((*stackptr)->dirname); - (*stackptr)->dirname = vim_strsave(dirbuf); + (*stackptr)->dirname = xstrdup(dirbuf); } } @@ -2221,7 +2218,7 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, bool i // pop dirbuf from the directory stack and return previous directory or NULL if // stack is empty -static char_u *qf_pop_dir(struct dir_stack_T **stackptr) +static char *qf_pop_dir(struct dir_stack_T **stackptr) { struct dir_stack_T *ds_ptr; @@ -2270,11 +2267,11 @@ static void qf_clean_dir_stack(struct dir_stack_T **stackptr) /// x.c:9: Error /// Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb. /// qf_guess_filepath will return NULL. -static char_u *qf_guess_filepath(qf_list_T * |