diff --git a/Filelist b/Filelist index 2aeea2800e..72a1f9685b 100644 --- a/Filelist +++ b/Filelist @@ -110,6 +110,7 @@ SRC_ALL = \ src/testdir/setup.vim \ src/testdir/gui_init.vim \ src/testdir/setup_gui.vim \ + src/testdir/gui_preinit.vim \ src/testdir/test[0-9]*.ok \ src/testdir/test[0-9]*a.ok \ src/testdir/test_[a-z]*.ok \ diff --git a/src/Makefile b/src/Makefile index fbff5f8805..0112140f02 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2116,6 +2116,7 @@ test_arglist \ test_cdo \ test_channel \ test_charsearch \ + test_charsearch_utf8 \ test_changedtick \ test_cindent \ test_cmdline \ diff --git a/src/buffer.c b/src/buffer.c index 7fe41f00b2..2f6121bcf7 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -111,7 +111,7 @@ read_buffer( { /* Set or reset 'modified' before executing autocommands, so that * it can be changed there. */ - if (!readonlymode && !bufempty()) + if (!readonlymode && !BUFEMPTY()) changed(); else if (retval == OK) unchanged(curbuf, FALSE); @@ -1963,7 +1963,7 @@ buflist_new( && curbuf != NULL && curbuf->b_ffname == NULL && curbuf->b_nwindows <= 1 - && (curbuf->b_ml.ml_mfp == NULL || bufempty())) + && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY())) { buf = curbuf; #ifdef FEAT_AUTOCMD @@ -2338,7 +2338,7 @@ buflist_getfile( /* If 'switchbuf' contains "split", "vsplit" or "newtab" and the * current buffer isn't empty: open new tab or window */ if (wp == NULL && (swb_flags & (SWB_VSPLIT | SWB_SPLIT | SWB_NEWTAB)) - && !bufempty()) + && !BUFEMPTY()) { if (swb_flags & SWB_NEWTAB) tabpage_new(); @@ -5027,7 +5027,7 @@ do_arg_all( #ifdef FEAT_WINDOWS /* ":drop all" should re-use an empty window to avoid "--remote-tab" * leaving an empty tab page when executed locally. */ - if (keep_tabs && bufempty() && curbuf->b_nwindows == 1 + if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 && curbuf->b_ffname == NULL && !curbuf->b_changed) use_firstwin = TRUE; #endif diff --git a/src/charset.c b/src/charset.c index 984d7653e7..29c587b521 100644 --- a/src/charset.c +++ b/src/charset.c @@ -870,7 +870,7 @@ win_linetabsize(win_T *wp, char_u *line, colnr_T len) char_u *s; for (s = line; *s != NUL && (len == MAXCOL || s < line + len); - mb_ptr_adv(s)) + MB_PTR_ADV(s)) col += win_lbr_chartabsize(wp, line, s, col, NULL); return (int)col; } @@ -1026,7 +1026,7 @@ lbr_chartabsize_adv( int retval; retval = lbr_chartabsize(line, *s, col); - mb_ptr_adv(*s); + MB_PTR_ADV(*s); return retval; } @@ -1089,8 +1089,8 @@ win_lbr_chartabsize( * needs a break here */ if (wp->w_p_lbr - && vim_isbreak(c) - && !vim_isbreak(s[1]) + && VIM_ISBREAK(c) + && !VIM_ISBREAK((int)s[1]) && wp->w_p_wrap # ifdef FEAT_WINDOWS && wp->w_width != 0 @@ -1115,12 +1115,12 @@ win_lbr_chartabsize( for (;;) { ps = s; - mb_ptr_adv(s); + MB_PTR_ADV(s); c = *s; if (!(c != NUL - && (vim_isbreak(c) - || (!vim_isbreak(c) - && (col2 == col || !vim_isbreak(*ps)))))) + && (VIM_ISBREAK(c) + || (!VIM_ISBREAK(c) + && (col2 == col || !VIM_ISBREAK((int)*ps)))))) break; col2 += win_chartabsize(wp, s, col2); @@ -1369,7 +1369,7 @@ getvcol( break; vcol += incr; - mb_ptr_adv(ptr); + MB_PTR_ADV(ptr); } } else @@ -1390,7 +1390,7 @@ getvcol( break; vcol += incr; - mb_ptr_adv(ptr); + MB_PTR_ADV(ptr); } } if (start != NULL) @@ -1403,7 +1403,8 @@ getvcol( && (State & NORMAL) && !wp->w_p_list && !virtual_active() - && !(VIsual_active && (*p_sel == 'e' || ltoreq(*pos, VIsual))) + && !(VIsual_active + && (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual))) ) *cursor = vcol + incr - 1; /* cursor at end */ else @@ -1496,7 +1497,7 @@ getvcols( { colnr_T from1, from2, to1, to2; - if (ltp(pos1, pos2)) + if (LT_POSP(pos1, pos2)) { getvvcol(wp, pos1, &from1, NULL, &to1); getvvcol(wp, pos2, &from2, NULL, &to2); @@ -1529,7 +1530,7 @@ skipwhite(char_u *q) { char_u *p = q; - while (vim_iswhite(*p)) /* skip to next non-white */ + while (VIM_ISWHITE(*p)) /* skip to next non-white */ ++p; return p; } diff --git a/src/config.h.in b/src/config.h.in index 49ed596f47..a9bcf1ef33 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -446,6 +446,9 @@ /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */ #undef HAVE_FD_CLOEXEC +/* Define if /proc/self/exe can be read */ +#undef HAVE_PROC_SELF_EXE + /* Define if you want Cygwin to use the WIN32 clipboard, not compatible with X11*/ #undef FEAT_CYGWIN_WIN32_CLIPBOARD diff --git a/src/diff.c b/src/diff.c index 435269984e..246c4e09ec 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1667,7 +1667,7 @@ diff_cmp(char_u *s1, char_u *s2) p2 = s2; while (*p1 != NUL && *p2 != NUL) { - if (vim_iswhite(*p1) && vim_iswhite(*p2)) + if (VIM_ISWHITE(*p1) && VIM_ISWHITE(*p2)) { p1 = skipwhite(p1); p2 = skipwhite(p2); @@ -1994,8 +1994,8 @@ diff_find_change( while (line_org[si_org] != NUL) { if ((diff_flags & DIFF_IWHITE) - && vim_iswhite(line_org[si_org]) - && vim_iswhite(line_new[si_new])) + && VIM_ISWHITE(line_org[si_org]) + && VIM_ISWHITE(line_new[si_new])) { si_org = (int)(skipwhite(line_org + si_org) - line_org); si_new = (int)(skipwhite(line_new + si_new) - line_new); @@ -2029,14 +2029,14 @@ diff_find_change( && ei_org >= 0 && ei_new >= 0) { if ((diff_flags & DIFF_IWHITE) - && vim_iswhite(line_org[ei_org]) - && vim_iswhite(line_new[ei_new])) + && VIM_ISWHITE(line_org[ei_org]) + && VIM_ISWHITE(line_new[ei_new])) { while (ei_org >= *startp - && vim_iswhite(line_org[ei_org])) + && VIM_ISWHITE(line_org[ei_org])) --ei_org; while (ei_new >= si_new - && vim_iswhite(line_new[ei_new])) + && VIM_ISWHITE(line_new[ei_new])) --ei_new; } else @@ -2202,7 +2202,7 @@ ex_diffgetput(exarg_T *eap) { /* Buffer number or pattern given. Ignore trailing white space. */ p = eap->arg + STRLEN(eap->arg); - while (p > eap->arg && vim_iswhite(p[-1])) + while (p > eap->arg && VIM_ISWHITE(p[-1])) --p; for (i = 0; vim_isdigit(eap->arg[i]) && eap->arg + i < p; ++i) ; @@ -2333,7 +2333,7 @@ ex_diffgetput(exarg_T *eap) end_skip = 0; } - buf_empty = bufempty(); + buf_empty = BUFEMPTY(); added = 0; for (i = 0; i < count; ++i) { diff --git a/src/edit.c b/src/edit.c index 0f5282f5c8..341c72b7cf 100644 --- a/src/edit.c +++ b/src/edit.c @@ -408,7 +408,7 @@ edit( * the "A" command, thus set State to avoid that. Also check that the * line number is still valid (lines may have been deleted). * Do not restore if v:char was set to a non-empty string. */ - if (!equalpos(curwin->w_cursor, save_cursor) + if (!EQUAL_POS(curwin->w_cursor, save_cursor) # ifdef FEAT_EVAL && *get_vim_var_str(VV_CHAR) == NUL # endif @@ -857,7 +857,7 @@ edit( if (str != NULL) { - for (p = str; *p != NUL; mb_ptr_adv(p)) + for (p = str; *p != NUL; MB_PTR_ADV(p)) ins_compl_addleader(PTR2CHAR(p)); vim_free(str); } @@ -1501,7 +1501,7 @@ normalchar: if (*str != NUL && stop_arrow() != FAIL) { /* Insert the new value of v:char literally. */ - for (p = str; *p != NUL; mb_ptr_adv(p)) + for (p = str; *p != NUL; MB_PTR_ADV(p)) { c = PTR2CHAR(p); if (c == CAR || c == K_KENTER || c == NL) @@ -1640,7 +1640,7 @@ ins_redraw( # endif ) # ifdef FEAT_AUTOCMD - && !equalpos(last_cursormoved, curwin->w_cursor) + && !EQUAL_POS(last_cursormoved, curwin->w_cursor) # endif # ifdef FEAT_INS_EXPAND && !pum_visible() @@ -2158,7 +2158,7 @@ truncate_spaces(char_u *line) int i; /* find start of trailing white space */ - for (i = (int)STRLEN(line) - 1; i >= 0 && vim_iswhite(line[i]); i--) + for (i = (int)STRLEN(line) - 1; i >= 0 && VIM_ISWHITE(line[i]); i--) { if (State & REPLACE_FLAG) replace_join(0); /* remove a NUL from the replace stack */ @@ -2367,7 +2367,7 @@ ins_compl_accept_char(int c) case CTRL_X_OMNI: /* Command line and Omni completion can work with just about any * printable character, but do stop at white space. */ - return vim_isprintc(c) && !vim_iswhite(c); + return vim_isprintc(c) && !VIM_ISWHITE(c); case CTRL_X_WHOLE_LINE: /* For while line completion a space can be part of the line. */ @@ -2412,7 +2412,7 @@ ins_compl_add_infercase( actual_len = 0; while (*p != NUL) { - mb_ptr_adv(p); + MB_PTR_ADV(p); ++actual_len; } } @@ -2428,7 +2428,7 @@ ins_compl_add_infercase( actual_compl_length = 0; while (*p != NUL) { - mb_ptr_adv(p); + MB_PTR_ADV(p); ++actual_compl_length; } } @@ -2731,8 +2731,8 @@ ins_compl_longest_match(compl_T *match) #ifdef FEAT_MBYTE if (has_mbyte) { - mb_ptr_adv(p); - mb_ptr_adv(s); + MB_PTR_ADV(p); + MB_PTR_ADV(s); } else #endif @@ -3483,7 +3483,7 @@ ins_compl_bs(void) line = ml_get_curline(); p = line + curwin->w_cursor.col; - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); /* Stop completion when the whole word was deleted. For Omni completion * allow the word to be deleted, we won't match everything. @@ -4037,7 +4037,7 @@ ins_compl_fixRedoBufForLeader(char_u *ptr_arg) if (len > 0) len -= (*mb_head_off)(p, p + len); #endif - for (p += len; *p != NUL; mb_ptr_adv(p)) + for (p += len; *p != NUL; MB_PTR_ADV(p)) AppendCharToRedobuff(K_BS); } else @@ -4144,7 +4144,7 @@ expand_by_function( } curwin->w_cursor = pos; /* restore the cursor position */ validate_cursor(); - if (!equalpos(curwin->w_cursor, pos)) + if (!EQUAL_POS(curwin->w_cursor, pos)) { EMSG(_(e_compldel)); goto theend; @@ -5350,9 +5350,9 @@ ins_complete(int c, int enable_pum) { char_u *p = line + startcol; - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); while (p > line && vim_isfilec(PTR2CHAR(p))) - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); if (p == line && vim_isfilec(PTR2CHAR(p))) startcol = 0; else @@ -5422,7 +5422,7 @@ ins_complete(int c, int enable_pum) } curwin->w_cursor = pos; /* restore the cursor position */ validate_cursor(); - if (!equalpos(curwin->w_cursor, pos)) + if (!EQUAL_POS(curwin->w_cursor, pos)) { EMSG(_(e_compldel)); return FAIL; @@ -6003,9 +6003,9 @@ insert_special( #endif #ifdef FEAT_MBYTE -# define WHITECHAR(cc) (vim_iswhite(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1)))) +# define WHITECHAR(cc) (VIM_ISWHITE(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1)))) #else -# define WHITECHAR(cc) vim_iswhite(cc) +# define WHITECHAR(cc) VIM_ISWHITE(cc) #endif /* @@ -6051,7 +6051,7 @@ insertchar( */ if (textwidth > 0 && (force_format - || (!vim_iswhite(c) + || (!VIM_ISWHITE(c) && !((State & REPLACE_FLAG) #ifdef FEAT_VREPLACE && !(State & VREPLACE_FLAG) @@ -6108,7 +6108,7 @@ insertchar( ++p; middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); /* Don't count trailing white space for middle_len */ - while (middle_len > 0 && vim_iswhite(lead_end[middle_len - 1])) + while (middle_len > 0 && VIM_ISWHITE(lead_end[middle_len - 1])) --middle_len; /* Find the end-comment string */ @@ -6118,7 +6118,7 @@ insertchar( /* Skip white space before the cursor */ i = curwin->w_cursor.col; - while (--i >= 0 && vim_iswhite(line[i])) + while (--i >= 0 && VIM_ISWHITE(line[i])) ; i++; @@ -6307,7 +6307,7 @@ internal_format( ) { cc = gchar_cursor(); - if (vim_iswhite(cc)) + if (VIM_ISWHITE(cc)) { save_char = cc; pchar_cursor('x'); @@ -7045,13 +7045,13 @@ stop_insert( { dec_cursor(); cc = gchar_cursor(); - if (!vim_iswhite(cc)) + if (!VIM_ISWHITE(cc)) curwin->w_cursor = tpos; } auto_format(TRUE, FALSE); - if (vim_iswhite(cc)) + if (VIM_ISWHITE(cc)) { if (gchar_cursor() != NUL) inc_cursor(); @@ -7087,7 +7087,7 @@ stop_insert( if (gchar_cursor() == NUL && curwin->w_cursor.col > 0) --curwin->w_cursor.col; cc = gchar_cursor(); - if (!vim_iswhite(cc)) + if (!VIM_ISWHITE(cc)) break; if (del_char(TRUE) == FAIL) break; /* should not happen */ @@ -7237,7 +7237,7 @@ beginline(int flags) { char_u *ptr; - for (ptr = ml_get_curline(); vim_iswhite(*ptr) + for (ptr = ml_get_curline(); VIM_ISWHITE(*ptr) && !((flags & BL_FIX) && ptr[1] == NUL); ++ptr) ++curwin->w_cursor.col; } @@ -8961,7 +8961,7 @@ ins_bs( * can't backup past starting point unless 'backspace' > 1 * can backup to a previous line if 'backspace' == 0 */ - if ( bufempty() + if ( BUFEMPTY() || ( #ifdef FEAT_RIGHTLEFT !revins_on && @@ -9183,7 +9183,7 @@ ins_bs( /* delete characters until we are at or before want_vcol */ while (vcol > want_vcol - && (cc = *(ml_get_cursor() - 1), vim_iswhite(cc))) + && (cc = *(ml_get_cursor() - 1), VIM_ISWHITE(cc))) ins_bs_one(&vcol); /* insert extra spaces until we are at want_vcol */ @@ -9495,7 +9495,7 @@ ins_mousescroll(int dir) } # endif - if (!equalpos(curwin->w_cursor, tpos)) + if (!EQUAL_POS(curwin->w_cursor, tpos)) { start_arrow(&tpos); # ifdef FEAT_CINDENT @@ -10089,7 +10089,7 @@ ins_tab(void) /* Find first white before the cursor */ fpos = curwin->w_cursor; - while (fpos.col > 0 && vim_iswhite(ptr[-1])) + while (fpos.col > 0 && VIM_ISWHITE(ptr[-1])) { --fpos.col; --ptr; @@ -10110,7 +10110,7 @@ ins_tab(void) /* Use as many TABs as possible. Beware of 'breakindent', 'showbreak' * and 'linebreak' adding extra virtual columns. */ - while (vim_iswhite(*ptr)) + while (VIM_ISWHITE(*ptr)) { i = lbr_chartabsize(NULL, (char_u *)"\t", vcol); if (vcol + i > want_vcol) @@ -10489,7 +10489,7 @@ ins_try_si(int c) ptr = ml_get(pos->lnum); i = pos->col; if (i > 0) /* skip blanks before '{' */ - while (--i > 0 && vim_iswhite(ptr[i])) + while (--i > 0 && VIM_ISWHITE(ptr[i])) ; curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.col = i; diff --git a/src/eval.c b/src/eval.c index 61843bcfba..e5e787b5e0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1516,7 +1516,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first) if (error || eap->skip) { arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); - if (!vim_iswhite(*arg) && !ends_excmd(*arg)) + if (!VIM_ISWHITE(*arg) && !ends_excmd(*arg)) { emsg_severe = TRUE; EMSG(_(e_trailing)); @@ -1856,7 +1856,7 @@ get_lval( if (expr_start != NULL) { /* Don't expand the name when we already know there is an error. */ - if (unlet && !vim_iswhite(*p) && !ends_excmd(*p) + if (unlet && !VIM_ISWHITE(*p) && !ends_excmd(*p) && *p != '[' && *p != '.') { EMSG(_(e_trailing)); @@ -2449,7 +2449,7 @@ eval_for_line( return fi; expr = skipwhite(expr); - if (expr[0] != 'i' || expr[1] != 'n' || !vim_iswhite(expr[2])) + if (expr[0] != 'i' || expr[1] != 'n' || !VIM_ISWHITE(expr[2])) { EMSG(_("E690: Missing \"in\" after :for")); return fi; @@ -2551,8 +2551,8 @@ set_context_for_expression( for (p = arg + STRLEN(arg); p >= arg; ) { xp->xp_pattern = p; - mb_ptr_back(arg, p); - if (vim_iswhite(*p)) + MB_PTR_BACK(arg, p); + if (VIM_ISWHITE(*p)) break; } return; @@ -2698,7 +2698,7 @@ ex_unletlock( FNE_CHECK_START); if (lv.ll_name == NULL) error = TRUE; /* error but continue parsing */ - if (name_end == NULL || (!vim_iswhite(*name_end) + if (name_end == NULL || (!VIM_ISWHITE(*name_end) && !ends_excmd(*name_end))) { if (name_end != NULL) @@ -4814,7 +4814,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate) /* * Find the end of the string, skipping backslashed characters. */ - for (p = *arg + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) + for (p = *arg + 1; *p != NUL && *p != '"'; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) { @@ -4952,7 +4952,7 @@ get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) /* * Find the end of the string, skipping ''. */ - for (p = *arg + 1; *p != NUL; mb_ptr_adv(p)) + for (p = *arg + 1; *p != NUL; MB_PTR_ADV(p)) { if (*p == '\'') { @@ -5910,7 +5910,7 @@ string_quote(char_u *str, int function) if (str != NULL) { len += (unsigned)STRLEN(str); - for (p = str; *p != NUL; mb_ptr_adv(p)) + for (p = str; *p != NUL; MB_PTR_ADV(p)) if (*p == '\'') ++len; } @@ -6369,12 +6369,12 @@ find_name_end( || *p == '{' || ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.')) || mb_nest != 0 - || br_nest != 0); mb_ptr_adv(p)) + || br_nest != 0); MB_PTR_ADV(p)) { if (*p == '\'') { /* skip over 'string' to avoid counting [ and ] inside it. */ - for (p = p + 1; *p != NUL && *p != '\''; mb_ptr_adv(p)) + for (p = p + 1; *p != NUL && *p != '\''; MB_PTR_ADV(p)) ; if (*p == NUL) break; @@ -6382,7 +6382,7 @@ find_name_end( else if (*p == '"') { /* skip over "str\"ing" to avoid counting [ and ] inside it. */ - for (p = p + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) + for (p = p + 1; *p != NUL && *p != '"'; MB_PTR_ADV(p)) if (*p == '\\' && p[1] != NUL) ++p; if (*p == NUL) @@ -6866,7 +6866,7 @@ handle_subscript( || (**arg == '.' && rettv->v_type == VAR_DICT) || (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC || rettv->v_type == VAR_PARTIAL))) - && !vim_iswhite(*(*arg - 1))) + && !VIM_ISWHITE(*(*arg - 1))) { if (**arg == '(') { @@ -9410,7 +9410,7 @@ shortpath_for_partial( /* Count up the path separators from the RHS.. so we know which part * of the path to return. */ sepcount = 0; - for (p = *fnamep; p < *fnamep + *fnamelen; mb_ptr_adv(p)) + for (p = *fnamep; p < *fnamep + *fnamelen; MB_PTR_ADV(p)) if (vim_ispathsep(*p)) ++sepcount; @@ -9528,7 +9528,7 @@ repeat: } /* When "/." or "/.." is used: force expansion to get rid of it. */ - for (p = *fnamep; *p != NUL; mb_ptr_adv(p)) + for (p = *fnamep; *p != NUL; MB_PTR_ADV(p)) { if (vim_ispathsep(*p) && p[1] == '.' @@ -9658,7 +9658,7 @@ repeat: *usedlen += 2; s = get_past_head(*fnamep); while (tail > s && after_pathsep(s, tail)) - mb_ptr_back(*fnamep, tail); + MB_PTR_BACK(*fnamep, tail); *fnamelen = (int)(tail - *fnamep); #ifdef VMS if (*fnamelen > 0) @@ -9677,7 +9677,7 @@ repeat: else { while (tail > s && !after_pathsep(s, tail)) - mb_ptr_back(*fnamep, tail); + MB_PTR_BACK(*fnamep, tail); } } diff --git a/src/evalfunc.c b/src/evalfunc.c index 6ec458abb5..c8d69eb1ca 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3534,7 +3534,7 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv) } } count = (long)(foldend - foldstart + 1); - txt = ngettext("+-%s%3ld line: ", "+-%s%3ld lines: ", count); + txt = NGETTEXT("+-%s%3ld line: ", "+-%s%3ld lines: ", count); r = alloc((unsigned)(STRLEN(txt) + STRLEN(dashes) /* for %s */ + 20 /* for %3ld */ @@ -9579,20 +9579,20 @@ do_searchpair( save_cursor = curwin->w_cursor; pos = curwin->w_cursor; - clearpos(&firstpos); - clearpos(&foundpos); + CLEAR_POS(&firstpos); + CLEAR_POS(&foundpos); pat = pat3; for (;;) { n = searchit(curwin, curbuf, &pos, dir, pat, 1L, options, RE_SEARCH, lnum_stop, &tm); - if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) + if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos))) /* didn't find it or found the first match again: FAIL */ break; if (firstpos.lnum == 0) firstpos = pos; - if (equalpos(pos, foundpos)) + if (EQUAL_POS(pos, foundpos)) { /* Found the same position again. Can happen with a pattern that * has "\zs" at the end and searching backwards. Advance one diff --git a/src/ex_cmds.c b/src/ex_cmds.c index c38687d740..64d7f6b847 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -256,7 +256,7 @@ linelen(int *has_tab) /* find the character after the last non-blank character */ for (last = first + STRLEN(first); - last > first && vim_iswhite(last[-1]); --last) + last > first && VIM_ISWHITE(last[-1]); --last) ; save = *last; *last = NUL; @@ -400,7 +400,7 @@ ex_sort(exarg_T *eap) for (p = eap->arg; *p != NUL; ++p) { - if (vim_iswhite(*p)) + if (VIM_ISWHITE(*p)) ; else if (*p == 'i') sort_ic = TRUE; @@ -683,7 +683,7 @@ ex_retab(exarg_T *eap) did_undo = FALSE; for (;;) { - if (vim_iswhite(ptr[col])) + if (VIM_ISWHITE(ptr[col])) { if (!got_tab && num_spaces == 0) { @@ -4211,7 +4211,7 @@ do_ecmd( /* If autocommands change the cursor position or topline, we should * keep it. Also when it moves within a line. */ - if (!equalpos(curwin->w_cursor, orig_pos)) + if (!EQUAL_POS(curwin->w_cursor, orig_pos)) { newlnum = curwin->w_cursor.lnum; newcol = curwin->w_cursor.col; @@ -4807,7 +4807,7 @@ do_sub(exarg_T *eap) which_pat = RE_SUBST; /* use last substitute regexp */ /* new pattern and substitution */ - if (eap->cmd[0] == 's' && *cmd != NUL && !vim_iswhite(*cmd) + if (eap->cmd[0] == 's' && *cmd != NUL && !VIM_ISWHITE(*cmd) && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL) { /* don't accept alphanumeric for separator */ @@ -4863,7 +4863,7 @@ do_sub(exarg_T *eap) } if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */ ++cmd; - mb_ptr_adv(cmd); + MB_PTR_ADV(cmd); } if (!eap->skip) @@ -6225,7 +6225,7 @@ ex_help(exarg_T *eap) /* remove trailing blanks */ p = arg + STRLEN(arg) - 1; - while (p > arg && vim_iswhite(*p) && p[-1] != '\\') + while (p > arg && VIM_ISWHITE(*p) && p[-1] != '\\') *p-- = NUL; #ifdef FEAT_MULTI_LANG @@ -6809,7 +6809,7 @@ fix_help_buffer(void) { line = ml_get_buf(curbuf, lnum, FALSE); len = (int)STRLEN(line); - if (in_example && len > 0 && !vim_iswhite(line[0])) + if (in_example && len > 0 && !VIM_ISWHITE(line[0])) { /* End of example: non-white or '<' in first column. */ if (line[0] == '<') @@ -7421,7 +7421,7 @@ ex_helptags(exarg_T *eap) int add_help_tags = FALSE; /* Check for ":helptags ++t {dir}". */ - if (STRNCMP(eap->arg, "++t", 3) == 0 && vim_iswhite(eap->arg[3])) + if (STRNCMP(eap->arg, "++t", 3) == 0 && VIM_ISWHITE(eap->arg[3])) { add_help_tags = TRUE; eap->arg = skipwhite(eap->arg + 3); @@ -7754,7 +7754,7 @@ ex_sign(exarg_T *eap) if (VIM_ISDIGIT(*arg)) { id = getdigits(&arg); - if (!vim_iswhite(*arg) && *arg != NUL) + if (!VIM_ISWHITE(*arg) && *arg != NUL) { id = -1; arg = arg1; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 51356d2b59..c66fcb17a6 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3599,7 +3599,7 @@ add_pack_plugin(char_u *fname, void *cookie) { /* directory is not yet in 'runtimepath', add it */ p4 = p3 = p2 = p1 = get_past_head(ffname); - for (p = p1; *p; mb_ptr_adv(p)) + for (p = p1; *p; MB_PTR_ADV(p)) if (vim_ispathsep_nocolon(*p)) { p4 = p3; p3 = p2; p2 = p1; p1 = p; @@ -5256,7 +5256,7 @@ ex_language(exarg_T *eap) * Allow abbreviation, but require at least 3 characters to avoid * confusion with a two letter language name "me" or "ct". */ p = skiptowhite(eap->arg); - if ((*p == NUL || vim_iswhite(*p)) && p - eap->arg >= 3) + if ((*p == NUL || VIM_ISWHITE(*p)) && p - eap->arg >= 3) { if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) { diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 1dd67daca7..07bd4d9718 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2020,7 +2020,7 @@ do_one_cmd( if (save_msg_silent == -1) save_msg_silent = msg_silent; ++msg_silent; - if (*ea.cmd == '!' && !vim_iswhite(ea.cmd[-1])) + if (*ea.cmd == '!' && !VIM_ISWHITE(ea.cmd[-1])) { /* ":silent!", but not "silent !cmd" */ ea.cmd = skipwhite(ea.cmd + 1); @@ -2778,7 +2778,7 @@ do_one_cmd( */ if ((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg) && (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == NUL - || vim_iswhite(*p))) + || VIM_ISWHITE(*p))) { n = getdigits(&ea.arg); ea.arg = skipwhite(ea.arg); @@ -2946,7 +2946,7 @@ do_one_cmd( else { p = ea.arg + STRLEN(ea.arg); - while (p > ea.arg && vim_iswhite(p[-1])) + while (p > ea.arg && VIM_ISWHITE(p[-1])) --p; } ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & BUFUNL) != 0, @@ -3703,7 +3703,7 @@ set_one_cmd_context( return NULL; /* It's a comment */ } } - mb_ptr_adv(p); + MB_PTR_ADV(p); } } @@ -3727,7 +3727,7 @@ set_one_cmd_context( { if (*p == '\\' && *(p + 1) != NUL) ++p; /* skip over escaped character */ - mb_ptr_adv(p); + MB_PTR_ADV(p); } } @@ -3764,7 +3764,7 @@ set_one_cmd_context( } /* An argument can contain just about everything, except * characters that end the command and white space. */ - else if (c == '|' || c == '\n' || c == '"' || (vim_iswhite(c) + else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c) #ifdef SPACE_IN_FILENAME && (!(ea.argt & NOSPC) || usefilter) #endif @@ -3787,7 +3787,7 @@ set_one_cmd_context( else #endif len = 1; - mb_ptr_adv(p); + MB_PTR_ADV(p); } if (in_quote) bow = p; @@ -3795,7 +3795,7 @@ set_one_cmd_context( xp->xp_pattern = p; p -= len; } - mb_ptr_adv(p); + MB_PTR_ADV(p); } /* @@ -4211,7 +4211,7 @@ set_one_cmd_context( arg = p + 1; else if (*p == '\\' && *(p + 1) != NUL) ++p; /* skip over escaped character */ - mb_ptr_adv(p); + MB_PTR_ADV(p); } xp->xp_pattern = arg; } @@ -5153,7 +5153,7 @@ expand_filename( /* skip escaped characters */ if (p[1] && (*p == '\\' || *p == Ctrl_V)) ++p; - else if (vim_iswhite(*p)) + else if (VIM_ISWHITE(*p)) { *errormsgp = (char_u *)_("E172: Only one file name allowed"); return FAIL; @@ -5297,7 +5297,7 @@ separate_nextcmd(exarg_T *eap) p = eap->arg; #endif - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (*p == Ctrl_V) { @@ -5397,7 +5397,7 @@ skip_cmd_arg( else ++p; } - mb_ptr_adv(p); + MB_PTR_ADV(p); } return p; } @@ -6353,7 +6353,7 @@ ex_command(exarg_T *eap) if (ASCII_ISALPHA(*p)) while (ASCII_ISALNUM(*p)) ++p; - if (!ends_excmd(*p) && !vim_iswhite(*p)) + if (!ends_excmd(*p) && !VIM_ISWHITE(*p)) { EMSG(_("E182: Invalid command name")); return; @@ -6481,7 +6481,7 @@ uc_split_args(char_u *arg, size_t *lenp) len += 2; p += 2; } - else if (p[0] == '\\' && vim_iswhite(p[1])) + else if (p[0] == '\\' && VIM_ISWHITE(p[1])) { len += 1; p += 2; @@ -6491,7 +6491,7 @@ uc_split_args(char_u *arg, size_t *lenp) len += 2; p += 1; } - else if (vim_iswhite(*p)) + else if (VIM_ISWHITE(*p)) { p = skipwhite(p); if (*p == NUL) @@ -6529,7 +6529,7 @@ uc_split_args(char_u *arg, size_t *lenp) *q++ = '\\'; p += 2; } - else if (p[0] == '\\' && vim_iswhite(p[1])) + else if (p[0] == '\\' && VIM_ISWHITE(p[1])) { *q++ = p[1]; p += 2; @@ -6539,7 +6539,7 @@ uc_split_args(char_u *arg, size_t *lenp) *q++ = '\\'; *q++ = *p++; } - else if (vim_iswhite(*p)) + else if (VIM_ISWHITE(*p)) { p = skipwhite(p); if (*p == NUL) @@ -7095,7 +7095,7 @@ parse_addr_type_arg( { char_u *err = value; - for (i = 0; err[i] != NUL && !vim_iswhite(err[i]); i++) + for (i = 0; err[i] != NUL && !VIM_ISWHITE(err[i]); i++) ; err[i] = NUL; EMSG2(_("E180: Invalid address type value: %s"), err); @@ -11896,7 +11896,7 @@ ses_put_fname(FILE *fd, char_u *name, unsigned *flagp) if (*flagp & SSOP_SLASH) { /* change all backslashes to forward slashes */ - for (p = sname; *p != NUL; mb_ptr_adv(p)) + for (p = sname; *p != NUL; MB_PTR_ADV(p)) if (*p == '\\') *p = '/'; } @@ -12299,7 +12299,7 @@ ex_match(exarg_T *eap) if (ends_excmd(*eap->arg)) end = eap->arg; else if ((STRNICMP(eap->arg, "none", 4) == 0 - && (vim_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) + && (VIM_ISWHITE(eap->arg[4]) || ends_excmd(eap->arg[4])))) end = eap->arg + 4; else { diff --git a/src/ex_getln.c b/src/ex_getln.c index 08f04d12f7..6fff93841b 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -234,7 +234,7 @@ getcmdline( ccline.overstrike = FALSE; /* always start in insert mode */ #ifdef FEAT_SEARCH_EXTRA - clearpos(&match_end); + CLEAR_POS(&match_end); save_cursor = curwin->w_cursor; /* may be restored later */ search_start = curwin->w_cursor; old_curswant = curwin->w_curswant; @@ -1487,7 +1487,7 @@ getcmdline( if (did_incsearch) { curwin->w_cursor = match_end; - if (!equalpos(curwin->w_cursor, search_start)) + if (!EQUAL_POS(curwin->w_cursor, search_start)) { c = gchar_cursor(); /* If 'ignorecase' and 'smartcase' are set and the @@ -1715,7 +1715,7 @@ getcmdline( search_start = t; (void)decl(&search_start); } - if (lt(t, search_start) && c == Ctrl_G) + if (LT_POS(t, search_start) && c == Ctrl_G) { /* wrap around */ search_start = t; @@ -2015,7 +2015,7 @@ returncmd: curwin->w_cursor = save_cursor; else { - if (!equalpos(save_cursor, search_start)) + if (!EQUAL_POS(save_cursor, search_start)) { /* put the '" mark at the original position */ curwin->w_cursor = save_cursor; @@ -4307,7 +4307,7 @@ sm_gettail(char_u *s) t = p; had_sep = FALSE; } - mb_ptr_adv(p); + MB_PTR_ADV(p); } return t; } @@ -5384,7 +5384,7 @@ ExpandRTDir( if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0) { e -= 4; - for (s = e; s > match; mb_ptr_back(match, s)) + for (s = e; s > match; MB_PTR_BACK(match, s)) if (s < match || vim_ispathsep(*s)) break; ++s; @@ -6041,7 +6041,7 @@ remove_key_from_history(void) if (p == NULL) break; ++p; - for (i = 0; p[i] && !vim_iswhite(p[i]); ++i) + for (i = 0; p[i] && !VIM_ISWHITE(p[i]); ++i) if (p[i] == '\\' && p[i + 1]) ++i; STRMOVE(p, p + i); diff --git a/src/fileio.c b/src/fileio.c index 5f139461a8..6b269708e5 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -6252,7 +6252,7 @@ buf_modname( * Then truncate what is after the '/', '\' or ':' to 8 characters for * MSDOS and 26 characters for AMIGA, a lot more for UNIX. */ - for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr)) + for (ptr = retval + fnamelen; ptr > retval; MB_PTR_BACK(retval, ptr)) { if (*ext == '.' #ifdef USE_LONG_FNAME @@ -7156,7 +7156,7 @@ buf_reload(buf_T *buf, int orig_mode) * the old contents. Can't use memory only, the file might be * too big. Use a hidden buffer to move the buffer contents to. */ - if (bufempty() || saved == FAIL) + if (BUFEMPTY() || saved == FAIL) savebuf = NULL; else { @@ -7199,7 +7199,7 @@ buf_reload(buf_T *buf, int orig_mode) { /* Put the text back from the save buffer. First * delete any lines that readfile() added. */ - while (!bufempty()) + while (!BUFEMPTY()) if (ml_delete(buf->b_ml.ml_line_count, FALSE) == FAIL) break; (void)move_lines(savebuf, buf); @@ -8201,7 +8201,7 @@ event_name2nr(char_u *start, char_u **end) int len; /* the event name ends with end of line, '|', a blank or a comma */ - for (p = start; *p && !vim_iswhite(*p) && *p != ',' && *p != '|'; ++p) + for (p = start; *p && !VIM_ISWHITE(*p) && *p != ',' && *p != '|'; ++p) ; for (i = 0; event_names[i].name != NULL; ++i) { @@ -8244,7 +8244,7 @@ find_end_event( if (*arg == '*') { - if (arg[1] && !vim_iswhite(arg[1])) + if (arg[1] && !VIM_ISWHITE(arg[1])) { EMSG2(_("E215: Illegal character after *: %s"), arg); return NULL; @@ -8253,7 +8253,7 @@ find_end_event( } else { - for (pat = arg; *pat && *pat != '|' && !vim_iswhite(*pat); pat = p) + for (pat = arg; *pat && *pat != '|' && !VIM_ISWHITE(*pat); pat = p) { if ((int)event_name2nr(pat, &p) >= (int)NUM_EVENTS) { @@ -8432,7 +8432,7 @@ do_autocmd(char_u *arg_in, int forceit) * Scan over the pattern. Put a NUL at the end. */ cmd = pat; - while (*cmd && (!vim_iswhite(*cmd) || cmd[-1] == '\\')) + while (*cmd && (!VIM_ISWHITE(*cmd) || cmd[-1] == '\\')) cmd++; if (*cmd) *cmd++ = NUL; @@ -8458,7 +8458,7 @@ do_autocmd(char_u *arg_in, int forceit) * Check for "nested" flag. */ cmd = skipwhite(cmd); - if (*cmd != NUL && STRNCMP(cmd, "nested", 6) == 0 && vim_iswhite(cmd[6])) + if (*cmd != NUL && STRNCMP(cmd, "nested", 6) == 0 && VIM_ISWHITE(cmd[6])) { nested = TRUE; cmd = skipwhite(cmd + 6); @@ -8501,7 +8501,7 @@ do_autocmd(char_u *arg_in, int forceit) } else { - while (*arg && *arg != '|' && !vim_iswhite(*arg)) + while (*arg && *arg != '|' && !VIM_ISWHITE(*arg)) if (do_autocmd_event(event_name2nr(arg, &arg), pat, nested, cmd, forceit, group) == FAIL) break; @@ -8526,7 +8526,7 @@ au_get_grouparg(char_u **argp) char_u *arg = *argp; int group = AUGROUP_ALL; - for (p = arg; *p && !vim_iswhite(*p) && *p != '|'; ++p) + for (p = arg; *p && !VIM_ISWHITE(*p) && *p != '|'; ++p) ; if (p > arg) { @@ -8838,7 +8838,7 @@ do_doautocmd( /* * Loop over the events. */ - while (*arg && !vim_iswhite(*arg)) + while (*arg && !VIM_ISWHITE(*arg)) if (apply_autocmds_group(event_name2nr(arg, &arg), fname, NULL, TRUE, group, curbuf, NULL)) nothing_done = FALSE; @@ -9954,14 +9954,14 @@ set_context_in_autocmd( if (group == AUGROUP_ERROR) return NULL; /* If there only is a group name that's what we expand. */ - if (*arg == NUL && group != AUGROUP_ALL && !vim_iswhite(arg[-1])) + if (*arg == NUL && group != AUGROUP_ALL && !VIM_ISWHITE(arg[-1])) { arg = p; group = AUGROUP_ALL; } /* skip over event name */ - for (p = arg; *p != NUL && !vim_iswhite(*p); ++p) + for (p = arg; *p != NUL && !VIM_ISWHITE(*p); ++p) if (*p == ',') arg = p + 1; if (*p == NUL) @@ -9975,7 +9975,7 @@ set_context_in_autocmd( /* skip over pattern */ arg = skipwhite(p); - while (*arg && (!vim_iswhite(*arg) || arg[-1] == '\\')) + while (*arg && (!VIM_ISWHITE(*arg) || arg[-1] == '\\')) arg++; if (*arg) return arg; /* expand (next) command */ diff --git a/src/fold.c b/src/fold.c index d75e937003..826ad5c8dc 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1039,7 +1039,7 @@ foldAdjustVisual(void) if (!VIsual_active || !hasAnyFolding(curwin)) return; - if (ltoreq(VIsual, curwin->w_cursor)) + if (LTOREQ_POS(VIsual, curwin->w_cursor)) { start = &VIsual; end = &curwin->w_cursor; @@ -1760,6 +1760,7 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen) int line_len; char_u *newline; char_u *p = (char_u *)strstr((char *)curbuf->b_p_cms, "%s"); + int line_is_comment = FALSE; /* Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end */ line = ml_get(lnum); @@ -1767,11 +1768,16 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen) if (u_save(lnum - 1, lnum + 1) == OK) { +#if defined(FEAT_COMMENTS) + /* Check if the line ends with an unclosed comment */ + (void)skip_comment(line, FALSE, FALSE, &line_is_comment); +#endif newline = alloc((unsigned)(line_len + markerlen + STRLEN(cms) + 1)); if (newline == NULL) return; STRCPY(newline, line); - if (p == NULL) + /* Append the marker to the end of the line */ + if (p == NULL || line_is_comment) vim_strncpy(newline + line_len, marker, markerlen); else { @@ -1970,7 +1976,7 @@ get_foldtext( long count = (long)(lnume - lnum + 1); vim_snprintf((char *)buf, FOLD_TEXT_LEN, - ngettext("+--%3ld line folded ", + NGETTEXT("+--%3ld line folded ", "+--%3ld lines folded ", count), count); text = buf; @@ -1998,7 +2004,7 @@ foldtext_cleanup(char_u *str) /* Ignore leading and trailing white space in 'commentstring'. */ cms_start = skipwhite(curbuf->b_p_cms); cms_slen = (int)STRLEN(cms_start); - while (cms_slen > 0 && vim_iswhite(cms_start[cms_slen - 1])) + while (cms_slen > 0 && VIM_ISWHITE(cms_start[cms_slen - 1])) --cms_slen; /* locate "%s" in 'commentstring', use the part before and after it. */ @@ -2009,7 +2015,7 @@ foldtext_cleanup(char_u *str) cms_slen = (int)(cms_end - cms_start); /* exclude white space before "%s" */ - while (cms_slen > 0 && vim_iswhite(cms_start[cms_slen - 1])) + while (cms_slen > 0 && VIM_ISWHITE(cms_start[cms_slen - 1])) --cms_slen; /* skip "%s" and white space after it */ @@ -2033,7 +2039,7 @@ foldtext_cleanup(char_u *str) /* May remove 'commentstring' start. Useful when it's a double * quote and we already removed a double quote. */ - for (p = s; p > str && vim_iswhite(p[-1]); --p) + for (p = s; p > str && VIM_ISWHITE(p[-1]); --p) ; if (p >= str + cms_slen && STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) @@ -2058,13 +2064,13 @@ foldtext_cleanup(char_u *str) } if (len != 0) { - while (vim_iswhite(s[len])) + while (VIM_ISWHITE(s[len])) ++len; STRMOVE(s, s + len); } else { - mb_ptr_adv(s); + MB_PTR_ADV(s); } } } @@ -3249,7 +3255,7 @@ foldlevelMarker(fline_T *flp) --flp->lvl_next; } else - mb_ptr_adv(s); + MB_PTR_ADV(s); } /* The level can't go negative, must be missing a start marker. */ diff --git a/src/getchar.c b/src/getchar.c index e6c7268aff..ec207891df 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2651,7 +2651,7 @@ vgetorpeek(int advance) ptr = ml_get_curline(); while (col < curwin->w_cursor.col) { - if (!vim_iswhite(ptr[col])) + if (!VIM_ISWHITE(ptr[col])) curwin->w_wcol = vcol; vcol += lbr_chartabsize(ptr, ptr + col, (colnr_T)vcol); @@ -3324,7 +3324,7 @@ do_map( */ p = keys; do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); - while (*p && (maptype == 1 || !vim_iswhite(*p))) + while (*p && (maptype == 1 || !VIM_ISWHITE(*p))) { if ((p[0] == Ctrl_V || (do_backslash && p[0] == '\\')) && p[1] != NUL) @@ -3429,7 +3429,7 @@ do_map( } /* An abbreviation cannot contain white space. */ for (n = 0; n < len; ++n) - if (vim_iswhite(keys[n])) + if (VIM_ISWHITE(keys[n])) { retval = 1; goto theend; @@ -5043,7 +5043,7 @@ put_escstr(FILE *fd, char_u *strstart, int what) * interpreted as the start of a special key name. * A space in the lhs of a :map needs a CTRL-V. */ - if (what == 2 && (vim_iswhite(c) || c == '"' || c == '\\')) + if (what == 2 && (VIM_ISWHITE(c) || c == '"' || c == '\\')) { if (putc('\\', fd) < 0) return FAIL; diff --git a/src/gui.c b/src/gui.c index e36927e488..250ad3bde0 100644 --- a/src/gui.c +++ b/src/gui.c @@ -4525,7 +4525,7 @@ gui_do_scroll(void) pum_redraw(); #endif - return (wp == curwin && !equalpos(curwin->w_cursor, old_cursor)); + return (wp == curwin && !EQUAL_POS(curwin->w_cursor, old_cursor)); } @@ -4549,7 +4549,7 @@ scroll_line_len(linenr_T lnum) for (;;) { w = chartabsize(p, col); - mb_ptr_adv(p); + MB_PTR_ADV(p); if (*p == NUL) /* don't count the last character */ break; col += w; @@ -5027,7 +5027,7 @@ ex_gui(exarg_T *eap) */ if (arg[0] == '-' && (arg[1] == 'f' || arg[1] == 'b') - && (arg[2] == NUL || vim_iswhite(arg[2]))) + && (arg[2] == NUL || VIM_ISWHITE(arg[2]))) { gui.dofork = (arg[1] == 'b'); eap->arg = skipwhite(eap->arg + 2); @@ -5179,7 +5179,7 @@ gui_update_screen(void) curwin->w_p_cole > 0 # endif ) - && !equalpos(last_cursormoved, curwin->w_cursor)) + && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) { # ifdef FEAT_AUTOCMD if (has_cursormoved()) diff --git a/src/gui_beval.c b/src/gui_beval.c index f108105f7f..d71a716a10 100644 --- a/src/gui_beval.c +++ b/src/gui_beval.c @@ -84,7 +84,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED) result = eval_to_string(bexpr, NULL, TRUE); /* Remove one trailing newline, it is added when the result was a - * list and it's hardly every useful. If the user really wants a + * list and it's hardly ever useful. If the user really wants a * trailing newline he can add two and one remains. */ if (result != NULL) { @@ -366,7 +366,7 @@ get_beval_info( if (VIsual_active) { - if (lt(VIsual, curwin->w_cursor)) + if (LT_POS(VIsual, curwin->w_cursor)) { spos = &VIsual; epos = &curwin->w_cursor; diff --git a/src/gui_gtk.c b/src/gui_gtk.c index c015d7ee66..c175dd31e9 100644 --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -51,9 +51,6 @@ # ifdef _ # undef _ # endif -# ifdef ngettext -# undef ngettext -# endif # ifdef N_ # undef N_ # endif @@ -1522,7 +1519,7 @@ split_button_string(char_u *button_string, int *n_buttons) else if (*p == DLG_HOTKEY_CHAR) *p++ = '_'; else - mb_ptr_adv(p); + MB_PTR_ADV(p); } array[count] = NULL; /* currently not relied upon, but doesn't hurt */ } diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 4bcdc50d19..c00b3d6c49 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -35,9 +35,6 @@ # ifdef _ # undef _ # endif -# ifdef ngettext -# undef ngettext -# endif # ifdef N_ # undef N_ # endif diff --git a/src/gui_w32.c b/src/gui_w32.c index cd9f31e215..fc566abee9 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -7112,7 +7112,7 @@ gui_mch_dialog( #else l = 1; #endif - if (l == 1 && vim_iswhite(*pend) + if (l == 1 && VIM_ISWHITE(*pend) && textWidth > maxDialogWidth * 3 / 4) last_white = pend; textWidth += GetTextWidthEnc(hdc, pend, l); @@ -8581,6 +8581,7 @@ gui_mch_enable_beval_area(BalloonEval *beval) gui_mch_post_balloon(BalloonEval *beval, char_u *mesg) { POINT pt; + // TRACE0("gui_mch_post_balloon {{{"); if (beval->showState == ShS_SHOWING) return; @@ -8588,8 +8589,8 @@ gui_mch_post_balloon(BalloonEval *beval, char_u *mesg) ScreenToClient(s_textArea, &pt); if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3) - /* cursor is still here */ { + /* cursor is still here */ gui_mch_disable_beval_area(cur_beval); beval->showState = ShS_SHOWING; make_tooltip(beval, (char *)mesg, pt); diff --git a/src/gui_x11.c b/src/gui_x11.c index 2cc0eba85c..2226e89547 100644 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -1992,14 +1992,40 @@ gui_mch_get_font(char_u *name, int giveErrorIfMissing) #if defined(FEAT_EVAL) || defined(PROTO) /* * Return the name of font "font" in allocated memory. - * Don't know how to get the actual name, thus use the provided name. */ char_u * -gui_mch_get_fontname(GuiFont font UNUSED, char_u *name) +gui_mch_get_fontname(GuiFont font, char_u *name) { - if (name == NULL) - return NULL; - return vim_strsave(name); + char_u *ret = NULL; + + if (name != NULL && font == NULL) + { + /* In this case, there's no way other than doing this. */ + ret = vim_strsave(name); + } + else if (font != NULL) + { + /* In this case, try to retrieve the XLFD corresponding to 'font'->fid; + * if failed, use 'name' unless it's NULL. */ + unsigned long value = 0L; + + if (XGetFontProperty(font, XA_FONT, &value)) + { + char *xa_font_name = NULL; + + xa_font_name = XGetAtomName(gui.dpy, value); + if (xa_font_name != NULL) + { + ret = vim_strsave((char_u *)xa_font_name); + XFree(xa_font_name); + } + else if (name != NULL) + ret = vim_strsave(name); + } + else if (name != NULL) + ret = vim_strsave(name); + } + return ret; } #endif diff --git a/src/if_cscope.c b/src/if_cscope.c index 5b384982e3..7a533230f3 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -781,7 +781,7 @@ cs_create_cmd(char *csoption, char *pattern) * they may want to use the leading white space. */ pat = pattern; if (search != 4 && search != 6) - while vim_iswhite(*pat) + while VIM_ISWHITE(*pat) ++pat; if ((cmd = (char *)alloc((unsigned)(strlen(pat) + 2))) == NULL) diff --git a/src/if_perl.xs b/src/if_perl.xs index ecb9726e3b..076c5c6019 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -1288,7 +1288,7 @@ ex_perldo(exarg_T *eap) linenr_T i; buf_T *was_curbuf = curbuf; - if (bufempty()) + if (BUFEMPTY()) return; if (perl_interp == NULL) diff --git a/src/macros.h b/src/macros.h index faa8ccc9c5..8ebc8ceb81 100644 --- a/src/macros.h +++ b/src/macros.h @@ -8,49 +8,58 @@ /* * macros.h: macro definitions for often used code + * + * Macros should be ALL_CAPS. An exception is for where a function is + * replaced and an argument is not used more than once. */ /* - * pchar(lp, c) - put character 'c' at position 'lp' + * PCHAR(lp, c) - put character 'c' at position 'lp' */ -#define pchar(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c)) +#define PCHAR(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c)) /* * Position comparisons */ #ifdef FEAT_VIRTUALEDIT -# define lt(a, b) (((a).lnum != (b).lnum) \ +# define LT_POS(a, b) (((a).lnum != (b).lnum) \ ? (a).lnum < (b).lnum \ : (a).col != (b).col \ ? (a).col < (b).col \ : (a).coladd < (b).coladd) -# define ltp(a, b) (((a)->lnum != (b)->lnum) \ +# define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \ ? (a)->lnum < (b)->lnum \ : (a)->col != (b)->col \ ? (a)->col < (b)->col \ : (a)->coladd < (b)->coladd) -# define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd)) -# define clearpos(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;} +# define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd)) +# define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;} #else -# define lt(a, b) (((a).lnum != (b).lnum) \ +# define LT_POS(a, b) (((a).lnum != (b).lnum) \ ? ((a).lnum < (b).lnum) : ((a).col < (b).col)) -# define ltp(a, b) (((a)->lnum != (b)->lnum) \ +# define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \ ? ((a)->lnum < (b)->lnum) : ((a)->col < (b)->col)) -# define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col)) -# define clearpos(a) {(a)->lnum = 0; (a)->col = 0;} +# define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col)) +# define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0;} #endif -#define ltoreq(a, b) (lt(a, b) || equalpos(a, b)) +#define LTOREQ_POS(a, b) (LT_POS(a, b) || EQUAL_POS(a, b)) /* - * lineempty() - return TRUE if the line is empty + * VIM_ISWHITE() is used for "^" and the like. It differs from isspace() + * because it doesn't include and and the like. */ -#define lineempty(p) (*ml_get(p) == NUL) +#define VIM_ISWHITE(x) ((x) == ' ' || (x) == '\t') /* - * bufempty() - return TRUE if the current buffer is empty + * LINEEMPTY() - return TRUE if the line is empty */ -#define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL) +#define LINEEMPTY(p) (*ml_get(p) == NUL) + +/* + * BUFEMPTY() - return TRUE if the current buffer is empty + */ +#define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL) /* * toupper() and tolower() that use the current locale. @@ -161,10 +170,10 @@ #endif /* - * vim_isbreak() is used very often if 'linebreak' is set, use a macro to make - * it work fast. + * VIM_ISBREAK() is used very often if 'linebreak' is set, use a macro to make + * it work fast. Only works for single byte characters! */ -#define vim_isbreak(c) (breakat_flags[(char_u)(c)]) +#define VIM_ISBREAK(c) ((c) < 256 && breakat_flags[(char_u)(c)]) /* * On VMS file names are different and require a translation. @@ -190,9 +199,7 @@ # define mch_stat(n, p) vim_stat((n), (p)) # else # ifdef STAT_IGNORES_SLASH - /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if - * the name ends in "/" and it's not a directory. */ -# define mch_stat(n, p) (illegal_slash(n) ? -1 : stat((n), (p))) +# define mch_stat(n, p) vim_stat((n), (p)) # else # define mch_stat(n, p) stat((n), (p)) # endif @@ -258,22 +265,22 @@ #endif /* - * mb_ptr_adv(): advance a pointer to the next character, taking care of + * MB_PTR_ADV(): advance a pointer to the next character, taking care of * multi-byte characters if needed. - * mb_ptr_back(): backup a pointer to the previous character, taking care of + * MB_PTR_BACK(): backup a pointer to the previous character, taking care of * multi-byte characters if needed. * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. * PTR2CHAR(): get character from pointer. */ #ifdef FEAT_MBYTE /* Get the length of the character p points to */ -# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) +# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) /* Advance multi-byte pointer, skip over composing chars. */ -# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 +# define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 /* Advance multi-byte pointer, do not skip over composing chars. */ -# define mb_cptr_adv(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1 +# define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1 /* Backup multi-byte pointer. Only use with "p" > "s" ! */ -# define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 +# define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 /* get length of multi-byte char, not including composing chars */ # define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) @@ -284,9 +291,9 @@ #else # define MB_PTR2LEN(p) 1 # define MB_CPTR2LEN(p) 1 -# define mb_ptr_adv(p) ++p -# define mb_cptr_adv(p) ++p -# define mb_ptr_back(s, p) --p +# define MB_PTR_ADV(p) ++p +# define MB_CPTR_ADV(p) ++p +# define MB_PTR_BACK(s, p) --p # define MB_COPY_CHAR(f, t) *t++ = *f++ # define MB_CHARLEN(p) STRLEN(p) # define MB_CHAR2LEN(c) 1 diff --git a/src/main.c b/src/main.c index 3ba5249b38..382fc24a49 100644 --- a/src/main.c +++ b/src/main.c @@ -1213,7 +1213,7 @@ main_loop( # endif ) # ifdef FEAT_AUTOCMD - && !equalpos(last_cursormoved, curwin->w_cursor) + && !EQUAL_POS(last_cursormoved, curwin->w_cursor) # endif ) { @@ -3623,16 +3623,27 @@ set_progpath(char_u *argv0) { char_u *val = argv0; +# ifdef HAVE_PROC_SELF_EXE + char buf[PATH_MAX + 1]; + ssize_t len; + + len = readlink("/proc/self/exe", buf, PATH_MAX); + if (len > 0) + { + buf[len] = NUL; + val = (char_u *)buf; + } +# else /* A relative path containing a "/" will become invalid when using ":cd", * turn it into a full path. * On MS-Windows "vim" should be expanded to "vim.exe", thus always do * this. */ -# ifdef WIN32 +# ifdef WIN32 char_u *path = NULL; if (mch_can_exe(argv0, &path, FALSE) && path != NULL) val = path; -# else +# else char_u buf[MAXPATHL]; if (!mch_isFullName(argv0)) @@ -3641,8 +3652,11 @@ set_progpath(char_u *argv0) && vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL) val = buf; } +# endif # endif + set_vim_var_string(VV_PROGPATH, val, -1); + # ifdef WIN32 vim_free(path); # endif diff --git a/src/mark.c b/src/mark.c index 59ac01dc51..194125eb00 100644 --- a/src/mark.c +++ b/src/mark.c @@ -206,7 +206,7 @@ setpcmark(void) checkpcmark(void) { if (curwin->w_prev_pcmark.lnum != 0 - && (equalpos(curwin->w_pcmark, curwin->w_cursor) + && (EQUAL_POS(curwin->w_pcmark, curwin->w_cursor) || curwin->w_pcmark.lnum == 0)) { curwin->w_pcmark = curwin->w_prev_pcmark; @@ -401,7 +401,7 @@ getmark_buf_fnum( { startp = &buf->b_visual.vi_start; endp = &buf->b_visual.vi_end; - if (((c == '<') == lt(*startp, *endp) || endp->lnum == 0) + if (((c == '<') == LT_POS(*startp, *endp) || endp->lnum == 0) && startp->lnum != 0) posp = startp; else @@ -497,14 +497,14 @@ getnextmark( { if (dir == FORWARD) { - if ((result == NULL || lt(curbuf->b_namedm[i], *result)) - && lt(pos, curbuf->b_namedm[i])) + if ((result == NULL || LT_POS(curbuf->b_namedm[i], *result)) + && LT_POS(pos, curbuf->b_namedm[i])) result = &curbuf->b_namedm[i]; } else { - if ((result == NULL || lt(*result, curbuf->b_namedm[i])) - && lt(curbuf->b_namedm[i], pos)) + if ((result == NULL || LT_POS(*result, curbuf->b_namedm[i])) + && LT_POS(curbuf->b_namedm[i], pos)) result = &curbuf->b_namedm[i]; } } @@ -695,7 +695,7 @@ mark_line(pos_T *mp, int lead_len) return NULL; /* Truncate the line to fit it in the window */ len = 0; - for (p = s; *p != NUL; mb_ptr_adv(p)) + for (p = s; *p != NUL; MB_PTR_ADV(p)) { len += ptr2cells(p); if (len >= Columns - lead_len) @@ -1063,7 +1063,7 @@ mark_adjust( one_adjust(&(curbuf->b_last_change.lnum)); /* last cursor position, if it was set */ - if (!equalpos(curbuf->b_last_cursor, initpos)) + if (!EQUAL_POS(curbuf->b_last_cursor, initpos)) one_adjust(&(curbuf->b_last_cursor.lnum)); @@ -1838,7 +1838,8 @@ write_buffer_marks(buf_T *buf, FILE *fp_out) for (i = 0; i < buf->b_changelistlen; ++i) { /* skip duplicates */ - if (i == 0 || !equalpos(buf->b_changelist[i - 1], buf->b_changelist[i])) + if (i == 0 || !EQUAL_POS(buf->b_changelist[i - 1], + buf->b_changelist[i])) write_one_mark(fp_out, '+', &buf->b_changelist[i]); } #endif diff --git a/src/mbyte.c b/src/mbyte.c index 8eab06ae15..c994b16c21 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -886,7 +886,7 @@ mb_get_class_buf(char_u *p, buf_T *buf) { if (MB_BYTE2LEN(p[0]) == 1) { - if (p[0] == NUL || vim_iswhite(p[0])) + if (p[0] == NUL || VIM_ISWHITE(p[0])) return 0; if (vim_iswordc_buf(p[0], buf)) return 2; @@ -4047,7 +4047,7 @@ mb_prevptr( char_u *p) { if (p > line) - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); return p; } @@ -5780,7 +5780,6 @@ static int xim_real_init(Window x11_window, Display *x11_display); #ifdef USE_X11R6_XIM -static void xim_instantiate_cb(Display *display, XPointer client_data, XPointer call_data); static void xim_destroy_cb(XIM im, XPointer client_data, XPointer call_data); static void diff --git a/src/memline.c b/src/memline.c index f9852e55bb..723bcd4bc5 100644 --- a/src/memline.c +++ b/src/memline.c @@ -2028,7 +2028,7 @@ make_percent_swname(char_u *dir, char_u *name) if (s != NULL) { STRCPY(s, f); - for (d = s; *d != NUL; mb_ptr_adv(d)) + for (d = s; *d != NUL; MB_PTR_ADV(d)) if (vim_ispathsep(*d)) *d = '%'; d = concat_fnames(dir, s, TRUE); @@ -4015,7 +4015,7 @@ get_file_in_dir( #ifdef WIN3264 if (retval != NULL) - for (t = gettail(retval); *t != NUL; mb_ptr_adv(t)) + for (t = gettail(retval); *t != NUL; MB_PTR_ADV(t)) if (*t == ':') *t = '%'; #endif @@ -4154,7 +4154,7 @@ findswapname( if (buf_fname == NULL) buf_fname = buf->b_fname; else - for (t = gettail(buf_fname); *t != NUL; mb_ptr_adv(t)) + for (t = gettail(buf_fname); *t != NUL; MB_PTR_ADV(t)) if (*t == ':') *t = '%'; } diff --git a/src/menu.c b/src/menu.c index 6b053fc5f8..4a29ebe59d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -152,7 +152,7 @@ ex_menu( { if (*arg == '\\') STRMOVE(arg, arg + 1); - mb_ptr_adv(arg); + MB_PTR_ADV(arg); } if (*arg != NUL) { @@ -167,9 +167,9 @@ ex_menu( for (p = arg; *p; ++p) if (!VIM_ISDIGIT(*p) && *p != '.') break; - if (vim_iswhite(*p)) + if (VIM_ISWHITE(*p)) { - for (i = 0; i < MENUDEPTH && !vim_iswhite(*arg); ++i) + for (i = 0; i < MENUDEPTH && !VIM_ISWHITE(*arg); ++i) { pri_tab[i] = getdigits(&arg); if (pri_tab[i] == 0) @@ -193,12 +193,12 @@ ex_menu( /* * Check for "disable" or "enable" argument. */ - if (STRNCMP(arg, "enable", 6) == 0 && vim_iswhite(arg[6])) + if (STRNCMP(arg, "enable", 6) == 0 && VIM_ISWHITE(arg[6])) { enable = TRUE; arg = skipwhite(arg + 6); } - else if (STRNCMP(arg, "disable", 7) == 0 && vim_iswhite(arg[7])) + else if (STRNCMP(arg, "disable", 7) == 0 && VIM_ISWHITE(arg[7])) { enable = FALSE; arg = skipwhite(arg + 7); @@ -662,7 +662,7 @@ add_menu_path( STRCPY(tearpath, menu_path); idx = (int)(next_name - path_name - 1); - for (s = tearpath; *s && s < tearpath + idx; mb_ptr_adv(s)) + for (s = tearpath; *s && s < tearpath + idx; MB_PTR_ADV(s)) { if ((*s == '\\' || *s == Ctrl_V) && s[1]) { @@ -1225,24 +1225,24 @@ set_context_in_menu_cmd( if (!VIM_ISDIGIT(*p) && *p != '.') break; - if (!vim_iswhite(*p)) + if (!VIM_ISWHITE(*p)) { if (STRNCMP(arg, "enable", 6) == 0 - && (arg[6] == NUL || vim_iswhite(arg[6]))) + && (arg[6] == NUL || VIM_ISWHITE(arg[6]))) p = arg + 6; else if (STRNCMP(arg, "disable", 7) == 0 - && (arg[7] == NUL || vim_iswhite(arg[7]))) + && (arg[7] == NUL || VIM_ISWHITE(arg[7]))) p = arg + 7; else p = arg; } - while (*p != NUL && vim_iswhite(*p)) + while (*p != NUL && VIM_ISWHITE(*p)) ++p; arg = after_dot = p; - for (; *p && !vim_iswhite(*p); ++p) + for (; *p && !VIM_ISWHITE(*p); ++p) { if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL) p++; @@ -1253,7 +1253,7 @@ set_context_in_menu_cmd( /* ":tearoff" and ":popup" only use menus, not entries */ expand_menus = !((*cmd == 't' && cmd[1] == 'e') || *cmd == 'p'); expand_emenu = (*cmd == 'e'); - if (expand_menus && vim_iswhite(*p)) + if (expand_menus && VIM_ISWHITE(*p)) return NULL; /* TODO: check for next command? */ if (*p == NUL) /* Complete the menu name */ { @@ -1478,7 +1478,7 @@ menu_name_skip(char_u *name) { char_u *p; - for (p = name; *p && *p != '.'; mb_ptr_adv(p)) + for (p = name; *p && *p != '.'; MB_PTR_ADV(p)) { if (*p == '\\' || *p == Ctrl_V) { @@ -2456,7 +2456,7 @@ ex_menutranslate(exarg_T *eap UNUSED) static char_u * menu_skip_part(char_u *p) { - while (*p != NUL && *p != '.' && !vim_iswhite(*p)) + while (*p != NUL && *p != '.' && !VIM_ISWHITE(*p)) { if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL) ++p; @@ -2509,7 +2509,7 @@ menu_unescape_name(char_u *name) { char_u *p; - for (p = name; *p && *p != '.'; mb_ptr_adv(p)) + for (p = name; *p && *p != '.'; MB_PTR_ADV(p)) if (*p == '\\') STRMOVE(p, p + 1); } @@ -2524,7 +2524,7 @@ menu_translate_tab_and_shift(char_u *arg_start) { char_u *arg = arg_start; - while (*arg && !vim_iswhite(*arg)) + while (*arg && !VIM_ISWHITE(*arg)) { if ((*arg == '\\' || *arg == Ctrl_V) && arg[1] != NUL) arg++; diff --git a/src/message.c b/src/message.c index 1468f53b57..a1600013bd 100644 --- a/src/message.c +++ b/src/message.c @@ -1793,7 +1793,7 @@ msg_prt_line(char_u *s, int list) if (list && lcs_trail) { trail = s + STRLEN(s); - while (trail > s && vim_iswhite(trail[-1])) + while (trail > s && VIM_ISWHITE(trail[-1])) --trail; } @@ -3750,7 +3750,7 @@ msg_show_console_dialog( } /* advance to the next character */ - mb_ptr_adv(r); + MB_PTR_ADV(r); } if (copy) diff --git a/src/misc1.c b/src/misc1.c index a454338491..544058bc9b 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -139,7 +139,7 @@ set_indent( ind_done = 0; /* count as many characters as we can use */ - while (todo > 0 && vim_iswhite(*p)) + while (todo > 0 && VIM_ISWHITE(*p)) { if (*p == TAB) { @@ -202,7 +202,7 @@ set_indent( } /* Return if the indent is OK already. */ - if (!doit && !vim_iswhite(*p) && !(flags & SIN_INSERT)) + if (!doit && !VIM_ISWHITE(*p) && !(flags & SIN_INSERT)) return FALSE; /* Allocate memory for the new line. */ @@ -234,7 +234,7 @@ set_indent( /* Skip over any additional white space (useful when newindent is less * than old) */ - while (vim_iswhite(*p)) + while (VIM_ISWHITE(*p)) ++p; } @@ -258,7 +258,7 @@ set_indent( p = oldline; ind_done = 0; - while (todo > 0 && vim_iswhite(*p)) + while (todo > 0 && VIM_ISWHITE(*p)) { if (*p == TAB) { @@ -357,7 +357,7 @@ copy_indent(int size, char_u *src) s = src; /* Count/copy the usable portion of the source line */ - while (todo > 0 && vim_iswhite(*s)) + while (todo > 0 && VIM_ISWHITE(*s)) { if (*s == TAB) { @@ -820,7 +820,7 @@ open_line( { /* Find last non-blank in line */ p = ptr + STRLEN(ptr) - 1; - while (p > ptr && vim_iswhite(*p)) + while (p > ptr && VIM_ISWHITE(*p)) --p; last_char = *p; @@ -831,7 +831,7 @@ open_line( { if (p > ptr) --p; - while (p > ptr && vim_iswhite(*p)) + while (p > ptr && VIM_ISWHITE(*p)) --p; } /* @@ -1020,7 +1020,7 @@ open_line( * comment leader, then put a space after the middle * comment leader on the next line. */ - if (!vim_iswhite(saved_line[lead_len - 1]) + if (!VIM_ISWHITE(saved_line[lead_len - 1]) && ((p_extra != NULL && (int)curwin->w_cursor.col == lead_len) || (p_extra == NULL @@ -1124,7 +1124,7 @@ open_line( { /* find last non-white in the leader to line up with */ for (p = leader + lead_len - 1; p > leader - && vim_iswhite(*p); --p) + && VIM_ISWHITE(*p); --p) ; ++p; @@ -1140,7 +1140,7 @@ open_line( while (old_size < repl_size && p > leader) { - mb_ptr_back(leader, p); + MB_PTR_BACK(leader, p); old_size += ptr2cells(p); } l = lead_repl_len - (int)(endp - p); @@ -1180,7 +1180,7 @@ open_line( } else #endif - if (!vim_iswhite(*p)) + if (!VIM_ISWHITE(*p)) *p = ' '; } } @@ -1217,7 +1217,7 @@ open_line( * leader by spaces. Keep Tabs, the indent must * remain the same. */ for (p += lead_repl_len; p < leader + lead_len; ++p) - if (!vim_iswhite(*p)) + if (!VIM_ISWHITE(*p)) { /* Don't put a space before a TAB. */ if (p + 1 < leader + lead_len && p[1] == TAB) @@ -1282,7 +1282,7 @@ open_line( /* If the leader ends in white space, don't add an * extra space */ - if (lead_len > 0 && vim_iswhite(leader[lead_len - 1])) + if (lead_len > 0 && VIM_ISWHITE(leader[lead_len - 1])) extra_space = FALSE; leader[lead_len] = NUL; } @@ -1305,7 +1305,7 @@ open_line( #endif ) { - while (lead_len && vim_iswhite(*leader)) + while (lead_len && VIM_ISWHITE(*leader)) { --lead_len; --newcol; @@ -1680,7 +1680,7 @@ get_leader_len( char_u *saved_flags = NULL; result = i = 0; - while (vim_iswhite(line[i])) /* leading white space is ignored */ + while (VIM_ISWHITE(line[i])) /* leading white space is ignored */ ++i; /* @@ -1725,11 +1725,11 @@ get_leader_len( * When string starts with white space, must have some white space * (but the amount does not need to match, there might be a mix of * TABs and spaces). */ - if (vim_iswhite(string[0])) + if (VIM_ISWHITE(string[0])) { - if (i == 0 || !vim_iswhite(line[i - 1])) + if (i == 0 || !VIM_ISWHITE(line[i - 1])) continue; /* missing white space */ - while (vim_iswhite(string[0])) + while (VIM_ISWHITE(string[0])) ++string; } for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) @@ -1740,7 +1740,7 @@ get_leader_len( /* When 'b' flag used, there must be white space or an * end-of-line after the string in the line. */ if (vim_strchr(part_buf, COM_BLANK) != NULL - && !vim_iswhite(line[i + j]) && line[i + j] != NUL) + && !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL) continue; /* We have found a match, stop searching unless this is a middle @@ -1785,7 +1785,7 @@ get_leader_len( result = i; /* Include any trailing white space. */ - while (vim_iswhite(line[i])) + while (VIM_ISWHITE(line[i])) ++i; if (include_space) @@ -1853,11 +1853,11 @@ get_last_leader_offset(char_u *line, char_u **flags) * (but the amount does not need to match, there might be a mix of * TABs and spaces). */ - if (vim_iswhite(string[0])) + if (VIM_ISWHITE(string[0])) { - if (i == 0 || !vim_iswhite(line[i - 1])) + if (i == 0 || !VIM_ISWHITE(line[i - 1])) continue; - while (vim_iswhite(string[0])) + while (VIM_ISWHITE(string[0])) ++string; } for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) @@ -1870,7 +1870,7 @@ get_last_leader_offset(char_u *line, char_u **flags) * end-of-line after the string in the line. */ if (vim_strchr(part_buf, COM_BLANK) != NULL - && !vim_iswhite(line[i + j]) && line[i + j] != NUL) + && !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL) { continue; } @@ -1907,7 +1907,7 @@ get_last_leader_offset(char_u *line, char_u **flags) * the comment leader correctly. */ - while (vim_iswhite(*com_leader)) + while (VIM_ISWHITE(*com_leader)) ++com_leader; len1 = (int)STRLEN(com_leader); @@ -1920,7 +1920,7 @@ get_last_leader_offset(char_u *line, char_u **flags) continue; string = vim_strchr(part_buf2, ':'); ++string; - while (vim_iswhite(*string)) + while (VIM_ISWHITE(*string)) ++string; len2 = (int)STRLEN(string); if (len2 == 0) @@ -2070,7 +2070,7 @@ plines_win_col(win_T *wp, linenr_T lnum, long column) while (*s != NUL && --column >= 0) { col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL); - mb_ptr_adv(s); + MB_PTR_ADV(s); } /* @@ -2694,7 +2694,7 @@ inindent(int extra) char_u *ptr; colnr_T col; - for (col = 0, ptr = ml_get_curline(); vim_iswhite(*ptr); ++col) + for (col = 0, ptr = ml_get_curline(); VIM_ISWHITE(*ptr); ++col) ++ptr; if (col >= curwin->w_cursor.col + extra) return TRUE; @@ -4843,7 +4843,7 @@ gettail(char_u *fname) { if (vim_ispathsep_nocolon(*p2)) p1 = p2 + 1; - mb_ptr_adv(p2); + MB_PTR_ADV(p2); } return p1; } @@ -4881,7 +4881,7 @@ gettail_dir(char_u *fname) dir_end = next_dir_end; look_for_sep = TRUE; } - mb_ptr_adv(p); + MB_PTR_ADV(p); } return dir_end; } @@ -4916,7 +4916,7 @@ gettail_sep(char_u *fname) getnextcomp(char_u *fname) { while (*fname && !vim_ispathsep(*fname)) - mb_ptr_adv(fname); + MB_PTR_ADV(fname); if (*fname) ++fname; return fname; @@ -5278,7 +5278,8 @@ ind_find_start_CORS(void) /* XXX */ /* If comment_pos is before rs_pos the raw string is inside the comment. * If rs_pos is before comment_pos the comment is inside the raw string. */ - if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos))) + if (comment_pos == NULL || (rs_pos != NULL + && LT_POS(*rs_pos, *comment_pos))) return rs_pos; return comment_pos; } @@ -5782,7 +5783,7 @@ cin_is_cpp_namespace(char_u *s) p = cin_skipcomment(skipwhite(s + 9)); while (*p != NUL) { - if (vim_iswhite(*p)) + if (VIM_ISWHITE(*p)) { has_name = TRUE; /* found end of a name */ p = cin_skipcomment(skipwhite(p)); @@ -5830,7 +5831,7 @@ cin_is_cpp_extern_c(char_u *s) p = cin_skipcomment(skipwhite(s + 6)); while (*p != NUL) { - if (vim_iswhite(*p)) + if (VIM_ISWHITE(*p)) { p = cin_skipcomment(skipwhite(p)); } @@ -5981,15 +5982,15 @@ cin_first_id_amount(void) || (len == 6 && STRNCMP(p, "signed", 6) == 0)) { s = skipwhite(p + len); - if ((STRNCMP(s, "int", 3) == 0 && vim_iswhite(s[3])) - || (STRNCMP(s, "long", 4) == 0 && vim_iswhite(s[4])) - || (STRNCMP(s, "short", 5) == 0 && vim_iswhite(s[5])) - || (STRNCMP(s, "char", 4) == 0 && vim_iswhite(s[4]))) + if ((STRNCMP(s, "int", 3) == 0 && VIM_ISWHITE(s[3])) + || (STRNCMP(s, "long", 4) == 0 && VIM_ISWHITE(s[4])) + || (STRNCMP(s, "short", 5) == 0 && VIM_ISWHITE(s[5])) + || (STRNCMP(s, "char", 4) == 0 && VIM_ISWHITE(s[4]))) p = s; } for (len = 0; vim_isIDc(p[len]); ++len) ; - if (len == 0 || !vim_iswhite(p[len]) || cin_nocode(p)) + if (len == 0 || !VIM_ISWHITE(p[len]) || cin_nocode(p)) return 0; p = skipwhite(p + len); @@ -6361,7 +6362,7 @@ cin_is_if_for_while_before_offset(char_u *line, int *poffset) if (offset-- < 2) return 0; - while (offset > 2 && vim_iswhite(line[offset])) + while (offset > 2 && VIM_ISWHITE(line[offset])) --offset; offset -= 1; @@ -7223,7 +7224,8 @@ get_c_indent(void) comment_pos = &tryposCopy; } trypos = find_start_rawstring(curbuf->b_ind_maxcomment); - if (trypos != NULL && (comment_pos == NULL || lt(*trypos, *comment_pos))) + if (trypos != NULL && (comment_pos == NULL + || LT_POS(*trypos, *comment_pos))) { amount = -1; goto laterend; @@ -7606,7 +7608,7 @@ get_c_indent(void) else { col = our_paren_pos.col + 1; - while (vim_iswhite(l[col])) + while (VIM_ISWHITE(l[col])) col++; if (l[col] != NUL) /* In case of trailing space */ our_paren_pos.col = col; @@ -9358,7 +9360,7 @@ get_lisp_indent(void) { paren = *pos; pos = findmatch(NULL, '['); - if (pos == NULL || ltp(pos, &paren)) + if (pos == NULL || LT_POSP(pos, &paren)) pos = &paren; } if (pos != NULL) @@ -9453,7 +9455,7 @@ get_lisp_indent(void) amount++; firsttry = amount; - while (vim_iswhite(*that)) + while (VIM_ISWHITE(*that)) { amount += lbr_chartabsize(line, that, (colnr_T)amount); ++that; @@ -9476,7 +9478,7 @@ get_lisp_indent(void) && (*that < '0' || *that > '9'))) { while (*that - && (!vim_iswhite(*that) + && (!VIM_ISWHITE(*that) || quotecount || parencount) && (!((*that == '(' || *that == '[') @@ -9499,7 +9501,7 @@ get_lisp_indent(void) line, &that, (colnr_T)amount); } } - while (vim_iswhite(*that)) + while (VIM_ISWHITE(*that)) { amount += lbr_chartabsize( line, that, (colnr_T)amount); @@ -10382,7 +10384,7 @@ find_previous_pathsep(char_u *path, char_u **psep) { if (vim_ispathsep(**psep)) return OK; - mb_ptr_back(path, *psep); + MB_PTR_BACK(path, *psep); } return FAIL; @@ -10537,7 +10539,7 @@ get_path_cutoff(char_u *fname, garray_T *gap) /* skip to the file or directory name */ if (cutoff != NULL) while (vim_ispathsep(*cutoff)) - mb_ptr_adv(cutoff); + MB_PTR_ADV(cutoff); return cutoff; } @@ -10794,7 +10796,7 @@ static int has_env_var(char_u *p); static int has_env_var(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) ++p; @@ -10820,7 +10822,7 @@ static int has_special_wildchar(char_u *p); static int has_special_wildchar(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { /* Allow for escaping. */ if (*p == '\\' && p[1] != NUL) @@ -11297,7 +11299,7 @@ get_isolated_shell_name(void) /* Find the last path separator before the space. */ p1 = p_sh; - for (p2 = p_sh; p2 < p; mb_ptr_adv(p2)) + for (p2 = p_sh; p2 < p; MB_PTR_ADV(p2)) if (vim_ispathsep(*p2)) p1 = p2 + 1; p = vim_strnsave(p1, (int)(p - p1)); diff --git a/src/misc2.c b/src/misc2.c index 3e02dc2275..4fcdd9e2e6 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -196,7 +196,7 @@ coladvance2( /* Count a tab for what it's worth (if list mode not on) */ #ifdef FEAT_LINEBREAK csize = win_lbr_chartabsize(curwin, line, ptr, col, &head); - mb_ptr_adv(ptr); + MB_PTR_ADV(ptr); #else csize = lbr_chartabsize_adv(line, &ptr, col); #endif @@ -1418,7 +1418,7 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline) /* First count the number of extra bytes required. */ length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */ - for (p = string; *p != NUL; mb_ptr_adv(p)) + for (p = string; *p != NUL; MB_PTR_ADV(p)) { # ifdef WIN32 if (!p_ssl) @@ -1702,7 +1702,7 @@ del_trailing_spaces(char_u *ptr) char_u *q; q = ptr + STRLEN(ptr); - while (--q > ptr && vim_iswhite(q[0]) && q[-1] != '\\' && q[-1] != Ctrl_V) + while (--q > ptr && VIM_ISWHITE(q[0]) && q[-1] != '\\' && q[-1] != Ctrl_V) *q = NUL; } @@ -1950,7 +1950,7 @@ vim_strrchr(char_u *string, int c) { if (*p == c) retval = p; - mb_ptr_adv(p); + MB_PTR_ADV(p); } return retval; } @@ -1971,7 +1971,7 @@ vim_strpbrk(char_u *s, char_u *charset) { if (vim_strchr(charset, *s) != NULL) return s; - mb_ptr_adv(s); + MB_PTR_ADV(s); } return NULL; } @@ -3370,7 +3370,7 @@ vim_chdirfile(char_u *fname) * Used for systems where stat() ignores a trailing slash on a file name. * The Vim code assumes a trailing slash is only ignored for a directory. */ - int + static int illegal_slash(char *name) { if (name[0] == NUL) @@ -3381,6 +3381,17 @@ illegal_slash(char *name) return FALSE; /* trailing slash for a directory */ return TRUE; } + +/* + * Special implementation of mch_stat() for Solaris. + */ + int +vim_stat(const char *name, stat_T *stp) +{ + /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if + * the name ends in "/" and it's not a directory. */ + return illegal_slash(n) ? -1 : stat(n, p); +} #endif #if defined(CURSOR_SHAPE) || defined(PROTO) diff --git a/src/move.c b/src/move.c index 849501fd90..9d175e115e 100644 --- a/src/move.c +++ b/src/move.c @@ -236,7 +236,7 @@ update_topline(void) /* * If the buffer is empty, always set topline to 1. */ - if (bufempty()) /* special case - file is empty */ + if (BUFEMPTY()) /* special case - file is empty */ { if (curwin->w_topline != 1) redraw_later(NOT_VALID); diff --git a/src/normal.c b/src/normal.c index 82a26ae79c..ca8fb4aeb2 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1540,7 +1540,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) if (VIsual_select && VIsual_mode == 'V' && cap->oap->op_type != OP_DELETE) { - if (lt(VIsual, curwin->w_cursor)) + if (LT_POS(VIsual, curwin->w_cursor)) { VIsual.col = 0; curwin->w_cursor.col = @@ -1572,7 +1572,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) * Set oap->start to the first position of the operated text, oap->end * to the end of the operated text. w_cursor is equal to oap->start. */ - if (lt(oap->start, curwin->w_cursor)) + if (LT_POS(oap->start, curwin->w_cursor)) { #ifdef FEAT_FOLDING /* Include folded lines completely. */ @@ -1776,7 +1776,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) && (!oap->inclusive || (oap->op_type == OP_YANK && gchar_pos(&oap->end) == NUL)) - && equalpos(oap->start, oap->end) + && EQUAL_POS(oap->start, oap->end) #ifdef FEAT_VIRTUALEDIT && !(virtual_op && oap->start.coladd != oap->end.coladd) #endif @@ -2685,12 +2685,12 @@ do_mouse( jump_flags = MOUSE_MAY_STOP_VIS; else { - if ((lt(curwin->w_cursor, VIsual) - && (lt(m_pos, curwin->w_cursor) - || lt(VIsual, m_pos))) - || (lt(VIsual, curwin->w_cursor) - && (lt(m_pos, VIsual) - || lt(curwin->w_cursor, m_pos)))) + if ((LT_POS(curwin->w_cursor, VIsual) + && (LT_POS(m_pos, curwin->w_cursor) + || LT_POS(VIsual, m_pos))) + || (LT_POS(VIsual, curwin->w_cursor) + && (LT_POS(m_pos, VIsual) + || LT_POS(curwin->w_cursor, m_pos)))) { jump_flags = MOUSE_MAY_STOP_VIS; } @@ -2756,7 +2756,7 @@ do_mouse( * Remember the start and end of visual before moving the * cursor. */ - if (lt(curwin->w_cursor, VIsual)) + if (LT_POS(curwin->w_cursor, VIsual)) { start_visual = curwin->w_cursor; end_visual = VIsual; @@ -2893,9 +2893,9 @@ do_mouse( * If the click is after the end of visual, change the end. If * the click is inside the visual, change the closest side. */ - if (lt(curwin->w_cursor, start_visual)) + if (LT_POS(curwin->w_cursor, start_visual)) VIsual = end_visual; - else if (lt(end_visual, curwin->w_cursor)) + else if (LT_POS(end_visual, curwin->w_cursor)) VIsual = start_visual; else { @@ -3092,14 +3092,14 @@ do_mouse( * not a word character, try finding a match and select a (), * {}, [], #if/#endif, etc. block. */ end_visual = curwin->w_cursor; - while (gc = gchar_pos(&end_visual), vim_iswhite(gc)) + while (gc = gchar_pos(&end_visual), VIM_ISWHITE(gc)) inc(&end_visual); if (oap != NULL) oap->motion_type = MCHAR; if (oap != NULL && VIsual_mode == 'v' && !vim_iswordc(gchar_pos(&end_visual)) - && equalpos(curwin->w_cursor, VIsual) + && EQUAL_POS(curwin->w_cursor, VIsual) && (pos = findmatch(oap, NUL)) != NULL) { curwin->w_cursor = *pos; @@ -3107,7 +3107,7 @@ do_mouse( VIsual_mode = 'V'; else if (*p_sel == 'e') { - if (lt(curwin->w_cursor, VIsual)) + if (LT_POS(curwin->w_cursor, VIsual)) ++VIsual.col; else ++curwin->w_cursor.col; @@ -3119,7 +3119,7 @@ do_mouse( { /* When not found a match or when dragging: extend to include * a word. */ - if (lt(curwin->w_cursor, orig_cursor)) + if (LT_POS(curwin->w_cursor, orig_cursor)) { find_start_of_word(&curwin->w_cursor); find_end_of_word(&VIsual); @@ -3469,7 +3469,7 @@ find_ident_at_pos( else #endif while (ptr[col] != NUL - && (i == 0 ? !vim_iswordc(ptr[col]) : vim_iswhite(ptr[col])) + && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col])) # if defined(FEAT_BEVAL) && (!(find_type & FIND_EVAL) || ptr[col] != ']') # endif @@ -3526,7 +3526,7 @@ find_ident_at_pos( while (col > 0 && ((i == 0 ? vim_iswordc(ptr[col - 1]) - : (!vim_iswhite(ptr[col - 1]) + : (!VIM_ISWHITE(ptr[col - 1]) && (!(find_type & FIND_IDENT) || !vim_iswordc(ptr[col - 1])))) #if defined(FEAT_BEVAL) @@ -3590,7 +3590,7 @@ find_ident_at_pos( else #endif while ((i == 0 ? vim_iswordc(ptr[col]) - : (ptr[col] != NUL && !vim_iswhite(ptr[col]))) + : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col]))) # if defined(FEAT_BEVAL) || ((find_type & FIND_EVAL) && col <= (int)startcol @@ -3747,7 +3747,7 @@ clear_showcmd(void) if (VIsual_active && !char_avail()) { - int cursor_bot = lt(VIsual, curwin->w_cursor); + int cursor_bot = LT_POS(VIsual, curwin->w_cursor); long lines; colnr_T leftcol, rightcol; linenr_T top, bot; @@ -4358,7 +4358,7 @@ find_decl( curwin->w_cursor.col = 0; /* Search forward for the identifier, ignore comment lines. */ - clearpos(&found_pos); + CLEAR_POS(&found_pos); for (;;) { valid = FALSE; @@ -4424,13 +4424,10 @@ find_decl( * declarations this skips the function header without types. */ if (!valid) { - /* Braces needed due to macro expansion of clearpos. */ - clearpos(&found_pos); + CLEAR_POS(&found_pos); } else - { found_pos = curwin->w_cursor; - } /* Remove SEARCH_START from flags to avoid getting stuck at one * position. */ searchflags &= ~SEARCH_START; @@ -5868,7 +5865,7 @@ get_visual_text( } else { - if (lt(curwin->w_cursor, VIsual)) + if (LT_POS(curwin->w_cursor, VIsual)) { *pp = ml_get_pos(&curwin->w_cursor); *lenp = VIsual.col - curwin->w_cursor.col + 1; @@ -6054,7 +6051,7 @@ nv_right(cmdarg_T *cap) * included, move to next line after that */ if ( cap->oap->op_type != OP_NOP && !cap->oap->inclusive - && !lineempty(curwin->w_cursor.lnum)) + && !LINEEMPTY(curwin->w_cursor.lnum)) cap->oap->inclusive = TRUE; else { @@ -6076,7 +6073,7 @@ nv_right(cmdarg_T *cap) } else { - if (!lineempty(curwin->w_cursor.lnum)) + if (!LINEEMPTY(curwin->w_cursor.lnum)) cap->oap->inclusive = TRUE; } break; @@ -6155,7 +6152,7 @@ nv_left(cmdarg_T *cap) * Don't adjust op_end now, otherwise it won't work. */ if ( (cap->oap->op_type == OP_DELETE || cap->oap->op_type == OP_CHANGE) - && !lineempty(curwin->w_cursor.lnum)) + && !LINEEMPTY(curwin->w_cursor.lnum)) { char_u *cp = ml_get_cursor(); @@ -6367,7 +6364,7 @@ nv_search(cmdarg_T *cap) } (void)normal_search(cap, cap->cmdchar, cap->searchbuf, - (cap->arg || !equalpos(save_cursor, curwin->w_cursor)) + (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor)) ? 0 : SEARCH_MARK); } @@ -6381,7 +6378,7 @@ nv_next(cmdarg_T *cap) pos_T old = curwin->w_cursor; int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); - if (i == 1 && equalpos(old, curwin->w_cursor)) + if (i == 1 && EQUAL_POS(old, curwin->w_cursor)) { /* Avoid getting stuck on the current cursor position, which can * happen when an offset is given and the cursor is on the last char @@ -6723,9 +6720,9 @@ nv_brackets(cmdarg_T *cap) if (VIsual_active) { - start = ltoreq(VIsual, curwin->w_cursor) + start = LTOREQ_POS(VIsual, curwin->w_cursor) ? VIsual : curwin->w_cursor; - end = equalpos(start,VIsual) ? curwin->w_cursor : VIsual; + end = EQUAL_POS(start,VIsual) ? curwin->w_cursor : VIsual; curwin->w_cursor = (dir == BACKWARD ? start : end); } # ifdef FEAT_CLIPBOARD @@ -7349,7 +7346,7 @@ n_swapchar(cmdarg_T *cap) if (checkclearopq(cap->oap)) return; - if (lineempty(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) + if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) { clearopbeep(cap->oap); return; @@ -7593,7 +7590,7 @@ nv_gomark(cmdarg_T *cap) #ifdef FEAT_FOLDING if (cap->oap->op_type == OP_NOP && pos != NULL - && (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos)) + && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos)) && (fdo_flags & FDO_MARK) && old_KeyTyped) foldOpenCursor(); @@ -8146,7 +8143,7 @@ nv_g_cmd(cmdarg_T *cap) { do i = gchar_cursor(); - while (vim_iswhite(i) && oneright() == OK); + while (VIM_ISWHITE(i) && oneright() == OK); } curwin->w_set_curswant = TRUE; break; @@ -8170,7 +8167,7 @@ nv_g_cmd(cmdarg_T *cap) /* Decrease the cursor column until it's on a non-blank. */ while (curwin->w_cursor.col > 0 - && vim_iswhite(ptr[curwin->w_cursor.col])) + && VIM_ISWHITE(ptr[curwin->w_cursor.col])) --curwin->w_cursor.col; curwin->w_set_curswant = TRUE; adjust_for_sel(cap); @@ -8753,7 +8750,7 @@ nv_wordcmd(cmdarg_T *cap) n = gchar_cursor(); if (n != NUL) /* not an empty line */ { - if (vim_iswhite(n)) + if (VIM_ISWHITE(n)) { /* * Reproduce a funny Vi behaviour: "cw" on a blank only @@ -8797,7 +8794,7 @@ nv_wordcmd(cmdarg_T *cap) /* Don't leave the cursor on the NUL past the end of line. Unless we * didn't move it forward. */ - if (lt(startpos, curwin->w_cursor)) + if (LT_POS(startpos, curwin->w_cursor)) adjust_cursor(cap->oap); if (n == FAIL && cap->oap->op_type == OP_NOP) @@ -8867,7 +8864,7 @@ nv_beginline(cmdarg_T *cap) adjust_for_sel(cmdarg_T *cap) { if (VIsual_active && cap->oap->inclusive && *p_sel == 'e' - && gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor)) + && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor)) { #ifdef FEAT_MBYTE if (has_mbyte) @@ -8889,9 +8886,9 @@ unadjust_for_sel(void) { pos_T *pp; - if (*p_sel == 'e' && !equalpos(VIsual, curwin->w_cursor)) + if (*p_sel == 'e' && !EQUAL_POS(VIsual, curwin->w_cursor)) { - if (lt(VIsual, curwin->w_cursor)) + if (LT_POS(VIsual, curwin->w_cursor)) pp = &curwin->w_cursor; else pp = &VIsual; @@ -9105,8 +9102,8 @@ nv_edit(cmdarg_T *cap) /* When the last char in the line was deleted then append. Detect this * by checking if the cursor moved to before the Visual area. */ - if (*ml_get_cursor() != NUL && lt(curwin->w_cursor, old_pos) - && lt(curwin->w_cursor, old_visual)) + if (*ml_get_cursor() != NUL && LT_POS(curwin->w_cursor, old_pos) + && LT_POS(curwin->w_cursor, old_visual)) inc_cursor(); /* Insert to replace the deleted text with the pasted text. */ diff --git a/src/ops.c b/src/ops.c index 757c115497..d3e97f07f0 100644 --- a/src/ops.c +++ b/src/ops.c @@ -113,9 +113,6 @@ static void copy_yank_reg(yankreg_T *reg); static void may_set_selection(void); #endif static void dis_msg(char_u *p, int skip_esc); -#if defined(FEAT_COMMENTS) || defined(PROTO) -static char_u *skip_comment(char_u *line, int process, int include_space, int *is_comment); -#endif static void block_prep(oparg_T *oap, struct block_def *, linenr_T, int); static int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1); #if defined(FEAT_CLIPBOARD) || defined(FEAT_EVAL) @@ -429,7 +426,7 @@ shift_block(oparg_T *oap, int amount) #endif ++bd.textstart; } - for ( ; vim_iswhite(*bd.textstart); ) + for ( ; VIM_ISWHITE(*bd.textstart); ) { /* TODO: is passing bd.textstart for start of the line OK? */ incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, @@ -486,12 +483,12 @@ shift_block(oparg_T *oap, int amount) * the part of which is displayed at the block's beginning. Let's start * searching from the next character. */ if (bd.startspaces) - mb_ptr_adv(non_white); + MB_PTR_ADV(non_white); /* The character's column is in "bd.start_vcol". */ non_white_col = bd.start_vcol; - while (vim_iswhite(*non_white)) + while (VIM_ISWHITE(*non_white)) { incr = lbr_chartabsize_adv(bd.textstart, &non_white, non_white_col); non_white_col += incr; @@ -526,7 +523,7 @@ shift_block(oparg_T *oap, int amount) if (verbatim_copy_width + incr > destination_col) break; verbatim_copy_width += incr; - mb_ptr_adv(verbatim_copy_end); + MB_PTR_ADV(verbatim_copy_end); } /* If "destination_col" is different from the width of the initial @@ -2190,7 +2187,7 @@ op_replace(oparg_T *oap, int c) else if (!oap->inclusive) dec(&(oap->end)); - while (ltoreq(curwin->w_cursor, oap->end)) + while (LTOREQ_POS(curwin->w_cursor, oap->end)) { n = gchar_cursor(); if (n != NUL) @@ -2229,7 +2226,7 @@ op_replace(oparg_T *oap, int c) getvpos(&oap->end, end_vcol); } #endif - pchar(curwin->w_cursor, c); + PCHAR(curwin->w_cursor, c); } } #ifdef FEAT_VIRTUALEDIT @@ -2248,7 +2245,7 @@ op_replace(oparg_T *oap, int c) curwin->w_cursor.col -= (virtcols + 1); for (; virtcols >= 0; virtcols--) { - pchar(curwin->w_cursor, c); + PCHAR(curwin->w_cursor, c); if (inc(&curwin->w_cursor) == -1) break; } @@ -2338,7 +2335,7 @@ op_tilde(oparg_T *oap) did_change |= swapchars(oap->op_type, &pos, pos.lnum == oap->end.lnum ? oap->end.col + 1: (int)STRLEN(ml_get_pos(&pos))); - if (ltoreq(oap->end, pos) || inc(&pos) == -1) + if (LTOREQ_POS(oap->end, pos) || inc(&pos) == -1) break; } if (did_change) @@ -2490,7 +2487,7 @@ swapchar(int op_type, pos_T *pos) } else #endif - pchar(*pos, nc); + PCHAR(*pos, nc); return TRUE; } return FALSE; @@ -2575,7 +2572,7 @@ op_insert(oparg_T *oap, long count1) check_cursor_col(); /* Works just like an 'i'nsert on the next character. */ - if (!lineempty(curwin->w_cursor.lnum) + if (!LINEEMPTY(curwin->w_cursor.lnum) && oap->start_vcol != oap->end_vcol) inc_cursor(); } @@ -2588,7 +2585,7 @@ op_insert(oparg_T *oap, long count1) * have been converted to a tab as well, the column of the cursor * might have actually been reduced, so need to adjust here. */ if (t1.lnum == curbuf->b_op_start_orig.lnum - && lt(curbuf->b_op_start_orig, t1)) + && LT_POS(curbuf->b_op_start_orig, t1)) oap->start = curbuf->b_op_start_orig; /* If user has moved off this line, we don't know what to do, so do @@ -2735,7 +2732,7 @@ op_change(oparg_T *oap) else if (op_delete(oap) == FAIL) return FALSE; - if ((l > curwin->w_cursor.col) && !lineempty(curwin->w_cursor.lnum) + if ((l > curwin->w_cursor.col) && !LINEEMPTY(curwin->w_cursor.lnum) && !virtual_op) inc_cursor(); @@ -3458,7 +3455,7 @@ do_put( goto end; p = ml_get_cursor(); if (dir == FORWARD && *p != NUL) - mb_ptr_adv(p); + MB_PTR_ADV(p); ptr = vim_strsave(p); if (ptr == NULL) goto end; @@ -3468,7 +3465,7 @@ do_put( oldp = ml_get_curline(); p = oldp + curwin->w_cursor.col; if (dir == FORWARD && *p != NUL) - mb_ptr_adv(p); + MB_PTR_ADV(p); ptr = vim_strnsave(oldp, p - oldp); if (ptr == NULL) goto end; @@ -3519,7 +3516,7 @@ do_put( ++lnum; /* In an empty buffer the empty line is going to be replaced, include * it in the saved lines. */ - if ((bufempty() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL) + if ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL) goto end; #ifdef FEAT_FOLDING if (dir == FORWARD) @@ -4301,7 +4298,7 @@ dis_msg( * is_comment - will indicate whether the current line ends with an unclosed * comment. */ - static char_u * + char_u * skip_comment( char_u *line, int process, @@ -4489,11 +4486,11 @@ do_join( if (has_mbyte) { cend = curr + currsize; - mb_ptr_back(curr, cend); + MB_PTR_BACK(curr, cend); endcurr1 = (*mb_ptr2char)(cend); if (cend > curr) { - mb_ptr_back(curr, cend); + MB_PTR_BACK(curr, cend); endcurr2 = (*mb_ptr2char)(cend); } } @@ -4655,18 +4652,18 @@ same_leader( line1 = vim_strsave(ml_get(lnum)); if (line1 != NULL) { - for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1) + for (idx1 = 0; VIM_ISWHITE(line1[idx1]); ++idx1) ; line2 = ml_get(lnum + 1); for (idx2 = 0; idx2 < leader2_len; ++idx2) { - if (!vim_iswhite(line2[idx2])) + if (!VIM_ISWHITE(line2[idx2])) { if (line1[idx1++] != line2[idx2]) break; } else - while (vim_iswhite(line1[idx1])) + while (VIM_ISWHITE(line1[idx1])) ++idx1; } vim_free(line1); @@ -4936,7 +4933,7 @@ format_lines( && prev_is_end_par && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { - if (do_second_indent && !lineempty(curwin->w_cursor.lnum + 1)) + if (do_second_indent && !LINEEMPTY(curwin->w_cursor.lnum + 1)) { #ifdef FEAT_COMMENTS if (leader_len == 0 && next_leader_len == 0) @@ -5092,10 +5089,10 @@ ends_in_white(linenr_T lnum) if (*s == NUL) return FALSE; - /* Don't use STRLEN() inside vim_iswhite(), SAS/C complains: "macro + /* Don't use STRLEN() inside VIM_ISWHITE(), SAS/C complains: "macro * invocation may call function multiple times". */ l = STRLEN(s) - 1; - return vim_iswhite(s[l]); + return VIM_ISWHITE(s[l]); } /* @@ -5250,7 +5247,7 @@ block_prep( incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol); bdp->start_vcol += incr; #ifdef FEAT_VISUALEXTRA - if (vim_iswhite(*pstart)) + if (VIM_ISWHITE(*pstart)) { bdp->pre_whitesp += incr; bdp->pre_whitesp_c++; @@ -5262,7 +5259,7 @@ block_prep( } #endif prev_pstart = pstart; - mb_ptr_adv(pstart); + MB_PTR_ADV(pstart); } bdp->start_char_vcols = incr; if (bdp->start_vcol < oap->start_vcol) /* line too short */ @@ -7237,7 +7234,7 @@ cursor_pos_info(dict_T *dict) if (VIsual_active) { - if (lt(VIsual, curwin->w_cursor)) + if (LT_POS(VIsual, curwin->w_cursor)) { min_pos = VIsual; max_pos = curwin->w_cursor; diff --git a/src/option.c b/src/option.c index 9fcf869d83..542710e746 100644 --- a/src/option.c +++ b/src/option.c @@ -4281,7 +4281,7 @@ set_init_3(void) } #endif - if (bufempty()) + if (BUFEMPTY()) { int idx_ffs = findoption((char_u *)"ffs"); @@ -4549,7 +4549,7 @@ do_set( afterchar = arg[len]; /* skip white space, allow ":set ai ?" */ - while (vim_iswhite(arg[len])) + while (VIM_ISWHITE(arg[len])) ++len; adding = FALSE; @@ -4673,7 +4673,7 @@ do_set( } } if (vim_strchr((char_u *)"?!&<", nextchar) != NULL - && arg[1] != NUL && !vim_iswhite(arg[1])) + && arg[1] != NUL && !VIM_ISWHITE(arg[1])) { errmsg = e_trailing; goto skip; @@ -4731,7 +4731,7 @@ do_set( (void)show_one_termcode(key_name, p, TRUE); } if (nextchar != '?' - && nextchar != NUL && !vim_iswhite(afterchar)) + && nextchar != NUL && !VIM_ISWHITE(afterchar)) errmsg = e_trailing; } else @@ -4771,7 +4771,7 @@ do_set( * ":set invopt": invert * ":set opt" or ":set noopt": set or reset */ - if (nextchar != NUL && !vim_iswhite(afterchar)) + if (nextchar != NUL && !VIM_ISWHITE(afterchar)) { errmsg = e_trailing; goto skip; @@ -4825,7 +4825,8 @@ do_set( || (long *)varp == &p_wcm) && (*arg == '<' || *arg == '^' - || (*arg != NUL && (!arg[1] || vim_iswhite(arg[1])) + || (*arg != NUL + && (!arg[1] || VIM_ISWHITE(arg[1])) && !VIM_ISDIGIT(*arg)))) { value = string_to_key(arg); @@ -4841,7 +4842,7 @@ do_set( * hex numbers. */ vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0); - if (arg[i] != NUL && !vim_iswhite(arg[i])) + if (arg[i] != NUL && !VIM_ISWHITE(arg[i])) { errmsg = e_invarg; goto skip; @@ -5033,7 +5034,7 @@ do_set( * do remove it for "\\\\machine\\path". * The reverse is found in ExpandOldSetting(). */ - while (*arg && !vim_iswhite(*arg)) + while (*arg && !VIM_ISWHITE(*arg)) { if (*arg == '\\' && arg[1] != NUL #ifdef BACKSLASH_IN_FILENAME @@ -5273,7 +5274,7 @@ do_set( else { ++arg; /* jump to after the '=' or ':' */ - for (p = arg; *p && !vim_iswhite(*p); ++p) + for (p = arg; *p && !VIM_ISWHITE(*p); ++p) if (*p == '\\' && p[1] != NUL) ++p; nextchar = *p; @@ -5301,7 +5302,7 @@ skip: */ for (i = 0; i < 2 ; ++i) { - while (*arg != NUL && !vim_iswhite(*arg)) + while (*arg != NUL && !VIM_ISWHITE(*arg)) if (*arg++ == '\\' && *arg != NUL) ++arg; arg = skipwhite(arg); @@ -6904,7 +6905,7 @@ did_set_string_option( { if (ptr2cells(s) != 1) errmsg = (char_u *)N_("E595: contains unprintable or wide character"); - mb_ptr_adv(s); + MB_PTR_ADV(s); } } #endif @@ -11879,7 +11880,7 @@ ExpandOldSetting(int *num_file, char_u ***file) #ifdef BACKSLASH_IN_FILENAME /* For MS-Windows et al. we don't double backslashes at the start and * before a file name character. */ - for (var = buf; *var != NUL; mb_ptr_adv(var)) + for (var = buf; *var != NUL; MB_PTR_ADV(var)) if (var[0] == '\\' && var[1] == '\\' && expand_option_idx >= 0 && (options[expand_option_idx].flags & P_EXPAND) @@ -12079,7 +12080,7 @@ langmap_set(void) for (p = p_langmap; p[0] != NUL; ) { for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; - mb_ptr_adv(p2)) + MB_PTR_ADV(p2)) { if (p2[0] == '\\' && p2[1] != NUL) ++p2; @@ -12105,7 +12106,7 @@ langmap_set(void) to = NUL; if (p2 == NULL) { - mb_ptr_adv(p); + MB_PTR_ADV(p); if (p[0] != ',') { if (p[0] == '\\') @@ -12145,10 +12146,10 @@ langmap_set(void) langmap_mapchar[from & 255] = to; /* Advance to next pair */ - mb_ptr_adv(p); + MB_PTR_ADV(p); if (p2 != NULL) { - mb_ptr_adv(p2); + MB_PTR_ADV(p2); if (*p == ';') { p = p2; diff --git a/src/os_amiga.c b/src/os_amiga.c index 87fcca97e1..85e0c4ef0e 100644 --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -1567,7 +1567,7 @@ sortcmp(const void *a, const void *b) int mch_has_exp_wildcard(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) ++p; @@ -1580,7 +1580,7 @@ mch_has_exp_wildcard(char_u *p) int mch_has_wildcard(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) ++p; diff --git a/src/os_mswin.c b/src/os_mswin.c index 5f6e11dab6..a713ea190d 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -454,7 +454,7 @@ slash_adjust(char_u *p) { if (*p == psepcN) *p = psepc; - mb_ptr_adv(p); + MB_PTR_ADV(p); } } @@ -600,7 +600,7 @@ vim_stat(const char *name, stat_T *stp) vim_strncpy((char_u *)buf, (char_u *)name, sizeof(buf) - 1); p = buf + STRLEN(buf); if (p > buf) - mb_ptr_back(buf, p); + MB_PTR_BACK(buf, p); /* Remove trailing '\\' except root path. */ if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':') @@ -720,7 +720,7 @@ display_errors(void) int mch_has_exp_wildcard(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (vim_strchr((char_u *)"?*[", *p) != NULL || (*p == '~' && p[1] != NUL)) @@ -736,7 +736,7 @@ mch_has_exp_wildcard(char_u *p) int mch_has_wildcard(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (vim_strchr((char_u *) # ifdef VIM_BACKTICK diff --git a/src/os_unix.c b/src/os_unix.c index 1ae9b3c6ff..21b67a3e89 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6161,7 +6161,7 @@ mch_expand_wildcards( STRCAT(command, pat[0] + 1); /* exclude first backtick */ p = command + STRLEN(command) - 1; *p-- = ')'; /* remove last backtick */ - while (p > command && vim_iswhite(*p)) + while (p > command && VIM_ISWHITE(*p)) --p; if (*p == '&') /* remove trailing '&' */ { @@ -6544,7 +6544,7 @@ save_patterns( int mch_has_exp_wildcard(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) ++p; @@ -6568,7 +6568,7 @@ mch_has_exp_wildcard(char_u *p) int mch_has_wildcard(char_u *p) { - for ( ; *p; mb_ptr_adv(p)) + for ( ; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) ++p; diff --git a/src/os_win32.c b/src/os_win32.c index ed15920f1d..edd38e3a9e 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -4706,7 +4706,7 @@ mch_call_shell( if (*cmdbase == '(') ++cmdbase; - if ((STRNICMP(cmdbase, "start", 5) == 0) && vim_iswhite(cmdbase[5])) + if ((STRNICMP(cmdbase, "start", 5) == 0) && VIM_ISWHITE(cmdbase[5])) { STARTUPINFO si; PROCESS_INFORMATION pi; @@ -4724,14 +4724,14 @@ mch_call_shell( cmdbase = skipwhite(cmdbase + 5); if ((STRNICMP(cmdbase, "/min", 4) == 0) - && vim_iswhite(cmdbase[4])) + && VIM_ISWHITE(cmdbase[4])) { cmdbase = skipwhite(cmdbase + 4); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWMINNOACTIVE; } else if ((STRNICMP(cmdbase, "/b", 2) == 0) - && vim_iswhite(cmdbase[2])) + && VIM_ISWHITE(cmdbase[2])) { cmdbase = skipwhite(cmdbase + 2); flags = CREATE_NO_WINDOW; @@ -5741,7 +5741,7 @@ write_chars( { char_u *p = pchBuf; for (n = 0; n < cchwritten; n++) - mb_cptr_adv(p); + MB_CPTR_ADV(p); written = p - pchBuf; g_coord.X += (SHORT)mb_string2cells(pchBuf, written); } diff --git a/src/popupmnu.c b/src/popupmnu.c index 307dbbedc6..58e38176c8 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -335,7 +335,7 @@ pum_redraw(void) case 3: p = pum_array[idx].pum_extra; break; } if (p != NULL) - for ( ; ; mb_ptr_adv(p)) + for ( ; ; MB_PTR_ADV(p)) { if (s == NULL) s = p; @@ -369,7 +369,7 @@ pum_redraw(void) { size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1; - mb_ptr_adv(rt); + MB_PTR_ADV(rt); } while (size > pum_width); if (size < pum_width) @@ -590,7 +590,7 @@ pum_set_selected(int n, int repeat) && curbuf->b_p_bh[0] == 'w') { /* Already a "wipeout" buffer, make it empty. */ - while (!bufempty()) + while (!BUFEMPTY()) ml_delete((linenr_T)1, FALSE); } else diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro index 83384c028c..68c40daa1f 100644 --- a/src/proto/misc2.pro +++ b/src/proto/misc2.pro @@ -83,7 +83,7 @@ int get_real_state(void); int after_pathsep(char_u *b, char_u *p); int same_directory(char_u *f1, char_u *f2); int vim_chdirfile(char_u *fname); -int illegal_slash(char *name); +int vim_stat(const char *name, stat_T *stp); char_u *parse_shape_opt(int what); int get_shape_idx(int mouse); void update_mouseshape(int shape_idx); diff --git a/src/proto/ops.pro b/src/proto/ops.pro index ef044e7aba..0740ddad3d 100644 --- a/src/proto/ops.pro +++ b/src/proto/ops.pro @@ -38,6 +38,7 @@ void adjust_cursor_eol(void); int preprocs_left(void); int get_register_name(int num); void ex_display(exarg_T *eap); +char_u *skip_comment(char_u *line, int process, int include_space, int *is_comment); int do_join(long count, int insert_space, int save_undo, int use_formatoptions, int setmark); void op_format(oparg_T *oap, int keep_cursor); void op_formatexpr(oparg_T *oap); diff --git a/src/quickfix.c b/src/quickfix.c index e4ea401ece..090b046dd2 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2608,7 +2608,7 @@ qf_fmt_text(char_u *text, char_u *buf, int bufsize) { buf[i] = ' '; while (*++p != NUL) - if (!vim_iswhite(*p) && *p != '\n') + if (!VIM_ISWHITE(*p) && *p != '\n') break; } else diff --git a/src/regexp.c b/src/regexp.c index 78d643174e..91b8015bb8 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -1205,7 +1205,7 @@ skip_anyof(char_u *p) { ++p; if (*p != ']' && *p != NUL) - mb_ptr_adv(p); + MB_PTR_ADV(p); } else if (*p == '\\' && !reg_cpo_bsl @@ -1252,7 +1252,7 @@ skip_regexp( mymagic = MAGIC_OFF; get_cpo_flags(); - for (; p[0] != NUL; mb_ptr_adv(p)) + for (; p[0] != NUL; MB_PTR_ADV(p)) { if (p[0] == dirc) /* found end of regexp */ break; @@ -3864,7 +3864,7 @@ bt_regexec_both( { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) break; /* Found it. */ - mb_ptr_adv(s); + MB_PTR_ADV(s); } #endif else @@ -3872,7 +3872,7 @@ bt_regexec_both( { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) break; /* Found it. */ - mb_ptr_adv(s); + MB_PTR_ADV(s); } if (s == NULL) /* Not present. */ goto theend; @@ -4150,7 +4150,7 @@ reg_match_visual(void) if (VIsual_active) { - if (lt(VIsual, wp->w_cursor)) + if (LT_POS(VIsual, wp->w_cursor)) { top = VIsual; bot = wp->w_cursor; @@ -4164,7 +4164,7 @@ reg_match_visual(void) } else { - if (lt(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end)) + if (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end)) { top = curbuf->b_visual.vi_start; bot = curbuf->b_visual.vi_end; @@ -4204,7 +4204,7 @@ reg_match_visual(void) return TRUE; } -#define ADVANCE_REGINPUT() mb_ptr_adv(reginput) +#define ADVANCE_REGINPUT() MB_PTR_ADV(reginput) /* * The arguments from BRACE_LIMITS are stored here. They are actually local @@ -4523,14 +4523,14 @@ regmatch( break; case WHITE: - if (!vim_iswhite(c)) + if (!VIM_ISWHITE(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NWHITE: - if (c == NUL || vim_iswhite(c)) + if (c == NUL || VIM_ISWHITE(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4775,7 +4775,7 @@ regmatch( { /* Skip composing characters. */ while (utf_iscomposing(utf_ptr2char(reginput))) - mb_cptr_adv(reginput); + MB_CPTR_ADV(reginput); } #endif break; @@ -5557,7 +5557,7 @@ regmatch( no = FAIL; else { - mb_ptr_back(regline, rp->rs_un.regsave.rs_u.ptr); + MB_PTR_BACK(regline, rp->rs_un.regsave.rs_u.ptr); if (limit > 0 && (long)(behind_pos.rs_u.ptr - rp->rs_un.regsave.rs_u.ptr) > limit) no = FAIL; @@ -5644,7 +5644,7 @@ regmatch( fast_breakcheck(); } else - mb_ptr_back(regline, reginput); + MB_PTR_BACK(regline, reginput); } else { @@ -5788,7 +5788,7 @@ regrepeat( while (*scan != NUL && count < maxcount) { ++count; - mb_ptr_adv(scan); + MB_PTR_ADV(scan); } if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline || rex.reg_line_lbr || count == maxcount) @@ -5811,7 +5811,7 @@ regrepeat( { if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) { - mb_ptr_adv(scan); + MB_PTR_ADV(scan); } else if (*scan == NUL) { @@ -5842,7 +5842,7 @@ regrepeat( if (vim_iswordp_buf(scan, rex.reg_buf) && (testval || !VIM_ISDIGIT(*scan))) { - mb_ptr_adv(scan); + MB_PTR_ADV(scan); } else if (*scan == NUL) { @@ -5872,7 +5872,7 @@ regrepeat( { if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) { - mb_ptr_adv(scan); + MB_PTR_ADV(scan); } else if (*scan == NUL) { @@ -5913,7 +5913,7 @@ regrepeat( else if (vim_isprintc(PTR2CHAR(scan)) == 1 && (testval || !VIM_ISDIGIT(*scan))) { - mb_ptr_adv(scan); + MB_PTR_ADV(scan); } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) ++scan; @@ -7546,7 +7546,7 @@ vim_regsub_both( { int had_backslash = FALSE; - for (s = eval_result; *s != NUL; mb_ptr_adv(s)) + for (s = eval_result; *s != NUL; MB_PTR_ADV(s)) { /* Change NL to CR, so that it becomes a line break, * unless called from vim_regexec_nl(). diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index de22dcbacc..20ef1869e2 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1425,7 +1425,7 @@ nfa_regatom(void) EMSG(_(e_nopresub)); return FAIL; } - for (lp = reg_prev_sub; *lp != NUL; mb_cptr_adv(lp)) + for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) { EMIT(PTR2CHAR(lp)); if (lp != reg_prev_sub) @@ -1672,7 +1672,7 @@ collection: else EMIT(result); regparse = endp; - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); return OK; } /* @@ -1684,7 +1684,7 @@ collection: if (*regparse == '^') /* negated range */ { negated = TRUE; - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); EMIT(NFA_START_NEG_COLL); } else @@ -1694,7 +1694,7 @@ collection: startc = '-'; EMIT(startc); EMIT(NFA_CONCAT); - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); } /* Emit the OR branches for each character in the [] */ emit_range = FALSE; @@ -1797,7 +1797,7 @@ collection: { emit_range = TRUE; startc = oldstartc; - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); continue; /* reading the end of the range */ } @@ -1817,7 +1817,7 @@ collection: ) ) { - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); if (*regparse == 'n') startc = reg_string ? NL : NFA_NEWL; @@ -1832,7 +1832,7 @@ collection: /* TODO(RE) This needs more testing */ startc = coll_get_char(); got_coll_char = TRUE; - mb_ptr_back(old_regparse, regparse); + MB_PTR_BACK(old_regparse, regparse); } else { @@ -1932,10 +1932,10 @@ collection: } } - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); } /* while (p < endp) */ - mb_ptr_back(old_regparse, regparse); + MB_PTR_BACK(old_regparse, regparse); if (*regparse == '-') /* if last, '-' is just a char */ { EMIT('-'); @@ -1944,7 +1944,7 @@ collection: /* skip the trailing ] */ regparse = endp; - mb_ptr_adv(regparse); + MB_PTR_ADV(regparse); /* Mark end of the collection. */ if (negated == TRUE) @@ -6351,12 +6351,12 @@ nfa_regmatch( break; case NFA_WHITE: /* \s */ - result = vim_iswhite(curc); + result = VIM_ISWHITE(curc); ADD_STATE_IF_MATCH(t->state); break; case NFA_NWHITE: /* \S */ - result = curc != NUL && !vim_iswhite(curc); + result = curc != NUL && !VIM_ISWHITE(curc); ADD_STATE_IF_MATCH(t->state); break; diff --git a/src/screen.c b/src/screen.c index 1b020007d7..ed7e2b8235 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2714,7 +2714,7 @@ fold_line( */ if (VIsual_active && wp->w_buffer == curwin->w_buffer) { - if (ltoreq(curwin->w_cursor, VIsual)) + if (LTOREQ_POS(curwin->w_cursor, VIsual)) { /* Visual is after curwin->w_cursor */ top = &curwin->w_cursor; @@ -3170,7 +3170,7 @@ win_line( if (VIsual_active && wp->w_buffer == curwin->w_buffer) { /* Visual is after curwin->w_cursor */ - if (ltoreq(curwin->w_cursor, VIsual)) + if (LTOREQ_POS(curwin->w_cursor, VIsual)) { top = &curwin->w_cursor; bot = &VIsual; @@ -3371,7 +3371,7 @@ win_line( if (lcs_trail) { trailcol = (colnr_T)STRLEN(ptr); - while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1])) + while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1])) --trailcol; trailcol += (colnr_T) (ptr - line); } @@ -3397,7 +3397,7 @@ win_line( #ifdef FEAT_MBYTE prev_ptr = ptr; #endif - mb_ptr_adv(ptr); + MB_PTR_ADV(ptr); } /* When: @@ -4554,7 +4554,7 @@ win_line( * Found last space before word: check for line break. */ if (wp->w_p_lbr && c0 == c - && vim_isbreak(c) && !vim_isbreak(*ptr)) + && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr)) { # ifdef FEAT_MBYTE int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0; @@ -4577,7 +4577,7 @@ win_line( # else c_extra = ' '; # endif - if (vim_iswhite(c)) + if (VIM_ISWHITE(c)) { #ifdef FEAT_CONCEAL if (c == TAB) @@ -6419,7 +6419,7 @@ status_match_len(expand_T *xp, char_u *s) { s += skip_status_match_char(xp, s); len += ptr2cells(s); - mb_ptr_adv(s); + MB_PTR_ADV(s); } return len; @@ -10498,7 +10498,7 @@ draw_tabline(void) while (len > room) { len -= ptr2cells(p); - mb_ptr_adv(p); + MB_PTR_ADV(p); } else #endif diff --git a/src/search.c b/src/search.c index a66276bce9..5f3fdaa0f0 100644 --- a/src/search.c +++ b/src/search.c @@ -1652,7 +1652,11 @@ searchc(cmdarg_T *cap, int t_cmd) } else /* repeat previous search */ { - if (*lastc == NUL) + if (*lastc == NUL +#ifdef FEAT_MBYTE + && lastc_bytelen == 1 +#endif + ) return FAIL; if (dir) /* repeat in opposite direction */ dir = -lastcdir; @@ -2105,7 +2109,7 @@ findmatchlimit( do_quotes = -1; start_in_quotes = MAYBE; - clearpos(&match_pos); + CLEAR_POS(&match_pos); /* backward search: Check if this line contains a single-line comment */ if ((backwards && comment_dir) @@ -2725,7 +2729,7 @@ findsent(int dir, long count) if (decl(&pos) == -1) break; /* when going forward: Stop in front of empty line */ - if (lineempty(pos.lnum) && dir == FORWARD) + if (LINEEMPTY(pos.lnum) && dir == FORWARD) { incl(&pos); goto found; @@ -3087,7 +3091,7 @@ bck_word(long count, int bigword, int stop) while (cls() == 0) { if (curwin->w_cursor.col == 0 - && lineempty(curwin->w_cursor.lnum)) + && LINEEMPTY(curwin->w_cursor.lnum)) goto finished; if (dec_cursor() == -1) /* hit start of file, stop here */ return OK; @@ -3168,7 +3172,7 @@ end_word( while (cls() == 0) { if (empty && curwin->w_cursor.col == 0 - && lineempty(curwin->w_cursor.lnum)) + && LINEEMPTY(curwin->w_cursor.lnum)) goto finished; if (inc_cursor() == -1) /* hit end of file, stop here */ return FAIL; @@ -3228,7 +3232,7 @@ bckend_word( */ while (cls() == 0) { - if (curwin->w_cursor.col == 0 && lineempty(curwin->w_cursor.lnum)) + if (curwin->w_cursor.col == 0 && LINEEMPTY(curwin->w_cursor.lnum)) break; if ((i = dec_cursor()) == -1 || (eol && i == 1)) return OK; @@ -3281,7 +3285,7 @@ find_first_blank(pos_T *posp) while (decl(posp) != -1) { c = gchar_pos(posp); - if (!vim_iswhite(c)) + if (!VIM_ISWHITE(c)) { incl(posp); break; @@ -3325,17 +3329,17 @@ current_word( int include_white = FALSE; cls_bigword = bigword; - clearpos(&start_pos); + CLEAR_POS(&start_pos); /* Correct cursor when 'selection' is exclusive */ - if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor)) + if (VIsual_active && *p_sel == 'e' && LT_POS(VIsual, curwin->w_cursor)) dec_cursor(); /* * When Visual mode is not active, or when the VIsual area is only one * character, select the word and/or white space under the cursor. */ - if (!VIsual_active || equalpos(curwin->w_cursor, VIsual)) + if (!VIsual_active || EQUAL_POS(curwin->w_cursor, VIsual)) { /* * Go to start of current word or white space. @@ -3392,7 +3396,7 @@ current_word( while (count > 0) { inclusive = TRUE; - if (VIsual_active && lt(curwin->w_cursor, VIsual)) + if (VIsual_active && LT_POS(curwin->w_cursor, VIsual)) { /* * In Visual mode, with cursor at start: move cursor back. @@ -3468,7 +3472,7 @@ current_word( if (VIsual_active) { - if (*p_sel == 'e' && inclusive && ltoreq(VIsual, curwin->w_cursor)) + if (*p_sel == 'e' && inclusive && LTOREQ_POS(VIsual, curwin->w_cursor)) inc_cursor(); if (VIsual_mode == 'V') { @@ -3503,10 +3507,10 @@ current_sent(oparg_T *oap, long count, int include) /* * When the Visual area is bigger than one character: Extend it. */ - if (VIsual_active && !equalpos(start_pos, VIsual)) + if (VIsual_active && !EQUAL_POS(start_pos, VIsual)) { extend: - if (lt(start_pos, VIsual)) + if (LT_POS(start_pos, VIsual)) { /* * Cursor at start of Visual area. @@ -3517,10 +3521,10 @@ extend: */ at_start_sent = TRUE; decl(&pos); - while (lt(pos, curwin->w_cursor)) + while (LT_POS(pos, curwin->w_cursor)) { c = gchar_pos(&pos); - if (!vim_iswhite(c)) + if (!VIM_ISWHITE(c)) { at_start_sent = FALSE; break; @@ -3530,7 +3534,7 @@ extend: if (!at_start_sent) { findsent(BACKWARD, 1L); - if (equalpos(curwin->w_cursor, start_pos)) + if (EQUAL_POS(curwin->w_cursor, start_pos)) at_start_sent = TRUE; /* exactly at start of sentence */ else /* inside a sentence, go to its end (start of next) */ @@ -3543,7 +3547,7 @@ extend: if (at_start_sent) find_first_blank(&curwin->w_cursor); c = gchar_cursor(); - if (!at_start_sent || (!include && !vim_iswhite(c))) + if (!at_start_sent || (!include && !VIM_ISWHITE(c))) findsent(BACKWARD, 1L); at_start_sent = !at_start_sent; } @@ -3559,13 +3563,14 @@ extend: */ incl(&pos); at_start_sent = TRUE; - if (!equalpos(pos, curwin->w_cursor)) /* not just before a sentence */ + /* not just before a sentence */ + if (!EQUAL_POS(pos, curwin->w_cursor)) { at_start_sent = FALSE; - while (lt(pos, curwin->w_cursor)) + while (LT_POS(pos, curwin->w_cursor)) { c = gchar_pos(&pos); - if (!vim_iswhite(c)) + if (!VIM_ISWHITE(c)) { at_start_sent = TRUE; break; @@ -3591,9 +3596,9 @@ extend: * If the cursor started on a blank, check if it is just before the start * of the next sentence. */ - while (c = gchar_pos(&pos), vim_iswhite(c)) /* vim_iswhite() is a macro */ + while (c = gchar_pos(&pos), VIM_ISWHITE(c)) /* VIM_ISWHITE() is a macro */ incl(&pos); - if (equalpos(pos, curwin->w_cursor)) + if (EQUAL_POS(pos, curwin->w_cursor)) { start_blank = TRUE; find_first_blank(&start_pos); /* go back to first blank */ @@ -3627,18 +3632,18 @@ extend: if (start_blank) { find_first_blank(&curwin->w_cursor); - c = gchar_pos(&curwin->w_cursor); /* vim_iswhite() is a macro */ - if (vim_iswhite(c)) + c = gchar_pos(&curwin->w_cursor); /* VIM_ISWHITE() is a macro */ + if (VIM_ISWHITE(c)) decl(&curwin->w_cursor); } - else if (c = gchar_cursor(), !vim_iswhite(c)) + else if (c = gchar_cursor(), !VIM_ISWHITE(c)) find_first_blank(&start_pos); } if (VIsual_active) { /* Avoid getting stuck with "is" on a single space before a sentence. */ - if (equalpos(start_pos, curwin->w_cursor)) + if (EQUAL_POS(start_pos, curwin->w_cursor)) goto extend; if (*p_sel == 'e') ++curwin->w_cursor.col; @@ -3687,7 +3692,7 @@ current_block( /* * If we start on '(', '{', ')', '}', etc., use the whole block inclusive. */ - if (!VIsual_active || equalpos(VIsual, curwin->w_cursor)) + if (!VIsual_active || EQUAL_POS(VIsual, curwin->w_cursor)) { setpcmark(); if (what == '{') /* ignore indent */ @@ -3698,7 +3703,7 @@ current_block( /* cursor on '(' or '{', move cursor just after it */ ++curwin->w_cursor.col; } - else if (lt(VIsual, curwin->w_cursor)) + else if (LT_POS(VIsual, curwin->w_cursor)) { old_start = VIsual; curwin->w_cursor = VIsual; /* cursor at low end of Visual */ @@ -3756,7 +3761,7 @@ current_block( * In Visual mode, when the resulting area is not bigger than what we * started with, extend it to the next block, and then exclude again. */ - if (!lt(start_pos, old_start) && !lt(old_end, curwin->w_cursor) + if (!LT_POS(start_pos, old_start) && !LT_POS(old_end, curwin->w_cursor) && VIsual_active) { curwin->w_cursor = old_start; @@ -3797,7 +3802,7 @@ current_block( oap->inclusive = FALSE; if (sol) incl(&curwin->w_cursor); - else if (ltoreq(start_pos, curwin->w_cursor)) + else if (LTOREQ_POS(start_pos, curwin->w_cursor)) /* Include the character under the cursor. */ oap->inclusive = TRUE; else @@ -3832,7 +3837,7 @@ in_html_tag( /* We search forward until the cursor, because searching backwards is * very slow for DBCS encodings. */ - for (p = line; p < line + curwin->w_cursor.col; mb_ptr_adv(p)) + for (p = line; p < line + curwin->w_cursor.col; MB_PTR_ADV(p)) if (*p == '>' || *p == '<') { lc = *p; @@ -3852,7 +3857,7 @@ in_html_tag( { if (*p == '<') /* find '<' under/before cursor */ break; - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); if (*p == '>') /* find '>' before cursor */ break; } @@ -3863,7 +3868,7 @@ in_html_tag( pos.lnum = curwin->w_cursor.lnum; pos.col = (colnr_T)(p - line); - mb_ptr_adv(p); + MB_PTR_ADV(p); if (end_tag) /* check that there is a '/' after the '<' */ return *p == '/'; @@ -3921,7 +3926,7 @@ current_tagblock( /* * If we start on "" select that block. */ - if (!VIsual_active || equalpos(VIsual, curwin->w_cursor)) + if (!VIsual_active || EQUAL_POS(VIsual, curwin->w_cursor)) { setpcmark(); @@ -3947,7 +3952,7 @@ current_tagblock( old_end = curwin->w_cursor; } } - else if (lt(VIsual, curwin->w_cursor)) + else if (LT_POS(VIsual, curwin->w_cursor)) { old_start = VIsual; curwin->w_cursor = VIsual; /* cursor at low end of Visual */ @@ -3978,7 +3983,7 @@ again: */ inc_cursor(); p = ml_get_cursor(); - for (cp = p; *cp != NUL && *cp != '>' && !vim_iswhite(*cp); mb_ptr_adv(cp)) + for (cp = p; *cp != NUL && *cp != '>' && !VIM_ISWHITE(*cp); MB_PTR_ADV(cp)) ; len = (int)(cp - p); if (len == 0) @@ -4004,7 +4009,7 @@ again: vim_free(spat); vim_free(epat); - if (r < 1 || lt(curwin->w_cursor, old_end)) + if (r < 1 || LT_POS(curwin->w_cursor, old_end)) { /* Can't find other end or it's before the previous end. Could be a * HTML tag that doesn't have a matching end. Search backwards for @@ -4051,7 +4056,7 @@ again: /* If we now have the same text as before reset "do_include" and try * again. */ - if (equalpos(start_pos, old_start) && equalpos(end_pos, old_end)) + if (EQUAL_POS(start_pos, old_start) && EQUAL_POS(end_pos, old_end)) { do_include = TRUE; curwin->w_cursor = old_start; @@ -4064,7 +4069,7 @@ again: { /* If the end is before the start there is no text between tags, select * the char under the cursor. */ - if (lt(end_pos, start_pos)) + if (LT_POS(end_pos, start_pos)) curwin->w_cursor = start_pos; else if (*p_sel == 'e') inc_cursor(); @@ -4077,7 +4082,7 @@ again: { oap->start = start_pos; oap->motion_type = MCHAR; - if (lt(end_pos, start_pos)) + if (LT_POS(end_pos, start_pos)) { /* End is before the start: there is no text between tags; operate * on an empty area. */ @@ -4367,10 +4372,10 @@ current_quote( if (VIsual.lnum != curwin->w_cursor.lnum) return FALSE; - vis_bef_curs = lt(VIsual, curwin->w_cursor); + vis_bef_curs = LT_POS(VIsual, curwin->w_cursor); if (*p_sel == 'e' && vis_bef_curs) dec_cursor(); - vis_empty = equalpos(VIsual, curwin->w_cursor); + vis_empty = EQUAL_POS(VIsual, curwin->w_cursor); } if (!vis_empty) @@ -4500,11 +4505,11 @@ current_quote( * the starting quote. */ if (include) { - if (vim_iswhite(line[col_end + 1])) - while (vim_iswhite(line[col_end + 1])) + if (VIM_ISWHITE(line[col_end + 1])) + while (VIM_ISWHITE(line[col_end + 1])) ++col_end; else - while (col_start > 0 && vim_iswhite(line[col_start - 1])) + while (col_start > 0 && VIM_ISWHITE(line[col_start - 1])) --col_start; } @@ -4610,7 +4615,7 @@ current_search( p_ws = FALSE; /* Correct cursor when 'selection' is exclusive */ - if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor)) + if (VIsual_active && *p_sel == 'e' && LT_POS(VIsual, curwin->w_cursor)) dec_cursor(); if (VIsual_active) @@ -4673,12 +4678,14 @@ current_search( } else if (!i && !result) { - if (forward) /* try again from start of buffer */ + if (forward) { - clearpos(&pos); + /* try again from start of buffer */ + CLEAR_POS(&pos); } - else /* try again from end of buffer */ + else { + /* try again from end of buffer */ /* searching backwards, so set pos to last line and col */ pos.lnum = curwin->w_buffer->b_ml.ml_line_count; pos.col = (colnr_T)STRLEN( @@ -4714,9 +4721,9 @@ current_search( if (*p_sel == 'e') { /* Correction for exclusive selection depends on the direction. */ - if (forward && ltoreq(VIsual, curwin->w_cursor)) + if (forward && LTOREQ_POS(VIsual, curwin->w_cursor)) inc_cursor(); - else if (!forward && ltoreq(curwin->w_cursor, VIsual)) + else if (!forward && LTOREQ_POS(curwin->w_cursor, VIsual)) inc(&VIsual); } @@ -4769,7 +4776,9 @@ is_one_char(char_u *pattern, int move) regmatch.startpos[0].col = -1; /* move to match */ if (move) - clearpos(&pos) + { + CLEAR_POS(&pos); + } else { pos = curwin->w_cursor; diff --git a/src/spell.c b/src/spell.c index f124ef21df..1700bba0e4 100644 --- a/src/spell.c +++ b/src/spell.c @@ -468,7 +468,7 @@ spell_check( { do { - mb_ptr_adv(mi.mi_fend); + MB_PTR_ADV(mi.mi_fend); } while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp)); if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) @@ -494,7 +494,7 @@ spell_check( /* case-fold the word with one non-word character, so that we can check * for the word end. */ if (*mi.mi_fend != NUL) - mb_ptr_adv(mi.mi_fend); + MB_PTR_ADV(mi.mi_fend); (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1); @@ -582,7 +582,7 @@ spell_check( else if (mi.mi_end == ptr) /* Always include at least one character. Required for when there * is a mixup in "midword". */ - mb_ptr_adv(mi.mi_end); + MB_PTR_ADV(mi.mi_end); else if (mi.mi_result == SP_BAD && LANGP_ENTRY(wp->w_s->b_langp, 0)->lp_slang->sl_nobreak) { @@ -598,8 +598,8 @@ spell_check( fp = mi.mi_fword; for (;;) { - mb_ptr_adv(p); - mb_ptr_adv(fp); + MB_PTR_ADV(p); + MB_PTR_ADV(fp); if (p >= mi.mi_end) break; mi.mi_compoff = (int)(fp - mi.mi_fword); @@ -827,8 +827,8 @@ find_word(matchinf_T *mip, int mode) p = mip->mi_word; if (STRNCMP(ptr, p, wlen) != 0) { - for (s = ptr; s < ptr + wlen; mb_ptr_adv(s)) - mb_ptr_adv(p); + for (s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) + MB_PTR_ADV(p); wlen = (int)(p - mip->mi_word); } } @@ -952,8 +952,8 @@ find_word(matchinf_T *mip, int mode) { /* case folding may have changed the length */ p = mip->mi_word; - for (s = ptr; s < ptr + mip->mi_compoff; mb_ptr_adv(s)) - mb_ptr_adv(p); + for (s = ptr; s < ptr + mip->mi_compoff; MB_PTR_ADV(s)) + MB_PTR_ADV(p); } else #endif @@ -969,7 +969,7 @@ find_word(matchinf_T *mip, int mode) * character we do not accept a Onecap word. We do * accept a no-caps word, even when the dictionary * word specifies ONECAP. */ - mb_ptr_back(mip->mi_word, p); + MB_PTR_BACK(mip->mi_word, p); if (spell_iswordp_nmw(p, mip->mi_win) ? capflags == WF_ONECAP : (flags & WF_ONECAP) != 0 @@ -1038,8 +1038,8 @@ find_word(matchinf_T *mip, int mode) p = mip->mi_fword; if (STRNCMP(ptr, p, wlen) != 0) { - for (s = ptr; s < ptr + wlen; mb_ptr_adv(s)) - mb_ptr_adv(p); + for (s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) + MB_PTR_ADV(p); mip->mi_compoff = (int)(p - mip->mi_fword); } } @@ -1506,12 +1506,12 @@ fold_more(matchinf_T *mip) p = mip->mi_fend; do { - mb_ptr_adv(mip->mi_fend); + MB_PTR_ADV(mip->mi_fend); } while (*mip->mi_fend != NUL && spell_iswordp(mip->mi_fend, mip->mi_win)); /* Include the non-word character so that we can check for the word end. */ if (*mip->mi_fend != NUL) - mb_ptr_adv(mip->mi_fend); + MB_PTR_ADV(mip->mi_fend); (void)spell_casefold(p, (int)(mip->mi_fend - p), mip->mi_fword + mip->mi_fwordlen, @@ -1603,7 +1603,7 @@ spell_move_to( * though... */ lnum = wp->w_cursor.lnum; - clearpos(&found_pos); + CLEAR_POS(&found_pos); while (!got_int) { @@ -2760,7 +2760,7 @@ captype( int past_second = FALSE; /* past second word char */ /* find first letter */ - for (p = word; !spell_iswordp_nmw(p, curwin); mb_ptr_adv(p)) + for (p = word; !spell_iswordp_nmw(p, curwin); MB_PTR_ADV(p)) if (end == NULL ? *p == NUL : p >= end) return 0; /* only non-word characters, illegal word */ #ifdef FEAT_MBYTE @@ -2775,7 +2775,7 @@ captype( * Need to check all letters to find a word with mixed upper/lower. * But a word with an upper char only at start is a ONECAP. */ - for ( ; end == NULL ? *p != NUL : p < end; mb_ptr_adv(p)) + for ( ; end == NULL ? *p != NUL : p < end; MB_PTR_ADV(p)) if (spell_iswordp_nmw(p, curwin)) { c = PTR2CHAR(p); @@ -2818,7 +2818,7 @@ badword_captype(char_u *word, char_u *end) /* Count the number of UPPER and lower case letters. */ l = u = 0; first = FALSE; - for (p = word; p < end; mb_ptr_adv(p)) + for (p = word; p < end; MB_PTR_ADV(p)) { c = PTR2CHAR(p); if (SPELL_ISUPPER(c)) @@ -3385,10 +3385,10 @@ spell_suggest(int count) p = line + curwin->w_cursor.col; /* Backup to before start of word. */ while (p > line && spell_iswordp_nmw(p, curwin)) - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); /* Forward to start of word. */ while (*p != NUL && !spell_iswordp_nmw(p, curwin)) - mb_ptr_adv(p); + MB_PTR_ADV(p); if (!spell_iswordp_nmw(p, curwin)) /* No word found. */ { @@ -3624,7 +3624,7 @@ check_need_cap(linenr_T lnum, colnr_T col) p = line + endcol; for (;;) { - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); if (p == line || spell_iswordp_nmw(p, curwin)) break; if (vim_regexec(®match, p, 0) @@ -4528,7 +4528,7 @@ suggest_trie_walk( fword_ends = (fword[sp->ts_fidx] == NUL || (soundfold - ? vim_iswhite(fword[sp->ts_fidx]) + ? VIM_ISWHITE(fword[sp->ts_fidx]) : !spell_iswordp(fword + sp->ts_fidx, curwin))); tword[sp->ts_twordlen] = NUL; @@ -4644,7 +4644,7 @@ suggest_trie_walk( /* Get pointer to last char of previous word. */ p = preword + sp->ts_prewordlen; - mb_ptr_back(preword, p); + MB_PTR_BACK(preword, p); } } @@ -4746,11 +4746,11 @@ suggest_trie_walk( /* Give a penalty when changing non-word char to word * char, e.g., "thes," -> "these". */ p = fword + sp->ts_fidx; - mb_ptr_back(fword, p); + MB_PTR_BACK(fword, p); if (!spell_iswordp(p, curwin)) { p = preword + STRLEN(preword); - mb_ptr_back(preword, p); + MB_PTR_BACK(preword, p); if (spell_iswordp(p, curwin)) newscore += SCORE_NONWORD; } @@ -5157,7 +5157,7 @@ suggest_trie_walk( * to the score. Also for the soundfold * tree (might seem illogical but does * give better scores). */ - mb_ptr_back(tword, p); + MB_PTR_BACK(tword, p); if (c == mb_ptr2char(p)) sp->ts_score -= SCORE_INS - SCORE_INSDUP; @@ -5867,9 +5867,9 @@ nofold_len(char_u *fword, int flen, char_u *word) char_u *p; int i = 0; - for (p = fword; p < fword + flen; mb_ptr_adv(p)) + for (p = fword; p < fword + flen; MB_PTR_ADV(p)) ++i; - for (p = word; i > 0; mb_ptr_adv(p)) + for (p = word; i > 0; MB_PTR_ADV(p)) --i; return (int)(p - word); } @@ -6231,7 +6231,7 @@ stp_sal_score( * sounds like "t h" while "the" sounds like "@". Avoid that by * removing the space. Don't do it when the good word also contains a * space. */ - if (vim_iswhite(su->su_badptr[su->su_badlen]) + if (VIM_ISWHITE(su->su_badptr[su->su_badlen]) && *skiptowhite(stp->st_word) == NUL) for (p = fword; *(p = skiptowhite(p)) != NUL; ) STRMOVE(p, p + 1); @@ -6745,8 +6745,8 @@ add_suggestion( badlen = (int)(pbad - su->su_badptr); if (goodlen <= 0 || badlen <= 0) break; - mb_ptr_back(goodword, pgood); - mb_ptr_back(su->su_badptr, pbad); + MB_PTR_BACK(goodword, pgood); + MB_PTR_BACK(su->su_badptr, pbad); #ifdef FEAT_MBYTE if (has_mbyte) { @@ -7106,7 +7106,7 @@ spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) for (s = inword; *s != NUL; ) { c = mb_cptr2char_adv(&s); - if (enc_utf8 ? utf_class(c) == 0 : vim_iswhite(c)) + if (enc_utf8 ? utf_class(c) == 0 : VIM_ISWHITE(c)) c = ' '; else if (c < 256) c = slang->sl_sal_first[c]; @@ -7147,7 +7147,7 @@ spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) /* The sl_sal_first[] table contains the translation. */ for (s = inword; (c = *s) != NUL; ++s) { - if (vim_iswhite(c)) + if (VIM_ISWHITE(c)) c = ' '; else c = slang->sl_sal_first[c]; @@ -7185,7 +7185,7 @@ spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) t = word; while (*s != NUL) { - if (vim_iswhite(*s)) + if (VIM_ISWHITE(*s)) { *t++ = ' '; s = skipwhite(s); @@ -7409,7 +7409,7 @@ spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) } } } - else if (vim_iswhite(c)) + else if (VIM_ISWHITE(c)) { c = ' '; k = 1; @@ -7474,7 +7474,7 @@ spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) c = mb_cptr2char_adv(&s); if (slang->sl_rem_accents) { - if (enc_utf8 ? utf_class(c) == 0 : vim_iswhite(c)) + if (enc_utf8 ? utf_class(c) == 0 : VIM_ISWHITE(c)) { if (did_white) continue; @@ -7715,7 +7715,7 @@ spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) } } } - else if (vim_iswhite(c)) + else if (VIM_ISWHITE(c)) { c = ' '; k = 1; @@ -8545,7 +8545,7 @@ ex_spelldump(exarg_T *eap) set_option_value((char_u*)"spl", dummy, spl, OPT_LOCAL); vim_free(spl); - if (!bufempty()) + if (!BUFEMPTY()) return; spell_dump_compl(NULL, 0, NULL, eap->forceit ? DUMPFLAG_COUNT : 0); @@ -8976,7 +8976,7 @@ spell_to_word_end(char_u *start, win_T *win) char_u *p = start; while (*p != NUL && spell_iswordp(p, win)) - mb_ptr_adv(p); + MB_PTR_ADV(p); return p; } @@ -9002,7 +9002,7 @@ spell_word_start(int startcol) line = ml_get_curline(); for (p = line + startcol; p > line; ) { - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); if (spell_iswordp_nmw(p, curwin)) break; } @@ -9011,7 +9011,7 @@ spell_word_start(int startcol) while (p > line) { col = (int)(p - line); - mb_ptr_back(line, p); + MB_PTR_BACK(line, p); if (!spell_iswordp(p, curwin)) break; col = 0; diff --git a/src/spellfile.c b/src/spellfile.c index 00ef019a6a..6188aaf40c 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -1429,7 +1429,7 @@ set_sofo(slang_T *lp, char_u *from, char_u *to) for (p = from, s = to; *p != NUL && *s != NUL; ) { c = mb_cptr2char_adv(&p); - mb_cptr_adv(s); + MB_CPTR_ADV(s); if (c >= 256) ++lp->sl_sal_first[c & 0xff]; } @@ -2802,7 +2802,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname) { p = aff_entry->ae_add + STRLEN(aff_entry->ae_add); - mb_ptr_back(aff_entry->ae_add, p); + MB_PTR_BACK(aff_entry->ae_add, p); if (PTR2CHAR(p) == c_up) { upper = TRUE; @@ -2930,10 +2930,10 @@ spell_read_aff(spellinfo_T *spin, char_u *fname) { /* Replace underscore with space (can't include a space * directly). */ - for (p = items[1]; *p != NUL; mb_ptr_adv(p)) + for (p = items[1]; *p != NUL; MB_PTR_ADV(p)) if (*p == '_') *p = ' '; - for (p = items[2]; *p != NUL; mb_ptr_adv(p)) + for (p = items[2]; *p != NUL; MB_PTR_ADV(p)) if (*p == '_') *p = ' '; add_fromto(spin, items[0][3] == 'S' @@ -3624,7 +3624,7 @@ spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) /* Truncate the word at the "/", set "afflist" to what follows. * Replace "\/" by "/" and "\\" by "\". */ afflist = NULL; - for (p = w; *p != NUL; mb_ptr_adv(p)) + for (p = w; *p != NUL; MB_PTR_ADV(p)) { if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) STRMOVE(p, p + 1); @@ -3947,7 +3947,7 @@ store_aff_word( { i = mb_charlen(ae->ae_chop); for ( ; i > 0; --i) - mb_ptr_adv(p); + MB_PTR_ADV(p); } else #endif @@ -3965,7 +3965,7 @@ store_aff_word( p = newword + STRLEN(newword); i = (int)MB_CHARLEN(ae->ae_chop); for ( ; i > 0; --i) - mb_ptr_back(newword, p); + MB_PTR_BACK(newword, p); *p = NUL; } if (ae->ae_add != NULL) diff --git a/src/syntax.c b/src/syntax.c index da8c08f82c..bc87a0f83b 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -2308,7 +2308,7 @@ syn_current_attr( { line = syn_getcurline(); if (((current_next_flags & HL_SKIPWHITE) - && vim_iswhite(line[current_col])) + && VIM_ISWHITE(line[current_col])) || ((current_next_flags & HL_SKIPEMPTY) && *line == NUL)) break; @@ -3211,12 +3211,12 @@ syn_add_end_off( if (off > 0) { while (off-- > 0 && *p != NUL) - mb_ptr_adv(p); + MB_PTR_ADV(p); } else if (off < 0) { while (off++ < 0 && base < p) - mb_ptr_back(base, p); + MB_PTR_BACK(base, p); } col = (int)(p - base); } @@ -3265,12 +3265,12 @@ syn_add_start_off( if (off > 0) { while (off-- && *p != NUL) - mb_ptr_adv(p); + MB_PTR_ADV(p); } else if (off < 0) { while (off++ && base < p) - mb_ptr_back(base, p); + MB_PTR_BACK(base, p); } col = (int)(p - base); } @@ -4631,7 +4631,7 @@ get_syn_options( for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) if (arg[len] != p[i] && arg[len] != p[i + 1]) break; - if (p[i] == NUL && (vim_iswhite(arg[len]) + if (p[i] == NUL && (VIM_ISWHITE(arg[len]) || (flagtab[fidx].argtype > 0 ? arg[len] == '=' : ends_excmd(arg[len])))) @@ -4905,7 +4905,7 @@ syn_cmd_keyword(exarg_T *eap, int syncing UNUSED) if (rest == NULL || ends_excmd(*rest)) break; /* Copy the keyword, removing backslashes, and add a NUL. */ - while (*rest != NUL && !vim_iswhite(*rest)) + while (*rest != NUL && !VIM_ISWHITE(*rest)) { if (*rest == '\\' && rest[1] != NUL) ++rest; @@ -5156,7 +5156,7 @@ syn_cmd_region( /* must be a pattern or matchgroup then */ key_end = rest; - while (*key_end && !vim_iswhite(*key_end) && *key_end != '=') + while (*key_end && !VIM_ISWHITE(*key_end) && *key_end != '=') ++key_end; vim_free(key); key = vim_strnsave_up(rest, (int)(key_end - rest)); @@ -5640,19 +5640,19 @@ syn_cmd_cluster(exarg_T *eap, int syncing UNUSED) for (;;) { if (STRNICMP(rest, "add", 3) == 0 - && (vim_iswhite(rest[3]) || rest[3] == '=')) + && (VIM_ISWHITE(rest[3]) || rest[3] == '=')) { opt_len = 3; list_op = CLUSTER_ADD; } else if (STRNICMP(rest, "remove", 6) == 0 - && (vim_iswhite(rest[6]) || rest[6] == '=')) + && (VIM_ISWHITE(rest[6]) || rest[6] == '=')) { opt_len = 6; list_op = CLUSTER_SUBTRACT; } else if (STRNICMP(rest, "contains", 8) == 0 - && (vim_iswhite(rest[8]) || rest[8] == '=')) + && (VIM_ISWHITE(rest[8]) || rest[8] == '=')) { opt_len = 8; list_op = CLUSTER_REPLACE; @@ -5793,7 +5793,7 @@ get_syn_pattern(char_u *arg, synpat_T *ci) } } while (idx >= 0); - if (!ends_excmd(*end) && !vim_iswhite(*end)) + if (!ends_excmd(*end) && !VIM_ISWHITE(*end)) { EMSG2(_("E402: Garbage after pattern: %s"), arg); return NULL; @@ -6014,7 +6014,7 @@ get_id_list( count = 0; while (!ends_excmd(*p)) { - for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end) + for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end) ; name = alloc((int)(end - p + 3)); /* leave room for "^$" */ if (name == NULL) @@ -7467,7 +7467,7 @@ do_highlight( * Isolate the key ("term", "ctermfg", "ctermbg", "font", "guifg" or * "guibg"). */ - while (*linep && !vim_iswhite(*linep) && *linep != '=') + while (*linep && !VIM_ISWHITE(*linep) && *linep != '=') ++linep; vim_free(key); key = vim_strnsave_up(key_start, (int)(linep - key_start)); @@ -8170,7 +8170,7 @@ hl_has_settings(int idx, int check_link) || HL_TABLE()[idx].sg_gui_fg_name != NULL || HL_TABLE()[idx].sg_gui_bg_name != NULL || HL_TABLE()[idx].sg_gui_sp_name != NULL - || HL_TABLE()[idx].sg_font_name != NUL + || HL_TABLE()[idx].sg_font_name != NULL #endif || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK))); } @@ -9722,7 +9722,7 @@ highlight_changed(void) attr = 0; for ( ; *p && *p != ','; ++p) /* parse upto comma */ { - if (vim_iswhite(*p)) /* ignore white space */ + if (VIM_ISWHITE(*p)) /* ignore white space */ continue; if (attr > HL_ALL) /* Combination with ':' is not allowed. */ diff --git a/src/tag.c b/src/tag.c index 8621419db9..af6196182c 100644 --- a/src/tag.c +++ b/src/tag.c @@ -178,7 +178,7 @@ do_tag( free_string_option(nofile_fname); nofile_fname = NULL; - clearpos(&saved_fmark.mark); /* shutup gcc 4.0 */ + CLEAR_POS(&saved_fmark.mark); /* shutup gcc 4.0 */ saved_fmark.fnum = 0; /* @@ -2005,7 +2005,7 @@ parse_line: #endif if ( fnamencmp(lbuf, tagp.fname, p - lbuf) == 0 #ifdef FEAT_TAG_ANYWHITE - && vim_iswhite(tagp.fname[p - lbuf]) + && VIM_ISWHITE(tagp.fname[p - lbuf]) #else && tagp.fname[p - lbuf] == TAB #endif @@ -3544,7 +3544,7 @@ simplify_filename(char_u *filename) tail = p + 1; if (p[1] != NUL) while (vim_ispathsep(*tail)) - mb_ptr_adv(tail); + MB_PTR_ADV(tail); else if (p > start) --p; /* strip preceding path separator */ STRMOVE(p, tail); @@ -3556,7 +3556,7 @@ simplify_filename(char_u *filename) /* Skip to after ".." or "../" or "..///". */ tail = p + 2; while (vim_ispathsep(*tail)) - mb_ptr_adv(tail); + MB_PTR_ADV(tail); if (components > 0) /* strip one preceding component */ { @@ -3583,7 +3583,7 @@ simplify_filename(char_u *filename) --p; /* Skip back to after previous '/'. */ while (p > start && !after_pathsep(start, p)) - mb_ptr_back(start, p); + MB_PTR_BACK(start, p); if (!do_strip) { @@ -3932,7 +3932,7 @@ get_tags(list_T *list, char_u *pat) else if (STRNCMP(p, "file:", 5) == 0) /* skip "file:" (static tag) */ p += 4; - else if (!vim_iswhite(*p)) + else if (!VIM_ISWHITE(*p)) { char_u *s, *n; int len; diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak index 0e7b461d77..f9d21a5fa8 100644 --- a/src/testdir/Make_dos.mak +++ b/src/testdir/Make_dos.mak @@ -126,7 +126,7 @@ test_gui.res: test_gui.vim test_gui_init.res: test_gui_init.vim @echo "$(VIMPROG)" > vimcmd - $(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim + $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim @del vimcmd opt_test.vim: ../option.c gen_opt_test.vim diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak index ad4697d723..7e13c0f787 100644 --- a/src/testdir/Make_ming.mak +++ b/src/testdir/Make_ming.mak @@ -129,7 +129,7 @@ test_gui.res: test_gui.vim test_gui_init.res: test_gui_init.vim @echo "$(VIMPROG)" > vimcmd - $(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< + $(VIMPROG) -u gui_preinit_vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< @$(DEL) vimcmd opt_test.vim: ../option.c gen_opt_test.vim diff --git a/src/testdir/Makefile b/src/testdir/Makefile index ca8597fe73..ce1c24cd68 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -138,7 +138,7 @@ test_gui.res: test_gui.vim test_gui_init.res: test_gui_init.vim @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" > vimcmd - $(RUN_VIMTEST) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< + $(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< @rm vimcmd opt_test.vim: ../option.c gen_opt_test.vim diff --git a/src/testdir/gui_init.vim b/src/testdir/gui_init.vim index bc5e33cb2a..42b2bca7fe 100644 --- a/src/testdir/gui_init.vim +++ b/src/testdir/gui_init.vim @@ -2,4 +2,5 @@ if has('gui_athena') || has('gui_motif') || has('gui_gtk2') || has('gui_gtk3') set guiheadroom=0 + set guioptions+=p endif diff --git a/src/testdir/gui_preinit.vim b/src/testdir/gui_preinit.vim new file mode 100644 index 0000000000..c351b72461 --- /dev/null +++ b/src/testdir/gui_preinit.vim @@ -0,0 +1,7 @@ +" vimrc for test_gui_init.vim + +" Note that this flag must be added in the .vimrc file, before switching on +" syntax or filetype recognition (when the |gvimrc| file is sourced the system +" menu has already been loaded; the ":syntax on" and ":filetype on" commands +" load the menu too). +set guioptions+=M diff --git a/src/testdir/test_alot_utf8.vim b/src/testdir/test_alot_utf8.vim index 3022da3348..13724cbd4a 100644 --- a/src/testdir/test_alot_utf8.vim +++ b/src/testdir/test_alot_utf8.vim @@ -6,6 +6,7 @@ " files, so that they can be run by themselves. set belloff=all +source test_charsearch_utf8.vim source test_expr_utf8.vim source test_matchadd_conceal_utf8.vim source test_regexp_utf8.vim diff --git a/src/testdir/test_charsearch_utf8.vim b/src/testdir/test_charsearch_utf8.vim new file mode 100644 index 0000000000..b700a8c756 --- /dev/null +++ b/src/testdir/test_charsearch_utf8.vim @@ -0,0 +1,44 @@ +" Tests for related f{char} and t{char} using utf-8. +if !has('multi_byte') + finish +endif + +" Test for t,f,F,T movement commands +function! Test_search_cmds() + new! + call setline(1, "・最初から最後まで最強のVimは最高") + 1 + normal! f最 + call assert_equal([0, 1, 4, 0], getpos('.')) + normal! ; + call assert_equal([0, 1, 16, 0], getpos('.')) + normal! 2; + call assert_equal([0, 1, 43, 0], getpos('.')) + normal! , + call assert_equal([0, 1, 28, 0], getpos('.')) + bw! +endfunction + +" vim: shiftwidth=2 sts=2 expandtab +" Tests for related f{char} and t{char} using utf-8. +if !has('multi_byte') + finish +endif + +" Test for t,f,F,T movement commands +function! Test_search_cmds() + new! + call setline(1, "・最初から最後まで最強のVimは最高") + 1 + normal! f最 + call assert_equal([0, 1, 4, 0], getpos('.')) + normal! ; + call assert_equal([0, 1, 16, 0], getpos('.')) + normal! 2; + call assert_equal([0, 1, 43, 0], getpos('.')) + normal! , + call assert_equal([0, 1, 28, 0], getpos('.')) + bw! +endfunction + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index 3c27f4f700..f10480bb4f 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -168,6 +168,22 @@ func Test_combining_folds_marker() bwipe! endfunc +func Test_folds_marker_in_comment() + new + call setline(1, ['" foo', 'bar', 'baz']) + setl fen fdm=marker + setl com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" cms=\"%s + norm! zf2j + setl nofen + :1y + call assert_equal(['" foo{{{'], getreg(0,1,1)) + :+2y + call assert_equal(['baz"}}}'], getreg(0,1,1)) + + set foldmethod& + bwipe! +endfunc + func s:TestFoldExpr(lnum) let thisline = getline(a:lnum) if thisline == 'a' diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 7d39a1d40d..3e06eab344 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -30,6 +30,18 @@ func Test_balloon_show() endif endfunc +func Test_colorscheme() + let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default' + + colorscheme torte + redraw! + sleep 200m + call assert_equal('dark', &background) + + exec 'colorscheme' colorscheme_saved + redraw! +endfunc + func Test_getfontname_with_arg() let skipped = '' @@ -40,8 +52,8 @@ func Test_getfontname_with_arg() call assert_equal('', getfontname('notexist')) " Valid font name. This is usually the real name of 7x13 by default. - let fname = '-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-1' - call assert_equal(fname, getfontname(fname)) + let fname = '-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1' + call assert_match(fname, getfontname(fname)) elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') " Invalid font name. The result should be the name plus the default size. @@ -68,8 +80,9 @@ func Test_getfontname_without_arg() " 'expected' is the value specified by SetUp() above. call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname) elseif has('gui_athena') || has('gui_motif') - " 'expected' is DFLT_FONT of gui_x11.c. - call assert_equal('7x13', fname) + " 'expected' is DFLT_FONT of gui_x11.c or its real name. + let pat = '\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)' + call assert_match(pat, fname) elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') " 'expected' is DEFAULT_FONT of gui_gtk_x11.c. call assert_equal('Monospace 10', fname) @@ -80,6 +93,12 @@ func Test_getfontname_without_arg() endif endfunc +func Test_getwinpos() + call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) + call assert_true(getwinposx() >= 0) + call assert_true(getwinposy() >= 0) +endfunc + func Test_quoteplus() let skipped = '' @@ -125,6 +144,18 @@ func Test_quoteplus() endif endfunc +func Test_set_background() + let background_saved = &background + + set background& + call assert_equal('light', &background) + + set background=dark + call assert_equal('dark', &background) + + let &background = background_saved +endfunc + func Test_set_balloondelay() if !exists('+balloondelay') return @@ -248,6 +279,46 @@ func Test_set_balloonexpr() let &balloonexpr = balloonexpr_saved endfunc +" Invalid arguments are tested with test_options in conjunction with segfaults +" caused by them (Patch 8.0.0357, 24922ec233). +func Test_set_guicursor() + let guicursor_saved = &guicursor + + let default = [ + \ "n-v-c:block-Cursor/lCursor", + \ "ve:ver35-Cursor", + \ "o:hor50-Cursor", + \ "i-ci:ver25-Cursor/lCursor", + \ "r-cr:hor20-Cursor/lCursor", + \ "sm:block-Cursor-blinkwait175-blinkoff150-blinkon175" + \ ] + + " Default Value + set guicursor& + call assert_equal(join(default, ','), &guicursor) + + " Argument List Example 1 + let opt_list = copy(default) + let opt_list[0] = "n-c-v:block-nCursor" + exec "set guicursor=" . join(opt_list, ',') + call assert_equal(join(opt_list, ','), &guicursor) + unlet opt_list + + " Argument List Example 2 + let opt_list = copy(default) + let opt_list[3] = "i-ci:ver30-iCursor-blinkwait300-blinkon200-blinkoff150" + exec "set guicursor=" . join(opt_list, ',') + call assert_equal(join(opt_list, ','), &guicursor) + unlet opt_list + + " 'a' Mode + set guicursor& + let &guicursor .= ',a:blinkon0' + call assert_equal(join(default, ',') . ",a:blinkon0", &guicursor) + + let &guicursor = guicursor_saved +endfunc + func Test_set_guifont() let skipped = '' @@ -274,11 +345,13 @@ func Test_set_guifont() " Non-empty font list with a valid font name. Should pick up the first " valid font. set guifont=-notexist1-*,fixed,-notexist2-* - call assert_equal('fixed', getfontname()) + let pat = '\(fixed\)\|\(\c-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO8859-1\)' + call assert_match(pat, getfontname()) " Empty list. Should fallback to the built-in default. set guifont= - call assert_equal('7x13', getfontname()) + let pat = '\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)' + call assert_match(pat, getfontname()) elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') " For GTK, what we refer to as 'font names' in our manual are actually @@ -477,10 +550,120 @@ func Test_set_guiheadroom() endif endfunc -func Test_getwinpos() - call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) - call assert_true(getwinposx() >= 0) - call assert_true(getwinposy() >= 0) +func Test_set_guioptions() + let guioptions_saved = &guioptions + let duration = '200m' + + if has('win32') + " Default Value + set guioptions& + call assert_equal('egmrLtT', &guioptions) + + else + " Default Value + set guioptions& + call assert_equal('aegimrLtT', &guioptions) + + " To activate scrollbars of type 'L' or 'R'. + wincmd v + redraw! + + " Remove all default GUI ornaments + set guioptions-=T + exec 'sleep' . duration + call assert_equal('aegimrLt', &guioptions) + set guioptions-=t + exec 'sleep' . duration + call assert_equal('aegimrL', &guioptions) + set guioptions-=L + exec 'sleep' . duration + call assert_equal('aegimr', &guioptions) + set guioptions-=r + exec 'sleep' . duration + call assert_equal('aegim', &guioptions) + set guioptions-=m + exec 'sleep' . duration + call assert_equal('aegi', &guioptions) + + " Try non-default GUI ornaments + set guioptions+=l + exec 'sleep' . duration + call assert_equal('aegil', &guioptions) + set guioptions-=l + exec 'sleep' . duration + call assert_equal('aegi', &guioptions) + + set guioptions+=R + exec 'sleep' . duration + call assert_equal('aegiR', &guioptions) + set guioptions-=R + exec 'sleep' . duration + call assert_equal('aegi', &guioptions) + + set guioptions+=b + exec 'sleep' . duration + call assert_equal('aegib', &guioptions) + set guioptions+=h + exec 'sleep' . duration + call assert_equal('aegibh', &guioptions) + set guioptions-=h + exec 'sleep' . duration + call assert_equal('aegib', &guioptions) + set guioptions-=b + exec 'sleep' . duration + call assert_equal('aegi', &guioptions) + + set guioptions+=v + exec 'sleep' . duration + call assert_equal('aegiv', &guioptions) + set guioptions-=v + exec 'sleep' . duration + call assert_equal('aegi', &guioptions) + + if has('gui_motif') + set guioptions+=F + exec 'sleep' . duration + call assert_equal('aegiF', &guioptions) + set guioptions-=F + exec 'sleep' . duration + call assert_equal('aegi', &guioptions) + endif + + " Restore GUI ornaments to the default state. + set guioptions+=m + exec 'sleep' . duration + call assert_equal('aegim', &guioptions) + set guioptions+=r + exec 'sleep' . duration + call assert_equal('aegimr', &guioptions) + set guioptions+=L + exec 'sleep' . duration + call assert_equal('aegimrL', &guioptions) + set guioptions+=t + exec 'sleep' . duration + call assert_equal('aegimrLt', &guioptions) + set guioptions+=T + exec 'sleep' . duration + call assert_equal("aegimrLtT", &guioptions) + + wincmd o + redraw! + endif + + let &guioptions = guioptions_saved +endfunc + +func Test_set_guipty() + let guipty_saved = &guipty + + " Default Value + set guipty& + call assert_equal(1, &guipty) + + set noguipty + call assert_equal(0, &guipty) + + let &guipty = guipty_saved endfunc func Test_shell_command() @@ -490,6 +673,19 @@ func Test_shell_command() bwipe! endfunc +func Test_syntax_colortest() + runtime syntax/colortest.vim + redraw! + sleep 200m + bwipe! +endfunc + +func Test_set_term() + " It's enough to check the current value since setting 'term' to anything + " other than builtin_gui makes no sense at all. + call assert_equal('builtin_gui', &term) +endfunc + func Test_windowid_variable() if g:x11_based_gui || has('win32') call assert_true(v:windowid > 0) diff --git a/src/testdir/test_gui_init.vim b/src/testdir/test_gui_init.vim index 811c6ecb23..21e5bb6a7a 100644 --- a/src/testdir/test_gui_init.vim +++ b/src/testdir/test_gui_init.vim @@ -36,3 +36,25 @@ func Test_set_guiheadroom() throw skipped endif endfunc + +func Test_set_guioptions_for_M() + sleep 200ms + " Check if the 'M' option is included. + call assert_match('.*M.*', &guioptions) +endfunc + +func Test_set_guioptions_for_p() + let skipped = '' + + if !g:x11_based_gui + let skipped = g:not_supported . '''p'' of guioptions' + else + sleep 200ms + " Check if the 'p' option is included. + call assert_match('.*p.*', &guioptions) + endif + + if !empty(skipped) + throw skipped + endif +endfunc diff --git a/src/ui.c b/src/ui.c index 6ffd4be026..1f5a34a868 100644 --- a/src/ui.c +++ b/src/ui.c @@ -458,7 +458,7 @@ clip_update_selection(VimClipboard *clip) /* If visual mode is only due to a redo command ("."), then ignore it */ if (!redo_VIsual_busy && VIsual_active && (State & NORMAL)) { - if (lt(VIsual, curwin->w_cursor)) + if (LT_POS(VIsual, curwin->w_cursor)) { start = VIsual; end = curwin->w_cursor; @@ -472,8 +472,8 @@ clip_update_selection(VimClipboard *clip) start = curwin->w_cursor; end = VIsual; } - if (!equalpos(clip->start, start) - || !equalpos(clip->end, end) + if (!EQUAL_POS(clip->start, start) + || !EQUAL_POS(clip->end, end) || clip->vmode != VIsual_mode) { clip_clear_selection(clip); @@ -3213,7 +3213,7 @@ vcol2col(win_T *wp, linenr_T lnum, int vcol) while (count < vcol && *ptr != NUL) { count += win_lbr_chartabsize(wp, line, ptr, count, NULL); - mb_ptr_adv(ptr); + MB_PTR_ADV(ptr); } return (int)(ptr - line); } diff --git a/src/undo.c b/src/undo.c index a985b0145b..1474bcce05 100644 --- a/src/undo.c +++ b/src/undo.c @@ -833,7 +833,7 @@ u_get_undo_file_name(char_u *buf_ffname, int reading) munged_name = vim_strsave(ffname); if (munged_name == NULL) return NULL; - for (p = munged_name; *p != NUL; mb_ptr_adv(p)) + for (p = munged_name; *p != NUL; MB_PTR_ADV(p)) if (vim_ispathsep(*p)) *p = '%'; } @@ -2784,7 +2784,7 @@ u_undoredo(int undo) curhead->uh_entry = newlist; curhead->uh_flags = new_flags; - if ((old_flags & UH_EMPTYBUF) && bufempty()) + if ((old_flags & UH_EMPTYBUF) && BUFEMPTY()) curbuf->b_ml.ml_flags |= ML_EMPTY; if (old_flags & UH_CHANGED) changed(); @@ -3175,14 +3175,14 @@ u_find_first_changed(void) if (STRCMP(ml_get_buf(curbuf, lnum, FALSE), uep->ue_array[lnum - 1]) != 0) { - clearpos(&(uhp->uh_cursor)); + CLEAR_POS(&(uhp->uh_cursor)); uhp->uh_cursor.lnum = lnum; return; } if (curbuf->b_ml.ml_line_count != uep->ue_size) { /* lines added or deleted at the end, put the cursor there */ - clearpos(&(uhp->uh_cursor)); + CLEAR_POS(&(uhp->uh_cursor)); uhp->uh_cursor.lnum = lnum; } } diff --git a/src/userfunc.c b/src/userfunc.c index 1bf028fa42..07cc47f7c6 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2104,7 +2104,7 @@ ex_function(exarg_T *eap) else { /* skip ':' and blanks*/ - for (p = theline; vim_iswhite(*p) || *p == ':'; ++p) + for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p) ; /* Check for "endfunction". */ diff --git a/src/version.c b/src/version.c index d3a72a086f..d4809fd0a2 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,26 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 454, +/**/ + 453, +/**/ + 452, +/**/ + 451, +/**/ + 450, +/**/ + 449, +/**/ + 448, +/**/ + 447, +/**/ + 446, +/**/ + 446, /**/ 445, /**/ @@ -2104,7 +2124,7 @@ static void do_intro_line(int row, char_u *mesg, int add_version, int attr); void maybe_intro_message(void) { - if (bufempty() + if (BUFEMPTY() && curbuf->b_fname == NULL #ifdef FEAT_WINDOWS && firstwin->w_next == NULL diff --git a/src/vim.h b/src/vim.h index c5fe10937c..5dd6fdc486 100644 --- a/src/vim.h +++ b/src/vim.h @@ -590,7 +590,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring); #ifdef FEAT_GETTEXT # ifdef DYNAMIC_GETTEXT # define _(x) (*dyn_libintl_gettext)((char *)(x)) -# define ngettext(x, xs, n) (*dyn_libintl_ngettext)((char *)(x), (char *)(xs), (n)) +# define NGETTEXT(x, xs, n) (*dyn_libintl_ngettext)((char *)(x), (char *)(xs), (n)) # define N_(x) x # define bindtextdomain(domain, dir) (*dyn_libintl_bindtextdomain)((domain), (dir)) # define bind_textdomain_codeset(domain, codeset) (*dyn_libintl_bind_textdomain_codeset)((domain), (codeset)) @@ -603,6 +603,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring); # else # include # define _(x) gettext((char *)(x)) +# define NGETTEXT(x, xs, n) ngettext((x), (xs), (n)) # ifdef gettext_noop # define N_(x) gettext_noop(x) # else @@ -611,7 +612,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring); # endif #else # define _(x) ((char *)(x)) -# define ngettext(x, xs, n) (((n) == 1) ? (char *)(x) : (char *)(xs)) +# define NGETTEXT(x, xs, n) (((n) == 1) ? (char *)(x) : (char *)(xs)) # define N_(x) x # ifdef bindtextdomain # undef bindtextdomain @@ -1766,12 +1767,6 @@ void *vim_memset(void *, int, size_t); #define hl_attr(n) highlight_attr[(int)(n)] #define term_str(n) term_strings[(int)(n)] -/* - * vim_iswhite() is used for "^" and the like. It differs from isspace() - * because it doesn't include and and the like. - */ -#define vim_iswhite(x) ((x) == ' ' || (x) == '\t') - /* * EXTERN is only defined in main.c. That's where global variables are * actually defined and initialized. diff --git a/src/window.c b/src/window.c index f71a002939..eb7673e204 100644 --- a/src/window.c +++ b/src/window.c @@ -6140,7 +6140,7 @@ file_name_in_line( */ ptr = line + col; while (*ptr != NUL && !vim_isfilec(*ptr)) - mb_ptr_adv(ptr); + MB_PTR_ADV(ptr); if (*ptr == NUL) /* nothing found */ { if (options & FNAME_MESS) diff --git a/src/workshop.c b/src/workshop.c index 0b9774fa5b..844da854a2 100644 --- a/src/workshop.c +++ b/src/workshop.c @@ -1087,7 +1087,7 @@ workshop_get_positions( *curCol = curwin->w_cursor.col; if (curbuf->b_visual.vi_mode == 'v' && - equalpos(curwin->w_cursor, curbuf->b_visual.vi_end)) + EQUAL_POS(curwin->w_cursor, curbuf->b_visual.vi_end)) { *selStartLine = curbuf->b_visual.vi_start.lnum; *selStartCol = curbuf->b_visual.vi_start.col;