From 9c46efd7dc57c1a8eae5137d05c7e67c4f82c3d7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 4 Feb 2019 20:30:18 +0100 Subject: [PATCH 01/75] patch 8.1.0874: using old style comments in new file Problem: Using old style comments in new file. Solution: Convert to // comments in new file. (Yegappan Lakshmanan) --- src/indent.c | 1809 ++++++++++++++++++++++--------------------------- src/version.c | 2 + 2 files changed, 795 insertions(+), 1016 deletions(-) diff --git a/src/indent.c b/src/indent.c index af401ee7ad..1ffa766954 100644 --- a/src/indent.c +++ b/src/indent.c @@ -59,13 +59,13 @@ static pos_T *find_start_rawstring(int ind_maxcomment); * Return NULL when not inside a comment. */ static pos_T * -ind_find_start_comment(void) /* XXX */ +ind_find_start_comment(void) // XXX { return find_start_comment(curbuf->b_ind_maxcomment); } pos_T * -find_start_comment(int ind_maxcomment) /* XXX */ +find_start_comment(int ind_maxcomment) // XXX { pos_T *pos; char_u *line; @@ -78,10 +78,8 @@ find_start_comment(int ind_maxcomment) /* XXX */ if (pos == NULL) break; - /* - * Check if the comment start we found is inside a string. - * If it is then restrict the search to below this line and try again. - */ + // Check if the comment start we found is inside a string. + // If it is then restrict the search to below this line and try again. line = ml_get(pos->lnum); for (p = line; *p && (colnr_T)(p - line) < pos->col; ++p) p = skip_string(p); @@ -106,7 +104,7 @@ find_start_comment(int ind_maxcomment) /* XXX */ * "CORS" -> Comment Or Raw String */ static pos_T * -ind_find_start_CORS(linenr_T *is_raw) /* XXX */ +ind_find_start_CORS(linenr_T *is_raw) // XXX { static pos_T comment_pos_copy; pos_T *comment_pos; @@ -115,15 +113,15 @@ ind_find_start_CORS(linenr_T *is_raw) /* XXX */ comment_pos = find_start_comment(curbuf->b_ind_maxcomment); if (comment_pos != NULL) { - /* Need to make a copy of the static pos in findmatchlimit(), - * calling find_start_rawstring() may change it. */ + // Need to make a copy of the static pos in findmatchlimit(), + // calling find_start_rawstring() may change it. comment_pos_copy = *comment_pos; comment_pos = &comment_pos_copy; } rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment); - /* 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 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_POS(*rs_pos, *comment_pos))) { @@ -140,7 +138,7 @@ ind_find_start_CORS(linenr_T *is_raw) /* XXX */ * Return NULL when not inside a raw string. */ static pos_T * -find_start_rawstring(int ind_maxcomment) /* XXX */ +find_start_rawstring(int ind_maxcomment) // XXX { pos_T *pos; char_u *line; @@ -153,10 +151,8 @@ find_start_rawstring(int ind_maxcomment) /* XXX */ if (pos == NULL) break; - /* - * Check if the raw string start we found is inside a string. - * If it is then restrict the search to below this line and try again. - */ + // Check if the raw string start we found is inside a string. + // If it is then restrict the search to below this line and try again. line = ml_get(pos->lnum); for (p = line; *p && (colnr_T)(p - line) < pos->col; ++p) p = skip_string(p); @@ -181,43 +177,41 @@ skip_string(char_u *p) { int i; - /* - * We loop, because strings may be concatenated: "date""time". - */ + // We loop, because strings may be concatenated: "date""time". for ( ; ; ++p) { - if (p[0] == '\'') /* 'c' or '\n' or '\000' */ + if (p[0] == '\'') // 'c' or '\n' or '\000' { - if (!p[1]) /* ' at end of line */ + if (!p[1]) // ' at end of line break; i = 2; - if (p[1] == '\\') /* '\n' or '\000' */ + if (p[1] == '\\') // '\n' or '\000' { ++i; - while (vim_isdigit(p[i - 1])) /* '\000' */ + while (vim_isdigit(p[i - 1])) // '\000' ++i; } - if (p[i] == '\'') /* check for trailing ' */ + if (p[i] == '\'') // check for trailing ' { p += i; continue; } } - else if (p[0] == '"') /* start of string */ + else if (p[0] == '"') // start of string { for (++p; p[0]; ++p) { if (p[0] == '\\' && p[1] != NUL) ++p; - else if (p[0] == '"') /* end of string */ + else if (p[0] == '"') // end of string break; } if (p[0] == '"') - continue; /* continue for another string */ + continue; // continue for another string } else if (p[0] == 'R' && p[1] == '"') { - /* Raw string: R"[delim](...)[delim]" */ + // Raw string: R"[delim](...)[delim]" char_u *delim = p + 2; char_u *paren = vim_strchr(delim, '('); @@ -233,16 +227,16 @@ skip_string(char_u *p) break; } if (p[0] == '"') - continue; /* continue for another string */ + continue; // continue for another string } } - break; /* no string found */ + break; // no string found } if (!*p) - --p; /* backup from NUL */ + --p; // backup from NUL return p; } -#endif /* FEAT_CINDENT || FEAT_SYN_HL */ +#endif // FEAT_CINDENT || FEAT_SYN_HL #if defined(FEAT_CINDENT) || defined(PROTO) @@ -259,7 +253,7 @@ cindent_on(void) )); } -/* Find result cache for cpp_baseclass */ +// Find result cache for cpp_baseclass typedef struct { int found; lpos_T lpos; @@ -299,8 +293,8 @@ cin_skipcomment(char_u *s) s = skipwhite(s); - /* Perl/shell # comment comment continues until eol. Require a space - * before # to avoid recognizing $#array. */ + // Perl/shell # comment comment continues until eol. Require a space + // before # to avoid recognizing $#array. if (curbuf->b_ind_hash_comment != 0 && s != prev_s && *s == '#') { s += STRLEN(s); @@ -309,14 +303,14 @@ cin_skipcomment(char_u *s) if (*s != '/') break; ++s; - if (*s == '/') /* slash-slash comment continues till eol */ + if (*s == '/') // slash-slash comment continues till eol { s += STRLEN(s); break; } if (*s != '*') break; - for (++s; *s; ++s) /* skip slash-star comment */ + for (++s; *s; ++s) // skip slash-star comment if (s[0] == '*' && s[1] == '/') { s += 2; @@ -340,7 +334,7 @@ cin_nocode(char_u *s) * Check previous lines for a "//" line comment, skipping over blank lines. */ static pos_T * -find_line_comment(void) /* XXX */ +find_line_comment(void) // XXX { static pos_T pos; char_u *line; @@ -373,11 +367,11 @@ cin_has_js_key(char_u *text) if (*s == '\'' || *s == '"') { - /* can be 'key': or "key": */ + // can be 'key': or "key": quote = *s; ++s; } - if (!vim_isIDc(*s)) /* need at least one ID character */ + if (!vim_isIDc(*s)) // need at least one ID character return FALSE; while (vim_isIDc(*s)) @@ -387,7 +381,7 @@ cin_has_js_key(char_u *text) s = cin_skipcomment(s); - /* "::" is not a label, it's C++ */ + // "::" is not a label, it's C++ return (*s == ':' && s[1] != ':'); } @@ -398,7 +392,7 @@ cin_has_js_key(char_u *text) static int cin_islabel_skip(char_u **s) { - if (!vim_isIDc(**s)) /* need at least one ID character */ + if (!vim_isIDc(**s)) // need at least one ID character return FALSE; while (vim_isIDc(**s)) @@ -406,7 +400,7 @@ cin_islabel_skip(char_u **s) *s = cin_skipcomment(*s); - /* "::" is not a label, it's C++ */ + // "::" is not a label, it's C++ return (**s == ':' && *++*s != ':'); } @@ -415,16 +409,14 @@ cin_islabel_skip(char_u **s) * Note: curwin->w_cursor must be where we are looking for the label. */ int -cin_islabel(void) /* XXX */ +cin_islabel(void) // XXX { char_u *s; s = cin_skipcomment(ml_get_curline()); - /* - * Exclude "default" from labels, since it should be indented - * like a switch label. Same for C++ scope declarations. - */ + // Exclude "default" from labels, since it should be indented + // like a switch label. Same for C++ scope declarations. if (cin_isdefault(s)) return FALSE; if (cin_isscopedecl(s)) @@ -432,10 +424,8 @@ cin_islabel(void) /* XXX */ if (cin_islabel_skip(&s)) { - /* - * Only accept a label if the previous line is terminated or is a case - * label. - */ + // Only accept a label if the previous line is terminated or is a case + // label. pos_T cursor_save; pos_T *trypos; char_u *line; @@ -445,16 +435,14 @@ cin_islabel(void) /* XXX */ { --curwin->w_cursor.lnum; - /* - * If we're in a comment or raw string now, skip to the start of - * it. - */ + // If we're in a comment or raw string now, skip to the start of + // it. curwin->w_cursor.col = 0; - if ((trypos = ind_find_start_CORS(NULL)) != NULL) /* XXX */ + if ((trypos = ind_find_start_CORS(NULL)) != NULL) // XXX curwin->w_cursor = *trypos; line = ml_get_curline(); - if (cin_ispreproc(line)) /* ignore #defines, #if, etc. */ + if (cin_ispreproc(line)) // ignore #defines, #if, etc. continue; if (*(line = cin_skipcomment(line)) == NUL) continue; @@ -468,7 +456,7 @@ cin_islabel(void) /* XXX */ return FALSE; } curwin->w_cursor = cursor_save; - return TRUE; /* label at start of file??? */ + return TRUE; // label at start of file??? } return FALSE; } @@ -522,7 +510,7 @@ cin_isinit(void) int cin_iscase( char_u *s, - int strict) /* Allow relaxed check of case statement for JS */ + int strict) // Allow relaxed check of case statement for JS { s = cin_skipcomment(s); if (cin_starts_with(s, "case")) @@ -532,20 +520,20 @@ cin_iscase( s = cin_skipcomment(s); if (*s == ':') { - if (s[1] == ':') /* skip over "::" for C++ */ + if (s[1] == ':') // skip over "::" for C++ ++s; else return TRUE; } if (*s == '\'' && s[1] && s[2] == '\'') - s += 2; /* skip over ':' */ + s += 2; // skip over ':' else if (*s == '/' && (s[1] == '*' || s[1] == '/')) - return FALSE; /* stop at comment */ + return FALSE; // stop at comment else if (*s == '"') { - /* JS etc. */ + // JS etc. if (strict) - return FALSE; /* stop at string */ + return FALSE; // stop at string else return TRUE; } @@ -589,7 +577,7 @@ cin_isscopedecl(char_u *s) return (*(s = cin_skipcomment(s + i)) == ':' && s[1] != ':'); } -/* Maximum number of lines to search back for a "namespace" line. */ +// Maximum number of lines to search back for a "namespace" line. #define FIND_NAMESPACE_LIM 20 /* @@ -610,7 +598,7 @@ cin_is_cpp_namespace(char_u *s) { if (VIM_ISWHITE(*p)) { - has_name = TRUE; /* found end of a name */ + has_name = TRUE; // found end of a name p = cin_skipcomment(skipwhite(p)); } else if (*p == '{') @@ -621,14 +609,14 @@ cin_is_cpp_namespace(char_u *s) { has_name_start = TRUE; if (has_name) - return FALSE; /* word character after skipping past name */ + return FALSE; // word character after skipping past name ++p; } else if (p[0] == ':' && p[1] == ':' && vim_iswordc(p[2])) { if (!has_name_start || has_name) return FALSE; - /* C++ 17 nested namespace */ + // C++ 17 nested namespace p += 3; } else @@ -702,13 +690,13 @@ after_label(char_u *l) { if (*l == ':') { - if (l[1] == ':') /* skip over "::" for C++ */ + if (l[1] == ':') // skip over "::" for C++ ++l; else if (!cin_iscase(l + 1, FALSE)) break; } else if (*l == '\'' && l[1] && l[2] == '\'') - l += 2; /* skip over 'x' */ + l += 2; // skip over 'x' } if (*l == NUL) return NULL; @@ -723,7 +711,7 @@ after_label(char_u *l) * Return 0 if there is nothing after the label. */ static int -get_indent_nolabel (linenr_T lnum) /* XXX */ +get_indent_nolabel (linenr_T lnum) // XXX { char_u *l; pos_T fp; @@ -757,12 +745,12 @@ skip_label(linenr_T lnum, char_u **pp) cursor_save = curwin->w_cursor; curwin->w_cursor.lnum = lnum; l = ml_get_curline(); - /* XXX */ + // XXX if (cin_iscase(l, FALSE) || cin_isscopedecl(l) || cin_islabel()) { amount = get_indent_nolabel(lnum); l = after_label(ml_get_curline()); - if (l == NULL) /* just in case */ + if (l == NULL) // just in case l = ml_get_curline(); } else @@ -852,7 +840,7 @@ cin_get_equal_amount(linenr_T lnum) line = s = ml_get(lnum); while (*s != NUL && vim_strchr((char_u *)"=;{}\"'", *s) == NULL) { - if (cin_iscomment(s)) /* ignore comments */ + if (cin_iscomment(s)) // ignore comments s = cin_skipcomment(s); else ++s; @@ -864,7 +852,7 @@ cin_get_equal_amount(linenr_T lnum) if (cin_nocode(s)) return 0; - if (*s == '"') /* nice alignment for continued strings */ + if (*s == '"') // nice alignment for continued strings ++s; fp.lnum = lnum; @@ -953,8 +941,8 @@ cin_islinecomment(char_u *p) static int cin_isterminated( char_u *s, - int incl_open, /* include '{' at the end as terminator */ - int incl_comma) /* recognize a trailing comma */ + int incl_open, // include '{' at the end as terminator + int incl_comma) // recognize a trailing comma { char_u found_start = 0; unsigned n_open = 0; @@ -970,7 +958,7 @@ cin_isterminated( while (*s) { - /* skip over comments, "" strings and 'c'haracters */ + // skip over comments, "" strings and 'c'haracters s = skip_string(cin_skipcomment(s)); if (*s == '}' && n_open > 0) --n_open; @@ -1035,38 +1023,38 @@ cin_isfuncdecl( } curwin->w_cursor.lnum = save_lnum; - /* Ignore line starting with #. */ + // Ignore line starting with #. if (cin_ispreproc(s)) return FALSE; while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"') { - if (cin_iscomment(s)) /* ignore comments */ + if (cin_iscomment(s)) // ignore comments s = cin_skipcomment(s); else if (*s == ':') { if (*(s + 1) == ':') s += 2; else - /* To avoid a mistake in the following situation: - * A::A(int a, int b) - * : a(0) // <--not a function decl - * , b(0) - * {... - */ + // To avoid a mistake in the following situation: + // A::A(int a, int b) + // : a(0) // <--not a function decl + // , b(0) + // {... return FALSE; } else ++s; } if (*s != '(') - return FALSE; /* ';', ' or " before any () or no '(' */ + return FALSE; // ';', ' or " before any () or no '(' while (*s && *s != ';' && *s != '\'' && *s != '"') { if (*s == ')' && cin_nocode(s + 1)) { - /* ')' at the end: may have found a match + /* + * ')' at the end: may have found a match * Check for he previous line not to end in a backslash: * #if defined(x) && \ * defined(y) @@ -1081,10 +1069,10 @@ cin_isfuncdecl( { int comma = (*s == ','); - /* ',' at the end: continue looking in the next line. - * At the end: check for ',' in the next line, for this style: - * func(arg1 - * , arg2) */ + // ',' at the end: continue looking in the next line. + // At the end: check for ',' in the next line, for this style: + // func(arg1 + // , arg2) for (;;) { if (lnum >= curbuf->b_ml.ml_line_count) @@ -1095,14 +1083,14 @@ cin_isfuncdecl( } if (lnum >= curbuf->b_ml.ml_line_count) break; - /* Require a comma at end of the line or a comma or ')' at the - * start of next line. */ + // Require a comma at end of the line or a comma or ')' at the + // start of next line. s = skipwhite(s); if (!just_started && (!comma && *s != ',' && *s != ')')) break; just_started = FALSE; } - else if (cin_iscomment(s)) /* ignore comments */ + else if (cin_iscomment(s)) // ignore comments s = cin_skipcomment(s); else { @@ -1128,7 +1116,7 @@ cin_isif(char_u *p) cin_iselse( char_u *p) { - if (*p == '}') /* accept "} else" */ + if (*p == '}') // accept "} else" p = cin_skipcomment(p + 1); return (STRNCMP(p, "else", 4) == 0 && !vim_isIDc(p[4])); } @@ -1145,14 +1133,14 @@ cin_isdo(char_u *p) * ')' and ';'. The condition may be spread over several lines. */ static int -cin_iswhileofdo (char_u *p, linenr_T lnum) /* XXX */ +cin_iswhileofdo (char_u *p, linenr_T lnum) // XXX { pos_T cursor_save; pos_T *trypos; int retval = FALSE; p = cin_skipcomment(p); - if (*p == '}') /* accept "} while (cond);" */ + if (*p == '}') // accept "} while (cond);" p = cin_skipcomment(p + 1); if (cin_starts_with(p, "while")) { @@ -1160,7 +1148,7 @@ cin_iswhileofdo (char_u *p, linenr_T lnum) /* XXX */ curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; p = ml_get_curline(); - while (*p && *p != 'w') /* skip any '}', until the 'w' of the "while" */ + while (*p && *p != 'w') // skip any '}', until the 'w' of the "while" { ++p; ++curwin->w_cursor.col; @@ -1235,7 +1223,7 @@ cin_iswhileofdo_end(int terminated) pos_T *trypos; int i; - if (terminated != ';') /* there must be a ';' at the end */ + if (terminated != ';') // there must be a ';' at the end return FALSE; p = line = ml_get_curline(); @@ -1247,15 +1235,15 @@ cin_iswhileofdo_end(int terminated) s = skipwhite(p + 1); if (*s == ';' && cin_nocode(s + 1)) { - /* Found ");" at end of the line, now check there is "while" - * before the matching '('. XXX */ + // Found ");" at end of the line, now check there is "while" + // before the matching '('. XXX i = (int)(p - line); curwin->w_cursor.col = i; trypos = find_match_paren(curbuf->b_ind_maxparen); if (trypos != NULL) { s = cin_skipcomment(ml_get(trypos->lnum)); - if (*s == '}') /* accept "} while (cond);" */ + if (*s == '}') // accept "} while (cond);" s = cin_skipcomment(s + 1); if (cin_starts_with(s, "while")) { @@ -1264,7 +1252,7 @@ cin_iswhileofdo_end(int terminated) } } - /* Searching may have made "line" invalid, get it again. */ + // Searching may have made "line" invalid, get it again. line = ml_get_curline(); p = line + i; } @@ -1296,21 +1284,21 @@ cin_isbreak(char_u *p) */ static int cin_is_cpp_baseclass( - cpp_baseclass_cache_T *cached) /* input and output */ + cpp_baseclass_cache_T *cached) // input and output { - lpos_T *pos = &cached->lpos; /* find position */ + lpos_T *pos = &cached->lpos; // find position char_u *s; int class_or_struct, lookfor_ctor_init, cpp_base_class; linenr_T lnum = curwin->w_cursor.lnum; char_u *line = ml_get_curline(); if (pos->lnum <= lnum) - return cached->found; /* Use the cached result */ + return cached->found; // Use the cached result pos->col = 0; s = skipwhite(line); - if (*s == '#') /* skip #define FOO x ? (x) : x */ + if (*s == '#') // skip #define FOO x ? (x) : x return FALSE; s = cin_skipcomment(s); if (*s == NUL) @@ -1318,19 +1306,18 @@ cin_is_cpp_baseclass( cpp_base_class = lookfor_ctor_init = class_or_struct = FALSE; - /* Search for a line starting with '#', empty, ending in ';' or containing - * '{' or '}' and start below it. This handles the following situations: - * a = cond ? - * func() : - * asdf; - * func::foo() - * : something - * {} - * Foo::Foo (int one, int two) - * : something(4), - * somethingelse(3) - * {} - */ + // Search for a line starting with '#', empty, ending in ';' or containing + // '{' or '}' and start below it. This handles the following situations: + // a = cond ? + // func() : + // asdf; + // func::foo() + // : something + // {} + // Foo::Foo (int one, int two) + // : something(4), + // somethingelse(3) + // {} while (lnum > 1) { line = ml_get(lnum - 1); @@ -1360,13 +1347,13 @@ cin_is_cpp_baseclass( { if (lnum == curwin->w_cursor.lnum) break; - /* Continue in the cursor line. */ + // Continue in the cursor line. line = ml_get(++lnum); s = line; } if (s == line) { - /* don't recognize "case (foo):" as a baseclass */ + // don't recognize "case (foo):" as a baseclass if (cin_iscase(s, FALSE)) break; s = cin_skipcomment(line); @@ -1380,15 +1367,15 @@ cin_is_cpp_baseclass( { if (s[1] == ':') { - /* skip double colon. It can't be a constructor - * initialization any more */ + // skip double colon. It can't be a constructor + // initialization any more lookfor_ctor_init = FALSE; s = cin_skipcomment(s + 2); } else if (lookfor_ctor_init || class_or_struct) { - /* we have something found, that looks like the start of - * cpp-base-class-declaration or constructor-initialization */ + // we have something found, that looks like the start of + // cpp-base-class-declaration or constructor-initialization cpp_base_class = TRUE; lookfor_ctor_init = class_or_struct = FALSE; pos->col = 0; @@ -1416,33 +1403,33 @@ cin_is_cpp_baseclass( } else if (s[0] == ')') { - /* Constructor-initialization is assumed if we come across - * something like "):" */ + // Constructor-initialization is assumed if we come across + // something like "):" class_or_struct = FALSE; lookfor_ctor_init = TRUE; } else if (s[0] == '?') { - /* Avoid seeing '() :' after '?' as constructor init. */ + // Avoid seeing '() :' after '?' as constructor init. return FALSE; } else if (!vim_isIDc(s[0])) { - /* if it is not an identifier, we are wrong */ + // if it is not an identifier, we are wrong class_or_struct = FALSE; lookfor_ctor_init = FALSE; } else if (pos->col == 0) { - /* it can't be a constructor-initialization any more */ + // it can't be a constructor-initialization any more lookfor_ctor_init = FALSE; - /* the first statement starts here: lineup with this one... */ + // the first statement starts here: lineup with this one... if (cpp_base_class) pos->col = (colnr_T)(s - line); } - /* When the line ends in a comma don't align with it. */ + // When the line ends in a comma don't align with it. if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode(s + 1)) pos->col = 0; @@ -1468,7 +1455,7 @@ get_baseclass_amount(int col) amount = get_indent(); if (find_last_paren(ml_get_curline(), '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) - amount = get_indent_lnum(trypos->lnum); /* XXX */ + amount = get_indent_lnum(trypos->lnum); // XXX if (!cin_ends_in(ml_get_curline(), (char_u *)",", NULL)) amount += curbuf->b_ind_cpp_baseclass; } @@ -1555,13 +1542,14 @@ cin_skip2pos(pos_T *trypos) * Find the '{' at the start of the block we are in. * Return NULL if no match found. * Ignore a '{' that is in a comment, makes indenting the next three lines - * work. */ + * work. + */ /* foo() */ /* { */ /* } */ static pos_T * -find_start_brace(void) /* XXX */ +find_start_brace(void) // XXX { pos_T cursor_save; pos_T *trypos; @@ -1571,13 +1559,13 @@ find_start_brace(void) /* XXX */ cursor_save = curwin->w_cursor; while ((trypos = findmatchlimit(NULL, '{', FM_BLOCKSTOP, 0)) != NULL) { - pos_copy = *trypos; /* copy pos_T, next findmatch will change it */ + pos_copy = *trypos; // copy pos_T, next findmatch will change it trypos = &pos_copy; curwin->w_cursor = *trypos; pos = NULL; - /* ignore the { if it's in a // or / * * / comment */ + // ignore the { if it's in a // or / * * / comment if ((colnr_T)cin_skip2pos(trypos) == trypos->col - && (pos = ind_find_start_CORS(NULL)) == NULL) /* XXX */ + && (pos = ind_find_start_CORS(NULL)) == NULL) // XXX break; if (pos != NULL) curwin->w_cursor.lnum = pos->lnum; @@ -1591,13 +1579,13 @@ find_start_brace(void) /* XXX */ * Return NULL if no match found. */ static pos_T * -find_match_paren(int ind_maxparen) /* XXX */ +find_match_paren(int ind_maxparen) // XXX { return find_match_char('(', ind_maxparen); } static pos_T * -find_match_char(int c, int ind_maxparen) /* XXX */ +find_match_char(int c, int ind_maxparen) // XXX { pos_T cursor_save; pos_T *trypos; @@ -1609,14 +1597,14 @@ find_match_char(int c, int ind_maxparen) /* XXX */ retry: if ((trypos = findmatchlimit(NULL, c, 0, ind_maxp_wk)) != NULL) { - /* check if the ( is in a // comment */ + // check if the ( is in a // comment if ((colnr_T)cin_skip2pos(trypos) > trypos->col) { ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos->lnum); if (ind_maxp_wk > 0) { curwin->w_cursor = *trypos; - curwin->w_cursor.col = 0; /* XXX */ + curwin->w_cursor.col = 0; // XXX goto retry; } trypos = NULL; @@ -1625,10 +1613,10 @@ retry: { pos_T *trypos_wk; - pos_copy = *trypos; /* copy trypos, findmatch will change it */ + pos_copy = *trypos; // copy trypos, findmatch will change it trypos = &pos_copy; curwin->w_cursor = *trypos; - if ((trypos_wk = ind_find_start_CORS(NULL)) != NULL) /* XXX */ + if ((trypos_wk = ind_find_start_CORS(NULL)) != NULL) // XXX { ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos_wk->lnum); @@ -1651,7 +1639,7 @@ retry: * Return NULL if no match found. */ static pos_T * -find_match_paren_after_brace (int ind_maxparen) /* XXX */ +find_match_paren_after_brace (int ind_maxparen) // XXX { pos_T *trypos = find_match_paren(ind_maxparen); @@ -1659,8 +1647,8 @@ find_match_paren_after_brace (int ind_maxparen) /* XXX */ { pos_T *tryposBrace = find_start_brace(); - /* If both an unmatched '(' and '{' is found. Ignore the '(' - * position if the '{' is further down. */ + // If both an unmatched '(' and '{' is found. Ignore the '(' + // position if the '{' is further down. if (tryposBrace != NULL && (trypos->lnum != tryposBrace->lnum ? trypos->lnum < tryposBrace->lnum @@ -1697,12 +1685,12 @@ find_last_paren(char_u *l, int start, int end) int retval = FALSE; int open_count = 0; - curwin->w_cursor.col = 0; /* default is start of line */ + curwin->w_cursor.col = 0; // default is start of line for (i = 0; l[i] != NUL; i++) { - i = (int)(cin_skipcomment(l + i) - l); /* ignore parens in comments */ - i = (int)(skip_string(l + i) - l); /* ignore parens in quotes */ + i = (int)(cin_skipcomment(l + i) - l); // ignore parens in comments + i = (int)(skip_string(l + i) - l); // ignore parens in quotes if (l[i] == start) ++open_count; else if (l[i] == end) @@ -1734,134 +1722,133 @@ parse_cino(buf_T *buf) int fraction = 0; int sw = (int)get_sw_value(buf); - /* - * Set the default values. - */ - /* Spaces from a block's opening brace the prevailing indent for that - * block should be. */ + // Set the default values. + + // Spaces from a block's opening brace the prevailing indent for that + // block should be. buf->b_ind_level = sw; - /* Spaces from the edge of the line an open brace that's at the end of a - * line is imagined to be. */ + // Spaces from the edge of the line an open brace that's at the end of a + // line is imagined to be. buf->b_ind_open_imag = 0; - /* Spaces from the prevailing indent for a line that is not preceded by - * an opening brace. */ + // Spaces from the prevailing indent for a line that is not preceded by + // an opening brace. buf->b_ind_no_brace = 0; - /* Column where the first { of a function should be located }. */ + // Column where the first { of a function should be located }. buf->b_ind_first_open = 0; - /* Spaces from the prevailing indent a leftmost open brace should be - * located. */ + // Spaces from the prevailing indent a leftmost open brace should be + // located. buf->b_ind_open_extra = 0; - /* Spaces from the matching open brace (real location for one at the left - * edge; imaginary location from one that ends a line) the matching close - * brace should be located. */ + // Spaces from the matching open brace (real location for one at the left + // edge; imaginary location from one that ends a line) the matching close + // brace should be located. buf->b_ind_close_extra = 0; - /* Spaces from the edge of the line an open brace sitting in the leftmost - * column is imagined to be. */ + // Spaces from the edge of the line an open brace sitting in the leftmost + // column is imagined to be. buf->b_ind_open_left_imag = 0; - /* Spaces jump labels should be shifted to the left if N is non-negative, - * otherwise the jump label will be put to column 1. */ + // Spaces jump labels should be shifted to the left if N is non-negative, + // otherwise the jump label will be put to column 1. buf->b_ind_jump_label = -1; - /* Spaces from the switch() indent a "case xx" label should be located. */ + // Spaces from the switch() indent a "case xx" label should be located. buf->b_ind_case = sw; - /* Spaces from the "case xx:" code after a switch() should be located. */ + // Spaces from the "case xx:" code after a switch() should be located. buf->b_ind_case_code = sw; - /* Lineup break at end of case in switch() with case label. */ + // Lineup break at end of case in switch() with case label. buf->b_ind_case_break = 0; - /* Spaces from the class declaration indent a scope declaration label - * should be located. */ + // Spaces from the class declaration indent a scope declaration label + // should be located. buf->b_ind_scopedecl = sw; - /* Spaces from the scope declaration label code should be located. */ + // Spaces from the scope declaration label code should be located. buf->b_ind_scopedecl_code = sw; - /* Amount K&R-style parameters should be indented. */ + // Amount K&R-style parameters should be indented. buf->b_ind_param = sw; - /* Amount a function type spec should be indented. */ + // Amount a function type spec should be indented. buf->b_ind_func_type = sw; - /* Amount a cpp base class declaration or constructor initialization - * should be indented. */ + // Amount a cpp base class declaration or constructor initialization + // should be indented. buf->b_ind_cpp_baseclass = sw; - /* additional spaces beyond the prevailing indent a continuation line - * should be located. */ + // additional spaces beyond the prevailing indent a continuation line + // should be located. buf->b_ind_continuation = sw; - /* Spaces from the indent of the line with an unclosed parentheses. */ + // Spaces from the indent of the line with an unclosed parentheses. buf->b_ind_unclosed = sw * 2; - /* Spaces from the indent of the line with an unclosed parentheses, which - * itself is also unclosed. */ + // Spaces from the indent of the line with an unclosed parentheses, which + // itself is also unclosed. buf->b_ind_unclosed2 = sw; - /* Suppress ignoring spaces from the indent of a line starting with an - * unclosed parentheses. */ + // Suppress ignoring spaces from the indent of a line starting with an + // unclosed parentheses. buf->b_ind_unclosed_noignore = 0; - /* If the opening paren is the last nonwhite character on the line, and - * b_ind_unclosed_wrapped is nonzero, use this indent relative to the outer - * context (for very long lines). */ + // If the opening paren is the last nonwhite character on the line, and + // b_ind_unclosed_wrapped is nonzero, use this indent relative to the outer + // context (for very long lines). buf->b_ind_unclosed_wrapped = 0; - /* Suppress ignoring white space when lining up with the character after - * an unclosed parentheses. */ + // Suppress ignoring white space when lining up with the character after + // an unclosed parentheses. buf->b_ind_unclosed_whiteok = 0; - /* Indent a closing parentheses under the line start of the matching - * opening parentheses. */ + // Indent a closing parentheses under the line start of the matching + // opening parentheses. buf->b_ind_matching_paren = 0; - /* Indent a closing parentheses under the previous line. */ + // Indent a closing parentheses under the previous line. buf->b_ind_paren_prev = 0; - /* Extra indent for comments. */ + // Extra indent for comments. buf->b_ind_comment = 0; - /* Spaces from the comment opener when there is nothing after it. */ + // Spaces from the comment opener when there is nothing after it. buf->b_ind_in_comment = 3; - /* Boolean: if non-zero, use b_ind_in_comment even if there is something - * after the comment opener. */ + // Boolean: if non-zero, use b_ind_in_comment even if there is something + // after the comment opener. buf->b_ind_in_comment2 = 0; - /* Max lines to search for an open paren. */ + // Max lines to search for an open paren. buf->b_ind_maxparen = 20; - /* Max lines to search for an open comment. */ + // Max lines to search for an open comment. buf->b_ind_maxcomment = 70; - /* Handle braces for java code. */ + // Handle braces for java code. buf->b_ind_java = 0; - /* Not to confuse JS object properties with labels. */ + // Not to confuse JS object properties with labels. buf->b_ind_js = 0; - /* Handle blocked cases correctly. */ + // Handle blocked cases correctly. buf->b_ind_keep_case_label = 0; - /* Handle C++ namespace. */ + // Handle C++ namespace. buf->b_ind_cpp_namespace = 0; - /* Handle continuation lines containing conditions of if(), for() and - * while(). */ + // Handle continuation lines containing conditions of if(), for() and + // while(). buf->b_ind_if_for_while = 0; - /* indentation for # comments */ + // indentation for # comments buf->b_ind_hash_comment = 0; - /* Handle C++ extern "C" or "C++" */ + // Handle C++ extern "C" or "C++" buf->b_ind_cpp_extern_c = 0; for (p = buf->b_p_cino; *p; ) @@ -1869,10 +1856,10 @@ parse_cino(buf_T *buf) l = p++; if (*p == '-') ++p; - digits = p; /* remember where the digits start */ + digits = p; // remember where the digits start n = getdigits(&p); divider = 0; - if (*p == '.') /* ".5s" means a fraction */ + if (*p == '.') // ".5s" means a fraction { fraction = atol((char *)++p); while (VIM_ISDIGIT(*p)) @@ -1884,10 +1871,10 @@ parse_cino(buf_T *buf) divider = 10; } } - if (*p == 's') /* "2s" means two times 'shiftwidth' */ + if (*p == 's') // "2s" means two times 'shiftwidth' { if (p == digits) - n = sw; /* just "s" is one 'shiftwidth' */ + n = sw; // just "s" is one 'shiftwidth' else { n *= sw; @@ -1899,8 +1886,8 @@ parse_cino(buf_T *buf) if (l[1] == '-') n = -n; - /* When adding an entry here, also update the default 'cinoptions' in - * doc/indent.txt, and add explanation for it! */ + // When adding an entry here, also update the default 'cinoptions' in + // doc/indent.txt, and add explanation for it! switch (*l) { case '>': buf->b_ind_level = n; break; @@ -1966,9 +1953,9 @@ get_c_indent(void) pos_T our_paren_pos; char_u *start; int start_brace; -#define BRACE_IN_COL0 1 /* '{' is in column 0 */ -#define BRACE_AT_START 2 /* '{' is at start of line */ -#define BRACE_AT_END 3 /* '{' is at end of line */ +#define BRACE_IN_COL0 1 // '{' is in column 0 +#define BRACE_AT_START 2 // '{' is at start of line +#define BRACE_AT_END 3 // '{' is at end of line linenr_T ourscope; char_u *l; char_u *look; @@ -1994,37 +1981,35 @@ get_c_indent(void) int iscase; int lookfor_break; int lookfor_cpp_namespace = FALSE; - int cont_amount = 0; /* amount for continuation line */ + int cont_amount = 0; // amount for continuation line int original_line_islabel; int added_to_amount = 0; int js_cur_has_key = 0; linenr_T raw_string_start = 0; cpp_baseclass_cache_T cache_cpp_baseclass = { FALSE, { MAXLNUM, 0 } }; - /* make a copy, value is changed below */ + // make a copy, value is changed below int ind_continuation = curbuf->b_ind_continuation; - /* remember where the cursor was when we started */ + // remember where the cursor was when we started cur_curpos = curwin->w_cursor; - /* if we are at line 1 zero indent is fine, right? */ + // if we are at line 1 zero indent is fine, right? if (cur_curpos.lnum == 1) return 0; - /* Get a copy of the current contents of the line. - * This is required, because only the most recent line obtained with - * ml_get is valid! */ + // Get a copy of the current contents of the line. + // This is required, because only the most recent line obtained with + // ml_get is valid! linecopy = vim_strsave(ml_get(cur_curpos.lnum)); if (linecopy == NULL) return 0; - /* - * In insert mode and the cursor is on a ')' truncate the line at the - * cursor position. We don't want to line up with the matching '(' when - * inserting new stuff. - * For unknown reasons the cursor might be past the end of the line, thus - * check for that. - */ + // In insert mode and the cursor is on a ')' truncate the line at the + // cursor position. We don't want to line up with the matching '(' when + // inserting new stuff. + // For unknown reasons the cursor might be past the end of the line, thus + // check for that. if ((State & INSERT) && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy) && linecopy[curwin->w_cursor.col] == ')') @@ -2032,20 +2017,18 @@ get_c_indent(void) theline = skipwhite(linecopy); - /* move the cursor to the start of the line */ + // move the cursor to the start of the line curwin->w_cursor.col = 0; - original_line_islabel = cin_islabel(); /* XXX */ + original_line_islabel = cin_islabel(); // XXX - /* - * If we are inside a raw string don't change the indent. - * Ignore a raw string inside a comment. - */ + // If we are inside a raw string don't change the indent. + // Ignore a raw string inside a comment. comment_pos = ind_find_start_comment(); if (comment_pos != NULL) { - /* findmatchlimit() static pos is overwritten, make a copy */ + // findmatchlimit() static pos is overwritten, make a copy tryposCopy = *comment_pos; comment_pos = &tryposCopy; } @@ -2057,20 +2040,16 @@ get_c_indent(void) goto laterend; } - /* - * #defines and so on always go at the left when included in 'cinkeys'. - */ + // #defines and so on always go at the left when included in 'cinkeys'. if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE))) { amount = curbuf->b_ind_hash_comment; goto theend; } - /* - * Is it a non-case label? Then that goes at the left margin too unless: - * - JS flag is set. - * - 'L' item has a positive value. - */ + // Is it a non-case label? Then that goes at the left margin too unless: + // - JS flag is set. + // - 'L' item has a positive value. if (original_line_islabel && !curbuf->b_ind_js && curbuf->b_ind_jump_label < 0) { @@ -2078,36 +2057,32 @@ get_c_indent(void) goto theend; } - /* - * If we're inside a "//" comment and there is a "//" comment in a - * previous line, lineup with that one. - */ + // If we're inside a "//" comment and there is a "//" comment in a + // previous line, lineup with that one. if (cin_islinecomment(theline) - && (trypos = find_line_comment()) != NULL) /* XXX */ + && (trypos = find_line_comment()) != NULL) // XXX { - /* find how indented the line beginning the comment is */ + // find how indented the line beginning the comment is getvcol(curwin, trypos, &col, NULL, NULL); amount = col; goto theend; } - /* - * If we're inside a comment and not looking at the start of the - * comment, try using the 'comments' option. - */ - if (!cin_iscomment(theline) && comment_pos != NULL) /* XXX */ + // If we're inside a comment and not looking at the start of the + // comment, try using the 'comments' option. + if (!cin_iscomment(theline) && comment_pos != NULL) // XXX { int lead_start_len = 2; int lead_middle_len = 1; - char_u lead_start[COM_MAX_LEN]; /* start-comment string */ - char_u lead_middle[COM_MAX_LEN]; /* middle-comment string */ - char_u lead_end[COM_MAX_LEN]; /* end-comment string */ + char_u lead_start[COM_MAX_LEN]; // start-comment string + char_u lead_middle[COM_MAX_LEN]; // middle-comment string + char_u lead_end[COM_MAX_LEN]; // end-comment string char_u *p; int start_align = 0; int start_off = 0; int done = FALSE; - /* find how indented the line beginning the comment is */ + // find how indented the line beginning the comment is getvcol(curwin, comment_pos, &col, NULL, NULL); amount = col; *lead_start = NUL; @@ -2149,18 +2124,18 @@ get_c_indent(void) } else if (what == COM_END) { - /* If our line starts with the middle comment string, line it - * up with the comment opener per the 'comments' option. */ + // If our line starts with the middle comment string, line it + // up with the comment opener per the 'comments' option. if (STRNCMP(theline, lead_middle, lead_middle_len) == 0 && STRNCMP(theline, lead_end, STRLEN(lead_end)) != 0) { done = TRUE; if (curwin->w_cursor.lnum > 1) { - /* If the start comment string matches in the previous - * line, use the indent of that line plus offset. If - * the middle comment string matches in the previous - * line, use the indent of that line. XXX */ + // If the start comment string matches in the previous + // line, use the indent of that line plus offset. If + // the middle comment string matches in the previous + // line, use the indent of that line. XXX look = skipwhite(ml_get(curwin->w_cursor.lnum - 1)); if (STRNCMP(look, lead_start, lead_start_len) == 0) amount = get_indent_lnum(curwin->w_cursor.lnum - 1); @@ -2170,8 +2145,8 @@ get_c_indent(void) amount = get_indent_lnum(curwin->w_cursor.lnum - 1); break; } - /* If the start comment string doesn't match with the - * start of the comment, skip this entry. XXX */ + // If the start comment string doesn't match with the + // start of the comment, skip this entry. XXX else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col, lead_start, lead_start_len) != 0) continue; @@ -2184,13 +2159,13 @@ get_c_indent(void) break; } - /* If our line starts with the end comment string, line it up - * with the middle comment */ + // If our line starts with the end comment string, line it up + // with the middle comment if (STRNCMP(theline, lead_middle, lead_middle_len) != 0 && STRNCMP(theline, lead_end, STRLEN(lead_end)) == 0) { amount = get_indent_lnum(curwin->w_cursor.lnum - 1); - /* XXX */ + // XXX if (off != 0) amount += off; else if (align == COM_RIGHT) @@ -2202,38 +2177,35 @@ get_c_indent(void) } } - /* If our line starts with an asterisk, line up with the - * asterisk in the comment opener; otherwise, line up - * with the first character of the comment text. - */ + // If our line starts with an asterisk, line up with the + // asterisk in the comment opener; otherwise, line up + // with the first character of the comment text. if (done) ; else if (theline[0] == '*') amount += 1; else { - /* - * If we are more than one line away from the comment opener, take - * the indent of the previous non-empty line. If 'cino' has "CO" - * and we are just below the comment opener and there are any - * white characters after it line up with the text after it; - * otherwise, add the amount specified by "c" in 'cino' - */ + // If we are more than one line away from the comment opener, take + // the indent of the previous non-empty line. If 'cino' has "CO" + // and we are just below the comment opener and there are any + // white characters after it line up with the text after it; + // otherwise, add the amount specified by "c" in 'cino' amount = -1; for (lnum = cur_curpos.lnum - 1; lnum > comment_pos->lnum; --lnum) { - if (linewhite(lnum)) /* skip blank lines */ + if (linewhite(lnum)) // skip blank lines continue; - amount = get_indent_lnum(lnum); /* XXX */ + amount = get_indent_lnum(lnum); // XXX break; } - if (amount == -1) /* use the comment opener */ + if (amount == -1) // use the comment opener { if (!curbuf->b_ind_in_comment2) { start = ml_get(comment_pos->lnum); - look = start + comment_pos->col + 2; /* skip / and * */ - if (*look != NUL) /* if something after it */ + look = start + comment_pos->col + 2; // skip / and * + if (*look != NUL) // if something after it comment_pos->col = (colnr_T)(skipwhite(look) - start); } getvcol(curwin, comment_pos, &col, NULL, NULL); @@ -2245,20 +2217,16 @@ get_c_indent(void) goto theend; } - /* - * Are we looking at a ']' that has a match? - */ + // Are we looking at a ']' that has a match? if (*skipwhite(theline) == ']' && (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL) { - /* align with the line containing the '['. */ + // align with the line containing the '['. amount = get_indent_lnum(trypos->lnum); goto theend; } - /* - * Are we inside parentheses or braces? - */ /* XXX */ + // Are we inside parentheses or braces? XXX if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL && curbuf->b_ind_java == 0) || (tryposBrace = find_start_brace()) != NULL @@ -2266,8 +2234,8 @@ get_c_indent(void) { if (trypos != NULL && tryposBrace != NULL) { - /* Both an unmatched '(' and '{' is found. Use the one which is - * closer to the current cursor position, set the other to NULL. */ + // Both an unmatched '(' and '{' is found. Use the one which is + // closer to the current cursor position, set the other to NULL. if (trypos->lnum != tryposBrace->lnum ? trypos->lnum < tryposBrace->lnum : trypos->col < tryposBrace->col) @@ -2278,14 +2246,12 @@ get_c_indent(void) if (trypos != NULL) { - /* - * If the matching paren is more than one line away, use the indent of - * a previous non-empty line that matches the same paren. - */ + // If the matching paren is more than one line away, use the indent of + // a previous non-empty line that matches the same paren. if (theline[0] == ')' && curbuf->b_ind_paren_prev) { - /* Line up with the start of the matching paren line. */ - amount = get_indent_lnum(curwin->w_cursor.lnum - 1); /* XXX */ + // Line up with the start of the matching paren line. + amount = get_indent_lnum(curwin->w_cursor.lnum - 1); // XXX } else { @@ -2294,26 +2260,26 @@ get_c_indent(void) for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum) { l = skipwhite(ml_get(lnum)); - if (cin_nocode(l)) /* skip comment lines */ + if (cin_nocode(l)) // skip comment lines continue; if (cin_ispreproc_cont(&l, &lnum, &amount)) - continue; /* ignore #define, #if, etc. */ + continue; // ignore #define, #if, etc. curwin->w_cursor.lnum = lnum; - /* Skip a comment or raw string. XXX */ + // Skip a comment or raw string. XXX if ((trypos = ind_find_start_CORS(NULL)) != NULL) { lnum = trypos->lnum + 1; continue; } - /* XXX */ + // XXX if ((trypos = find_match_paren( corr_ind_maxparen(&cur_curpos))) != NULL && trypos->lnum == our_paren_pos.lnum && trypos->col == our_paren_pos.col) { - amount = get_indent_lnum(lnum); /* XXX */ + amount = get_indent_lnum(lnum); // XXX if (theline[0] == ')') { @@ -2327,11 +2293,9 @@ get_c_indent(void) } } - /* - * Line up with line where the matching paren is. XXX - * If the line starts with a '(' or the indent for unclosed - * parentheses is zero, line up with the unclosed parentheses. - */ + // Line up with line where the matching paren is. XXX + // If the line starts with a '(' or the indent for unclosed + // parentheses is zero, line up with the unclosed parentheses. if (amount == -1) { int ignore_paren_col = 0; @@ -2339,8 +2303,8 @@ get_c_indent(void) if (curbuf->b_ind_if_for_while) { - /* Look for the outermost opening parenthesis on this line - * and check whether it belongs to an "if", "for" or "while". */ + // Look for the outermost opening parenthesis on this line + // and check whether it belongs to an "if", "for" or "while". pos_T cursor_save = curwin->w_cursor; pos_T outermost; @@ -2371,8 +2335,8 @@ get_c_indent(void) char_u *line; int look_col; - /* Ignore a '(' in front of the line that has a match before - * our matching '('. */ + // Ignore a '(' in front of the line that has a match before + // our matching '('. curwin->w_cursor.lnum = our_paren_pos.lnum; line = ml_get_curline(); look_col = (int)(look - line); @@ -2392,15 +2356,13 @@ get_c_indent(void) || (!curbuf->b_ind_unclosed_noignore && *look == '(' && ignore_paren_col == 0)) { - /* - * If we're looking at a close paren, line up right there; - * otherwise, line up with the next (non-white) character. - * When b_ind_unclosed_wrapped is set and the matching paren is - * the last nonwhite character of the line, use either the - * indent of the current line or the indentation of the next - * outer paren and add b_ind_unclosed_wrapped (for very long - * lines). - */ + // If we're looking at a close paren, line up right there; + // otherwise, line up with the next (non-white) character. + // When b_ind_unclosed_wrapped is set and the matching paren is + // the last nonwhite character of the line, use either the + // indent of the current line or the indentation of the next + // outer paren and add b_ind_unclosed_wrapped (for very long + // lines). if (theline[0] != ')') { cur_amount = MAXCOL; @@ -2408,8 +2370,8 @@ get_c_indent(void) if (curbuf->b_ind_unclosed_wrapped && cin_ends_in(l, (char_u *)"(", NULL)) { - /* look for opening unmatched paren, indent one level - * for each additional level */ + // look for opening unmatched paren, indent one level + // for each additional level n = 1; for (col = 0; col < our_paren_pos.col; ++col) { @@ -2436,17 +2398,15 @@ get_c_indent(void) col = our_paren_pos.col + 1; while (VIM_ISWHITE(l[col])) col++; - if (l[col] != NUL) /* In case of trailing space */ + if (l[col] != NUL) // In case of trailing space our_paren_pos.col = col; else our_paren_pos.col++; } } - /* - * Find how indented the paren is, or the character after it - * if we did the above "if". - */ + // Find how indented the paren is, or the character after it + // if we did the above "if". if (our_paren_pos.col > 0) { getvcol(curwin, &our_paren_pos, &col, NULL, NULL); @@ -2457,7 +2417,7 @@ get_c_indent(void) if (theline[0] == ')' && curbuf->b_ind_matching_paren) { - /* Line up with the start of the matching paren line. */ + // Line up with the start of the matching paren line. } else if ((curbuf->b_ind_unclosed == 0 && is_if_for_while == 0) || (!curbuf->b_ind_unclosed_noignore @@ -2468,8 +2428,8 @@ get_c_indent(void) } else { - /* Add b_ind_unclosed2 for each '(' before our matching one, - * but ignore (void) before the line (ignore_paren_col). */ + // Add b_ind_unclosed2 for each '(' before our matching one, + // but ignore (void) before the line (ignore_paren_col). col = our_paren_pos.col; while ((int)our_paren_pos.col > ignore_paren_col) { @@ -2485,8 +2445,8 @@ get_c_indent(void) } } - /* Use b_ind_unclosed once, when the first '(' is not inside - * braces */ + // Use b_ind_unclosed once, when the first '(' is not inside + // braces if (col == MAXCOL) amount += curbuf->b_ind_unclosed; else @@ -2504,43 +2464,37 @@ get_c_indent(void) amount += curbuf->b_ind_unclosed; } } - /* - * For a line starting with ')' use the minimum of the two - * positions, to avoid giving it more indent than the previous - * lines: - * func_long_name( if (x - * arg && yy - * ) ^ not here ) ^ not here - */ + // For a line starting with ')' use the minimum of the two + // positions, to avoid giving it more indent than the previous + // lines: + // func_long_name( if (x + // arg && yy + // ) ^ not here ) ^ not here if (cur_amount < amount) amount = cur_amount; } } - /* add extra indent for a comment */ + // add extra indent for a comment if (cin_iscomment(theline)) amount += curbuf->b_ind_comment; } else { - /* - * We are inside braces, there is a { before this line at the position - * stored in tryposBrace. - * Make a copy of tryposBrace, it may point to pos_copy inside - * find_start_brace(), which may be changed somewhere. - */ + // We are inside braces, there is a { before this line at the position + // stored in tryposBrace. + // Make a copy of tryposBrace, it may point to pos_copy inside + // find_start_brace(), which may be changed somewhere. tryposCopy = *tryposBrace; tryposBrace = &tryposCopy; trypos = tryposBrace; ourscope = trypos->lnum; start = ml_get(ourscope); - /* - * Now figure out how indented the line is in general. - * If the brace was at the start of the line, we use that; - * otherwise, check out the indentation of the line as - * a whole and then add the "imaginary indent" to that. - */ + // Now figure out how indented the line is in general. + // If the brace was at the start of the line, we use that; + // otherwise, check out the indentation of the line as + // a whole and then add the "imaginary indent" to that. look = skipwhite(start); if (*look == '{') { @@ -2553,23 +2507,22 @@ get_c_indent(void) } else { - /* That opening brace might have been on a continuation - * line. if so, find the start of the line. */ + // That opening brace might have been on a continuation + // line. if so, find the start of the line. curwin->w_cursor.lnum = ourscope; - /* Position the cursor over the rightmost paren, so that - * matching it will take us back to the start of the line. */ + // Position the cursor over the rightmost paren, so that + // matching it will take us back to the start of the line. lnum = ourscope; if (find_last_paren(start, '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) lnum = trypos->lnum; - /* It could have been something like - * case 1: if (asdf && - * ldfd) { - * } - */ + // It could have been something like + // case 1: if (asdf && + // ldfd) { + // } if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label) && cin_iscase(skipwhite(ml_get_curline()), FALSE)) amount = get_indent(); @@ -2581,73 +2534,63 @@ get_c_indent(void) start_brace = BRACE_AT_END; } - /* For Javascript check if the line starts with "key:". */ + // For Javascript check if the line starts with "key:". if (curbuf->b_ind_js) js_cur_has_key = cin_has_js_key(theline); - /* - * If we're looking at a closing brace, that's where - * we want to be. otherwise, add the amount of room - * that an indent is supposed to be. - */ + // If we're looking at a closing brace, that's where + // we want to be. otherwise, add the amount of room + // that an indent is supposed to be. if (theline[0] == '}') { - /* - * they may want closing braces to line up with something - * other than the open brace. indulge them, if so. - */ + // they may want closing braces to line up with something + // other than the open brace. indulge them, if so. amount += curbuf->b_ind_close_extra; } else { - /* - * If we're looking at an "else", try to find an "if" - * to match it with. - * If we're looking at a "while", try to find a "do" - * to match it with. - */ + // If we're looking at an "else", try to find an "if" + // to match it with. + // If we're looking at a "while", try to find a "do" + // to match it with. lookfor = LOOKFOR_INITIAL; if (cin_iselse(theline)) lookfor = LOOKFOR_IF; - else if (cin_iswhileofdo(theline, cur_curpos.lnum)) /* XXX */ + else if (cin_iswhileofdo(theline, cur_curpos.lnum)) // XXX lookfor = LOOKFOR_DO; if (lookfor != LOOKFOR_INITIAL) { curwin->w_cursor.lnum = cur_curpos.lnum; if (find_match(lookfor, ourscope) == OK) { - amount = get_indent(); /* XXX */ + amount = get_indent(); // XXX goto theend; } } - /* - * We get here if we are not on an "while-of-do" or "else" (or - * failed to find a matching "if"). - * Search backwards for something to line up with. - * First set amount for when we don't find anything. - */ + // We get here if we are not on an "while-of-do" or "else" (or + // failed to find a matching "if"). + // Search backwards for something to line up with. + // First set amount for when we don't find anything. - /* - * if the '{' is _really_ at the left margin, use the imaginary - * location of a left-margin brace. Otherwise, correct the - * location for b_ind_open_extra. - */ + // if the '{' is _really_ at the left margin, use the imaginary + // location of a left-margin brace. Otherwise, correct the + // location for b_ind_open_extra. - if (start_brace == BRACE_IN_COL0) /* '{' is in column 0 */ + if (start_brace == BRACE_IN_COL0) // '{' is in column 0 { amount = curbuf->b_ind_open_left_imag; lookfor_cpp_namespace = TRUE; } else if (start_brace == BRACE_AT_START && - lookfor_cpp_namespace) /* '{' is at start */ + lookfor_cpp_namespace) // '{' is at start { lookfor_cpp_namespace = TRUE; } else { - if (start_brace == BRACE_AT_END) /* '{' is at end of line */ + if (start_brace == BRACE_AT_END) // '{' is at end of line { amount += curbuf->b_ind_open_imag; @@ -2659,7 +2602,7 @@ get_c_indent(void) } else { - /* Compensate for adding b_ind_open_extra later. */ + // Compensate for adding b_ind_open_extra later. amount -= curbuf->b_ind_open_extra; if (amount < 0) amount = 0; @@ -2668,67 +2611,62 @@ get_c_indent(void) lookfor_break = FALSE; - if (cin_iscase(theline, FALSE)) /* it's a switch() label */ + if (cin_iscase(theline, FALSE)) // it's a switch() label { - lookfor = LOOKFOR_CASE; /* find a previous switch() label */ + lookfor = LOOKFOR_CASE; // find a previous switch() label amount += curbuf->b_ind_case; } - else if (cin_isscopedecl(theline)) /* private:, ... */ + else if (cin_isscopedecl(theline)) // private:, ... { - lookfor = LOOKFOR_SCOPEDECL; /* class decl is this block */ + lookfor = LOOKFOR_SCOPEDECL; // class decl is this block amount += curbuf->b_ind_scopedecl; } else { if (curbuf->b_ind_case_break && cin_isbreak(theline)) - /* break; ... */ + // break; ... lookfor_break = TRUE; lookfor = LOOKFOR_INITIAL; - /* b_ind_level from start of block */ + // b_ind_level from start of block amount += curbuf->b_ind_level; } scope_amount = amount; whilelevel = 0; - /* - * Search backwards. If we find something we recognize, line up - * with that. - * - * If we're looking at an open brace, indent - * the usual amount relative to the conditional - * that opens the block. - */ + // Search backwards. If we find something we recognize, line up + // with that. + // + // If we're looking at an open brace, indent + // the usual amount relative to the conditional + // that opens the block. curwin->w_cursor = cur_curpos; for (;;) { curwin->w_cursor.lnum--; curwin->w_cursor.col = 0; - /* - * If we went all the way back to the start of our scope, line - * up with it. - */ + // If we went all the way back to the start of our scope, line + // up with it. if (curwin->w_cursor.lnum <= ourscope) { - /* We reached end of scope: - * If looking for a enum or structure initialization - * go further back: - * If it is an initializer (enum xxx or xxx =), then - * don't add ind_continuation, otherwise it is a variable - * declaration: - * int x, - * here; <-- add ind_continuation - */ + // We reached end of scope: + // If looking for a enum or structure initialization + // go further back: + // If it is an initializer (enum xxx or xxx =), then + // don't add ind_continuation, otherwise it is a variable + // declaration: + // int x, + // here; <-- add ind_continuation if (lookfor == LOOKFOR_ENUM_OR_INIT) { if (curwin->w_cursor.lnum == 0 || curwin->w_cursor.lnum < ourscope - curbuf->b_ind_maxparen) { - /* nothing found (abuse curbuf->b_ind_maxparen as - * limit) assume terminated line (i.e. a variable - * initialization) */ + // nothing found (abuse curbuf->b_ind_maxparen as + // limit) assume terminated line (i.e. a variable + // initialization) if (cont_amount > 0) amount = cont_amount; else if (!curbuf->b_ind_js) @@ -2738,10 +2676,8 @@ get_c_indent(void) l = ml_get_curline(); - /* - * If we're in a comment or raw string now, skip to - * the start of it. - */ + // If we're in a comment or raw string now, skip to + // the start of it. trypos = ind_find_start_CORS(NULL); if (trypos != NULL) { @@ -2750,9 +2686,7 @@ get_c_indent(void) continue; } - /* - * Skip preprocessor directives and blank lines. - */ + // Skip preprocessor directives and blank lines. if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) continue; @@ -2762,41 +2696,37 @@ get_c_indent(void) terminated = cin_isterminated(l, FALSE, TRUE); - /* - * If we are at top level and the line looks like a - * function declaration, we are done - * (it's a variable declaration). - */ + // If we are at top level and the line looks like a + // function declaration, we are done + // (it's a variable declaration). if (start_brace != BRACE_IN_COL0 || !cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0)) { - /* if the line is terminated with another ',' - * it is a continued variable initialization. - * don't add extra indent. - * TODO: does not work, if a function - * declaration is split over multiple lines: - * cin_isfuncdecl returns FALSE then. - */ + // if the line is terminated with another ',' + // it is a continued variable initialization. + // don't add extra indent. + // TODO: does not work, if a function + // declaration is split over multiple lines: + // cin_isfuncdecl returns FALSE then. if (terminated == ',') break; - /* if it es a enum declaration or an assignment, - * we are done. - */ + // if it es a enum declaration or an assignment, + // we are done. if (terminated != ';' && cin_isinit()) break; - /* nothing useful found */ + // nothing useful found if (terminated == 0 || terminated == '{') continue; } if (terminated != ';') { - /* Skip parens and braces. Position the cursor - * over the rightmost paren, so that matching it - * will take us back to the start of the line. - */ /* XXX */ + // Skip parens and braces. Position the cursor + // over the rightmost paren, so that matching it + // will take us back to the start of the line. + // XXX trypos = NULL; if (find_last_paren(l, '(', ')')) trypos = find_match_paren( @@ -2813,11 +2743,10 @@ get_c_indent(void) } } - /* it's a variable declaration, add indentation - * like in - * int a, - * b; - */ + // it's a variable declaration, add indentation + // like in + // int a, + // b; if (cont_amount > 0) amount = cont_amount; else @@ -2846,10 +2775,8 @@ get_c_indent(void) if (lookfor_cpp_namespace) { - /* - * Looking for C++ namespace, need to look further - * back. - */ + // Looking for C++ namespace, need to look further + // back. if (curwin->w_cursor.lnum == ourscope) continue; @@ -2860,8 +2787,8 @@ get_c_indent(void) l = ml_get_curline(); - /* If we're in a comment or raw string now, skip - * to the start of it. */ + // If we're in a comment or raw string now, skip + // to the start of it. trypos = ind_find_start_CORS(NULL); if (trypos != NULL) { @@ -2870,12 +2797,12 @@ get_c_indent(void) continue; } - /* Skip preprocessor directives and blank lines. */ + // Skip preprocessor directives and blank lines. if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) continue; - /* Finally the actual check for "namespace". */ + // Finally the actual check for "namespace". if (cin_is_cpp_namespace(l)) { amount += curbuf->b_ind_cpp_namespace @@ -2896,10 +2823,8 @@ get_c_indent(void) break; } - /* - * If we're in a comment or raw string now, skip to the start - * of it. - */ /* XXX */ + // If we're in a comment or raw string now, skip to the start + // of it. XXX if ((trypos = ind_find_start_CORS(&raw_string_start)) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; @@ -2909,28 +2834,24 @@ get_c_indent(void) l = ml_get_curline(); - /* - * If this is a switch() label, may line up relative to that. - * If this is a C++ scope declaration, do the same. - */ + // If this is a switch() label, may line up relative to that. + // If this is a C++ scope declaration, do the same. iscase = cin_iscase(l, FALSE); if (iscase || cin_isscopedecl(l)) { - /* we are only looking for cpp base class - * declaration/initialization any longer */ + // we are only looking for cpp base class + // declaration/initialization any longer if (lookfor == LOOKFOR_CPP_BASECLASS) break; - /* When looking for a "do" we are not interested in - * labels. */ + // When looking for a "do" we are not interested in + // labels. if (whilelevel > 0) continue; - /* - * case xx: - * c = 99 + <- this indent plus continuation - *-> here; - */ + // case xx: + // c = 99 + <- this indent plus continuation + //-> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { @@ -2941,40 +2862,34 @@ get_c_indent(void) break; } - /* - * case xx: <- line up with this case - * x = 333; - * case yy: - */ + // case xx: <- line up with this case + // x = 333; + // case yy: if ( (iscase && lookfor == LOOKFOR_CASE) || (iscase && lookfor_break) || (!iscase && lookfor == LOOKFOR_SCOPEDECL)) { - /* - * Check that this case label is not for another - * switch() - */ /* XXX */ + // Check that this case label is not for another + // switch() XXX if ((trypos = find_start_brace()) == NULL || trypos->lnum == ourscope) { - amount = get_indent(); /* XXX */ + amount = get_indent(); // XXX break; } continue; } - n = get_indent_nolabel(curwin->w_cursor.lnum); /* XXX */ + n = get_indent_nolabel(curwin->w_cursor.lnum); // XXX - /* - * case xx: if (cond) <- line up with this if - * y = y + 1; - * -> s = 99; - * - * case xx: - * if (cond) <- line up with this line - * y = y + 1; - * -> s = 99; - */ + // case xx: if (cond) <- line up with this if + // y = y + 1; + // -> s = 99; + // + // case xx: + // if (cond) <- line up with this line + // y = y + 1; + // -> s = 99; if (lookfor == LOOKFOR_TERM) { if (n) @@ -2984,13 +2899,11 @@ get_c_indent(void) break; } - /* - * case xx: x = x + 1; <- line up with this x - * -> y = y + 1; - * - * case xx: if (cond) <- line up with this if - * -> y = y + 1; - */ + // case xx: x = x + 1; <- line up with this x + // -> y = y + 1; + // + // case xx: if (cond) <- line up with this if + // -> y = y + 1; if (n) { amount = n; @@ -3006,15 +2919,13 @@ get_c_indent(void) break; } - /* - * Try to get the indent of a statement before the switch - * label. If nothing is found, line up relative to the - * switch label. - * break; <- may line up with this line - * case xx: - * -> y = 1; - */ - scope_amount = get_indent() + (iscase /* XXX */ + // Try to get the indent of a statement before the switch + // label. If nothing is found, line up relative to the + // switch label. + // break; <- may line up with this line + // case xx: + // -> y = 1; + scope_amount = get_indent() + (iscase // XXX ? curbuf->b_ind_case_code : curbuf->b_ind_scopedecl_code); lookfor = curbuf->b_ind_case_break @@ -3022,10 +2933,8 @@ get_c_indent(void) continue; } - /* - * Looking for a switch() label or C++ scope declaration, - * ignore other lines, skip {}-blocks. - */ + // Looking for a switch() label or C++ scope declaration, + // ignore other lines, skip {}-blocks. if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL) { if (find_last_paren(l, '{', '}') @@ -3037,9 +2946,7 @@ get_c_indent(void) continue; } - /* - * Ignore jump labels with nothing after them. - */ + // Ignore jump labels with nothing after them. if (!curbuf->b_ind_js && cin_islabel()) { l = after_label(ml_get_curline()); @@ -3047,21 +2954,17 @@ get_c_indent(void) continue; } - /* - * Ignore #defines, #if, etc. - * Ignore comment and empty lines. - * (need to get the line again, cin_islabel() may have - * unlocked it) - */ + // Ignore #defines, #if, etc. + // Ignore comment and empty lines. + // (need to get the line again, cin_islabel() may have + // unlocked it) l = ml_get_curline(); if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount) || cin_nocode(l)) continue; - /* - * Are we at the start of a cpp base class declaration or - * constructor initialization? - */ /* XXX */ + // Are we at the start of a cpp base class declaration or + // constructor initialization? XXX n = FALSE; if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) { @@ -3079,54 +2982,50 @@ get_c_indent(void) } else if (theline[0] == '{') { - /* Need to find start of the declaration. */ + // Need to find start of the declaration. lookfor = LOOKFOR_UNTERM; ind_continuation = 0; continue; } else - /* XXX */ + // XXX amount = get_baseclass_amount( cache_cpp_baseclass.lpos.col); break; } else if (lookfor == LOOKFOR_CPP_BASECLASS) { - /* only look, whether there is a cpp base class - * declaration or initialization before the opening brace. - */ + // only look, whether there is a cpp base class + // declaration or initialization before the opening brace. if (cin_isterminated(l, TRUE, FALSE)) break; else continue; } - /* - * What happens next depends on the line being terminated. - * If terminated with a ',' only consider it terminating if - * there is another unterminated statement behind, eg: - * 123, - * sizeof - * here - * Otherwise check whether it is a enumeration or structure - * initialisation (not indented) or a variable declaration - * (indented). - */ + // What happens next depends on the line being terminated. + // If terminated with a ',' only consider it terminating if + // there is another unterminated statement behind, eg: + // 123, + // sizeof + // here + // Otherwise check whether it is a enumeration or structure + // initialisation (not indented) or a variable declaration + // (indented). terminated = cin_isterminated(l, FALSE, TRUE); if (js_cur_has_key) { - js_cur_has_key = 0; /* only check the first line */ + js_cur_has_key = 0; // only check the first line if (curbuf->b_ind_js && terminated == ',') { - /* For Javascript we might be inside an object: - * key: something, <- align with this - * key: something - * or: - * key: something + <- align with this - * something, - * key: something - */ + // For Javascript we might be inside an object: + // key: something, <- align with this + // key: something + // or: + // key: something + <- align with this + // something, + // key: something lookfor = LOOKFOR_JS_KEY; } } @@ -3141,16 +3040,16 @@ get_c_indent(void) >= curwin->w_cursor.lnum) break; if (terminated == ',') - /* line below current line is the one that starts a - * (possibly broken) line ending in a comma. */ + // line below current line is the one that starts a + // (possibly broken) line ending in a comma. break; else { amount = get_indent(); if (curwin->w_cursor.lnum - 1 == ourscope) - /* line above is start of the scope, thus current - * line is the one that stars a (possibly broken) - * line ending in a comma. */ + // line above is start of the scope, thus current + // line is the one that stars a (possibly broken) + // line ending in a comma. break; } } @@ -3161,18 +3060,15 @@ get_c_indent(void) if (lookfor != LOOKFOR_ENUM_OR_INIT && (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[')) amount += ind_continuation; - /* - * if we're in the middle of a paren thing, - * go back to the line that starts it so - * we can get the right prevailing indent - * if ( foo && - * bar ) - */ - /* - * Position the cursor over the rightmost paren, so that - * matching it will take us back to the start of the line. - * Ignore a match before the start of the block. - */ + // if we're in the middle of a paren thing, + // go back to the line that starts it so + // we can get the right prevailing indent + // if ( foo && + // bar ) + + // Position the cursor over the rightmost paren, so that + // matching it will take us back to the start of the line. + // Ignore a match before the start of the block. (void)find_last_paren(l, '(', ')'); trypos = find_match_paren(corr_ind_maxparen(&cur_curpos)); if (trypos != NULL && (trypos->lnum < tryposBrace->lnum @@ -3180,22 +3076,18 @@ get_c_indent(void) && trypos->col < tryposBrace->col))) trypos = NULL; - /* - * If we are looking for ',', we also look for matching - * braces. - */ + // If we are looking for ',', we also look for matching + // braces. if (trypos == NULL && terminated == ',' && find_last_paren(l, '{', '}')) trypos = find_start_brace(); if (trypos != NULL) { - /* - * Check if we are on a case label now. This is - * handled above. - * case xx: if ( asdf && - * asdf) - */ + // Check if we are on a case label now. This is + // handled above. + // case xx: if ( asdf && + // asdf) curwin->w_cursor = *trypos; l = ml_get_curline(); if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) @@ -3225,58 +3117,48 @@ get_c_indent(void) } } - /* - * Get indent and pointer to text for current line, - * ignoring any jump label. XXX - */ + // Get indent and pointer to text for current line, + // ignoring any jump label. XXX if (curbuf->b_ind_js) cur_amount = get_indent(); else cur_amount = skip_label(curwin->w_cursor.lnum, &l); - /* - * If this is just above the line we are indenting, and it - * starts with a '{', line it up with this line. - * while (not) - * -> { - * } - */ + // If this is just above the line we are indenting, and it + // starts with a '{', line it up with this line. + // while (not) + // -> { + // } if (terminated != ',' && lookfor != LOOKFOR_TERM && theline[0] == '{') { amount = cur_amount; - /* - * Only add b_ind_open_extra when the current line - * doesn't start with a '{', which must have a match - * in the same line (scope is the same). Probably: - * { 1, 2 }, - * -> { 3, 4 } - */ + // Only add b_ind_open_extra when the current line + // doesn't start with a '{', which must have a match + // in the same line (scope is the same). Probably: + // { 1, 2 }, + // -> { 3, 4 } if (*skipwhite(l) != '{') amount += curbuf->b_ind_open_extra; if (curbuf->b_ind_cpp_baseclass && !curbuf->b_ind_js) { - /* have to look back, whether it is a cpp base - * class declaration or initialization */ + // have to look back, whether it is a cpp base + // class declaration or initialization lookfor = LOOKFOR_CPP_BASECLASS; continue; } break; } - /* - * Check if we are after an "if", "while", etc. - * Also allow " } else". - */ + // Check if we are after an "if", "while", etc. + // Also allow " } else". if (cin_is_cinword(l) || cin_iselse(skipwhite(l))) { - /* - * Found an unterminated line after an if (), line up - * with the last one. - * if (cond) - * 100 + - * -> here; - */ + // Found an unterminated line after an if (), line up + // with the last one. + // if (cond) + // 100 + + // -> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { @@ -3287,19 +3169,17 @@ get_c_indent(void) break; } - /* - * If this is just above the line we are indenting, we - * are finished. - * while (not) - * -> here; - * Otherwise this indent can be used when the line - * before this is terminated. - * yyy; - * if (stat) - * while (not) - * xxx; - * -> here; - */ + // If this is just above the line we are indenting, we + // are finished. + // while (not) + // -> here; + // Otherwise this indent can be used when the line + // before this is terminated. + // yyy; + // if (stat) + // while (not) + // xxx; + // -> here; amount = cur_amount; if (theline[0] == '{') amount += curbuf->b_ind_open_extra; @@ -3310,13 +3190,11 @@ get_c_indent(void) break; } - /* - * Special trick: when expecting the while () after a - * do, line up with the while() - * do - * x = 1; - * -> here - */ + // Special trick: when expecting the while () after a + // do, line up with the while() + // do + // x = 1; + // -> here l = skipwhite(ml_get_curline()); if (cin_isdo(l)) { @@ -3325,17 +3203,15 @@ get_c_indent(void) --whilelevel; } - /* - * When searching for a terminated line, don't use the - * one between the "if" and the matching "else". - * Need to use the scope of this "else". XXX - * If whilelevel != 0 continue looking for a "do {". - */ + // When searching for a terminated line, don't use the + // one between the "if" and the matching "else". + // Need to use the scope of this "else". XXX + // If whilelevel != 0 continue looking for a "do {". if (cin_iselse(l) && whilelevel == 0) { - /* If we're looking at "} else", let's make sure we - * find the opening brace of the enclosing scope, - * not the one from "if () {". */ + // If we're looking at "} else", let's make sure we + // find the opening brace of the enclosing scope, + // not the one from "if () {". if (*l == '}') curwin->w_cursor.col = (colnr_T)(l - ml_get_curline()) + 1; @@ -3347,24 +3223,20 @@ get_c_indent(void) } } - /* - * If we're below an unterminated line that is not an - * "if" or something, we may line up with this line or - * add something for a continuation line, depending on - * the line before this one. - */ + // If we're below an unterminated line that is not an + // "if" or something, we may line up with this line or + // add something for a continuation line, depending on + // the line before this one. else { - /* - * Found two unterminated lines on a row, line up with - * the last one. - * c = 99 + - * 100 + - * -> here; - */ + // Found two unterminated lines on a row, line up with + // the last one. + // c = 99 + + // 100 + + // -> here; if (lookfor == LOOKFOR_UNTERM) { - /* When line ends in a comma add extra indent */ + // When line ends in a comma add extra indent if (terminated == ',') amount += ind_continuation; break; @@ -3372,11 +3244,11 @@ get_c_indent(void) if (lookfor == LOOKFOR_ENUM_OR_INIT) { - /* Found two lines ending in ',', lineup with the - * lowest one, but check for cpp base class - * declaration/initialization, if it is an - * opening brace or we are looking just for - * enumerations/initializations. */ + // Found two lines ending in ',', lineup with the + // lowest one, but check for cpp base class + // declaration/initialization, if it is an + // opening brace or we are looking just for + // enumerations/initializations. if (terminated == ',') { if (curbuf->b_ind_cpp_baseclass == 0) @@ -3386,19 +3258,17 @@ get_c_indent(void) continue; } - /* Ignore unterminated lines in between, but - * reduce indent. */ + // Ignore unterminated lines in between, but + // reduce indent. if (amount > cur_amount) amount = cur_amount; } else { - /* - * Found first unterminated line on a row, may - * line up with this line, remember its indent - * 100 + - * -> here; - */ + // Found first unterminated line on a row, may + // line up with this line, remember its indent + // 100 + + // -> here; l = ml_get_curline(); amount = cur_amount; @@ -3407,33 +3277,30 @@ get_c_indent(void) || (n >=2 && l[n - 2] == ']'))) break; - /* - * If previous line ends in ',', check whether we - * are in an initialization or enum - * struct xxx = - * { - * sizeof a, - * 124 }; - * or a normal possible continuation line. - * but only, of no other statement has been found - * yet. - */ + // If previous line ends in ',', check whether we + // are in an initialization or enum + // struct xxx = + // { + // sizeof a, + // 124 }; + // or a normal possible continuation line. + // but only, of no other statement has been found + // yet. if (lookfor == LOOKFOR_INITIAL && terminated == ',') { if (curbuf->b_ind_js) { - /* Search for a line ending in a comma - * and line up with the line below it - * (could be the current line). - * some = [ - * 1, <- line up here - * 2, - * some = [ - * 3 + <- line up here - * 4 * - * 5, - * 6, - */ + // Search for a line ending in a comma + // and line up with the line below it + // (could be the current line). + // some = [ + // 1, <- line up here + // 2, + // some = [ + // 3 + <- line up here + // 4 * + // 5, + // 6, if (cin_iscomment(skipwhite(l))) break; lookfor = LOOKFOR_COMMA; @@ -3444,8 +3311,8 @@ get_c_indent(void) if (trypos->lnum == curwin->w_cursor.lnum - 1) { - /* Current line is first inside - * [], line up with it. */ + // Current line is first inside + // [], line up with it. break; } ourscope = trypos->lnum; @@ -3462,7 +3329,7 @@ get_c_indent(void) if (lookfor == LOOKFOR_INITIAL && *l != NUL && l[STRLEN(l) - 1] == '\\') - /* XXX */ + // XXX cont_amount = cin_get_equal_amount( curwin->w_cursor.lnum); if (lookfor != LOOKFOR_TERM @@ -3475,19 +3342,15 @@ get_c_indent(void) } } - /* - * Check if we are after a while (cond); - * If so: Ignore until the matching "do". - */ - else if (cin_iswhileofdo_end(terminated)) /* XXX */ + // Check if we are after a while (cond); + // If so: Ignore until the matching "do". + else if (cin_iswhileofdo_end(terminated)) // XXX { - /* - * Found an unterminated line after a while ();, line up - * with the last one. - * while (cond); - * 100 + <- line up with this one - * -> here; - */ + // Found an unterminated line after a while ();, line up + // with the last one. + // while (cond); + // 100 + <- line up with this one + // -> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { @@ -3501,26 +3364,22 @@ get_c_indent(void) if (whilelevel == 0) { lookfor = LOOKFOR_TERM; - amount = get_indent(); /* XXX */ + amount = get_indent(); // XXX if (theline[0] == '{') amount += curbuf->b_ind_open_extra; } ++whilelevel; } - /* - * We are after a "normal" statement. - * If we had another statement we can stop now and use the - * indent of that other statement. - * Otherwise the indent of the current statement may be used, - * search backwards for the next "normal" statement. - */ + // We are after a "normal" statement. + // If we had another statement we can stop now and use the + // indent of that other statement. + // Otherwise the indent of the current statement may be used, + // search backwards for the next "normal" statement. else { - /* - * Skip single break line, if before a switch label. It - * may be lined up with the case label. - */ + // Skip single break line, if before a switch label. It + // may be lined up with the case label. if (lookfor == LOOKFOR_NOBREAK && cin_isbreak(skipwhite(ml_get_curline()))) { @@ -3528,31 +3387,27 @@ get_c_indent(void) continue; } - /* - * Handle "do {" line. - */ + // Handle "do {" line. if (whilelevel > 0) { l = cin_skipcomment(ml_get_curline()); if (cin_isdo(l)) { - amount = get_indent(); /* XXX */ + amount = get_indent(); // XXX --whilelevel; continue; } } - /* - * Found a terminated line above an unterminated line. Add - * the amount for a continuation line. - * x = 1; - * y = foo + - * -> here; - * or - * int x = 1; - * int foo, - * -> here; - */ + // Found a terminated line above an unterminated line. Add + // the amount for a continuation line. + // x = 1; + // y = foo + + // -> here; + // or + // int x = 1; + // int foo, + // -> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { @@ -3563,48 +3418,40 @@ get_c_indent(void) break; } - /* - * Found a terminated line above a terminated line or "if" - * etc. line. Use the amount of the line below us. - * x = 1; x = 1; - * if (asdf) y = 2; - * while (asdf) ->here; - * here; - * ->foo; - */ + // Found a terminated line above a terminated line or "if" + // etc. line. Use the amount of the line below us. + // x = 1; x = 1; + // if (asdf) y = 2; + // while (asdf) ->here; + // here; + // ->foo; if (lookfor == LOOKFOR_TERM) { if (!lookfor_break && whilelevel == 0) break; } - /* - * First line above the one we're indenting is terminated. - * To know what needs to be done look further backward for - * a terminated line. - */ + // First line above the one we're indenting is terminated. + // To know what needs to be done look further backward for + // a terminated line. else { - /* - * position the cursor over the rightmost paren, so - * that matching it will take us back to the start of - * the line. Helps for: - * func(asdr, - * asdfasdf); - * here; - */ + // position the cursor over the rightmost paren, so + // that matching it will take us back to the start of + // the line. Helps for: + // func(asdr, + // asdfasdf); + // here; term_again: l = ml_get_curline(); if (find_last_paren(l, '(', ')') && (trypos = find_match_paren( curbuf->b_ind_maxparen)) != NULL) { - /* - * Check if we are on a case label now. This is - * handled above. - * case xx: if ( asdf && - * asdf) - */ + // Check if we are on a case label now. This is + // handled above. + // case xx: if ( asdf && + // asdf) curwin->w_cursor = *trypos; l = ml_get_curline(); if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) @@ -3615,40 +3462,35 @@ term_again: } } - /* When aligning with the case statement, don't align - * with a statement after it. - * case 1: { <-- don't use this { position - * stat; - * } - * case 2: - * stat; - * } - */ + // When aligning with the case statement, don't align + // with a statement after it. + // case 1: { <-- don't use this { position + // stat; + // } + // case 2: + // stat; + // } iscase = (curbuf->b_ind_keep_case_label && cin_iscase(l, FALSE)); - /* - * Get indent and pointer to text for current line, - * ignoring any jump label. - */ + // Get indent and pointer to text for current line, + // ignoring any jump label. amount = skip_label(curwin->w_cursor.lnum, &l); if (theline[0] == '{') amount += curbuf->b_ind_open_extra; - /* See remark above: "Only add b_ind_open_extra.." */ + // See remark above: "Only add b_ind_open_extra.." l = skipwhite(l); if (*l == '{') amount -= curbuf->b_ind_open_extra; lookfor = iscase ? LOOKFOR_ANY : LOOKFOR_TERM; - /* - * When a terminated line starts with "else" skip to - * the matching "if": - * else 3; - * indent this; - * Need to use the scope of this "else". XXX - * If whilelevel != 0 continue looking for a "do {". - */ + // When a terminated line starts with "else" skip to + // the matching "if": + // else 3; + // indent this; + // Need to use the scope of this "else". XXX + // If whilelevel != 0 continue looking for a "do {". if (lookfor == LOOKFOR_TERM && *l != '}' && cin_iselse(l) @@ -3661,17 +3503,15 @@ term_again: continue; } - /* - * If we're at the end of a block, skip to the start of - * that block. - */ + // If we're at the end of a block, skip to the start of + // that block. l = ml_get_curline(); - if (find_last_paren(l, '{', '}') /* XXX */ + if (find_last_paren(l, '{', '}') // XXX && (trypos = find_start_brace()) != NULL) { curwin->w_cursor = *trypos; - /* if not "else {" check for terminated again */ - /* but skip block for "} else {" */ + // if not "else {" check for terminated again + // but skip block for "} else {" l = cin_skipcomment(ml_get_curline()); if (*l == '}' || !cin_iselse(l)) goto term_again; @@ -3684,29 +3524,27 @@ term_again: } } - /* add extra indent for a comment */ + // add extra indent for a comment if (cin_iscomment(theline)) amount += curbuf->b_ind_comment; - /* subtract extra left-shift for jump labels */ + // subtract extra left-shift for jump labels if (curbuf->b_ind_jump_label > 0 && original_line_islabel) amount -= curbuf->b_ind_jump_label; goto theend; } - /* - * ok -- we're not inside any sort of structure at all! - * - * This means we're at the top level, and everything should - * basically just match where the previous line is, except - * for the lines immediately following a function declaration, - * which are K&R-style parameters and need to be indented. - * - * if our line starts with an open brace, forget about any - * prevailing indent and make sure it looks like the start - * of a function - */ + // ok -- we're not inside any sort of structure at all! + // + // This means we're at the top level, and everything should + // basically just match where the previous line is, except + // for the lines immediately following a function declaration, + // which are K&R-style parameters and need to be indented. + // + // if our line starts with an open brace, forget about any + // prevailing indent and make sure it looks like the start + // of a function if (theline[0] == '{') { @@ -3714,13 +3552,11 @@ term_again: goto theend; } - /* - * If the NEXT line is a function declaration, the current - * line needs to be indented as a function type spec. - * Don't do this if the current line looks like a comment or if the - * current line is terminated, ie. ends in ';', or if the current line - * contains { or }: "void f() {\n if (1)" - */ + // If the NEXT line is a function declaration, the current + // line needs to be indented as a function type spec. + // Don't do this if the current line looks like a comment or if the + // current line is terminated, ie. ends in ';', or if the current line + // contains { or }: "void f() {\n if (1)" if (cur_curpos.lnum < curbuf->b_ml.ml_line_count && !cin_nocode(theline) && vim_strchr(theline, '{') == NULL @@ -3735,7 +3571,7 @@ term_again: goto theend; } - /* search backwards until we find something we recognize */ + // search backwards until we find something we recognize amount = 0; curwin->w_cursor = cur_curpos; while (curwin->w_cursor.lnum > 1) @@ -3745,10 +3581,8 @@ term_again: l = ml_get_curline(); - /* - * If we're in a comment or raw string now, skip to the start - * of it. - */ /* XXX */ + // If we're in a comment or raw string now, skip to the start + // of it. XXX if ((trypos = ind_find_start_CORS(NULL)) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; @@ -3756,10 +3590,8 @@ term_again: continue; } - /* - * Are we at the start of a cpp base class declaration or - * constructor initialization? - */ /* XXX */ + // Are we at the start of a cpp base class declaration or + // constructor initialization? XXX n = FALSE; if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') { @@ -3768,43 +3600,40 @@ term_again: } if (n) { - /* XXX */ + // XXX amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col); break; } - /* - * Skip preprocessor directives and blank lines. - */ + // Skip preprocessor directives and blank lines. if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) continue; if (cin_nocode(l)) continue; - /* - * If the previous line ends in ',', use one level of - * indentation: - * int foo, - * bar; - * do this before checking for '}' in case of eg. - * enum foobar - * { - * ... - * } foo, - * bar; - */ + // If the previous line ends in ',', use one level of + // indentation: + // int foo, + // bar; + // do this before checking for '}' in case of eg. + // enum foobar + // { + // ... + // } foo, + // bar; n = 0; if (cin_ends_in(l, (char_u *)",", NULL) || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\')) { - /* take us back to opening paren */ + // take us back to opening paren if (find_last_paren(l, '(', ')') && (trypos = find_match_paren( curbuf->b_ind_maxparen)) != NULL) curwin->w_cursor = *trypos; - /* For a line ending in ',' that is a continuation line go + /* + * For a line ending in ',' that is a continuation line go * back to the first line with a backslash: * char *foo = "bla\ * bla", @@ -3819,7 +3648,7 @@ term_again: curwin->w_cursor.col = 0; } - amount = get_indent(); /* XXX */ + amount = get_indent(); // XXX if (amount == 0) amount = cin_first_id_amount(); @@ -3828,47 +3657,38 @@ term_again: break; } - /* - * If the line looks like a function declaration, and we're - * not in a comment, put it the left margin. - */ - if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */ + // If the line looks like a function declaration, and we're + // not in a comment, put it the left margin. + if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) // XXX break; l = ml_get_curline(); - /* - * Finding the closing '}' of a previous function. Put - * current line at the left margin. For when 'cino' has "fs". - */ + // Finding the closing '}' of a previous function. Put + // current line at the left margin. For when 'cino' has "fs". if (*skipwhite(l) == '}') break; - /* (matching {) - * If the previous line ends on '};' (maybe followed by - * comments) align at column 0. For example: - * char *string_array[] = { "foo", - * / * x * / "b};ar" }; / * foobar * / - */ + // (matching {) + // If the previous line ends on '};' (maybe followed by + // comments) align at column 0. For example: + // char *string_array[] = { "foo", + // / * x * / "b};ar" }; / * foobar * / if (cin_ends_in(l, (char_u *)"};", NULL)) break; - /* - * If the previous line ends on '[' we are probably in an - * array constant: - * something = [ - * 234, <- extra indent - */ + // If the previous line ends on '[' we are probably in an + // array constant: + // something = [ + // 234, <- extra indent if (cin_ends_in(l, (char_u *)"[", NULL)) { amount = get_indent() + ind_continuation; break; } - /* - * Find a line only has a semicolon that belongs to a previous - * line ending in '}', e.g. before an #endif. Don't increase - * indent then. - */ + // Find a line only has a semicolon that belongs to a previous + // line ending in '}', e.g. before an #endif. Don't increase + // indent then. if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1)) { pos_T curpos_save = curwin->w_cursor; @@ -3887,24 +3707,20 @@ term_again: curwin->w_cursor = curpos_save; } - /* - * If the PREVIOUS line is a function declaration, the current - * line (and the ones that follow) needs to be indented as - * parameters. - */ + // If the PREVIOUS line is a function declaration, the current + // line (and the ones that follow) needs to be indented as + // parameters. if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0)) { amount = curbuf->b_ind_param; break; } - /* - * If the previous line ends in ';' and the line before the - * previous line ends in ',' or '\', ident to column zero: - * int foo, - * bar; - * indent_to_0 here; - */ + // If the previous line ends in ';' and the line before the + // previous line ends in ',' or '\', ident to column zero: + // int foo, + // bar; + // indent_to_0 here; if (cin_ends_in(l, (char_u *)";", NULL)) { l = ml_get(curwin->w_cursor.lnum - 1); @@ -3914,26 +3730,25 @@ term_again: l = ml_get_curline(); } - /* - * Doesn't look like anything interesting -- so just - * use the indent of this line. - * - * Position the cursor over the rightmost paren, so that - * matching it will take us back to the start of the line. - */ + // Doesn't look like anything interesting -- so just + // use the indent of this line. + // + // Position the cursor over the rightmost paren, so that + // matching it will take us back to the start of the line. find_last_paren(l, '(', ')'); if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) curwin->w_cursor = *trypos; - amount = get_indent(); /* XXX */ + amount = get_indent(); // XXX break; } - /* add extra indent for a comment */ + // add extra indent for a comment if (cin_iscomment(theline)) amount += curbuf->b_ind_comment; - /* add extra indent if the previous line ended in a backslash: + /* + * add extra indent if the previous line ended in a backslash: * "asdfasdf\ * here"; * char *foo = "asdf\ @@ -3957,7 +3772,7 @@ theend: amount = 0; laterend: - /* put the cursor back where it belongs */ + // put the cursor back where it belongs curwin->w_cursor = cur_curpos; vim_free(linecopy); @@ -3995,38 +3810,30 @@ find_match(int lookfor, linenr_T ourscope) look = cin_skipcomment(ml_get_curline()); if (cin_iselse(look) || cin_isif(look) - || cin_isdo(look) /* XXX */ + || cin_isdo(look) // XXX || cin_iswhileofdo(look, curwin->w_cursor.lnum)) { - /* - * if we've gone outside the braces entirely, - * we must be out of scope... - */ - theirscope = find_start_brace(); /* XXX */ + // if we've gone outside the braces entirely, + // we must be out of scope... + theirscope = find_start_brace(); // XXX if (theirscope == NULL) break; - /* - * and if the brace enclosing this is further - * back than the one enclosing the else, we're - * out of luck too. - */ + // and if the brace enclosing this is further + // back than the one enclosing the else, we're + // out of luck too. if (theirscope->lnum < ourscope) break; - /* - * and if they're enclosed in a *deeper* brace, - * then we can ignore it because it's in a - * different scope... - */ + // and if they're enclosed in a *deeper* brace, + // then we can ignore it because it's in a + // different scope... if (theirscope->lnum > ourscope) continue; - /* - * if it was an "else" (that's not an "else if") - * then we need to go back to another if, so - * increment elselevel - */ + // if it was an "else" (that's not an "else if") + // then we need to go back to another if, so + // increment elselevel look = cin_skipcomment(ml_get_curline()); if (cin_iselse(look)) { @@ -4036,38 +3843,32 @@ find_match(int lookfor, linenr_T ourscope) continue; } - /* - * if it was a "while" then we need to go back to - * another "do", so increment whilelevel. XXX - */ + // if it was a "while" then we need to go back to + // another "do", so increment whilelevel. XXX if (cin_iswhileofdo(look, curwin->w_cursor.lnum)) { ++whilelevel; continue; } - /* If it's an "if" decrement elselevel */ + // If it's an "if" decrement elselevel look = cin_skipcomment(ml_get_curline()); if (cin_isif(look)) { elselevel--; - /* - * When looking for an "if" ignore "while"s that - * get in the way. - */ + // When looking for an "if" ignore "while"s that + // get in the way. if (elselevel == 0 && lookfor == LOOKFOR_IF) whilelevel = 0; } - /* If it's a "do" decrement whilelevel */ + // If it's a "do" decrement whilelevel if (cin_isdo(look)) whilelevel--; - /* - * if we've used up all the elses, then - * this must be the if that we want! - * match the indent level of that if. - */ + // if we've used up all the elses, then + // this must be the if that we want! + // match the indent level of that if. if (elselevel <= 0 && whilelevel <= 0) { return OK; @@ -4093,8 +3894,8 @@ get_expr_indent(void) int use_sandbox = was_set_insecurely((char_u *)"indentexpr", OPT_LOCAL); - /* Save and restore cursor position and curswant, in case it was changed - * via :normal commands */ + // Save and restore cursor position and curswant, in case it was changed + // via :normal commands save_pos = curwin->w_cursor; save_curswant = curwin->w_curswant; save_set_curswant = curwin->w_set_curswant; @@ -4103,8 +3904,8 @@ get_expr_indent(void) ++sandbox; ++textlock; - /* Need to make a copy, the 'indentexpr' option could be changed while - * evaluating it. */ + // Need to make a copy, the 'indentexpr' option could be changed while + // evaluating it. inde_copy = vim_strsave(curbuf->b_p_inde); if (inde_copy != NULL) { @@ -4116,9 +3917,9 @@ get_expr_indent(void) --sandbox; --textlock; - /* Restore the cursor position so that 'indentexpr' doesn't need to. - * Pretend to be in Insert mode, allow cursor past end of line for "o" - * command. */ + // Restore the cursor position so that 'indentexpr' doesn't need to. + // Pretend to be in Insert mode, allow cursor past end of line for "o" + // command. save_State = State; State = INSERT; curwin->w_cursor = save_pos; @@ -4127,7 +3928,7 @@ get_expr_indent(void) check_cursor(); State = save_State; - /* If there is an error, just keep the current indent. */ + // If there is an error, just keep the current indent. if (indent < 0) indent = get_indent(); @@ -4163,21 +3964,19 @@ in_cinkeys( int i; if (keytyped == NUL) - /* Can happen with CTRL-Y and CTRL-E on a short line. */ + // Can happen with CTRL-Y and CTRL-E on a short line. return FALSE; #ifdef FEAT_EVAL if (*curbuf->b_p_inde != NUL) - look = curbuf->b_p_indk; /* 'indentexpr' set: use 'indentkeys' */ + look = curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys' else #endif - look = curbuf->b_p_cink; /* 'indentexpr' empty: use 'cinkeys' */ + look = curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys' while (*look) { - /* - * Find out if we want to try a match with this key, depending on - * 'when' and a '*' or '!' before the key. - */ + // Find out if we want to try a match with this key, depending on + // 'when' and a '*' or '!' before the key. switch (when) { case '*': try_match = (*look == '*'); break; @@ -4187,10 +3986,8 @@ in_cinkeys( if (*look == '*' || *look == '!') ++look; - /* - * If there is a '0', only accept a match if the line is empty. - * But may still match when typing last char of a word. - */ + // If there is a '0', only accept a match if the line is empty. + // But may still match when typing last char of a word. if (*look == '0') { try_match_word = try_match; @@ -4201,9 +3998,7 @@ in_cinkeys( else try_match_word = FALSE; - /* - * does it look like a control character? - */ + // does it look like a control character? if (*look == '^' #ifdef EBCDIC && (Ctrl_chr(look[1]) != 0) @@ -4216,10 +4011,8 @@ in_cinkeys( return TRUE; look += 2; } - /* - * 'o' means "o" command, open forward. - * 'O' means "O" command, open backward. - */ + // 'o' means "o" command, open forward. + // 'O' means "O" command, open backward. else if (*look == 'o') { if (try_match && keytyped == KEY_OPEN_FORW) @@ -4233,10 +4026,8 @@ in_cinkeys( ++look; } - /* - * 'e' means to check for "else" at start of line and just before the - * cursor. - */ + // 'e' means to check for "else" at start of line and just before the + // cursor. else if (*look == 'e') { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) @@ -4249,11 +4040,9 @@ in_cinkeys( ++look; } - /* - * ':' only causes an indent if it is at the end of a label or case - * statement, or when it was before typing the ':' (to fix - * class::method for C++). - */ + // ':' only causes an indent if it is at the end of a label or case + // statement, or when it was before typing the ':' (to fix + // class::method for C++). else if (*look == ':') { if (try_match && keytyped == ':') @@ -4261,7 +4050,7 @@ in_cinkeys( p = ml_get_curline(); if (cin_iscase(p, FALSE) || cin_isscopedecl(p) || cin_islabel()) return TRUE; - /* Need to get the line again after cin_islabel(). */ + // Need to get the line again after cin_islabel(). p = ml_get_curline(); if (curwin->w_cursor.col > 2 && p[curwin->w_cursor.col - 1] == ':' @@ -4280,18 +4069,14 @@ in_cinkeys( } - /* - * Is it a key in <>, maybe? - */ + // Is it a key in <>, maybe? else if (*look == '<') { if (try_match) { - /* - * make up some named keys , , , <0>, <>>, <<>, <*>, - * <:> and so that people can re-indent on o, O, e, 0, <, - * >, *, : and ! keys if they really really want to. - */ + // make up some named keys , , , <0>, <>>, <<>, <*>, + // <:> and so that people can re-indent on o, O, e, 0, <, + // >, *, : and ! keys if they really really want to. if (vim_strchr((char_u *)"<>!*oOe0:", look[1]) != NULL && keytyped == look[1]) return TRUE; @@ -4305,9 +4090,7 @@ in_cinkeys( look++; } - /* - * Is it a word: "=word"? - */ + // Is it a word: "=word"? else if (*look == '=' && look[1] != ',' && look[1] != NUL) { ++look; @@ -4331,8 +4114,8 @@ in_cinkeys( { char_u *s; - /* Just completed a word, check if it starts with "look". - * search back for the start of a word. */ + // Just completed a word, check if it starts with "look". + // search back for the start of a word. line = ml_get_curline(); if (has_mbyte) { @@ -4357,7 +4140,7 @@ in_cinkeys( } else #endif - /* TODO: multi-byte */ + // TODO: multi-byte if (keytyped == (int)p[-1] || (icase && keytyped < 256 && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { @@ -4372,8 +4155,8 @@ in_cinkeys( } if (match && try_match_word && !try_match) { - /* "0=word": Check if there are only blanks before the - * word. */ + // "0=word": Check if there are only blanks before the + // word. if (getwhitecols_curline() != (int)(curwin->w_cursor.col - (p - look))) match = FALSE; @@ -4384,9 +4167,7 @@ in_cinkeys( look = p; } - /* - * ok, it's a boring generic character. - */ + // ok, it's a boring generic character. else { if (try_match && *look == keytyped) @@ -4395,14 +4176,12 @@ in_cinkeys( ++look; } - /* - * Skip over ", ". - */ + // Skip over ", ". look = skip_to_option_part(look); } return FALSE; } -#endif /* FEAT_CINDENT */ +#endif // FEAT_CINDENT #if defined(FEAT_LISP) || defined(PROTO) @@ -4450,7 +4229,7 @@ get_lisp_indent(void) int parencount, quotecount; int vi_lisp; - /* Set vi_lisp to use the vi-compatible method */ + // Set vi_lisp to use the vi-compatible method vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL); realpos = curwin->w_cursor; @@ -4467,8 +4246,8 @@ get_lisp_indent(void) } if (pos != NULL) { - /* Extra trick: Take the indent of the first previous non-white - * line that is at the same () level. */ + // Extra trick: Take the indent of the first previous non-white + // line that is at the same () level. amount = -1; parencount = 0; @@ -4494,7 +4273,7 @@ get_lisp_indent(void) { while (*++that && *that != '"') { - /* skipping escaped characters in the string */ + // skipping escaped characters in the string if (*that == '\\') { if (*++that == NUL) @@ -4540,13 +4319,11 @@ get_lisp_indent(void) col--; } - /* - * Some keywords require "body" indenting rules (the - * non-standard-lisp ones are Scheme special forms): - * - * (let ((a 1)) instead (let ((a 1)) - * (...)) of (...)) - */ + // Some keywords require "body" indenting rules (the + // non-standard-lisp ones are Scheme special forms): + // + // (let ((a 1)) instead (let ((a 1)) + // (...)) of (...)) if (!vi_lisp && (*that == '(' || *that == '[') && lisp_match(that + 1)) @@ -4563,10 +4340,10 @@ get_lisp_indent(void) ++that; } - if (*that && *that != ';') /* not a comment line */ + if (*that && *that != ';') // not a comment line { - /* test *that != '(' to accommodate first let/do - * argument if it is more than one line */ + // test *that != '(' to accommodate first let/do + // argument if it is more than one line if (!vi_lisp && *that != '(' && *that != '[') firsttry++; @@ -4617,13 +4394,13 @@ get_lisp_indent(void) } } else - amount = 0; /* no matching '(' or '[' found, use zero indent */ + amount = 0; // no matching '(' or '[' found, use zero indent curwin->w_cursor = realpos; return amount; } -#endif /* FEAT_LISP */ +#endif // FEAT_LISP #if defined(FEAT_CINDENT) || defined(PROTO) /* @@ -4658,7 +4435,7 @@ fixthisline(int (*get_the_indent)(void)) { change_indent(INDENT_SET, amount, FALSE, 0, TRUE); if (linewhite(curwin->w_cursor.lnum)) - did_ai = TRUE; /* delete the indent if the line stays empty */ + did_ai = TRUE; // delete the indent if the line stays empty } } diff --git a/src/version.c b/src/version.c index 888bc256f8..24a9fb31b0 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 874, /**/ 873, /**/ From 94688b8a2a1fc3d6c8e49151b9533ec1c0a6757f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 4 Feb 2019 21:02:06 +0100 Subject: [PATCH 02/75] Add missing matchit file. --- .../dist/opt/matchit/autoload/matchit.vim | 754 ++++++++++++++++++ 1 file changed, 754 insertions(+) create mode 100644 runtime/pack/dist/opt/matchit/autoload/matchit.vim diff --git a/runtime/pack/dist/opt/matchit/autoload/matchit.vim b/runtime/pack/dist/opt/matchit/autoload/matchit.vim new file mode 100644 index 0000000000..abf06d3c4c --- /dev/null +++ b/runtime/pack/dist/opt/matchit/autoload/matchit.vim @@ -0,0 +1,754 @@ +" matchit.vim: (global plugin) Extended "%" matching +" autload script of matchit plugin, see ../plugin/matchit.vim +" Last Change: 2019 Jan 28 + +let s:last_mps = "" +let s:last_words = ":" +let s:patBR = "" + +let s:save_cpo = &cpo +set cpo&vim + +" Auto-complete mappings: (not yet "ready for prime time") +" TODO Read :help write-plugin for the "right" way to let the user +" specify a key binding. +" let g:match_auto = '' +" let g:match_autoCR = '' +" if exists("g:match_auto") +" execute "inoremap " . g:match_auto . ' x"=Autocomplete()Pls' +" endif +" if exists("g:match_autoCR") +" execute "inoremap " . g:match_autoCR . ' =Autocomplete()' +" endif +" if exists("g:match_gthhoh") +" execute "inoremap " . g:match_gthhoh . ' :call Gthhoh()' +" endif " gthhoh = "Get the heck out of here!" + +let s:notslash = '\\\@1" + elseif a:mode == "o" && mode(1) !~# '[vV]' + exe "norm! v" + endif + " In s:CleanUp(), we may need to check whether the cursor moved forward. + let startpos = [line("."), col(".")] + " Use default behavior if called with a count. + if v:count + exe "normal! " . v:count . "%" + return s:CleanUp(restore_options, a:mode, startpos) + end + + " First step: if not already done, set the script variables + " s:do_BR flag for whether there are backrefs + " s:pat parsed version of b:match_words + " s:all regexp based on s:pat and the default groups + if !exists("b:match_words") || b:match_words == "" + let match_words = "" + elseif b:match_words =~ ":" + let match_words = b:match_words + else + " Allow b:match_words = "GetVimMatchWords()" . + execute "let match_words =" b:match_words + endif +" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion! + if (match_words != s:last_words) || (&mps != s:last_mps) + \ || exists("b:match_debug") + let s:last_mps = &mps + " quote the special chars in 'matchpairs', replace [,:] with \| and then + " append the builtin pairs (/*, */, #if, #ifdef, #ifndef, #else, #elif, + " #endif) + let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . + \ '\/\*:\*\/,#\s*if\%(n\=def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>' + " s:all = pattern with all the keywords + let match_words = match_words . (strlen(match_words) ? "," : "") . default + let s:last_words = match_words + if match_words !~ s:notslash . '\\\d' + let s:do_BR = 0 + let s:pat = match_words + else + let s:do_BR = 1 + let s:pat = s:ParseWords(match_words) + endif + let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g') + " Just in case there are too many '\(...)' groups inside the pattern, make + " sure to use \%(...) groups, so that error E872 can be avoided + let s:all = substitute(s:all, '\\(', '\\%(', 'g') + let s:all = '\%(' . s:all . '\)' + if exists("b:match_debug") + let b:match_pat = s:pat + endif + " Reconstruct the version with unresolved backrefs. + let s:patBR = substitute(match_words.',', + \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') + let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g') + endif + + " Second step: set the following local variables: + " matchline = line on which the cursor started + " curcol = number of characters before match + " prefix = regexp for start of line to start of match + " suffix = regexp for end of match to end of line + " Require match to end on or after the cursor and prefer it to + " start on or before the cursor. + let matchline = getline(startpos[0]) + if a:word != '' + " word given + if a:word !~ s:all + echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE + return s:CleanUp(restore_options, a:mode, startpos) + endif + let matchline = a:word + let curcol = 0 + let prefix = '^\%(' + let suffix = '\)$' + " Now the case when "word" is not given + else " Find the match that ends on or after the cursor and set curcol. + let regexp = s:Wholematch(matchline, s:all, startpos[1]-1) + let curcol = match(matchline, regexp) + " If there is no match, give up. + if curcol == -1 + return s:CleanUp(restore_options, a:mode, startpos) + endif + let endcol = matchend(matchline, regexp) + let suf = strlen(matchline) - endcol + let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(') + let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$') + endif + if exists("b:match_debug") + let b:match_match = matchstr(matchline, regexp) + let b:match_col = curcol+1 + endif + + " Third step: Find the group and single word that match, and the original + " (backref) versions of these. Then, resolve the backrefs. + " Set the following local variable: + " group = colon-separated list of patterns, one of which matches + " = ini:mid:fin or ini:fin + " + " Now, set group and groupBR to the matching group: 'if:endif' or + " 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns + " group . "," . groupBR, and we pick it apart. + let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, s:patBR) + let i = matchend(group, s:notslash . ",") + let groupBR = strpart(group, i) + let group = strpart(group, 0, i-1) + " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix + if s:do_BR " Do the hard part: resolve those backrefs! + let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline) + endif + if exists("b:match_debug") + let b:match_wholeBR = groupBR + let i = matchend(groupBR, s:notslash . ":") + let b:match_iniBR = strpart(groupBR, 0, i-1) + endif + + " Fourth step: Set the arguments for searchpair(). + let i = matchend(group, s:notslash . ":") + let j = matchend(group, '.*' . s:notslash . ":") + let ini = strpart(group, 0, i-1) + let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g') + let fin = strpart(group, j) + "Un-escape the remaining , and : characters. + let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') + let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') + let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') + " searchpair() requires that these patterns avoid \(\) groups. + let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g') + let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g') + let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g') + " Set mid. This is optimized for readability, not micro-efficiency! + if a:forward && matchline =~ prefix . fin . suffix + \ || !a:forward && matchline =~ prefix . ini . suffix + let mid = "" + endif + " Set flag. This is optimized for readability, not micro-efficiency! + if a:forward && matchline =~ prefix . fin . suffix + \ || !a:forward && matchline !~ prefix . ini . suffix + let flag = "bW" + else + let flag = "W" + endif + " Set skip. + if exists("b:match_skip") + let skip = b:match_skip + elseif exists("b:match_comment") " backwards compatibility and testing! + let skip = "r:" . b:match_comment + else + let skip = 's:comment\|string' + endif + let skip = s:ParseSkip(skip) + if exists("b:match_debug") + let b:match_ini = ini + let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin + endif + + " Fifth step: actually start moving the cursor and call searchpair(). + " Later, :execute restore_cursor to get to the original screen. + let view = winsaveview() + call cursor(0, curcol + 1) + if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) + let skip = "0" + else + execute "if " . skip . "| let skip = '0' | endif" + endif + let sp_return = searchpair(ini, mid, fin, flag, skip) + let final_position = "call cursor(" . line(".") . "," . col(".") . ")" + " Restore cursor position and original screen. + call winrestview(view) + normal! m' + if sp_return > 0 + execute final_position + endif + return s:CleanUp(restore_options, a:mode, startpos, mid.'\|'.fin) +endfun + +" Restore options and do some special handling for Operator-pending mode. +" The optional argument is the tail of the matching group. +fun! s:CleanUp(options, mode, startpos, ...) + if strlen(a:options) + execute "set" a:options + endif + " Open folds, if appropriate. + if a:mode != "o" + if &foldopen =~ "percent" + normal! zv + endif + " In Operator-pending mode, we want to include the whole match + " (for example, d%). + " This is only a problem if we end up moving in the forward direction. + elseif (a:startpos[0] < line(".")) || + \ (a:startpos[0] == line(".") && a:startpos[1] < col(".")) + if a:0 + " Check whether the match is a single character. If not, move to the + " end of the match. + let matchline = getline(".") + let currcol = col(".") + let regexp = s:Wholematch(matchline, a:1, currcol-1) + let endcol = matchend(matchline, regexp) + if endcol > currcol " This is NOT off by one! + call cursor(0, endcol) + endif + endif " a:0 + endif " a:mode != "o" && etc. + return 0 +endfun + +" Example (simplified HTML patterns): if +" a:groupBR = '<\(\k\+\)>:' +" a:prefix = '^.\{3}\(' +" a:group = '<\(\k\+\)>:' +" a:suffix = '\).\{2}$' +" a:matchline = "12312" or "12312" +" then extract "tag" from a:matchline and return ":" . +fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline) + if a:matchline !~ a:prefix . + \ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix + return a:group + endif + let i = matchend(a:groupBR, s:notslash . ':') + let ini = strpart(a:groupBR, 0, i-1) + let tailBR = strpart(a:groupBR, i) + let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix, + \ a:groupBR) + let i = matchend(word, s:notslash . ":") + let wordBR = strpart(word, i) + let word = strpart(word, 0, i-1) + " Now, a:matchline =~ a:prefix . word . a:suffix + if wordBR != ini + let table = s:Resolve(ini, wordBR, "table") + else + let table = "" + let d = 0 + while d < 10 + if tailBR =~ s:notslash . '\\' . d + let table = table . d + else + let table = table . "-" + endif + let d = d + 1 + endwhile + endif + let d = 9 + while d + if table[d] != "-" + let backref = substitute(a:matchline, a:prefix.word.a:suffix, + \ '\'.table[d], "") + " Are there any other characters that should be escaped? + let backref = escape(backref, '*,:') + execute s:Ref(ini, d, "start", "len") + let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len) + let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d, + \ escape(backref, '\\&'), 'g') + endif + let d = d-1 + endwhile + if exists("b:match_debug") + if s:do_BR + let b:match_table = table + let b:match_word = word + else + let b:match_table = "" + let b:match_word = "" + endif + endif + return ini . ":" . tailBR +endfun + +" Input a comma-separated list of groups with backrefs, such as +" a:groups = '\(foo\):end\1,\(bar\):end\1' +" and return a comma-separated list of groups with backrefs replaced: +" return '\(foo\):end\(foo\),\(bar\):end\(bar\)' +fun! s:ParseWords(groups) + let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g') + let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g') + let parsed = "" + while groups =~ '[^,:]' + let i = matchend(groups, s:notslash . ':') + let j = matchend(groups, s:notslash . ',') + let ini = strpart(groups, 0, i-1) + let tail = strpart(groups, i, j-i-1) . ":" + let groups = strpart(groups, j) + let parsed = parsed . ini + let i = matchend(tail, s:notslash . ':') + while i != -1 + " In 'if:else:endif', ini='if' and word='else' and then word='endif'. + let word = strpart(tail, 0, i-1) + let tail = strpart(tail, i) + let i = matchend(tail, s:notslash . ':') + let parsed = parsed . ":" . s:Resolve(ini, word, "word") + endwhile " Now, tail has been used up. + let parsed = parsed . "," + endwhile " groups =~ '[^,:]' + let parsed = substitute(parsed, ',$', '', '') + return parsed +endfun + +" TODO I think this can be simplified and/or made more efficient. +" TODO What should I do if a:start is out of range? +" Return a regexp that matches all of a:string, such that +" matchstr(a:string, regexp) represents the match for a:pat that starts +" as close to a:start as possible, before being preferred to after, and +" ends after a:start . +" Usage: +" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1) +" let i = match(getline("."), regexp) +" let j = matchend(getline("."), regexp) +" let match = matchstr(getline("."), regexp) +fun! s:Wholematch(string, pat, start) + let group = '\%(' . a:pat . '\)' + let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^') + let len = strlen(a:string) + let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$') + if a:string !~ prefix . group . suffix + let prefix = '' + endif + return prefix . group . suffix +endfun + +" No extra arguments: s:Ref(string, d) will +" find the d'th occurrence of '\(' and return it, along with everything up +" to and including the matching '\)'. +" One argument: s:Ref(string, d, "start") returns the index of the start +" of the d'th '\(' and any other argument returns the length of the group. +" Two arguments: s:Ref(string, d, "foo", "bar") returns a string to be +" executed, having the effect of +" :let foo = s:Ref(string, d, "start") +" :let bar = s:Ref(string, d, "len") +fun! s:Ref(string, d, ...) + let len = strlen(a:string) + if a:d == 0 + let start = 0 + else + let cnt = a:d + let match = a:string + while cnt + let cnt = cnt - 1 + let index = matchend(match, s:notslash . '\\(') + if index == -1 + return "" + endif + let match = strpart(match, index) + endwhile + let start = len - strlen(match) + if a:0 == 1 && a:1 == "start" + return start - 2 + endif + let cnt = 1 + while cnt + let index = matchend(match, s:notslash . '\\(\|\\)') - 1 + if index == -2 + return "" + endif + " Increment if an open, decrement if a ')': + let cnt = cnt + (match[index]=="(" ? 1 : -1) " ')' + let match = strpart(match, index+1) + endwhile + let start = start - 2 + let len = len - start - strlen(match) + endif + if a:0 == 1 + return len + elseif a:0 == 2 + return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len + else + return strpart(a:string, start, len) + endif +endfun + +" Count the number of disjoint copies of pattern in string. +" If the pattern is a literal string and contains no '0' or '1' characters +" then s:Count(string, pattern, '0', '1') should be faster than +" s:Count(string, pattern). +fun! s:Count(string, pattern, ...) + let pat = escape(a:pattern, '\\') + if a:0 > 1 + let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g") + let foo = substitute(a:string, pat, a:2, "g") + let foo = substitute(foo, '[^' . a:2 . ']', "", "g") + return strlen(foo) + endif + let result = 0 + let foo = a:string + let index = matchend(foo, pat) + while index != -1 + let result = result + 1 + let foo = strpart(foo, index) + let index = matchend(foo, pat) + endwhile + return result +endfun + +" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where +" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'. That is, the first +" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this +" indicates that all other instances of '\1' in target are to be replaced +" by '\3'. The hard part is dealing with nesting... +" Note that ":" is an illegal character for source and target, +" unless it is preceded by "\". +fun! s:Resolve(source, target, output) + let word = a:target + let i = matchend(word, s:notslash . '\\\d') - 1 + let table = "----------" + while i != -2 " There are back references to be replaced. + let d = word[i] + let backref = s:Ref(a:source, d) + " The idea is to replace '\d' with backref. Before we do this, + " replace any \(\) groups in backref with :1, :2, ... if they + " correspond to the first, second, ... group already inserted + " into backref. Later, replace :1 with \1 and so on. The group + " number w+b within backref corresponds to the group number + " s within a:source. + " w = number of '\(' in word before the current one + let w = s:Count( + \ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1') + let b = 1 " number of the current '\(' in backref + let s = d " number of the current '\(' in a:source + while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1') + \ && s < 10 + if table[s] == "-" + if w + b < 10 + " let table[s] = w + b + let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1) + endif + let b = b + 1 + let s = s + 1 + else + execute s:Ref(backref, b, "start", "len") + let ref = strpart(backref, start, len) + let backref = strpart(backref, 0, start) . ":". table[s] + \ . strpart(backref, start+len) + let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1') + endif + endwhile + let word = strpart(word, 0, i-1) . backref . strpart(word, i+1) + let i = matchend(word, s:notslash . '\\\d') - 1 + endwhile + let word = substitute(word, s:notslash . '\zs:', '\\', 'g') + if a:output == "table" + return table + elseif a:output == "word" + return word + else + return table . word + endif +endfun + +" Assume a:comma = ",". Then the format for a:patterns and a:1 is +" a:patterns = ",,..." +" a:1 = ",,..." +" If is the first pattern that matches a:string then return +" if no optional arguments are given; return , if a:1 is given. +fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...) + let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma) + let i = matchend(tail, s:notslash . a:comma) + if a:0 + let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma) + let j = matchend(alttail, s:notslash . a:comma) + endif + let current = strpart(tail, 0, i-1) + if a:branch == "" + let currpat = current + else + let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g') + endif + while a:string !~ a:prefix . currpat . a:suffix + let tail = strpart(tail, i) + let i = matchend(tail, s:notslash . a:comma) + if i == -1 + return -1 + endif + let current = strpart(tail, 0, i-1) + if a:branch == "" + let currpat = current + else + let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g') + endif + if a:0 + let alttail = strpart(alttail, j) + let j = matchend(alttail, s:notslash . a:comma) + endif + endwhile + if a:0 + let current = current . a:comma . strpart(alttail, 0, j-1) + endif + return current +endfun + +fun! matchit#Match_debug() + let b:match_debug = 1 " Save debugging information. + " pat = all of b:match_words with backrefs parsed + amenu &Matchit.&pat :echo b:match_pat + " match = bit of text that is recognized as a match + amenu &Matchit.&match :echo b:match_match + " curcol = cursor column of the start of the matching text + amenu &Matchit.&curcol :echo b:match_col + " wholeBR = matching group, original version + amenu &Matchit.wh&oleBR :echo b:match_wholeBR + " iniBR = 'if' piece, original version + amenu &Matchit.ini&BR :echo b:match_iniBR + " ini = 'if' piece, with all backrefs resolved from match + amenu &Matchit.&ini :echo b:match_ini + " tail = 'else\|endif' piece, with all backrefs resolved from match + amenu &Matchit.&tail :echo b:match_tail + " fin = 'endif' piece, with all backrefs resolved from match + amenu &Matchit.&word :echo b:match_word + " '\'.d in ini refers to the same thing as '\'.table[d] in word. + amenu &Matchit.t&able :echo '0:' . b:match_table . ':9' +endfun + +" Jump to the nearest unmatched "(" or "if" or "" if a:spflag == "bW" +" or the nearest unmatched "" or "endif" or ")" if a:spflag == "W". +" Return a "mark" for the original position, so that +" let m = MultiMatch("bW", "n") ... call winrestview(m) +" will return to the original position. If there is a problem, do not +" move the cursor and return {}, unless a count is given, in which case +" go up or down as many levels as possible and again return {}. +" TODO This relies on the same patterns as % matching. It might be a good +" idea to give it its own matching patterns. +fun! matchit#MultiMatch(spflag, mode) + let restore_options = s:RestoreOptions() + let startpos = [line("."), col(".")] + " save v:count1 variable, might be reset from the restore_cursor command + let level = v:count1 + if a:mode == "o" && mode(1) !~# '[vV]' + exe "norm! v" + endif + + " First step: if not already done, set the script variables + " s:do_BR flag for whether there are backrefs + " s:pat parsed version of b:match_words + " s:all regexp based on s:pat and the default groups + " This part is copied and slightly modified from matchit#Match_wrapper(). + if !exists("b:match_words") || b:match_words == "" + let match_words = "" + " Allow b:match_words = "GetVimMatchWords()" . + elseif b:match_words =~ ":" + let match_words = b:match_words + else + execute "let match_words =" b:match_words + endif + if (match_words != s:last_words) || (&mps != s:last_mps) || + \ exists("b:match_debug") + let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . + \ '\/\*:\*\/,#\s*if\%(n\=def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>' + let s:last_mps = &mps + let match_words = match_words . (strlen(match_words) ? "," : "") . default + let s:last_words = match_words + if match_words !~ s:notslash . '\\\d' + let s:do_BR = 0 + let s:pat = match_words + else + let s:do_BR = 1 + let s:pat = s:ParseWords(match_words) + endif + let s:all = '\%(' . substitute(s:pat, '[,:]\+', '\\|', 'g') . '\)' + if exists("b:match_debug") + let b:match_pat = s:pat + endif + " Reconstruct the version with unresolved backrefs. + let s:patBR = substitute(match_words.',', + \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') + let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g') + endif + + " Second step: figure out the patterns for searchpair() + " and save the screen, cursor position, and 'ignorecase'. + " - TODO: A lot of this is copied from matchit#Match_wrapper(). + " - maybe even more functionality should be split off + " - into separate functions! + let openlist = split(s:pat . ',', s:notslash . '\zs:.\{-}' . s:notslash . ',') + let midclolist = split(',' . s:pat, s:notslash . '\zs,.\{-}' . s:notslash . ':') + call map(midclolist, {-> split(v:val, s:notslash . ':')}) + let closelist = [] + let middlelist = [] + call map(midclolist, {i,v -> [extend(closelist, v[-1 : -1]), + \ extend(middlelist, v[0 : -2])]}) + call map(openlist, {i,v -> v =~# s:notslash . '\\|' ? '\%(' . v . '\)' : v}) + call map(middlelist, {i,v -> v =~# s:notslash . '\\|' ? '\%(' . v . '\)' : v}) + call map(closelist, {i,v -> v =~# s:notslash . '\\|' ? '\%(' . v . '\)' : v}) + let open = join(openlist, ',') + let middle = join(middlelist, ',') + let close = join(closelist, ',') + if exists("b:match_skip") + let skip = b:match_skip + elseif exists("b:match_comment") " backwards compatibility and testing! + let skip = "r:" . b:match_comment + else + let skip = 's:comment\|string' + endif + let skip = s:ParseSkip(skip) + let view = winsaveview() + + " Third step: call searchpair(). + " Replace '\('--but not '\\('--with '\%(' and ',' with '\|'. + let openpat = substitute(open, '\%(' . s:notslash . '\)\@<=\\(', '\\%(', 'g') + let openpat = substitute(openpat, ',', '\\|', 'g') + let closepat = substitute(close, '\%(' . s:notslash . '\)\@<=\\(', '\\%(', 'g') + let closepat = substitute(closepat, ',', '\\|', 'g') + let middlepat = substitute(middle, '\%(' . s:notslash . '\)\@<=\\(', '\\%(', 'g') + let middlepat = substitute(middlepat, ',', '\\|', 'g') + + if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) + let skip = '0' + else + try + execute "if " . skip . "| let skip = '0' | endif" + catch /^Vim\%((\a\+)\)\=:E363/ + " We won't find anything, so skip searching, should keep Vim responsive. + return {} + endtry + endif + mark ' + while level + if searchpair(openpat, middlepat, closepat, a:spflag, skip) < 1 + call s:CleanUp(restore_options, a:mode, startpos) + return {} + endif + let level = level - 1 + endwhile + + " Restore options and return a string to restore the original position. + call s:CleanUp(restore_options, a:mode, startpos) + return view +endfun + +" Search backwards for "if" or "while" or "" or ... +" and return "endif" or "endwhile" or "" or ... . +" For now, this uses b:match_words and the same script variables +" as matchit#Match_wrapper() . Later, it may get its own patterns, +" either from a buffer variable or passed as arguments. +" fun! s:Autocomplete() +" echo "autocomplete not yet implemented :-(" +" if !exists("b:match_words") || b:match_words == "" +" return "" +" end +" let startpos = matchit#MultiMatch("bW") +" +" if startpos == "" +" return "" +" endif +" " - TODO: figure out whether 'if' or '' matched, and construct +" " - the appropriate closing. +" let matchline = getline(".") +" let curcol = col(".") - 1 +" " - TODO: Change the s:all argument if there is a new set of match pats. +" let regexp = s:Wholematch(matchline, s:all, curcol) +" let suf = strlen(matchline) - matchend(matchline, regexp) +" let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(') +" let suffix = (suf ? '\).\{' . suf . '}$' : '\)$') +" " Reconstruct the version with unresolved backrefs. +" let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g') +" let patBR = substitute(patBR, ':\{2,}', ':', "g") +" " Now, set group and groupBR to the matching group: 'if:endif' or +" " 'while:endwhile' or whatever. +" let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR) +" let i = matchend(group, s:notslash . ",") +" let groupBR = strpart(group, i) +" let group = strpart(group, 0, i-1) +" " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix +" if s:do_BR +" let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline) +" endif +" " let g:group = group +" +" " - TODO: Construct the closing from group. +" let fake = "end" . expand("") +" execute startpos +" return fake +" endfun + +" Close all open structures. "Get the heck out of here!" +" fun! s:Gthhoh() +" let close = s:Autocomplete() +" while strlen(close) +" put=close +" let close = s:Autocomplete() +" endwhile +" endfun + +" Parse special strings as typical skip arguments for searchpair(): +" s:foo becomes (current syntax item) =~ foo +" S:foo becomes (current syntax item) !~ foo +" r:foo becomes (line before cursor) =~ foo +" R:foo becomes (line before cursor) !~ foo +fun! s:ParseSkip(str) + let skip = a:str + if skip[1] == ":" + if skip[0] == "s" + let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . + \ strpart(skip,2) . "'" + elseif skip[0] == "S" + let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" . + \ strpart(skip,2) . "'" + elseif skip[0] == "r" + let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'" + elseif skip[0] == "R" + let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'" + endif + endif + return skip +endfun + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:sts=2:sw=2:et: From 71b13e92ae580038b8aecbb783296c577ca2ba5a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 4 Feb 2019 21:14:45 +0100 Subject: [PATCH 03/75] patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested Problem: Not all errors of marks and findfile()/finddir() are tested. Solution: Add more test coverage. (Dominique Pelle) --- src/testdir/test_findfile.vim | 16 ++++++++++++++ src/testdir/test_marks.vim | 41 +++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 59 insertions(+) diff --git a/src/testdir/test_findfile.vim b/src/testdir/test_findfile.vim index 78e51ed836..0bae161a8b 100644 --- a/src/testdir/test_findfile.vim +++ b/src/testdir/test_findfile.vim @@ -119,6 +119,14 @@ func Test_findfile() let &shellslash = save_shellslash endfunc +func Test_findfile_error() + call assert_fails('call findfile([])', 'E730:') + call assert_fails('call findfile("x", [])', 'E730:') + call assert_fails('call findfile("x", "", [])', 'E745:') + call assert_fails('call findfile("x", "**x")', 'E343:') + call assert_fails('call findfile("x", repeat("x", 5000))', 'E854:') +endfunc + " Test finddir({name} [, {path} [, {count}]]) func Test_finddir() let save_path = &path @@ -167,3 +175,11 @@ func Test_finddir() let &path = save_path let &shellslash = save_shellslash endfunc + +func Test_finddir_error() + call assert_fails('call finddir([])', 'E730:') + call assert_fails('call finddir("x", [])', 'E730:') + call assert_fails('call finddir("x", "", [])', 'E745:') + call assert_fails('call finddir("x", "**x")', 'E343:') + call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:') +endfunc diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim index 2fb95a5362..a9bba57804 100644 --- a/src/testdir/test_marks.vim +++ b/src/testdir/test_marks.vim @@ -133,3 +133,44 @@ func Test_marks_cmd_multibyte() bwipe! endfunc + +func Test_delmarks() + new + norm mx + norm `x + delmarks x + call assert_fails('norm `x', 'E20:') + + " Deleting an already deleted mark should not fail. + delmarks x + + " Test deleting a range of marks. + norm ma + norm mb + norm mc + norm mz + delmarks b-z + norm `a + call assert_fails('norm `b', 'E20:') + call assert_fails('norm `c', 'E20:') + call assert_fails('norm `z', 'E20:') + call assert_fails('delmarks z-b', 'E475:') + + call assert_fails('delmarks', 'E471:') + call assert_fails('delmarks /', 'E475:') + + " Test delmarks! + norm mx + norm `x + delmarks! + call assert_fails('norm `x', 'E20:') + call assert_fails('delmarks! x', 'E474:') + + bwipe! +endfunc + +func Test_mark_error() + call assert_fails('mark', 'E471:') + call assert_fails('mark xx', 'E488:') + call assert_fails('mark _', 'E191:') +endfunc diff --git a/src/version.c b/src/version.c index 24a9fb31b0..9b2e7c9f6d 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 875, /**/ 874, /**/ From 2a78b7c70471527d83adef6b147dbfb6c9f838f7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 5 Feb 2019 20:12:06 +0100 Subject: [PATCH 04/75] patch 8.1.0876: completion match not displayed when popup menu is not shown Problem: Completion match not displayed when popup menu is not shown. Solution: Call update_screen() when not displaying the popup menu to show the inserted match. (Ken Takata, Hirohito Higashi) --- src/edit.c | 10 +++++++--- src/version.c | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/edit.c b/src/edit.c index eac4803147..042826a872 100644 --- a/src/edit.c +++ b/src/edit.c @@ -5021,9 +5021,13 @@ ins_compl_next( /* may undisplay the popup menu first */ ins_compl_upd_pum(); - // Redraw before showing the popup menu to show the user what was - // inserted. - pum_call_update_screen(); + if (pum_enough_matches()) + // Will display the popup menu, don't redraw yet to avoid flicker. + pum_call_update_screen(); + else + // Not showing the popup menu yet, redraw to show the user what was + // inserted. + update_screen(0); /* display the updated popup menu */ ins_compl_show_pum(); diff --git a/src/version.c b/src/version.c index 9b2e7c9f6d..dbf0cabf25 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 876, /**/ 875, /**/ From ee8188fc74a7cf9ee7acb634b2bb7a032d0cb24c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 5 Feb 2019 21:23:04 +0100 Subject: [PATCH 05/75] patch 8.1.0877: new buffer used every time the quickfix window is opened Problem: New buffer used every time the quickfix window is opened. Solution: Reuse the buffer. (Yegappan Lakshmanan, closes #3902) --- src/buffer.c | 13 +++--- src/proto/quickfix.pro | 1 + src/quickfix.c | 84 ++++++++++++++++++++++++----------- src/testdir/test_quickfix.vim | 43 ++++++++++++++++++ src/version.c | 2 + 5 files changed, 110 insertions(+), 33 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 98d505f18e..e0b616498a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5753,17 +5753,14 @@ buf_spname(buf_T *buf) #if defined(FEAT_QUICKFIX) if (bt_quickfix(buf)) { - win_T *win; - tabpage_T *tp; - /* - * For location list window, w_llist_ref points to the location list. - * For quickfix window, w_llist_ref is NULL. + * Differentiate between the quickfix and location list buffers using + * the buffer number stored in the global quickfix stack. */ - if (find_win_for_buf(buf, &win, &tp) == OK && win->w_llist_ref != NULL) - return (char_u *)_(msg_loclist); - else + if (buf->b_fnum == qf_stack_get_bufnr()) return (char_u *)_(msg_qflist); + else + return (char_u *)_(msg_loclist); } #endif diff --git a/src/proto/quickfix.pro b/src/proto/quickfix.pro index a71f3431b6..c8d5956fb5 100644 --- a/src/proto/quickfix.pro +++ b/src/proto/quickfix.pro @@ -1,5 +1,6 @@ /* quickfix.c */ int qf_init(win_T *wp, char_u *efile, char_u *errorformat, int newlist, char_u *qf_title, char_u *enc); +int qf_stack_get_bufnr(void); void qf_free_all(win_T *wp); void check_quickfix_busy(void); void copy_loclist_stack(win_T *from, win_T *to); diff --git a/src/quickfix.c b/src/quickfix.c index 3bfa027d62..dba6b63bbe 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -48,6 +48,7 @@ struct qfline_S */ #define LISTCOUNT 10 #define INVALID_QFIDX (-1) +#define INVALID_QFBUFNR (0) /* * Quickfix list type. @@ -107,6 +108,7 @@ struct qf_info_S int qf_curlist; // current error list qf_list_T qf_lists[LISTCOUNT]; qfltype_T qfl_type; // type of list + int qf_bufnr; // quickfix window buffer number }; static qf_info_T ql_info; // global quickfix list @@ -1852,6 +1854,37 @@ locstack_queue_delreq(qf_info_T *qi) } } +/* + * Return the global quickfix stack window buffer number. + */ + int +qf_stack_get_bufnr(void) +{ + return ql_info.qf_bufnr; +} + +/* + * Wipe the quickfix window buffer (if present) for the specified + * quickfix/location list. + */ + static void +wipe_qf_buffer(qf_info_T *qi) +{ + buf_T *qfbuf; + + if (qi->qf_bufnr != INVALID_QFBUFNR) + { + qfbuf = buflist_findnr(qi->qf_bufnr); + if (qfbuf != NULL && qfbuf->b_nwindows == 0) + { + // If the quickfix buffer is not loaded in any window, then + // wipe the buffer. + close_buffer(NULL, qfbuf, DOBUF_WIPE, FALSE); + qi->qf_bufnr = INVALID_QFBUFNR; + } + } +} + /* * Free a location list stack */ @@ -1876,6 +1909,9 @@ ll_free_all(qf_info_T **pqi) locstack_queue_delreq(qi); else { + // If the quickfix window buffer is loaded, then wipe it + wipe_qf_buffer(qi); + for (i = 0; i < qi->qf_listcount; ++i) qf_free(&qi->qf_lists[i]); vim_free(qi); @@ -2066,6 +2102,7 @@ qf_alloc_stack(qfltype_T qfltype) { qi->qf_refcount++; qi->qfl_type = qfltype; + qi->qf_bufnr = INVALID_QFBUFNR; } return qi; } @@ -2741,7 +2778,8 @@ jump_to_help_window(qf_info_T *qi, int newwin, int *opened_window) } /* - * Find a non-quickfix window using the given location list. + * Find a non-quickfix window in the current tabpage using the given location + * list stack. * Returns NULL if a matching window is not found. */ static win_T * @@ -3988,7 +4026,7 @@ qf_open_new_cwindow(qf_info_T *qi, int height) set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", OPT_LOCAL); - set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); + set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL); RESET_BINDING(curwin); #ifdef FEAT_DIFF curwin->w_p_diff = FALSE; @@ -3997,6 +4035,8 @@ qf_open_new_cwindow(qf_info_T *qi, int height) set_option_value((char_u *)"fdm", 0L, (char_u *)"manual", OPT_LOCAL); #endif + // save the number of the new buffer + qi->qf_bufnr = curbuf->b_fnum; } // Only set the height when still in the same tab page and there is no @@ -4212,6 +4252,16 @@ qf_find_buf(qf_info_T *qi) tabpage_T *tp; win_T *win; + if (qi->qf_bufnr != INVALID_QFBUFNR) + { + buf_T *qfbuf; + qfbuf = buflist_findnr(qi->qf_bufnr); + if (qfbuf != NULL) + return qfbuf; + // buffer is no longer present + qi->qf_bufnr = INVALID_QFBUFNR; + } + FOR_ALL_TAB_WINDOWS(tp, win) if (is_qf_win(win, qi)) return win->w_buffer; @@ -6580,22 +6630,6 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title) return retval; } -/* - * Find the non-location list window with the specified location list stack in - * the current tabpage. - */ - static win_T * -find_win_with_ll(qf_info_T *qi) -{ - win_T *wp = NULL; - - FOR_ALL_WINDOWS(wp) - if ((wp->w_llist == qi) && !bt_quickfix(wp->w_buffer)) - return wp; - - return NULL; -} - /* * Free the entire quickfix/location list stack. * If the quickfix/location list window is open, then clear it. @@ -6605,7 +6639,6 @@ qf_free_stack(win_T *wp, qf_info_T *qi) { win_T *qfwin = qf_find_win(qi); win_T *llwin = NULL; - win_T *orig_wp = wp; if (qfwin != NULL) { @@ -6619,7 +6652,7 @@ qf_free_stack(win_T *wp, qf_info_T *qi) { // If in the location list window, then use the non-location list // window with this location list (if present) - llwin = find_win_with_ll(qi); + llwin = qf_find_win_with_loclist(qi); if (llwin != NULL) wp = llwin; } @@ -6631,19 +6664,20 @@ qf_free_stack(win_T *wp, qf_info_T *qi) qi->qf_curlist = 0; qi->qf_listcount = 0; } - else if (IS_LL_WINDOW(orig_wp)) + else if (qfwin != NULL) { // If the location list window is open, then create a new empty // location list qf_info_T *new_ll = qf_alloc_stack(QFLT_LOCATION); + new_ll->qf_bufnr = qfwin->w_buffer->b_fnum; // first free the list reference in the location list window - ll_free_all(&orig_wp->w_llist_ref); + ll_free_all(&qfwin->w_llist_ref); - orig_wp->w_llist_ref = new_ll; - if (llwin != NULL) + qfwin->w_llist_ref = new_ll; + if (wp != qfwin) { - llwin->w_llist = new_ll; + wp->w_llist = new_ll; new_ll->qf_refcount++; } } diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index e7aa41ebf9..aa22508255 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -3899,3 +3899,46 @@ func Test_viscol() set efm& call delete('Xfile1') endfunc + +" Test for the quickfix window buffer +func Xqfbuf_test(cchar) + call s:setup_commands(a:cchar) + + " Quickfix buffer should be reused across closing and opening a quickfix + " window + Xexpr "F1:10:Line10" + Xopen + let qfbnum = bufnr('') + Xclose + " Even after the quickfix window is closed, the buffer should be loaded + call assert_true(bufloaded(qfbnum)) + Xopen + " Buffer should be reused when opening the window again + call assert_equal(qfbnum, bufnr('')) + Xclose + + if a:cchar == 'l' + %bwipe + " For a location list, when both the file window and the location list + " window for the list are closed, then the buffer should be freed. + new | only + lexpr "F1:10:Line10" + let wid = win_getid() + lopen + let qfbnum = bufnr('') + call assert_match(qfbnum . ' %a- "\[Location List]"', execute('ls')) + close + " When the location list window is closed, the buffer name should not + " change to 'Quickfix List' + call assert_match(qfbnum . ' h- "\[Location List]"', execute('ls')) + call assert_true(bufloaded(qfbnum)) + + new | only + call assert_false(bufloaded(qfbnum)) + endif +endfunc + +func Test_qfbuf() + call Xqfbuf_test('c') + call Xqfbuf_test('l') +endfunc diff --git a/src/version.c b/src/version.c index dbf0cabf25..3ad7869b40 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 877, /**/ 876, /**/ From a02e3f65c52a2c8c987e7dcac5df1f8db9a7b0de Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 7 Feb 2019 21:27:14 +0100 Subject: [PATCH 06/75] patch 8.1.0878: test for has('bsd') fails on some BSD systems Problem: Test for has('bsd') fails on some BSD systems. Solution: Adjust the uname match. (James McCoy, closes #3909) --- src/testdir/test_functions.vim | 2 ++ src/version.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index b08d9aa856..e75a8965a0 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1238,6 +1238,8 @@ func Test_platform_name() let uname = system('uname') call assert_equal(uname =~? 'BeOS', has('beos')) call assert_equal(uname =~? 'BSD\|DragonFly', has('bsd')) + " GNU userland on BSD kernels (e.g., GNU/kFreeBSD) don't have BSD defined + call assert_equal(uname =~? '\%(GNU/k\w\+\)\@ Date: Fri, 8 Feb 2019 12:21:30 +0100 Subject: [PATCH 07/75] patch 8.1.0879: MS-Windows: temp name encoding can be wrong Problem: MS-Windows: temp name encoding can be wrong. Solution: Convert from active code page to 'encoding'. (Ken Takata, closes #3520, closes #1698) --- src/fileio.c | 18 ++++++++++++++++++ src/version.c | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/fileio.c b/src/fileio.c index bf724f642f..446ae7edf8 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -7470,6 +7470,24 @@ vim_tempname( for (p = retval; *p; ++p) if (*p == '\\') *p = '/'; + +#if defined(FEAT_MBYTE) && defined(WIN3264) + if (enc_utf8) + { + int len; + char_u *pp = NULL; + + // Convert from active codepage to UTF-8 since mch_call_shell() + // converts command-line to wide string from encoding. + acp_to_enc(retval, (int)STRLEN(retval), &pp, &len); + if (pp != NULL) + { + vim_free(retval); + return pp; + } + } +#endif + return retval; # else /* WIN3264 */ diff --git a/src/version.c b/src/version.c index 6a8ba37551..f1205f12dd 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 879, /**/ 878, /**/ From c6ddce3f2cf6daa3a545405373b661f8a9bccad9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 8 Feb 2019 12:47:03 +0100 Subject: [PATCH 08/75] patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty Problem: MS-Windows: inconsistent selection of winpty/conpty. Solution: Name option 'termwintype', use ++type argument and "term_pty" for term_start(). (Hirohito Higashi, closes #3915) --- runtime/doc/eval.txt | 11 ++++--- runtime/doc/options.txt | 35 +++++++++++----------- runtime/doc/quickref.txt | 3 +- runtime/doc/terminal.txt | 10 ++++--- runtime/optwin.vim | 6 +++- src/channel.c | 18 +++++++---- src/option.c | 35 ++++++++++------------ src/option.h | 4 ++- src/structs.h | 9 +++--- src/terminal.c | 58 ++++++++++++++++++------------------ src/testdir/gen_opt_test.vim | 2 +- src/version.c | 2 ++ 12 files changed, 106 insertions(+), 87 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 50ca3769b8..0fc249c8b2 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5750,6 +5750,11 @@ job_info([{job}]) *job_info()* (See |job_stop()| for the values) only valid when "status" is "dead" + Only in MS-Windows: + "tty_type" Type of virtual console in use. + Values are "winpty" or "conpty". + See 'termwintype'. + Without any arguments, returns a List with all Job objects. job_setoptions({job}, {options}) *job_setoptions()* @@ -9469,10 +9474,8 @@ term_start({cmd}, {options}) *term_start()* "ansi_colors" A list of 16 color names or hex codes defining the ANSI palette used in GUI color modes. See |g:terminal_ansi_colors|. - "term_mode" (MS-Windows only): Specify which pty to - use: - "winpty": Use winpty - "conpty": Use ConPTY (if available) + "tty_type" (MS-Windows only): Specify which pty to + use. See 'termwintype' for the values. {only available when compiled with the |+terminal| feature} diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index c9e2b0b5bb..413342087e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -8054,23 +8054,6 @@ A jump table for the options with a short description can be found at |Q_op|. Note that the "cterm" attributes are still used, not the "gui" ones. NOTE: This option is reset when 'compatible' is set. - *'termmode'* *'tmod'* -'termmode' 'tmod' string (default "") - local to window - {not in Vi, MS-Windows only} - Whether the window uses winpty or |ConPTY| as the virtual console. - When set before opening the terminal, it influences what pty is used. - When opening the terminal it will be set to the actually used pty. - - Possible values are: - "" use ConPTY if possible, winpty otherwise - "winpty" use winpty, fail if not supported - "conpty" use |ConPTY|, fail if not supported - - |ConPTY| support depends on the platform (Windows 10 October 2018 - edition). winpty support needs to be installed. If neither is - supported then you cannot open a terminal window. - *'termwinscroll'* *'twsl'* 'termwinscroll' 'twsl' number (default 10000) local to buffer @@ -8119,6 +8102,24 @@ A jump table for the options with a short description can be found at |Q_op|. the size of the terminal. In that case the Vim window will be adjusted to that size, if possible. + *'termwintype'* *'twt'* +'termwintype' 'twt' string (default "") + global + {not in Vi} + {only available when compiled with the |terminal| + feature on MS-Windows} + Specify the virtual console (pty) used when opening the terminal + window. + + Possible values are: + "" use ConPTY if possible, winpty otherwise + "winpty" use winpty, fail if not supported + "conpty" use |ConPTY|, fail if not supported + + |ConPTY| support depends on the platform (Windows 10 October 2018 + edition). winpty support needs to be installed. If neither is + supported then you cannot open a terminal window. + *'terse'* *'noterse'* 'terse' boolean (default off) global diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 03ac357726..75f400f6d7 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 8.1. Last change: 2018 Apr 18 +*quickref.txt* For Vim version 8.1. Last change: 2019 Feb 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -930,6 +930,7 @@ Short explanation of each option: *option-list* 'termwinkey' 'twk' key that precedes a Vim command in a terminal 'termwinscroll' 'twsl' max number of scrollback lines in a terminal window 'termwinsize' 'tws' size of a terminal window +'termwintype' 'twt' MS-Windows: type of pty to use for terminal window 'terse' shorten some messages 'textauto' 'ta' obsolete, use 'fileformats' 'textmode' 'tx' obsolete, use 'fileformat' diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index de79ff00aa..4b009d32fb 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -228,8 +228,10 @@ Syntax ~ for Python "++eof=exit()". Special codes can be used like with `:map`, e.g. "" for CTRL-Z. - ++winpty Use winpty as the virtual console. - ++conpty Use |ConPTY| as the virtual console. + ++type={pty} (MS-Windows only): Use {pty} as the + virtual console. See 'termwintype' + for the values. + If you want to use more options use the |term_start()| function. If you want to split the window vertically, use: > @@ -416,8 +418,8 @@ On more recent versions of MS-Windows 10 (beginning with the "October 2018 Update"), winpty is no longer required. On those versions, |:terminal| will use Windows' built-in support for hosting terminal applications, "ConPTY". When ConPTY is in use, there may be rendering artifacts regarding ambiguous-width -characters. If you encounter any such issues, set 'termmode' to winpty (which -you then must have instlled). +characters. If you encounter any such issues, set 'termwintype' to "winpty" +(which you then must have instlled). Environment variables are used to pass information to the running job: VIM_SERVERNAME v:servername diff --git a/runtime/optwin.vim b/runtime/optwin.vim index de3cdfb0a5..d929836e74 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar -" Last Change: 2019 Jan 27 +" Last Change: 2019 Feb 08 " If there already is an option window, jump to that one. let buf = bufnr('option-window') @@ -503,6 +503,10 @@ if has("terminal") call OptionL("twk") call append("$", "termwinscroll\tmax number of lines to keep for scrollback in a terminal window") call append("$", "\t(local to window)") + if has('win32') + call append("$", "termwintype\ttype of pty to use for a terminal window") + call OptionG("twt", &twt) + endif call OptionL("twsl") if exists("&winptydll") call append("$", "winptydll\tname of the winpty dynamic library") diff --git a/src/channel.c b/src/channel.c index 484d0139b1..34a1fc3e03 100644 --- a/src/channel.c +++ b/src/channel.c @@ -4947,27 +4947,27 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) opt->jo_set2 |= JO2_TERM_KILL; opt->jo_term_kill = tv_get_string_chk(item); } - else if (STRCMP(hi->hi_key, "term_mode") == 0) + else if (STRCMP(hi->hi_key, "tty_type") == 0) { char_u *p; - if (!(supported2 & JO2_TERM_MODE)) + if (!(supported2 & JO2_TTY_TYPE)) break; - opt->jo_set2 |= JO2_TERM_MODE; + opt->jo_set2 |= JO2_TTY_TYPE; p = tv_get_string_chk(item); if (p == NULL) { - semsg(_(e_invargval), "term_mode"); + semsg(_(e_invargval), "tty_type"); return FAIL; } // Allow empty string, "winpty", "conpty". if (!(*p == NUL || STRCMP(p, "winpty") == 0 || STRCMP(p, "conpty") == 0)) { - semsg(_(e_invargval), "term_mode"); + semsg(_(e_invargval), "tty_type"); return FAIL; } - opt->jo_term_mode = p[0]; + opt->jo_tty_type = p[0]; } # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) else if (STRCMP(hi->hi_key, "ansi_colors") == 0) @@ -5193,6 +5193,9 @@ job_free_contents(job_T *job) vim_free(job->jv_stoponexit); #ifdef UNIX vim_free(job->jv_termsig); +#endif +#ifdef WIN3264 + vim_free(job->jv_tty_type); #endif free_callback(job->jv_exit_cb, job->jv_exit_partial); if (job->jv_argv != NULL) @@ -5963,6 +5966,9 @@ job_info(job_T *job, dict_T *dict) #ifdef UNIX dict_add_string(dict, "termsig", job->jv_termsig); #endif +#ifdef WIN3264 + dict_add_string(dict, "tty_type", job->jv_tty_type); +#endif l = list_alloc(); if (l != NULL) diff --git a/src/option.c b/src/option.c index 77d1024ecd..c8808be041 100644 --- a/src/option.c +++ b/src/option.c @@ -253,7 +253,6 @@ # define PV_TWK OPT_WIN(WV_TWK) # define PV_TWS OPT_WIN(WV_TWS) # define PV_TWSL OPT_BUF(BV_TWSL) -# define PV_TMOD OPT_WIN(WV_TMOD) #endif #ifdef FEAT_SIGNS # define PV_SCL OPT_WIN(WV_SCL) @@ -2699,15 +2698,6 @@ static struct vimoption options[] = #else (char_u*)NULL, PV_NONE, {(char_u *)FALSE, (char_u *)FALSE} -#endif - SCTX_INIT}, - {"termmode", "tmod", P_STRING|P_ALLOCED|P_VI_DEF, -#ifdef FEAT_TERMINAL - (char_u *)VAR_WIN, PV_TMOD, - {(char_u *)"", (char_u *)NULL} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)NULL, (char_u *)0L} #endif SCTX_INIT}, {"termwinkey", "twk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, @@ -2735,6 +2725,15 @@ static struct vimoption options[] = #else (char_u *)NULL, PV_NONE, {(char_u *)NULL, (char_u *)0L} +#endif + SCTX_INIT}, + {"termwintype", "twt", P_STRING|P_ALLOCED|P_VI_DEF, +#if defined(WIN3264) && defined(FEAT_TERMINAL) + (char_u *)&p_twt, PV_NONE, + {(char_u *)"", (char_u *)NULL} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} #endif SCTX_INIT}, {"terse", NULL, P_BOOL|P_VI_DEF, @@ -3218,8 +3217,8 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noins #ifdef FEAT_SIGNS static char *(p_scl_values[]) = {"yes", "no", "auto", NULL}; #endif -#ifdef FEAT_TERMINAL -static char *(p_tmod_values[]) = {"winpty", "conpty", "", NULL}; +#if defined(WIN3264) && defined(FEAT_TERMINAL) +static char *(p_twt_values[]) = {"winpty", "conpty", "", NULL}; #endif static void set_options_default(int opt_flags); @@ -7505,12 +7504,14 @@ did_set_string_option( errmsg = e_invarg; } } - // 'termmode' - else if (varp == &curwin->w_p_tmod) +# if defined(WIN3264) + // 'termwintype' + else if (varp == &p_twt) { - if (check_opt_strings(*varp, p_tmod_values, FALSE) != OK) + if (check_opt_strings(*varp, p_twt_values, FALSE) != OK) errmsg = e_invarg; } +# endif #endif #ifdef FEAT_VARTABS @@ -10952,7 +10953,6 @@ get_varp(struct vimoption *p) case PV_TWK: return (char_u *)&(curwin->w_p_twk); case PV_TWS: return (char_u *)&(curwin->w_p_tws); case PV_TWSL: return (char_u *)&(curbuf->b_p_twsl); - case PV_TMOD: return (char_u *)&(curwin->w_p_tmod); #endif case PV_AI: return (char_u *)&(curbuf->b_p_ai); @@ -11153,7 +11153,6 @@ copy_winopt(winopt_T *from, winopt_T *to) #ifdef FEAT_TERMINAL to->wo_twk = vim_strsave(from->wo_twk); to->wo_tws = vim_strsave(from->wo_tws); - to->wo_tmod = vim_strsave(from->wo_tmod); #endif #ifdef FEAT_FOLDING to->wo_fdc = from->wo_fdc; @@ -11224,7 +11223,6 @@ check_winopt(winopt_T *wop UNUSED) #ifdef FEAT_TERMINAL check_string_option(&wop->wo_twk); check_string_option(&wop->wo_tws); - check_string_option(&wop->wo_tmod); #endif #ifdef FEAT_LINEBREAK check_string_option(&wop->wo_briopt); @@ -11268,7 +11266,6 @@ clear_winopt(winopt_T *wop UNUSED) #ifdef FEAT_TERMINAL clear_string_option(&wop->wo_twk); clear_string_option(&wop->wo_tws); - clear_string_option(&wop->wo_tmod); #endif } diff --git a/src/option.h b/src/option.h index 2985781e65..26e5fd04c6 100644 --- a/src/option.h +++ b/src/option.h @@ -834,6 +834,9 @@ EXTERN char_u *p_tenc; /* 'termencoding' */ #ifdef FEAT_TERMGUICOLORS EXTERN int p_tgc; /* 'termguicolors' */ #endif +#if defined(WIN3264) && defined(FEAT_TERMINAL) +EXTERN char_u *p_twt; // 'termwintype' +#endif EXTERN int p_terse; /* 'terse' */ EXTERN int p_ta; /* 'textauto' */ EXTERN int p_to; /* 'tildeop' */ @@ -1112,7 +1115,6 @@ enum #ifdef FEAT_TERMINAL , WV_TWK , WV_TWS - , WV_TMOD #endif , WV_CRBIND #ifdef FEAT_LINEBREAK diff --git a/src/structs.h b/src/structs.h index 5d0541bc83..4464c4b8d1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -282,8 +282,6 @@ typedef struct # define w_p_twk w_onebuf_opt.wo_twk /* 'termwinkey' */ char_u *wo_tws; # define w_p_tws w_onebuf_opt.wo_tws /* 'termwinsize' */ - char_u *wo_tmod; -# define w_p_tmod w_onebuf_opt.wo_tmod /* 'termmode' */ #endif #ifdef FEAT_EVAL @@ -1555,6 +1553,9 @@ struct jobvar_S char_u *jv_stoponexit; /* allocated */ #ifdef UNIX char_u *jv_termsig; /* allocated */ +#endif +#ifdef WIN3264 + char_u *jv_tty_type; // allocated #endif int jv_exitval; char_u *jv_exit_cb; /* allocated */ @@ -1791,7 +1792,7 @@ struct channel_S { #define JO2_NORESTORE 0x2000 /* "norestore" */ #define JO2_TERM_KILL 0x4000 /* "term_kill" */ #define JO2_ANSI_COLORS 0x8000 /* "ansi_colors" */ -#define JO2_TERM_MODE 0x10000 /* "term_mode" */ +#define JO2_TTY_TYPE 0x10000 /* "tty_type" */ #define JO_MODE_ALL (JO_MODE + JO_IN_MODE + JO_OUT_MODE + JO_ERR_MODE) #define JO_CB_ALL \ @@ -1864,7 +1865,7 @@ typedef struct # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) long_u jo_ansi_colors[16]; # endif - int jo_term_mode; // first character of "term_mode" + int jo_tty_type; // first character of "tty_type" #endif } jobopt_T; diff --git a/src/terminal.c b/src/terminal.c index 41cd5c952b..27ff24f103 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -742,16 +742,26 @@ ex_terminal(exarg_T *eap) vim_free(buf); *p = ' '; } - else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "winpty", 6) == 0) +#ifdef WIN3264 + else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "type", 4) == 0 + && ep != NULL) { - opt.jo_set2 |= JO2_TERM_MODE; - opt.jo_term_mode = 'w'; - } - else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "conpty", 6) == 0) - { - opt.jo_set2 |= JO2_TERM_MODE; - opt.jo_term_mode = 'c'; + int tty_type = NUL; + + p = skiptowhite(cmd); + if (STRNICMP(ep + 1, "winpty", p - (ep + 1)) == 0) + tty_type = 'w'; + else if (STRNICMP(ep + 1, "conpty", p - (ep + 1)) == 0) + tty_type = 'c'; + else + { + semsg(e_invargval, "type"); + goto theend; + } + opt.jo_set2 |= JO2_TTY_TYPE; + opt.jo_tty_type = tty_type; } +#endif else { if (*p) @@ -809,9 +819,8 @@ term_write_session(FILE *fd, win_T *wp) term->tl_cols, term->tl_rows) < 0) return FAIL; #ifdef WIN3264 - if (*wp->w_p_tmod != NUL) - if (fprintf(fd, "++%s ", wp->w_p_tmod) < 0) - return FAIL; + if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0) + return FAIL; #endif if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0) return FAIL; @@ -5369,7 +5378,7 @@ f_term_start(typval_T *argvars, typval_T *rettv) + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN + JO2_CWD + JO2_ENV + JO2_EOF_CHARS + JO2_NORESTORE + JO2_TERM_KILL - + JO2_ANSI_COLORS + JO2_TERM_MODE) == FAIL) + + JO2_ANSI_COLORS + JO2_TTY_TYPE) == FAIL) return; buf = term_start(&argvars[0], NULL, &opt, 0); @@ -5713,6 +5722,7 @@ conpty_term_and_job_init( job->jv_proc_info = proc_info; job->jv_job_object = jo; job->jv_status = JOB_STARTED; + job->jv_tty_type = vim_strsave("conpty"); ++job->jv_refcount; term->tl_job = job; @@ -6046,6 +6056,7 @@ winpty_term_and_job_init( (short_u *)winpty_conin_name(term->tl_winpty), NULL); job->jv_tty_out = utf16_to_enc( (short_u *)winpty_conout_name(term->tl_winpty), NULL); + job->jv_tty_type = vim_strsave("winpty"); ++job->jv_refcount; term->tl_job = job; @@ -6113,6 +6124,7 @@ term_and_job_init( { int use_winpty = FALSE; int use_conpty = FALSE; + int tty_type = *p_twt; has_winpty = dyn_winpty_init(FALSE) != FAIL ? TRUE : FALSE; has_conpty = dyn_conpty_init(FALSE) != FAIL ? TRUE : FALSE; @@ -6122,14 +6134,10 @@ term_and_job_init( // conpty is not available it can't be installed either. return dyn_winpty_init(TRUE); - if (opt->jo_term_mode == 'w') - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"winpty", - OPT_FREE|OPT_LOCAL, 0); - if (opt->jo_term_mode == 'c') - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"conpty", - OPT_FREE|OPT_LOCAL, 0); + if (opt->jo_tty_type != NUL) + tty_type = opt->jo_tty_type; - if (curwin->w_p_tmod == NULL || *curwin->w_p_tmod == NUL) + if (tty_type == NUL) { if (has_conpty) use_conpty = TRUE; @@ -6137,12 +6145,12 @@ term_and_job_init( use_winpty = TRUE; // else: error } - else if (STRICMP(curwin->w_p_tmod, "winpty") == 0) + else if (tty_type == 'w') // winpty { if (has_winpty) use_winpty = TRUE; } - else if (STRICMP(curwin->w_p_tmod, "conpty") == 0) + else if (tty_type == 'c') // conpty { if (has_conpty) use_conpty = TRUE; @@ -6151,18 +6159,10 @@ term_and_job_init( } if (use_conpty) - { - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"conpty", - OPT_FREE|OPT_LOCAL, 0); return conpty_term_and_job_init(term, argvar, argv, opt, orig_opt); - } if (use_winpty) - { - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"winpty", - OPT_FREE|OPT_LOCAL, 0); return winpty_term_and_job_init(term, argvar, argv, opt, orig_opt); - } // error return dyn_winpty_init(TRUE); diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim index 8c75d377ee..bd3f80ce6c 100644 --- a/src/testdir/gen_opt_test.vim +++ b/src/testdir/gen_opt_test.vim @@ -131,8 +131,8 @@ let test_values = { \ 'term': [[], []], \ 'termguicolors': [[], []], \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']], - \ 'termmode': [['', 'winpty', 'conpty'], ['xxx']], \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']], + \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']], \ 'toolbar': [['', 'icons', 'text'], ['xxx']], \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']], \ 'ttymouse': [['', 'xterm'], ['xxx']], diff --git a/src/version.c b/src/version.c index f1205f12dd..1235cf0eda 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 880, /**/ 879, /**/ From 8c62a08faf89663e5633dc5036cd8695c80f1075 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 8 Feb 2019 14:34:10 +0100 Subject: [PATCH 09/75] patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others. --- runtime/doc/starting.txt | 14 +++-- src/evalfunc.c | 22 +++++-- src/ex_cmds.c | 2 +- src/ex_docmd.c | 7 ++- src/if_perl.xs | 13 ++-- src/testdir/Make_all.mak | 2 + src/testdir/test_restricted.vim | 107 ++++++++++++++++++++++++++++++++ src/version.c | 2 + 8 files changed, 151 insertions(+), 18 deletions(-) create mode 100644 src/testdir/test_restricted.vim diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 711a4876b6..6289e9c8f7 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -248,12 +248,18 @@ a slash. Thus "-R" means recovery and "-/R" readonly. changes and writing. {not in Vi} - *-Z* *restricted-mode* *E145* + *-Z* *restricted-mode* *E145* *E981* -Z Restricted mode. All commands that make use of an external shell are disabled. This includes suspending with CTRL-Z, - ":sh", filtering, the system() function, backtick expansion, - delete(), rename(), mkdir(), writefile(), libcall(), - job_start(), etc. + ":sh", filtering, the system() function, backtick expansion + and libcall(). + Also disallowed are delete(), rename(), mkdir(), job_start(), + etc. + Interfaces, such as Python, Ruby and Lua, are also disabled, + since they could be used to execute shell commands. Perl uses + the Safe module. + Note that the user may still find a loophole to execute a + shell command, it has only been made difficult. {not in Vi} *-g* diff --git a/src/evalfunc.c b/src/evalfunc.c index fa7ed9bab1..eb082b771b 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6817,7 +6817,7 @@ f_histadd(typval_T *argvars UNUSED, typval_T *rettv) #endif rettv->vval.v_number = FALSE; - if (check_restricted() || check_secure()) + if (check_secure()) return; #ifdef FEAT_CMDHIST str = tv_get_string_chk(&argvars[0]); /* NULL on type error */ @@ -7898,6 +7898,9 @@ f_luaeval(typval_T *argvars, typval_T *rettv) char_u *str; char_u buf[NUMBUFLEN]; + if (check_restricted() || check_secure()) + return; + str = tv_get_string_buf(&argvars[0], buf); do_luaeval(str, argvars + 1, rettv); } @@ -8644,6 +8647,8 @@ f_mzeval(typval_T *argvars, typval_T *rettv) char_u *str; char_u buf[NUMBUFLEN]; + if (check_restricted() || check_secure()) + return; str = tv_get_string_buf(&argvars[0], buf); do_mzeval(str, rettv); } @@ -8932,6 +8937,9 @@ f_py3eval(typval_T *argvars, typval_T *rettv) char_u *str; char_u buf[NUMBUFLEN]; + if (check_restricted() || check_secure()) + return; + if (p_pyx == 0) p_pyx = 3; @@ -8950,6 +8958,9 @@ f_pyeval(typval_T *argvars, typval_T *rettv) char_u *str; char_u buf[NUMBUFLEN]; + if (check_restricted() || check_secure()) + return; + if (p_pyx == 0) p_pyx = 2; @@ -8965,6 +8976,9 @@ f_pyeval(typval_T *argvars, typval_T *rettv) static void f_pyxeval(typval_T *argvars, typval_T *rettv) { + if (check_restricted() || check_secure()) + return; + # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) init_pyxversion(); if (p_pyx == 2) @@ -10819,7 +10833,7 @@ f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED) typval_T *varp; char_u nbuf[NUMBUFLEN]; - if (check_restricted() || check_secure()) + if (check_secure()) return; (void)tv_get_number(&argvars[0]); /* issue errmsg if type error */ varname = tv_get_string_chk(&argvars[1]); @@ -11341,7 +11355,7 @@ f_settabvar(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = 0; - if (check_restricted() || check_secure()) + if (check_secure()) return; tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL)); @@ -14714,7 +14728,7 @@ f_writefile(typval_T *argvars, typval_T *rettv) blob_T *blob = NULL; rettv->vval.v_number = -1; - if (check_restricted() || check_secure()) + if (check_secure()) return; if (argvars[0].v_type == VAR_LIST) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index a3974c1bad..681ef422a9 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4775,7 +4775,7 @@ check_restricted(void) { if (restricted) { - emsg(_("E145: Shell commands not allowed in rvim")); + emsg(_("E145: Shell commands and some functionality not allowed in rvim")); return TRUE; } return FALSE; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index b90ea7b17c..ccca2f98fa 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2007,11 +2007,16 @@ do_one_cmd( #ifdef HAVE_SANDBOX if (sandbox != 0 && !(ea.argt & SBOXOK)) { - /* Command not allowed in sandbox. */ + // Command not allowed in sandbox. errormsg = _(e_sandbox); goto doend; } #endif + if (restricted != 0 && (ea.argt & RESTRICT)) + { + errormsg = _("E981: Command not allowed in rvim"); + goto doend; + } if (!curbuf->b_p_ma && (ea.argt & MODIFY)) { /* Command not allowed in non-'modifiable' buffer */ diff --git a/src/if_perl.xs b/src/if_perl.xs index 203bb6a679..67d0b94888 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -971,6 +971,7 @@ VIM_init(void) #ifdef DYNAMIC_PERL static char *e_noperl = N_("Sorry, this command is disabled: the Perl library could not be loaded."); #endif +static char *e_perlsandbox = N_("E299: Perl evaluation forbidden in sandbox without the Safe module"); /* * ":perl" @@ -1019,13 +1020,12 @@ ex_perl(exarg_T *eap) vim_free(script); } -#ifdef HAVE_SANDBOX - if (sandbox) + if (sandbox || secure) { safe = perl_get_sv("VIM::safe", FALSE); # ifndef MAKE_TEST /* avoid a warning for unreachable code */ if (safe == NULL || !SvTRUE(safe)) - emsg(_("E299: Perl evaluation forbidden in sandbox without the Safe module")); + emsg(_(e_perlsandbox)); else # endif { @@ -1037,7 +1037,6 @@ ex_perl(exarg_T *eap) } } else -#endif perl_eval_sv(sv, G_DISCARD | G_NOARGS); SvREFCNT_dec(sv); @@ -1298,13 +1297,12 @@ do_perleval(char_u *str, typval_T *rettv) ENTER; SAVETMPS; -#ifdef HAVE_SANDBOX - if (sandbox) + if (sandbox || secure) { safe = get_sv("VIM::safe", FALSE); # ifndef MAKE_TEST /* avoid a warning for unreachable code */ if (safe == NULL || !SvTRUE(safe)) - emsg(_("E299: Perl evaluation forbidden in sandbox without the Safe module")); + emsg(_(e_perlsandbox)); else # endif { @@ -1320,7 +1318,6 @@ do_perleval(char_u *str, typval_T *rettv) } } else -#endif /* HAVE_SANDBOX */ sv = eval_pv((char *)str, 0); if (sv) { diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 5857a228f5..2ca5f2b1de 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -213,6 +213,7 @@ NEW_TESTS = \ test_regexp_utf8 \ test_registers \ test_reltime \ + test_restricted \ test_retab \ test_ruby \ test_scriptnames \ @@ -375,6 +376,7 @@ NEW_TESTS_RES = \ test_quotestar.res \ test_regex_char_classes.res \ test_registers.res \ + test_restricted.res \ test_retab.res \ test_ruby.res \ test_scriptnames.res \ diff --git a/src/testdir/test_restricted.vim b/src/testdir/test_restricted.vim new file mode 100644 index 0000000000..9dd937cf3e --- /dev/null +++ b/src/testdir/test_restricted.vim @@ -0,0 +1,107 @@ +" Test for "rvim" or "vim -Z" + +source shared.vim + +func Test_restricted() + let cmd = GetVimCommand('Xrestricted') + if cmd == '' + return + endif + + call writefile([ + \ "silent !ls", + \ "call writefile([v:errmsg], 'Xrestrout')", + \ "qa!", + \ ], 'Xrestricted') + call system(cmd . ' -Z') + call assert_match('E145:', join(readfile('Xrestrout'))) + + call delete('Xrestricted') + call delete('Xrestrout') +endfunc + +func Run_restricted_test(ex_cmd, error) + let cmd = GetVimCommand('Xrestricted') + if cmd == '' + return + endif + + call writefile([ + \ a:ex_cmd, + \ "call writefile([v:errmsg], 'Xrestrout')", + \ "qa!", + \ ], 'Xrestricted') + call system(cmd . ' -Z') + call assert_match(a:error, join(readfile('Xrestrout'))) + + call delete('Xrestricted') + call delete('Xrestrout') +endfunc + +func Test_restricted_lua() + if !has('lua') + throw 'Skipped: Lua is not supported' + endif + call Run_restricted_test('lua print("Hello, Vim!")', 'E981:') + call Run_restricted_test('luado return "hello"', 'E981:') + call Run_restricted_test('luafile somefile', 'E981:') + call Run_restricted_test('call luaeval("expression")', 'E145:') +endfunc + +func Test_restricted_mzscheme() + if !has('mzscheme') + throw 'Skipped: MzScheme is not supported' + endif + call Run_restricted_test('mzscheme statement', 'E981:') + call Run_restricted_test('mzfile somefile', 'E981:') + call Run_restricted_test('call mzeval("expression")', 'E145:') +endfunc + +func Test_restricted_perl() + if !has('perl') + throw 'Skipped: Perl is not supported' + endif + " TODO: how to make Safe mode fail? + " call Run_restricted_test('perl system("ls")', 'E981:') + " call Run_restricted_test('perldo system("hello")', 'E981:') + " call Run_restricted_test('perlfile somefile', 'E981:') + " call Run_restricted_test('call perleval("system(\"ls\")")', 'E145:') +endfunc + +func Test_restricted_python() + if !has('python') + throw 'Skipped: Python is not supported' + endif + call Run_restricted_test('python print "hello"', 'E981:') + call Run_restricted_test('pydo return "hello"', 'E981:') + call Run_restricted_test('pyfile somefile', 'E981:') + call Run_restricted_test('call pyeval("expression")', 'E145:') +endfunc + +func Test_restricted_python3() + if !has('python3') + throw 'Skipped: Python3 is not supported' + endif + call Run_restricted_test('py3 print "hello"', 'E981:') + call Run_restricted_test('py3do return "hello"', 'E981:') + call Run_restricted_test('py3file somefile', 'E981:') + call Run_restricted_test('call py3eval("expression")', 'E145:') +endfunc + +func Test_restricted_ruby() + if !has('ruby') + throw 'Skipped: Ruby is not supported' + endif + call Run_restricted_test('ruby print "Hello"', 'E981:') + call Run_restricted_test('rubydo print "Hello"', 'E981:') + call Run_restricted_test('rubyfile somefile', 'E981:') +endfunc + +func Test_restricted_tcl() + if !has('tcl') + throw 'Skipped: Tcl is not supported' + endif + call Run_restricted_test('tcl puts "Hello"', 'E981:') + call Run_restricted_test('tcldo puts "Hello"', 'E981:') + call Run_restricted_test('tclfile somefile', 'E981:') +endfunc diff --git a/src/version.c b/src/version.c index 1235cf0eda..48236fe354 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 881, /**/ 880, /**/ From 1aa43755e2116ba744be13b6f596ea033a0d82ae Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 8 Feb 2019 14:41:31 +0100 Subject: [PATCH 10/75] patch 8.1.0882: checking for FEAT_MBYTE which doesn't exist anymore Problem: Checking for FEAT_MBYTE which doesn't exist anymore. (Christ van Willegen) Solution: Remove it. --- src/fileio.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index 446ae7edf8..c1aa1a76f9 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -7471,7 +7471,7 @@ vim_tempname( if (*p == '\\') *p = '/'; -#if defined(FEAT_MBYTE) && defined(WIN3264) +#if defined(WIN3264) if (enc_utf8) { int len; diff --git a/src/version.c b/src/version.c index 48236fe354..164fd44032 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 882, /**/ 881, /**/ From 54d6fe5e60c0c488a424c078963ead40ae7dc397 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 8 Feb 2019 16:50:26 +0100 Subject: [PATCH 11/75] patch 8.1.0883: missing some changes for Ex commands Problem: Missing some changes for Ex commands. Solution: Add mising changes in header file. --- src/ex_cmds.h | 45 +++++++++++++++++++++++---------------------- src/version.c | 2 ++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 07afb00616..eed4ce2382 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -57,6 +57,7 @@ * curbuf_lock is set */ #define MODIFY 0x200000L /* forbidden in non-'modifiable' buffer */ #define EXFLAGS 0x400000L /* allow flags after count in argument */ +#define RESTRICT 0x800000L /* forbidden in restricted mode */ #define FILES (XFILE | EXTRA) /* multiple extra files allowed */ #define WORD1 (EXTRA | NOSPC) /* one extra word allowed */ #define FILE1 (FILES | NOSPC) /* 1 file allowed, defaults to current file */ @@ -861,13 +862,13 @@ EX(CMD_lunmap, "lunmap", ex_unmap, EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN, ADDR_LINES), EX(CMD_lua, "lua", ex_lua, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_luado, "luado", ex_luado, - RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN, + RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_luafile, "luafile", ex_luafile, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_lvimgrep, "lvimgrep", ex_vimgrep, RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE, @@ -930,10 +931,10 @@ EX(CMD_mode, "mode", ex_mode, WORD1|TRLBAR|CMDWIN, ADDR_LINES), EX(CMD_mzscheme, "mzscheme", ex_mzscheme, - RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN|SBOXOK, + RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN|SBOXOK|RESTRICT, ADDR_LINES), EX(CMD_mzfile, "mzfile", ex_mzfile, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_next, "next", ex_next, RANGE|NOTADR|BANG|FILES|EDITCMD|ARGOPT|TRLBAR, @@ -1116,37 +1117,37 @@ EX(CMD_pwd, "pwd", ex_pwd, TRLBAR|CMDWIN, ADDR_LINES), EX(CMD_python, "python", ex_python, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_pydo, "pydo", ex_pydo, - RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN, + RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_pyfile, "pyfile", ex_pyfile, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_py3, "py3", ex_py3, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_py3do, "py3do", ex_py3do, - RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN, + RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_python3, "python3", ex_py3, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_py3file, "py3file", ex_py3file, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_pyx, "pyx", ex_pyx, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_pyxdo, "pyxdo", ex_pyxdo, - RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN, + RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_pythonx, "pythonx", ex_pyx, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_pyxfile, "pyxfile", ex_pyxfile, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_quit, "quit", ex_quit, BANG|RANGE|COUNT|NOTADR|TRLBAR|CMDWIN, @@ -1203,13 +1204,13 @@ EX(CMD_runtime, "runtime", ex_runtime, BANG|NEEDARG|FILES|TRLBAR|SBOXOK|CMDWIN, ADDR_LINES), EX(CMD_ruby, "ruby", ex_ruby, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_rubydo, "rubydo", ex_rubydo, - RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN, + RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_rubyfile, "rubyfile", ex_rubyfile, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_rundo, "rundo", ex_rundo, NEEDARG|FILE1, @@ -1476,13 +1477,13 @@ EX(CMD_tabs, "tabs", ex_tabs, TRLBAR|CMDWIN, ADDR_TABS), EX(CMD_tcl, "tcl", ex_tcl, - RANGE|EXTRA|NEEDARG|CMDWIN, + RANGE|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_tcldo, "tcldo", ex_tcldo, - RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN, + RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_tclfile, "tclfile", ex_tclfile, - RANGE|FILE1|NEEDARG|CMDWIN, + RANGE|FILE1|NEEDARG|CMDWIN|RESTRICT, ADDR_LINES), EX(CMD_tearoff, "tearoff", ex_tearoff, NEEDARG|EXTRA|TRLBAR|NOTRLCOM|CMDWIN, diff --git a/src/version.c b/src/version.c index 164fd44032..bf1e466964 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 883, /**/ 882, /**/ From af630d4f7f8daa7edbda0b607d32d39a5feae9d9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 8 Feb 2019 23:09:48 +0100 Subject: [PATCH 12/75] patch 8.1.0884: double check for bsd systems Problem: Double check for bsd systems. Solution: Delete the old line. --- src/testdir/test_functions.vim | 1 - src/version.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index e75a8965a0..69e6ce0f8f 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1237,7 +1237,6 @@ func Test_platform_name() if has('unix') && executable('uname') let uname = system('uname') call assert_equal(uname =~? 'BeOS', has('beos')) - call assert_equal(uname =~? 'BSD\|DragonFly', has('bsd')) " GNU userland on BSD kernels (e.g., GNU/kFreeBSD) don't have BSD defined call assert_equal(uname =~? '\%(GNU/k\w\+\)\@ Date: Sat, 9 Feb 2019 11:13:12 +0100 Subject: [PATCH 13/75] patch 8.1.0885: test for restricted hangs on MS-Windows GUI Problem: Test for restricted hangs on MS-Windows GUI. Solution: Skip the test. --- src/testdir/test_restricted.vim | 5 +++++ src/version.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/testdir/test_restricted.vim b/src/testdir/test_restricted.vim index 9dd937cf3e..85da94c418 100644 --- a/src/testdir/test_restricted.vim +++ b/src/testdir/test_restricted.vim @@ -2,6 +2,11 @@ source shared.vim +if has('win32') && has('gui') + " Win32 GUI shows a dialog instead of displaying the error in the last line. + finish +endif + func Test_restricted() let cmd = GetVimCommand('Xrestricted') if cmd == '' diff --git a/src/version.c b/src/version.c index b08bd82284..641d8020ca 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 885, /**/ 884, /**/ From b7633611611eeb5f14f8fd598afa687964e23f23 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 21:48:25 +0100 Subject: [PATCH 14/75] patch 8.1.0886: compiler warning for NULL pointer and condition always true Problem: Compiler warning for adding to NULL pointer and a condition that is always true. Solution: Check for NULL pointer before adding. Remove useless "if". (Friedirch, closes #3913) --- src/dosinst.c | 9 +++++---- src/search.c | 18 +++++++----------- src/version.c | 2 ++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/dosinst.c b/src/dosinst.c index 5b05598872..7025eb6184 100644 --- a/src/dosinst.c +++ b/src/dosinst.c @@ -291,16 +291,17 @@ findoldfile(char **destination) { char *bp = *destination; size_t indir_l = strlen(installdir); - char *cp = bp + indir_l; + char *cp; char *tmpname; char *farname; /* * No action needed if exe not found or not in this directory. */ - if (bp == NULL - || strnicmp(bp, installdir, indir_l) != 0 - || strchr("/\\", *cp++) == NULL + if (bp == NULL || strnicmp(bp, installdir, indir_l) != 0) + return; + cp = bp + indir_l; + if (strchr("/\\", *cp++) == NULL || strchr(cp, '\\') != NULL || strchr(cp, '/') != NULL) return; diff --git a/src/search.c b/src/search.c index 4b3f8532a5..df7067b08f 100644 --- a/src/search.c +++ b/src/search.c @@ -4732,18 +4732,14 @@ current_search( VIsual_active = TRUE; VIsual_mode = 'v'; - if (VIsual_active) + redraw_curbuf_later(INVERTED); /* update the inversion */ + if (*p_sel == 'e') { - redraw_curbuf_later(INVERTED); /* update the inversion */ - if (*p_sel == 'e') - { - /* Correction for exclusive selection depends on the direction. */ - if (forward && LTOREQ_POS(VIsual, curwin->w_cursor)) - inc_cursor(); - else if (!forward && LTOREQ_POS(curwin->w_cursor, VIsual)) - inc(&VIsual); - } - + /* Correction for exclusive selection depends on the direction. */ + if (forward && LTOREQ_POS(VIsual, curwin->w_cursor)) + inc_cursor(); + else if (!forward && LTOREQ_POS(curwin->w_cursor, VIsual)) + inc(&VIsual); } #ifdef FEAT_FOLDING diff --git a/src/version.c b/src/version.c index 641d8020ca..aa17e0afa3 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 886, /**/ 885, /**/ From 9474716d39764ac5642e55b5548580cf53bd9bed Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 21:55:26 +0100 Subject: [PATCH 15/75] patch 8.1.0887: the 'l' flag in :subsitute is sticky Problem: The 'l' flag in :subsitute is sticky. Solution: Reset the flag. (Dominique Pelle, closes #3925) --- src/ex_cmds.c | 3 ++- src/testdir/test_substitute.vim | 26 ++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 681ef422a9..abb5f7096f 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2098,7 +2098,7 @@ write_viminfo(char_u *file, int forceit) fp_out = NULL; # ifdef EEXIST /* Avoid trying lots of names while the problem is lack - * of premission, only retry if the file already + * of permission, only retry if the file already * exists. */ if (errno != EEXIST) break; @@ -5040,6 +5040,7 @@ do_sub(exarg_T *eap) } subflags.do_error = TRUE; subflags.do_print = FALSE; + subflags.do_list = FALSE; subflags.do_count = FALSE; subflags.do_number = FALSE; subflags.do_ic = 0; diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim index d84daa7212..0ae407d8af 100644 --- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -107,6 +107,32 @@ func Test_substitute_variants() endfor endfunc +" Test the l, p, # flags. +func Test_substitute_flags_lp() + new + call setline(1, "abc\tdef\ghi") + + let a = execute('s/a/a/p') + call assert_equal("\nabc def^Hghi", a) + + let a = execute('s/a/a/l') + call assert_equal("\nabc^Idef^Hghi$", a) + + let a = execute('s/a/a/#') + call assert_equal("\n 1 abc def^Hghi", a) + + let a = execute('s/a/a/p#') + call assert_equal("\n 1 abc def^Hghi", a) + + let a = execute('s/a/a/l#') + call assert_equal("\n 1 abc^Idef^Hghi$", a) + + let a = execute('s/a/a/') + call assert_equal("", a) + + bwipe! +endfunc + func Test_substitute_repeat() " This caused an invalid memory access. split Xfile diff --git a/src/version.c b/src/version.c index aa17e0afa3..94825f826d 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 887, /**/ 886, /**/ From 31b816042fca879b11965ddd75287732563ba698 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 22:14:27 +0100 Subject: [PATCH 16/75] patch 8.1.0888: the a: dict is not immutable as documented Problem: The a: dict is not immutable as documented. Solution: Make the a:dict immutable, add a test. (Ozaki Kiichi, Yasuhiro Matsumoto, closes #3929) --- src/eval.c | 13 ++-- src/testdir/test_let.vim | 121 ++++++++++++++++++++++++++++++++++ src/testdir/test_listdict.vim | 80 +++++++++++++++++++++- src/userfunc.c | 3 +- src/version.c | 2 + 5 files changed, 210 insertions(+), 9 deletions(-) diff --git a/src/eval.c b/src/eval.c index 3f9db7d16f..08603cad6a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2092,14 +2092,15 @@ get_lval( if (lp->ll_di == NULL) { - /* Can't add "v:" variable. */ - if (lp->ll_dict == &vimvardict) + // Can't add "v:" or "a:" variable. + if (lp->ll_dict == &vimvardict + || &lp->ll_dict->dv_hashtab == get_funccal_args_ht()) { semsg(_(e_illvar), name); return NULL; } - /* Key does not exist in dict: may need to add it. */ + // Key does not exist in dict: may need to add it. if (*p == '[' || *p == '.' || unlet) { if (!quiet) @@ -7919,14 +7920,14 @@ set_var( } else /* add a new variable */ { - /* Can't add "v:" variable. */ - if (ht == &vimvarht) + // Can't add "v:" or "a:" variable. + if (ht == &vimvarht || ht == get_funccal_args_ht()) { semsg(_(e_illvar), name); return; } - /* Make sure the variable name is valid. */ + // Make sure the variable name is valid. if (!valid_varname(varname)) return; diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim index 24c6ef5e01..550655cb6e 100644 --- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -25,3 +25,124 @@ func Test_let() let s = "\na #1\nb #2" call assert_equal(s, out) endfunc + +func s:set_arg1(a) abort + let a:a = 1 +endfunction + +func s:set_arg2(a) abort + let a:b = 1 +endfunction + +func s:set_arg3(a) abort + let b = a: + let b['a'] = 1 +endfunction + +func s:set_arg4(a) abort + let b = a: + let b['a'] = 1 +endfunction + +func s:set_arg5(a) abort + let b = a: + let b['a'][0] = 1 +endfunction + +func s:set_arg6(a) abort + let a:a[0] = 1 +endfunction + +func s:set_arg7(a) abort + call extend(a:, {'a': 1}) +endfunction + +func s:set_arg8(a) abort + call extend(a:, {'b': 1}) +endfunction + +func s:set_arg9(a) abort + let a:['b'] = 1 +endfunction + +func s:set_arg10(a) abort + let b = a: + call extend(b, {'a': 1}) +endfunction + +func s:set_arg11(a) abort + let b = a: + call extend(b, {'b': 1}) +endfunction + +func s:set_arg12(a) abort + let b = a: + let b['b'] = 1 +endfunction + +func Test_let_arg_fail() + call assert_fails('call s:set_arg1(1)', 'E46:') + call assert_fails('call s:set_arg2(1)', 'E461:') + call assert_fails('call s:set_arg3(1)', 'E46:') + call assert_fails('call s:set_arg4(1)', 'E46:') + call assert_fails('call s:set_arg5(1)', 'E46:') + call s:set_arg6([0]) + call assert_fails('call s:set_arg7(1)', 'E742:') + call assert_fails('call s:set_arg8(1)', 'E742:') + call assert_fails('call s:set_arg9(1)', 'E461:') + call assert_fails('call s:set_arg10(1)', 'E742:') + call assert_fails('call s:set_arg11(1)', 'E742:') + call assert_fails('call s:set_arg12(1)', 'E461:') +endfunction + +func s:set_varg1(...) abort + let a:000 = [] +endfunction + +func s:set_varg2(...) abort + let a:000[0] = 1 +endfunction + +func s:set_varg3(...) abort + let a:000 += [1] +endfunction + +func s:set_varg4(...) abort + call add(a:000, 1) +endfunction + +func s:set_varg5(...) abort + let a:000[0][0] = 1 +endfunction + +func s:set_varg6(...) abort + let b = a:000 + let b[0] = 1 +endfunction + +func s:set_varg7(...) abort + let b = a:000 + let b += [1] +endfunction + +func s:set_varg8(...) abort + let b = a:000 + call add(b, 1) +endfunction + +func s:set_varg9(...) abort + let b = a:000 + let b[0][0] = 1 +endfunction + +func Test_let_varg_fail() + call assert_fails('call s:set_varg1(1)', 'E46:') + call assert_fails('call s:set_varg2(1)', 'E742:') + call assert_fails('call s:set_varg3(1)', 'E46:') + call assert_fails('call s:set_varg4(1)', 'E742:') + call s:set_varg5([0]) + call assert_fails('call s:set_varg6(1)', 'E742:') + " call assert_fails('call s:set_varg7(1)', 'E46:') + call assert_fails('call s:set_varg8(1)', 'E742:') + call s:set_varg9([0]) +endfunction diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index 1af47d9f7e..4807d78245 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -500,17 +500,21 @@ endfunc " No remove() of write-protected scope-level variable func Tfunc1(this_is_a_long_parameter_name) - call assert_fails("call remove(a:, 'this_is_a_long_parameter_name')", 'E795') + call assert_fails("call remove(a:, 'this_is_a_long_parameter_name')", 'E742') endfunc func Test_dict_scope_var_remove() call Tfunc1('testval') endfunc " No extend() of write-protected scope-level variable +func Test_dict_scope_var_extend() + call assert_fails("call extend(a:, {'this_is_a_long_parameter_name': 1234})", 'E742') +endfunc + func Tfunc2(this_is_a_long_parameter_name) call assert_fails("call extend(a:, {'this_is_a_long_parameter_name': 1234})", 'E742') endfunc -func Test_dict_scope_var_extend() +func Test_dict_scope_var_extend_overwrite() call Tfunc2('testval') endfunc @@ -651,3 +655,75 @@ func Test_listdict_extend() call assert_fails("call extend(d, d, 'error')", 'E737:') call assert_equal({'a': {'b': 'B'}}, d) endfunc + +func s:check_scope_dict(x, fixed) + func s:gen_cmd(cmd, x) + return substitute(a:cmd, '\fixvar[fixvar_idx++].var; name = v->di_key; STRCPY(name, "self"); - v->di_flags = DI_FLAGS_RO + DI_FLAGS_FIX; + v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; hash_add(&fc->l_vars.dv_hashtab, DI2HIKEY(v)); v->di_tv.v_type = VAR_DICT; v->di_tv.v_lock = 0; @@ -788,6 +788,7 @@ call_user_func( init_var_dict(&fc->l_avars, &fc->l_avars_var, VAR_SCOPE); add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "0", (varnumber_T)(argcount - fp->uf_args.ga_len)); + fc->l_avars.dv_lock = VAR_FIXED; /* Use "name" to avoid a warning from some compiler that checks the * destination size. */ v = &fc->fixvar[fixvar_idx++].var; diff --git a/src/version.c b/src/version.c index 94825f826d..e31b7cace6 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 888, /**/ 887, /**/ From 6524068ff3252f1373807f1ebfde21408cef624e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 22:23:26 +0100 Subject: [PATCH 17/75] patch 8.1.0889: MS-Windows: a channel write may hang Problem: MS-Windows: a channel write may hang. Solution: Check for WriteFile() not writing anything. (Yasuhiro Matsumoto, closes #3920) --- src/channel.c | 9 +++++++-- src/testdir/test_channel.vim | 14 ++++++++++++++ src/testdir/test_channel_pipe.py | 3 +++ src/version.c | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/channel.c b/src/channel.c index 34a1fc3e03..d728c77d9f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -91,9 +91,10 @@ fd_write(sock_T fd, char *buf, size_t len) size = MAX_NAMED_PIPE_SIZE; else size = (DWORD)todo; - // If the pipe overflows while the job does not read the data, WriteFile - // will block forever. This abandons the write. + // If the pipe overflows while the job does not read the data, + // WriteFile() will block forever. This abandons the write. memset(&ov, 0, sizeof(ov)); + nwrite = 0; if (!WriteFile(h, buf + done, size, &nwrite, &ov)) { DWORD err = GetLastError(); @@ -104,6 +105,10 @@ fd_write(sock_T fd, char *buf, size_t len) return -1; FlushFileBuffers(h); } + else if (nwrite == 0) + // WriteFile() returns TRUE but did not write anything. This causes + // a hang, so bail out. + break; todo -= nwrite; done += nwrite; } diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 2aef3e1dc4..becd5484f9 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -2003,6 +2003,20 @@ func Test_raw_large_data() endtry endfunc +func Test_no_hang_windows() + if !has('job') || !has('win32') + return + endif + + try + let job = job_start(s:python . " test_channel_pipe.py busy", + \ {'mode': 'raw', 'drop': 'never', 'noblock': 0}) + call assert_fails('call ch_sendraw(job, repeat("X", 80000))', 'E631:') + finally + call job_stop(job) + endtry +endfunc + func Test_job_exitval_and_termsig() if !has('unix') return diff --git a/src/testdir/test_channel_pipe.py b/src/testdir/test_channel_pipe.py index 810a8e3032..5caffcbf9e 100644 --- a/src/testdir/test_channel_pipe.py +++ b/src/testdir/test_channel_pipe.py @@ -18,6 +18,9 @@ if __name__ == "__main__": print(sys.argv[1], end='') sys.stdout.flush() sys.exit(0) + elif sys.argv[1].startswith("busy"): + time.sleep(100) + sys.exit(0) else: print(sys.argv[1]) sys.stdout.flush() diff --git a/src/version.c b/src/version.c index e31b7cace6..a990f2c3c1 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 889, /**/ 888, /**/ From 593864817a08f9b719a093ef4fd8d4d35132ab86 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 22:43:46 +0100 Subject: [PATCH 18/75] patch 8.1.0890: pty allocation wrong if using file for out channel Problem: Pty allocation wrong if using file for out channel and using null for in channel and null for error channel. Solution: Correct using use_file_for_out in condition. (Ozaki Kiichi, closes #3917) --- src/os_unix.c | 34 +++++++++++++---------- src/testdir/test_channel.vim | 52 ++++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/src/os_unix.c b/src/os_unix.c index a17abe3d52..425498c6bc 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4196,13 +4196,19 @@ set_default_child_environment(int is_terminal) /* * Open a PTY, with FD for the master and slave side. * When failing "pty_master_fd" and "pty_slave_fd" are -1. - * When successful both file descriptors are stored. + * When successful both file descriptors are stored and the allocated pty name + * is stored in both "*name1" and "*name2". */ static void -open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **namep) +open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **name1, char_u **name2) { char *tty_name; + if (name1 != NULL) + *name1 = NULL; + if (name2 != NULL) + *name2 = NULL; + *pty_master_fd = mch_openpty(&tty_name); // open pty if (*pty_master_fd >= 0) { @@ -4219,8 +4225,13 @@ open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **namep) close(*pty_master_fd); *pty_master_fd = -1; } - else if (namep != NULL) - *namep = vim_strsave((char_u *)tty_name); + else + { + if (name1 != NULL) + *name1 = vim_strsave((char_u *)tty_name); + if (name2 != NULL) + *name2 = vim_strsave((char_u *)tty_name); + } } } #endif @@ -4513,7 +4524,7 @@ mch_call_shell_fork( * If the slave can't be opened, close the master pty. */ if (p_guipty && !(options & (SHELL_READ|SHELL_WRITE))) - open_pty(&pty_master_fd, &pty_slave_fd, NULL); + open_pty(&pty_master_fd, &pty_slave_fd, NULL, NULL); /* * If not opening a pty or it didn't work, try using pipes. */ @@ -5352,13 +5363,10 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal) if (options->jo_pty && (!(use_file_for_in || use_null_for_in) - || !(use_file_for_in || use_null_for_out) + || !(use_file_for_out || use_null_for_out) || !(use_out_for_err || use_file_for_err || use_null_for_err))) - { - open_pty(&pty_master_fd, &pty_slave_fd, &job->jv_tty_out); - if (job->jv_tty_out != NULL) - job->jv_tty_in = vim_strsave(job->jv_tty_out); - } + open_pty(&pty_master_fd, &pty_slave_fd, + &job->jv_tty_out, &job->jv_tty_in); /* TODO: without the channel feature connect the child to /dev/null? */ /* Open pipes for stdin, stdout, stderr. */ @@ -5834,9 +5842,7 @@ mch_create_pty_channel(job_T *job, jobopt_T *options) int pty_slave_fd = -1; channel_T *channel; - open_pty(&pty_master_fd, &pty_slave_fd, &job->jv_tty_out); - if (job->jv_tty_out != NULL) - job->jv_tty_in = vim_strsave(job->jv_tty_out); + open_pty(&pty_master_fd, &pty_slave_fd, &job->jv_tty_out, &job->jv_tty_in); close(pty_slave_fd); channel = add_channel(); diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index becd5484f9..e263115392 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -2040,3 +2040,55 @@ func Test_job_exitval_and_termsig() call assert_equal(-1, info.exitval) call assert_equal("term", info.termsig) endfunc + +func Test_job_tty_in_out() + if !has('job') || !has('unix') + return + endif + + call writefile(['test'], 'Xtestin') + let in_opts = [{}, + \ {'in_io': 'null'}, + \ {'in_io': 'file', 'in_name': 'Xtestin'}] + let out_opts = [{}, + \ {'out_io': 'null'}, + \ {'out_io': 'file', 'out_name': 'Xtestout'}] + let err_opts = [{}, + \ {'err_io': 'null'}, + \ {'err_io': 'file', 'err_name': 'Xtesterr'}, + \ {'err_io': 'out'}] + let opts = [] + + for in_opt in in_opts + let x = copy(in_opt) + for out_opt in out_opts + call extend(x, out_opt) + for err_opt in err_opts + call extend(x, err_opt) + let opts += [extend({'pty': 1}, x)] + endfor + endfor + endfor + + for opt in opts + let job = job_start('echo', opt) + let info = job_info(job) + let msg = printf('option={"in_io": "%s", "out_io": "%s", "err_io": "%s"}', + \ get(opt, 'in_io', 'tty'), + \ get(opt, 'out_io', 'tty'), + \ get(opt, 'err_io', 'tty')) + + if !has_key(opt, 'in_io') || !has_key(opt, 'out_io') || !has_key(opt, 'err_io') + call assert_notequal('', info.tty_in, msg) + else + call assert_equal('', info.tty_in, msg) + endif + call assert_equal(info.tty_in, info.tty_out, msg) + + call WaitForAssert({-> assert_equal('dead', job_status(job))}) + endfor + + call delete('Xtestin') + call delete('Xtestout') + call delete('Xtesterr') +endfunc diff --git a/src/version.c b/src/version.c index a990f2c3c1..c865fc0b13 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 890, /**/ 889, /**/ From d77aa4d22e943998c337d5a603622ac5cf2928cb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 22:50:14 +0100 Subject: [PATCH 19/75] patch 8.1.0891: substitute command inssuficiently tested Problem: Substitute command inssuficiently tested. Solution: Add more test coverage. (Dominique Pelle) --- src/testdir/test_substitute.vim | 84 +++++++++++++++++++++++++++++++++ src/version.c | 2 + 2 files changed, 86 insertions(+) diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim index 0ae407d8af..f01e60e595 100644 --- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -141,6 +141,90 @@ func Test_substitute_repeat() bwipe! endfunc +" Test %s/\n// which is implemented as a special case to use a +" more efficient join rather than doing a regular substitution. +func Test_substitute_join() + new + + call setline(1, ["foo\tbar", "bar\foo"]) + let a = execute('%s/\n//') + call assert_equal("", a) + call assert_equal(["foo\tbarbar\foo"], getline(1, '$')) + call assert_equal('\n', histget("search", -1)) + + call setline(1, ["foo\tbar", "bar\foo"]) + let a = execute('%s/\n//g') + call assert_equal("", a) + call assert_equal(["foo\tbarbar\foo"], getline(1, '$')) + call assert_equal('\n', histget("search", -1)) + + call setline(1, ["foo\tbar", "bar\foo"]) + let a = execute('%s/\n//p') + call assert_equal("\nfoo barbar^Hfoo", a) + call assert_equal(["foo\tbarbar\foo"], getline(1, '$')) + call assert_equal('\n', histget("search", -1)) + + call setline(1, ["foo\tbar", "bar\foo"]) + let a = execute('%s/\n//l') + call assert_equal("\nfoo^Ibarbar^Hfoo$", a) + call assert_equal(["foo\tbarbar\foo"], getline(1, '$')) + call assert_equal('\n', histget("search", -1)) + + call setline(1, ["foo\tbar", "bar\foo"]) + let a = execute('%s/\n//#') + call assert_equal("\n 1 foo barbar^Hfoo", a) + call assert_equal(["foo\tbarbar\foo"], getline(1, '$')) + call assert_equal('\n', histget("search", -1)) + + bwipe! +endfunc + +func Test_substitute_count() + new + call setline(1, ['foo foo', 'foo foo', 'foo foo', 'foo foo', 'foo foo']) + 2 + + s/foo/bar/3 + call assert_equal(['foo foo', 'bar foo', 'bar foo', 'bar foo', 'foo foo'], + \ getline(1, '$')) + + call assert_fails('s/foo/bar/0', 'E939:') + + bwipe! +endfunc + +" Test substitute 'n' flag (report number of matches, do not substitute). +func Test_substitute_flag_n() + new + let lines = ['foo foo', 'foo foo', 'foo foo', 'foo foo', 'foo foo'] + call setline(1, lines) + + call assert_equal("\n3 matches on 3 lines", execute('2,4s/foo/bar/n')) + call assert_equal("\n6 matches on 3 lines", execute('2,4s/foo/bar/gn')) + + " c flag (confirm) should be ignored when using n flag. + call assert_equal("\n3 matches on 3 lines", execute('2,4s/foo/bar/nc')) + + " No substitution should have been done. + call assert_equal(lines, getline(1, '$')) + + bwipe! +endfunc + +func Test_substitute_errors() + new + call setline(1, 'foobar') + + call assert_fails('s/FOO/bar/', 'E486:') + call assert_fails('s/foo/bar/@', 'E488:') + call assert_fails('s/\(/bar/', 'E476:') + + setl nomodifiable + call assert_fails('s/foo/bar/', 'E21:') + + bwipe! +endfunc + " Test for *sub-replace-special* and *sub-replace-expression* on substitute(). func Test_sub_replace_1() " Run the tests with 'magic' on diff --git a/src/version.c b/src/version.c index c865fc0b13..7de8a0ab7e 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 891, /**/ 890, /**/ From eeb1b9c7ed33c152e041a286d79bf3ed00d80e40 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 22:59:04 +0100 Subject: [PATCH 20/75] patch 8.1.0892: failure when closing a window when location list is in use Problem: Failure when closing a window when location list is in use. Solution: Handle the situation gracefully. Make sure memory for 'switchbuf' is not freed at the wrong time. (Yegappan Lakshmanan, closes #3928) --- src/eval.c | 2 +- src/evalfunc.c | 2 +- src/proto/window.pro | 2 +- src/quickfix.c | 62 ++++++++++++++++++++--------------- src/testdir/test_quickfix.vim | 58 +++++++++++++++++++++++++++++--- src/version.c | 2 ++ src/window.c | 3 +- 7 files changed, 95 insertions(+), 36 deletions(-) diff --git a/src/eval.c b/src/eval.c index 08603cad6a..c30c5d83c0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -8587,7 +8587,7 @@ find_win_by_nr_or_id(typval_T *vp) int nr = (int)tv_get_number_chk(vp, NULL); if (nr >= LOWEST_WIN_ID) - return win_id2wp(vp); + return win_id2wp(tv_get_number(vp)); return find_win_by_nr(vp, NULL); } diff --git a/src/evalfunc.c b/src/evalfunc.c index eb082b771b..c18ab31251 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5800,7 +5800,7 @@ f_getwininfo(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type != VAR_UNKNOWN) { - wparg = win_id2wp(argvars); + wparg = win_id2wp(tv_get_number(&argvars[0])); if (wparg == NULL) return; } diff --git a/src/proto/window.pro b/src/proto/window.pro index 4527a37f42..27f77c4758 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -91,7 +91,7 @@ int get_tab_number(tabpage_T *tp); int win_getid(typval_T *argvars); int win_gotoid(typval_T *argvars); void win_id2tabwin(typval_T *argvars, list_T *list); -win_T *win_id2wp(typval_T *argvars); +win_T *win_id2wp(int id); int win_id2win(typval_T *argvars); void win_findbuf(typval_T *argvars, list_T *list); void get_framelayout(frame_T *fr, list_T *l, int outer); diff --git a/src/quickfix.c b/src/quickfix.c index dba6b63bbe..ea2e8c9d18 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -1899,23 +1899,24 @@ ll_free_all(qf_info_T **pqi) return; *pqi = NULL; // Remove reference to this list + // If the location list is still in use, then queue the delete request + // to be processed later. + if (quickfix_busy > 0) + { + locstack_queue_delreq(qi); + return; + } + qi->qf_refcount--; if (qi->qf_refcount < 1) { // No references to this location list. - // If the location list is still in use, then queue the delete request - // to be processed later. - if (quickfix_busy > 0) - locstack_queue_delreq(qi); - else - { - // If the quickfix window buffer is loaded, then wipe it - wipe_qf_buffer(qi); + // If the quickfix window buffer is loaded, then wipe it + wipe_qf_buffer(qi); - for (i = 0; i < qi->qf_listcount; ++i) - qf_free(&qi->qf_lists[i]); - vim_free(qi); - } + for (i = 0; i < qi->qf_listcount; ++i) + qf_free(&qi->qf_lists[i]); + vim_free(qi); } } @@ -3018,7 +3019,7 @@ qf_jump_edit_buffer( qf_info_T *qi, qfline_T *qf_ptr, int forceit, - win_T *oldwin, + int prev_winid, int *opened_window) { qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist]; @@ -3039,7 +3040,7 @@ qf_jump_edit_buffer( retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, ECMD_HIDE + ECMD_SET_HELP, - oldwin == curwin ? curwin : NULL); + prev_winid == curwin->w_id ? curwin : NULL); } else retval = buflist_getfile(qf_ptr->qf_fnum, @@ -3047,11 +3048,15 @@ qf_jump_edit_buffer( // If a location list, check whether the associated window is still // present. - if (qfl_type == QFLT_LOCATION && !win_valid_any_tab(oldwin)) + if (qfl_type == QFLT_LOCATION) { - emsg(_("E924: Current window was closed")); - *opened_window = FALSE; - return NOTDONE; + win_T *wp = win_id2wp(prev_winid); + if (wp == NULL && curwin->w_llist != qi) + { + emsg(_("E924: Current window was closed")); + *opened_window = FALSE; + return NOTDONE; + } } if (qfl_type == QFLT_QUICKFIX && !qflist_valid(NULL, save_qfid)) @@ -3211,7 +3216,7 @@ qf_jump_to_buffer( int qf_index, qfline_T *qf_ptr, int forceit, - win_T *oldwin, + int prev_winid, int *opened_window, int openfold, int print_message) @@ -3227,7 +3232,7 @@ qf_jump_to_buffer( if (qf_ptr->qf_fnum != 0) { - retval = qf_jump_edit_buffer(qi, qf_ptr, forceit, oldwin, + retval = qf_jump_edit_buffer(qi, qf_ptr, forceit, prev_winid, opened_window); if (retval != OK) return retval; @@ -3287,8 +3292,8 @@ qf_jump_newwin(qf_info_T *qi, int old_qf_index; char_u *old_swb = p_swb; unsigned old_swb_flags = swb_flags; + int prev_winid; int opened_window = FALSE; - win_T *oldwin = curwin; int print_message = TRUE; #ifdef FEAT_FOLDING int old_KeyTyped = KeyTyped; // getting file may reset it @@ -3304,6 +3309,8 @@ qf_jump_newwin(qf_info_T *qi, return; } + incr_quickfix_busy(); + qfl = &qi->qf_lists[qi->qf_curlist]; qf_ptr = qfl->qf_ptr; @@ -3325,13 +3332,15 @@ qf_jump_newwin(qf_info_T *qi, // window print_message = FALSE; + prev_winid = curwin->w_id; + retval = qf_jump_open_window(qi, qf_ptr, newwin, &opened_window); if (retval == FAIL) goto failed; if (retval == NOTDONE) goto theend; - retval = qf_jump_to_buffer(qi, qf_index, qf_ptr, forceit, oldwin, + retval = qf_jump_to_buffer(qi, qf_index, qf_ptr, forceit, prev_winid, &opened_window, old_KeyTyped, print_message); if (retval == NOTDONE) { @@ -3359,7 +3368,7 @@ theend: qfl->qf_ptr = qf_ptr; qfl->qf_index = qf_index; } - if (p_swb != old_swb && opened_window) + if (p_swb != old_swb) { // Restore old 'switchbuf' value, but not when an autocommand or // modeline has changed the value. @@ -3371,6 +3380,7 @@ theend: else free_string_option(old_swb); } + decr_quickfix_busy(); } // Highlight attributes used for displaying entries from the quickfix list. @@ -4004,9 +4014,9 @@ qf_open_new_cwindow(qf_info_T *qi, int height) if (IS_LL_STACK(qi)) { // For the location list window, create a reference to the - // location list from the window 'win'. - curwin->w_llist_ref = win->w_llist; - win->w_llist->qf_refcount++; + // location list stack from the window 'win'. + curwin->w_llist_ref = qi; + qi->qf_refcount++; } if (oldwin != curwin) diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index aa22508255..d31bd5233f 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -1,4 +1,4 @@ -" Test for the quickfix commands. +" Test for the quickfix feature. if !has('quickfix') finish @@ -1419,7 +1419,7 @@ func XquickfixSetListWithAct(cchar) \ {'filename': 'fnameD', 'text': 'D'}, \ {'filename': 'fnameE', 'text': 'E'}] - " {action} is unspecified. Same as specifing ' '. + " {action} is unspecified. Same as specifying ' '. new | only silent! Xnewer 99 call g:Xsetlist(list1) @@ -2348,7 +2348,7 @@ func Test_cwindow_jump() " Open a new window and create a location list " Open the location list window and close the other window " Jump to an entry. - " Should create a new window and jump to the entry. The scrtach buffer + " Should create a new window and jump to the entry. The scratch buffer " should not be used. enew | only set buftype=nofile @@ -3831,7 +3831,7 @@ func Test_splitview() new | only " When split opening files from a helpgrep location list window, a new help - " window should be opend with a copy of the location list. + " window should be opened with a copy of the location list. lhelpgrep window let locid = getloclist(0, {'id' : 0}).id lwindow @@ -3933,8 +3933,30 @@ func Xqfbuf_test(cchar) call assert_match(qfbnum . ' h- "\[Location List]"', execute('ls')) call assert_true(bufloaded(qfbnum)) + " When the location list is cleared for the window, the buffer should be + " removed + call setloclist(0, [], 'f') + call assert_false(bufexists(qfbnum)) + + " When the location list is freed with the location list window open, the + " location list buffer should not be lost. It should be reused when the + " location list is again populated. + lexpr "F1:10:Line10" + lopen + let wid = win_getid() + let qfbnum = bufnr('') + wincmd p + call setloclist(0, [], 'f') + lexpr "F1:10:Line10" + lopen + call assert_equal(wid, win_getid()) + call assert_equal(qfbnum, bufnr('')) + lclose + + " When the window with the location list is closed, the buffer should be + " removed new | only - call assert_false(bufloaded(qfbnum)) + call assert_false(bufexists(qfbnum)) endif endfunc @@ -3942,3 +3964,29 @@ func Test_qfbuf() call Xqfbuf_test('c') call Xqfbuf_test('l') endfunc + +" If there is an autocmd to use only one window, then opening the location +" list window used to crash Vim. +func Test_winonly_autocmd() + call s:create_test_file('Xtest1') + " Autocmd to show only one Vim window at a time + autocmd WinEnter * only + new + " Load the location list + lexpr "Xtest1:5:Line5\nXtest1:10:Line10\nXtest1:15:Line15" + let loclistid = getloclist(0, {'id' : 0}).id + " Open the location list window. Only this window will be shown and the file + " window is closed. + lopen + call assert_equal(loclistid, getloclist(0, {'id' : 0}).id) + " Jump to an entry in the location list and make sure that the cursor is + " positioned correctly. + ll 3 + call assert_equal(loclistid, getloclist(0, {'id' : 0}).id) + call assert_equal('Xtest1', bufname('')) + call assert_equal(15, line('.')) + " Cleanup + autocmd! WinEnter + new | only + call delete('Xtest1') +endfunc diff --git a/src/version.c b/src/version.c index 7de8a0ab7e..3305e22d2e 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 892, /**/ 891, /**/ diff --git a/src/window.c b/src/window.c index f78fccafe6..f6e611535a 100644 --- a/src/window.c +++ b/src/window.c @@ -7193,11 +7193,10 @@ win_id2tabwin(typval_T *argvars, list_T *list) } win_T * -win_id2wp(typval_T *argvars) +win_id2wp(int id) { win_T *wp; tabpage_T *tp; - int id = tv_get_number(&argvars[0]); FOR_ALL_TAB_WINDOWS(tp, wp) if (wp->w_id == id) From 3615abb693ab2d9374ae72f0993128e32ffa3e1c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 23:04:12 +0100 Subject: [PATCH 21/75] patch 8.1.0893: terminal test is a bit flaky Problem: Terminal test is a bit flaky. Solution: Add test_terminal_no_cmd() to list of flaky tests. --- src/testdir/runtest.vim | 1 + src/version.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 3f49ccb1cb..383e6270d1 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -310,6 +310,7 @@ let s:flaky_tests = [ \ 'Test_terminal_env()', \ 'Test_terminal_hide_buffer()', \ 'Test_terminal_make_change()', + \ 'Test_terminal_no_cmd()', \ 'Test_terminal_noblock()', \ 'Test_terminal_redir_file()', \ 'Test_terminal_response_to_control_sequence()', diff --git a/src/version.c b/src/version.c index 3305e22d2e..b86e5c8775 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 893, /**/ 892, /**/ From dce1e89be4675bcdbc9785584d3da25295481e63 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 23:18:53 +0100 Subject: [PATCH 22/75] patch 8.1.0894: MS-Windows: resolve() does not return a reparse point Problem: MS-Windows: resolve() does not return a reparse point. Solution: Improve resolve(). (Yasuhiro Matsumoto, closes #3896) --- runtime/doc/eval.txt | 3 + src/buffer.c | 2 +- src/evalfunc.c | 2 +- src/os_mswin.c | 182 ++++++++++++++++++++++++++++++++- src/proto/os_mswin.pro | 2 +- src/testdir/test_functions.vim | 99 +++++++++++++++++- src/version.c | 2 + 7 files changed, 286 insertions(+), 6 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0fc249c8b2..c2150e5b90 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -7385,6 +7385,9 @@ repeat({expr}, {count}) *repeat()* resolve({filename}) *resolve()* *E655* On MS-Windows, when {filename} is a shortcut (a .lnk file), returns the path the shortcut points to in a simplified form. + When {filename} is a symbolic link or junction point, return + the full path to the target. If the target of junction is + removed, return {filename}. On Unix, repeat resolving symbolic links in all path components of {filename} and return the simplified result. To cope with link cycles, resolving of symbolic links is diff --git a/src/buffer.c b/src/buffer.c index e0b616498a..7dd4d34e28 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4847,7 +4847,7 @@ fname_expand( char_u *rfname; // If the file name is a shortcut file, use the file it links to. - rfname = mch_resolve_shortcut(*ffname); + rfname = mch_resolve_path(*ffname, FALSE); if (rfname != NULL) { vim_free(*ffname); diff --git a/src/evalfunc.c b/src/evalfunc.c index c18ab31251..4c03470224 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -9912,7 +9912,7 @@ f_resolve(typval_T *argvars, typval_T *rettv) { char_u *v = NULL; - v = mch_resolve_shortcut(p); + v = mch_resolve_path(p, TRUE); if (v != NULL) rettv->vval.v_string = v; else diff --git a/src/os_mswin.c b/src/os_mswin.c index 363dc4666e..8d46e53cf1 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -1823,13 +1823,181 @@ mch_print_set_fg(long_u fgcol) # include # endif +typedef enum _FILE_INFO_BY_HANDLE_CLASS_ { + FileBasicInfo_, + FileStandardInfo_, + FileNameInfo_, + FileRenameInfo_, + FileDispositionInfo_, + FileAllocationInfo_, + FileEndOfFileInfo_, + FileStreamInfo_, + FileCompressionInfo_, + FileAttributeTagInfo_, + FileIdBothDirectoryInfo_, + FileIdBothDirectoryRestartInfo_, + FileIoPriorityHintInfo_, + FileRemoteProtocolInfo_, + FileFullDirectoryInfo_, + FileFullDirectoryRestartInfo_, + FileStorageInfo_, + FileAlignmentInfo_, + FileIdInfo_, + FileIdExtdDirectoryInfo_, + FileIdExtdDirectoryRestartInfo_, + FileDispositionInfoEx_, + FileRenameInfoEx_, + MaximumFileInfoByHandleClass_ +} FILE_INFO_BY_HANDLE_CLASS_; + +typedef struct _FILE_NAME_INFO_ { + DWORD FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFO_; + +typedef BOOL (WINAPI *pfnGetFileInformationByHandleEx)( + HANDLE hFile, + FILE_INFO_BY_HANDLE_CLASS_ FileInformationClass, + LPVOID lpFileInformation, + DWORD dwBufferSize); +static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL; + +typedef BOOL (WINAPI *pfnGetVolumeInformationByHandleW)( + HANDLE hFile, + LPWSTR lpVolumeNameBuffer, + DWORD nVolumeNameSize, + LPDWORD lpVolumeSerialNumber, + LPDWORD lpMaximumComponentLength, + LPDWORD lpFileSystemFlags, + LPWSTR lpFileSystemNameBuffer, + DWORD nFileSystemNameSize); +static pfnGetVolumeInformationByHandleW pGetVolumeInformationByHandleW = NULL; + + char_u * +resolve_reparse_point(char_u *fname) +{ + HANDLE h = INVALID_HANDLE_VALUE; + DWORD size; + char_u *rfname = NULL; + FILE_NAME_INFO_ *nameinfo = NULL; + WCHAR buff[MAX_PATH], *volnames = NULL; + HANDLE hv; + DWORD snfile, snfind; + static BOOL loaded = FALSE; + + if (pGetFileInformationByHandleEx == NULL || + pGetVolumeInformationByHandleW == NULL) + { + HMODULE hmod = GetModuleHandle("kernel32.dll"); + + if (loaded == TRUE) + return NULL; + pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx) + GetProcAddress(hmod, "GetFileInformationByHandleEx"); + pGetVolumeInformationByHandleW = (pfnGetVolumeInformationByHandleW) + GetProcAddress(hmod, "GetVolumeInformationByHandleW"); + loaded = TRUE; + if (pGetFileInformationByHandleEx == NULL || + pGetVolumeInformationByHandleW == NULL) + return NULL; + } + + if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) + { + WCHAR *p; + + p = enc_to_utf16(fname, NULL); + if (p == NULL) + goto fail; + + if ((GetFileAttributesW(p) & FILE_ATTRIBUTE_REPARSE_POINT) == 0) + { + vim_free(p); + goto fail; + } + + h = CreateFileW(p, 0, 0, NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); + vim_free(p); + } + else + { + if ((GetFileAttributes((char*) fname) & + FILE_ATTRIBUTE_REPARSE_POINT) == 0) + goto fail; + + h = CreateFile((char*) fname, 0, 0, NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); + } + + if (h == INVALID_HANDLE_VALUE) + goto fail; + + size = sizeof(FILE_NAME_INFO_) + sizeof(WCHAR) * (MAX_PATH - 1); + nameinfo = (FILE_NAME_INFO_*)alloc(size + sizeof(WCHAR)); + if (nameinfo == NULL) + goto fail; + + if (!pGetFileInformationByHandleEx(h, FileNameInfo_, nameinfo, size)) + goto fail; + + nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = 0; + + if (!pGetVolumeInformationByHandleW( + h, NULL, 0, &snfile, NULL, NULL, NULL, 0)) + goto fail; + + hv = FindFirstVolumeW(buff, MAX_PATH); + if (hv == INVALID_HANDLE_VALUE) + goto fail; + + do { + GetVolumeInformationW( + buff, NULL, 0, &snfind, NULL, NULL, NULL, 0); + if (snfind == snfile) + break; + } while (FindNextVolumeW(hv, buff, MAX_PATH)); + + FindVolumeClose(hv); + + if (snfind != snfile) + goto fail; + + size = 0; + if (!GetVolumePathNamesForVolumeNameW(buff, NULL, 0, &size) && + GetLastError() != ERROR_MORE_DATA) + goto fail; + + volnames = (WCHAR*)alloc(size * sizeof(WCHAR)); + if (!GetVolumePathNamesForVolumeNameW(buff, volnames, size, + &size)) + goto fail; + + wcscpy(buff, volnames); + if (nameinfo->FileName[0] == '\\') + wcscat(buff, nameinfo->FileName + 1); + else + wcscat(buff, nameinfo->FileName); + rfname = utf16_to_enc(buff, NULL); + +fail: + if (h != INVALID_HANDLE_VALUE) + CloseHandle(h); + if (nameinfo != NULL) + vim_free(nameinfo); + if (volnames != NULL) + vim_free(volnames); + + return rfname; +} + /* * When "fname" is the name of a shortcut (*.lnk) resolve the file it points * to and return that name in allocated memory. * Otherwise NULL is returned. */ - char_u * -mch_resolve_shortcut(char_u *fname) + static char_u * +resolve_shortcut(char_u *fname) { HRESULT hr; IShellLink *psl = NULL; @@ -1937,6 +2105,16 @@ shortcut_end: CoUninitialize(); return rfname; } + + char_u * +mch_resolve_path(char_u *fname, int reparse_point) +{ + char_u *path = resolve_shortcut(fname); + + if (path == NULL && reparse_point) + path = resolve_reparse_point(fname); + return path; +} #endif #if (defined(FEAT_EVAL) && !defined(FEAT_GUI)) || defined(PROTO) diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro index cc660a6d97..3e8d487077 100644 --- a/src/proto/os_mswin.pro +++ b/src/proto/os_mswin.pro @@ -37,7 +37,7 @@ int mch_print_text_out(char_u *p, int len); void mch_print_set_font(int iBold, int iItalic, int iUnderline); void mch_print_set_bg(long_u bgcol); void mch_print_set_fg(long_u fgcol); -char_u *mch_resolve_shortcut(char_u *fname); +char_u *mch_resolve_path(char_u *fname, int reparse_point); void win32_set_foreground(void); void serverInitMessaging(void); void serverSetName(char_u *name); diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 69e6ce0f8f..a7caf22408 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -188,7 +188,7 @@ func Test_strftime() call assert_fails('call strftime("%Y", [])', 'E745:') endfunc -func Test_resolve() +func Test_resolve_unix() if !has('unix') return endif @@ -234,6 +234,103 @@ func Test_resolve() call delete('Xlink1') endfunc +func s:normalize_fname(fname) + let ret = substitute(a:fname, '\', '/', 'g') + let ret = substitute(ret, '//', '/', 'g') + let ret = tolower(ret) +endfunc + +func Test_resolve_win32() + if !has('win32') + return + endif + + " test for shortcut file + if executable('cscript') + new Xfile + wq + call writefile([ + \ 'Set fs = CreateObject("Scripting.FileSystemObject")', + \ 'Set ws = WScript.CreateObject("WScript.Shell")', + \ 'Set shortcut = ws.CreateShortcut("Xlink.lnk")', + \ 'shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile")', + \ 'shortcut.Save' + \], 'link.vbs') + silent !cscript link.vbs + call delete('link.vbs') + call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk'))) + call delete('Xfile') + + call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk'))) + call delete('Xlink.lnk') + else + echomsg 'skipped test for shortcut file' + endif + + " remove files + call delete('Xlink') + call delete('Xdir', 'd') + call delete('Xfile') + + " test for symbolic link to a file + new Xfile + wq + silent !mklink Xlink Xfile + if !v:shell_error + call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink'))) + call delete('Xlink') + else + echomsg 'skipped test for symbolic link to a file' + endif + call delete('Xfile') + + " test for junction to a directory + call mkdir('Xdir') + silent !mklink /J Xlink Xdir + if !v:shell_error + call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) + + call delete('Xdir', 'd') + + " test for junction already removed + call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) + call delete('Xlink') + else + echomsg 'skipped test for junction to a directory' + call delete('Xdir', 'd') + endif + + " test for symbolic link to a directory + call mkdir('Xdir') + silent !mklink /D Xlink Xdir + if !v:shell_error + call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) + + call delete('Xdir', 'd') + + " test for symbolic link already removed + call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) + call delete('Xlink') + else + echomsg 'skipped test for symbolic link to a directory' + call delete('Xdir', 'd') + endif + + " test for buffer name + new Xfile + wq + silent !mklink Xlink Xfile + if !v:shell_error + edit Xlink + call assert_equal('Xlink', bufname('%')) + call delete('Xlink') + bw! + else + echomsg 'skipped test for buffer name' + endif + call delete('Xfile') +endfunc + func Test_simplify() call assert_equal('', simplify('')) call assert_equal('/', simplify('/')) diff --git a/src/version.c b/src/version.c index b86e5c8775..2563561644 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 894, /**/ 893, /**/ From ec0f50a35e207e01ff54cef954313030e3ab42a6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 10 Feb 2019 23:26:13 +0100 Subject: [PATCH 23/75] patch 8.1.0895: MS-Windows: dealing with temp name encoding not quite right Problem: MS-Windows: dealing with temp name encoding not quite right. Solution: Use more wide functions. (Ken Takata, closes #3921) --- src/fileio.c | 48 ++++++++++++++++-------------------------------- src/version.c | 2 ++ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index c1aa1a76f9..9ab90eb39b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -7322,6 +7322,8 @@ vim_tempname( { #ifdef USE_TMPNAM char_u itmp[L_tmpnam]; /* use tmpnam() */ +#elif defined(WIN3264) + WCHAR itmp[TEMPNAMELEN]; #else char_u itmp[TEMPNAMELEN]; #endif @@ -7443,51 +7445,33 @@ vim_tempname( #else /* TEMPDIRNAMES */ # ifdef WIN3264 - char szTempFile[_MAX_PATH + 1]; - char buf4[4]; + WCHAR wszTempFile[_MAX_PATH + 1]; + WCHAR buf4[4]; char_u *retval; char_u *p; - STRCPY(itmp, ""); - if (GetTempPath(_MAX_PATH, szTempFile) == 0) + wcscpy(itmp, L""); + if (GetTempPathW(_MAX_PATH, wszTempFile) == 0) { - szTempFile[0] = '.'; /* GetTempPath() failed, use current dir */ - szTempFile[1] = NUL; + wszTempFile[0] = L'.'; // GetTempPathW() failed, use current dir + wszTempFile[1] = NUL; } - strcpy(buf4, "VIM"); + wcscpy(buf4, L"VIM"); buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */ - if (GetTempFileName(szTempFile, buf4, 0, (LPSTR)itmp) == 0) + if (GetTempFileNameW(wszTempFile, buf4, 0, itmp) == 0) return NULL; if (!keep) - /* GetTempFileName() will create the file, we don't want that */ - (void)DeleteFile((LPSTR)itmp); + // GetTempFileName() will create the file, we don't want that + (void)DeleteFileW(itmp); - /* Backslashes in a temp file name cause problems when filtering with - * "sh". NOTE: This also checks 'shellcmdflag' to help those people who - * didn't set 'shellslash'. */ - retval = vim_strsave(itmp); + // Backslashes in a temp file name cause problems when filtering with + // "sh". NOTE: This also checks 'shellcmdflag' to help those people who + // didn't set 'shellslash'. + retval = utf16_to_enc(itmp, NULL); if (*p_shcf == '-' || p_ssl) for (p = retval; *p; ++p) if (*p == '\\') *p = '/'; - -#if defined(WIN3264) - if (enc_utf8) - { - int len; - char_u *pp = NULL; - - // Convert from active codepage to UTF-8 since mch_call_shell() - // converts command-line to wide string from encoding. - acp_to_enc(retval, (int)STRLEN(retval), &pp, &len); - if (pp != NULL) - { - vim_free(retval); - return pp; - } - } -#endif - return retval; # else /* WIN3264 */ diff --git a/src/version.c b/src/version.c index 2563561644..33353ba845 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 895, /**/ 894, /**/ From 5a6698169d10833abad88c98e5a332ddde5d110d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 11 Feb 2019 21:45:00 +0100 Subject: [PATCH 24/75] patch 8.1.0896: tests for restricted mode no run for MS-Windows GUI Problem: Tests for restricted mode no run for MS-Windows GUI. Solution: Make tests also work in MS-Windows GUI. --- src/testdir/test_restricted.vim | 35 ++++++++++++--------------------- src/version.c | 2 ++ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/testdir/test_restricted.vim b/src/testdir/test_restricted.vim index 85da94c418..a29f7c33d3 100644 --- a/src/testdir/test_restricted.vim +++ b/src/testdir/test_restricted.vim @@ -2,27 +2,13 @@ source shared.vim -if has('win32') && has('gui') - " Win32 GUI shows a dialog instead of displaying the error in the last line. - finish -endif +"if has('win32') && has('gui') +" " Win32 GUI shows a dialog instead of displaying the error in the last line. +" finish +"endif func Test_restricted() - let cmd = GetVimCommand('Xrestricted') - if cmd == '' - return - endif - - call writefile([ - \ "silent !ls", - \ "call writefile([v:errmsg], 'Xrestrout')", - \ "qa!", - \ ], 'Xrestricted') - call system(cmd . ' -Z') - call assert_match('E145:', join(readfile('Xrestrout'))) - - call delete('Xrestricted') - call delete('Xrestrout') + call Run_restricted_test('!ls', 'E145:') endfunc func Run_restricted_test(ex_cmd, error) @@ -31,10 +17,15 @@ func Run_restricted_test(ex_cmd, error) return endif + " Use a VimEnter autocommand to avoid that the error message is displayed in + " a dialog with an OK button. call writefile([ - \ a:ex_cmd, - \ "call writefile([v:errmsg], 'Xrestrout')", - \ "qa!", + \ "func Init()", + \ " silent! " . a:ex_cmd, + \ " call writefile([v:errmsg], 'Xrestrout')", + \ " qa!", + \ "endfunc", + \ "au VimEnter * call Init()", \ ], 'Xrestricted') call system(cmd . ' -Z') call assert_match(a:error, join(readfile('Xrestrout'))) diff --git a/src/version.c b/src/version.c index 33353ba845..6e3c6f4089 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 896, /**/ 895, /**/ From 05c00c038bc16e862e17f9e5c8d5a72af6cf7788 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 11 Feb 2019 22:00:11 +0100 Subject: [PATCH 25/75] patch 8.1.0897: can modify a:000 when using a reference Problem: Can modify a:000 when using a reference. Solution: Make check for locked variable stricter. (Ozaki Kiichi, closes #3930) --- src/dict.c | 4 +- src/eval.c | 106 +++++++++++++++++++++++------------ src/evalfunc.c | 21 +++---- src/proto/eval.pro | 2 +- src/testdir/test_channel.vim | 4 +- src/testdir/test_let.vim | 2 +- src/userfunc.c | 4 +- src/version.c | 2 + 8 files changed, 90 insertions(+), 55 deletions(-) diff --git a/src/dict.c b/src/dict.c index 91c6e55724..0bb9dfa875 100644 --- a/src/dict.c +++ b/src/dict.c @@ -758,8 +758,8 @@ dict_extend(dict_T *d1, dict_T *d2, char_u *action) } else if (*action == 'f' && HI2DI(hi2) != di1) { - if (tv_check_lock(di1->di_tv.v_lock, arg_errmsg, TRUE) - || var_check_ro(di1->di_flags, arg_errmsg, TRUE)) + if (var_check_lock(di1->di_tv.v_lock, arg_errmsg, TRUE) + || var_check_ro(di1->di_flags, arg_errmsg, TRUE)) break; clear_tv(&di1->di_tv); copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv); diff --git a/src/eval.c b/src/eval.c index c30c5d83c0..484f9bcc45 100644 --- a/src/eval.c +++ b/src/eval.c @@ -247,6 +247,7 @@ static typval_T *alloc_string_tv(char_u *string); static void delete_var(hashtab_T *ht, hashitem_T *hi); static void list_one_var(dictitem_T *v, char *prefix, int *first); static void list_one_var_a(char *prefix, char_u *name, int type, char_u *string, int *first); +static int tv_check_lock(typval_T *tv, char_u *name, int use_gettext); static char_u *find_option_end(char_u **arg, int *opt_flags); /* for VIM_VERSION_ defines */ @@ -2332,9 +2333,8 @@ set_var_lval( &tv, &di, TRUE, FALSE) == OK) { if ((di == NULL - || (!var_check_ro(di->di_flags, lp->ll_name, FALSE) - && !tv_check_lock(di->di_tv.v_lock, lp->ll_name, - FALSE))) + || (!var_check_ro(di->di_flags, lp->ll_name, FALSE) + && !tv_check_lock(&di->di_tv, lp->ll_name, FALSE))) && tv_op(&tv, rettv, op) == OK) set_var(lp->ll_name, &tv, FALSE); clear_tv(&tv); @@ -2344,7 +2344,7 @@ set_var_lval( set_var(lp->ll_name, rettv, copy); *endp = cc; } - else if (tv_check_lock(lp->ll_newkey == NULL + else if (var_check_lock(lp->ll_newkey == NULL ? lp->ll_tv->v_lock : lp->ll_tv->vval.v_dict->dv_lock, lp->ll_name, FALSE)) ; @@ -2358,7 +2358,7 @@ set_var_lval( */ for (ri = rettv->vval.v_list->lv_first; ri != NULL && ll_li != NULL; ) { - if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE)) + if (var_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE)) return; ri = ri->li_next; if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == ll_n1)) @@ -2951,9 +2951,9 @@ do_unlet_var( *name_end = cc; } else if ((lp->ll_list != NULL - && tv_check_lock(lp->ll_list->lv_lock, lp->ll_name, FALSE)) + && var_check_lock(lp->ll_list->lv_lock, lp->ll_name, FALSE)) || (lp->ll_dict != NULL - && tv_check_lock(lp->ll_dict->dv_lock, lp->ll_name, FALSE))) + && var_check_lock(lp->ll_dict->dv_lock, lp->ll_name, FALSE))) return FAIL; else if (lp->ll_range) { @@ -2964,7 +2964,7 @@ do_unlet_var( while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1)) { li = ll_li->li_next; - if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE)) + if (var_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE)) return FAIL; ll_li = li; ++ll_n1; @@ -3034,7 +3034,7 @@ do_unlet(char_u *name, int forceit) di = HI2DI(hi); if (var_check_fixed(di->di_flags, name, FALSE) || var_check_ro(di->di_flags, name, FALSE) - || tv_check_lock(d->dv_lock, name, FALSE)) + || var_check_lock(d->dv_lock, name, FALSE)) return FAIL; delete_var(ht, hi); @@ -7866,7 +7866,7 @@ set_var( { /* existing variable, need to clear the value */ if (var_check_ro(v->di_flags, name, FALSE) - || tv_check_lock(v->di_tv.v_lock, name, FALSE)) + || var_check_lock(v->di_tv.v_lock, name, FALSE)) return; /* @@ -8021,31 +8021,12 @@ var_check_func_name( } /* - * Check if a variable name is valid. - * Return FALSE and give an error if not. - */ - int -valid_varname(char_u *varname) -{ - char_u *p; - - for (p = varname; *p != NUL; ++p) - if (!eval_isnamec1(*p) && (p == varname || !VIM_ISDIGIT(*p)) - && *p != AUTOLOAD_CHAR) - { - semsg(_(e_illvar), varname); - return FALSE; - } - return TRUE; -} - -/* - * Return TRUE if typeval "tv" is set to be locked (immutable). + * Return TRUE if "flags" indicates variable "name" is locked (immutable). * Also give an error message, using "name" or _("name") when use_gettext is * TRUE. */ int -tv_check_lock(int lock, char_u *name, int use_gettext) +var_check_lock(int lock, char_u *name, int use_gettext) { if (lock & VAR_LOCKED) { @@ -8066,6 +8047,56 @@ tv_check_lock(int lock, char_u *name, int use_gettext) return FALSE; } +/* + * Return TRUE if typeval "tv" and its value are set to be locked (immutable). + * Also give an error message, using "name" or _("name") when use_gettext is + * TRUE. + */ + static int +tv_check_lock(typval_T *tv, char_u *name, int use_gettext) +{ + int lock = 0; + + switch (tv->v_type) + { + case VAR_BLOB: + if (tv->vval.v_blob != NULL) + lock = tv->vval.v_blob->bv_lock; + break; + case VAR_LIST: + if (tv->vval.v_list != NULL) + lock = tv->vval.v_list->lv_lock; + break; + case VAR_DICT: + if (tv->vval.v_dict != NULL) + lock = tv->vval.v_dict->dv_lock; + break; + default: + break; + } + return var_check_lock(tv->v_lock, name, use_gettext) + || (lock != 0 && var_check_lock(lock, name, use_gettext)); +} + +/* + * Check if a variable name is valid. + * Return FALSE and give an error if not. + */ + int +valid_varname(char_u *varname) +{ + char_u *p; + + for (p = varname; *p != NUL; ++p) + if (!eval_isnamec1(*p) && (p == varname || !VIM_ISDIGIT(*p)) + && *p != AUTOLOAD_CHAR) + { + semsg(_(e_illvar), varname); + return FALSE; + } + return TRUE; +} + /* * Copy the values from typval_T "from" to typval_T "to". * When needed allocates string or increases reference count. @@ -10711,13 +10742,13 @@ filter_map(typval_T *argvars, typval_T *rettv, int map) else if (argvars[0].v_type == VAR_LIST) { if ((l = argvars[0].vval.v_list) == NULL - || (!map && tv_check_lock(l->lv_lock, arg_errmsg, TRUE))) + || (!map && var_check_lock(l->lv_lock, arg_errmsg, TRUE))) return; } else if (argvars[0].v_type == VAR_DICT) { if ((d = argvars[0].vval.v_dict) == NULL - || (!map && tv_check_lock(d->dv_lock, arg_errmsg, TRUE))) + || (!map && var_check_lock(d->dv_lock, arg_errmsg, TRUE))) return; } else @@ -10755,9 +10786,10 @@ filter_map(typval_T *argvars, typval_T *rettv, int map) --todo; di = HI2DI(hi); - if (map && - (tv_check_lock(di->di_tv.v_lock, arg_errmsg, TRUE) - || var_check_ro(di->di_flags, arg_errmsg, TRUE))) + if (map && (var_check_lock(di->di_tv.v_lock, + arg_errmsg, TRUE) + || var_check_ro(di->di_flags, + arg_errmsg, TRUE))) break; vimvars[VV_KEY].vv_str = vim_strsave(di->di_key); r = filter_map_one(&di->di_tv, expr, map, &rem); @@ -10813,7 +10845,7 @@ filter_map(typval_T *argvars, typval_T *rettv, int map) for (li = l->lv_first; li != NULL; li = nli) { - if (map && tv_check_lock(li->li_tv.v_lock, arg_errmsg, TRUE)) + if (map && var_check_lock(li->li_tv.v_lock, arg_errmsg, TRUE)) break; nli = li->li_next; vimvars[VV_KEY].vv_nr = idx; diff --git a/src/evalfunc.c b/src/evalfunc.c index 4c03470224..6982ddfe1a 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1248,7 +1248,7 @@ f_add(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type == VAR_LIST) { if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, + && !var_check_lock(l->lv_lock, (char_u *)N_("add() argument"), TRUE) && list_append_tv(l, &argvars[1]) == OK) copy_tv(&argvars[0], rettv); @@ -1256,7 +1256,7 @@ f_add(typval_T *argvars, typval_T *rettv) else if (argvars[0].v_type == VAR_BLOB) { if ((b = argvars[0].vval.v_blob) != NULL - && !tv_check_lock(b->bv_lock, + && !var_check_lock(b->bv_lock, (char_u *)N_("add() argument"), TRUE)) { int error = FALSE; @@ -3579,7 +3579,7 @@ f_extend(typval_T *argvars, typval_T *rettv) l1 = argvars[0].vval.v_list; l2 = argvars[1].vval.v_list; - if (l1 != NULL && !tv_check_lock(l1->lv_lock, arg_errmsg, TRUE) + if (l1 != NULL && !var_check_lock(l1->lv_lock, arg_errmsg, TRUE) && l2 != NULL) { if (argvars[2].v_type != VAR_UNKNOWN) @@ -3615,7 +3615,7 @@ f_extend(typval_T *argvars, typval_T *rettv) d1 = argvars[0].vval.v_dict; d2 = argvars[1].vval.v_dict; - if (d1 != NULL && !tv_check_lock(d1->dv_lock, arg_errmsg, TRUE) + if (d1 != NULL && !var_check_lock(d1->dv_lock, arg_errmsg, TRUE) && d2 != NULL) { /* Check the third argument. */ @@ -7266,8 +7266,9 @@ f_insert(typval_T *argvars, typval_T *rettv) } else if (argvars[0].v_type != VAR_LIST) semsg(_(e_listblobarg), "insert()"); - else if ((l = argvars[0].vval.v_list) != NULL && !tv_check_lock(l->lv_lock, - (char_u *)N_("insert() argument"), TRUE)) + else if ((l = argvars[0].vval.v_list) != NULL + && !var_check_lock(l->lv_lock, + (char_u *)N_("insert() argument"), TRUE)) { if (argvars[2].v_type != VAR_UNKNOWN) before = (long)tv_get_number_chk(&argvars[2], &error); @@ -9698,7 +9699,7 @@ f_remove(typval_T *argvars, typval_T *rettv) if (argvars[2].v_type != VAR_UNKNOWN) semsg(_(e_toomanyarg), "remove()"); else if ((d = argvars[0].vval.v_dict) != NULL - && !tv_check_lock(d->dv_lock, arg_errmsg, TRUE)) + && !var_check_lock(d->dv_lock, arg_errmsg, TRUE)) { key = tv_get_string_chk(&argvars[1]); if (key != NULL) @@ -9781,7 +9782,7 @@ f_remove(typval_T *argvars, typval_T *rettv) else if (argvars[0].v_type != VAR_LIST) semsg(_(e_listdictblobarg), "remove()"); else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, arg_errmsg, TRUE)) + && !var_check_lock(l->lv_lock, arg_errmsg, TRUE)) { idx = (long)tv_get_number_chk(&argvars[1], &error); if (error) @@ -10128,7 +10129,7 @@ f_reverse(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type != VAR_LIST) semsg(_(e_listblobarg), "reverse()"); else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, + && !var_check_lock(l->lv_lock, (char_u *)N_("reverse() argument"), TRUE)) { li = l->lv_last; @@ -12112,7 +12113,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) else { l = argvars[0].vval.v_list; - if (l == NULL || tv_check_lock(l->lv_lock, + if (l == NULL || var_check_lock(l->lv_lock, (char_u *)(sort ? N_("sort() argument") : N_("uniq() argument")), TRUE)) goto theend; diff --git a/src/proto/eval.pro b/src/proto/eval.pro index 1e673e3c8b..ba75f07986 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -103,8 +103,8 @@ void set_var(char_u *name, typval_T *tv, int copy); int var_check_ro(int flags, char_u *name, int use_gettext); int var_check_fixed(int flags, char_u *name, int use_gettext); int var_check_func_name(char_u *name, int new_var); +int var_check_lock(int lock, char_u *name, int use_gettext); int valid_varname(char_u *varname); -int tv_check_lock(int lock, char_u *name, int use_gettext); void copy_tv(typval_T *from, typval_T *to); int item_copy(typval_T *from, typval_T *to, int deep, int copyID); void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog, int secret); diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index e263115392..67163e606b 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -2062,9 +2062,9 @@ func Test_job_tty_in_out() for in_opt in in_opts let x = copy(in_opt) for out_opt in out_opts - call extend(x, out_opt) + let x = extend(copy(x), out_opt) for err_opt in err_opts - call extend(x, err_opt) + let x = extend(copy(x), err_opt) let opts += [extend({'pty': 1}, x)] endfor endfor diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim index 550655cb6e..40eabb8cf0 100644 --- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -142,7 +142,7 @@ func Test_let_varg_fail() call assert_fails('call s:set_varg4(1)', 'E742:') call s:set_varg5([0]) call assert_fails('call s:set_varg6(1)', 'E742:') - " call assert_fails('call s:set_varg7(1)', 'E46:') + call assert_fails('call s:set_varg7(1)', 'E742:') call assert_fails('call s:set_varg8(1)', 'E742:') call s:set_varg9([0]) endfunction diff --git a/src/userfunc.c b/src/userfunc.c index d1ea33afeb..a293dd68e3 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2394,11 +2394,11 @@ ex_function(exarg_T *eap) if (fudi.fd_di == NULL) { /* Can't add a function to a locked dictionary */ - if (tv_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE)) + if (var_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE)) goto erret; } /* Can't change an existing function if it is locked */ - else if (tv_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE)) + else if (var_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE)) goto erret; /* Give the function a sequential number. Can only be used with a diff --git a/src/version.c b/src/version.c index 6e3c6f4089..6e3d7806fb 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 897, /**/ 896, /**/ From 0ea21e41c6789c356762f970ecf168a897dcf8b6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 20:46:48 +0100 Subject: [PATCH 26/75] patch 8.1.0898: a messed up rgb.txt can crash Vim Problem: A messed up rgb.txt can crash Vim. (Pavel Cheremushkin) Solution: Limit to 10000 entries. Also don't retry many times when the file cannot be read. --- src/term.c | 10 ++++++++-- src/version.c | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/term.c b/src/term.c index 47d2bdafb1..be33fb92d5 100644 --- a/src/term.c +++ b/src/term.c @@ -6985,13 +6985,13 @@ gui_get_color_cmn(char_u *name) return rgb_table[i].color; /* - * Last attempt. Look in the file "$VIM/rgb.txt". + * Last attempt. Look in the file "$VIMRUNTIME/rgb.txt". */ if (size == 0) { int counting; - /* colornames_table not yet initialized */ + // colornames_table not yet initialized fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) return INVALCOLOR; @@ -7002,6 +7002,7 @@ gui_get_color_cmn(char_u *name) { if (p_verbose > 1) verb_msg(_("Cannot open $VIMRUNTIME/rgb.txt")); + size = -1; // don't try again return INVALCOLOR; } @@ -7050,6 +7051,11 @@ gui_get_color_cmn(char_u *name) colornames_table[size].color = (guicolor_T)RGB(r, g, b); } size++; + + // The distributed rgb.txt has less than 1000 entries. Limit to + // 10000, just in case the file was messed up. + if (size == 10000) + break; } } fclose(fd); diff --git a/src/version.c b/src/version.c index 6e3d7806fb..a2c250e529 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 898, /**/ 897, /**/ From e0fb7d1e38e1cf699412e212cda863420f5f8bd2 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 20:48:10 +0100 Subject: [PATCH 27/75] patch 8.1.0899: no need to check restricted mode for setwinvar() Problem: No need to check restricted mode for setwinvar(). Solution: Remove check_restricted(). --- src/eval.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 484f9bcc45..46d24ef788 100644 --- a/src/eval.c +++ b/src/eval.c @@ -8750,7 +8750,7 @@ setwinvar(typval_T *argvars, typval_T *rettv UNUSED, int off) char_u nbuf[NUMBUFLEN]; tabpage_T *tp = NULL; - if (check_restricted() || check_secure()) + if (check_secure()) return; if (off == 1) diff --git a/src/version.c b/src/version.c index a2c250e529..f3e1081822 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 899, /**/ 898, /**/ From 48773f1f83e666c49b9d88ea6a392d50215ca013 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 21:46:46 +0100 Subject: [PATCH 28/75] patch 8.1.0900: ConPTY many crash with 32-bit build Problem: ConPTY many crash with 32-bit build. Solution: Fix function declarations. (Ken Takata, closes #3943) --- src/terminal.c | 6 +++--- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 27ff24f103..2544f8567a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5489,9 +5489,9 @@ term_getjob(term_T *term) HRESULT (WINAPI *pCreatePseudoConsole)(COORD, HANDLE, HANDLE, DWORD, HPCON*); HRESULT (WINAPI *pResizePseudoConsole)(HPCON, COORD); HRESULT (WINAPI *pClosePseudoConsole)(HPCON); -BOOL (*pInitializeProcThreadAttributeList)(LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD, PSIZE_T); -BOOL (*pUpdateProcThreadAttribute)(LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD_PTR, PVOID, SIZE_T, PVOID, PSIZE_T); -void (*pDeleteProcThreadAttributeList)(LPPROC_THREAD_ATTRIBUTE_LIST); +BOOL (WINAPI *pInitializeProcThreadAttributeList)(LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD, PSIZE_T); +BOOL (WINAPI *pUpdateProcThreadAttribute)(LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD_PTR, PVOID, SIZE_T, PVOID, PSIZE_T); +void (WINAPI *pDeleteProcThreadAttributeList)(LPPROC_THREAD_ATTRIBUTE_LIST); static int dyn_conpty_init(int verbose) diff --git a/src/version.c b/src/version.c index f3e1081822..b02be7c1df 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 900, /**/ 899, /**/ From 57ee2b6e0b5b730d12ee9db00a8e2a577df9e374 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 22:15:06 +0100 Subject: [PATCH 29/75] patch 8.1.0901: index in getjumplist() may be wrong Problem: Index in getjumplist() may be wrong. (Epheien) Solution: Call cleanup_jumplist() earlier. (Yegappan Lakshmanan, closes #3941) --- src/evalfunc.c | 4 ++-- src/testdir/test_jumplist.vim | 16 ++++++++++------ src/version.c | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/evalfunc.c b/src/evalfunc.c index 6982ddfe1a..6538b36d3c 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5271,6 +5271,8 @@ f_getjumplist(typval_T *argvars, typval_T *rettv) if (wp == NULL) return; + cleanup_jumplist(wp, TRUE); + l = list_alloc(); if (l == NULL) return; @@ -5279,8 +5281,6 @@ f_getjumplist(typval_T *argvars, typval_T *rettv) return; list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx); - cleanup_jumplist(wp, TRUE); - for (i = 0; i < wp->w_jumplistlen; ++i) { if (wp->w_jumplist[i].fmark.mark.lnum == 0) diff --git a/src/testdir/test_jumplist.vim b/src/testdir/test_jumplist.vim index 02dbd76194..be1af5e705 100644 --- a/src/testdir/test_jumplist.vim +++ b/src/testdir/test_jumplist.vim @@ -28,11 +28,13 @@ func Test_getjumplist() normal G normal gg - call assert_equal([[ + let expected = [[ \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, - \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4], - \ getjumplist()) + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 3] + call assert_equal(expected, getjumplist()) + " jumplist doesn't change in between calls + call assert_equal(expected, getjumplist()) " Traverse the jump list and verify the results 5 @@ -44,12 +46,14 @@ func Test_getjumplist() call assert_equal(3, getjumplist()[1]) exe "normal \" normal 20% - call assert_equal([[ + let expected = [[ \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0}, - \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 5], - \ getjumplist()) + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4] + call assert_equal(expected, getjumplist()) + " jumplist doesn't change in between calls + call assert_equal(expected, getjumplist()) let l = getjumplist() call test_garbagecollect_now() diff --git a/src/version.c b/src/version.c index b02be7c1df..998f259bad 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 901, /**/ 900, /**/ From ff697e6cef8ced7717a21fd525ab3200b2f1724f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 22:28:33 +0100 Subject: [PATCH 30/75] patch 8.1.0902: incomplete set of assignment operators Problem: Incomplete set of assignment operators. Solution: Add /=, *= and %=. (Ozaki Kiichi, closes #3931) --- runtime/doc/eval.txt | 6 ++- src/eval.c | 88 +++++++++++++++++++++------------- src/testdir/test_vimscript.vim | 78 ++++++++++++++++++++++++++++++ src/version.c | 2 + 4 files changed, 140 insertions(+), 34 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c2150e5b90..535517d21d 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -10836,9 +10836,13 @@ This does NOT work: > When the selected range of items is partly past the end of the list, items will be added. - *:let+=* *:let-=* *:let.=* *E734* + *:let+=* *:let-=* *:letstar=* + *:let/=* *:let%=* *:let.=* *E734* :let {var} += {expr1} Like ":let {var} = {var} + {expr1}". :let {var} -= {expr1} Like ":let {var} = {var} - {expr1}". +:let {var} *= {expr1} Like ":let {var} = {var} * {expr1}". +:let {var} /= {expr1} Like ":let {var} = {var} / {expr1}". +:let {var} %= {expr1} Like ":let {var} = {var} % {expr1}". :let {var} .= {expr1} Like ":let {var} = {var} . {expr1}". These fail if {var} was not set yet and when the type of {var} and {expr1} don't fit the operator. diff --git a/src/eval.c b/src/eval.c index 46d24ef788..56a26b1aea 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1197,6 +1197,9 @@ eval_foldexpr(char_u *arg, int *cp) * ":let var = expr" assignment command. * ":let var += expr" assignment command. * ":let var -= expr" assignment command. + * ":let var *= expr" assignment command. + * ":let var /= expr" assignment command. + * ":let var %= expr" assignment command. * ":let var .= expr" assignment command. * ":let [var1, var2] = expr" unpack list. */ @@ -1216,10 +1219,10 @@ ex_let(exarg_T *eap) argend = skip_var_list(arg, &var_count, &semicolon); if (argend == NULL) return; - if (argend > arg && argend[-1] == '.') /* for var.='str' */ + if (argend > arg && argend[-1] == '.') // for var.='str' --argend; expr = skipwhite(argend); - if (*expr != '=' && !(vim_strchr((char_u *)"+-.", *expr) != NULL + if (*expr != '=' && !(vim_strchr((char_u *)"+-*/%.", *expr) != NULL && expr[1] == '=')) { /* @@ -1249,8 +1252,8 @@ ex_let(exarg_T *eap) op[1] = NUL; if (*expr != '=') { - if (vim_strchr((char_u *)"+-.", *expr) != NULL) - op[0] = *expr; /* +=, -= or .= */ + if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) + op[0] = *expr; // +=, -=, *=, /=, %= or .= expr = skipwhite(expr + 2); } else @@ -1671,7 +1674,7 @@ ex_let_one( semsg(_(e_invarg2), name - 1); else { - if (op != NULL && (*op == '+' || *op == '-')) + if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) semsg(_(e_letwrong), op); else if (endchars != NULL && vim_strchr(endchars, *skipwhite(arg)) == NULL) @@ -1744,18 +1747,22 @@ ex_let_one( || (opt_type == 0 && *op != '.')) { semsg(_(e_letwrong), op); - s = NULL; /* don't set the value */ + s = NULL; // don't set the value } else { - if (opt_type == 1) /* number */ + if (opt_type == 1) // number { - if (*op == '+') - n = numval + n; - else - n = numval - n; + switch (*op) + { + case '+': n = numval + n; break; + case '-': n = numval - n; break; + case '*': n = numval * n; break; + case '/': n = numval / n; break; + case '%': n = numval % n; break; + } } - else if (opt_type == 0 && stringval != NULL) /* string */ + else if (opt_type == 0 && stringval != NULL) // string { s = concat_str(stringval, s); vim_free(stringval); @@ -1779,7 +1786,7 @@ ex_let_one( else if (*arg == '@') { ++arg; - if (op != NULL && (*op == '+' || *op == '-')) + if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) semsg(_(e_letwrong), op); else if (endchars != NULL && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) @@ -2254,7 +2261,8 @@ clear_lval(lval_T *lp) /* * Set a variable that was parsed by get_lval() to "rettv". * "endp" points to just after the parsed name. - * "op" is NULL, "+" for "+=", "-" for "-=", "." for ".=" or "=" for "=". + * "op" is NULL, "+" for "+=", "-" for "-=", "*" for "*=", "/" for "/=", + * "%" for "%=", "." for ".=" or "=" for "=". */ static void set_var_lval( @@ -2327,7 +2335,7 @@ set_var_lval( { typval_T tv; - /* handle +=, -= and .= */ + // handle +=, -=, *=, /=, %= and .= di = NULL; if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name), &tv, &di, TRUE, FALSE) == OK) @@ -2448,7 +2456,8 @@ set_var_lval( } /* - * Handle "tv1 += tv2", "tv1 -= tv2" and "tv1 .= tv2" + * Handle "tv1 += tv2", "tv1 -= tv2", "tv1 *= tv2", "tv1 /= tv2", "tv1 %= tv2" + * and "tv1 .= tv2" * Returns OK or FAIL. */ static int @@ -2490,7 +2499,7 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) case VAR_LIST: if (*op != '+' || tv2->v_type != VAR_LIST) break; - /* List += List */ + // List += List if (tv1->vval.v_list != NULL && tv2->vval.v_list != NULL) list_extend(tv1->vval.v_list, tv2->vval.v_list, NULL); return OK; @@ -2499,19 +2508,24 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) case VAR_STRING: if (tv2->v_type == VAR_LIST) break; - if (*op == '+' || *op == '-') + if (vim_strchr((char_u *)"+-*/%", *op) != NULL) { - /* nr += nr or nr -= nr*/ + // nr += nr , nr -= nr , nr *=nr , nr /= nr , nr %= nr n = tv_get_number(tv1); #ifdef FEAT_FLOAT if (tv2->v_type == VAR_FLOAT) { float_T f = n; - if (*op == '+') - f += tv2->vval.v_float; - else - f -= tv2->vval.v_float; + if (*op == '%') + break; + switch (*op) + { + case '+': f += tv2->vval.v_float; break; + case '-': f -= tv2->vval.v_float; break; + case '*': f *= tv2->vval.v_float; break; + case '/': f /= tv2->vval.v_float; break; + } clear_tv(tv1); tv1->v_type = VAR_FLOAT; tv1->vval.v_float = f; @@ -2519,10 +2533,14 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) else #endif { - if (*op == '+') - n += tv_get_number(tv2); - else - n -= tv_get_number(tv2); + switch (*op) + { + case '+': n += tv_get_number(tv2); break; + case '-': n -= tv_get_number(tv2); break; + case '*': n *= tv_get_number(tv2); break; + case '/': n /= tv_get_number(tv2); break; + case '%': n %= tv_get_number(tv2); break; + } clear_tv(tv1); tv1->v_type = VAR_NUMBER; tv1->vval.v_number = n; @@ -2533,7 +2551,7 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) if (tv2->v_type == VAR_FLOAT) break; - /* str .= str */ + // str .= str s = tv_get_string(tv1); s = concat_str(s, tv_get_string_buf(tv2, numbuf)); clear_tv(tv1); @@ -2547,7 +2565,8 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) { float_T f; - if (*op == '.' || (tv2->v_type != VAR_FLOAT + if (*op == '%' || *op == '.' + || (tv2->v_type != VAR_FLOAT && tv2->v_type != VAR_NUMBER && tv2->v_type != VAR_STRING)) break; @@ -2555,10 +2574,13 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) f = tv2->vval.v_float; else f = tv_get_number(tv2); - if (*op == '+') - tv1->vval.v_float += f; - else - tv1->vval.v_float -= f; + switch (*op) + { + case '+': tv1->vval.v_float += f; break; + case '-': tv1->vval.v_float -= f; break; + case '*': tv1->vval.v_float *= f; break; + case '/': tv1->vval.v_float /= f; break; + } } #endif return OK; diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim index 9de0a620c1..41a1dda7db 100644 --- a/src/testdir/test_vimscript.vim +++ b/src/testdir/test_vimscript.vim @@ -1441,6 +1441,84 @@ func Test_script_local_func() enew! | close endfunc +func Test_compound_assignment_operators() + " Test for number + let x = 1 + let x += 10 + call assert_equal(11, x) + let x -= 5 + call assert_equal(6, x) + let x *= 4 + call assert_equal(24, x) + let x /= 3 + call assert_equal(8, x) + let x %= 3 + call assert_equal(2, x) + let x .= 'n' + call assert_equal('2n', x) + + " Test for string + let x = 'str' + let x .= 'ing' + call assert_equal('string', x) + let x += 1 + call assert_equal(1, x) + let x -= 1.5 + call assert_equal(-0.5, x) + + if has('float') + " Test for float + let x = 0.5 + let x += 4.5 + call assert_equal(5.0, x) + let x -= 1.5 + call assert_equal(3.5, x) + let x *= 3.0 + call assert_equal(10.5, x) + let x /= 2.5 + call assert_equal(4.2, x) + call assert_fails('let x %= 0.5', 'E734') + call assert_fails('let x .= "f"', 'E734') + endif + + " Test for environment variable + let $FOO = 1 + call assert_fails('let $FOO += 1', 'E734') + call assert_fails('let $FOO -= 1', 'E734') + call assert_fails('let $FOO *= 1', 'E734') + call assert_fails('let $FOO /= 1', 'E734') + call assert_fails('let $FOO %= 1', 'E734') + let $FOO .= 's' + call assert_equal('1s', $FOO) + unlet $FOO + + " Test for option variable (type: number) + let &scrolljump = 1 + let &scrolljump += 5 + call assert_equal(6, &scrolljump) + let &scrolljump -= 2 + call assert_equal(4, &scrolljump) + let &scrolljump *= 3 + call assert_equal(12, &scrolljump) + let &scrolljump /= 2 + call assert_equal(6, &scrolljump) + let &scrolljump %= 5 + call assert_equal(1, &scrolljump) + call assert_fails('let &scrolljump .= "j"', 'E734') + set scrolljump&vim + + " Test for register + let @/ = 1 + call assert_fails('let @/ += 1', 'E734') + call assert_fails('let @/ -= 1', 'E734') + call assert_fails('let @/ *= 1', 'E734') + call assert_fails('let @/ /= 1', 'E734') + call assert_fails('let @/ %= 1', 'E734') + let @/ .= 's' + call assert_equal('1s', @/) + let @/ = '' +endfunc + "------------------------------------------------------------------------------- " Modelines {{{1 " vim: ts=8 sw=4 tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index 998f259bad..cadd46e4f4 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 902, /**/ 901, /**/ From beb7574d6b0eea1cae70aa2913a690da56de5307 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 22:33:00 +0100 Subject: [PATCH 31/75] patch 8.1.0903: struct uses more bytes than needed Problem: Struct uses more bytes than needed. Solution: Reorder members of regitem_S. (Dominique Pelle, closes #3936) --- src/regexp.c | 8 ++++---- src/version.c | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/regexp.c b/src/regexp.c index 9e6cf702d9..f06e15c833 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -3545,14 +3545,14 @@ typedef enum regstate_E */ typedef struct regitem_S { - regstate_T rs_state; /* what we are doing, one of RS_ above */ - char_u *rs_scan; /* current node in program */ + regstate_T rs_state; // what we are doing, one of RS_ above + short rs_no; // submatch nr or BEHIND/NOBEHIND + char_u *rs_scan; // current node in program union { save_se_T sesave; regsave_T regsave; - } rs_un; /* room for saving rex.input */ - short rs_no; /* submatch nr or BEHIND/NOBEHIND */ + } rs_un; // room for saving rex.input } regitem_T; static regitem_T *regstack_push(regstate_T state, char_u *scan); diff --git a/src/version.c b/src/version.c index cadd46e4f4..a6101b57a8 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 903, /**/ 902, /**/ From 00f148d2f24fb955ab36b0833811582c58b2cf2f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 22:37:27 +0100 Subject: [PATCH 32/75] patch 8.1.0904: USE_LONG_FNAME never defined Problem: USE_LONG_FNAME never defined. Solution: Remove using USE_LONG_FNAME. (Ken Takata, closes #3938) --- src/buffer.c | 14 +++----------- src/ex_cmds.c | 7 ++----- src/fileio.c | 20 +++----------------- src/version.c | 2 ++ 4 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 7dd4d34e28..db0c591613 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3168,10 +3168,7 @@ setfname( return FAIL; } #ifdef USE_FNAME_CASE -# ifdef USE_LONG_FNAME - if (USE_LONG_FNAME) -# endif - fname_case(sfname, 0); /* set correct case for short file name */ + fname_case(sfname, 0); /* set correct case for short file name */ #endif if (buf->b_sfname != buf->b_ffname) vim_free(buf->b_sfname); @@ -4808,13 +4805,8 @@ fix_fname(char_u *fname) fname = vim_strsave(fname); # ifdef USE_FNAME_CASE -# ifdef USE_LONG_FNAME - if (USE_LONG_FNAME) -# endif - { - if (fname != NULL) - fname_case(fname, 0); /* set correct case for file name */ - } + if (fname != NULL) + fname_case(fname, 0); /* set correct case for file name */ # endif return fname; diff --git a/src/ex_cmds.c b/src/ex_cmds.c index abb5f7096f..e9fa94f678 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3826,11 +3826,8 @@ do_ecmd( if (sfname == NULL) sfname = ffname; #ifdef USE_FNAME_CASE -# ifdef USE_LONG_FNAME - if (USE_LONG_FNAME) -# endif - if (sfname != NULL) - fname_case(sfname, 0); /* set correct case for sfname */ + if (sfname != NULL) + fname_case(sfname, 0); /* set correct case for sfname */ #endif if ((flags & ECMD_ADDBUF) && (ffname == NULL || *ffname == NUL)) diff --git a/src/fileio.c b/src/fileio.c index 9ab90eb39b..c7f3ad1768 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -6224,13 +6224,7 @@ buf_modname( */ for (ptr = retval + fnamelen; ptr > retval; MB_PTR_BACK(retval, ptr)) { - if (*ext == '.' -#ifdef USE_LONG_FNAME - && (!USE_LONG_FNAME || shortname) -#else - && shortname -#endif - ) + if (*ext == '.' && shortname) if (*ptr == '.') /* replace '.' by '_' */ *ptr = '_'; if (vim_ispathsep(*ptr)) @@ -6249,11 +6243,7 @@ buf_modname( /* * For 8.3 file names we may have to reduce the length. */ -#ifdef USE_LONG_FNAME - if (!USE_LONG_FNAME || shortname) -#else if (shortname) -#endif { /* * If there is no file name, or the file name ends in '/', and the @@ -6291,7 +6281,7 @@ buf_modname( else if ((int)STRLEN(e) + extlen > 4) s = e + 4 - extlen; } -#if defined(USE_LONG_FNAME) || defined(WIN3264) +#ifdef WIN3264 /* * If there is no file name, and the extension starts with '.', put a * '_' before the dot, because just ".ext" may be invalid if it's on a @@ -6310,11 +6300,7 @@ buf_modname( /* * Prepend the dot. */ - if (prepend_dot && !shortname && *(e = gettail(retval)) != '.' -#ifdef USE_LONG_FNAME - && USE_LONG_FNAME -#endif - ) + if (prepend_dot && !shortname && *(e = gettail(retval)) != '.') { STRMOVE(e + 1, e); *e = '.'; diff --git a/src/version.c b/src/version.c index a6101b57a8..20fdcba998 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 904, /**/ 903, /**/ From 5567ad48b66dff13670af52a48509059acc34dfe Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 23:05:46 +0100 Subject: [PATCH 33/75] patch 8.1.0905: complicated regexp causes a crash Problem: Complicated regexp causes a crash. (Kuang-che Wu) Solution: Limit the recursiveness of addstate(). (closes #3941) --- src/regexp_nfa.c | 83 ++++++++++++++++++++++++------- src/testdir/test_regexp_latin.vim | 6 +++ src/version.c | 2 + 3 files changed, 73 insertions(+), 18 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 031a6cf207..7c4d407576 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4284,6 +4284,7 @@ state_in_list( /* * Add "state" and possibly what follows to state list ".". * Returns "subs_arg", possibly copied into temp_subs. + * Returns NULL when recursiveness is too deep. */ static regsubs_T * addstate( @@ -4310,6 +4311,15 @@ addstate( #ifdef ENABLE_LOG int did_print = FALSE; #endif + static int depth = 0; + + // This function is called recursively. When the depth is too much we run + // out of stack and crash, limit recursiveness here. + if (++depth >= 10000 || subs == NULL) + { + --depth; + return NULL; + } if (off_arg <= -ADDSTATE_HERE_OFFSET) { @@ -4421,6 +4431,7 @@ skip_add: abs(state->id), l->id, state->c, code, pim == NULL ? "NULL" : "yes", l->has_pim, found); #endif + --depth; return subs; } } @@ -4595,7 +4606,9 @@ skip_add: } subs = addstate(l, state->out, subs, pim, off_arg); - /* "subs" may have changed, need to set "sub" again */ + if (subs == NULL) + break; + // "subs" may have changed, need to set "sub" again #ifdef FEAT_SYN_HL if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) sub = &subs->synt; @@ -4619,7 +4632,7 @@ skip_add: ? subs->norm.list.multi[0].end_lnum >= 0 : subs->norm.list.line[0].end != NULL)) { - /* Do not overwrite the position set by \ze. */ + // Do not overwrite the position set by \ze. subs = addstate(l, state->out, subs, pim, off_arg); break; } @@ -4695,6 +4708,8 @@ skip_add: } subs = addstate(l, state->out, subs, pim, off_arg); + if (subs == NULL) + break; /* "subs" may have changed, need to set "sub" again */ #ifdef FEAT_SYN_HL if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) @@ -4710,6 +4725,7 @@ skip_add: sub->in_use = save_in_use; break; } + --depth; return subs; } @@ -4719,7 +4735,7 @@ skip_add: * This makes sure the order of states to be tried does not change, which * matters for alternatives. */ - static void + static regsubs_T * addstate_here( nfa_list_T *l, /* runtime state list */ nfa_state_T *state, /* state to update */ @@ -4730,23 +4746,26 @@ addstate_here( int tlen = l->n; int count; int listidx = *ip; + regsubs_T *r; /* First add the state(s) at the end, so that we know how many there are. * Pass the listidx as offset (avoids adding another argument to * addstate(). */ - addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET); + r = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET); + if (r == NULL) + return r; - /* when "*ip" was at the end of the list, nothing to do */ + // when "*ip" was at the end of the list, nothing to do if (listidx + 1 == tlen) - return; + return r; - /* re-order to put the new state at the current position */ + // re-order to put the new state at the current position count = l->n - tlen; if (count == 0) - return; /* no state got added */ + return r; // no state got added if (count == 1) { - /* overwrite the current state */ + // overwrite the current state l->t[listidx] = l->t[l->n - 1]; } else if (count > 1) @@ -4760,7 +4779,7 @@ addstate_here( l->len = l->len * 3 / 2 + 50; newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T)); if (newl == NULL) - return; + return r; mch_memmove(&(newl[0]), &(l->t[0]), sizeof(nfa_thread_T) * listidx); @@ -4787,6 +4806,8 @@ addstate_here( } --l->n; *ip = listidx - 1; + + return r; } /* @@ -5493,6 +5514,7 @@ nfa_regmatch( int add_count; int add_off = 0; int toplevel = start->c == NFA_MOPEN; + regsubs_T *r; #ifdef NFA_REGEXP_DEBUG_LOG FILE *debug; #endif @@ -5567,10 +5589,15 @@ nfa_regmatch( else m->norm.list.line[0].start = rex.input; m->norm.in_use = 1; - addstate(thislist, start->out, m, NULL, 0); + r = addstate(thislist, start->out, m, NULL, 0); } else - addstate(thislist, start, m, NULL, 0); + r = addstate(thislist, start, m, NULL, 0); + if (r == NULL) + { + nfa_match = NFA_TOO_EXPENSIVE; + goto theend; + } #define ADD_STATE_IF_MATCH(state) \ if (result) { \ @@ -5874,8 +5901,12 @@ nfa_regmatch( /* t->state->out1 is the corresponding END_INVISIBLE * node; Add its out to the current list (zero-width * match). */ - addstate_here(thislist, t->state->out1->out, &t->subs, - &pim, &listidx); + if (addstate_here(thislist, t->state->out1->out, + &t->subs, &pim, &listidx) == NULL) + { + nfa_match = NFA_TOO_EXPENSIVE; + goto theend; + } } } break; @@ -6749,13 +6780,19 @@ nfa_regmatch( } if (add_here) - addstate_here(thislist, add_state, &t->subs, pim, &listidx); + r = addstate_here(thislist, add_state, &t->subs, + pim, &listidx); else { - addstate(nextlist, add_state, &t->subs, pim, add_off); + r = addstate(nextlist, add_state, &t->subs, pim, add_off); if (add_count > 0) nextlist->t[nextlist->n - 1].count = add_count; } + if (r == NULL) + { + nfa_match = NFA_TOO_EXPENSIVE; + goto theend; + } } } /* for (thislist = thislist; thislist->state; thislist++) */ @@ -6831,11 +6868,21 @@ nfa_regmatch( (colnr_T)(rex.input - rex.line) + clen; else m->norm.list.line[0].start = rex.input + clen; - addstate(nextlist, start->out, m, NULL, clen); + if (addstate(nextlist, start->out, m, NULL, clen) == NULL) + { + nfa_match = NFA_TOO_EXPENSIVE; + goto theend; + } } } else - addstate(nextlist, start, m, NULL, clen); + { + if (addstate(nextlist, start, m, NULL, clen) == NULL) + { + nfa_match = NFA_TOO_EXPENSIVE; + goto theend; + } + } } #ifdef ENABLE_LOG diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index 15249455ed..415a2764f1 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -84,3 +84,9 @@ func Test_multi_failure() call assert_fails('/a\{a}', 'E870:') set re=0 endfunc + +func Test_recursive_addstate() + " This will call addstate() recursively until it runs into the limit. + let lnum = search('\v((){328}){389}') + call assert_equal(0, lnum) +endfunc diff --git a/src/version.c b/src/version.c index 20fdcba998..f28d69dc66 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 905, /**/ 904, /**/ From e1ed53f3f95786c744d4b6c85bda4f476f67cc91 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Feb 2019 23:12:37 +0100 Subject: [PATCH 34/75] patch 8.1.0906: using clumsy way to get console window handle Problem: Using clumsy way to get console window handle. Solution: Use GetConsoleWindow(). (Ken Takata, closes #3940) --- src/os_mswin.c | 17 +---------------- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/os_mswin.c b/src/os_mswin.c index 8d46e53cf1..8dafaa35b1 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -1043,11 +1043,6 @@ extern HWND g_hWnd; /* This is in os_win32.c. */ static void GetConsoleHwnd(void) { -# define MY_BUFSIZE 1024 // Buffer size for console window titles. - - char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle. - char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle. - /* Skip if it's already set. */ if (s_hwnd != 0) return; @@ -1061,17 +1056,7 @@ GetConsoleHwnd(void) } # endif - GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); - - wsprintf(pszNewWindowTitle, "%s/%d/%d", - pszOldWindowTitle, - GetTickCount(), - GetCurrentProcessId()); - SetConsoleTitle(pszNewWindowTitle); - Sleep(40); - s_hwnd = FindWindow(NULL, pszNewWindowTitle); - - SetConsoleTitle(pszOldWindowTitle); + s_hwnd = GetConsoleWindow(); } /* diff --git a/src/version.c b/src/version.c index f28d69dc66..3a71b93929 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 906, /**/ 905, /**/ From 5382f12c910b7f8e46acdde5488f26a86f9fcac1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 01:18:38 +0100 Subject: [PATCH 35/75] patch 8.1.0907: CI tests on AppVeyor are failing Problem: CI tests on AppVeyor are failing. Solution: Reduce the recursiveness limit for regexp. --- src/regexp_nfa.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 7c4d407576..18bc8d9a60 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4315,7 +4315,7 @@ addstate( // This function is called recursively. When the depth is too much we run // out of stack and crash, limit recursiveness here. - if (++depth >= 10000 || subs == NULL) + if (++depth >= 5000 || subs == NULL) { --depth; return NULL; diff --git a/src/version.c b/src/version.c index 3a71b93929..a66e8b6adf 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 907, /**/ 906, /**/ From 9403a2168db82b7de80f792984084bb3f00e2263 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 18:35:06 +0100 Subject: [PATCH 36/75] patch 8.1.0908: can't handle large value for %{nr}v in regexp Problem: Can't handle large value for %{nr}v in regexp. (Kuang-che Wu) Solution: Give an error if the value is too large. (closes #3948) --- src/regexp_nfa.c | 9 ++++++--- src/version.c | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 18bc8d9a60..3e2ef93fa1 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1550,6 +1550,8 @@ nfa_regatom(void) } if (c == 'l' || c == 'c' || c == 'v') { + int limit = INT_MAX; + if (c == 'l') { /* \%{n}l \%{n}l */ @@ -1563,16 +1565,17 @@ nfa_regatom(void) EMIT(cmp == '<' ? NFA_COL_LT : cmp == '>' ? NFA_COL_GT : NFA_COL); else + { /* \%{n}v \%{n}v */ EMIT(cmp == '<' ? NFA_VCOL_LT : cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); -#if VIM_SIZEOF_INT < VIM_SIZEOF_LONG - if (n > INT_MAX) + limit = INT_MAX / MB_MAXBYTES; + } + if (n >= limit) { emsg(_("E951: \\% value too large")); return FAIL; } -#endif EMIT((int)n); break; } diff --git a/src/version.c b/src/version.c index a66e8b6adf..a6d7addc69 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 908, /**/ 907, /**/ From d9ef1b8d77f304c83241f807c17ffa26c9033778 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 19:23:10 +0100 Subject: [PATCH 37/75] patch 8.1.0909: MS-Windows: using ConPTY even though it is not stable Problem: MS-Windows: using ConPTY even though it is not stable. Solution: When ConPTY version is unstable, prefer using winpty. (Ken Takata, closes #3949) --- runtime/doc/options.txt | 8 +++++--- src/os_win32.c | 25 ++++++++++++++++++++----- src/proto/os_win32.pro | 4 +++- src/terminal.c | 4 ++-- src/version.c | 2 ++ 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 413342087e..6b2dde8257 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -8112,12 +8112,14 @@ A jump table for the options with a short description can be found at |Q_op|. window. Possible values are: - "" use ConPTY if possible, winpty otherwise + "" use ConPTY if it is stable, winpty otherwise "winpty" use winpty, fail if not supported "conpty" use |ConPTY|, fail if not supported - |ConPTY| support depends on the platform (Windows 10 October 2018 - edition). winpty support needs to be installed. If neither is + |ConPTY| support depends on the platform. Windows 10 October 2018 + Update is the first version that supports ConPTY, however it is still + considered unstable. ConPTY might become stable in the next release + of Windows 10. winpty support needs to be installed. If neither is supported then you cannot open a terminal window. *'terse'* *'noterse'* diff --git a/src/os_win32.c b/src/os_win32.c index 10ca41881e..0680346af0 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -187,6 +187,8 @@ static int win32_setattrs(char_u *name, int attrs); static int win32_set_archive(char_u *name); static int vtp_working = 0; +static int conpty_working = 0; +static int conpty_stable = 0; static void vtp_flag_init(); #ifndef FEAT_GUI_W32 @@ -7638,9 +7640,10 @@ mch_setenv(char *var, char *value, int x) /* * Support for pseudo-console (ConPTY) was added in windows 10 - * version 1809 (October 2018 update). + * version 1809 (October 2018 update). However, that version is unstable. */ -#define CONPTY_FIRST_SUPPORT_BUILD MAKE_VER(10, 0, 17763) +#define CONPTY_FIRST_SUPPORT_BUILD MAKE_VER(10, 0, 17763) +#define CONPTY_STABLE_BUILD MAKE_VER(10, 0, 32767) // T.B.D. static void vtp_flag_init(void) @@ -7659,10 +7662,10 @@ vtp_flag_init(void) vtp_working = 0; #endif -#ifdef FEAT_GUI_W32 if (ver >= CONPTY_FIRST_SUPPORT_BUILD) - vtp_working = 1; -#endif + conpty_working = 1; + if (ver >= CONPTY_STABLE_BUILD) + conpty_stable = 1; } @@ -7878,3 +7881,15 @@ has_vtp_working(void) { return vtp_working; } + + int +has_conpty_working(void) +{ + return conpty_working; +} + + int +is_conpty_stable(void) +{ + return conpty_stable; +} diff --git a/src/proto/os_win32.pro b/src/proto/os_win32.pro index 7f45c5cf16..6157e011fd 100644 --- a/src/proto/os_win32.pro +++ b/src/proto/os_win32.pro @@ -70,7 +70,9 @@ void set_alist_count(void); void fix_arg_enc(void); int mch_setenv(char *var, char *value, int x); void control_console_color_rgb(void); -int has_vtp_working(void); int use_vtp(void); int is_term_win32(void); +int has_vtp_working(void); +int has_conpty_working(void); +int is_conpty_stable(void); /* vim: set ft=c : */ diff --git a/src/terminal.c b/src/terminal.c index 2544f8567a..3be2698586 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5521,7 +5521,7 @@ dyn_conpty_init(int verbose) if (handled) return result; - if (!has_vtp_working()) + if (!has_conpty_working()) { handled = TRUE; result = FAIL; @@ -6139,7 +6139,7 @@ term_and_job_init( if (tty_type == NUL) { - if (has_conpty) + if (has_conpty && (is_conpty_stable() || !has_winpty)) use_conpty = TRUE; else if (has_winpty) use_winpty = TRUE; diff --git a/src/version.c b/src/version.c index a6d7addc69..bc4ae279bd 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 909, /**/ 908, /**/ From 15bbd6ec871a0efdd16256e1fccbaac0fd374cbd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 20:31:50 +0100 Subject: [PATCH 38/75] patch 8.1.0910: crash with tricky search pattern Problem: Crash with tricky search pattern. (Kuang-che Wu) Solution: Check for runnning out of memory. (closes #3950) --- src/regexp_nfa.c | 24 ++++++++++++++++-------- src/testdir/test_regexp_latin.vim | 7 +++++++ src/version.c | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 3e2ef93fa1..2a16fff94a 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4449,7 +4449,8 @@ skip_add: * be (a lot) bigger than anticipated. */ if (l->n == l->len) { - int newlen = l->len * 3 / 2 + 50; + int newlen = l->len * 3 / 2 + 50; + nfa_thread_T *newt; if (subs != &temp_subs) { @@ -4463,8 +4464,14 @@ skip_add: subs = &temp_subs; } - /* TODO: check for vim_realloc() returning NULL. */ - l->t = vim_realloc(l->t, newlen * sizeof(nfa_thread_T)); + newt = vim_realloc(l->t, newlen * sizeof(nfa_thread_T)); + if (newt == NULL) + { + // out of memory + --depth; + return NULL; + } + l->t = newt; l->len = newlen; } @@ -4756,7 +4763,7 @@ addstate_here( * addstate(). */ r = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET); if (r == NULL) - return r; + return NULL; // when "*ip" was at the end of the list, nothing to do if (listidx + 1 == tlen) @@ -4777,12 +4784,13 @@ addstate_here( { /* not enough space to move the new states, reallocate the list * and move the states to the right position */ - nfa_thread_T *newl; + int newlen = l->len * 3 / 2 + 50; + nfa_thread_T *newl; - l->len = l->len * 3 / 2 + 50; - newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T)); + newl = (nfa_thread_T *)alloc(newlen * sizeof(nfa_thread_T)); if (newl == NULL) - return r; + return NULL; + l->len = newlen; mch_memmove(&(newl[0]), &(l->t[0]), sizeof(nfa_thread_T) * listidx); diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index 415a2764f1..bcac6c72c8 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -90,3 +90,10 @@ func Test_recursive_addstate() let lnum = search('\v((){328}){389}') call assert_equal(0, lnum) endfunc + +func Test_out_of_memory() + new + s/^/,n + " This will be slow... + call assert_fails('call search("\\v((n||<)+);")', 'E363:') +endfunc diff --git a/src/version.c b/src/version.c index bc4ae279bd..59f7b5dadd 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 910, /**/ 909, /**/ From 943e9639a9ecb08bdec78ae6695c917bca6210b9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 21:19:14 +0100 Subject: [PATCH 39/75] patch 8.1.0911: tag line with Ex command cannot have extra fields Problem: Tag line with Ex command cannot have extra fields. Solution: Recognize |;" as the end of the command. (closes #2402) --- runtime/doc/tagsrch.txt | 9 ++++++++- src/tag.c | 18 +++++++++++++++--- src/testdir/test_taglist.vim | 16 +++++++++++++++- src/version.c | 2 ++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index e6589c70b6..f9cc1efdc0 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -571,7 +571,14 @@ only supported by new versions of ctags (such as Exuberant ctags). {term} ;" The two characters semicolon and double quote. This is interpreted by Vi as the start of a comment, which makes the following be ignored. This is for backwards compatibility - with Vi, it ignores the following fields. + with Vi, it ignores the following fields. Example: + APP file /^static int APP;$/;" v + When {tagaddress} is not a line number or search pattern, then + {term} must be |;". Here the bar ends the command (excluding + the bar) and ;" is used to have Vi ignore the rest of the + line. Example: + APP file.c call cursor(3, 4)|;" v + {field} .. A list of optional fields. Each field has the form: {fieldname}:{value} diff --git a/src/tag.c b/src/tag.c index b1915e1e14..a148fbc0e9 100644 --- a/src/tag.c +++ b/src/tag.c @@ -3014,7 +3014,10 @@ parse_match( p = tagp->command; if (find_extra(&p) == OK) { - tagp->command_end = p; + if (p > tagp->command && p[-1] == '|') + tagp->command_end = p - 1; // drop trailing bar + else + tagp->command_end = p; p += 2; /* skip ";\"" */ if (*p++ == TAB) while (ASCII_ISALPHA(*p)) @@ -3784,7 +3787,7 @@ find_extra(char_u **pp) { char_u *str = *pp; - /* Repeat for addresses separated with ';' */ + // Repeat for addresses separated with ';' for (;;) { if (VIM_ISDIGIT(*str)) @@ -3798,7 +3801,16 @@ find_extra(char_u **pp) ++str; } else - str = NULL; + { + // not a line number or search string, look for terminator. + str = (char_u *)strstr((char *)str, "|;\""); + if (str != NULL) + { + ++str; + break; + } + + } if (str == NULL || *str != ';' || !(VIM_ISDIGIT(str[1]) || str[1] == '/' || str[1] == '?')) break; diff --git a/src/testdir/test_taglist.vim b/src/testdir/test_taglist.vim index 0a9350adc7..de9ca0c809 100644 --- a/src/testdir/test_taglist.vim +++ b/src/testdir/test_taglist.vim @@ -5,7 +5,9 @@ func Test_taglist() \ "FFoo\tXfoo\t1", \ "FBar\tXfoo\t2", \ "BFoo\tXbar\t1", - \ "BBar\tXbar\t2" + \ "BBar\tXbar\t2", + \ "Kindly\tXbar\t3;\"\tv\tfile:", + \ "Command\tXbar\tcall cursor(3, 4)|;\"\td", \ ], 'Xtags') set tags=Xtags split Xtext @@ -15,6 +17,18 @@ func Test_taglist() call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name})) call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name})) + let kind = taglist("Kindly") + call assert_equal(1, len(kind)) + call assert_equal('v', kind[0]['kind']) + call assert_equal('3', kind[0]['cmd']) + call assert_equal(1, kind[0]['static']) + call assert_equal('Xbar', kind[0]['filename']) + + let cmd = taglist("Command") + call assert_equal(1, len(cmd)) + call assert_equal('d', cmd[0]['kind']) + call assert_equal('call cursor(3, 4)', cmd[0]['cmd']) + call delete('Xtags') bwipe endfunc diff --git a/src/version.c b/src/version.c index 59f7b5dadd..88960bafd2 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 911, /**/ 910, /**/ From 18442cbcc0d335a8ea6947e94eee9a2ab9552690 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 21:22:12 +0100 Subject: [PATCH 40/75] patch 8.1.0912: MS-Windows: warning for signed/unsigned Problem: MS-Windows: warning for signed/unsigned. Solution: Add type cast. (Nobuhiro Takasaki, closes #3945) --- src/terminal.c | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 3be2698586..a823499ed9 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5722,7 +5722,7 @@ conpty_term_and_job_init( job->jv_proc_info = proc_info; job->jv_job_object = jo; job->jv_status = JOB_STARTED; - job->jv_tty_type = vim_strsave("conpty"); + job->jv_tty_type = vim_strsave((char_u *)"conpty"); ++job->jv_refcount; term->tl_job = job; @@ -6056,7 +6056,7 @@ winpty_term_and_job_init( (short_u *)winpty_conin_name(term->tl_winpty), NULL); job->jv_tty_out = utf16_to_enc( (short_u *)winpty_conout_name(term->tl_winpty), NULL); - job->jv_tty_type = vim_strsave("winpty"); + job->jv_tty_type = vim_strsave((char_u *)"winpty"); ++job->jv_refcount; term->tl_job = job; diff --git a/src/version.c b/src/version.c index 88960bafd2..343270cc04 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 912, /**/ 911, /**/ From 688b3983d8b321e0d32dd51914fa474a0988daf6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 21:47:36 +0100 Subject: [PATCH 41/75] patch 8.1.0913: CI crashes when running out of memory Problem: CI crashes when running out of memory. Solution: Apply 'maxmempattern' also to new regexp engine. --- src/regexp_nfa.c | 21 +++++++++++++++++---- src/version.c | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 2a16fff94a..dadb9d067f 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4445,13 +4445,20 @@ skip_add: goto skip_add; } - /* When there are backreferences or PIMs the number of states may - * be (a lot) bigger than anticipated. */ + // When there are backreferences or PIMs the number of states may + // be (a lot) bigger than anticipated. if (l->n == l->len) { int newlen = l->len * 3 / 2 + 50; + size_t newsize = newlen * sizeof(nfa_thread_T); nfa_thread_T *newt; + if ((long)(newsize >> 10) >= p_mmp) + { + emsg(_(e_maxmempat)); + --depth; + return NULL; + } if (subs != &temp_subs) { /* "subs" may point into the current array, need to make a @@ -4464,7 +4471,7 @@ skip_add: subs = &temp_subs; } - newt = vim_realloc(l->t, newlen * sizeof(nfa_thread_T)); + newt = vim_realloc(l->t, newsize); if (newt == NULL) { // out of memory @@ -4785,9 +4792,15 @@ addstate_here( /* not enough space to move the new states, reallocate the list * and move the states to the right position */ int newlen = l->len * 3 / 2 + 50; + size_t newsize = newlen * sizeof(nfa_thread_T); nfa_thread_T *newl; - newl = (nfa_thread_T *)alloc(newlen * sizeof(nfa_thread_T)); + if ((long)(newsize >> 10) >= p_mmp) + { + emsg(_(e_maxmempat)); + return NULL; + } + newl = (nfa_thread_T *)alloc(newsize); if (newl == NULL) return NULL; l->len = newlen; diff --git a/src/version.c b/src/version.c index 343270cc04..f60b9d62be 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 913, /**/ 912, /**/ From 5fd0f5052f9a312bb4cfe7b4176b1211d45127ee Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Feb 2019 23:13:28 +0100 Subject: [PATCH 42/75] patch 8.1.0914: code related to findfile() is spread out Problem: Code related to findfile() is spread out. Solution: Put findfile() related code into a new source file. (Yegappan Lakshmanan, closes #3934) --- Filelist | 2 + src/Make_bc5.mak | 1 + src/Make_cyg_ming.mak | 1 + src/Make_dice.mak | 4 + src/Make_ivc.mak | 5 + src/Make_manx.mak | 6 + src/Make_morph.mak | 1 + src/Make_mvc.mak | 4 + src/Make_sas.mak | 5 + src/Make_vms.mms | 40 +- src/Makefile | 11 + src/README.txt | 2 + src/findfile.c | 2607 ++++++++++++++++++++++++++++++++++++++++ src/misc1.c | 528 ++------ src/misc2.c | 1926 ----------------------------- src/proto.h | 1 + src/proto/findfile.pro | 18 + src/proto/misc1.pro | 5 +- src/proto/misc2.pro | 8 - src/proto/window.pro | 7 - src/version.c | 2 + src/window.c | 315 ----- 22 files changed, 2775 insertions(+), 2724 deletions(-) create mode 100644 src/findfile.c create mode 100644 src/proto/findfile.pro diff --git a/Filelist b/Filelist index cd9cbf311a..211b487673 100644 --- a/Filelist +++ b/Filelist @@ -41,6 +41,7 @@ SRC_ALL = \ src/farsi.h \ src/feature.h \ src/fileio.c \ + src/findfile.c \ src/fold.c \ src/getchar.c \ src/globals.h \ @@ -170,6 +171,7 @@ SRC_ALL = \ src/proto/ex_getln.pro \ src/proto/farsi.pro \ src/proto/fileio.pro \ + src/proto/findfile.pro \ src/proto/fold.pro \ src/proto/getchar.pro \ src/proto/gui.pro \ diff --git a/src/Make_bc5.mak b/src/Make_bc5.mak index b2977e7007..eb38dd7ccd 100644 --- a/src/Make_bc5.mak +++ b/src/Make_bc5.mak @@ -544,6 +544,7 @@ vimobj = \ $(OBJDIR)\ex_getln.obj \ $(OBJDIR)\farsi.obj \ $(OBJDIR)\fileio.obj \ + $(OBJDIR)\findfile.obj \ $(OBJDIR)\fold.obj \ $(OBJDIR)\getchar.obj \ $(OBJDIR)\hardcopy.obj \ diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak index 1e26adda5d..48ce3974d6 100644 --- a/src/Make_cyg_ming.mak +++ b/src/Make_cyg_ming.mak @@ -716,6 +716,7 @@ OBJ = \ $(OUTDIR)/ex_getln.o \ $(OUTDIR)/farsi.o \ $(OUTDIR)/fileio.o \ + $(OUTDIR)/findfile.o \ $(OUTDIR)/fold.o \ $(OUTDIR)/getchar.o \ $(OUTDIR)/hardcopy.o \ diff --git a/src/Make_dice.mak b/src/Make_dice.mak index 57aed477b9..ffce805d3c 100644 --- a/src/Make_dice.mak +++ b/src/Make_dice.mak @@ -46,6 +46,7 @@ SRC = \ ex_getln.c \ farsi.c \ fileio.c \ + findfile.c \ fold.c \ getchar.c \ hardcopy.c \ @@ -105,6 +106,7 @@ OBJ = o/arabic.o \ o/ex_getln.o \ o/farsi.o \ o/fileio.o \ + o/findfile.o \ o/fold.o \ o/getchar.o \ o/hardcopy.o \ @@ -203,6 +205,8 @@ o/farsi.o: farsi.c $(SYMS) o/fileio.o: fileio.c $(SYMS) +o/findfile.o: findfile.c $(SYMS) + o/fold.o: fold.c $(SYMS) o/getchar.o: getchar.c $(SYMS) diff --git a/src/Make_ivc.mak b/src/Make_ivc.mak index 96d6a47b54..a02ba960f1 100644 --- a/src/Make_ivc.mak +++ b/src/Make_ivc.mak @@ -230,6 +230,7 @@ LINK32_OBJS= \ "$(INTDIR)/ex_getln.obj" \ "$(INTDIR)/farsi.obj" \ "$(INTDIR)/fileio.obj" \ + "$(INTDIR)/findfile.obj" \ "$(INTDIR)/fold.obj" \ "$(INTDIR)/getchar.obj" \ "$(INTDIR)/hardcopy.obj" \ @@ -419,6 +420,10 @@ SOURCE=.\farsi.c SOURCE=.\fileio.c # End Source File # Begin Source File +# +SOURCE=.\findfile.c +# End Source File +# Begin Source File SOURCE=.\fold.c # End Source File diff --git a/src/Make_manx.mak b/src/Make_manx.mak index a44ad6558c..5314a86a13 100644 --- a/src/Make_manx.mak +++ b/src/Make_manx.mak @@ -56,6 +56,7 @@ SRC = arabic.c \ ex_getln.c \ farsi.c \ fileio.c \ + findfile.c \ fold.c \ getchar.c \ hardcopy.c \ @@ -117,6 +118,7 @@ OBJ = obj/arabic.o \ obj/ex_getln.o \ obj/farsi.o \ obj/fileio.o \ + obj/findfile.o \ obj/fold.o \ obj/getchar.o \ obj/hardcopy.o \ @@ -176,6 +178,7 @@ PRO = proto/arabic.pro \ proto/ex_getln.pro \ proto/farsi.pro \ proto/fileio.pro \ + proto/findfile.pro \ proto/fold.pro \ proto/getchar.pro \ proto/hardcopy.pro \ @@ -320,6 +323,9 @@ obj/farsi.o: farsi.c obj/fileio.o: fileio.c $(CCSYM) $@ fileio.c +obj/findfile.o: findfile.c + $(CCSYM) $@ findfile.c + obj/fold.o: fold.c $(CCSYM) $@ fold.c diff --git a/src/Make_morph.mak b/src/Make_morph.mak index 6bcae1a0b1..a6e0dae178 100644 --- a/src/Make_morph.mak +++ b/src/Make_morph.mak @@ -44,6 +44,7 @@ SRC = arabic.c \ ex_getln.c \ farsi.c \ fileio.c \ + findfile.c \ fold.c \ getchar.c \ hardcopy.c \ diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index 52deb549c3..c948f37719 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -721,6 +721,7 @@ OBJ = \ $(OUTDIR)\ex_getln.obj \ $(OUTDIR)\farsi.obj \ $(OUTDIR)\fileio.obj \ + $(OUTDIR)\findfile.obj \ $(OUTDIR)\fold.obj \ $(OUTDIR)\getchar.obj \ $(OUTDIR)\hardcopy.obj \ @@ -1407,6 +1408,8 @@ $(OUTDIR)/farsi.obj: $(OUTDIR) farsi.c $(INCL) $(OUTDIR)/fileio.obj: $(OUTDIR) fileio.c $(INCL) +$(OUTDIR)/findfile.obj: $(OUTDIR) findfile.c $(INCL) + $(OUTDIR)/fold.obj: $(OUTDIR) fold.c $(INCL) $(OUTDIR)/getchar.obj: $(OUTDIR) getchar.c $(INCL) @@ -1645,6 +1648,7 @@ proto.h: \ proto/ex_getln.pro \ proto/farsi.pro \ proto/fileio.pro \ + proto/findfile.pro \ proto/getchar.pro \ proto/hardcopy.pro \ proto/hashtab.pro \ diff --git a/src/Make_sas.mak b/src/Make_sas.mak index e7faf56771..deaa5eb5d6 100644 --- a/src/Make_sas.mak +++ b/src/Make_sas.mak @@ -109,6 +109,7 @@ SRC = \ ex_getln.c \ farsi.c \ fileio.c \ + findfile.c \ fold.c \ getchar.c \ hardcopy.c \ @@ -169,6 +170,7 @@ OBJ = \ ex_getln.o \ farsi.o \ fileio.o \ + findfile.o \ fold.o \ getchar.o \ hardcopy.o \ @@ -229,6 +231,7 @@ PRO = \ proto/ex_getln.pro \ proto/farsi.pro \ proto/fileio.pro \ + proto/findfile.pro \ proto/fold.pro \ proto/getchar.pro \ proto/hardcopy.pro \ @@ -363,6 +366,8 @@ farsi.o: farsi.c proto/farsi.pro: farsi.c fileio.o: fileio.c proto/fileio.pro: fileio.c +findfile.o: findfile.c +proto/findfile.pro: findfile.c fold.o: fold.c proto/fold.pro: fold.c getchar.o: getchar.c diff --git a/src/Make_vms.mms b/src/Make_vms.mms index 1a21d15fb9..92f5ab12ef 100644 --- a/src/Make_vms.mms +++ b/src/Make_vms.mms @@ -312,23 +312,31 @@ ALL_CFLAGS_VER = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF) - ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \ $(PERL_LIB) $(PYTHON_LIB) $(TCL_LIB) $(RUBY_LIB) -SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c charset.c crypt.c crypt_zip.c dict.c diff.c digraph.c edit.c eval.c \ - evalfunc.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c if_cscope.c if_xcmdsrv.c farsi.c fileio.c fold.c \ - getchar.c hardcopy.c hashtab.c indent.c json.c list.c main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \ - misc2.c move.c normal.c ops.c option.c popupmnu.c quickfix.c regexp.c search.c sha256.c sign.c \ - spell.c spellfile.c syntax.c tag.c term.c termlib.c textprop.c ui.c undo.c userfunc.c version.c screen.c \ - window.c os_unix.c os_vms.c pathdef.c \ +SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c charset.c \ + crypt.c crypt_zip.c dict.c diff.c digraph.c edit.c eval.c evalfunc.c \ + ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c if_cscope.c \ + if_xcmdsrv.c farsi.c fileio.c findfile.c fold.c getchar.c hardcopy.c \ + hashtab.c indent.c json.c list.c main.c mark.c menu.c mbyte.c \ + memfile.c memline.c message.c misc1.c misc2.c move.c normal.c ops.c \ + option.c popupmnu.c quickfix.c regexp.c search.c sha256.c sign.c \ + spell.c spellfile.c syntax.c tag.c term.c termlib.c textprop.c ui.c \ + undo.c userfunc.c version.c screen.c window.c os_unix.c os_vms.c \ + pathdef.c $(GUI_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) \ $(RUBY_SRC) $(HANGULIN_SRC) $(MZSCH_SRC) $(XDIFF_SRC) -OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj charset.obj crypt.obj crypt_zip.obj dict.obj diff.obj digraph.obj \ - edit.obj eval.obj evalfunc.obj ex_cmds.obj ex_cmds2.obj ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj \ - if_xcmdsrv.obj farsi.obj fileio.obj fold.obj getchar.obj hardcopy.obj hashtab.obj indent.obj json.obj list.obj main.obj mark.obj \ - menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \ - move.obj mbyte.obj normal.obj ops.obj option.obj popupmnu.obj quickfix.obj \ - regexp.obj search.obj sha256.obj sign.obj spell.obj spellfile.obj syntax.obj tag.obj term.obj termlib.obj textprop.obj \ - ui.obj undo.obj userfunc.obj screen.obj version.obj window.obj os_unix.obj \ - os_vms.obj pathdef.obj if_mzsch.obj\ +OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj \ + charset.obj crypt.obj crypt_zip.obj dict.obj diff.obj digraph.obj \ + edit.obj eval.obj evalfunc.obj ex_cmds.obj ex_cmds2.obj ex_docmd.obj \ + ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj farsi.obj \ + fileio.obj findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \ + indent.obj json.obj list.obj main.obj mark.obj menu.obj memfile.obj \ + memline.obj message.obj misc1.obj misc2.obj move.obj mbyte.obj \ + normal.obj ops.obj option.obj popupmnu.obj quickfix.obj regexp.obj \ + search.obj sha256.obj sign.obj spell.obj spellfile.obj syntax.obj \ + tag.obj term.obj termlib.obj textprop.obj ui.obj undo.obj \ + userfunc.obj screen.obj version.obj window.obj os_unix.obj os_vms.obj \ + pathdef.obj if_mzsch.obj \ $(GUI_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(TCL_OBJ) \ $(RUBY_OBJ) $(HANGULIN_OBJ) $(MZSCH_OBJ) $(XDIFF_OBJ) @@ -568,6 +576,10 @@ fileio.obj : fileio.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ globals.h farsi.h arabic.h +findfile.obj : findfile.c vim.h [.auto]config.h feature.h os_unix.h \ + ascii.h keymap.h term.h macros.h structs.h regexp.h \ + gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ + globals.h farsi.h arabic.h fold.obj : fold.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ diff --git a/src/Makefile b/src/Makefile index 8b83e9540a..60828ad16b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1592,6 +1592,7 @@ BASIC_SRC = \ ex_getln.c \ farsi.c \ fileio.c \ + findfile.c \ fold.c \ getchar.c \ hardcopy.c \ @@ -1705,6 +1706,7 @@ OBJ_COMMON = \ objects/ex_getln.o \ objects/farsi.o \ objects/fileio.o \ + objects/findfile.o \ objects/fold.o \ objects/getchar.o \ objects/hardcopy.o \ @@ -1831,6 +1833,7 @@ PRO_AUTO = \ ex_getln.pro \ farsi.pro \ fileio.pro \ + findfile.pro \ fold.pro \ getchar.pro \ hardcopy.pro \ @@ -2999,6 +3002,9 @@ objects/farsi.o: farsi.c objects/fileio.o: fileio.c $(CCC) -o $@ fileio.c +objects/findfile.o: findfile.c + $(CCC) -o $@ findfile.c + objects/fold.o: fold.c $(CCC) -o $@ fold.c @@ -3471,6 +3477,11 @@ objects/fileio.o: fileio.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto.h globals.h farsi.h arabic.h +objects/findfile.o: findfile.c vim.h protodef.h auto/config.h feature.h \ + os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ + proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ + proto.h globals.h farsi.h arabic.h libvterm/include/vterm.h \ + libvterm/include/vterm_keycodes.h objects/fold.o: fold.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ diff --git a/src/README.txt b/src/README.txt index e1dc36f69c..52edeb73e6 100644 --- a/src/README.txt +++ b/src/README.txt @@ -22,8 +22,10 @@ Most code can be found in a file with an obvious name (incomplete list): diff.c diff mode (vimdiff) eval.c expression evaluation fileio.c reading and writing files + findfile.c search for files in 'path' fold.c folding getchar.c getting characters and key mapping + indent.c C and Lisp indentation mark.c marks mbyte.c multi-byte character handling memfile.c storing lines for buffers in a swapfile diff --git a/src/findfile.c b/src/findfile.c new file mode 100644 index 0000000000..9730b35a46 --- /dev/null +++ b/src/findfile.c @@ -0,0 +1,2607 @@ +/* vi:set ts=8 sts=4 sw=4 noet: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + +/* + * findfile.c: Search for files in directories listed in 'path' + */ + +#include "vim.h" + +/* + * File searching functions for 'path', 'tags' and 'cdpath' options. + * External visible functions: + * vim_findfile_init() creates/initialises the search context + * vim_findfile_free_visited() free list of visited files/dirs of search + * context + * vim_findfile() find a file in the search context + * vim_findfile_cleanup() cleanup/free search context created by + * vim_findfile_init() + * + * All static functions and variables start with 'ff_' + * + * In general it works like this: + * First you create yourself a search context by calling vim_findfile_init(). + * It is possible to give a search context from a previous call to + * vim_findfile_init(), so it can be reused. After this you call vim_findfile() + * until you are satisfied with the result or it returns NULL. On every call it + * returns the next file which matches the conditions given to + * vim_findfile_init(). If it doesn't find a next file it returns NULL. + * + * It is possible to call vim_findfile_init() again to reinitialise your search + * with some new parameters. Don't forget to pass your old search context to + * it, so it can reuse it and especially reuse the list of already visited + * directories. If you want to delete the list of already visited directories + * simply call vim_findfile_free_visited(). + * + * When you are done call vim_findfile_cleanup() to free the search context. + * + * The function vim_findfile_init() has a long comment, which describes the + * needed parameters. + * + * + * + * ATTENTION: + * ========== + * Also we use an allocated search context here, this functions are NOT + * thread-safe!!!!! + * + * To minimize parameter passing (or because I'm to lazy), only the + * external visible functions get a search context as a parameter. This is + * then assigned to a static global, which is used throughout the local + * functions. + */ + +/* + * type for the directory search stack + */ +typedef struct ff_stack +{ + struct ff_stack *ffs_prev; + + // the fix part (no wildcards) and the part containing the wildcards + // of the search path + char_u *ffs_fix_path; +#ifdef FEAT_PATH_EXTRA + char_u *ffs_wc_path; +#endif + + // files/dirs found in the above directory, matched by the first wildcard + // of wc_part + char_u **ffs_filearray; + int ffs_filearray_size; + char_u ffs_filearray_cur; // needed for partly handled dirs + + // to store status of partly handled directories + // 0: we work on this directory for the first time + // 1: this directory was partly searched in an earlier step + int ffs_stage; + + // How deep are we in the directory tree? + // Counts backward from value of level parameter to vim_findfile_init + int ffs_level; + + // Did we already expand '**' to an empty string? + int ffs_star_star_empty; +} ff_stack_T; + +/* + * type for already visited directories or files. + */ +typedef struct ff_visited +{ + struct ff_visited *ffv_next; + +#ifdef FEAT_PATH_EXTRA + // Visited directories are different if the wildcard string are + // different. So we have to save it. + char_u *ffv_wc_path; +#endif + // for unix use inode etc for comparison (needed because of links), else + // use filename. +#ifdef UNIX + int ffv_dev_valid; // ffv_dev and ffv_ino were set + dev_t ffv_dev; // device number + ino_t ffv_ino; // inode number +#endif + // The memory for this struct is allocated according to the length of + // ffv_fname. + char_u ffv_fname[1]; // actually longer +} ff_visited_T; + +/* + * We might have to manage several visited lists during a search. + * This is especially needed for the tags option. If tags is set to: + * "./++/tags,./++/TAGS,++/tags" (replace + with *) + * So we have to do 3 searches: + * 1) search from the current files directory downward for the file "tags" + * 2) search from the current files directory downward for the file "TAGS" + * 3) search from Vims current directory downwards for the file "tags" + * As you can see, the first and the third search are for the same file, so for + * the third search we can use the visited list of the first search. For the + * second search we must start from a empty visited list. + * The struct ff_visited_list_hdr is used to manage a linked list of already + * visited lists. + */ +typedef struct ff_visited_list_hdr +{ + struct ff_visited_list_hdr *ffvl_next; + + // the filename the attached visited list is for + char_u *ffvl_filename; + + ff_visited_T *ffvl_visited_list; + +} ff_visited_list_hdr_T; + + +/* + * '**' can be expanded to several directory levels. + * Set the default maximum depth. + */ +#define FF_MAX_STAR_STAR_EXPAND ((char_u)30) + +/* + * The search context: + * ffsc_stack_ptr: the stack for the dirs to search + * ffsc_visited_list: the currently active visited list + * ffsc_dir_visited_list: the currently active visited list for search dirs + * ffsc_visited_lists_list: the list of all visited lists + * ffsc_dir_visited_lists_list: the list of all visited lists for search dirs + * ffsc_file_to_search: the file to search for + * ffsc_start_dir: the starting directory, if search path was relative + * ffsc_fix_path: the fix part of the given path (without wildcards) + * Needed for upward search. + * ffsc_wc_path: the part of the given path containing wildcards + * ffsc_level: how many levels of dirs to search downwards + * ffsc_stopdirs_v: array of stop directories for upward search + * ffsc_find_what: FINDFILE_BOTH, FINDFILE_DIR or FINDFILE_FILE + * ffsc_tagfile: searching for tags file, don't use 'suffixesadd' + */ +typedef struct ff_search_ctx_T +{ + ff_stack_T *ffsc_stack_ptr; + ff_visited_list_hdr_T *ffsc_visited_list; + ff_visited_list_hdr_T *ffsc_dir_visited_list; + ff_visited_list_hdr_T *ffsc_visited_lists_list; + ff_visited_list_hdr_T *ffsc_dir_visited_lists_list; + char_u *ffsc_file_to_search; + char_u *ffsc_start_dir; + char_u *ffsc_fix_path; +#ifdef FEAT_PATH_EXTRA + char_u *ffsc_wc_path; + int ffsc_level; + char_u **ffsc_stopdirs_v; +#endif + int ffsc_find_what; + int ffsc_tagfile; +} ff_search_ctx_T; + +// locally needed functions +#ifdef FEAT_PATH_EXTRA +static int ff_check_visited(ff_visited_T **, char_u *, char_u *); +#else +static int ff_check_visited(ff_visited_T **, char_u *); +#endif +static void vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp); +static void ff_free_visited_list(ff_visited_T *vl); +static ff_visited_list_hdr_T* ff_get_visited_list(char_u *, ff_visited_list_hdr_T **list_headp); + +static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr); +static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx); +static void ff_clear(ff_search_ctx_T *search_ctx); +static void ff_free_stack_element(ff_stack_T *stack_ptr); +#ifdef FEAT_PATH_EXTRA +static ff_stack_T *ff_create_stack_element(char_u *, char_u *, int, int); +#else +static ff_stack_T *ff_create_stack_element(char_u *, int, int); +#endif +#ifdef FEAT_PATH_EXTRA +static int ff_path_in_stoplist(char_u *, int, char_u **); +#endif + +static char_u e_pathtoolong[] = N_("E854: path too long for completion"); + +static char_u *ff_expand_buffer = NULL; // used for expanding filenames + +#if 0 +/* + * if someone likes findfirst/findnext, here are the functions + * NOT TESTED!! + */ + +static void *ff_fn_search_context = NULL; + + char_u * +vim_findfirst(char_u *path, char_u *filename, int level) +{ + ff_fn_search_context = + vim_findfile_init(path, filename, NULL, level, TRUE, FALSE, + ff_fn_search_context, rel_fname); + if (NULL == ff_fn_search_context) + return NULL; + else + return vim_findnext() +} + + char_u * +vim_findnext(void) +{ + char_u *ret = vim_findfile(ff_fn_search_context); + + if (NULL == ret) + { + vim_findfile_cleanup(ff_fn_search_context); + ff_fn_search_context = NULL; + } + return ret; +} +#endif + +/* + * Initialization routine for vim_findfile(). + * + * Returns the newly allocated search context or NULL if an error occurred. + * + * Don't forget to clean up by calling vim_findfile_cleanup() if you are done + * with the search context. + * + * Find the file 'filename' in the directory 'path'. + * The parameter 'path' may contain wildcards. If so only search 'level' + * directories deep. The parameter 'level' is the absolute maximum and is + * not related to restricts given to the '**' wildcard. If 'level' is 100 + * and you use '**200' vim_findfile() will stop after 100 levels. + * + * 'filename' cannot contain wildcards! It is used as-is, no backslashes to + * escape special characters. + * + * If 'stopdirs' is not NULL and nothing is found downward, the search is + * restarted on the next higher directory level. This is repeated until the + * start-directory of a search is contained in 'stopdirs'. 'stopdirs' has the + * format ";**\(;\)*;\=$". + * + * If the 'path' is relative, the starting dir for the search is either VIM's + * current dir or if the path starts with "./" the current files dir. + * If the 'path' is absolute, the starting dir is that part of the path before + * the first wildcard. + * + * Upward search is only done on the starting dir. + * + * If 'free_visited' is TRUE the list of already visited files/directories is + * cleared. Set this to FALSE if you just want to search from another + * directory, but want to be sure that no directory from a previous search is + * searched again. This is useful if you search for a file at different places. + * The list of visited files/dirs can also be cleared with the function + * vim_findfile_free_visited(). + * + * Set the parameter 'find_what' to FINDFILE_DIR if you want to search for + * directories only, FINDFILE_FILE for files only, FINDFILE_BOTH for both. + * + * A search context returned by a previous call to vim_findfile_init() can be + * passed in the parameter "search_ctx_arg". This context is reused and + * reinitialized with the new parameters. The list of already visited + * directories from this context is only deleted if the parameter + * "free_visited" is true. Be aware that the passed "search_ctx_arg" is freed + * if the reinitialization fails. + * + * If you don't have a search context from a previous call "search_ctx_arg" + * must be NULL. + * + * This function silently ignores a few errors, vim_findfile() will have + * limited functionality then. + */ + void * +vim_findfile_init( + char_u *path, + char_u *filename, + char_u *stopdirs UNUSED, + int level, + int free_visited, + int find_what, + void *search_ctx_arg, + int tagfile, // expanding names of tags files + char_u *rel_fname) // file name to use for "." +{ +#ifdef FEAT_PATH_EXTRA + char_u *wc_part; +#endif + ff_stack_T *sptr; + ff_search_ctx_T *search_ctx; + + // If a search context is given by the caller, reuse it, else allocate a + // new one. + if (search_ctx_arg != NULL) + search_ctx = search_ctx_arg; + else + { + search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T)); + if (search_ctx == NULL) + goto error_return; + vim_memset(search_ctx, 0, sizeof(ff_search_ctx_T)); + } + search_ctx->ffsc_find_what = find_what; + search_ctx->ffsc_tagfile = tagfile; + + // clear the search context, but NOT the visited lists + ff_clear(search_ctx); + + // clear visited list if wanted + if (free_visited == TRUE) + vim_findfile_free_visited(search_ctx); + else + { + // Reuse old visited lists. Get the visited list for the given + // filename. If no list for the current filename exists, creates a new + // one. + search_ctx->ffsc_visited_list = ff_get_visited_list(filename, + &search_ctx->ffsc_visited_lists_list); + if (search_ctx->ffsc_visited_list == NULL) + goto error_return; + search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename, + &search_ctx->ffsc_dir_visited_lists_list); + if (search_ctx->ffsc_dir_visited_list == NULL) + goto error_return; + } + + if (ff_expand_buffer == NULL) + { + ff_expand_buffer = (char_u*)alloc(MAXPATHL); + if (ff_expand_buffer == NULL) + goto error_return; + } + + // Store information on starting dir now if path is relative. + // If path is absolute, we do that later. + if (path[0] == '.' + && (vim_ispathsep(path[1]) || path[1] == NUL) + && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) + && rel_fname != NULL) + { + int len = (int)(gettail(rel_fname) - rel_fname); + + if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) + { + // Make the start dir an absolute path name. + vim_strncpy(ff_expand_buffer, rel_fname, len); + search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE); + } + else + search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len); + if (search_ctx->ffsc_start_dir == NULL) + goto error_return; + if (*++path != NUL) + ++path; + } + else if (*path == NUL || !vim_isAbsName(path)) + { +#ifdef BACKSLASH_IN_FILENAME + // "c:dir" needs "c:" to be expanded, otherwise use current dir + if (*path != NUL && path[1] == ':') + { + char_u drive[3]; + + drive[0] = path[0]; + drive[1] = ':'; + drive[2] = NUL; + if (vim_FullName(drive, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) + goto error_return; + path += 2; + } + else +#endif + if (mch_dirname(ff_expand_buffer, MAXPATHL) == FAIL) + goto error_return; + + search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer); + if (search_ctx->ffsc_start_dir == NULL) + goto error_return; + +#ifdef BACKSLASH_IN_FILENAME + // A path that starts with "/dir" is relative to the drive, not to the + // directory (but not for "//machine/dir"). Only use the drive name. + if ((*path == '/' || *path == '\\') + && path[1] != path[0] + && search_ctx->ffsc_start_dir[1] == ':') + search_ctx->ffsc_start_dir[2] = NUL; +#endif + } + +#ifdef FEAT_PATH_EXTRA + /* + * If stopdirs are given, split them into an array of pointers. + * If this fails (mem allocation), there is no upward search at all or a + * stop directory is not recognized -> continue silently. + * If stopdirs just contains a ";" or is empty, + * search_ctx->ffsc_stopdirs_v will only contain a NULL pointer. This + * is handled as unlimited upward search. See function + * ff_path_in_stoplist() for details. + */ + if (stopdirs != NULL) + { + char_u *walker = stopdirs; + int dircount; + + while (*walker == ';') + walker++; + + dircount = 1; + search_ctx->ffsc_stopdirs_v = + (char_u **)alloc((unsigned)sizeof(char_u *)); + + if (search_ctx->ffsc_stopdirs_v != NULL) + { + do + { + char_u *helper; + void *ptr; + + helper = walker; + ptr = vim_realloc(search_ctx->ffsc_stopdirs_v, + (dircount + 1) * sizeof(char_u *)); + if (ptr) + search_ctx->ffsc_stopdirs_v = ptr; + else + // ignore, keep what we have and continue + break; + walker = vim_strchr(walker, ';'); + if (walker) + { + search_ctx->ffsc_stopdirs_v[dircount-1] = + vim_strnsave(helper, (int)(walker - helper)); + walker++; + } + else + // this might be "", which means ascent till top + // of directory tree. + search_ctx->ffsc_stopdirs_v[dircount-1] = + vim_strsave(helper); + + dircount++; + + } while (walker != NULL); + search_ctx->ffsc_stopdirs_v[dircount-1] = NULL; + } + } +#endif + +#ifdef FEAT_PATH_EXTRA + search_ctx->ffsc_level = level; + + /* + * split into: + * -fix path + * -wildcard_stuff (might be NULL) + */ + wc_part = vim_strchr(path, '*'); + if (wc_part != NULL) + { + int llevel; + int len; + char *errpt; + + // save the fix part of the path + search_ctx->ffsc_fix_path = vim_strnsave(path, (int)(wc_part - path)); + + /* + * copy wc_path and add restricts to the '**' wildcard. + * The octet after a '**' is used as a (binary) counter. + * So '**3' is transposed to '**^C' ('^C' is ASCII value 3) + * or '**76' is transposed to '**N'( 'N' is ASCII value 76). + * For EBCDIC you get different character values. + * If no restrict is given after '**' the default is used. + * Due to this technique the path looks awful if you print it as a + * string. + */ + len = 0; + while (*wc_part != NUL) + { + if (len + 5 >= MAXPATHL) + { + emsg(_(e_pathtoolong)); + break; + } + if (STRNCMP(wc_part, "**", 2) == 0) + { + ff_expand_buffer[len++] = *wc_part++; + ff_expand_buffer[len++] = *wc_part++; + + llevel = strtol((char *)wc_part, &errpt, 10); + if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) + ff_expand_buffer[len++] = llevel; + else if ((char_u *)errpt != wc_part && llevel == 0) + // restrict is 0 -> remove already added '**' + len -= 2; + else + ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND; + wc_part = (char_u *)errpt; + if (*wc_part != NUL && !vim_ispathsep(*wc_part)) + { + semsg(_("E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."), PATHSEPSTR); + goto error_return; + } + } + else + ff_expand_buffer[len++] = *wc_part++; + } + ff_expand_buffer[len] = NUL; + search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer); + + if (search_ctx->ffsc_wc_path == NULL) + goto error_return; + } + else +#endif + search_ctx->ffsc_fix_path = vim_strsave(path); + + if (search_ctx->ffsc_start_dir == NULL) + { + // store the fix part as startdir. + // This is needed if the parameter path is fully qualified. + search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path); + if (search_ctx->ffsc_start_dir == NULL) + goto error_return; + search_ctx->ffsc_fix_path[0] = NUL; + } + + // create an absolute path + if (STRLEN(search_ctx->ffsc_start_dir) + + STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) + { + emsg(_(e_pathtoolong)); + goto error_return; + } + STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir); + add_pathsep(ff_expand_buffer); + { + int eb_len = (int)STRLEN(ff_expand_buffer); + char_u *buf = alloc(eb_len + + (int)STRLEN(search_ctx->ffsc_fix_path) + 1); + + STRCPY(buf, ff_expand_buffer); + STRCPY(buf + eb_len, search_ctx->ffsc_fix_path); + if (mch_isdir(buf)) + { + STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); + add_pathsep(ff_expand_buffer); + } +#ifdef FEAT_PATH_EXTRA + else + { + char_u *p = gettail(search_ctx->ffsc_fix_path); + char_u *wc_path = NULL; + char_u *temp = NULL; + int len = 0; + + if (p > search_ctx->ffsc_fix_path) + { + len = (int)(p - search_ctx->ffsc_fix_path) - 1; + STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len); + add_pathsep(ff_expand_buffer); + } + else + len = (int)STRLEN(search_ctx->ffsc_fix_path); + + if (search_ctx->ffsc_wc_path != NULL) + { + wc_path = vim_strsave(search_ctx->ffsc_wc_path); + temp = alloc((int)(STRLEN(search_ctx->ffsc_wc_path) + + STRLEN(search_ctx->ffsc_fix_path + len) + + 1)); + if (temp == NULL || wc_path == NULL) + { + vim_free(buf); + vim_free(temp); + vim_free(wc_path); + goto error_return; + } + + STRCPY(temp, search_ctx->ffsc_fix_path + len); + STRCAT(temp, search_ctx->ffsc_wc_path); + vim_free(search_ctx->ffsc_wc_path); + vim_free(wc_path); + search_ctx->ffsc_wc_path = temp; + } + } +#endif + vim_free(buf); + } + + sptr = ff_create_stack_element(ff_expand_buffer, +#ifdef FEAT_PATH_EXTRA + search_ctx->ffsc_wc_path, +#endif + level, 0); + + if (sptr == NULL) + goto error_return; + + ff_push(search_ctx, sptr); + + search_ctx->ffsc_file_to_search = vim_strsave(filename); + if (search_ctx->ffsc_file_to_search == NULL) + goto error_return; + + return search_ctx; + +error_return: + /* + * We clear the search context now! + * Even when the caller gave us a (perhaps valid) context we free it here, + * as we might have already destroyed it. + */ + vim_findfile_cleanup(search_ctx); + return NULL; +} + +#if defined(FEAT_PATH_EXTRA) || defined(PROTO) +/* + * Get the stopdir string. Check that ';' is not escaped. + */ + char_u * +vim_findfile_stopdir(char_u *buf) +{ + char_u *r_ptr = buf; + + while (*r_ptr != NUL && *r_ptr != ';') + { + if (r_ptr[0] == '\\' && r_ptr[1] == ';') + { + // Overwrite the escape char, + // use STRLEN(r_ptr) to move the trailing '\0'. + STRMOVE(r_ptr, r_ptr + 1); + r_ptr++; + } + r_ptr++; + } + if (*r_ptr == ';') + { + *r_ptr = 0; + r_ptr++; + } + else if (*r_ptr == NUL) + r_ptr = NULL; + return r_ptr; +} +#endif + +/* + * Clean up the given search context. Can handle a NULL pointer. + */ + void +vim_findfile_cleanup(void *ctx) +{ + if (ctx == NULL) + return; + + vim_findfile_free_visited(ctx); + ff_clear(ctx); + vim_free(ctx); +} + +/* + * Find a file in a search context. + * The search context was created with vim_findfile_init() above. + * Return a pointer to an allocated file name or NULL if nothing found. + * To get all matching files call this function until you get NULL. + * + * If the passed search_context is NULL, NULL is returned. + * + * The search algorithm is depth first. To change this replace the + * stack with a list (don't forget to leave partly searched directories on the + * top of the list). + */ + char_u * +vim_findfile(void *search_ctx_arg) +{ + char_u *file_path; +#ifdef FEAT_PATH_EXTRA + char_u *rest_of_wildcards; + char_u *path_end = NULL; +#endif + ff_stack_T *stackp; +#if defined(FEAT_SEARCHPATH) || defined(FEAT_PATH_EXTRA) + int len; +#endif + int i; + char_u *p; +#ifdef FEAT_SEARCHPATH + char_u *suf; +#endif + ff_search_ctx_T *search_ctx; + + if (search_ctx_arg == NULL) + return NULL; + + search_ctx = (ff_search_ctx_T *)search_ctx_arg; + + /* + * filepath is used as buffer for various actions and as the storage to + * return a found filename. + */ + if ((file_path = alloc((int)MAXPATHL)) == NULL) + return NULL; + +#ifdef FEAT_PATH_EXTRA + // store the end of the start dir -- needed for upward search + if (search_ctx->ffsc_start_dir != NULL) + path_end = &search_ctx->ffsc_start_dir[ + STRLEN(search_ctx->ffsc_start_dir)]; +#endif + +#ifdef FEAT_PATH_EXTRA + // upward search loop + for (;;) + { +#endif + // downward search loop + for (;;) + { + // check if user user wants to stop the search + ui_breakcheck(); + if (got_int) + break; + + // get directory to work on from stack + stackp = ff_pop(search_ctx); + if (stackp == NULL) + break; + + /* + * TODO: decide if we leave this test in + * + * GOOD: don't search a directory(-tree) twice. + * BAD: - check linked list for every new directory entered. + * - check for double files also done below + * + * Here we check if we already searched this directory. + * We already searched a directory if: + * 1) The directory is the same. + * 2) We would use the same wildcard string. + * + * Good if you have links on same directory via several ways + * or you have selfreferences in directories (e.g. SuSE Linux 6.3: + * /etc/rc.d/init.d is linked to /etc/rc.d -> endless loop) + * + * This check is only needed for directories we work on for the + * first time (hence stackp->ff_filearray == NULL) + */ + if (stackp->ffs_filearray == NULL + && ff_check_visited(&search_ctx->ffsc_dir_visited_list + ->ffvl_visited_list, + stackp->ffs_fix_path +#ifdef FEAT_PATH_EXTRA + , stackp->ffs_wc_path +#endif + ) == FAIL) + { +#ifdef FF_VERBOSE + if (p_verbose >= 5) + { + verbose_enter_scroll(); + smsg("Already Searched: %s (%s)", + stackp->ffs_fix_path, stackp->ffs_wc_path); + // don't overwrite this either + msg_puts("\n"); + verbose_leave_scroll(); + } +#endif + ff_free_stack_element(stackp); + continue; + } +#ifdef FF_VERBOSE + else if (p_verbose >= 5) + { + verbose_enter_scroll(); + smsg("Searching: %s (%s)", + stackp->ffs_fix_path, stackp->ffs_wc_path); + // don't overwrite this either + msg_puts("\n"); + verbose_leave_scroll(); + } +#endif + + // check depth + if (stackp->ffs_level <= 0) + { + ff_free_stack_element(stackp); + continue; + } + + file_path[0] = NUL; + + /* + * If no filearray till now expand wildcards + * The function expand_wildcards() can handle an array of paths + * and all possible expands are returned in one array. We use this + * to handle the expansion of '**' into an empty string. + */ + if (stackp->ffs_filearray == NULL) + { + char_u *dirptrs[2]; + + // we use filepath to build the path expand_wildcards() should + // expand. + dirptrs[0] = file_path; + dirptrs[1] = NULL; + + // if we have a start dir copy it in + if (!vim_isAbsName(stackp->ffs_fix_path) + && search_ctx->ffsc_start_dir) + { + if (STRLEN(search_ctx->ffsc_start_dir) + 1 < MAXPATHL) + { + STRCPY(file_path, search_ctx->ffsc_start_dir); + add_pathsep(file_path); + } + else + { + ff_free_stack_element(stackp); + goto fail; + } + } + + // append the fix part of the search path + if (STRLEN(file_path) + STRLEN(stackp->ffs_fix_path) + 1 + < MAXPATHL) + { + STRCAT(file_path, stackp->ffs_fix_path); + add_pathsep(file_path); + } + else + { + ff_free_stack_element(stackp); + goto fail; + } + +#ifdef FEAT_PATH_EXTRA + rest_of_wildcards = stackp->ffs_wc_path; + if (*rest_of_wildcards != NUL) + { + len = (int)STRLEN(file_path); + if (STRNCMP(rest_of_wildcards, "**", 2) == 0) + { + // pointer to the restrict byte + // The restrict byte is not a character! + p = rest_of_wildcards + 2; + + if (*p > 0) + { + (*p)--; + if (len + 1 < MAXPATHL) + file_path[len++] = '*'; + else + { + ff_free_stack_element(stackp); + goto fail; + } + } + + if (*p == 0) + { + // remove '** from wildcards + STRMOVE(rest_of_wildcards, rest_of_wildcards + 3); + } + else + rest_of_wildcards += 3; + + if (stackp->ffs_star_star_empty == 0) + { + // if not done before, expand '**' to empty + stackp->ffs_star_star_empty = 1; + dirptrs[1] = stackp->ffs_fix_path; + } + } + + /* + * Here we copy until the next path separator or the end of + * the path. If we stop at a path separator, there is + * still something else left. This is handled below by + * pushing every directory returned from expand_wildcards() + * on the stack again for further search. + */ + while (*rest_of_wildcards + && !vim_ispathsep(*rest_of_wildcards)) + if (len + 1 < MAXPATHL) + file_path[len++] = *rest_of_wildcards++; + else + { + ff_free_stack_element(stackp); + goto fail; + } + + file_path[len] = NUL; + if (vim_ispathsep(*rest_of_wildcards)) + rest_of_wildcards++; + } +#endif + + /* + * Expand wildcards like "*" and "$VAR". + * If the path is a URL don't try this. + */ + if (path_with_url(dirptrs[0])) + { + stackp->ffs_filearray = (char_u **) + alloc((unsigned)sizeof(char *)); + if (stackp->ffs_filearray != NULL + && (stackp->ffs_filearray[0] + = vim_strsave(dirptrs[0])) != NULL) + stackp->ffs_filearray_size = 1; + else + stackp->ffs_filearray_size = 0; + } + else + // Add EW_NOTWILD because the expanded path may contain + // wildcard characters that are to be taken literally. + // This is a bit of a hack. + expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs, + &stackp->ffs_filearray_size, + &stackp->ffs_filearray, + EW_DIR|EW_ADDSLASH|EW_SILENT|EW_NOTWILD); + + stackp->ffs_filearray_cur = 0; + stackp->ffs_stage = 0; + } +#ifdef FEAT_PATH_EXTRA + else + rest_of_wildcards = &stackp->ffs_wc_path[ + STRLEN(stackp->ffs_wc_path)]; +#endif + + if (stackp->ffs_stage == 0) + { + // this is the first time we work on this directory +#ifdef FEAT_PATH_EXTRA + if (*rest_of_wildcards == NUL) +#endif + { + /* + * We don't have further wildcards to expand, so we have to + * check for the final file now. + */ + for (i = stackp->ffs_filearray_cur; + i < stackp->ffs_filearray_size; ++i) + { + if (!path_with_url(stackp->ffs_filearray[i]) + && !mch_isdir(stackp->ffs_filearray[i])) + continue; /* not a directory */ + + // prepare the filename to be checked for existence + // below + if (STRLEN(stackp->ffs_filearray[i]) + 1 + + STRLEN(search_ctx->ffsc_file_to_search) + < MAXPATHL) + { + STRCPY(file_path, stackp->ffs_filearray[i]); + add_pathsep(file_path); + STRCAT(file_path, search_ctx->ffsc_file_to_search); + } + else + { + ff_free_stack_element(stackp); + goto fail; + } + + /* + * Try without extra suffix and then with suffixes + * from 'suffixesadd'. + */ +#ifdef FEAT_SEARCHPATH + len = (int)STRLEN(file_path); + if (search_ctx->ffsc_tagfile) + suf = (char_u *)""; + else + suf = curbuf->b_p_sua; + for (;;) +#endif + { + // if file exists and we didn't already find it + if ((path_with_url(file_path) + || (mch_getperm(file_path) >= 0 + && (search_ctx->ffsc_find_what + == FINDFILE_BOTH + || ((search_ctx->ffsc_find_what + == FINDFILE_DIR) + == mch_isdir(file_path))))) +#ifndef FF_VERBOSE + && (ff_check_visited( + &search_ctx->ffsc_visited_list->ffvl_visited_list, + file_path +#ifdef FEAT_PATH_EXTRA + , (char_u *)"" +#endif + ) == OK) +#endif + ) + { +#ifdef FF_VERBOSE + if (ff_check_visited( + &search_ctx->ffsc_visited_list->ffvl_visited_list, + file_path +#ifdef FEAT_PATH_EXTRA + , (char_u *)"" +#endif + ) == FAIL) + { + if (p_verbose >= 5) + { + verbose_enter_scroll(); + smsg("Already: %s", + file_path); + // don't overwrite this either + msg_puts("\n"); + verbose_leave_scroll(); + } + continue; + } +#endif + + // push dir to examine rest of subdirs later + stackp->ffs_filearray_cur = i + 1; + ff_push(search_ctx, stackp); + + if (!path_with_url(file_path)) + simplify_filename(file_path); + if (mch_dirname(ff_expand_buffer, MAXPATHL) + == OK) + { + p = shorten_fname(file_path, + ff_expand_buffer); + if (p != NULL) + STRMOVE(file_path, p); + } +#ifdef FF_VERBOSE + if (p_verbose >= 5) + { + verbose_enter_scroll(); + smsg("HIT: %s", file_path); + // don't overwrite this either + msg_puts("\n"); + verbose_leave_scroll(); + } +#endif + return file_path; + } + +#ifdef FEAT_SEARCHPATH + // Not found or found already, try next suffix. + if (*suf == NUL) + break; + copy_option_part(&suf, file_path + len, + MAXPATHL - len, ","); +#endif + } + } + } +#ifdef FEAT_PATH_EXTRA + else + { + /* + * still wildcards left, push the directories for further + * search + */ + for (i = stackp->ffs_filearray_cur; + i < stackp->ffs_filearray_size; ++i) + { + if (!mch_isdir(stackp->ffs_filearray[i])) + continue; // not a directory + + ff_push(search_ctx, + ff_create_stack_element( + stackp->ffs_filearray[i], + rest_of_wildcards, + stackp->ffs_level - 1, 0)); + } + } +#endif + stackp->ffs_filearray_cur = 0; + stackp->ffs_stage = 1; + } + +#ifdef FEAT_PATH_EXTRA + /* + * if wildcards contains '**' we have to descent till we reach the + * leaves of the directory tree. + */ + if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) + { + for (i = stackp->ffs_filearray_cur; + i < stackp->ffs_filearray_size; ++i) + { + if (fnamecmp(stackp->ffs_filearray[i], + stackp->ffs_fix_path) == 0) + continue; // don't repush same directory + if (!mch_isdir(stackp->ffs_filearray[i])) + continue; // not a directory + ff_push(search_ctx, + ff_create_stack_element(stackp->ffs_filearray[i], + stackp->ffs_wc_path, stackp->ffs_level - 1, 1)); + } + } +#endif + + // we are done with the current directory + ff_free_stack_element(stackp); + + } + +#ifdef FEAT_PATH_EXTRA + // If we reached this, we didn't find anything downwards. + // Let's check if we should do an upward search. + if (search_ctx->ffsc_start_dir + && search_ctx->ffsc_stopdirs_v != NULL && !got_int) + { + ff_stack_T *sptr; + + // is the last starting directory in the stop list? + if (ff_path_in_stoplist(search_ctx->ffsc_start_dir, + (int)(path_end - search_ctx->ffsc_start_dir), + search_ctx->ffsc_stopdirs_v) == TRUE) + break; + + // cut of last dir + while (path_end > search_ctx->ffsc_start_dir + && vim_ispathsep(*path_end)) + path_end--; + while (path_end > search_ctx->ffsc_start_dir + && !vim_ispathsep(path_end[-1])) + path_end--; + *path_end = 0; + path_end--; + + if (*search_ctx->ffsc_start_dir == 0) + break; + + if (STRLEN(search_ctx->ffsc_start_dir) + 1 + + STRLEN(search_ctx->ffsc_fix_path) < MAXPATHL) + { + STRCPY(file_path, search_ctx->ffsc_start_dir); + add_pathsep(file_path); + STRCAT(file_path, search_ctx->ffsc_fix_path); + } + else + goto fail; + + // create a new stack entry + sptr = ff_create_stack_element(file_path, + search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0); + if (sptr == NULL) + break; + ff_push(search_ctx, sptr); + } + else + break; + } +#endif + +fail: + vim_free(file_path); + return NULL; +} + +/* + * Free the list of lists of visited files and directories + * Can handle it if the passed search_context is NULL; + */ + void +vim_findfile_free_visited(void *search_ctx_arg) +{ + ff_search_ctx_T *search_ctx; + + if (search_ctx_arg == NULL) + return; + + search_ctx = (ff_search_ctx_T *)search_ctx_arg; + vim_findfile_free_visited_list(&search_ctx->ffsc_visited_lists_list); + vim_findfile_free_visited_list(&search_ctx->ffsc_dir_visited_lists_list); +} + + static void +vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp) +{ + ff_visited_list_hdr_T *vp; + + while (*list_headp != NULL) + { + vp = (*list_headp)->ffvl_next; + ff_free_visited_list((*list_headp)->ffvl_visited_list); + + vim_free((*list_headp)->ffvl_filename); + vim_free(*list_headp); + *list_headp = vp; + } + *list_headp = NULL; +} + + static void +ff_free_visited_list(ff_visited_T *vl) +{ + ff_visited_T *vp; + + while (vl != NULL) + { + vp = vl->ffv_next; +#ifdef FEAT_PATH_EXTRA + vim_free(vl->ffv_wc_path); +#endif + vim_free(vl); + vl = vp; + } + vl = NULL; +} + +/* + * Returns the already visited list for the given filename. If none is found it + * allocates a new one. + */ + static ff_visited_list_hdr_T* +ff_get_visited_list( + char_u *filename, + ff_visited_list_hdr_T **list_headp) +{ + ff_visited_list_hdr_T *retptr = NULL; + + // check if a visited list for the given filename exists + if (*list_headp != NULL) + { + retptr = *list_headp; + while (retptr != NULL) + { + if (fnamecmp(filename, retptr->ffvl_filename) == 0) + { +#ifdef FF_VERBOSE + if (p_verbose >= 5) + { + verbose_enter_scroll(); + smsg("ff_get_visited_list: FOUND list for %s", + filename); + // don't overwrite this either + msg_puts("\n"); + verbose_leave_scroll(); + } +#endif + return retptr; + } + retptr = retptr->ffvl_next; + } + } + +#ifdef FF_VERBOSE + if (p_verbose >= 5) + { + verbose_enter_scroll(); + smsg("ff_get_visited_list: new list for %s", filename); + // don't overwrite this either + msg_puts("\n"); + verbose_leave_scroll(); + } +#endif + + /* + * if we reach this we didn't find a list and we have to allocate new list + */ + retptr = (ff_visited_list_hdr_T*)alloc((unsigned)sizeof(*retptr)); + if (retptr == NULL) + return NULL; + + retptr->ffvl_visited_list = NULL; + retptr->ffvl_filename = vim_strsave(filename); + if (retptr->ffvl_filename == NULL) + { + vim_free(retptr); + return NULL; + } + retptr->ffvl_next = *list_headp; + *list_headp = retptr; + + return retptr; +} + +#ifdef FEAT_PATH_EXTRA +/* + * check if two wildcard paths are equal. Returns TRUE or FALSE. + * They are equal if: + * - both paths are NULL + * - they have the same length + * - char by char comparison is OK + * - the only differences are in the counters behind a '**', so + * '**\20' is equal to '**\24' + */ + static int +ff_wc_equal(char_u *s1, char_u *s2) +{ + int i, j; + int c1 = NUL; + int c2 = NUL; + int prev1 = NUL; + int prev2 = NUL; + + if (s1 == s2) + return TRUE; + + if (s1 == NULL || s2 == NULL) + return FALSE; + + for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) + { + c1 = PTR2CHAR(s1 + i); + c2 = PTR2CHAR(s2 + j); + + if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2) + && (prev1 != '*' || prev2 != '*')) + return FALSE; + prev2 = prev1; + prev1 = c1; + + i += MB_PTR2LEN(s1 + i); + j += MB_PTR2LEN(s2 + j); + } + return s1[i] == s2[j]; +} +#endif + +/* + * maintains the list of already visited files and dirs + * returns FAIL if the given file/dir is already in the list + * returns OK if it is newly added + * + * TODO: What to do on memory allocation problems? + * -> return TRUE - Better the file is found several times instead of + * never. + */ + static int +ff_check_visited( + ff_visited_T **visited_list, + char_u *fname +#ifdef FEAT_PATH_EXTRA + , char_u *wc_path +#endif + ) +{ + ff_visited_T *vp; +#ifdef UNIX + stat_T st; + int url = FALSE; +#endif + + // For an URL we only compare the name, otherwise we compare the + // device/inode (unix) or the full path name (not Unix). + if (path_with_url(fname)) + { + vim_strncpy(ff_expand_buffer, fname, MAXPATHL - 1); +#ifdef UNIX + url = TRUE; +#endif + } + else + { + ff_expand_buffer[0] = NUL; +#ifdef UNIX + if (mch_stat((char *)fname, &st) < 0) +#else + if (vim_FullName(fname, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) +#endif + return FAIL; + } + + // check against list of already visited files + for (vp = *visited_list; vp != NULL; vp = vp->ffv_next) + { + if ( +#ifdef UNIX + !url ? (vp->ffv_dev_valid && vp->ffv_dev == st.st_dev + && vp->ffv_ino == st.st_ino) + : +#endif + fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0 + ) + { +#ifdef FEAT_PATH_EXTRA + // are the wildcard parts equal + if (ff_wc_equal(vp->ffv_wc_path, wc_path) == TRUE) +#endif + // already visited + return FAIL; + } + } + + /* + * New file/dir. Add it to the list of visited files/dirs. + */ + vp = (ff_visited_T *)alloc((unsigned)(sizeof(ff_visited_T) + + STRLEN(ff_expand_buffer))); + + if (vp != NULL) + { +#ifdef UNIX + if (!url) + { + vp->ffv_dev_valid = TRUE; + vp->ffv_ino = st.st_ino; + vp->ffv_dev = st.st_dev; + vp->ffv_fname[0] = NUL; + } + else + { + vp->ffv_dev_valid = FALSE; +#endif + STRCPY(vp->ffv_fname, ff_expand_buffer); +#ifdef UNIX + } +#endif +#ifdef FEAT_PATH_EXTRA + if (wc_path != NULL) + vp->ffv_wc_path = vim_strsave(wc_path); + else + vp->ffv_wc_path = NULL; +#endif + + vp->ffv_next = *visited_list; + *visited_list = vp; + } + + return OK; +} + +/* + * create stack element from given path pieces + */ + static ff_stack_T * +ff_create_stack_element( + char_u *fix_part, +#ifdef FEAT_PATH_EXTRA + char_u *wc_part, +#endif + int level, + int star_star_empty) +{ + ff_stack_T *new; + + new = (ff_stack_T *)alloc((unsigned)sizeof(ff_stack_T)); + if (new == NULL) + return NULL; + + new->ffs_prev = NULL; + new->ffs_filearray = NULL; + new->ffs_filearray_size = 0; + new->ffs_filearray_cur = 0; + new->ffs_stage = 0; + new->ffs_level = level; + new->ffs_star_star_empty = star_star_empty; + + // the following saves NULL pointer checks in vim_findfile + if (fix_part == NULL) + fix_part = (char_u *)""; + new->ffs_fix_path = vim_strsave(fix_part); + +#ifdef FEAT_PATH_EXTRA + if (wc_part == NULL) + wc_part = (char_u *)""; + new->ffs_wc_path = vim_strsave(wc_part); +#endif + + if (new->ffs_fix_path == NULL +#ifdef FEAT_PATH_EXTRA + || new->ffs_wc_path == NULL +#endif + ) + { + ff_free_stack_element(new); + new = NULL; + } + + return new; +} + +/* + * Push a dir on the directory stack. + */ + static void +ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr) +{ + // check for NULL pointer, not to return an error to the user, but + // to prevent a crash + if (stack_ptr != NULL) + { + stack_ptr->ffs_prev = search_ctx->ffsc_stack_ptr; + search_ctx->ffsc_stack_ptr = stack_ptr; + } +} + +/* + * Pop a dir from the directory stack. + * Returns NULL if stack is empty. + */ + static ff_stack_T * +ff_pop(ff_search_ctx_T *search_ctx) +{ + ff_stack_T *sptr; + + sptr = search_ctx->ffsc_stack_ptr; + if (search_ctx->ffsc_stack_ptr != NULL) + search_ctx->ffsc_stack_ptr = search_ctx->ffsc_stack_ptr->ffs_prev; + + return sptr; +} + +/* + * free the given stack element + */ + static void +ff_free_stack_element(ff_stack_T *stack_ptr) +{ + // vim_free handles possible NULL pointers + vim_free(stack_ptr->ffs_fix_path); +#ifdef FEAT_PATH_EXTRA + vim_free(stack_ptr->ffs_wc_path); +#endif + + if (stack_ptr->ffs_filearray != NULL) + FreeWild(stack_ptr->ffs_filearray_size, stack_ptr->ffs_filearray); + + vim_free(stack_ptr); +} + +/* + * Clear the search context, but NOT the visited list. + */ + static void +ff_clear(ff_search_ctx_T *search_ctx) +{ + ff_stack_T *sptr; + + // clear up stack + while ((sptr = ff_pop(search_ctx)) != NULL) + ff_free_stack_element(sptr); + + vim_free(search_ctx->ffsc_file_to_search); + vim_free(search_ctx->ffsc_start_dir); + vim_free(search_ctx->ffsc_fix_path); +#ifdef FEAT_PATH_EXTRA + vim_free(search_ctx->ffsc_wc_path); +#endif + +#ifdef FEAT_PATH_EXTRA + if (search_ctx->ffsc_stopdirs_v != NULL) + { + int i = 0; + + while (search_ctx->ffsc_stopdirs_v[i] != NULL) + { + vim_free(search_ctx->ffsc_stopdirs_v[i]); + i++; + } + vim_free(search_ctx->ffsc_stopdirs_v); + } + search_ctx->ffsc_stopdirs_v = NULL; +#endif + + // reset everything + search_ctx->ffsc_file_to_search = NULL; + search_ctx->ffsc_start_dir = NULL; + search_ctx->ffsc_fix_path = NULL; +#ifdef FEAT_PATH_EXTRA + search_ctx->ffsc_wc_path = NULL; + search_ctx->ffsc_level = 0; +#endif +} + +#ifdef FEAT_PATH_EXTRA +/* + * check if the given path is in the stopdirs + * returns TRUE if yes else FALSE + */ + static int +ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v) +{ + int i = 0; + + // eat up trailing path separators, except the first + while (path_len > 1 && vim_ispathsep(path[path_len - 1])) + path_len--; + + // if no path consider it as match + if (path_len == 0) + return TRUE; + + for (i = 0; stopdirs_v[i] != NULL; i++) + { + if ((int)STRLEN(stopdirs_v[i]) > path_len) + { + // match for parent directory. So '/home' also matches + // '/home/rks'. Check for PATHSEP in stopdirs_v[i], else + // '/home/r' would also match '/home/rks' + if (fnamencmp(stopdirs_v[i], path, path_len) == 0 + && vim_ispathsep(stopdirs_v[i][path_len])) + return TRUE; + } + else + { + if (fnamecmp(stopdirs_v[i], path) == 0) + return TRUE; + } + } + return FALSE; +} +#endif + +#if defined(FEAT_SEARCHPATH) || defined(PROTO) +/* + * Find the file name "ptr[len]" in the path. Also finds directory names. + * + * On the first call set the parameter 'first' to TRUE to initialize + * the search. For repeating calls to FALSE. + * + * Repeating calls will return other files called 'ptr[len]' from the path. + * + * Only on the first call 'ptr' and 'len' are used. For repeating calls they + * don't need valid values. + * + * If nothing found on the first call the option FNAME_MESS will issue the + * message: + * 'Can't find file "" in path' + * On repeating calls: + * 'No more file "" found in path' + * + * options: + * FNAME_MESS give error message when not found + * + * Uses NameBuff[]! + * + * Returns an allocated string for the file name. NULL for error. + * + */ + char_u * +find_file_in_path( + char_u *ptr, // file name + int len, // length of file name + int options, + int first, // use count'th matching file name + char_u *rel_fname) // file name searching relative to +{ + return find_file_in_path_option(ptr, len, options, first, + *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path, + FINDFILE_BOTH, rel_fname, curbuf->b_p_sua); +} + +static char_u *ff_file_to_find = NULL; +static void *fdip_search_ctx = NULL; + +# if defined(EXITFREE) || defined(PROTO) + void +free_findfile(void) +{ + vim_free(ff_file_to_find); + vim_findfile_cleanup(fdip_search_ctx); + vim_free(ff_expand_buffer); +} +# endif + +/* + * Find the directory name "ptr[len]" in the path. + * + * options: + * FNAME_MESS give error message when not found + * FNAME_UNESC unescape backslashes. + * + * Uses NameBuff[]! + * + * Returns an allocated string for the file name. NULL for error. + */ + char_u * +find_directory_in_path( + char_u *ptr, // file name + int len, // length of file name + int options, + char_u *rel_fname) // file name searching relative to +{ + return find_file_in_path_option(ptr, len, options, TRUE, p_cdpath, + FINDFILE_DIR, rel_fname, (char_u *)""); +} + + char_u * +find_file_in_path_option( + char_u *ptr, // file name + int len, // length of file name + int options, + int first, // use count'th matching file name + char_u *path_option, // p_path or p_cdpath + int find_what, // FINDFILE_FILE, _DIR or _BOTH + char_u *rel_fname, // file name we are looking relative to. + char_u *suffixes) // list of suffixes, 'suffixesadd' option +{ + static char_u *dir; + static int did_findfile_init = FALSE; + char_u save_char; + char_u *file_name = NULL; + char_u *buf = NULL; + int rel_to_curdir; +# ifdef AMIGA + struct Process *proc = (struct Process *)FindTask(0L); + APTR save_winptr = proc->pr_WindowPtr; + + // Avoid a requester here for a volume that doesn't exist. + proc->pr_WindowPtr = (APTR)-1L; +# endif + + if (first == TRUE) + { + // copy file name into NameBuff, expanding environment variables + save_char = ptr[len]; + ptr[len] = NUL; + expand_env_esc(ptr, NameBuff, MAXPATHL, FALSE, TRUE, NULL); + ptr[len] = save_char; + + vim_free(ff_file_to_find); + ff_file_to_find = vim_strsave(NameBuff); + if (ff_file_to_find == NULL) // out of memory + { + file_name = NULL; + goto theend; + } + if (options & FNAME_UNESC) + { + // Change all "\ " to " ". + for (ptr = ff_file_to_find; *ptr != NUL; ++ptr) + if (ptr[0] == '\\' && ptr[1] == ' ') + mch_memmove(ptr, ptr + 1, STRLEN(ptr)); + } + } + + rel_to_curdir = (ff_file_to_find[0] == '.' + && (ff_file_to_find[1] == NUL + || vim_ispathsep(ff_file_to_find[1]) + || (ff_file_to_find[1] == '.' + && (ff_file_to_find[2] == NUL + || vim_ispathsep(ff_file_to_find[2]))))); + if (vim_isAbsName(ff_file_to_find) + // "..", "../path", "." and "./path": don't use the path_option + || rel_to_curdir +# if defined(MSWIN) + // handle "\tmp" as absolute path + || vim_ispathsep(ff_file_to_find[0]) + // handle "c:name" as absolute path + || (ff_file_to_find[0] != NUL && ff_file_to_find[1] == ':') +# endif +# ifdef AMIGA + // handle ":tmp" as absolute path + || ff_file_to_find[0] == ':' +# endif + ) + { + /* + * Absolute path, no need to use "path_option". + * If this is not a first call, return NULL. We already returned a + * filename on the first call. + */ + if (first == TRUE) + { + int l; + int run; + + if (path_with_url(ff_file_to_find)) + { + file_name = vim_strsave(ff_file_to_find); + goto theend; + } + + // When FNAME_REL flag given first use the directory of the file. + // Otherwise or when this fails use the current directory. + for (run = 1; run <= 2; ++run) + { + l = (int)STRLEN(ff_file_to_find); + if (run == 1 + && rel_to_curdir + && (options & FNAME_REL) + && rel_fname != NULL + && STRLEN(rel_fname) + l < MAXPATHL) + { + STRCPY(NameBuff, rel_fname); + STRCPY(gettail(NameBuff), ff_file_to_find); + l = (int)STRLEN(NameBuff); + } + else + { + STRCPY(NameBuff, ff_file_to_find); + run = 2; + } + + // When the file doesn't exist, try adding parts of + // 'suffixesadd'. + buf = suffixes; + for (;;) + { + if (mch_getperm(NameBuff) >= 0 + && (find_what == FINDFILE_BOTH + || ((find_what == FINDFILE_DIR) + == mch_isdir(NameBuff)))) + { + file_name = vim_strsave(NameBuff); + goto theend; + } + if (*buf == NUL) + break; + copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); + } + } + } + } + else + { + /* + * Loop over all paths in the 'path' or 'cdpath' option. + * When "first" is set, first setup to the start of the option. + * Otherwise continue to find the next match. + */ + if (first == TRUE) + { + // vim_findfile_free_visited can handle a possible NULL pointer + vim_findfile_free_visited(fdip_search_ctx); + dir = path_option; + did_findfile_init = FALSE; + } + + for (;;) + { + if (did_findfile_init) + { + file_name = vim_findfile(fdip_search_ctx); + if (file_name != NULL) + break; + + did_findfile_init = FALSE; + } + else + { + char_u *r_ptr; + + if (dir == NULL || *dir == NUL) + { + // We searched all paths of the option, now we can + // free the search context. + vim_findfile_cleanup(fdip_search_ctx); + fdip_search_ctx = NULL; + break; + } + + if ((buf = alloc((int)(MAXPATHL))) == NULL) + break; + + // copy next path + buf[0] = 0; + copy_option_part(&dir, buf, MAXPATHL, " ,"); + +# ifdef FEAT_PATH_EXTRA + // get the stopdir string + r_ptr = vim_findfile_stopdir(buf); +# else + r_ptr = NULL; +# endif + fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find, + r_ptr, 100, FALSE, find_what, + fdip_search_ctx, FALSE, rel_fname); + if (fdip_search_ctx != NULL) + did_findfile_init = TRUE; + vim_free(buf); + } + } + } + if (file_name == NULL && (options & FNAME_MESS)) + { + if (first == TRUE) + { + if (find_what == FINDFILE_DIR) + semsg(_("E344: Can't find directory \"%s\" in cdpath"), + ff_file_to_find); + else + semsg(_("E345: Can't find file \"%s\" in path"), + ff_file_to_find); + } + else + { + if (find_what == FINDFILE_DIR) + semsg(_("E346: No more directory \"%s\" found in cdpath"), + ff_file_to_find); + else + semsg(_("E347: No more file \"%s\" found in path"), + ff_file_to_find); + } + } + +theend: +# ifdef AMIGA + proc->pr_WindowPtr = save_winptr; +# endif + return file_name; +} + +/* + * Get the file name at the cursor. + * If Visual mode is active, use the selected text if it's in one line. + * Returns the name in allocated memory, NULL for failure. + */ + char_u * +grab_file_name(long count, linenr_T *file_lnum) +{ + int options = FNAME_MESS|FNAME_EXP|FNAME_REL|FNAME_UNESC; + + if (VIsual_active) + { + int len; + char_u *ptr; + + if (get_visual_text(NULL, &ptr, &len) == FAIL) + return NULL; + return find_file_name_in_path(ptr, len, options, + count, curbuf->b_ffname); + } + return file_name_at_cursor(options | FNAME_HYP, count, file_lnum); +} + +/* + * Return the file name under or after the cursor. + * + * The 'path' option is searched if the file name is not absolute. + * The string returned has been alloc'ed and should be freed by the caller. + * NULL is returned if the file name or file is not found. + * + * options: + * FNAME_MESS give error messages + * FNAME_EXP expand to path + * FNAME_HYP check for hypertext link + * FNAME_INCL apply "includeexpr" + */ + char_u * +file_name_at_cursor(int options, long count, linenr_T *file_lnum) +{ + return file_name_in_line(ml_get_curline(), + curwin->w_cursor.col, options, count, curbuf->b_ffname, + file_lnum); +} + +/* + * Return the name of the file under or after ptr[col]. + * Otherwise like file_name_at_cursor(). + */ + char_u * +file_name_in_line( + char_u *line, + int col, + int options, + long count, + char_u *rel_fname, // file we are searching relative to + linenr_T *file_lnum) // line number after the file name +{ + char_u *ptr; + int len; + int in_type = TRUE; + int is_url = FALSE; + + /* + * search forward for what could be the start of a file name + */ + ptr = line + col; + while (*ptr != NUL && !vim_isfilec(*ptr)) + MB_PTR_ADV(ptr); + if (*ptr == NUL) // nothing found + { + if (options & FNAME_MESS) + emsg(_("E446: No file name under cursor")); + return NULL; + } + + /* + * Search backward for first char of the file name. + * Go one char back to ":" before "//" even when ':' is not in 'isfname'. + */ + while (ptr > line) + { + if (has_mbyte && (len = (*mb_head_off)(line, ptr - 1)) > 0) + ptr -= len + 1; + else if (vim_isfilec(ptr[-1]) + || ((options & FNAME_HYP) && path_is_url(ptr - 1))) + --ptr; + else + break; + } + + /* + * Search forward for the last char of the file name. + * Also allow "://" when ':' is not in 'isfname'. + */ + len = 0; + while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') + || ((options & FNAME_HYP) && path_is_url(ptr + len)) + || (is_url && vim_strchr((char_u *)"?&=", ptr[len]) != NULL)) + { + // After type:// we also include ?, & and = as valid characters, so that + // http://google.com?q=this&that=ok works. + if ((ptr[len] >= 'A' && ptr[len] <= 'Z') || (ptr[len] >= 'a' && ptr[len] <= 'z')) + { + if (in_type && path_is_url(ptr + len + 1)) + is_url = TRUE; + } + else + in_type = FALSE; + + if (ptr[len] == '\\') + // Skip over the "\" in "\ ". + ++len; + if (has_mbyte) + len += (*mb_ptr2len)(ptr + len); + else + ++len; + } + + /* + * If there is trailing punctuation, remove it. + * But don't remove "..", could be a directory name. + */ + if (len > 2 && vim_strchr((char_u *)".,:;!", ptr[len - 1]) != NULL + && ptr[len - 2] != '.') + --len; + + if (file_lnum != NULL) + { + char_u *p; + + // Get the number after the file name and a separator character + p = ptr + len; + p = skipwhite(p); + if (*p != NUL) + { + if (!isdigit(*p)) + ++p; // skip the separator + p = skipwhite(p); + if (isdigit(*p)) + *file_lnum = (int)getdigits(&p); + } + } + + return find_file_name_in_path(ptr, len, options, count, rel_fname); +} + +# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) + static char_u * +eval_includeexpr(char_u *ptr, int len) +{ + char_u *res; + + set_vim_var_string(VV_FNAME, ptr, len); + res = eval_to_string_safe(curbuf->b_p_inex, NULL, + was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL)); + set_vim_var_string(VV_FNAME, NULL, 0); + return res; +} +# endif + +/* + * Return the name of the file ptr[len] in 'path'. + * Otherwise like file_name_at_cursor(). + */ + char_u * +find_file_name_in_path( + char_u *ptr, + int len, + int options, + long count, + char_u *rel_fname) // file we are searching relative to +{ + char_u *file_name; + int c; +# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) + char_u *tofree = NULL; + + if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) + { + tofree = eval_includeexpr(ptr, len); + if (tofree != NULL) + { + ptr = tofree; + len = (int)STRLEN(ptr); + } + } +# endif + + if (options & FNAME_EXP) + { + file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS, + TRUE, rel_fname); + +# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) + /* + * If the file could not be found in a normal way, try applying + * 'includeexpr' (unless done already). + */ + if (file_name == NULL + && !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) + { + tofree = eval_includeexpr(ptr, len); + if (tofree != NULL) + { + ptr = tofree; + len = (int)STRLEN(ptr); + file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS, + TRUE, rel_fname); + } + } +# endif + if (file_name == NULL && (options & FNAME_MESS)) + { + c = ptr[len]; + ptr[len] = NUL; + semsg(_("E447: Can't find file \"%s\" in path"), ptr); + ptr[len] = c; + } + + // Repeat finding the file "count" times. This matters when it + // appears several times in the path. + while (file_name != NULL && --count > 0) + { + vim_free(file_name); + file_name = find_file_in_path(ptr, len, options, FALSE, rel_fname); + } + } + else + file_name = vim_strnsave(ptr, len); + +# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) + vim_free(tofree); +# endif + + return file_name; +} + +/* + * Return the end of the directory name, on the first path + * separator: + * "/path/file", "/path/dir/", "/path//dir", "/file" + * ^ ^ ^ ^ + */ + static char_u * +gettail_dir(char_u *fname) +{ + char_u *dir_end = fname; + char_u *next_dir_end = fname; + int look_for_sep = TRUE; + char_u *p; + + for (p = fname; *p != NUL; ) + { + if (vim_ispathsep(*p)) + { + if (look_for_sep) + { + next_dir_end = p; + look_for_sep = FALSE; + } + } + else + { + if (!look_for_sep) + dir_end = next_dir_end; + look_for_sep = TRUE; + } + MB_PTR_ADV(p); + } + return dir_end; +} + +/* + * return TRUE if 'c' is a path list separator. + */ + int +vim_ispathlistsep(int c) +{ +# ifdef UNIX + return (c == ':'); +# else + return (c == ';'); // might not be right for every system... +# endif +} + +/* + * Moves "*psep" back to the previous path separator in "path". + * Returns FAIL is "*psep" ends up at the beginning of "path". + */ + static int +find_previous_pathsep(char_u *path, char_u **psep) +{ + // skip the current separator + if (*psep > path && vim_ispathsep(**psep)) + --*psep; + + // find the previous separator + while (*psep > path) + { + if (vim_ispathsep(**psep)) + return OK; + MB_PTR_BACK(path, *psep); + } + + return FAIL; +} + +/* + * Returns TRUE if "maybe_unique" is unique wrt other_paths in "gap". + * "maybe_unique" is the end portion of "((char_u **)gap->ga_data)[i]". + */ + static int +is_unique(char_u *maybe_unique, garray_T *gap, int i) +{ + int j; + int candidate_len; + int other_path_len; + char_u **other_paths = (char_u **)gap->ga_data; + char_u *rival; + + for (j = 0; j < gap->ga_len; j++) + { + if (j == i) + continue; // don't compare it with itself + + candidate_len = (int)STRLEN(maybe_unique); + other_path_len = (int)STRLEN(other_paths[j]); + if (other_path_len < candidate_len) + continue; // it's different when it's shorter + + rival = other_paths[j] + other_path_len - candidate_len; + if (fnamecmp(maybe_unique, rival) == 0 + && (rival == other_paths[j] || vim_ispathsep(*(rival - 1)))) + return FALSE; // match + } + + return TRUE; // no match found +} + +/* + * Split the 'path' option into an array of strings in garray_T. Relative + * paths are expanded to their equivalent fullpath. This includes the "." + * (relative to current buffer directory) and empty path (relative to current + * directory) notations. + * + * TODO: handle upward search (;) and path limiter (**N) notations by + * expanding each into their equivalent path(s). + */ + static void +expand_path_option(char_u *curdir, garray_T *gap) +{ + char_u *path_option = *curbuf->b_p_path == NUL + ? p_path : curbuf->b_p_path; + char_u *buf; + char_u *p; + int len; + + if ((buf = alloc((int)MAXPATHL)) == NULL) + return; + + while (*path_option != NUL) + { + copy_option_part(&path_option, buf, MAXPATHL, " ,"); + + if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) + { + // Relative to current buffer: + // "/path/file" + "." -> "/path/" + // "/path/file" + "./subdir" -> "/path/subdir" + if (curbuf->b_ffname == NULL) + continue; + p = gettail(curbuf->b_ffname); + len = (int)(p - curbuf->b_ffname); + if (len + (int)STRLEN(buf) >= MAXPATHL) + continue; + if (buf[1] == NUL) + buf[len] = NUL; + else + STRMOVE(buf + len, buf + 2); + mch_memmove(buf, curbuf->b_ffname, len); + simplify_filename(buf); + } + else if (buf[0] == NUL) + // relative to current directory + STRCPY(buf, curdir); + else if (path_with_url(buf)) + // URL can't be used here + continue; + else if (!mch_isFullName(buf)) + { + // Expand relative path to their full path equivalent + len = (int)STRLEN(curdir); + if (len + (int)STRLEN(buf) + 3 > MAXPATHL) + continue; + STRMOVE(buf + len + 1, buf); + STRCPY(buf, curdir); + buf[len] = PATHSEP; + simplify_filename(buf); + } + + if (ga_grow(gap, 1) == FAIL) + break; + +# if defined(MSWIN) + // Avoid the path ending in a backslash, it fails when a comma is + // appended. + len = (int)STRLEN(buf); + if (buf[len - 1] == '\\') + buf[len - 1] = '/'; +# endif + + p = vim_strsave(buf); + if (p == NULL) + break; + ((char_u **)gap->ga_data)[gap->ga_len++] = p; + } + + vim_free(buf); +} + +/* + * Returns a pointer to the file or directory name in "fname" that matches the + * longest path in "ga"p, or NULL if there is no match. For example: + * + * path: /foo/bar/baz + * fname: /foo/bar/baz/quux.txt + * returns: ^this + */ + static char_u * +get_path_cutoff(char_u *fname, garray_T *gap) +{ + int i; + int maxlen = 0; + char_u **path_part = (char_u **)gap->ga_data; + char_u *cutoff = NULL; + + for (i = 0; i < gap->ga_len; i++) + { + int j = 0; + + while ((fname[j] == path_part[i][j] +# if defined(MSWIN) + || (vim_ispathsep(fname[j]) && vim_ispathsep(path_part[i][j])) +# endif + ) && fname[j] != NUL && path_part[i][j] != NUL) + j++; + if (j > maxlen) + { + maxlen = j; + cutoff = &fname[j]; + } + } + + // skip to the file or directory name + if (cutoff != NULL) + while (vim_ispathsep(*cutoff)) + MB_PTR_ADV(cutoff); + + return cutoff; +} + +/* + * Sorts, removes duplicates and modifies all the fullpath names in "gap" so + * that they are unique with respect to each other while conserving the part + * that matches the pattern. Beware, this is at least O(n^2) wrt "gap->ga_len". + */ + void +uniquefy_paths(garray_T *gap, char_u *pattern) +{ + int i; + int len; + char_u **fnames = (char_u **)gap->ga_data; + int sort_again = FALSE; + char_u *pat; + char_u *file_pattern; + char_u *curdir; + regmatch_T regmatch; + garray_T path_ga; + char_u **in_curdir = NULL; + char_u *short_name; + + remove_duplicates(gap); + ga_init2(&path_ga, (int)sizeof(char_u *), 1); + + /* + * We need to prepend a '*' at the beginning of file_pattern so that the + * regex matches anywhere in the path. FIXME: is this valid for all + * possible patterns? + */ + len = (int)STRLEN(pattern); + file_pattern = alloc(len + 2); + if (file_pattern == NULL) + return; + file_pattern[0] = '*'; + file_pattern[1] = NUL; + STRCAT(file_pattern, pattern); + pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, TRUE); + vim_free(file_pattern); + if (pat == NULL) + return; + + regmatch.rm_ic = TRUE; // always ignore case + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); + vim_free(pat); + if (regmatch.regprog == NULL) + return; + + if ((curdir = alloc((int)(MAXPATHL))) == NULL) + goto theend; + mch_dirname(curdir, MAXPATHL); + expand_path_option(curdir, &path_ga); + + in_curdir = (char_u **)alloc_clear(gap->ga_len * sizeof(char_u *)); + if (in_curdir == NULL) + goto theend; + + for (i = 0; i < gap->ga_len && !got_int; i++) + { + char_u *path = fnames[i]; + int is_in_curdir; + char_u *dir_end = gettail_dir(path); + char_u *pathsep_p; + char_u *path_cutoff; + + len = (int)STRLEN(path); + is_in_curdir = fnamencmp(curdir, path, dir_end - path) == 0 + && curdir[dir_end - path] == NUL; + if (is_in_curdir) + in_curdir[i] = vim_strsave(path); + + // Shorten the filename while maintaining its uniqueness + path_cutoff = get_path_cutoff(path, &path_ga); + + // Don't assume all files can be reached without path when search + // pattern starts with star star slash, so only remove path_cutoff + // when possible. + if (pattern[0] == '*' && pattern[1] == '*' + && vim_ispathsep_nocolon(pattern[2]) + && path_cutoff != NULL + && vim_regexec(®match, path_cutoff, (colnr_T)0) + && is_unique(path_cutoff, gap, i)) + { + sort_again = TRUE; + mch_memmove(path, path_cutoff, STRLEN(path_cutoff) + 1); + } + else + { + // Here all files can be reached without path, so get shortest + // unique path. We start at the end of the path. + pathsep_p = path + len - 1; + + while (find_previous_pathsep(path, &pathsep_p)) + if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) + && is_unique(pathsep_p + 1, gap, i) + && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) + { + sort_again = TRUE; + mch_memmove(path, pathsep_p + 1, STRLEN(pathsep_p)); + break; + } + } + + if (mch_isFullName(path)) + { + /* + * Last resort: shorten relative to curdir if possible. + * 'possible' means: + * 1. It is under the current directory. + * 2. The result is actually shorter than the original. + * + * Before curdir After + * /foo/bar/file.txt /foo/bar ./file.txt + * c:\foo\bar\file.txt c:\foo\bar .\file.txt + * /file.txt / /file.txt + * c:\file.txt c:\ .\file.txt + */ + short_name = shorten_fname(path, curdir); + if (short_name != NULL && short_name > path + 1 +# if defined(MSWIN) + // On windows, + // shorten_fname("c:\a\a.txt", "c:\a\b") + // returns "\a\a.txt", which is not really the short + // name, hence: + && !vim_ispathsep(*short_name) +# endif + ) + { + STRCPY(path, "."); + add_pathsep(path); + STRMOVE(path + STRLEN(path), short_name); + } + } + ui_breakcheck(); + } + + // Shorten filenames in /in/current/directory/{filename} + for (i = 0; i < gap->ga_len && !got_int; i++) + { + char_u *rel_path; + char_u *path = in_curdir[i]; + + if (path == NULL) + continue; + + // If the {filename} is not unique, change it to ./{filename}. + // Else reduce it to {filename} + short_name = shorten_fname(path, curdir); + if (short_name == NULL) + short_name = path; + if (is_unique(short_name, gap, i)) + { + STRCPY(fnames[i], short_name); + continue; + } + + rel_path = alloc((int)(STRLEN(short_name) + STRLEN(PATHSEPSTR) + 2)); + if (rel_path == NULL) + goto theend; + STRCPY(rel_path, "."); + add_pathsep(rel_path); + STRCAT(rel_path, short_name); + + vim_free(fnames[i]); + fnames[i] = rel_path; + sort_again = TRUE; + ui_breakcheck(); + } + +theend: + vim_free(curdir); + if (in_curdir != NULL) + { + for (i = 0; i < gap->ga_len; i++) + vim_free(in_curdir[i]); + vim_free(in_curdir); + } + ga_clear_strings(&path_ga); + vim_regfree(regmatch.regprog); + + if (sort_again) + remove_duplicates(gap); +} + +/* + * Calls globpath() with 'path' values for the given pattern and stores the + * result in "gap". + * Returns the total number of matches. + */ + int +expand_in_path( + garray_T *gap, + char_u *pattern, + int flags) // EW_* flags +{ + char_u *curdir; + garray_T path_ga; + char_u *paths = NULL; + int glob_flags = 0; + + if ((curdir = alloc((unsigned)MAXPATHL)) == NULL) + return 0; + mch_dirname(curdir, MAXPATHL); + + ga_init2(&path_ga, (int)sizeof(char_u *), 1); + expand_path_option(curdir, &path_ga); + vim_free(curdir); + if (path_ga.ga_len == 0) + return 0; + + paths = ga_concat_strings(&path_ga, ","); + ga_clear_strings(&path_ga); + if (paths == NULL) + return 0; + + if (flags & EW_ICASE) + glob_flags |= WILD_ICASE; + if (flags & EW_ADDSLASH) + glob_flags |= WILD_ADD_SLASH; + globpath(paths, pattern, gap, glob_flags); + vim_free(paths); + + return gap->ga_len; +} + +#endif // FEAT_SEARCHPATH diff --git a/src/misc1.c b/src/misc1.c index 26b570bcb0..1d957908eb 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -21,6 +21,9 @@ static char_u *vim_version_dir(char_u *vimdir); static char_u *remove_tail(char_u *p, char_u *pend, char_u *name); +#define URL_SLASH 1 /* path_is_url() has found "://" */ +#define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */ + /* All user names (for ~user completion as done by shell). */ #if defined(FEAT_CMDL_COMPL) || defined(PROTO) static garray_T ga_users; @@ -5023,43 +5026,6 @@ gettail(char_u *fname) return p1; } -#if defined(FEAT_SEARCHPATH) -/* - * Return the end of the directory name, on the first path - * separator: - * "/path/file", "/path/dir/", "/path//dir", "/file" - * ^ ^ ^ ^ - */ - static char_u * -gettail_dir(char_u *fname) -{ - char_u *dir_end = fname; - char_u *next_dir_end = fname; - int look_for_sep = TRUE; - char_u *p; - - for (p = fname; *p != NUL; ) - { - if (vim_ispathsep(*p)) - { - if (look_for_sep) - { - next_dir_end = p; - look_for_sep = FALSE; - } - } - else - { - if (!look_for_sep) - dir_end = next_dir_end; - look_for_sep = TRUE; - } - MB_PTR_ADV(p); - } - return dir_end; -} -#endif - /* * Get pointer to tail of "fname", including path separators. Putting a NUL * here leaves the directory name. Takes care of "c:/" and "//". @@ -5165,21 +5131,6 @@ vim_ispathsep_nocolon(int c) ; } -#if defined(FEAT_SEARCHPATH) || defined(PROTO) -/* - * return TRUE if 'c' is a path list separator. - */ - int -vim_ispathlistsep(int c) -{ -#ifdef UNIX - return (c == ':'); -#else - return (c == ';'); /* might not be right for every system... */ -#endif -} -#endif - /* * Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" * It's done in-place. @@ -6183,407 +6134,6 @@ unix_expandpath( } #endif -#if defined(FEAT_SEARCHPATH) -/* - * Moves "*psep" back to the previous path separator in "path". - * Returns FAIL is "*psep" ends up at the beginning of "path". - */ - static int -find_previous_pathsep(char_u *path, char_u **psep) -{ - /* skip the current separator */ - if (*psep > path && vim_ispathsep(**psep)) - --*psep; - - /* find the previous separator */ - while (*psep > path) - { - if (vim_ispathsep(**psep)) - return OK; - MB_PTR_BACK(path, *psep); - } - - return FAIL; -} - -/* - * Returns TRUE if "maybe_unique" is unique wrt other_paths in "gap". - * "maybe_unique" is the end portion of "((char_u **)gap->ga_data)[i]". - */ - static int -is_unique(char_u *maybe_unique, garray_T *gap, int i) -{ - int j; - int candidate_len; - int other_path_len; - char_u **other_paths = (char_u **)gap->ga_data; - char_u *rival; - - for (j = 0; j < gap->ga_len; j++) - { - if (j == i) - continue; /* don't compare it with itself */ - - candidate_len = (int)STRLEN(maybe_unique); - other_path_len = (int)STRLEN(other_paths[j]); - if (other_path_len < candidate_len) - continue; /* it's different when it's shorter */ - - rival = other_paths[j] + other_path_len - candidate_len; - if (fnamecmp(maybe_unique, rival) == 0 - && (rival == other_paths[j] || vim_ispathsep(*(rival - 1)))) - return FALSE; /* match */ - } - - return TRUE; /* no match found */ -} - -/* - * Split the 'path' option into an array of strings in garray_T. Relative - * paths are expanded to their equivalent fullpath. This includes the "." - * (relative to current buffer directory) and empty path (relative to current - * directory) notations. - * - * TODO: handle upward search (;) and path limiter (**N) notations by - * expanding each into their equivalent path(s). - */ - static void -expand_path_option(char_u *curdir, garray_T *gap) -{ - char_u *path_option = *curbuf->b_p_path == NUL - ? p_path : curbuf->b_p_path; - char_u *buf; - char_u *p; - int len; - - if ((buf = alloc((int)MAXPATHL)) == NULL) - return; - - while (*path_option != NUL) - { - copy_option_part(&path_option, buf, MAXPATHL, " ,"); - - if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) - { - /* Relative to current buffer: - * "/path/file" + "." -> "/path/" - * "/path/file" + "./subdir" -> "/path/subdir" */ - if (curbuf->b_ffname == NULL) - continue; - p = gettail(curbuf->b_ffname); - len = (int)(p - curbuf->b_ffname); - if (len + (int)STRLEN(buf) >= MAXPATHL) - continue; - if (buf[1] == NUL) - buf[len] = NUL; - else - STRMOVE(buf + len, buf + 2); - mch_memmove(buf, curbuf->b_ffname, len); - simplify_filename(buf); - } - else if (buf[0] == NUL) - /* relative to current directory */ - STRCPY(buf, curdir); - else if (path_with_url(buf)) - /* URL can't be used here */ - continue; - else if (!mch_isFullName(buf)) - { - /* Expand relative path to their full path equivalent */ - len = (int)STRLEN(curdir); - if (len + (int)STRLEN(buf) + 3 > MAXPATHL) - continue; - STRMOVE(buf + len + 1, buf); - STRCPY(buf, curdir); - buf[len] = PATHSEP; - simplify_filename(buf); - } - - if (ga_grow(gap, 1) == FAIL) - break; - -# if defined(MSWIN) - /* Avoid the path ending in a backslash, it fails when a comma is - * appended. */ - len = (int)STRLEN(buf); - if (buf[len - 1] == '\\') - buf[len - 1] = '/'; -# endif - - p = vim_strsave(buf); - if (p == NULL) - break; - ((char_u **)gap->ga_data)[gap->ga_len++] = p; - } - - vim_free(buf); -} - -/* - * Returns a pointer to the file or directory name in "fname" that matches the - * longest path in "ga"p, or NULL if there is no match. For example: - * - * path: /foo/bar/baz - * fname: /foo/bar/baz/quux.txt - * returns: ^this - */ - static char_u * -get_path_cutoff(char_u *fname, garray_T *gap) -{ - int i; - int maxlen = 0; - char_u **path_part = (char_u **)gap->ga_data; - char_u *cutoff = NULL; - - for (i = 0; i < gap->ga_len; i++) - { - int j = 0; - - while ((fname[j] == path_part[i][j] -# if defined(MSWIN) - || (vim_ispathsep(fname[j]) && vim_ispathsep(path_part[i][j])) -#endif - ) && fname[j] != NUL && path_part[i][j] != NUL) - j++; - if (j > maxlen) - { - maxlen = j; - cutoff = &fname[j]; - } - } - - /* skip to the file or directory name */ - if (cutoff != NULL) - while (vim_ispathsep(*cutoff)) - MB_PTR_ADV(cutoff); - - return cutoff; -} - -/* - * Sorts, removes duplicates and modifies all the fullpath names in "gap" so - * that they are unique with respect to each other while conserving the part - * that matches the pattern. Beware, this is at least O(n^2) wrt "gap->ga_len". - */ - static void -uniquefy_paths(garray_T *gap, char_u *pattern) -{ - int i; - int len; - char_u **fnames = (char_u **)gap->ga_data; - int sort_again = FALSE; - char_u *pat; - char_u *file_pattern; - char_u *curdir; - regmatch_T regmatch; - garray_T path_ga; - char_u **in_curdir = NULL; - char_u *short_name; - - remove_duplicates(gap); - ga_init2(&path_ga, (int)sizeof(char_u *), 1); - - /* - * We need to prepend a '*' at the beginning of file_pattern so that the - * regex matches anywhere in the path. FIXME: is this valid for all - * possible patterns? - */ - len = (int)STRLEN(pattern); - file_pattern = alloc(len + 2); - if (file_pattern == NULL) - return; - file_pattern[0] = '*'; - file_pattern[1] = NUL; - STRCAT(file_pattern, pattern); - pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, TRUE); - vim_free(file_pattern); - if (pat == NULL) - return; - - regmatch.rm_ic = TRUE; /* always ignore case */ - regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); - vim_free(pat); - if (regmatch.regprog == NULL) - return; - - if ((curdir = alloc((int)(MAXPATHL))) == NULL) - goto theend; - mch_dirname(curdir, MAXPATHL); - expand_path_option(curdir, &path_ga); - - in_curdir = (char_u **)alloc_clear(gap->ga_len * sizeof(char_u *)); - if (in_curdir == NULL) - goto theend; - - for (i = 0; i < gap->ga_len && !got_int; i++) - { - char_u *path = fnames[i]; - int is_in_curdir; - char_u *dir_end = gettail_dir(path); - char_u *pathsep_p; - char_u *path_cutoff; - - len = (int)STRLEN(path); - is_in_curdir = fnamencmp(curdir, path, dir_end - path) == 0 - && curdir[dir_end - path] == NUL; - if (is_in_curdir) - in_curdir[i] = vim_strsave(path); - - /* Shorten the filename while maintaining its uniqueness */ - path_cutoff = get_path_cutoff(path, &path_ga); - - /* Don't assume all files can be reached without path when search - * pattern starts with star star slash, so only remove path_cutoff - * when possible. */ - if (pattern[0] == '*' && pattern[1] == '*' - && vim_ispathsep_nocolon(pattern[2]) - && path_cutoff != NULL - && vim_regexec(®match, path_cutoff, (colnr_T)0) - && is_unique(path_cutoff, gap, i)) - { - sort_again = TRUE; - mch_memmove(path, path_cutoff, STRLEN(path_cutoff) + 1); - } - else - { - /* Here all files can be reached without path, so get shortest - * unique path. We start at the end of the path. */ - pathsep_p = path + len - 1; - - while (find_previous_pathsep(path, &pathsep_p)) - if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) - && is_unique(pathsep_p + 1, gap, i) - && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) - { - sort_again = TRUE; - mch_memmove(path, pathsep_p + 1, STRLEN(pathsep_p)); - break; - } - } - - if (mch_isFullName(path)) - { - /* - * Last resort: shorten relative to curdir if possible. - * 'possible' means: - * 1. It is under the current directory. - * 2. The result is actually shorter than the original. - * - * Before curdir After - * /foo/bar/file.txt /foo/bar ./file.txt - * c:\foo\bar\file.txt c:\foo\bar .\file.txt - * /file.txt / /file.txt - * c:\file.txt c:\ .\file.txt - */ - short_name = shorten_fname(path, curdir); - if (short_name != NULL && short_name > path + 1 -#if defined(MSWIN) - /* On windows, - * shorten_fname("c:\a\a.txt", "c:\a\b") - * returns "\a\a.txt", which is not really the short - * name, hence: */ - && !vim_ispathsep(*short_name) -#endif - ) - { - STRCPY(path, "."); - add_pathsep(path); - STRMOVE(path + STRLEN(path), short_name); - } - } - ui_breakcheck(); - } - - /* Shorten filenames in /in/current/directory/{filename} */ - for (i = 0; i < gap->ga_len && !got_int; i++) - { - char_u *rel_path; - char_u *path = in_curdir[i]; - - if (path == NULL) - continue; - - /* If the {filename} is not unique, change it to ./{filename}. - * Else reduce it to {filename} */ - short_name = shorten_fname(path, curdir); - if (short_name == NULL) - short_name = path; - if (is_unique(short_name, gap, i)) - { - STRCPY(fnames[i], short_name); - continue; - } - - rel_path = alloc((int)(STRLEN(short_name) + STRLEN(PATHSEPSTR) + 2)); - if (rel_path == NULL) - goto theend; - STRCPY(rel_path, "."); - add_pathsep(rel_path); - STRCAT(rel_path, short_name); - - vim_free(fnames[i]); - fnames[i] = rel_path; - sort_again = TRUE; - ui_breakcheck(); - } - -theend: - vim_free(curdir); - if (in_curdir != NULL) - { - for (i = 0; i < gap->ga_len; i++) - vim_free(in_curdir[i]); - vim_free(in_curdir); - } - ga_clear_strings(&path_ga); - vim_regfree(regmatch.regprog); - - if (sort_again) - remove_duplicates(gap); -} - -/* - * Calls globpath() with 'path' values for the given pattern and stores the - * result in "gap". - * Returns the total number of matches. - */ - static int -expand_in_path( - garray_T *gap, - char_u *pattern, - int flags) /* EW_* flags */ -{ - char_u *curdir; - garray_T path_ga; - char_u *paths = NULL; - int glob_flags = 0; - - if ((curdir = alloc((unsigned)MAXPATHL)) == NULL) - return 0; - mch_dirname(curdir, MAXPATHL); - - ga_init2(&path_ga, (int)sizeof(char_u *), 1); - expand_path_option(curdir, &path_ga); - vim_free(curdir); - if (path_ga.ga_len == 0) - return 0; - - paths = ga_concat_strings(&path_ga, ","); - ga_clear_strings(&path_ga); - if (paths == NULL) - return 0; - - if (flags & EW_ICASE) - glob_flags |= WILD_ICASE; - if (flags & EW_ADDSLASH) - glob_flags |= WILD_ADD_SLASH; - globpath(paths, pattern, gap, glob_flags); - vim_free(paths); - - return gap->ga_len; -} -#endif - #if defined(FEAT_SEARCHPATH) || defined(FEAT_CMDL_COMPL) || defined(PROTO) /* * Sort "gap" and remove duplicate entries. "gap" is expected to contain a @@ -7120,3 +6670,75 @@ get_isolated_shell_name(void) #endif return p; } + +/* + * Check if the "://" of a URL is at the pointer, return URL_SLASH. + * Also check for ":\\", which MS Internet Explorer accepts, return + * URL_BACKSLASH. + */ + int +path_is_url(char_u *p) +{ + if (STRNCMP(p, "://", (size_t)3) == 0) + return URL_SLASH; + else if (STRNCMP(p, ":\\\\", (size_t)3) == 0) + return URL_BACKSLASH; + return 0; +} + +/* + * Check if "fname" starts with "name://". Return URL_SLASH if it does. + * Return URL_BACKSLASH for "name:\\". + * Return zero otherwise. + */ + int +path_with_url(char_u *fname) +{ + char_u *p; + + for (p = fname; isalpha(*p); ++p) + ; + return path_is_url(p); +} + +/* + * Return TRUE if "name" is a full (absolute) path name or URL. + */ + int +vim_isAbsName(char_u *name) +{ + return (path_with_url(name) != 0 || mch_isFullName(name)); +} + +/* + * Get absolute file name into buffer "buf[len]". + * + * return FAIL for failure, OK otherwise + */ + int +vim_FullName( + char_u *fname, + char_u *buf, + int len, + int force) /* force expansion even when already absolute */ +{ + int retval = OK; + int url; + + *buf = NUL; + if (fname == NULL) + return FAIL; + + url = path_with_url(fname); + if (!url) + retval = mch_FullName(fname, buf, len, force); + if (url || retval == FAIL) + { + /* something failed; use the file name (truncate when too long) */ + vim_strncpy(buf, fname, len - 1); + } +#if defined(MSWIN) + slash_adjust(buf); +#endif + return retval; +} diff --git a/src/misc2.c b/src/misc2.c index 278cc330c0..d323fe512f 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -14,8 +14,6 @@ static char_u *username = NULL; /* cached result of mch_get_user_name() */ -static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */ - static int coladvance2(pos_T *pos, int addspaces, int finetune, colnr_T wcol); /* @@ -1047,10 +1045,6 @@ do_outofmem_msg(long_u size) #if defined(EXITFREE) || defined(PROTO) -# if defined(FEAT_SEARCHPATH) -static void free_findfile(void); -# endif - /* * Free everything that we allocated. * Can be used to detect memory leaks, e.g., with ccmalloc. @@ -1161,7 +1155,6 @@ free_all_mem(void) vim_free(new_last_cmdline); # endif set_keep_msg(NULL, 0); - vim_free(ff_expand_buffer); /* Clear cmdline history. */ p_hi = 0; @@ -3822,1925 +3815,6 @@ update_mouseshape(int shape_idx) #endif /* CURSOR_SHAPE */ -/* TODO: make some #ifdef for this */ -/*--------[ file searching ]-------------------------------------------------*/ -/* - * File searching functions for 'path', 'tags' and 'cdpath' options. - * External visible functions: - * vim_findfile_init() creates/initialises the search context - * vim_findfile_free_visited() free list of visited files/dirs of search - * context - * vim_findfile() find a file in the search context - * vim_findfile_cleanup() cleanup/free search context created by - * vim_findfile_init() - * - * All static functions and variables start with 'ff_' - * - * In general it works like this: - * First you create yourself a search context by calling vim_findfile_init(). - * It is possible to give a search context from a previous call to - * vim_findfile_init(), so it can be reused. After this you call vim_findfile() - * until you are satisfied with the result or it returns NULL. On every call it - * returns the next file which matches the conditions given to - * vim_findfile_init(). If it doesn't find a next file it returns NULL. - * - * It is possible to call vim_findfile_init() again to reinitialise your search - * with some new parameters. Don't forget to pass your old search context to - * it, so it can reuse it and especially reuse the list of already visited - * directories. If you want to delete the list of already visited directories - * simply call vim_findfile_free_visited(). - * - * When you are done call vim_findfile_cleanup() to free the search context. - * - * The function vim_findfile_init() has a long comment, which describes the - * needed parameters. - * - * - * - * ATTENTION: - * ========== - * Also we use an allocated search context here, this functions are NOT - * thread-safe!!!!! - * - * To minimize parameter passing (or because I'm to lazy), only the - * external visible functions get a search context as a parameter. This is - * then assigned to a static global, which is used throughout the local - * functions. - */ - -/* - * type for the directory search stack - */ -typedef struct ff_stack -{ - struct ff_stack *ffs_prev; - - /* the fix part (no wildcards) and the part containing the wildcards - * of the search path - */ - char_u *ffs_fix_path; -#ifdef FEAT_PATH_EXTRA - char_u *ffs_wc_path; -#endif - - /* files/dirs found in the above directory, matched by the first wildcard - * of wc_part - */ - char_u **ffs_filearray; - int ffs_filearray_size; - char_u ffs_filearray_cur; /* needed for partly handled dirs */ - - /* to store status of partly handled directories - * 0: we work on this directory for the first time - * 1: this directory was partly searched in an earlier step - */ - int ffs_stage; - - /* How deep are we in the directory tree? - * Counts backward from value of level parameter to vim_findfile_init - */ - int ffs_level; - - /* Did we already expand '**' to an empty string? */ - int ffs_star_star_empty; -} ff_stack_T; - -/* - * type for already visited directories or files. - */ -typedef struct ff_visited -{ - struct ff_visited *ffv_next; - -#ifdef FEAT_PATH_EXTRA - /* Visited directories are different if the wildcard string are - * different. So we have to save it. - */ - char_u *ffv_wc_path; -#endif - /* for unix use inode etc for comparison (needed because of links), else - * use filename. - */ -#ifdef UNIX - int ffv_dev_valid; /* ffv_dev and ffv_ino were set */ - dev_t ffv_dev; /* device number */ - ino_t ffv_ino; /* inode number */ -#endif - /* The memory for this struct is allocated according to the length of - * ffv_fname. - */ - char_u ffv_fname[1]; /* actually longer */ -} ff_visited_T; - -/* - * We might have to manage several visited lists during a search. - * This is especially needed for the tags option. If tags is set to: - * "./++/tags,./++/TAGS,++/tags" (replace + with *) - * So we have to do 3 searches: - * 1) search from the current files directory downward for the file "tags" - * 2) search from the current files directory downward for the file "TAGS" - * 3) search from Vims current directory downwards for the file "tags" - * As you can see, the first and the third search are for the same file, so for - * the third search we can use the visited list of the first search. For the - * second search we must start from a empty visited list. - * The struct ff_visited_list_hdr is used to manage a linked list of already - * visited lists. - */ -typedef struct ff_visited_list_hdr -{ - struct ff_visited_list_hdr *ffvl_next; - - /* the filename the attached visited list is for */ - char_u *ffvl_filename; - - ff_visited_T *ffvl_visited_list; - -} ff_visited_list_hdr_T; - - -/* - * '**' can be expanded to several directory levels. - * Set the default maximum depth. - */ -#define FF_MAX_STAR_STAR_EXPAND ((char_u)30) - -/* - * The search context: - * ffsc_stack_ptr: the stack for the dirs to search - * ffsc_visited_list: the currently active visited list - * ffsc_dir_visited_list: the currently active visited list for search dirs - * ffsc_visited_lists_list: the list of all visited lists - * ffsc_dir_visited_lists_list: the list of all visited lists for search dirs - * ffsc_file_to_search: the file to search for - * ffsc_start_dir: the starting directory, if search path was relative - * ffsc_fix_path: the fix part of the given path (without wildcards) - * Needed for upward search. - * ffsc_wc_path: the part of the given path containing wildcards - * ffsc_level: how many levels of dirs to search downwards - * ffsc_stopdirs_v: array of stop directories for upward search - * ffsc_find_what: FINDFILE_BOTH, FINDFILE_DIR or FINDFILE_FILE - * ffsc_tagfile: searching for tags file, don't use 'suffixesadd' - */ -typedef struct ff_search_ctx_T -{ - ff_stack_T *ffsc_stack_ptr; - ff_visited_list_hdr_T *ffsc_visited_list; - ff_visited_list_hdr_T *ffsc_dir_visited_list; - ff_visited_list_hdr_T *ffsc_visited_lists_list; - ff_visited_list_hdr_T *ffsc_dir_visited_lists_list; - char_u *ffsc_file_to_search; - char_u *ffsc_start_dir; - char_u *ffsc_fix_path; -#ifdef FEAT_PATH_EXTRA - char_u *ffsc_wc_path; - int ffsc_level; - char_u **ffsc_stopdirs_v; -#endif - int ffsc_find_what; - int ffsc_tagfile; -} ff_search_ctx_T; - -/* locally needed functions */ -#ifdef FEAT_PATH_EXTRA -static int ff_check_visited(ff_visited_T **, char_u *, char_u *); -#else -static int ff_check_visited(ff_visited_T **, char_u *); -#endif -static void vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp); -static void ff_free_visited_list(ff_visited_T *vl); -static ff_visited_list_hdr_T* ff_get_visited_list(char_u *, ff_visited_list_hdr_T **list_headp); - -static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr); -static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx); -static void ff_clear(ff_search_ctx_T *search_ctx); -static void ff_free_stack_element(ff_stack_T *stack_ptr); -#ifdef FEAT_PATH_EXTRA -static ff_stack_T *ff_create_stack_element(char_u *, char_u *, int, int); -#else -static ff_stack_T *ff_create_stack_element(char_u *, int, int); -#endif -#ifdef FEAT_PATH_EXTRA -static int ff_path_in_stoplist(char_u *, int, char_u **); -#endif - -static char_u e_pathtoolong[] = N_("E854: path too long for completion"); - -#if 0 -/* - * if someone likes findfirst/findnext, here are the functions - * NOT TESTED!! - */ - -static void *ff_fn_search_context = NULL; - - char_u * -vim_findfirst(char_u *path, char_u *filename, int level) -{ - ff_fn_search_context = - vim_findfile_init(path, filename, NULL, level, TRUE, FALSE, - ff_fn_search_context, rel_fname); - if (NULL == ff_fn_search_context) - return NULL; - else - return vim_findnext() -} - - char_u * -vim_findnext(void) -{ - char_u *ret = vim_findfile(ff_fn_search_context); - - if (NULL == ret) - { - vim_findfile_cleanup(ff_fn_search_context); - ff_fn_search_context = NULL; - } - return ret; -} -#endif - -/* - * Initialization routine for vim_findfile(). - * - * Returns the newly allocated search context or NULL if an error occurred. - * - * Don't forget to clean up by calling vim_findfile_cleanup() if you are done - * with the search context. - * - * Find the file 'filename' in the directory 'path'. - * The parameter 'path' may contain wildcards. If so only search 'level' - * directories deep. The parameter 'level' is the absolute maximum and is - * not related to restricts given to the '**' wildcard. If 'level' is 100 - * and you use '**200' vim_findfile() will stop after 100 levels. - * - * 'filename' cannot contain wildcards! It is used as-is, no backslashes to - * escape special characters. - * - * If 'stopdirs' is not NULL and nothing is found downward, the search is - * restarted on the next higher directory level. This is repeated until the - * start-directory of a search is contained in 'stopdirs'. 'stopdirs' has the - * format ";**\(;\)*;\=$". - * - * If the 'path' is relative, the starting dir for the search is either VIM's - * current dir or if the path starts with "./" the current files dir. - * If the 'path' is absolute, the starting dir is that part of the path before - * the first wildcard. - * - * Upward search is only done on the starting dir. - * - * If 'free_visited' is TRUE the list of already visited files/directories is - * cleared. Set this to FALSE if you just want to search from another - * directory, but want to be sure that no directory from a previous search is - * searched again. This is useful if you search for a file at different places. - * The list of visited files/dirs can also be cleared with the function - * vim_findfile_free_visited(). - * - * Set the parameter 'find_what' to FINDFILE_DIR if you want to search for - * directories only, FINDFILE_FILE for files only, FINDFILE_BOTH for both. - * - * A search context returned by a previous call to vim_findfile_init() can be - * passed in the parameter "search_ctx_arg". This context is reused and - * reinitialized with the new parameters. The list of already visited - * directories from this context is only deleted if the parameter - * "free_visited" is true. Be aware that the passed "search_ctx_arg" is freed - * if the reinitialization fails. - * - * If you don't have a search context from a previous call "search_ctx_arg" - * must be NULL. - * - * This function silently ignores a few errors, vim_findfile() will have - * limited functionality then. - */ - void * -vim_findfile_init( - char_u *path, - char_u *filename, - char_u *stopdirs UNUSED, - int level, - int free_visited, - int find_what, - void *search_ctx_arg, - int tagfile, /* expanding names of tags files */ - char_u *rel_fname) /* file name to use for "." */ -{ -#ifdef FEAT_PATH_EXTRA - char_u *wc_part; -#endif - ff_stack_T *sptr; - ff_search_ctx_T *search_ctx; - - /* If a search context is given by the caller, reuse it, else allocate a - * new one. - */ - if (search_ctx_arg != NULL) - search_ctx = search_ctx_arg; - else - { - search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T)); - if (search_ctx == NULL) - goto error_return; - vim_memset(search_ctx, 0, sizeof(ff_search_ctx_T)); - } - search_ctx->ffsc_find_what = find_what; - search_ctx->ffsc_tagfile = tagfile; - - /* clear the search context, but NOT the visited lists */ - ff_clear(search_ctx); - - /* clear visited list if wanted */ - if (free_visited == TRUE) - vim_findfile_free_visited(search_ctx); - else - { - /* Reuse old visited lists. Get the visited list for the given - * filename. If no list for the current filename exists, creates a new - * one. */ - search_ctx->ffsc_visited_list = ff_get_visited_list(filename, - &search_ctx->ffsc_visited_lists_list); - if (search_ctx->ffsc_visited_list == NULL) - goto error_return; - search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename, - &search_ctx->ffsc_dir_visited_lists_list); - if (search_ctx->ffsc_dir_visited_list == NULL) - goto error_return; - } - - if (ff_expand_buffer == NULL) - { - ff_expand_buffer = (char_u*)alloc(MAXPATHL); - if (ff_expand_buffer == NULL) - goto error_return; - } - - /* Store information on starting dir now if path is relative. - * If path is absolute, we do that later. */ - if (path[0] == '.' - && (vim_ispathsep(path[1]) || path[1] == NUL) - && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) - && rel_fname != NULL) - { - int len = (int)(gettail(rel_fname) - rel_fname); - - if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) - { - /* Make the start dir an absolute path name. */ - vim_strncpy(ff_expand_buffer, rel_fname, len); - search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE); - } - else - search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len); - if (search_ctx->ffsc_start_dir == NULL) - goto error_return; - if (*++path != NUL) - ++path; - } - else if (*path == NUL || !vim_isAbsName(path)) - { -#ifdef BACKSLASH_IN_FILENAME - /* "c:dir" needs "c:" to be expanded, otherwise use current dir */ - if (*path != NUL && path[1] == ':') - { - char_u drive[3]; - - drive[0] = path[0]; - drive[1] = ':'; - drive[2] = NUL; - if (vim_FullName(drive, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) - goto error_return; - path += 2; - } - else -#endif - if (mch_dirname(ff_expand_buffer, MAXPATHL) == FAIL) - goto error_return; - - search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer); - if (search_ctx->ffsc_start_dir == NULL) - goto error_return; - -#ifdef BACKSLASH_IN_FILENAME - /* A path that starts with "/dir" is relative to the drive, not to the - * directory (but not for "//machine/dir"). Only use the drive name. */ - if ((*path == '/' || *path == '\\') - && path[1] != path[0] - && search_ctx->ffsc_start_dir[1] == ':') - search_ctx->ffsc_start_dir[2] = NUL; -#endif - } - -#ifdef FEAT_PATH_EXTRA - /* - * If stopdirs are given, split them into an array of pointers. - * If this fails (mem allocation), there is no upward search at all or a - * stop directory is not recognized -> continue silently. - * If stopdirs just contains a ";" or is empty, - * search_ctx->ffsc_stopdirs_v will only contain a NULL pointer. This - * is handled as unlimited upward search. See function - * ff_path_in_stoplist() for details. - */ - if (stopdirs != NULL) - { - char_u *walker = stopdirs; - int dircount; - - while (*walker == ';') - walker++; - - dircount = 1; - search_ctx->ffsc_stopdirs_v = - (char_u **)alloc((unsigned)sizeof(char_u *)); - - if (search_ctx->ffsc_stopdirs_v != NULL) - { - do - { - char_u *helper; - void *ptr; - - helper = walker; - ptr = vim_realloc(search_ctx->ffsc_stopdirs_v, - (dircount + 1) * sizeof(char_u *)); - if (ptr) - search_ctx->ffsc_stopdirs_v = ptr; - else - /* ignore, keep what we have and continue */ - break; - walker = vim_strchr(walker, ';'); - if (walker) - { - search_ctx->ffsc_stopdirs_v[dircount-1] = - vim_strnsave(helper, (int)(walker - helper)); - walker++; - } - else - /* this might be "", which means ascent till top - * of directory tree. - */ - search_ctx->ffsc_stopdirs_v[dircount-1] = - vim_strsave(helper); - - dircount++; - - } while (walker != NULL); - search_ctx->ffsc_stopdirs_v[dircount-1] = NULL; - } - } -#endif - -#ifdef FEAT_PATH_EXTRA - search_ctx->ffsc_level = level; - - /* split into: - * -fix path - * -wildcard_stuff (might be NULL) - */ - wc_part = vim_strchr(path, '*'); - if (wc_part != NULL) - { - int llevel; - int len; - char *errpt; - - /* save the fix part of the path */ - search_ctx->ffsc_fix_path = vim_strnsave(path, (int)(wc_part - path)); - - /* - * copy wc_path and add restricts to the '**' wildcard. - * The octet after a '**' is used as a (binary) counter. - * So '**3' is transposed to '**^C' ('^C' is ASCII value 3) - * or '**76' is transposed to '**N'( 'N' is ASCII value 76). - * For EBCDIC you get different character values. - * If no restrict is given after '**' the default is used. - * Due to this technique the path looks awful if you print it as a - * string. - */ - len = 0; - while (*wc_part != NUL) - { - if (len + 5 >= MAXPATHL) - { - emsg(_(e_pathtoolong)); - break; - } - if (STRNCMP(wc_part, "**", 2) == 0) - { - ff_expand_buffer[len++] = *wc_part++; - ff_expand_buffer[len++] = *wc_part++; - - llevel = strtol((char *)wc_part, &errpt, 10); - if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) - ff_expand_buffer[len++] = llevel; - else if ((char_u *)errpt != wc_part && llevel == 0) - /* restrict is 0 -> remove already added '**' */ - len -= 2; - else - ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND; - wc_part = (char_u *)errpt; - if (*wc_part != NUL && !vim_ispathsep(*wc_part)) - { - semsg(_("E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."), PATHSEPSTR); - goto error_return; - } - } - else - ff_expand_buffer[len++] = *wc_part++; - } - ff_expand_buffer[len] = NUL; - search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer); - - if (search_ctx->ffsc_wc_path == NULL) - goto error_return; - } - else -#endif - search_ctx->ffsc_fix_path = vim_strsave(path); - - if (search_ctx->ffsc_start_dir == NULL) - { - /* store the fix part as startdir. - * This is needed if the parameter path is fully qualified. - */ - search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path); - if (search_ctx->ffsc_start_dir == NULL) - goto error_return; - search_ctx->ffsc_fix_path[0] = NUL; - } - - /* create an absolute path */ - if (STRLEN(search_ctx->ffsc_start_dir) - + STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) - { - emsg(_(e_pathtoolong)); - goto error_return; - } - STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir); - add_pathsep(ff_expand_buffer); - { - int eb_len = (int)STRLEN(ff_expand_buffer); - char_u *buf = alloc(eb_len - + (int)STRLEN(search_ctx->ffsc_fix_path) + 1); - - STRCPY(buf, ff_expand_buffer); - STRCPY(buf + eb_len, search_ctx->ffsc_fix_path); - if (mch_isdir(buf)) - { - STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); - add_pathsep(ff_expand_buffer); - } -#ifdef FEAT_PATH_EXTRA - else - { - char_u *p = gettail(search_ctx->ffsc_fix_path); - char_u *wc_path = NULL; - char_u *temp = NULL; - int len = 0; - - if (p > search_ctx->ffsc_fix_path) - { - len = (int)(p - search_ctx->ffsc_fix_path) - 1; - STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len); - add_pathsep(ff_expand_buffer); - } - else - len = (int)STRLEN(search_ctx->ffsc_fix_path); - - if (search_ctx->ffsc_wc_path != NULL) - { - wc_path = vim_strsave(search_ctx->ffsc_wc_path); - temp = alloc((int)(STRLEN(search_ctx->ffsc_wc_path) - + STRLEN(search_ctx->ffsc_fix_path + len) - + 1)); - if (temp == NULL || wc_path == NULL) - { - vim_free(buf); - vim_free(temp); - vim_free(wc_path); - goto error_return; - } - - STRCPY(temp, search_ctx->ffsc_fix_path + len); - STRCAT(temp, search_ctx->ffsc_wc_path); - vim_free(search_ctx->ffsc_wc_path); - vim_free(wc_path); - search_ctx->ffsc_wc_path = temp; - } - } -#endif - vim_free(buf); - } - - sptr = ff_create_stack_element(ff_expand_buffer, -#ifdef FEAT_PATH_EXTRA - search_ctx->ffsc_wc_path, -#endif - level, 0); - - if (sptr == NULL) - goto error_return; - - ff_push(search_ctx, sptr); - - search_ctx->ffsc_file_to_search = vim_strsave(filename); - if (search_ctx->ffsc_file_to_search == NULL) - goto error_return; - - return search_ctx; - -error_return: - /* - * We clear the search context now! - * Even when the caller gave us a (perhaps valid) context we free it here, - * as we might have already destroyed it. - */ - vim_findfile_cleanup(search_ctx); - return NULL; -} - -#if defined(FEAT_PATH_EXTRA) || defined(PROTO) -/* - * Get the stopdir string. Check that ';' is not escaped. - */ - char_u * -vim_findfile_stopdir(char_u *buf) -{ - char_u *r_ptr = buf; - - while (*r_ptr != NUL && *r_ptr != ';') - { - if (r_ptr[0] == '\\' && r_ptr[1] == ';') - { - /* Overwrite the escape char, - * use STRLEN(r_ptr) to move the trailing '\0'. */ - STRMOVE(r_ptr, r_ptr + 1); - r_ptr++; - } - r_ptr++; - } - if (*r_ptr == ';') - { - *r_ptr = 0; - r_ptr++; - } - else if (*r_ptr == NUL) - r_ptr = NULL; - return r_ptr; -} -#endif - -/* - * Clean up the given search context. Can handle a NULL pointer. - */ - void -vim_findfile_cleanup(void *ctx) -{ - if (ctx == NULL) - return; - - vim_findfile_free_visited(ctx); - ff_clear(ctx); - vim_free(ctx); -} - -/* - * Find a file in a search context. - * The search context was created with vim_findfile_init() above. - * Return a pointer to an allocated file name or NULL if nothing found. - * To get all matching files call this function until you get NULL. - * - * If the passed search_context is NULL, NULL is returned. - * - * The search algorithm is depth first. To change this replace the - * stack with a list (don't forget to leave partly searched directories on the - * top of the list). - */ - char_u * -vim_findfile(void *search_ctx_arg) -{ - char_u *file_path; -#ifdef FEAT_PATH_EXTRA - char_u *rest_of_wildcards; - char_u *path_end = NULL; -#endif - ff_stack_T *stackp; -#if defined(FEAT_SEARCHPATH) || defined(FEAT_PATH_EXTRA) - int len; -#endif - int i; - char_u *p; -#ifdef FEAT_SEARCHPATH - char_u *suf; -#endif - ff_search_ctx_T *search_ctx; - - if (search_ctx_arg == NULL) - return NULL; - - search_ctx = (ff_search_ctx_T *)search_ctx_arg; - - /* - * filepath is used as buffer for various actions and as the storage to - * return a found filename. - */ - if ((file_path = alloc((int)MAXPATHL)) == NULL) - return NULL; - -#ifdef FEAT_PATH_EXTRA - /* store the end of the start dir -- needed for upward search */ - if (search_ctx->ffsc_start_dir != NULL) - path_end = &search_ctx->ffsc_start_dir[ - STRLEN(search_ctx->ffsc_start_dir)]; -#endif - -#ifdef FEAT_PATH_EXTRA - /* upward search loop */ - for (;;) - { -#endif - /* downward search loop */ - for (;;) - { - /* check if user user wants to stop the search*/ - ui_breakcheck(); - if (got_int) - break; - - /* get directory to work on from stack */ - stackp = ff_pop(search_ctx); - if (stackp == NULL) - break; - - /* - * TODO: decide if we leave this test in - * - * GOOD: don't search a directory(-tree) twice. - * BAD: - check linked list for every new directory entered. - * - check for double files also done below - * - * Here we check if we already searched this directory. - * We already searched a directory if: - * 1) The directory is the same. - * 2) We would use the same wildcard string. - * - * Good if you have links on same directory via several ways - * or you have selfreferences in directories (e.g. SuSE Linux 6.3: - * /etc/rc.d/init.d is linked to /etc/rc.d -> endless loop) - * - * This check is only needed for directories we work on for the - * first time (hence stackp->ff_filearray == NULL) - */ - if (stackp->ffs_filearray == NULL - && ff_check_visited(&search_ctx->ffsc_dir_visited_list - ->ffvl_visited_list, - stackp->ffs_fix_path -#ifdef FEAT_PATH_EXTRA - , stackp->ffs_wc_path -#endif - ) == FAIL) - { -#ifdef FF_VERBOSE - if (p_verbose >= 5) - { - verbose_enter_scroll(); - smsg("Already Searched: %s (%s)", - stackp->ffs_fix_path, stackp->ffs_wc_path); - /* don't overwrite this either */ - msg_puts("\n"); - verbose_leave_scroll(); - } -#endif - ff_free_stack_element(stackp); - continue; - } -#ifdef FF_VERBOSE - else if (p_verbose >= 5) - { - verbose_enter_scroll(); - smsg("Searching: %s (%s)", - stackp->ffs_fix_path, stackp->ffs_wc_path); - /* don't overwrite this either */ - msg_puts("\n"); - verbose_leave_scroll(); - } -#endif - - /* check depth */ - if (stackp->ffs_level <= 0) - { - ff_free_stack_element(stackp); - continue; - } - - file_path[0] = NUL; - - /* - * If no filearray till now expand wildcards - * The function expand_wildcards() can handle an array of paths - * and all possible expands are returned in one array. We use this - * to handle the expansion of '**' into an empty string. - */ - if (stackp->ffs_filearray == NULL) - { - char_u *dirptrs[2]; - - /* we use filepath to build the path expand_wildcards() should - * expand. - */ - dirptrs[0] = file_path; - dirptrs[1] = NULL; - - /* if we have a start dir copy it in */ - if (!vim_isAbsName(stackp->ffs_fix_path) - && search_ctx->ffsc_start_dir) - { - if (STRLEN(search_ctx->ffsc_start_dir) + 1 < MAXPATHL) - { - STRCPY(file_path, search_ctx->ffsc_start_dir); - add_pathsep(file_path); - } - else - { - ff_free_stack_element(stackp); - goto fail; - } - } - - /* append the fix part of the search path */ - if (STRLEN(file_path) + STRLEN(stackp->ffs_fix_path) + 1 < MAXPATHL) - { - STRCAT(file_path, stackp->ffs_fix_path); - add_pathsep(file_path); - } - else - { - ff_free_stack_element(stackp); - goto fail; - } - -#ifdef FEAT_PATH_EXTRA - rest_of_wildcards = stackp->ffs_wc_path; - if (*rest_of_wildcards != NUL) - { - len = (int)STRLEN(file_path); - if (STRNCMP(rest_of_wildcards, "**", 2) == 0) - { - /* pointer to the restrict byte - * The restrict byte is not a character! - */ - p = rest_of_wildcards + 2; - - if (*p > 0) - { - (*p)--; - if (len + 1 < MAXPATHL) - file_path[len++] = '*'; - else - { - ff_free_stack_element(stackp); - goto fail; - } - } - - if (*p == 0) - { - /* remove '** from wildcards */ - STRMOVE(rest_of_wildcards, rest_of_wildcards + 3); - } - else - rest_of_wildcards += 3; - - if (stackp->ffs_star_star_empty == 0) - { - /* if not done before, expand '**' to empty */ - stackp->ffs_star_star_empty = 1; - dirptrs[1] = stackp->ffs_fix_path; - } - } - - /* - * Here we copy until the next path separator or the end of - * the path. If we stop at a path separator, there is - * still something else left. This is handled below by - * pushing every directory returned from expand_wildcards() - * on the stack again for further search. - */ - while (*rest_of_wildcards - && !vim_ispathsep(*rest_of_wildcards)) - if (len + 1 < MAXPATHL) - file_path[len++] = *rest_of_wildcards++; - else - { - ff_free_stack_element(stackp); - goto fail; - } - - file_path[len] = NUL; - if (vim_ispathsep(*rest_of_wildcards)) - rest_of_wildcards++; - } -#endif - - /* - * Expand wildcards like "*" and "$VAR". - * If the path is a URL don't try this. - */ - if (path_with_url(dirptrs[0])) - { - stackp->ffs_filearray = (char_u **) - alloc((unsigned)sizeof(char *)); - if (stackp->ffs_filearray != NULL - && (stackp->ffs_filearray[0] - = vim_strsave(dirptrs[0])) != NULL) - stackp->ffs_filearray_size = 1; - else - stackp->ffs_filearray_size = 0; - } - else - /* Add EW_NOTWILD because the expanded path may contain - * wildcard characters that are to be taken literally. - * This is a bit of a hack. */ - expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs, - &stackp->ffs_filearray_size, - &stackp->ffs_filearray, - EW_DIR|EW_ADDSLASH|EW_SILENT|EW_NOTWILD); - - stackp->ffs_filearray_cur = 0; - stackp->ffs_stage = 0; - } -#ifdef FEAT_PATH_EXTRA - else - rest_of_wildcards = &stackp->ffs_wc_path[ - STRLEN(stackp->ffs_wc_path)]; -#endif - - if (stackp->ffs_stage == 0) - { - /* this is the first time we work on this directory */ -#ifdef FEAT_PATH_EXTRA - if (*rest_of_wildcards == NUL) -#endif - { - /* - * We don't have further wildcards to expand, so we have to - * check for the final file now. - */ - for (i = stackp->ffs_filearray_cur; - i < stackp->ffs_filearray_size; ++i) - { - if (!path_with_url(stackp->ffs_filearray[i]) - && !mch_isdir(stackp->ffs_filearray[i])) - continue; /* not a directory */ - - /* prepare the filename to be checked for existence - * below */ - if (STRLEN(stackp->ffs_filearray[i]) + 1 - + STRLEN(search_ctx->ffsc_file_to_search) < MAXPATHL) - { - STRCPY(file_path, stackp->ffs_filearray[i]); - add_pathsep(file_path); - STRCAT(file_path, search_ctx->ffsc_file_to_search); - } - else - { - ff_free_stack_element(stackp); - goto fail; - } - - /* - * Try without extra suffix and then with suffixes - * from 'suffixesadd'. - */ -#ifdef FEAT_SEARCHPATH - len = (int)STRLEN(file_path); - if (search_ctx->ffsc_tagfile) - suf = (char_u *)""; - else - suf = curbuf->b_p_sua; - for (;;) -#endif - { - /* if file exists and we didn't already find it */ - if ((path_with_url(file_path) - || (mch_getperm(file_path) >= 0 - && (search_ctx->ffsc_find_what - == FINDFILE_BOTH - || ((search_ctx->ffsc_find_what - == FINDFILE_DIR) - == mch_isdir(file_path))))) -#ifndef FF_VERBOSE - && (ff_check_visited( - &search_ctx->ffsc_visited_list->ffvl_visited_list, - file_path -#ifdef FEAT_PATH_EXTRA - , (char_u *)"" -#endif - ) == OK) -#endif - ) - { -#ifdef FF_VERBOSE - if (ff_check_visited( - &search_ctx->ffsc_visited_list->ffvl_visited_list, - file_path -#ifdef FEAT_PATH_EXTRA - , (char_u *)"" -#endif - ) == FAIL) - { - if (p_verbose >= 5) - { - verbose_enter_scroll(); - smsg("Already: %s", - file_path); - /* don't overwrite this either */ - msg_puts("\n"); - verbose_leave_scroll(); - } - continue; - } -#endif - - /* push dir to examine rest of subdirs later */ - stackp->ffs_filearray_cur = i + 1; - ff_push(search_ctx, stackp); - - if (!path_with_url(file_path)) - simplify_filename(file_path); - if (mch_dirname(ff_expand_buffer, MAXPATHL) - == OK) - { - p = shorten_fname(file_path, - ff_expand_buffer); - if (p != NULL) - STRMOVE(file_path, p); - } -#ifdef FF_VERBOSE - if (p_verbose >= 5) - { - verbose_enter_scroll(); - smsg("HIT: %s", file_path); - /* don't overwrite this either */ - msg_puts("\n"); - verbose_leave_scroll(); - } -#endif - return file_path; - } - -#ifdef FEAT_SEARCHPATH - /* Not found or found already, try next suffix. */ - if (*suf == NUL) - break; - copy_option_part(&suf, file_path + len, - MAXPATHL - len, ","); -#endif - } - } - } -#ifdef FEAT_PATH_EXTRA - else - { - /* - * still wildcards left, push the directories for further - * search - */ - for (i = stackp->ffs_filearray_cur; - i < stackp->ffs_filearray_size; ++i) - { - if (!mch_isdir(stackp->ffs_filearray[i])) - continue; /* not a directory */ - - ff_push(search_ctx, - ff_create_stack_element( - stackp->ffs_filearray[i], - rest_of_wildcards, - stackp->ffs_level - 1, 0)); - } - } -#endif - stackp->ffs_filearray_cur = 0; - stackp->ffs_stage = 1; - } - -#ifdef FEAT_PATH_EXTRA - /* - * if wildcards contains '**' we have to descent till we reach the - * leaves of the directory tree. - */ - if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) - { - for (i = stackp->ffs_filearray_cur; - i < stackp->ffs_filearray_size; ++i) - { - if (fnamecmp(stackp->ffs_filearray[i], - stackp->ffs_fix_path) == 0) - continue; /* don't repush same directory */ - if (!mch_isdir(stackp->ffs_filearray[i])) - continue; /* not a directory */ - ff_push(search_ctx, - ff_create_stack_element(stackp->ffs_filearray[i], - stackp->ffs_wc_path, stackp->ffs_level - 1, 1)); - } - } -#endif - - /* we are done with the current directory */ - ff_free_stack_element(stackp); - - } - -#ifdef FEAT_PATH_EXTRA - /* If we reached this, we didn't find anything downwards. - * Let's check if we should do an upward search. - */ - if (search_ctx->ffsc_start_dir - && search_ctx->ffsc_stopdirs_v != NULL && !got_int) - { - ff_stack_T *sptr; - - /* is the last starting directory in the stop list? */ - if (ff_path_in_stoplist(search_ctx->ffsc_start_dir, - (int)(path_end - search_ctx->ffsc_start_dir), - search_ctx->ffsc_stopdirs_v) == TRUE) - break; - - /* cut of last dir */ - while (path_end > search_ctx->ffsc_start_dir - && vim_ispathsep(*path_end)) - path_end--; - while (path_end > search_ctx->ffsc_start_dir - && !vim_ispathsep(path_end[-1])) - path_end--; - *path_end = 0; - path_end--; - - if (*search_ctx->ffsc_start_dir == 0) - break; - - if (STRLEN(search_ctx->ffsc_start_dir) + 1 - + STRLEN(search_ctx->ffsc_fix_path) < MAXPATHL) - { - STRCPY(file_path, search_ctx->ffsc_start_dir); - add_pathsep(file_path); - STRCAT(file_path, search_ctx->ffsc_fix_path); - } - else - goto fail; - - /* create a new stack entry */ - sptr = ff_create_stack_element(file_path, - search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0); - if (sptr == NULL) - break; - ff_push(search_ctx, sptr); - } - else - break; - } -#endif - -fail: - vim_free(file_path); - return NULL; -} - -/* - * Free the list of lists of visited files and directories - * Can handle it if the passed search_context is NULL; - */ - void -vim_findfile_free_visited(void *search_ctx_arg) -{ - ff_search_ctx_T *search_ctx; - - if (search_ctx_arg == NULL) - return; - - search_ctx = (ff_search_ctx_T *)search_ctx_arg; - vim_findfile_free_visited_list(&search_ctx->ffsc_visited_lists_list); - vim_findfile_free_visited_list(&search_ctx->ffsc_dir_visited_lists_list); -} - - static void -vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp) -{ - ff_visited_list_hdr_T *vp; - - while (*list_headp != NULL) - { - vp = (*list_headp)->ffvl_next; - ff_free_visited_list((*list_headp)->ffvl_visited_list); - - vim_free((*list_headp)->ffvl_filename); - vim_free(*list_headp); - *list_headp = vp; - } - *list_headp = NULL; -} - - static void -ff_free_visited_list(ff_visited_T *vl) -{ - ff_visited_T *vp; - - while (vl != NULL) - { - vp = vl->ffv_next; -#ifdef FEAT_PATH_EXTRA - vim_free(vl->ffv_wc_path); -#endif - vim_free(vl); - vl = vp; - } - vl = NULL; -} - -/* - * Returns the already visited list for the given filename. If none is found it - * allocates a new one. - */ - static ff_visited_list_hdr_T* -ff_get_visited_list( - char_u *filename, - ff_visited_list_hdr_T **list_headp) -{ - ff_visited_list_hdr_T *retptr = NULL; - - /* check if a visited list for the given filename exists */ - if (*list_headp != NULL) - { - retptr = *list_headp; - while (retptr != NULL) - { - if (fnamecmp(filename, retptr->ffvl_filename) == 0) - { -#ifdef FF_VERBOSE - if (p_verbose >= 5) - { - verbose_enter_scroll(); - smsg("ff_get_visited_list: FOUND list for %s", - filename); - /* don't overwrite this either */ - msg_puts("\n"); - verbose_leave_scroll(); - } -#endif - return retptr; - } - retptr = retptr->ffvl_next; - } - } - -#ifdef FF_VERBOSE - if (p_verbose >= 5) - { - verbose_enter_scroll(); - smsg("ff_get_visited_list: new list for %s", filename); - /* don't overwrite this either */ - msg_puts("\n"); - verbose_leave_scroll(); - } -#endif - - /* - * if we reach this we didn't find a list and we have to allocate new list - */ - retptr = (ff_visited_list_hdr_T*)alloc((unsigned)sizeof(*retptr)); - if (retptr == NULL) - return NULL; - - retptr->ffvl_visited_list = NULL; - retptr->ffvl_filename = vim_strsave(filename); - if (retptr->ffvl_filename == NULL) - { - vim_free(retptr); - return NULL; - } - retptr->ffvl_next = *list_headp; - *list_headp = retptr; - - return retptr; -} - -#ifdef FEAT_PATH_EXTRA -/* - * check if two wildcard paths are equal. Returns TRUE or FALSE. - * They are equal if: - * - both paths are NULL - * - they have the same length - * - char by char comparison is OK - * - the only differences are in the counters behind a '**', so - * '**\20' is equal to '**\24' - */ - static int -ff_wc_equal(char_u *s1, char_u *s2) -{ - int i, j; - int c1 = NUL; - int c2 = NUL; - int prev1 = NUL; - int prev2 = NUL; - - if (s1 == s2) - return TRUE; - - if (s1 == NULL || s2 == NULL) - return FALSE; - - for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) - { - c1 = PTR2CHAR(s1 + i); - c2 = PTR2CHAR(s2 + j); - - if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2) - && (prev1 != '*' || prev2 != '*')) - return FALSE; - prev2 = prev1; - prev1 = c1; - - i += MB_PTR2LEN(s1 + i); - j += MB_PTR2LEN(s2 + j); - } - return s1[i] == s2[j]; -} -#endif - -/* - * maintains the list of already visited files and dirs - * returns FAIL if the given file/dir is already in the list - * returns OK if it is newly added - * - * TODO: What to do on memory allocation problems? - * -> return TRUE - Better the file is found several times instead of - * never. - */ - static int -ff_check_visited( - ff_visited_T **visited_list, - char_u *fname -#ifdef FEAT_PATH_EXTRA - , char_u *wc_path -#endif - ) -{ - ff_visited_T *vp; -#ifdef UNIX - stat_T st; - int url = FALSE; -#endif - - /* For an URL we only compare the name, otherwise we compare the - * device/inode (unix) or the full path name (not Unix). */ - if (path_with_url(fname)) - { - vim_strncpy(ff_expand_buffer, fname, MAXPATHL - 1); -#ifdef UNIX - url = TRUE; -#endif - } - else - { - ff_expand_buffer[0] = NUL; -#ifdef UNIX - if (mch_stat((char *)fname, &st) < 0) -#else - if (vim_FullName(fname, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) -#endif - return FAIL; - } - - /* check against list of already visited files */ - for (vp = *visited_list; vp != NULL; vp = vp->ffv_next) - { - if ( -#ifdef UNIX - !url ? (vp->ffv_dev_valid && vp->ffv_dev == st.st_dev - && vp->ffv_ino == st.st_ino) - : -#endif - fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0 - ) - { -#ifdef FEAT_PATH_EXTRA - /* are the wildcard parts equal */ - if (ff_wc_equal(vp->ffv_wc_path, wc_path) == TRUE) -#endif - /* already visited */ - return FAIL; - } - } - - /* - * New file/dir. Add it to the list of visited files/dirs. - */ - vp = (ff_visited_T *)alloc((unsigned)(sizeof(ff_visited_T) - + STRLEN(ff_expand_buffer))); - - if (vp != NULL) - { -#ifdef UNIX - if (!url) - { - vp->ffv_dev_valid = TRUE; - vp->ffv_ino = st.st_ino; - vp->ffv_dev = st.st_dev; - vp->ffv_fname[0] = NUL; - } - else - { - vp->ffv_dev_valid = FALSE; -#endif - STRCPY(vp->ffv_fname, ff_expand_buffer); -#ifdef UNIX - } -#endif -#ifdef FEAT_PATH_EXTRA - if (wc_path != NULL) - vp->ffv_wc_path = vim_strsave(wc_path); - else - vp->ffv_wc_path = NULL; -#endif - - vp->ffv_next = *visited_list; - *visited_list = vp; - } - - return OK; -} - -/* - * create stack element from given path pieces - */ - static ff_stack_T * -ff_create_stack_element( - char_u *fix_part, -#ifdef FEAT_PATH_EXTRA - char_u *wc_part, -#endif - int level, - int star_star_empty) -{ - ff_stack_T *new; - - new = (ff_stack_T *)alloc((unsigned)sizeof(ff_stack_T)); - if (new == NULL) - return NULL; - - new->ffs_prev = NULL; - new->ffs_filearray = NULL; - new->ffs_filearray_size = 0; - new->ffs_filearray_cur = 0; - new->ffs_stage = 0; - new->ffs_level = level; - new->ffs_star_star_empty = star_star_empty; - - /* the following saves NULL pointer checks in vim_findfile */ - if (fix_part == NULL) - fix_part = (char_u *)""; - new->ffs_fix_path = vim_strsave(fix_part); - -#ifdef FEAT_PATH_EXTRA - if (wc_part == NULL) - wc_part = (char_u *)""; - new->ffs_wc_path = vim_strsave(wc_part); -#endif - - if (new->ffs_fix_path == NULL -#ifdef FEAT_PATH_EXTRA - || new->ffs_wc_path == NULL -#endif - ) - { - ff_free_stack_element(new); - new = NULL; - } - - return new; -} - -/* - * Push a dir on the directory stack. - */ - static void -ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr) -{ - /* check for NULL pointer, not to return an error to the user, but - * to prevent a crash */ - if (stack_ptr != NULL) - { - stack_ptr->ffs_prev = search_ctx->ffsc_stack_ptr; - search_ctx->ffsc_stack_ptr = stack_ptr; - } -} - -/* - * Pop a dir from the directory stack. - * Returns NULL if stack is empty. - */ - static ff_stack_T * -ff_pop(ff_search_ctx_T *search_ctx) -{ - ff_stack_T *sptr; - - sptr = search_ctx->ffsc_stack_ptr; - if (search_ctx->ffsc_stack_ptr != NULL) - search_ctx->ffsc_stack_ptr = search_ctx->ffsc_stack_ptr->ffs_prev; - - return sptr; -} - -/* - * free the given stack element - */ - static void -ff_free_stack_element(ff_stack_T *stack_ptr) -{ - /* vim_free handles possible NULL pointers */ - vim_free(stack_ptr->ffs_fix_path); -#ifdef FEAT_PATH_EXTRA - vim_free(stack_ptr->ffs_wc_path); -#endif - - if (stack_ptr->ffs_filearray != NULL) - FreeWild(stack_ptr->ffs_filearray_size, stack_ptr->ffs_filearray); - - vim_free(stack_ptr); -} - -/* - * Clear the search context, but NOT the visited list. - */ - static void -ff_clear(ff_search_ctx_T *search_ctx) -{ - ff_stack_T *sptr; - - /* clear up stack */ - while ((sptr = ff_pop(search_ctx)) != NULL) - ff_free_stack_element(sptr); - - vim_free(search_ctx->ffsc_file_to_search); - vim_free(search_ctx->ffsc_start_dir); - vim_free(search_ctx->ffsc_fix_path); -#ifdef FEAT_PATH_EXTRA - vim_free(search_ctx->ffsc_wc_path); -#endif - -#ifdef FEAT_PATH_EXTRA - if (search_ctx->ffsc_stopdirs_v != NULL) - { - int i = 0; - - while (search_ctx->ffsc_stopdirs_v[i] != NULL) - { - vim_free(search_ctx->ffsc_stopdirs_v[i]); - i++; - } - vim_free(search_ctx->ffsc_stopdirs_v); - } - search_ctx->ffsc_stopdirs_v = NULL; -#endif - - /* reset everything */ - search_ctx->ffsc_file_to_search = NULL; - search_ctx->ffsc_start_dir = NULL; - search_ctx->ffsc_fix_path = NULL; -#ifdef FEAT_PATH_EXTRA - search_ctx->ffsc_wc_path = NULL; - search_ctx->ffsc_level = 0; -#endif -} - -#ifdef FEAT_PATH_EXTRA -/* - * check if the given path is in the stopdirs - * returns TRUE if yes else FALSE - */ - static int -ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v) -{ - int i = 0; - - /* eat up trailing path separators, except the first */ - while (path_len > 1 && vim_ispathsep(path[path_len - 1])) - path_len--; - - /* if no path consider it as match */ - if (path_len == 0) - return TRUE; - - for (i = 0; stopdirs_v[i] != NULL; i++) - { - if ((int)STRLEN(stopdirs_v[i]) > path_len) - { - /* match for parent directory. So '/home' also matches - * '/home/rks'. Check for PATHSEP in stopdirs_v[i], else - * '/home/r' would also match '/home/rks' - */ - if (fnamencmp(stopdirs_v[i], path, path_len) == 0 - && vim_ispathsep(stopdirs_v[i][path_len])) - return TRUE; - } - else - { - if (fnamecmp(stopdirs_v[i], path) == 0) - return TRUE; - } - } - return FALSE; -} -#endif - -#if defined(FEAT_SEARCHPATH) || defined(PROTO) -/* - * Find the file name "ptr[len]" in the path. Also finds directory names. - * - * On the first call set the parameter 'first' to TRUE to initialize - * the search. For repeating calls to FALSE. - * - * Repeating calls will return other files called 'ptr[len]' from the path. - * - * Only on the first call 'ptr' and 'len' are used. For repeating calls they - * don't need valid values. - * - * If nothing found on the first call the option FNAME_MESS will issue the - * message: - * 'Can't find file "" in path' - * On repeating calls: - * 'No more file "" found in path' - * - * options: - * FNAME_MESS give error message when not found - * - * Uses NameBuff[]! - * - * Returns an allocated string for the file name. NULL for error. - * - */ - char_u * -find_file_in_path( - char_u *ptr, /* file name */ - int len, /* length of file name */ - int options, - int first, /* use count'th matching file name */ - char_u *rel_fname) /* file name searching relative to */ -{ - return find_file_in_path_option(ptr, len, options, first, - *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path, - FINDFILE_BOTH, rel_fname, curbuf->b_p_sua); -} - -static char_u *ff_file_to_find = NULL; -static void *fdip_search_ctx = NULL; - -#if defined(EXITFREE) - static void -free_findfile(void) -{ - vim_free(ff_file_to_find); - vim_findfile_cleanup(fdip_search_ctx); -} -#endif - -/* - * Find the directory name "ptr[len]" in the path. - * - * options: - * FNAME_MESS give error message when not found - * FNAME_UNESC unescape backslashes. - * - * Uses NameBuff[]! - * - * Returns an allocated string for the file name. NULL for error. - */ - char_u * -find_directory_in_path( - char_u *ptr, /* file name */ - int len, /* length of file name */ - int options, - char_u *rel_fname) /* file name searching relative to */ -{ - return find_file_in_path_option(ptr, len, options, TRUE, p_cdpath, - FINDFILE_DIR, rel_fname, (char_u *)""); -} - - char_u * -find_file_in_path_option( - char_u *ptr, /* file name */ - int len, /* length of file name */ - int options, - int first, /* use count'th matching file name */ - char_u *path_option, /* p_path or p_cdpath */ - int find_what, /* FINDFILE_FILE, _DIR or _BOTH */ - char_u *rel_fname, /* file name we are looking relative to. */ - char_u *suffixes) /* list of suffixes, 'suffixesadd' option */ -{ - static char_u *dir; - static int did_findfile_init = FALSE; - char_u save_char; - char_u *file_name = NULL; - char_u *buf = NULL; - int rel_to_curdir; -#ifdef AMIGA - struct Process *proc = (struct Process *)FindTask(0L); - APTR save_winptr = proc->pr_WindowPtr; - - /* Avoid a requester here for a volume that doesn't exist. */ - proc->pr_WindowPtr = (APTR)-1L; -#endif - - if (first == TRUE) - { - /* copy file name into NameBuff, expanding environment variables */ - save_char = ptr[len]; - ptr[len] = NUL; - expand_env_esc(ptr, NameBuff, MAXPATHL, FALSE, TRUE, NULL); - ptr[len] = save_char; - - vim_free(ff_file_to_find); - ff_file_to_find = vim_strsave(NameBuff); - if (ff_file_to_find == NULL) /* out of memory */ - { - file_name = NULL; - goto theend; - } - if (options & FNAME_UNESC) - { - /* Change all "\ " to " ". */ - for (ptr = ff_file_to_find; *ptr != NUL; ++ptr) - if (ptr[0] == '\\' && ptr[1] == ' ') - mch_memmove(ptr, ptr + 1, STRLEN(ptr)); - } - } - - rel_to_curdir = (ff_file_to_find[0] == '.' - && (ff_file_to_find[1] == NUL - || vim_ispathsep(ff_file_to_find[1]) - || (ff_file_to_find[1] == '.' - && (ff_file_to_find[2] == NUL - || vim_ispathsep(ff_file_to_find[2]))))); - if (vim_isAbsName(ff_file_to_find) - /* "..", "../path", "." and "./path": don't use the path_option */ - || rel_to_curdir -#if defined(MSWIN) - /* handle "\tmp" as absolute path */ - || vim_ispathsep(ff_file_to_find[0]) - /* handle "c:name" as absolute path */ - || (ff_file_to_find[0] != NUL && ff_file_to_find[1] == ':') -#endif -#ifdef AMIGA - /* handle ":tmp" as absolute path */ - || ff_file_to_find[0] == ':' -#endif - ) - { - /* - * Absolute path, no need to use "path_option". - * If this is not a first call, return NULL. We already returned a - * filename on the first call. - */ - if (first == TRUE) - { - int l; - int run; - - if (path_with_url(ff_file_to_find)) - { - file_name = vim_strsave(ff_file_to_find); - goto theend; - } - - /* When FNAME_REL flag given first use the directory of the file. - * Otherwise or when this fails use the current directory. */ - for (run = 1; run <= 2; ++run) - { - l = (int)STRLEN(ff_file_to_find); - if (run == 1 - && rel_to_curdir - && (options & FNAME_REL) - && rel_fname != NULL - && STRLEN(rel_fname) + l < MAXPATHL) - { - STRCPY(NameBuff, rel_fname); - STRCPY(gettail(NameBuff), ff_file_to_find); - l = (int)STRLEN(NameBuff); - } - else - { - STRCPY(NameBuff, ff_file_to_find); - run = 2; - } - - /* When the file doesn't exist, try adding parts of - * 'suffixesadd'. */ - buf = suffixes; - for (;;) - { - if (mch_getperm(NameBuff) >= 0 - && (find_what == FINDFILE_BOTH - || ((find_what == FINDFILE_DIR) - == mch_isdir(NameBuff)))) - { - file_name = vim_strsave(NameBuff); - goto theend; - } - if (*buf == NUL) - break; - copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); - } - } - } - } - else - { - /* - * Loop over all paths in the 'path' or 'cdpath' option. - * When "first" is set, first setup to the start of the option. - * Otherwise continue to find the next match. - */ - if (first == TRUE) - { - /* vim_findfile_free_visited can handle a possible NULL pointer */ - vim_findfile_free_visited(fdip_search_ctx); - dir = path_option; - did_findfile_init = FALSE; - } - - for (;;) - { - if (did_findfile_init) - { - file_name = vim_findfile(fdip_search_ctx); - if (file_name != NULL) - break; - - did_findfile_init = FALSE; - } - else - { - char_u *r_ptr; - - if (dir == NULL || *dir == NUL) - { - /* We searched all paths of the option, now we can - * free the search context. */ - vim_findfile_cleanup(fdip_search_ctx); - fdip_search_ctx = NULL; - break; - } - - if ((buf = alloc((int)(MAXPATHL))) == NULL) - break; - - /* copy next path */ - buf[0] = 0; - copy_option_part(&dir, buf, MAXPATHL, " ,"); - -#ifdef FEAT_PATH_EXTRA - /* get the stopdir string */ - r_ptr = vim_findfile_stopdir(buf); -#else - r_ptr = NULL; -#endif - fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find, - r_ptr, 100, FALSE, find_what, - fdip_search_ctx, FALSE, rel_fname); - if (fdip_search_ctx != NULL) - did_findfile_init = TRUE; - vim_free(buf); - } - } - } - if (file_name == NULL && (options & FNAME_MESS)) - { - if (first == TRUE) - { - if (find_what == FINDFILE_DIR) - semsg(_("E344: Can't find directory \"%s\" in cdpath"), - ff_file_to_find); - else - semsg(_("E345: Can't find file \"%s\" in path"), - ff_file_to_find); - } - else - { - if (find_what == FINDFILE_DIR) - semsg(_("E346: No more directory \"%s\" found in cdpath"), - ff_file_to_find); - else - semsg(_("E347: No more file \"%s\" found in path"), - ff_file_to_find); - } - } - -theend: -#ifdef AMIGA - proc->pr_WindowPtr = save_winptr; -#endif - return file_name; -} - -#endif /* FEAT_SEARCHPATH */ - /* * Change directory to "new_dir". If FEAT_SEARCHPATH is defined, search * 'cdpath' for relative directory names, otherwise just mch_chdir(). diff --git a/src/proto.h b/src/proto.h index d7e63168e4..1ab5cf78c3 100644 --- a/src/proto.h +++ b/src/proto.h @@ -80,6 +80,7 @@ extern int _stricoll(char *a, char *b); # include "ex_eval.pro" # include "ex_getln.pro" # include "fileio.pro" +# include "findfile.pro" # include "fold.pro" # include "getchar.pro" # ifdef FEAT_HANGULIN diff --git a/src/proto/findfile.pro b/src/proto/findfile.pro new file mode 100644 index 0000000000..5b80b83c69 --- /dev/null +++ b/src/proto/findfile.pro @@ -0,0 +1,18 @@ +/* findfile.c */ +void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int level, int free_visited, int find_what, void *search_ctx_arg, int tagfile, char_u *rel_fname); +char_u *vim_findfile_stopdir(char_u *buf); +void vim_findfile_cleanup(void *ctx); +char_u *vim_findfile(void *search_ctx_arg); +void vim_findfile_free_visited(void *search_ctx_arg); +char_u *find_file_in_path(char_u *ptr, int len, int options, int first, char_u *rel_fname); +void free_findfile(void); +char_u *find_directory_in_path(char_u *ptr, int len, int options, char_u *rel_fname); +char_u *find_file_in_path_option(char_u *ptr, int len, int options, int first, char_u *path_option, int find_what, char_u *rel_fname, char_u *suffixes); +char_u *grab_file_name(long count, linenr_T *file_lnum); +char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum); +char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u *rel_fname, linenr_T *file_lnum); +char_u *find_file_name_in_path(char_u *ptr, int len, int options, long count, char_u *rel_fname); +int vim_ispathlistsep(int c); +void uniquefy_paths(garray_T *gap, char_u *pattern); +int expand_in_path(garray_T *gap, char_u *pattern, int flags); +/* vim: set ft=c : */ diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro index 1e50f8acd7..6a2a5f1142 100644 --- a/src/proto/misc1.pro +++ b/src/proto/misc1.pro @@ -74,7 +74,6 @@ char_u *getnextcomp(char_u *fname); char_u *get_past_head(char_u *path); int vim_ispathsep(int c); int vim_ispathsep_nocolon(int c); -int vim_ispathlistsep(int c); void shorten_dir(char_u *str); int dir_of_file_exists(char_u *fname); int vim_fnamecmp(char_u *x, char_u *y); @@ -99,4 +98,8 @@ char_u *get_cmd_output(char_u *cmd, char_u *infile, int flags, int *ret_len); void FreeWild(int count, char_u **files); int goto_im(void); char_u *get_isolated_shell_name(void); +int path_is_url(char_u *p); +int path_with_url(char_u *fname); +int vim_isAbsName(char_u *name); +int vim_FullName(char_u *fname, char_u *buf, int len, int force); /* vim: set ft=c : */ diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro index 7d33de8b65..3c88efb3a0 100644 --- a/src/proto/misc2.pro +++ b/src/proto/misc2.pro @@ -90,14 +90,6 @@ int vim_stat(const char *name, stat_T *stp); char *parse_shape_opt(int what); int get_shape_idx(int mouse); void update_mouseshape(int shape_idx); -void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int level, int free_visited, int find_what, void *search_ctx_arg, int tagfile, char_u *rel_fname); -char_u *vim_findfile_stopdir(char_u *buf); -void vim_findfile_cleanup(void *ctx); -char_u *vim_findfile(void *search_ctx_arg); -void vim_findfile_free_visited(void *search_ctx_arg); -char_u *find_file_in_path(char_u *ptr, int len, int options, int first, char_u *rel_fname); -char_u *find_directory_in_path(char_u *ptr, int len, int options, char_u *rel_fname); -char_u *find_file_in_path_option(char_u *ptr, int len, int options, int first, char_u *path_option, int find_what, char_u *rel_fname, char_u *suffixes); int vim_chdir(char_u *new_dir); int get_user_name(char_u *buf, int len); void sort_strings(char_u **files, int count); diff --git a/src/proto/window.pro b/src/proto/window.pro index 27f77c4758..0efff64eb3 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -65,13 +65,6 @@ void win_comp_scroll(win_T *wp); void command_height(void); void last_status(int morewin); int tabline_height(void); -char_u *grab_file_name(long count, linenr_T *file_lnum); -char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum); -char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u *rel_fname, linenr_T *file_lnum); -char_u *find_file_name_in_path(char_u *ptr, int len, int options, long count, char_u *rel_fname); -int path_with_url(char_u *fname); -int vim_isAbsName(char_u *name); -int vim_FullName(char_u *fname, char_u *buf, int len, int force); int min_rows(void); int only_one_window(void); void check_lnums(int do_curwin); diff --git a/src/version.c b/src/version.c index f60b9d62be..ed224a454c 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 914, /**/ 913, /**/ diff --git a/src/window.c b/src/window.c index f6e611535a..7dc3848e42 100644 --- a/src/window.c +++ b/src/window.c @@ -9,7 +9,6 @@ #include "vim.h" -static int path_is_url(char_u *p); static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize, long Prenum); static void win_init(win_T *newp, win_T *oldp, int flags); static void win_init_some(win_T *newp, win_T *oldp); @@ -61,9 +60,6 @@ static int frame_check_width(frame_T *topfrp, int width); static win_T *win_alloc(win_T *after, int hidden); -#define URL_SLASH 1 /* path_is_url() has found "://" */ -#define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */ - #define NOWIN (win_T *)-1 /* non-existing window */ #define ROWS_AVAIL (Rows - p_ch - tabline_height()) @@ -6098,317 +6094,6 @@ tabline_height(void) return 1; } -#if defined(FEAT_SEARCHPATH) || defined(PROTO) -/* - * Get the file name at the cursor. - * If Visual mode is active, use the selected text if it's in one line. - * Returns the name in allocated memory, NULL for failure. - */ - char_u * -grab_file_name(long count, linenr_T *file_lnum) -{ - int options = FNAME_MESS|FNAME_EXP|FNAME_REL|FNAME_UNESC; - - if (VIsual_active) - { - int len; - char_u *ptr; - - if (get_visual_text(NULL, &ptr, &len) == FAIL) - return NULL; - return find_file_name_in_path(ptr, len, options, - count, curbuf->b_ffname); - } - return file_name_at_cursor(options | FNAME_HYP, count, file_lnum); -} - -/* - * Return the file name under or after the cursor. - * - * The 'path' option is searched if the file name is not absolute. - * The string returned has been alloc'ed and should be freed by the caller. - * NULL is returned if the file name or file is not found. - * - * options: - * FNAME_MESS give error messages - * FNAME_EXP expand to path - * FNAME_HYP check for hypertext link - * FNAME_INCL apply "includeexpr" - */ - char_u * -file_name_at_cursor(int options, long count, linenr_T *file_lnum) -{ - return file_name_in_line(ml_get_curline(), - curwin->w_cursor.col, options, count, curbuf->b_ffname, - file_lnum); -} - -/* - * Return the name of the file under or after ptr[col]. - * Otherwise like file_name_at_cursor(). - */ - char_u * -file_name_in_line( - char_u *line, - int col, - int options, - long count, - char_u *rel_fname, /* file we are searching relative to */ - linenr_T *file_lnum) /* line number after the file name */ -{ - char_u *ptr; - int len; - int in_type = TRUE; - int is_url = FALSE; - - /* - * search forward for what could be the start of a file name - */ - ptr = line + col; - while (*ptr != NUL && !vim_isfilec(*ptr)) - MB_PTR_ADV(ptr); - if (*ptr == NUL) /* nothing found */ - { - if (options & FNAME_MESS) - emsg(_("E446: No file name under cursor")); - return NULL; - } - - /* - * Search backward for first char of the file name. - * Go one char back to ":" before "//" even when ':' is not in 'isfname'. - */ - while (ptr > line) - { - if (has_mbyte && (len = (*mb_head_off)(line, ptr - 1)) > 0) - ptr -= len + 1; - else if (vim_isfilec(ptr[-1]) - || ((options & FNAME_HYP) && path_is_url(ptr - 1))) - --ptr; - else - break; - } - - /* - * Search forward for the last char of the file name. - * Also allow "://" when ':' is not in 'isfname'. - */ - len = 0; - while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') - || ((options & FNAME_HYP) && path_is_url(ptr + len)) - || (is_url && vim_strchr((char_u *)"?&=", ptr[len]) != NULL)) - { - /* After type:// we also include ?, & and = as valid characters, so that - * http://google.com?q=this&that=ok works. */ - if ((ptr[len] >= 'A' && ptr[len] <= 'Z') || (ptr[len] >= 'a' && ptr[len] <= 'z')) - { - if (in_type && path_is_url(ptr + len + 1)) - is_url = TRUE; - } - else - in_type = FALSE; - - if (ptr[len] == '\\') - /* Skip over the "\" in "\ ". */ - ++len; - if (has_mbyte) - len += (*mb_ptr2len)(ptr + len); - else - ++len; - } - - /* - * If there is trailing punctuation, remove it. - * But don't remove "..", could be a directory name. - */ - if (len > 2 && vim_strchr((char_u *)".,:;!", ptr[len - 1]) != NULL - && ptr[len - 2] != '.') - --len; - - if (file_lnum != NULL) - { - char_u *p; - - /* Get the number after the file name and a separator character */ - p = ptr + len; - p = skipwhite(p); - if (*p != NUL) - { - if (!isdigit(*p)) - ++p; /* skip the separator */ - p = skipwhite(p); - if (isdigit(*p)) - *file_lnum = (int)getdigits(&p); - } - } - - return find_file_name_in_path(ptr, len, options, count, rel_fname); -} - -# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) - static char_u * -eval_includeexpr(char_u *ptr, int len) -{ - char_u *res; - - set_vim_var_string(VV_FNAME, ptr, len); - res = eval_to_string_safe(curbuf->b_p_inex, NULL, - was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL)); - set_vim_var_string(VV_FNAME, NULL, 0); - return res; -} -#endif - -/* - * Return the name of the file ptr[len] in 'path'. - * Otherwise like file_name_at_cursor(). - */ - char_u * -find_file_name_in_path( - char_u *ptr, - int len, - int options, - long count, - char_u *rel_fname) /* file we are searching relative to */ -{ - char_u *file_name; - int c; -# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) - char_u *tofree = NULL; - - if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) - { - tofree = eval_includeexpr(ptr, len); - if (tofree != NULL) - { - ptr = tofree; - len = (int)STRLEN(ptr); - } - } -# endif - - if (options & FNAME_EXP) - { - file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS, - TRUE, rel_fname); - -# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) - /* - * If the file could not be found in a normal way, try applying - * 'includeexpr' (unless done already). - */ - if (file_name == NULL - && !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) - { - tofree = eval_includeexpr(ptr, len); - if (tofree != NULL) - { - ptr = tofree; - len = (int)STRLEN(ptr); - file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS, - TRUE, rel_fname); - } - } -# endif - if (file_name == NULL && (options & FNAME_MESS)) - { - c = ptr[len]; - ptr[len] = NUL; - semsg(_("E447: Can't find file \"%s\" in path"), ptr); - ptr[len] = c; - } - - /* Repeat finding the file "count" times. This matters when it - * appears several times in the path. */ - while (file_name != NULL && --count > 0) - { - vim_free(file_name); - file_name = find_file_in_path(ptr, len, options, FALSE, rel_fname); - } - } - else - file_name = vim_strnsave(ptr, len); - -# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) - vim_free(tofree); -# endif - - return file_name; -} -#endif /* FEAT_SEARCHPATH */ - -/* - * Check if the "://" of a URL is at the pointer, return URL_SLASH. - * Also check for ":\\", which MS Internet Explorer accepts, return - * URL_BACKSLASH. - */ - static int -path_is_url(char_u *p) -{ - if (STRNCMP(p, "://", (size_t)3) == 0) - return URL_SLASH; - else if (STRNCMP(p, ":\\\\", (size_t)3) == 0) - return URL_BACKSLASH; - return 0; -} - -/* - * Check if "fname" starts with "name://". Return URL_SLASH if it does. - * Return URL_BACKSLASH for "name:\\". - * Return zero otherwise. - */ - int -path_with_url(char_u *fname) -{ - char_u *p; - - for (p = fname; isalpha(*p); ++p) - ; - return path_is_url(p); -} - -/* - * Return TRUE if "name" is a full (absolute) path name or URL. - */ - int -vim_isAbsName(char_u *name) -{ - return (path_with_url(name) != 0 || mch_isFullName(name)); -} - -/* - * Get absolute file name into buffer "buf[len]". - * - * return FAIL for failure, OK otherwise - */ - int -vim_FullName( - char_u *fname, - char_u *buf, - int len, - int force) /* force expansion even when already absolute */ -{ - int retval = OK; - int url; - - *buf = NUL; - if (fname == NULL) - return FAIL; - - url = path_with_url(fname); - if (!url) - retval = mch_FullName(fname, buf, len, force); - if (url || retval == FAIL) - { - /* something failed; use the file name (truncate when too long) */ - vim_strncpy(buf, fname, len - 1); - } -#if defined(MSWIN) - slash_adjust(buf); -#endif - return retval; -} - /* * Return the minimal number of rows that is needed on the screen to display * the current number of windows. From a787019518a540a7b4d0070f15467931b870ac89 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 12:56:36 +0100 Subject: [PATCH 43/75] patch 8.1.0915: fsync() may not work properly on Mac Problem: fsync() may not work properly on Mac. Solution: Use fcntl() with F_FULLFSYNC. (suggested by Justin M. Keyes) --- src/evalfunc.c | 4 ++-- src/fileio.c | 21 ++++++++++++++++++++- src/memfile.c | 6 +++--- src/proto/fileio.pro | 1 + src/version.c | 2 ++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/evalfunc.c b/src/evalfunc.c index 6538b36d3c..e693ef9137 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -14791,7 +14791,7 @@ f_writefile(typval_T *argvars, typval_T *rettv) else if (do_fsync) // Ignore the error, the user wouldn't know what to do about it. // May happen for a device. - vim_ignored = fsync(fileno(fd)); + vim_ignored = vim_fsync(fileno(fd)); #endif fclose(fd); } @@ -14803,7 +14803,7 @@ f_writefile(typval_T *argvars, typval_T *rettv) else if (do_fsync) /* Ignore the error, the user wouldn't know what to do about it. * May happen for a device. */ - vim_ignored = fsync(fileno(fd)); + vim_ignored = vim_fsync(fileno(fd)); #endif fclose(fd); } diff --git a/src/fileio.c b/src/fileio.c index c7f3ad1768..f9e18d413a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4661,7 +4661,7 @@ restore_backup: * work (could be a pipe). * If the 'fsync' option is FALSE, don't fsync(). Useful for laptops. */ - if (p_fs && fsync(fd) != 0 && !device) + if (p_fs && vim_fsync(fd) != 0 && !device) { errmsg = (char_u *)_(e_fsync); end = 0; @@ -5123,6 +5123,25 @@ nofail: return retval; } +#if defined(HAVE_FSYNC) || defined(PROTO) +/* + * Call fsync() with Mac-specific exception. + * Return fsync() result: zero for success. + */ + int +vim_fsync(int fd) +{ + int r; + +# ifdef MACOS_X + r = fcntl(fd, F_FULLFSYNC); + if (r != 0 && errno == ENOTTY) +# endif + r = fsync(fd); + return r; +} +#endif + /* * Set the name of the current buffer. Use when the buffer doesn't have a * name and a ":r" or ":w" command with a file name is used. diff --git a/src/memfile.c b/src/memfile.c index f2e774a4ed..1a527340ad 100644 --- a/src/memfile.c +++ b/src/memfile.c @@ -600,7 +600,7 @@ mf_sync(memfile_T *mfp, int flags) */ if (STRCMP(p_sws, "fsync") == 0) { - if (fsync(mfp->mf_fd)) + if (vim_fsync(mfp->mf_fd)) status = FAIL; } else @@ -617,7 +617,7 @@ mf_sync(memfile_T *mfp, int flags) #ifdef VMS if (STRCMP(p_sws, "fsync") == 0) { - if (fsync(mfp->mf_fd)) + if (vim_fsync(mfp->mf_fd)) status = FAIL; } #endif @@ -627,7 +627,7 @@ mf_sync(memfile_T *mfp, int flags) #endif #ifdef AMIGA # if defined(__AROS__) || defined(__amigaos4__) - if (fsync(mfp->mf_fd) != 0) + if (vim_fsync(mfp->mf_fd) != 0) status = FAIL; # else /* diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro index 21ac55c9d1..e99cbc8bfd 100644 --- a/src/proto/fileio.pro +++ b/src/proto/fileio.pro @@ -7,6 +7,7 @@ void set_file_options(int set_options, exarg_T *eap); void set_forced_fenc(exarg_T *eap); int check_file_readonly(char_u *fname, int perm); int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering); +int vim_fsync(int fd); void msg_add_fname(buf_T *buf, char_u *fname); void msg_add_lines(int insert_space, long lnum, off_T nchars); char_u *shorten_fname1(char_u *full_path); diff --git a/src/version.c b/src/version.c index ed224a454c..d0255a1b8e 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 915, /**/ 914, /**/ From b999ba2778b6c02fdd100e498a9ba5b2e7036f7d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 13:28:45 +0100 Subject: [PATCH 44/75] patch 8.1.0916: with Python 3.7 "find_module" is not made available Problem: With Python 3.7 "find_module" is not made available. Solution: Also add "find_module" with Python 3.7. (Joel Frederico, closes #3954) --- src/if_py_both.h | 31 +++++++++++++++++++------------ src/version.c | 2 ++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/if_py_both.h b/src/if_py_both.h index a0c1663784..8d11488d39 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -87,9 +87,9 @@ static PyObject *vim_special_path_object; #if PY_VERSION_HEX >= 0x030700f0 static PyObject *py_find_spec; #else -static PyObject *py_find_module; static PyObject *py_load_module; #endif +static PyObject *py_find_module; static PyObject *VimError; @@ -759,7 +759,7 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict) sprintf(buf, "%ld", (long)our_tv->vval.v_number); ret = PyString_FromString((char *)buf); } -# ifdef FEAT_FLOAT +#ifdef FEAT_FLOAT else if (our_tv->v_type == VAR_FLOAT) { char buf[NUMBUFLEN]; @@ -767,7 +767,7 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict) sprintf(buf, "%f", our_tv->vval.v_float); ret = PyString_FromString((char *)buf); } -# endif +#endif else if (our_tv->v_type == VAR_LIST) { list_T *list = our_tv->vval.v_list; @@ -6093,18 +6093,18 @@ convert_dl(PyObject *obj, typval_T *tv, sprintf(hexBuf, "%p", (void *)obj); -# ifdef PY_USE_CAPSULE +#ifdef PY_USE_CAPSULE capsule = PyDict_GetItemString(lookup_dict, hexBuf); -# else +#else capsule = (PyObject *)PyDict_GetItemString(lookup_dict, hexBuf); -# endif +#endif if (capsule == NULL) { -# ifdef PY_USE_CAPSULE +#ifdef PY_USE_CAPSULE capsule = PyCapsule_New(tv, NULL, NULL); -# else +#else capsule = PyCObject_FromVoidPtr(tv, NULL); -# endif +#endif if (PyDict_SetItemString(lookup_dict, hexBuf, capsule)) { Py_DECREF(capsule); @@ -6130,11 +6130,11 @@ convert_dl(PyObject *obj, typval_T *tv, { typval_T *v; -# ifdef PY_USE_CAPSULE +#ifdef PY_USE_CAPSULE v = PyCapsule_GetPointer(capsule, NULL); -# else +#else v = PyCObject_AsVoidPtr(capsule); -# endif +#endif copy_tv(v, tv); } return 0; @@ -6921,6 +6921,13 @@ populate_module(PyObject *m) return -1; } + if ((py_find_module = PyObject_GetAttrString(cls, "find_module"))) + { + // find_module() is deprecated, this may stop working in some later + // version. + ADD_OBJECT(m, "_find_module", py_find_module); + } + Py_DECREF(imp); ADD_OBJECT(m, "_find_spec", py_find_spec); diff --git a/src/version.c b/src/version.c index d0255a1b8e..7614566d8d 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 916, /**/ 915, /**/ From 445e71c5ee06015064cf0642cac8190cfe8fbc59 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 13:43:36 +0100 Subject: [PATCH 45/75] patch 8.1.0917: double free when running out of memory Problem: Double free when running out of memory. Solution: Remove one free. (Ken Takata, closes #3955) --- src/userfunc.c | 6 ++---- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/userfunc.c b/src/userfunc.c index a293dd68e3..6deb8a9f1f 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -205,6 +205,7 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate) garray_T newlines; garray_T *pnewargs; ufunc_T *fp = NULL; + partial_T *pt = NULL; int varargs; int ret; char_u *start = skipwhite(*arg + 1); @@ -252,7 +253,6 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate) int len, flags = 0; char_u *p; char_u name[20]; - partial_T *pt; sprintf((char*)name, "%d", ++lambda_no); @@ -261,10 +261,7 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate) goto errret; pt = (partial_T *)alloc_clear((unsigned)sizeof(partial_T)); if (pt == NULL) - { - vim_free(fp); goto errret; - } ga_init2(&newlines, (int)sizeof(char_u *), 1); if (ga_grow(&newlines, 1) == FAIL) @@ -318,6 +315,7 @@ errret: ga_clear_strings(&newargs); ga_clear_strings(&newlines); vim_free(fp); + vim_free(pt); eval_lavars_used = old_eval_lavars; return FAIL; } diff --git a/src/version.c b/src/version.c index 7614566d8d..9a31c2f78e 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 917, /**/ 916, /**/ From 9b5c1fcdeae75f82a2083fafbbf75ab220f6ac1e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 14:08:04 +0100 Subject: [PATCH 46/75] patch 8.1.0918: MS-Windows: startup messages are not converted Problem: MS-Windows: startup messages are not converted. Solution: Convert messages when the current codepage differs from 'encoding'. (Yasuhiro Matsumoto, closes #3914) --- src/message.c | 149 ++++++++++++++++++++++++++++++------------------- src/os_mswin.c | 12 ++-- src/version.c | 2 + src/vim.h | 2 +- 4 files changed, 104 insertions(+), 61 deletions(-) diff --git a/src/message.c b/src/message.c index 063fadae4a..4aa15eba69 100644 --- a/src/message.c +++ b/src/message.c @@ -2570,57 +2570,45 @@ msg_use_printf(void) msg_puts_printf(char_u *str, int maxlen) { char_u *s = str; - char_u buf[4]; - char_u *p; + char_u *buf = NULL; + char_u *p = s; + #ifdef WIN3264 -# if !defined(FEAT_GUI_MSWIN) - char_u *ccp = NULL; - -# endif if (!(silent_mode && p_verbose == 0)) - mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */ - -# if !defined(FEAT_GUI_MSWIN) - if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage) - { - int inlen = (int)STRLEN(str); - int outlen; - WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &inlen); - - if (widestr != NULL) - { - WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, inlen, - (LPSTR *)&ccp, &outlen, 0, 0); - vim_free(widestr); - s = str = ccp; - } - } -# endif + mch_settmode(TMODE_COOK); /* handle CR and NL correctly */ #endif while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL) { if (!(silent_mode && p_verbose == 0)) { - /* NL --> CR NL translation (for Unix, not for "--version") */ - p = &buf[0]; - if (*s == '\n' && !info_message) - *p++ = '\r'; -#if defined(USE_CR) - else + // NL --> CR NL translation (for Unix, not for "--version") + if (*s == NL) + { + int n = (int)(s - p); + + buf = alloc(n + 3); + memcpy(buf, p, n); + if (!info_message) + buf[n++] = CAR; +#ifdef USE_CR + else #endif - *p++ = *s; - *p = '\0'; - if (info_message) /* informative message, not an error */ - mch_msg((char *)buf); - else - mch_errmsg((char *)buf); + buf[n++] = NL; + buf[n++] = NUL; + if (info_message) // informative message, not an error + mch_msg((char *)buf); + else + mch_errmsg((char *)buf); + vim_free(buf); + p = s + 1; + } } - /* primitive way to compute the current column */ + // primitive way to compute the current column #ifdef FEAT_RIGHTLEFT if (cmdmsg_rl) { - if (*s == '\r' || *s == '\n') + if (*s == CAR || *s == NL) msg_col = Columns - 1; else --msg_col; @@ -2628,19 +2616,27 @@ msg_puts_printf(char_u *str, int maxlen) else #endif { - if (*s == '\r' || *s == '\n') + if (*s == CAR || *s == NL) msg_col = 0; else ++msg_col; } ++s; } - msg_didout = TRUE; /* assume that line is not empty */ + + if (*p != NUL && !(silent_mode && p_verbose == 0)) + { + if (maxlen > 0 && STRLEN(p) > (size_t)maxlen) + p[maxlen] = 0; + if (info_message) + mch_msg((char *)p); + else + mch_errmsg((char *)p); + } + + msg_didout = TRUE; // assume that line is not empty #ifdef WIN3264 -# if !defined(FEAT_GUI_MSWIN) - vim_free(ccp); -# endif if (!(silent_mode && p_verbose == 0)) mch_settmode(TMODE_RAW); #endif @@ -2941,32 +2937,51 @@ do_more_prompt(int typed_char) void mch_errmsg(char *str) { +#if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) + int len = STRLEN(str); + DWORD nwrite = 0; + DWORD mode = 0; + HANDLE h = GetStdHandle(STD_ERROR_HANDLE); + + if (GetConsoleMode(h, &mode) && enc_codepage >= 0 + && (int)GetConsoleCP() != enc_codepage) + { + WCHAR *w = enc_to_utf16((char_u *)str, &len); + + WriteConsoleW(h, w, len, &nwrite, NULL); + vim_free(w); + } + else + { + fprintf(stderr, "%s", str); + } +#else int len; -#if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) +# if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) /* On Unix use stderr if it's a tty. * When not going to start the GUI also use stderr. * On Mac, when started from Finder, stderr is the console. */ if ( -# ifdef UNIX -# ifdef MACOS_X +# ifdef UNIX +# ifdef MACOS_X (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0) -# else +# else isatty(2) +# endif +# ifdef FEAT_GUI + || +# endif # endif # ifdef FEAT_GUI - || -# endif -# endif -# ifdef FEAT_GUI !(gui.in_use || gui.starting) -# endif +# endif ) { fprintf(stderr, "%s", str); return; } -#endif +# endif /* avoid a delay for a message that isn't there */ emsg_on_display = FALSE; @@ -2981,7 +2996,7 @@ mch_errmsg(char *str) { mch_memmove((char_u *)error_ga.ga_data + error_ga.ga_len, (char_u *)str, len); -#ifdef UNIX +# ifdef UNIX /* remove CR characters, they are displayed */ { char_u *p; @@ -2995,10 +3010,11 @@ mch_errmsg(char *str) *p = ' '; } } -#endif +# endif --len; /* don't count the NUL at the end */ error_ga.ga_len += len; } +#endif } /* @@ -3009,7 +3025,27 @@ mch_errmsg(char *str) void mch_msg(char *str) { -#if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) +#if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) + int len = STRLEN(str); + DWORD nwrite = 0; + DWORD mode; + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + + + if (GetConsoleMode(h, &mode) && enc_codepage >= 0 + && (int)GetConsoleCP() != enc_codepage) + { + WCHAR *w = enc_to_utf16((char_u *)str, &len); + + WriteConsoleW(h, w, len, &nwrite, NULL); + vim_free(w); + } + else + { + printf("%s", str); + } +#else +# if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) /* On Unix use stdout if we have a tty. This allows "vim -h | more" and * uses mch_errmsg() when started from the desktop. * When not going to start the GUI also use stdout. @@ -3035,6 +3071,7 @@ mch_msg(char *str) } # endif mch_errmsg(str); +#endif } #endif /* USE_MCH_ERRMSG */ diff --git a/src/os_mswin.c b/src/os_mswin.c index 8dafaa35b1..9da72b0a4d 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -675,6 +675,7 @@ mch_suspend(void) # undef display_errors #endif +#ifdef FEAT_GUI /* * Display the saved error message(s). */ @@ -690,13 +691,9 @@ display_errors(void) if (!isspace(*p)) { (void)gui_mch_dialog( -#ifdef FEAT_GUI gui.starting ? VIM_INFO : -#endif VIM_ERROR, -#ifdef FEAT_GUI gui.starting ? (char_u *)_("Message") : -#endif (char_u *)_("Error"), (char_u *)p, (char_u *)_("&Ok"), 1, NULL, FALSE); @@ -705,6 +702,13 @@ display_errors(void) ga_clear(&error_ga); } } +#else + void +display_errors(void) +{ + FlushFileBuffers(GetStdHandle(STD_ERROR_HANDLE)); +} +#endif #endif diff --git a/src/version.c b/src/version.c index 9a31c2f78e..73840c2513 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 918, /**/ 917, /**/ diff --git a/src/vim.h b/src/vim.h index 7ee164af77..be1ec1d317 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2093,7 +2093,7 @@ typedef enum { * functions of these names. The declarations would break if the defines had * been seen at that stage. But it must be before globals.h, where error_ga * is declared. */ -#if !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_X11) \ +#if !defined(MSWIN) && !defined(FEAT_GUI_X11) \ && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC) && !defined(PROTO) # define mch_errmsg(str) fprintf(stderr, "%s", (str)) # define display_errors() fflush(stderr) From 0f77d6afd506d1be4b0bef46e1d2268440e1ba88 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 20:55:09 +0100 Subject: [PATCH 47/75] patch 8.1.0919: compiler warnings Problem: Compiler warnings. Solution: Add type casts. (Mike Williams) --- src/message.c | 4 ++-- src/regexp_nfa.c | 2 +- src/version.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/message.c b/src/message.c index 4aa15eba69..82772fdbc0 100644 --- a/src/message.c +++ b/src/message.c @@ -2938,7 +2938,7 @@ do_more_prompt(int typed_char) mch_errmsg(char *str) { #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) - int len = STRLEN(str); + int len = (int)STRLEN(str); DWORD nwrite = 0; DWORD mode = 0; HANDLE h = GetStdHandle(STD_ERROR_HANDLE); @@ -3026,7 +3026,7 @@ mch_errmsg(char *str) mch_msg(char *str) { #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) - int len = STRLEN(str); + int len = (int)STRLEN(str); DWORD nwrite = 0; DWORD mode; HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index dadb9d067f..b83e309f7c 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4800,7 +4800,7 @@ addstate_here( emsg(_(e_maxmempat)); return NULL; } - newl = (nfa_thread_T *)alloc(newsize); + newl = (nfa_thread_T *)alloc((int)newsize); if (newl == NULL) return NULL; l->len = newlen; diff --git a/src/version.c b/src/version.c index 73840c2513..30b78e5ff8 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 919, /**/ 918, /**/ From 29ae223ddcfcbbce46c7e1f4e8fa71b8f2674271 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 21:22:01 +0100 Subject: [PATCH 48/75] patch 8.1.0920: in Terminal-Normal mode job output messes up the window Problem: In Terminal-Normal mode job output messes up the window. Solution: Postpone scrolling and updating the buffer when in Terminal-Normal mode. --- src/terminal.c | 173 +++++++++++++++++++----- src/testdir/dumps/Test_terminal_01.dump | 20 +++ src/testdir/dumps/Test_terminal_02.dump | 20 +++ src/testdir/dumps/Test_terminal_03.dump | 20 +++ src/testdir/test_terminal.vim | 40 ++++++ src/version.c | 2 + 6 files changed, 242 insertions(+), 33 deletions(-) create mode 100644 src/testdir/dumps/Test_terminal_01.dump create mode 100644 src/testdir/dumps/Test_terminal_02.dump create mode 100644 src/testdir/dumps/Test_terminal_03.dump diff --git a/src/terminal.c b/src/terminal.c index a823499ed9..f2f4ec0f1a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -60,9 +60,10 @@ typedef struct { } cellattr_T; typedef struct sb_line_S { - int sb_cols; /* can differ per line */ - cellattr_T *sb_cells; /* allocated */ - cellattr_T sb_fill_attr; /* for short line */ + int sb_cols; // can differ per line + cellattr_T *sb_cells; // allocated + cellattr_T sb_fill_attr; // for short line + char_u *sb_text; // for tl_scrollback_postponed } sb_line_T; #ifdef WIN3264 @@ -144,6 +145,8 @@ struct terminal_S { garray_T tl_scrollback; int tl_scrollback_scrolled; + garray_T tl_scrollback_postponed; + cellattr_T tl_default_color; linenr_T tl_top_diff_rows; /* rows of top diff file or zero */ @@ -188,6 +191,8 @@ static void term_free_vterm(term_T *term); static void update_system_term(term_T *term); #endif +static void handle_postponed_scrollback(term_T *term); + /* The character that we know (or assume) that the terminal expects for the * backspace key. */ static int term_backspace_char = BS; @@ -419,6 +424,7 @@ term_start( term->tl_system = (flags & TERM_START_SYSTEM); #endif ga_init2(&term->tl_scrollback, sizeof(sb_line_T), 300); + ga_init2(&term->tl_scrollback_postponed, sizeof(sb_line_T), 300); vim_memset(&split_ea, 0, sizeof(split_ea)); if (opt->jo_curwin) @@ -852,6 +858,9 @@ free_scrollback(term_T *term) for (i = 0; i < term->tl_scrollback.ga_len; ++i) vim_free(((sb_line_T *)term->tl_scrollback.ga_data + i)->sb_cells); ga_clear(&term->tl_scrollback); + for (i = 0; i < term->tl_scrollback_postponed.ga_len; ++i) + vim_free(((sb_line_T *)term->tl_scrollback_postponed.ga_data + i)->sb_cells); + ga_clear(&term->tl_scrollback_postponed); } @@ -1770,10 +1779,17 @@ term_check_timers(int next_due_arg, proftime_T *now) } #endif +/* + * When "normal_mode" is TRUE set the terminal to Terminal-Normal mode, + * otherwise end it. + */ static void set_terminal_mode(term_T *term, int normal_mode) { +ch_log(NULL, "set_terminal_mode(): %d", normal_mode); term->tl_normal_mode = normal_mode; + if (!normal_mode) + handle_postponed_scrollback(term); VIM_CLEAR(term->tl_status_text); if (term->tl_buffer == curbuf) maketitle(); @@ -1786,10 +1802,10 @@ set_terminal_mode(term_T *term, int normal_mode) static void cleanup_vterm(term_T *term) { + set_terminal_mode(term, FALSE); if (term->tl_finish != TL_FINISH_CLOSE) may_move_terminal_to_buffer(term, TRUE); term_free_vterm(term); - set_terminal_mode(term, FALSE); } /* @@ -2791,20 +2807,15 @@ handle_resize(int rows, int cols, void *user) } /* - * Handle a line that is pushed off the top of the screen. + * If the number of lines that are stored goes over 'termscrollback' then + * delete the first 10%. + * "gap" points to tl_scrollback or tl_scrollback_postponed. + * "update_buffer" is TRUE when the buffer should be updated. */ - static int -handle_pushline(int cols, const VTermScreenCell *cells, void *user) + static void +limit_scrollback(term_T *term, garray_T *gap, int update_buffer) { - term_T *term = (term_T *)user; - - /* First remove the lines that were appended before, the pushed line goes - * above it. */ - cleanup_scrollback(term); - - /* If the number of lines that are stored goes over 'termscrollback' then - * delete the first 10%. */ - if (term->tl_scrollback.ga_len >= term->tl_buffer->b_p_twsl) + if (gap->ga_len >= term->tl_buffer->b_p_twsl) { int todo = term->tl_buffer->b_p_twsl / 10; int i; @@ -2812,30 +2823,65 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user) curbuf = term->tl_buffer; for (i = 0; i < todo; ++i) { - vim_free(((sb_line_T *)term->tl_scrollback.ga_data + i)->sb_cells); - ml_delete(1, FALSE); + vim_free(((sb_line_T *)gap->ga_data + i)->sb_cells); + if (update_buffer) + ml_delete(1, FALSE); } curbuf = curwin->w_buffer; - term->tl_scrollback.ga_len -= todo; - mch_memmove(term->tl_scrollback.ga_data, - (sb_line_T *)term->tl_scrollback.ga_data + todo, - sizeof(sb_line_T) * term->tl_scrollback.ga_len); - term->tl_scrollback_scrolled -= todo; + gap->ga_len -= todo; + mch_memmove(gap->ga_data, + (sb_line_T *)gap->ga_data + todo, + sizeof(sb_line_T) * gap->ga_len); + if (update_buffer) + term->tl_scrollback_scrolled -= todo; + } +} + +/* + * Handle a line that is pushed off the top of the screen. + */ + static int +handle_pushline(int cols, const VTermScreenCell *cells, void *user) +{ + term_T *term = (term_T *)user; + garray_T *gap; + int update_buffer; + + if (term->tl_normal_mode) + { + // In Terminal-Normal mode the user interacts with the buffer, thus we + // must not change it. Postpone adding the scrollback lines. + gap = &term->tl_scrollback_postponed; + update_buffer = FALSE; +ch_log(NULL, "handle_pushline(): add to postponed"); + } + else + { + // First remove the lines that were appended before, the pushed line + // goes above it. + cleanup_scrollback(term); + gap = &term->tl_scrollback; + update_buffer = TRUE; +ch_log(NULL, "handle_pushline(): add to window"); } - if (ga_grow(&term->tl_scrollback, 1) == OK) + limit_scrollback(term, gap, update_buffer); + + if (ga_grow(gap, 1) == OK) { cellattr_T *p = NULL; int len = 0; int i; int c; int col; + int text_len; + char_u *text; sb_line_T *line; garray_T ga; cellattr_T fill_attr = term->tl_default_color; - /* do not store empty cells at the end */ + // do not store empty cells at the end for (i = 0; i < cols; ++i) if (cells[i].chars[0] != 0) len = i + 1; @@ -2861,25 +2907,86 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user) } } if (ga_grow(&ga, 1) == FAIL) - add_scrollback_line_to_buffer(term, (char_u *)"", 0); + { + if (update_buffer) + text = (char_u *)""; + else + text = vim_strsave((char_u *)""); + text_len = 0; + } else { - *((char_u *)ga.ga_data + ga.ga_len) = NUL; - add_scrollback_line_to_buffer(term, ga.ga_data, ga.ga_len); + text = ga.ga_data; + text_len = ga.ga_len; + *(text + text_len) = NUL; } - ga_clear(&ga); + if (update_buffer) + add_scrollback_line_to_buffer(term, text, text_len); - line = (sb_line_T *)term->tl_scrollback.ga_data - + term->tl_scrollback.ga_len; + line = (sb_line_T *)gap->ga_data + gap->ga_len; line->sb_cols = len; line->sb_cells = p; line->sb_fill_attr = fill_attr; - ++term->tl_scrollback.ga_len; - ++term->tl_scrollback_scrolled; + if (update_buffer) + { + line->sb_text = NULL; + ++term->tl_scrollback_scrolled; + ga_clear(&ga); // free the text + } + else + { + line->sb_text = text; + ga_init(&ga); // text is kept in tl_scrollback_postponed + } + ++gap->ga_len; } return 0; /* ignored */ } +/* + * Called when leaving Terminal-Normal mode: deal with any scrollback that was + * received and stored in tl_scrollback_postponed. + */ + static void +handle_postponed_scrollback(term_T *term) +{ + int i; + +ch_log(NULL, "Moving postponed scrollback to scrollback"); + // First remove the lines that were appended before, the pushed lines go + // above it. + cleanup_scrollback(term); + + for (i = 0; i < term->tl_scrollback_postponed.ga_len; ++i) + { + char_u *text; + sb_line_T *pp_line; + sb_line_T *line; + + if (ga_grow(&term->tl_scrollback, 1) == FAIL) + break; + pp_line = (sb_line_T *)term->tl_scrollback_postponed.ga_data + i; + + text = pp_line->sb_text; + if (text == NULL) + text = (char_u *)""; + add_scrollback_line_to_buffer(term, text, (int)STRLEN(text)); + vim_free(pp_line->sb_text); + + line = (sb_line_T *)term->tl_scrollback.ga_data + + term->tl_scrollback.ga_len; + line->sb_cols = pp_line->sb_cols; + line->sb_cells = pp_line->sb_cells; + line->sb_fill_attr = pp_line->sb_fill_attr; + line->sb_text = NULL; + ++term->tl_scrollback_scrolled; + ++term->tl_scrollback.ga_len; + } + + ga_clear(&term->tl_scrollback_postponed); + limit_scrollback(term, &term->tl_scrollback, TRUE); +} + static VTermScreenCallbacks screen_callbacks = { handle_damage, /* damage */ handle_moverect, /* moverect */ diff --git a/src/testdir/dumps/Test_terminal_01.dump b/src/testdir/dumps/Test_terminal_01.dump new file mode 100644 index 0000000000..22dd32356f --- /dev/null +++ b/src/testdir/dumps/Test_terminal_01.dump @@ -0,0 +1,20 @@ +|4+0&#ffffff0|2| @72 +|4|3| @72 +|4@1| @72 +|4|5| @72 +|4|6| @72 +|4|7| @72 +|4|8| @72 +>4|9| @72 +|~+0#4040ff13&| @73 +|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|2|,|1| @10|B|o|t +| +0#0000000#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +| +0&&@74 diff --git a/src/testdir/dumps/Test_terminal_02.dump b/src/testdir/dumps/Test_terminal_02.dump new file mode 100644 index 0000000000..495d2d2f58 --- /dev/null +++ b/src/testdir/dumps/Test_terminal_02.dump @@ -0,0 +1,20 @@ +|4+0&#ffffff0|2| @72 +|4|3| @72 +|4@1| @72 +|4|5| @72 +|4|6| @72 +|4|7| @72 +>4|8| @72 +|4|9| @72 +|~+0#4040ff13&| @73 +|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|1|,|1| @10|B|o|t +| +0#0000000#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +| +0&&@74 diff --git a/src/testdir/dumps/Test_terminal_03.dump b/src/testdir/dumps/Test_terminal_03.dump new file mode 100644 index 0000000000..a2883f657f --- /dev/null +++ b/src/testdir/dumps/Test_terminal_03.dump @@ -0,0 +1,20 @@ +|4+0&#ffffff0|3| @72 +|4@1| @72 +|4|5| @72 +|4|6| @72 +|4|7| @72 +|4|8| @72 +|4|9| @72 +|o|n|e| |m|o|r|e| |l|i|n|e| @61 +> @74 +|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|r|u|n@1|i|n|g|]| @36|4@1|,|1| @10|B|o|t +| +0#0000000#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +| +0&&@74 diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 8eb43a0cc7..b24dbc9974 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -299,6 +299,44 @@ func Test_terminal_scrollback() call term_wait(buf) exe buf . 'bwipe' set termwinscroll& + call delete('Xtext') +endfunc + +func Test_terminal_postponed_scrollback() + if !has('unix') + " tail -f only works on Unix + return + endif + + call writefile(range(50), 'Xtext') + call writefile([ + \ 'terminal', + \ 'call feedkeys("tail -n 100 -f Xtext\", "xt")', + \ 'sleep 100m', + \ 'call feedkeys("\N", "xt")', + \ ], 'XTest_postponed') + let buf = RunVimInTerminal('-S XTest_postponed', {}) + " Check that the Xtext lines are displayed and in Terminal-Normal mode + call VerifyScreenDump(buf, 'Test_terminal_01', {}) + + silent !echo 'one more line' >>Xtext + " Sceen will not change, move cursor to get a different dump + call term_sendkeys(buf, "k") + call VerifyScreenDump(buf, 'Test_terminal_02', {}) + + " Back to Terminal-Job mode, text will scroll and show the extra line. + call term_sendkeys(buf, "a") + call VerifyScreenDump(buf, 'Test_terminal_03', {}) + + call term_wait(buf) + call term_sendkeys(buf, "\") + call term_wait(buf) + call term_sendkeys(buf, "exit\") + call term_wait(buf) + call term_sendkeys(buf, ":q\") + call StopVimInTerminal(buf) + call delete('XTest_postponed') + call delete('Xtext') endfunc func Test_terminal_size() @@ -1512,6 +1550,8 @@ func Test_terminal_termwinkey() let job = term_getjob(buf) call feedkeys("\\", 'tx') call WaitForAssert({-> assert_equal("dead", job_status(job))}) + + set termwinkey& endfunc func Test_terminal_out_err() diff --git a/src/version.c b/src/version.c index 30b78e5ff8..e3ec2151a3 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 920, /**/ 919, /**/ From 81aa0f56f8be6922730f1ca368d6c64661dc97a3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 23:23:19 +0100 Subject: [PATCH 49/75] patch 8.1.0921: terminal test sometimes fails; using memory after free Problem: Terminal test sometimes fails; using memory after free. Solution: Fee memory a bit later. Add test to cover this. Disable flaky screenshot test. (closes #3956) --- src/terminal.c | 3 ++- src/testdir/test_terminal.vim | 24 +++++++++++++++++++++--- src/version.c | 2 ++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index f2f4ec0f1a..e2ae2f600f 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -4735,7 +4735,6 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff) p2 += len2; /* TODO: handle different width */ } - vim_free(line1); while (col < width) { @@ -4753,6 +4752,8 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff) } ++col; } + + vim_free(line1); } if (add_empty_scrollback(term, &term->tl_default_color, term->tl_top_diff_rows) == OK) diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index b24dbc9974..ba06f36235 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -317,16 +317,22 @@ func Test_terminal_postponed_scrollback() \ ], 'XTest_postponed') let buf = RunVimInTerminal('-S XTest_postponed', {}) " Check that the Xtext lines are displayed and in Terminal-Normal mode - call VerifyScreenDump(buf, 'Test_terminal_01', {}) + call term_wait(buf) + " TODO: this sometimes fails + "call VerifyScreenDump(buf, 'Test_terminal_01', {}) silent !echo 'one more line' >>Xtext " Sceen will not change, move cursor to get a different dump call term_sendkeys(buf, "k") - call VerifyScreenDump(buf, 'Test_terminal_02', {}) + call term_wait(buf) + " TODO: this sometimes fails + "call VerifyScreenDump(buf, 'Test_terminal_02', {}) " Back to Terminal-Job mode, text will scroll and show the extra line. call term_sendkeys(buf, "a") - call VerifyScreenDump(buf, 'Test_terminal_03', {}) + call term_wait(buf) + " TODO: this sometimes fails + "call VerifyScreenDump(buf, 'Test_terminal_03', {}) call term_wait(buf) call term_sendkeys(buf, "\") @@ -339,6 +345,18 @@ func Test_terminal_postponed_scrollback() call delete('Xtext') endfunc +" Run diff on two dumps with different size. +func Test_terminal_dumpdiff_size() + call assert_equal(1, winnr('$')) + call term_dumpdiff('dumps/Test_incsearch_search_01.dump', 'dumps/Test_popup_command_01.dump') + call assert_equal(2, winnr('$')) + call assert_match('Test_incsearch_search_01.dump', getline(10)) + call assert_match(' +++++$', getline(11)) + call assert_match('Test_popup_command_01.dump', getline(31)) + call assert_equal(repeat('+', 75), getline(30)) + quit +endfunc + func Test_terminal_size() let cmd = Get_cat_123_cmd() diff --git a/src/version.c b/src/version.c index e3ec2151a3..d0857e7f95 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 921, /**/ 920, /**/ From 96baf02aa87dc6ec43850c5617fe53061edd97bf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Feb 2019 23:49:38 +0100 Subject: [PATCH 50/75] patch 8.1.0922: terminal scrollback test is flaky Problem: Terminal scrollback test is flaky. Solution: Wait a bit before running the tail command. --- src/testdir/dumps/Test_terminal_01.dump | 2 +- src/testdir/dumps/Test_terminal_02.dump | 2 +- src/testdir/dumps/Test_terminal_03.dump | 2 +- src/testdir/test_terminal.vim | 10 ++++------ src/version.c | 2 ++ 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/testdir/dumps/Test_terminal_01.dump b/src/testdir/dumps/Test_terminal_01.dump index 22dd32356f..4a0014f05c 100644 --- a/src/testdir/dumps/Test_terminal_01.dump +++ b/src/testdir/dumps/Test_terminal_01.dump @@ -7,7 +7,7 @@ |4|8| @72 >4|9| @72 |~+0#4040ff13&| @73 -|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|2|,|1| @10|B|o|t +|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|1|,|1| @10|B|o|t | +0#0000000#ffffff0@74 |~+0#4040ff13&| @73 |~| @73 diff --git a/src/testdir/dumps/Test_terminal_02.dump b/src/testdir/dumps/Test_terminal_02.dump index 495d2d2f58..b9dfdbe2a8 100644 --- a/src/testdir/dumps/Test_terminal_02.dump +++ b/src/testdir/dumps/Test_terminal_02.dump @@ -7,7 +7,7 @@ >4|8| @72 |4|9| @72 |~+0#4040ff13&| @73 -|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|1|,|1| @10|B|o|t +|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|0|,|1| @10|B|o|t | +0#0000000#ffffff0@74 |~+0#4040ff13&| @73 |~| @73 diff --git a/src/testdir/dumps/Test_terminal_03.dump b/src/testdir/dumps/Test_terminal_03.dump index a2883f657f..6bc6ee790a 100644 --- a/src/testdir/dumps/Test_terminal_03.dump +++ b/src/testdir/dumps/Test_terminal_03.dump @@ -7,7 +7,7 @@ |4|9| @72 |o|n|e| |m|o|r|e| |l|i|n|e| @61 > @74 -|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|r|u|n@1|i|n|g|]| @36|4@1|,|1| @10|B|o|t +|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|r|u|n@1|i|n|g|]| @36|4|3|,|1| @10|B|o|t | +0#0000000#ffffff0@74 |~+0#4040ff13&| @73 |~| @73 diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index ba06f36235..9529b764c8 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -311,6 +311,7 @@ func Test_terminal_postponed_scrollback() call writefile(range(50), 'Xtext') call writefile([ \ 'terminal', + \ 'sleep 100m', \ 'call feedkeys("tail -n 100 -f Xtext\", "xt")', \ 'sleep 100m', \ 'call feedkeys("\N", "xt")', @@ -318,21 +319,18 @@ func Test_terminal_postponed_scrollback() let buf = RunVimInTerminal('-S XTest_postponed', {}) " Check that the Xtext lines are displayed and in Terminal-Normal mode call term_wait(buf) - " TODO: this sometimes fails - "call VerifyScreenDump(buf, 'Test_terminal_01', {}) + call VerifyScreenDump(buf, 'Test_terminal_01', {}) silent !echo 'one more line' >>Xtext " Sceen will not change, move cursor to get a different dump call term_sendkeys(buf, "k") call term_wait(buf) - " TODO: this sometimes fails - "call VerifyScreenDump(buf, 'Test_terminal_02', {}) + call VerifyScreenDump(buf, 'Test_terminal_02', {}) " Back to Terminal-Job mode, text will scroll and show the extra line. call term_sendkeys(buf, "a") call term_wait(buf) - " TODO: this sometimes fails - "call VerifyScreenDump(buf, 'Test_terminal_03', {}) + call VerifyScreenDump(buf, 'Test_terminal_03', {}) call term_wait(buf) call term_sendkeys(buf, "\") diff --git a/src/version.c b/src/version.c index d0857e7f95..bf47f97b38 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 922, /**/ 921, /**/ From c3ef8966081c03ce989f72a1e477df3327ccb971 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Feb 2019 00:16:13 +0100 Subject: [PATCH 51/75] patch 8.1.0923: terminal dump diff swap does not update file names Problem: Terminal dump diff swap does not update file names. Solution: Also swap the file name. Add a test. --- src/terminal.c | 20 ++++++++++++++++++-- src/testdir/test_terminal.vim | 18 ++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index e2ae2f600f..714cb2bcbd 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -4816,7 +4816,7 @@ term_swap_diff() bot_start = line_count - bot_rows; sb_line = (sb_line_T *)term->tl_scrollback.ga_data; - /* move lines from top to above the bottom part */ + // move lines from top to above the bottom part for (lnum = 1; lnum <= top_rows; ++lnum) { p = vim_strsave(ml_get(1)); @@ -4827,7 +4827,7 @@ term_swap_diff() vim_free(p); } - /* move lines from bottom to the top */ + // move lines from bottom to the top for (lnum = 1; lnum <= bot_rows; ++lnum) { p = vim_strsave(ml_get(bot_start + lnum)); @@ -4838,6 +4838,22 @@ term_swap_diff() vim_free(p); } + // move top title to bottom + p = vim_strsave(ml_get(bot_rows + 1)); + if (p == NULL) + return OK; + ml_append(line_count - top_rows - 1, p, 0, FALSE); + ml_delete(bot_rows + 1, FALSE); + vim_free(p); + + // move bottom title to top + p = vim_strsave(ml_get(line_count - top_rows)); + if (p == NULL) + return OK; + ml_delete(line_count - top_rows, FALSE); + ml_append(bot_rows, p, 0, FALSE); + vim_free(p); + if (top_rows == bot_rows) { /* rows counts are equal, can swap cell properties */ diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 9529b764c8..4bac4f93c1 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1124,6 +1124,24 @@ func Test_terminal_dumpdiff() quit endfunc +func Test_terminal_dumpdiff_swap() + call assert_equal(1, winnr('$')) + call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_popup_command_03.dump') + call assert_equal(2, winnr('$')) + call assert_equal(62, line('$')) + call assert_match('Test_popup_command_01.dump', getline(21)) + call assert_match('Test_popup_command_03.dump', getline(42)) + call assert_match('Undo', getline(3)) + call assert_match('three four five', getline(45)) + + normal s + call assert_match('Test_popup_command_03.dump', getline(21)) + call assert_match('Test_popup_command_01.dump', getline(42)) + call assert_match('three four five', getline(3)) + call assert_match('Undo', getline(45)) + quit +endfunc + func Test_terminal_dumpdiff_options() set laststatus=0 call assert_equal(1, winnr('$')) diff --git a/src/version.c b/src/version.c index bf47f97b38..bb5e0e1dba 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 923, /**/ 922, /**/ From 7e841e3ce507d3c03175213d167692609028fdd9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Feb 2019 00:26:14 +0100 Subject: [PATCH 52/75] patch 8.1.0924: terminal scrollback test still flaky Problem: Terminal scrollback test still flaky. Solution: Wait a bit longer before running the tail command. --- src/testdir/test_terminal.vim | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 4bac4f93c1..353bd54d01 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -311,9 +311,9 @@ func Test_terminal_postponed_scrollback() call writefile(range(50), 'Xtext') call writefile([ \ 'terminal', - \ 'sleep 100m', + \ 'sleep 400m', \ 'call feedkeys("tail -n 100 -f Xtext\", "xt")', - \ 'sleep 100m', + \ 'sleep 200m', \ 'call feedkeys("\N", "xt")', \ ], 'XTest_postponed') let buf = RunVimInTerminal('-S XTest_postponed', {}) diff --git a/src/version.c b/src/version.c index bb5e0e1dba..10715acbad 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 924, /**/ 923, /**/ From 5ff7df509ad6bde89991d38d87a6fc796b862ba7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Feb 2019 01:06:13 +0100 Subject: [PATCH 53/75] patch 8.1.0925: terminal scrollback test still still flaky Problem: Terminal scrollback test still still flaky. Solution: Explicitly set the shell. Disable ruler. (Ozaki Kiichi, closes #3966) --- src/testdir/dumps/Test_terminal_01.dump | 4 ++-- src/testdir/dumps/Test_terminal_02.dump | 4 ++-- src/testdir/dumps/Test_terminal_03.dump | 4 ++-- src/testdir/test_terminal.vim | 8 +++----- src/version.c | 2 ++ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/testdir/dumps/Test_terminal_01.dump b/src/testdir/dumps/Test_terminal_01.dump index 4a0014f05c..a242bb797e 100644 --- a/src/testdir/dumps/Test_terminal_01.dump +++ b/src/testdir/dumps/Test_terminal_01.dump @@ -7,7 +7,7 @@ |4|8| @72 >4|9| @72 |~+0#4040ff13&| @73 -|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|1|,|1| @10|B|o|t +|!+2#ffffff16#00e0003|/|b|i|n|/|s|h| |[|T|e|r|m|i|n|a|l|]| @55 | +0#0000000#ffffff0@74 |~+0#4040ff13&| @73 |~| @73 @@ -16,5 +16,5 @@ |~| @73 |~| @73 |~| @73 -|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +|[+1#0000000&|N|o| |N|a|m|e|]| @65 | +0&&@74 diff --git a/src/testdir/dumps/Test_terminal_02.dump b/src/testdir/dumps/Test_terminal_02.dump index b9dfdbe2a8..427a9ad4ae 100644 --- a/src/testdir/dumps/Test_terminal_02.dump +++ b/src/testdir/dumps/Test_terminal_02.dump @@ -7,7 +7,7 @@ >4|8| @72 |4|9| @72 |~+0#4040ff13&| @73 -|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|T|e|r|m|i|n|a|l|]| @35|5|0|,|1| @10|B|o|t +|!+2#ffffff16#00e0003|/|b|i|n|/|s|h| |[|T|e|r|m|i|n|a|l|]| @55 | +0#0000000#ffffff0@74 |~+0#4040ff13&| @73 |~| @73 @@ -16,5 +16,5 @@ |~| @73 |~| @73 |~| @73 -|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +|[+1#0000000&|N|o| |N|a|m|e|]| @65 | +0&&@74 diff --git a/src/testdir/dumps/Test_terminal_03.dump b/src/testdir/dumps/Test_terminal_03.dump index 6bc6ee790a..0796088449 100644 --- a/src/testdir/dumps/Test_terminal_03.dump +++ b/src/testdir/dumps/Test_terminal_03.dump @@ -7,7 +7,7 @@ |4|9| @72 |o|n|e| |m|o|r|e| |l|i|n|e| @61 > @74 -|!+2#ffffff16#00e0003|/|b|i|n|/|t|c|s|h| |[|r|u|n@1|i|n|g|]| @36|4|3|,|1| @10|B|o|t +|!+2#ffffff16#00e0003|/|b|i|n|/|s|h| |[|r|u|n@1|i|n|g|]| @56 | +0#0000000#ffffff0@74 |~+0#4040ff13&| @73 |~| @73 @@ -16,5 +16,5 @@ |~| @73 |~| @73 |~| @73 -|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +|[+1#0000000&|N|o| |N|a|m|e|]| @65 | +0&&@74 diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 353bd54d01..32cc212563 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -310,26 +310,24 @@ func Test_terminal_postponed_scrollback() call writefile(range(50), 'Xtext') call writefile([ + \ 'set shell=/bin/sh noruler', \ 'terminal', - \ 'sleep 400m', - \ 'call feedkeys("tail -n 100 -f Xtext\", "xt")', \ 'sleep 200m', + \ 'call feedkeys("tail -n 100 -f Xtext\", "xt")', + \ 'sleep 100m', \ 'call feedkeys("\N", "xt")', \ ], 'XTest_postponed') let buf = RunVimInTerminal('-S XTest_postponed', {}) " Check that the Xtext lines are displayed and in Terminal-Normal mode - call term_wait(buf) call VerifyScreenDump(buf, 'Test_terminal_01', {}) silent !echo 'one more line' >>Xtext " Sceen will not change, move cursor to get a different dump call term_sendkeys(buf, "k") - call term_wait(buf) call VerifyScreenDump(buf, 'Test_terminal_02', {}) " Back to Terminal-Job mode, text will scroll and show the extra line. call term_sendkeys(buf, "a") - call term_wait(buf) call VerifyScreenDump(buf, 'Test_terminal_03', {}) call term_wait(buf) diff --git a/src/version.c b/src/version.c index 10715acbad..567e870c8c 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 925, /**/ 924, /**/ From e93e5a504f481bd0dad9c504d5fcf0e5f0dfc6e6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Feb 2019 20:22:38 +0100 Subject: [PATCH 54/75] patch 8.1.0926: no test for :wnext, :wNext and :wprevious Problem: No test for :wnext, :wNext and :wprevious. Solution: Add a test. (Dominique Pelle, closes #3963) --- src/testdir/Make_all.mak | 1 + src/testdir/test_alot.vim | 1 + src/testdir/test_wnext.vim | 101 +++++++++++++++++++++++++++++++++++++ src/version.c | 2 + 4 files changed, 105 insertions(+) create mode 100644 src/testdir/test_wnext.vim diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 2ca5f2b1de..92e2ae3680 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -269,6 +269,7 @@ NEW_TESTS = \ test_window_cmd \ test_window_id \ test_windows_home \ + test_wnext \ test_wordcount \ test_writefile \ test_xxd \ diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 81873af2e6..204796a971 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -66,3 +66,4 @@ source test_true_false.vim source test_unlet.vim source test_virtualedit.vim source test_window_cmd.vim +source test_wnext.vim diff --git a/src/testdir/test_wnext.vim b/src/testdir/test_wnext.vim new file mode 100644 index 0000000000..3df61ceb78 --- /dev/null +++ b/src/testdir/test_wnext.vim @@ -0,0 +1,101 @@ +" Test :wnext :wNext and :wprevious + +func Test_wnext() + args X1 X2 + + call setline(1, '1') + wnext + call assert_equal(['1'], readfile('X1')) + call assert_equal('X2', bufname('%')) + + call setline(1, '2') + call assert_fails('wnext', 'E165:') + call assert_equal(['2'], readfile('X2')) + call assert_equal('X2', bufname('%')) + + " Test :wnext with a single file. + args X1 + call assert_equal('X1', bufname('%')) + call assert_fails('wnext', 'E163:') + + " Test :wnext with a count. + args X1 X2 X3 + call assert_equal('X1', bufname('%')) + 2wnext + call assert_equal('X3', bufname('%')) + + " Test :wnext {file}. + args X1 X2 X3 + wnext X4 + call assert_equal(['1'], readfile('X4')) + call assert_equal('X2', bufname('%')) + call assert_fails('wnext X4', 'E13:') + call assert_equal(['1'], readfile('X4')) + wnext! X4 + call assert_equal(['2'], readfile('X4')) + call assert_equal('X3', bufname('%')) + + args X1 X2 + " Commented out as, E13 occurs on Windows instead of E17 + "call assert_fails('wnext .', 'E17:') + call assert_fails('wnext! .', 'E502:') + + %bwipe! + call delete('X1') + call delete('X2') + call delete('X3') + call delete('X4') +endfunc + +func Test_wprevious() + args X1 X2 + + next + call assert_equal('X2', bufname('%')) + call setline(1, '2') + wprevious + call assert_equal(['2'], readfile('X2')) + call assert_equal('X1', bufname('%')) + + call setline(1, '1') + call assert_fails('wprevious', 'E164:') + call assert_fails('wNext', 'E164:') + + " Test :wprevious with a single file. + args X1 + call assert_fails('wprevious', 'E163:') + call assert_fails('wNext', 'E163:') + + " Test :wprevious with a count. + args X1 X2 X3 + 2next + call setline(1, '3') + call assert_equal('X3', bufname('%')) + 2wprevious + call assert_equal('X1', bufname('%')) + call assert_equal(['3'], readfile('X3')) + + " Test :wprevious {file} + args X1 X2 X3 + 2next + call assert_equal('X3', bufname('%')) + wprevious X4 + call assert_equal(['3'], readfile('X4')) + call assert_equal('X2', bufname('%')) + call assert_fails('wprevious X4', 'E13:') + call assert_equal(['3'], readfile('X4')) + wprevious! X4 + call assert_equal(['2'], readfile('X4')) + call assert_equal('X1', bufname('%')) + + args X1 X2 + " Commented out as, E13 occurs on Windows instead of E17 + "call assert_fails('wprevious .', 'E17:') + call assert_fails('wprevious! .', 'E502:') + + %bwipe! + call delete('X1') + call delete('X2') + call delete('X3') + call delete('X4') +endfunc diff --git a/src/version.c b/src/version.c index 567e870c8c..1451697c67 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 926, /**/ 925, /**/ From 00590740081489db69f43d9f1c0e3f70e29ce6da Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Feb 2019 21:06:09 +0100 Subject: [PATCH 55/75] patch 8.1.0927: USE_CR is never defined Problem: USE_CR is never defined. Solution: Remove usage of USE_CR. (Ken Takata, closes #3958) --- runtime/doc/options.txt | 10 ++-- src/diff.c | 12 ++--- src/evalfunc.c | 16 +----- src/ex_cmds2.c | 110 ++-------------------------------------- src/fileio.c | 53 +------------------ src/message.c | 5 +- src/ops.c | 4 -- src/option.h | 21 +++----- src/proto/ex_cmds2.pro | 1 - src/proto/fileio.pro | 1 - src/tag.c | 18 ++----- src/version.c | 2 + 12 files changed, 29 insertions(+), 224 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6b2dde8257..3b62c0f530 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3134,9 +3134,8 @@ A jump table for the options with a short description can be found at |Q_op|. is read. *'fileformat'* *'ff'* -'fileformat' 'ff' string (MS-DOS, MS-Windows, OS/2 default: "dos", - Unix default: "unix", - Macintosh default: "mac") +'fileformat' 'ff' string (MS-Windows default: "dos", + Unix, macOS default: "unix") local to buffer {not in Vi} This gives the of the current buffer, which is used for @@ -3159,9 +3158,8 @@ A jump table for the options with a short description can be found at |Q_op|. *'fileformats'* *'ffs'* 'fileformats' 'ffs' string (default: - Vim+Vi MS-DOS, MS-Windows OS/2: "dos,unix", - Vim Unix: "unix,dos", - Vim Mac: "mac,unix,dos", + Vim+Vi MS-Windows: "dos,unix", + Vim Unix, macOS: "unix,dos", Vi Cygwin: "unix,dos", Vi others: "") global diff --git a/src/diff.c b/src/diff.c index d368f96978..9220c72148 100644 --- a/src/diff.c +++ b/src/diff.c @@ -90,10 +90,6 @@ static int parse_diff_ed(char_u *line, linenr_T *lnum_orig, long *count_orig, li static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new, long *count_new); static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf); -#ifndef USE_CR -# define tag_fgets vim_fgets -#endif - /* * Called when deleting or unloading a buffer: No longer make a diff with it. */ @@ -996,7 +992,7 @@ check_external_diff(diffio_T *diffio) for (;;) { /* There must be a line that contains "1c1". */ - if (tag_fgets(linebuf, LBUFLEN, fd)) + if (vim_fgets(linebuf, LBUFLEN, fd)) break; if (STRNCMP(linebuf, "1c1", 3) == 0) ok = TRUE; @@ -1604,7 +1600,7 @@ diff_read( } else { - if (tag_fgets(linebuf, LBUFLEN, fd)) + if (vim_fgets(linebuf, LBUFLEN, fd)) break; // end of file line = linebuf; } @@ -1626,9 +1622,9 @@ diff_read( else if ((STRNCMP(line, "@@ ", 3) == 0)) diffstyle = DIFF_UNIFIED; else if ((STRNCMP(line, "--- ", 4) == 0) - && (tag_fgets(linebuf, LBUFLEN, fd) == 0) + && (vim_fgets(linebuf, LBUFLEN, fd) == 0) && (STRNCMP(line, "+++ ", 4) == 0) - && (tag_fgets(linebuf, LBUFLEN, fd) == 0) + && (vim_fgets(linebuf, LBUFLEN, fd) == 0) && (STRNCMP(line, "@@ ", 3) == 0)) diffstyle = DIFF_UNIFIED; else diff --git a/src/evalfunc.c b/src/evalfunc.c index e693ef9137..f1cb9dc607 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -13431,20 +13431,7 @@ get_cmd_output_as_rettv( else { res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL); -#ifdef USE_CR - /* translate into */ - if (res != NULL) - { - char_u *s; - - for (s = res; *s; ++s) - { - if (*s == CAR) - *s = NL; - } - } -#else -# ifdef USE_CRNL +#ifdef USE_CRNL /* translate into */ if (res != NULL) { @@ -13459,7 +13446,6 @@ get_cmd_output_as_rettv( } *d = NUL; } -# endif #endif rettv->vval.v_string = res; res = NULL; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 30efcdf83d..a723025715 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1359,7 +1359,7 @@ check_due_timer(void) did_throw = FALSE; current_exception = NULL; save_vimvars(&vvsave); - +ch_log(NULL, "calling timer callback"); timer->tr_firing = TRUE; timer_callback(timer); timer->tr_firing = FALSE; @@ -4243,7 +4243,7 @@ struct source_cookie FILE *fp; /* opened file for sourcing */ char_u *nextline; /* if not NULL: line that was read ahead */ int finished; /* ":finish" used */ -#if defined(USE_CRNL) || defined(USE_CR) +#ifdef USE_CRNL int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */ int error; /* TRUE if LF found after CR-LF */ #endif @@ -4465,15 +4465,6 @@ do_source( cookie.error = FALSE; #endif -#ifdef USE_CR - /* If no automatic file format: Set default to CR. */ - if (*p_ffs == NUL) - cookie.fileformat = EOL_MAC; - else - cookie.fileformat = EOL_UNKNOWN; - cookie.error = FALSE; -#endif - cookie.nextline = NULL; cookie.finished = FALSE; @@ -4768,59 +4759,6 @@ free_scriptnames(void) #endif -#if defined(USE_CR) || defined(PROTO) - -# if defined(__MSL__) && (__MSL__ >= 22) -/* - * Newer version of the Metrowerks library handle DOS and UNIX files - * without help. - * Test with earlier versions, MSL 2.2 is the library supplied with - * Codewarrior Pro 2. - */ - char * -fgets_cr(char *s, int n, FILE *stream) -{ - return fgets(s, n, stream); -} -# else -/* - * Version of fgets() which also works for lines ending in a only - * (Macintosh format). - * For older versions of the Metrowerks library. - * At least CodeWarrior 9 needed this code. - */ - char * -fgets_cr(char *s, int n, FILE *stream) -{ - int c = 0; - int char_read = 0; - - while (!feof(stream) && c != '\r' && c != '\n' && char_read < n - 1) - { - c = fgetc(stream); - s[char_read++] = c; - /* If the file is in DOS format, we need to skip a NL after a CR. I - * thought it was the other way around, but this appears to work... */ - if (c == '\n') - { - c = fgetc(stream); - if (c != '\r') - ungetc(c, stream); - } - } - - s[char_read] = 0; - if (char_read == 0) - return NULL; - - if (feof(stream) && char_read == 1) - return NULL; - - return s; -} -# endif -#endif - /* * Get one full line from a sourced file. * Called by do_cmdline() when it's called from do_source(). @@ -4953,9 +4891,6 @@ get_one_sourceline(struct source_cookie *sp) char_u *buf; #ifdef USE_CRNL int has_cr; /* CR-LF found */ -#endif -#ifdef USE_CR - char_u *scan; #endif int have_read = FALSE; @@ -4973,18 +4908,9 @@ get_one_sourceline(struct source_cookie *sp) break; buf = (char_u *)ga.ga_data; -#ifdef USE_CR - if (sp->fileformat == EOL_MAC) - { - if (fgets_cr((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, + if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, sp->fp) == NULL) - break; - } - else -#endif - if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, - sp->fp) == NULL) - break; + break; len = ga.ga_len + (int)STRLEN(buf + ga.ga_len); #ifdef USE_CRNL /* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the @@ -4998,34 +4924,6 @@ get_one_sourceline(struct source_cookie *sp) } #endif -#ifdef USE_CR - /* If the read doesn't stop on a new line, and there's - * some CR then we assume a Mac format */ - if (sp->fileformat == EOL_UNKNOWN) - { - if (buf[len - 1] != '\n' && vim_strchr(buf, '\r') != NULL) - sp->fileformat = EOL_MAC; - else - sp->fileformat = EOL_UNIX; - } - - if (sp->fileformat == EOL_MAC) - { - scan = vim_strchr(buf, '\r'); - - if (scan != NULL) - { - *scan = '\n'; - if (*(scan + 1) != 0) - { - *(scan + 1) = 0; - fseek(sp->fp, (long)(scan - buf - len + 1), SEEK_CUR); - } - } - len = STRLEN(buf); - } -#endif - have_read = TRUE; ga.ga_len = len; diff --git a/src/fileio.c b/src/fileio.c index f9e18d413a..85d2df3bbf 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5216,14 +5216,12 @@ msg_add_fileformat(int eol_type) return TRUE; } #endif -#ifndef USE_CR if (eol_type == EOL_MAC) { STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]")); return TRUE; } -#endif -#if defined(USE_CRNL) || defined(USE_CR) +#ifdef USE_CRNL if (eol_type == EOL_UNIX) { STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]")); @@ -6359,11 +6357,7 @@ vim_fgets(char_u *buf, int size, FILE *fp) char tbuf[FGETS_SIZE]; buf[size - 2] = NUL; -#ifdef USE_CR - eof = fgets_cr((char *)buf, size, fp); -#else eof = fgets((char *)buf, size, fp); -#endif if (buf[size - 2] != NUL && buf[size - 2] != '\n') { buf[size - 1] = NUL; /* Truncate the line */ @@ -6372,57 +6366,12 @@ vim_fgets(char_u *buf, int size, FILE *fp) do { tbuf[FGETS_SIZE - 2] = NUL; -#ifdef USE_CR - vim_ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp); -#else vim_ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); -#endif } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); } return (eof == NULL); } -#if defined(USE_CR) || defined(PROTO) -/* - * Like vim_fgets(), but accept any line terminator: CR, CR-LF or LF. - * Returns TRUE for end-of-file. - * Only used for the Mac, because it's much slower than vim_fgets(). - */ - int -tag_fgets(char_u *buf, int size, FILE *fp) -{ - int i = 0; - int c; - int eof = FALSE; - - for (;;) - { - c = fgetc(fp); - if (c == EOF) - { - eof = TRUE; - break; - } - if (c == '\r') - { - /* Always store a NL for end-of-line. */ - if (i < size - 1) - buf[i++] = '\n'; - c = fgetc(fp); - if (c != '\n') /* Macintosh format: single CR. */ - ungetc(c, fp); - break; - } - if (i < size - 1) - buf[i++] = c; - if (c == '\n') - break; - } - buf[i] = NUL; - return eof; -} -#endif - /* * rename() only works if both files are on the same file system, this * function will (attempts to?) copy the file across if rename fails -- webb diff --git a/src/message.c b/src/message.c index 82772fdbc0..ed59d1b435 100644 --- a/src/message.c +++ b/src/message.c @@ -2590,10 +2590,7 @@ msg_puts_printf(char_u *str, int maxlen) memcpy(buf, p, n); if (!info_message) buf[n++] = CAR; -#ifdef USE_CR - else -#endif - buf[n++] = NL; + buf[n++] = NL; buf[n++] = NUL; if (info_message) // informative message, not an error mch_msg((char *)buf); diff --git a/src/ops.c b/src/ops.c index dacbfd87cd..c5e2be5e53 100644 --- a/src/ops.c +++ b/src/ops.c @@ -6577,11 +6577,7 @@ clip_convert_selection(char_u **str, long_u *len, VimClipboard *cbd) #ifdef USE_CRNL p[i++] = '\r'; #endif -#ifdef USE_CR - p[i] = '\r'; -#else p[i] = '\n'; -#endif lnum++; j = -1; } diff --git a/src/option.h b/src/option.h index 26e5fd04c6..2f1d322bf1 100644 --- a/src/option.h +++ b/src/option.h @@ -50,21 +50,14 @@ # define DFLT_FFS_VI "dos,unix" /* also autodetect in compatible mode */ # define DFLT_TEXTAUTO TRUE #else -# ifdef USE_CR -# define DFLT_FF "mac" -# define DFLT_FFS_VIM "mac,unix,dos" -# define DFLT_FFS_VI "mac,unix,dos" -# define DFLT_TEXTAUTO TRUE +# define DFLT_FF "unix" +# define DFLT_FFS_VIM "unix,dos" +# ifdef __CYGWIN__ +# define DFLT_FFS_VI "unix,dos" /* Cygwin always needs file detection */ +# define DFLT_TEXTAUTO TRUE # else -# define DFLT_FF "unix" -# define DFLT_FFS_VIM "unix,dos" -# ifdef __CYGWIN__ -# define DFLT_FFS_VI "unix,dos" /* Cygwin always needs file detection */ -# define DFLT_TEXTAUTO TRUE -# else -# define DFLT_FFS_VI "" -# define DFLT_TEXTAUTO FALSE -# endif +# define DFLT_FFS_VI "" +# define DFLT_TEXTAUTO FALSE # endif #endif diff --git a/src/proto/ex_cmds2.pro b/src/proto/ex_cmds2.pro index ac9b291e5c..01d20db634 100644 --- a/src/proto/ex_cmds2.pro +++ b/src/proto/ex_cmds2.pro @@ -93,7 +93,6 @@ void ex_scriptnames(exarg_T *eap); void scriptnames_slash_adjust(void); char_u *get_scriptname(scid_T id); void free_scriptnames(void); -char *fgets_cr(char *s, int n, FILE *stream); char_u *getsourceline(int c, void *cookie, int indent); void script_line_start(void); void script_line_exec(void); diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro index e99cbc8bfd..1844924fdb 100644 --- a/src/proto/fileio.pro +++ b/src/proto/fileio.pro @@ -18,7 +18,6 @@ void shorten_filenames(char_u **fnames, int count); char_u *modname(char_u *fname, char_u *ext, int prepend_dot); char_u *buf_modname(int shortname, char_u *fname, char_u *ext, int prepend_dot); int vim_fgets(char_u *buf, int size, FILE *fp); -int tag_fgets(char_u *buf, int size, FILE *fp); int vim_rename(char_u *from, char_u *to); int check_timestamps(int focus); int buf_check_timestamp(buf_T *buf, int focus); diff --git a/src/tag.c b/src/tag.c index a148fbc0e9..9dde6a9e2b 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1146,14 +1146,6 @@ do_tags(exarg_T *eap UNUSED) msg_puts("\n>"); } -/* When not using a CR for line separator, use vim_fgets() to read tag lines. - * For the Mac use tag_fgets(). It can handle any line separator, but is much - * slower than vim_fgets(). - */ -#ifndef USE_CR -# define tag_fgets vim_fgets -#endif - #ifdef FEAT_TAG_BINS /* * Compare two strings, for length "len", ignoring case the ASCII way. @@ -1654,7 +1646,7 @@ find_tags( /* Adjust the search file offset to the correct position */ search_info.curr_offset_used = search_info.curr_offset; vim_fseek(fp, search_info.curr_offset, SEEK_SET); - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); if (!eof && search_info.curr_offset != 0) { /* The explicit cast is to work around a bug in gcc 3.4.2 @@ -1666,13 +1658,13 @@ find_tags( vim_fseek(fp, search_info.low_offset, SEEK_SET); search_info.curr_offset = search_info.low_offset; } - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); } /* skip empty and blank lines */ while (!eof && vim_isblankline(lbuf)) { search_info.curr_offset = vim_ftell(fp); - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); } if (eof) { @@ -1698,7 +1690,7 @@ find_tags( eof = cs_fgets(lbuf, LSIZE); else #endif - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); } while (!eof && vim_isblankline(lbuf)); if (eof) @@ -1763,7 +1755,7 @@ line_read_in: { is_etag = 1; /* in case at the start */ state = TS_LINEAR; - if (!tag_fgets(ebuf, LSIZE, fp)) + if (!vim_fgets(ebuf, LSIZE, fp)) { for (p = ebuf; *p && *p != ','; p++) ; diff --git a/src/version.c b/src/version.c index 1451697c67..6374cba9fa 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 927, /**/ 926, /**/ From d634024b90c7ae6ff08c1970646f1bca91f5611f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 00:00:28 +0100 Subject: [PATCH 56/75] patch 8.1.0928: stray log function call Problem: Stray log function call. Solution: Remove the log function call. --- src/ex_cmds2.c | 1 - src/version.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index a723025715..4bf2072723 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1359,7 +1359,6 @@ check_due_timer(void) did_throw = FALSE; current_exception = NULL; save_vimvars(&vvsave); -ch_log(NULL, "calling timer callback"); timer->tr_firing = TRUE; timer_callback(timer); timer->tr_firing = FALSE; diff --git a/src/version.c b/src/version.c index 6374cba9fa..4662831d46 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 928, /**/ 927, /**/ From 5acd9872580a12ca1138275bf65d1cb9349e2a53 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 13:35:13 +0100 Subject: [PATCH 57/75] patch 8.1.0929: no error when requesting ConPTY but it's not available Problem: No error when requesting ConPTY but it's not available. Solution: Add an error message. (Hirohito Higashi, closes #3967) --- runtime/doc/terminal.txt | 6 +++--- src/terminal.c | 21 ++++++++++----------- src/version.c | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index 4b009d32fb..42fe2c9d9d 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -413,13 +413,13 @@ Just put the files somewhere in your PATH. You can set the 'winptydll' option to point to the right file, if needed. If you have both the 32-bit and 64-bit version, rename to winpty32.dll and winpty64.dll to match the way Vim was build. - *ConPTY* + *ConPTY* *E982* On more recent versions of MS-Windows 10 (beginning with the "October 2018 Update"), winpty is no longer required. On those versions, |:terminal| will use Windows' built-in support for hosting terminal applications, "ConPTY". When ConPTY is in use, there may be rendering artifacts regarding ambiguous-width -characters. If you encounter any such issues, set 'termwintype' to "winpty" -(which you then must have instlled). +characters. If you encounter any such issues, install "winpty". Until the +ConPTY problems have been fixed "winpty" will be preferred. Environment variables are used to pass information to the running job: VIM_SERVERNAME v:servername diff --git a/src/terminal.c b/src/terminal.c index 714cb2bcbd..899d3b687a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5620,10 +5620,8 @@ void (WINAPI *pDeleteProcThreadAttributeList)(LPPROC_THREAD_ATTRIBUTE_LIST); static int dyn_conpty_init(int verbose) { - static BOOL handled = FALSE; - static int result; - HMODULE hKerneldll; - int i; + static HMODULE hKerneldll = NULL; + int i; static struct { char *name; @@ -5642,16 +5640,17 @@ dyn_conpty_init(int verbose) {NULL, NULL} }; - if (handled) - return result; - if (!has_conpty_working()) { - handled = TRUE; - result = FAIL; + if (verbose) + emsg(_("E982: ConPTY is not available")); return FAIL; } + // No need to initialize twice. + if (hKerneldll) + return OK; + hKerneldll = vimLoadLib("kernel32.dll"); for (i = 0; conpty_entry[i].name != NULL && conpty_entry[i].ptr != NULL; ++i) @@ -5661,12 +5660,11 @@ dyn_conpty_init(int verbose) { if (verbose) semsg(_(e_loadfunc), conpty_entry[i].name); + hKerneldll = NULL; return FAIL; } } - handled = TRUE; - result = OK; return OK; } @@ -6015,6 +6013,7 @@ dyn_winpty_init(int verbose) { if (verbose) semsg(_(e_loadfunc), winpty_entry[i].name); + hWinPtyDLL = NULL; return FAIL; } } diff --git a/src/version.c b/src/version.c index 4662831d46..8a7ab7f5bf 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 929, /**/ 928, /**/ From 0a1b17bbec8f71beaab1d58b4c054ab4320f3bb2 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 13:45:09 +0100 Subject: [PATCH 58/75] patch 8.1.0930: typo in Makefile Problem: Typo in Makefile. Solution: Change ABORT_CLFAGS to ABORT_CFLAGS. (Kuang-che Wu, closes #3977) --- src/Makefile | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 60828ad16b..5575902a3d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -703,7 +703,7 @@ SANITIZER_LIBS = $(SANITIZER_CFLAGS) # Uncomment this line to have Vim call abort() when an internal error is # detected. Useful when using a tool to find errors. -#ABORT_CLFAGS = -DABORT_ON_INTERNAL_ERROR +#ABORT_CFLAGS = -DABORT_ON_INTERNAL_ERROR ##################################################### ### Specific systems, check if yours is listed! ### {{{ @@ -1471,7 +1471,7 @@ VTERM_CFLAGS = -Ilibvterm/include PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS) POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(EXTRA_DEFS) -ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(ABORT_CLFAGS) $(POST_DEFS) +ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(ABORT_CFLAGS) $(POST_DEFS) # Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together # with "-E". diff --git a/src/version.c b/src/version.c index 8a7ab7f5bf..e2b6f7a611 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 930, /**/ 929, /**/ From 6902c0eb27a3e4479445badfef31443f2227fe60 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 14:07:37 +0100 Subject: [PATCH 59/75] patch 8.1.0931: vtp_working included in GUI build but unused Problem: vtp_working included in GUI build but unused. Solution: Adjust #ifdefs. (Ken Takata, closes #3971) --- src/os_win32.c | 6 +++--- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index 0680346af0..816c3a59cf 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -186,12 +186,12 @@ static int win32_getattrs(char_u *name); static int win32_setattrs(char_u *name, int attrs); static int win32_set_archive(char_u *name); -static int vtp_working = 0; static int conpty_working = 0; static int conpty_stable = 0; static void vtp_flag_init(); #ifndef FEAT_GUI_W32 +static int vtp_working = 0; static void vtp_init(); static void vtp_exit(); static int vtp_printf(char *format, ...); @@ -7874,14 +7874,14 @@ is_term_win32(void) return T_NAME != NULL && STRCMP(T_NAME, "win32") == 0; } -#endif - int has_vtp_working(void) { return vtp_working; } +#endif + int has_conpty_working(void) { diff --git a/src/version.c b/src/version.c index e2b6f7a611..00c63e53ce 100644 --- a/src/version.c +++ b/src/version.c @@ -783,6 +783,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 931, /**/ 930, /**/ From 14184a3133b9a6ee5f711d493c04e41ba4fa7c2f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 15:10:30 +0100 Subject: [PATCH 60/75] patch 8.1.0932: Farsi support is outdated and unused Problem: Farsi support is outdated and unused. Solution: Delete the Farsi support. --- Filelist | 5 - farsi/README.txt | 2 - farsi/fonts/DOS/far-a01.com | Bin 4673 -> 0 bytes farsi/fonts/SunOs/far-a01.fb | Bin 14988 -> 0 bytes farsi/fonts/UNIXs/far-a01.f16 | Bin 4096 -> 0 bytes farsi/fonts/UNIXs/far-a01.pcf.Z | Bin 7181 -> 0 bytes farsi/fonts/UNIXs/far-a01.pcf.gz | Bin 5350 -> 0 bytes farsi/fonts/WINDOWS/far-a01.fon | Bin 17408 -> 0 bytes runtime/doc/farsi.txt | 261 +--- runtime/doc/options.txt | 14 +- runtime/doc/quickref.txt | 2 - runtime/doc/starting.txt | 5 +- src/Make_bc5.mak | 1 - src/Make_cyg_ming.mak | 3 +- src/Make_dice.mak | 4 - src/Make_ivc.mak | 5 - src/Make_manx.mak | 6 - src/Make_morph.mak | 1 - src/Make_mvc.mak | 6 +- src/Make_sas.mak | 5 - src/Make_vms.mms | 173 ++- src/Makefile | 212 ++- src/auto/configure | 15 +- src/charset.c | 20 +- src/config.h.in | 3 - src/configure.ac | 13 +- src/edit.c | 51 +- src/evalfunc.c | 3 - src/ex_cmds.c | 9 - src/ex_getln.c | 122 +- src/farsi.c | 2179 ------------------------------ src/farsi.h | 234 ---- src/getchar.c | 9 - src/globals.h | 11 +- src/main.c | 21 +- src/normal.c | 9 - src/option.c | 83 -- src/proto.h | 3 - src/proto/farsi.pro | 12 - src/screen.c | 4 - src/search.c | 12 +- src/structs.h | 4 - src/testdir/Make_all.mak | 2 - src/testdir/test_farsi.vim | 133 -- src/version.c | 6 +- src/window.c | 6 - 46 files changed, 240 insertions(+), 3429 deletions(-) delete mode 100644 farsi/README.txt delete mode 100755 farsi/fonts/DOS/far-a01.com delete mode 100644 farsi/fonts/SunOs/far-a01.fb delete mode 100644 farsi/fonts/UNIXs/far-a01.f16 delete mode 100644 farsi/fonts/UNIXs/far-a01.pcf.Z delete mode 100644 farsi/fonts/UNIXs/far-a01.pcf.gz delete mode 100644 farsi/fonts/WINDOWS/far-a01.fon delete mode 100644 src/farsi.c delete mode 100644 src/farsi.h delete mode 100644 src/proto/farsi.pro delete mode 100644 src/testdir/test_farsi.vim diff --git a/Filelist b/Filelist index 211b487673..c621f8c937 100644 --- a/Filelist +++ b/Filelist @@ -37,8 +37,6 @@ SRC_ALL = \ src/ex_docmd.c \ src/ex_eval.c \ src/ex_getln.c \ - src/farsi.c \ - src/farsi.h \ src/feature.h \ src/fileio.c \ src/findfile.c \ @@ -169,7 +167,6 @@ SRC_ALL = \ src/proto/ex_docmd.pro \ src/proto/ex_eval.pro \ src/proto/ex_getln.pro \ - src/proto/farsi.pro \ src/proto/fileio.pro \ src/proto/findfile.pro \ src/proto/fold.pro \ @@ -837,8 +834,6 @@ EXTRA = \ $(SRC_EXTRA) \ README_extra.txt \ src/VisVim/VisVim.dll \ - farsi/README.txt \ - farsi/fonts/*/far-* \ runtime/vimlogo.xpm \ src/tee/Makefile \ src/tee/Make_mvc.mak \ diff --git a/farsi/README.txt b/farsi/README.txt deleted file mode 100644 index ef6129fb63..0000000000 --- a/farsi/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -For information about installation of Farsi fonts and Vim usage in Farsi mode, -refer to the Farsi help file by typing ":help farsi" in Vim. diff --git a/farsi/fonts/DOS/far-a01.com b/farsi/fonts/DOS/far-a01.com deleted file mode 100755 index ebd06caed1133abb5f8353306354d464d7cd497b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4673 zcma)8Z)h9m8GlbwUY)&*a(10^&4he*RL^6nk(*7qj>EFDkYbvFlak?f8_032CLm(t z%EB9mY%N)uf#<;XWgCMIyp1sSp<{z8ffm(ax3$>whk-X%WAb67*%-x8aMI13_B`*O zyOR>wp2WKQz0dPL@ALn?f4r$!3&UCS^yJ*@m(AkLm9qJ@Av2#DHp#)x({t0)=4n_v zW}cd!GKXJyA!}avmig70x$@+)PuyMp<4WV5e6&uw-qwFhZWHAWA$L3fK7W2Zy=X@(-FCd3u)E5~?C$d5 z#87i+PMP@WP%|~BJot5U{_yzAXV1~|4{kU4+Bf5`zVh{nO(8L!I^J0M>mR75g33VZXYRYfX5Iw&%lrVrH#Jtfg{Vb ztlasVQrDl|=zH)NZ~hxBP${}U@cZno*!M>&3dZPml6>;>cyB!)UHy@=ocM{d`b&7+ zQihgBmIx_#)_L030`pzXHvWmsi5B^XzJ4z6we8Qf$)CvNTI|`Qp1@?Oac}pL z_h|QCV~H(AXd*S@jieGZ!bJ?bY8XbI|S>4C9gCX@O8^_9CGkZNvGHR<;7( zw)K1ow6j0t8;0YqH5^K>yN>i=&DD%d(G?12mKm&7bt{TShOke^fOu#Sm*0m9aIoh0Ikt;y z;9+B}Xmk9igv?^G^oV1xc;V8*rNV`xh?l^H!ft5)j_Ve`%rTzCjuYo$@i7wmQ>+@G zendR(!%+(haOi!$f49KMKhOQx^B|o-LjV0eZ|6?|X0b*n{AK>33Spn%Z|yi*0yQu` z`Y6r=e!@z&Os_i;(s=a!%w9SAzd7)urd;lJlz$K`t!=>?W1XokJ;pUpYV%A8j9mF&VuIn{Yvf?3K(rD0$xG{E(|+lJP7%h2Lav+{N6_Op?S?y9Qecej$Z=OKH1XSm10mI%s;3A>7Sm-jG%kj zB)ZOsxfhBDD*-uQK!O*5$UoweWrg#^OQuRS*;4CJ05bmxaCH^~#HteqgCu@9@=(T@ zWw^4p6}1~a*6brW2a(3@hHbJO+)Bowi<~lO=xdJDixUDk&p+0 z85{Ew#<*ymp-m`0f4{)~9V;-~kL4N0xTw4|*4$!TLe!pCjLUTFZ1Y{g$7?){0czc5 z2JQFBPO4~+PpL#KHw86b7y;onc{DmKkM{ZUISPn&bR1&wf%kYDCQ6iQ8s+f=UaaG( z77TnKMUnf7a`gD{GaUyH^on%D9(KZ~d+ZGw7@jThRkf!-_l4oGe?~fe?9)%aXlOC9 zN6H5!C>WuKnp9O4v8t;&A?d344B+1f{`E0BI(qV4nw*P7BK`fm1zPWasWNnd!4lLb z8V;T>oUA$- zuvP?vkg>%IV1Qx^RdwjMOy3B1o~TCh>4Bs9vBfOkKkC?^i_(brp3LW`vT&ZiAK#M6 z>{LF_!kw_eRD9TcT5@F1SdWg?nI-!I~C~Q#KNhzro_k&cZ&Y9fxk#YPGwbBj$x4 zKQS+S45spVA;h`4FoAN_0<`8RVraBT{Ax&m;)FUR;)Ch^OjlRSe2KK_whAhbq1y1KEdk#M+*{$m{%Q)4O#=OsAeK`OC diff --git a/farsi/fonts/SunOs/far-a01.fb b/farsi/fonts/SunOs/far-a01.fb deleted file mode 100644 index c353f85319c2000c209a78a7606a5c736d6888ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14988 zcmbuGU2I&%8HOjx)=BA-IKcq}Za7I?eu|+ExWUjBiHS|H*!qmORTlKZLP&M_ku0b0cV@qxnRm}w zyXuT)&w0*y&o_VH%$c3FXAQy@WA1qK;V!e|UqU<04pT2DIE%xrbvf+5VNCtck^0On zpjF6?@Eizp#zgY5XB;15uN?Nw5HE#%M~1kCxIkPYo+4f#UJbdSiMW%vNIXG2OS~NN z-Yjt&aUby*@ig%w@mk1tHWTNGM~Nqi=ZIHAzN>*aM?6S8PCP@r6mnyRxP`btTq2$# zULal#`R*p-PU0f*1o15Ka>(~&iQ9<#h{uShi5H32LcX_|I8QuEJV`u9yb^L#196Uc zka(PUhIlFD?`DWwhzrCe;wj<<;?@Z8RDgoAIK255EqC` z#8boz#H%4c*hJh(TqK?#o+Vxm`JpUv8*v};81XdmBJou_fw)9GMZ7?~8uBAe#GS-N;tAqe;^mMZ%@Vf}_Ysc~PZKW^ zuZ8@BX5u{YDDfom9PvuXtqsIE;z8nZ;u+$lkPl^uTZjw9CE_XK1>)6^A8R7+BrXz9 z5YG}Xhx~Y!xQ)1vc#L?Oc#(K5aO2|KKAkGmF5|0zl5HE#%I78e* zTp%tHPZ2K=uZH|Y6LBYTk$8f5mUubj_AGH5aUby*@ig%w@mk1FHWTNGM~Nqi=ZIHA zeyV{uM?C2B`H{^vJp5@cC$P%(!RW%J zpN_oo=m9e{aOIJK)N>v(r>q34Y0?(OdBZbdL1Kk4e}INo*k#qQ3+bEfxn$1!>2nCa>2J(Yi<(0%IU z*)u-8WKMU#)RjNm+x>Ev>FDe{+gmu3?>c+3<3yJ+$TqfP@#M&rR|krwH{XHE^q3dB zqz?Ahi3@|nufJ-Z?Ksh$KVvUFJACcJAS(XC$xamT#K@J=fj0-D;}-{Bdu`wxnrisU zz@@ldB&)NPnxMIj^ntYdlSs1D(vBoMH%}qmhV&z(Ye*8XYg7LL(r=J{hXnts{|C}P zk(QDEgCx59PDmB&BWf)H;M$q9m7jimhbW~-dn3X!L~Zr(A!M|#Kn(fm3-Uavgr>yDVm z%@NaDj+f0B=95I-TjsoxB=HsVnfcV*NYokAi1-m2|1+eIVp3t`l~1opqe}8aRMs6f zwPTX*D;WBUo=ehwY3j_EDLR;_1S#8Q>^*@Nd?Ll3UkfQ;T74^-;$(f3<&(bKOukaS zBYp-rj}qEh+9lrB^t7ro=56%)C-9N4q4_%Yl^eLG!RfZb%1*P-JPqB`IPL^H_jNk) zmYlgBdr2dXIh?uR>xPUUO-!ovb$Tu7`2XtGQ5%UGe0$aPNFHy#PDYAE4WT`~E61>9 ze4Tx^(PUAstY=HESL<3$KXm=@1wT~l4EkB3tE=d%bq|^%G)42E+^&R(#(6!a-gZ+$ z^jojmp4=6csQqnpwpYoBPJErTvqWv-txol{n3ved|PFKJ?W2m#G8n6l)ljrdHFWt`n7WTZ7q`L z1MwF>*LiQu`Sz@?4s9%cRfngrj3@_Rmo-h$6yYf{A4uG%vY;O8sG-EQ*jl>1cFY!5 zC$*KBobNjBNV#nLS^v_E{qjjYtQC7qv!}Z2u~o6FOSS5LllHa2oe4)?e+av~a+c=L zS_hdWWpvcZqj8AHp255<}Idc)c zdJ!IW4z#Yaz+R~9hxUs^oh#qRaczgI^^6AJp7`;5XcL*w`r{Qv z@;J)jei)PO=^FnsO4w9m-JYv>y?TGOJ)MKJ+cCl~Z^!1vSPwd$@ak{<3<}vi#wMy?L&o9>E z)pA`WXBlq`crJW@*!mW+o>UJ@9&h&j)9#I=>i(5H<()6vDst2)mPH+T?+=^r5PV-} zz~p@W9BYkVm`7NNXFxmV=IteXMqa-5;!>ryQZ^0MI)B!xCr7kn-6%FwI};V?TMi;w^_UiZw)4?P5K2V?Wi|Eq%Rf^AMfRfXVZp z>SQLBC^MjjsH%J}-+9dIvNDs^M73@mo^EHrwDt4OvL|1zcy#%XxX7OMx$qN`I7D9g z)Q;M1G?&XNzkKqoEj{@5M5Xhk)Y{GBzCB~^g--TX?!l~Z06RMO$%Ew(Rm#_F@}|Xf znoK!vH``Q%qtj*L*-BLzlcsYIZ-u2T_^xNm*BIY$_R@5AUnkVb3}LV<`R}o;T8I`L>wnO*cw+Q!n5cRr*a%vhWv-Y;Zl8gHR6M<^EdcT z;6mj2OKbV^M&nW*$(lRO1Lk4mpH@E2qtP@YwwQ0szfBuv;4FM1xqO_jyhS3fd}=Z2 zSWCAf_M06jHQSS)R`d^hoAH)$yMewve?QURNsw|l-BBa)8T_mzR(deINj!ikZ(*kc zAZ%v;&nn%gyqPpaDeYq4UfPpkzV@4feiM+MaKX1{SK7L^_jgM|d-}9}pG$AK5K;N0 zTz0SDY2=J`_O9Ctv7D^)=c!t{q`keQd^e{PZ<2W^48A>?McZRf7hktg)xPc-v`7hB z+h^jR&Z@8L#;GNoYeVT+{ZHRWUtle1C^QW_ytdl%5XkU4w z??;*T$%S%=%JtQC$woST&K|eMt9Dr>Y%7m;wI}!0ru3Yw?$dPccY@kFo2PtkF?$hz zYsSqO;u^l!N0ok)F?(D5M;5hp&YD5l_F^5AY)?wB^G+>Y6n}$`P?G!2Lp9bV5q1Ik zq1s3%<&zatJ^XN2#jm7?eLt{mys=KdgGmc-H$U^nk!^>l(teeHF^Y5FWquj|1;;z) zuUMCtymt22o$2E!Tz97Hq!eP&tvluKM>JRCZN)dXt(Ym(g6iyZ`gFBgb=7ymCsil; z9zHt_6hG0*iB4HrNtJ+U1x2xq)I~EeN#PI$VaaKM!f1vjV<#d4*bE#z85#)L zLV`3yfy|vc_0MRbx&SAm-L%9oJUL4d7%1R4fI;=Wd+*4j;-QyVSh()1;C1lIbs58B3jb)Wp1a4ziu0DOa094LhAWR5-_m3UzmdgiI)@i=z~ z_E+L8UMc7e-%k>KJZxuKlK6h3U?{!0K@hWu1teJWXM}@j7d#yAMgif|7>Q97pAycZ$4>@N!p9NE zi*Xnp8}bKf8huF^Pg2M6d02dEvHrHI2B;s7#}OPg7{H-NB!3*Lm7kZs$udYMEY^Q? zk{$e2U=?eG?62|bX_gwo)HgK0(!mx2NeM4A93vaW}c{IhSJe3wFd>D z^Ir#7H!(n}I&m=QMTa8|dE8BfxAtk<_*EUQ)rn7ptbcrGv3s33mLJ^ux(cf{N4V-Z z2y?7ANiYkQN zEMwf38xNK9+={S<&2ej(^M(G{=ie*@!Y@Xhs3Z=8-dyNZSI z-!mBc59w$m@e_ugsn1nzblXZ4`_06pPgphRp*fWjIPj&RIXh4<)>%Q&IY1d zy?7A@N{&h4+?8ug7b=eh?u22dbMv#j-#SqlW3x8g1@sr~2Wv_gr>s@0{ix!p&cZ&I z^9wIWqtTyP!t)}JAJ2;%gQ+wxn4Qdp3Dg~i(3(BO&}dfeslgy|LM?E7FufmKx>TAk zbF~*QUXK3291H!u0b^V({e7XazK`^L()UkZE_QR}yOn0qV2zdL#pX(b)xl%-^IlVE zBI8x2E;-&Vf9}}LM$2yKdB!Zgo!(CE<%{QeP&M5cB1Dgbk+<&U$s&>^DW_}7H&0!(HyQfBeR?GQ=a#;H6 R#(I8#;2}jiivVzZ{sS1zzxDtC diff --git a/farsi/fonts/UNIXs/far-a01.pcf.Z b/farsi/fonts/UNIXs/far-a01.pcf.Z deleted file mode 100644 index d8e44605f73db753e992da052c9e1e80a5e58688..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7181 zcmWNTc{J4BAII;EG4mY;Uu(uvLzbybjVwc`u@xGVWhx|%eF@1DvNU6?V@VN)Xq3uN z_CmHAOIf09V=p7xp6W^URN8;ex#ynqy6^LTozK00-7V$$h>;w20bun2Gy<~A^w9t` zton8vh()tvN@H!RGWje^IWe4OW(h1N%hB79WHmZh9RM~Z$|%bT0xE-cRT(HpoxxQDf!W`1BoZuXnOLm{v(I~&p zk&|m4o)B%l6(<+c{6j&o?H)Fm^y1Q3v9KA0D`s;1Gsud!m! zp;B_x%T!r0ABj@K$lkjMrr#Mk9rt^KH%2X_Dt0S1DA-4$u!B1o5ZGLO0+5CibO!YfKsw0Yk13f3}PP0+Y7#W zXZ}*ue;`j|SlY@pB(ZI|J6hL$a_%`IY+>udI25op39^-SL7lb56*pf zTC@<}|E4Ha!Ct`E#?kg*Uu?29(eIbHS%;`N>RyDcl3VKm+w@bJJ^NLBS=5KBk~fyo zP(ar*T3wIv?XsFbi?5C+6fUQ$oLXH*f`6J`Z3b?M?EbUiNZ3|UCi#LNd$IfL4ZQc@ zxRo-QAAc-&XYcEN8;m&NRxLWl_)^G`Ttk;YxvW)r(DnSsEz2*zeDe=tgZ(>F%@ili}^JFW&n1?mO<=f7{>QD+}*jn=otW z`Z%54(Ea_{tq=GApcg*~ekpZ*=mGLMjRLgpBDqg;$GeDrnS;2G{mLh5n;xhgeW(9` z5V&}HQ1zT%^N@Cd`KO`n*SaEy^#*XCM|RD;`!q^=rFVOD&t%T${=0}Pf*pdR5Mbu7)V3lpkrp7$oHw_<5V%PLF|*T~+g=Ic zq^V+N7dE%O5tP)|3R{srJIJlbH39whz;QEjOT!)4|lUIzCO`1!Yd zVi9F>K7mmGmj76GGCBVNr^bS>r=w(W-vGnEWu28Nld}%o8Vi1$zAc0M2|ODMex06_ z!Tkoz#)3bmKg;0$fV9q_Y+(GaALw9Wuf4?R_xqKV{W0=S1> zs7%p8aJGjrsD@vQxxl~y{l zRvu7h?afz=4>3pNfyu1>-j&uv%y;s@bk?4_V(i4kDS$n*_EsycPE0)oU^Z)SvtsPb zq$vRNS^NDft(GqP==_EALLsrJ6*INuVuarg^i;AwCi0%WAFJ|HC8 z4W9jcGXLj9Y`dApsXuF_@c*P|8??8P*|K_~)RLYa*m#hmt>z7AZbqB#MQ|u1%hCxY zU2mnDlEra?^D65NI5dmBPl778wXI)*uFsXBt>EvQ^z43kI@dSHS^b>bfWUJX8L{pg zm{lMCwyx|o_m^wEX?#EJjMDnE_GhsvyN0n?DadktqL{1v=*0eDE3b|hdcNOBqS8Kk zZR%Q4IQHNnYcwLQC-de1?iCDU+oLKfa~@mVbRXEIZf%v~2iJE;-}`)tYl#ZWFYf)` zl8Oe`qW`QvjtCX}js< z={en#; ze}BC;YuL6LEH-(6@c4&Icb7F|_9mmDLs*;q<;(|C zaBjxWRqX@q{R_DtlU3K3Ka1<&EO21~!md8bfH0@n@ma}-d4dD_QzvgE+*8qF*z%A* zIcf7L?n38_yGPo}uHW;%c<8JQwx`4Ljinn`0lo&HdDLGqIC$$skSjxOdAj z6Ag;(&PGgFSauX?qFae9z4Yemy`$^pCbYP;+&t%kdcuu!qmNHlUs0bN@YfekmaiBU%-rwD>v*>;HJX|^PcYaQ z?z!pQa%?Z0p4hPVZ(CVs2mbG;fxnJvs(c%BzDwCt#r;`P}DqqG0MVtt=s$poGKfU>G&d%|&NCfeAEUlV`mp8frm?iUd5 zt8?aAtY>mtT+Pf`!>`UM8Ij!m3BzaNFBk`p9Ch3BB4m$pWc|w&WPlfToYEv_^_OuD z-o#w};@or~;oxj)sPSR%Z*1bLP{yp@L!s*(b63UhuU4TW{ zh?s_};x-2}3rrOYO$%YOU|8UkW)@Ru>kBuz@Cv{bvA54kdU zNl(6}_R3v4hy{-BX@vi1pB0ZCt&XxiQ}p3RkwwfU-b=+(*kkHCCoNtS{hGey=bq+@ z1rz!3MP~80L2rSW-N>h6b}-BtDxQc9{VXg2`6`KX81+`yy^1`nB`+x$F5-m2Ww%=Vp84%pHA3q%8e|E6X`toZ~ry7*0Mj!HwCCd zYy7nV#p}*3nVP!U0)rZ)4lhU?R28Ld+h1e6d~Lz#gjK1JN_6evFwQi zSlV-eI21zH0Bg-z`rqKEO;7M^`-d zqcm&02-Z9aJ6*5TE~_#$KJ1=#ecMk)*IY9@t!hNBdFvzJfv?Wb1^kXVc~662PkFO( z?O5!`+vst=-&WbrW2bD(F58#fp_-Li9gFqSZW(pCe8j%xpz0mVzRQpBE%Qc4seY+H zv7ki)jQi(CDKD}|Ht+(6vgmzxq+j18)mM=HnzB24B zH|M&X-ThI-*wNYCCkPb3+xFV@3Q_WY|5uL>Josa9H3)?bI-9i?y#L&~!YQjf$GcB& zxjz?}lcso2gg=fxLOG<;+AYU88Pd7XE?6&vmAWeb6!m;SSBSE@XW!mG|I;H&5{%`; znXJCUZ~2eUR4inf4@TYJUIw4;DK>r-@T#PrY1$GU5?Y8^uzsns*E1bT zlK`cVcO?Kww|jzQLDH)u?JA$3UEjCS#dG%`jnJ#JKKL;gR=Ksmy5~ z$LT1kiAgJ=wWBb_3CeVW&M}1PWNnH-E6+&G$$82-aS)z zd|I=7CV@N^tUg!nIDKAf{({uRwb9v_r?c19=c`EbwWCnz(|P~y`R3etzu!~YN%KMP zF?Y)+&P0&d0E&7Fbtg?^Q5PPl&p!xT=>NUooHXw^x)^OSeJg3PpCp{J5RR2Yb74QihoDR&HWx^B|Tf@GIO%3NERY=*u#PW?_= z`dYU%Ik9A!yM+3)gh?i4u|(^?N#cLTQ9F13eh>XtUs`loP9je#g)d?6E&aB5hDaX& zW&!y+LTtfY2kEKR)5)=?!h++oMcq>|<;&YQL%z9CB6*72h|$V}GDJfCa?FvWC4DK# zq5{$;J$>=}S@iF5+WXZ*qpS4yt2(5)#BL}tVzsIJxoh_vb@T-nK-TI@7MqviEhfNT z67unq%I~G6<_W3#aU;h$d_5`V-xc=Qv-m&b$Yf|~0$O_hDl(a*N?+3G-X%+aEl(He zhA%B$g`(=8a>%4`b&=I%|3^R9~jY~A-`D^+4jQANvYyOy<~ zhK+-kt%uhB5Um4ewd}ZB_N7`5=QR&{rs$lIb(~Y6zfm~!UBL;f=!{o%@s@Qpmqh{i zx@Dx?C(F2f&06*VxOSibLEaI7hEFK|E&1R23a4De0aHBRY8w!#V(*GuB0%u6IA~O= z)>ia!id1q&pW1YEODP)g(LfX?HKDZN?eRqs0|*!(NIK<=0Za^7ON_sO0es9n27LGD zSzq_Gb!POaY>IM*022Zc(6`G_0TyHffSQMZXyatlBpwUMB?SOHJcb2KEQr9?FEA3C zut0zXV^|>CNGl~(BmhAIkRM##^WZ@N_~Nu*{TqE@Q#su6O_{lq>-F0>G>oh>&UC1R6ardT*&}NCsfgA@q%+ z0z#@vpcn)*n38^MAP|2@RVIp^BuI6!cabrVsp>&u@dW8bHnkCh?%6^_WfNr0Q}&Xv z(w5pmC>}x1GsUS9yT3=5D1M8e*p)&jOVTY#LE`NMrNtCxqhxx|E+YC70dLOnB1`32 z8U>-}2r8bOh(@W0JrpA5EkV7D6Hbe&c$5JkDX+fAFc_{NY8er4tK{Nbsj}2>5k5 ze=>w+X_^2o89_v%`H(tGGZSzlkVK>;AJS)O&H`?u7!e8cAzPLv5y4$U5s`{~$epDb zhv1UYOr|OyiezanBDew!(Tc!_(pj2%NG`wNF|Ghdv@+yF(=5$UF)olMTAA{pe^{DbVqB^WF=eltUs#_88DtO;YDjbh zv{|5$4>I^jH6$(qG8Sm8Z6qi)q+A3<7ic&kGWg}fy zGNkmKjK(%PVuv}>3@HniQBAr=wMq^@#4e?Vjjc)7tyZbxhg7H3AS7$jN!2P{{1Av! z!^YL58&s=I@k4?*H3;dNbkk~;cl?mSjYOsr(6#G`@2;zkEUwcL`QTg(JrNU=Dq zoJgC=Di$HUkk~lvc9FJ#Rm>FgLdwKptwh=ccCiTMg;b2gdWf`H>|!R`3#l51jTC8% zHWG{%QX>w_6=_pbikVn1q;4G6nt2dlNo<{7E!?_9!0ytLp->;4zAPS1H(+-~$xxz? zj+jG94#M*}y=aKR)^SZMr74E)K74nGfzWkLyG&Dz-hFs>$bhH&WVNCYk>rB@Wsir6 z{sMj>BFzP@=77)NfUB1gxsm91L-;Y>K*5#E2zDeIH;i{81_~-KBeEjVdJZaM#9%>1 z6(Z^4hCl`00DcuB?c#<&C4U31)*^D7Hv}qUx+eu!Y7y+_4S|Xi@uZ-#7LnDwAy6G7 zh6yU}Ad)6F1gh``@b4hfCN>1B`5SPx3z7S2L!dgQdrEMn3&H-hAy9Q9o)T1cA+kPg z2-L=irv(-Lh$K18FMBn31Ni-jG&zi#gIfLuTpdB=?#8?uQXA8a5?mQUuywqq{08v*3)18cZFVr{ZNPAUf$wfKG|I<|`2^rf zc>4T+hpaNZSY!Zhb^`(*vMy~C^SFVFDqTEfRZgkXMwwOGQc8oLKb3&(E zt=vHVMBd}Fp4=$ zc9}cW>#(DkipATP-@D2-8M^#4D(SK9=S%U?Le}S$Gs8Xc zdnE(0NrjoWQ|ZGG+^zbsckUYBPC3GFfQxn{+cs8LcKW!BxMNOwc@G)}E9DUX2T;-q A7XSbN diff --git a/farsi/fonts/UNIXs/far-a01.pcf.gz b/farsi/fonts/UNIXs/far-a01.pcf.gz deleted file mode 100644 index ab6fa9ddd6418b958d820eecd6d55dd2f2f24d79..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5350 zcmZWn2UJtp-&AmIG?%K%0E&fqxn9FVm6Kf>l^+}80zTxD@W<~eV!a!ZELXp6!lOu+<2{7mje78pQ z1asT`$vF40&0>M!4rSl(6y94Ef86HAqK zwd_-?^-hUqR9sY&wF$;sKrKcq{(;?`{P}*ElCo{CnI{LIqJC!*nMrP>mE6fo8p(gw zSOMRyNljQCu~bY@8L!^lO6~EMdMRV=JAb&^Tc#4O)wz(2W|DpBTD%DocziIn`bsC^*$FKZ$;R0;>LC zmN?B~mWg&e)%^4mJ((OW);mdz_2?SEA*O!i9kbV&`>DX*JxTlonrc2>xU-+xbTFS3zJNW= zxjfZ*MqE83KAjPd&rA%@f>kq4`oI2({FgYJ==pbJ*fZkxN$i_a`(JIRE~!pU3d$Faz@N)A};>EES`k$&H-=pldZt^&W&ax+ZHv^+H3 zKe+@In7n5#L&rk)f)@vYqt%z z^jwx$jx3k+5i!g|5rqJ3rQI>g#K&xZ3zl?I+Fe(yGshsdk_#TpBnTt1y zHfrjlMo<`mJwuH-Wu3)kROZ!?<@ak0pk0*?U^?1Fe9t`6m_9d}j$3c-Q=gl-I+s)j z-&@(~6wX<$mEWOZSKt`<0Z()uWCU8?@q{+5nl9{`uE9Q>AlA z6m$tRDzi8{8<{KK5wblEEul1ejEu7XefY%pBbF`|%M)0`zyw>FVjJXOR^ z`Mna2buYtg%dOgA`c+<1No@@S5`wS<9`T#faR;%EDCnlO!@5pSoWf+RJk1HIFV*Ny z#SDi_l)pD4H+Gg>7#ee{u9M|KrS_of2@CEX{^V;2V(|Wf(UYv^KL2c~Fi#2(Om>d= zwu}m2LwA+qkW>2cf^-9&t%>h(+>KQmca!r0oyVQYa-D}mULw6nK95bEqi#AAk0nR9 zLStTwLCFaFc!vUtOWdDKOmRB7WsVZn5$@o&bMq_K!l8-SG)8*^6ofhhc#yd7FzF+s z@2}q!L`id?GN<)85uL#=QFDg`ciQ5wJGg_aVOnTg5(n7-$m}m@K>hiLi>$UyYkJ0q z*w%B)A0O0yDn0!`3PebUd2{H-}QttL8#qp&`!VnU*>edq1t`EgdHQ`-1SPa zTk~L78PNkS0mk@Mx{8gH<$d-`!_!qBAK>#Vfz=0ar3R;0kkr|9i&dl|WJ0YDG8K+! zqH)_08ZPI`VtBmgZ;+%U&CN=aOhrlFm;D`b#F_#}ebMac>2t)8kIIqiJ@W;vVK>%; z*ELq}zQm|6o0(LhbO+k1o#@7&)K^+A=ICEF5fs>VsHQ6+6JPj44^?^i5hkBw?q;ch z)Ss7|CIGChB2yHYk%L_M71Jw~2>=ZZedH+6swc>Q9mV&#R8Z1xdA&8ehMGjPB*xuL zraYYbekG<2Z!momxb035EN=r12$nbAUQRj=d1u(9Vs52*a9E2Rcl=FPCphxYv_#)adedO3Qt5VR&NfIW8|xLP|0Igbyh<9D=_?$*j;A)VZq zRE3y-WrW&8fw$FJpw+C=E&IrwPZ-+zgT_NuRih$FINEc$_bzupX*vm=7ZY6tZw(F1 zzy>V+eOPr&Mb(^~KNoXr3X z_LaDUGNY)4XHNNzo{ne0sbfo?{umu)f4Abdo0{rqp zLY+RMQq7P)ZoAUF{o$kfOKieQMqW^H(mBUpwauAHWmAyrx$52XVDs87aH{zCUD1B8 zC!b?19v5i}E|RGCq#MI%rjiG~@@Tap-`?1lx3{GeRmxnZv>OaoU8X_e=JY>X;AaU zR!fCN(zE8rj7F>PI31wkD#xZJ+tqz;@)Ek(Eb}n*WB1pk1bp_!~kfe1MP|Hq)g31sxmz? zt!?O^9oc#Ev-1hN8fJ4*xp!8Yb`1}^j@zf`Rn($fI($#`9lzQIMYp8~-fKFs@@r<} zua9+IQNQ-$sOnieYil=W*M2W@(=%HC*{1o+#M&t4sG^;lJn*2@=nau~iC|S+>9(%C zS)$Lojuk#8-I$D_ncGA$QKK?W0*I-ExVzE|0P{XCD1pd^<~T10v# zWM&}m)%t_hS;l=SYuC(BNrKTTSREK$+3K^kJ)&j29`A&GZ#0HIFcw3O8B+AVwUD^k zsM)k*I4K%wtj8iWa z4vFe^zE9ZMWpNq*BlB5uvhZU=;rO3Z?~e{aN6#yK*e)KunoysEMouo&1@)Q4MEY*n z^RJU};l{t*jtU$2zvDVBOv#8w&jSH4LtsRhYn3yD=OjXMF7qY@6f)%BXjC_a%lYc3 zMwI%%yi+Be;m!EAy5hr*$9ver=v13xr@5shRUe*8JS@Azy^`6VGLBAzqV zXSx=%TNYoEt*LFB?C;6MjVjh>&Ke3N6d==<*Ww4)$6MO>ETzD%Gfyeroee^j7rk7U zc=_tsko_6tBV8Xab72Fay{Or)gKLzXu#!qZl<-zFfCKO*yEA)~ksod6ep_c`{i}zc zIHJ&Z#;-1|o_-}cn8QD0@25z5REM9e;kQqGH_}4~Hr4gN-%#avQJe(ccocbeu$0Tq z#%(mX)Pq%LVtp~642k|T)kDD1)2lDSEV(n(Di?-APR&KMQgvl`#k4)HO55N)}YwPUi`u)_`HZ_8*NUzpfZzPbpsV) zu^~SZ5i_Suy`dg74iGwo2V6x3-P?c$T+I5OvCl_tvYy@EmzqG!{uH3zX?Q0)V?||Y zh-&>UB5IkmPTU~XjK8!(scrO>A^Z1`~f`EcI#9|wFp$J z-9C?6wBYO&s#IXG_$FsyRMyYw(Ya$zqq*r#=D^Swn{X-vJ!o-5Pc4StQnbOKBiz{P zwqa2hoV0n5%7fUSo_k7Fd9gx&J5tV7weC=GxBUU@)+N3DTK_HoduB;-dwmX;TIwTW z&h6sOUB{$tyR9Bv9bML0yj!k!M*Uo=0Q~nZdXn^8GeIks?K*Q>uh9bER&-X^jaRnA zXbpW=F~P7DyC0S1WFhO<2ODdqHVp`=)u0mE0e`YDH%d42jaefyk;?8!+g0dlbH^jG z>oWq{(IRb_E2Ima?0^J)(FjsIK)6eV!J^~9USRoFWCz~9x;wAjUU*Ei0wXl0MTzC@ z(CH{3`FLJB;Hypx2%pdqxWyLdhS6zfYo8+lOR}g@YC2Z8WaCVAl0#oH-_VKvgQHzU zAtl`~H;ymGutylKdvE!co^DXSh;zGkNs3n-e@@nfuB%vOoKf7pj!BZ$*3%<&OIU|6 z3A}aT;EI3fiJeHJa8X=bwyK+`4yF=22V?<+=!*(KMHF?J09jq)JXkzQp(G+-cqEor zJ7rygEQILLX_qE(kXSu=s>1?OCX57xriG?OW8wtkj!9-)Y6mR-A$5k@F}VfUO_HiY zT)Jj%tRj#fFdoR{$(^Fd9jiq$E_nk1D#xz2n-CrzwyS$`R3`*r0zv~a1L98hEHZs- zT5MW82K%9XfW$*GC5djWI6anZi}fH~R|wL_tV6H^9ZDGCfewFrR;W0?{T0dB1bdb- zU1h9H$=e+)Z$~#tS>Z8C(x0d#nkjBo;O9L%6q&?P^q@|AGj&N4Eb;#yKir1qOn4JV zi1<|_&P)k4@F@V6iZBNcM&L|1%W)sMv9+sDweV& zgLvu)qD5Z)QkE1DPlE#9Ez;TRPH@DPWk|pzKo$|7Rm6(QiO=FIxbfXuPz0E06JK#1Z=elL0~4K| z^bGP84Ebc2%}BriptNX0MRwVy1nfR2ErvkJzNzmpU=I5mG#*RP&MD)PglU7u;|QTS zWulTW(C7ZaCj~>pIb{Gzm=TCKp1_SS14_akgLo4NCiqnSJ1V;nQ!kilW`&f|c*2LZ z9|Jz~(AupsOMhaa+6kuR#z3Fbe@pAk u2h^Yi{}KNm&kCuco-&wu-v0~xk3LU@#qKzbB7H#rjk)K(;S<|)=l%;;*Take diff --git a/farsi/fonts/WINDOWS/far-a01.fon b/farsi/fonts/WINDOWS/far-a01.fon deleted file mode 100644 index 3121097d80651fce0e0ca3418799b833c2bebe79..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17408 zcmeHNU2I!Nb{nb_wte!0)-d?6NVdXaVW6nvs4mrW zzH{!+P}gl9`cM=ao8O)D&6$}qXU_caQfDWAU|NhZt@PR6Hs+`FXR z=Ev>7Jp9wxnO`0rzjpmY=hocp2Xm7*oTh)GPfBmDqvH0&pe%oXD8PiWeo^g7Zy$m#l6rP+j;Jrte zG4vmRr;4f_JYwb-e;i0bE^d;6@V}OOZSKRlDYT|z%95aVdz}=FslGOMwKyw^qVPOD z-taW!Sun=(l3n^gOCKz}nc?|o-?b4QGp5XAF3^*`dV!wwFo9kSGx2!@&w7;|d@F`V zu~p_+`xkn0f4`yU9(qz^WqyR)XF0>Jq14PDdj_9-27me){Do)m*NC5w#mwJO-@g{e zn67xtY`hrAza`^74VB+|DQ2FAel9GSgbygubznY}Sd zYh-%%=IvLVv1^laSDne5SDdRiXJ-H6HEQ@7DQ&LMzfQ082eHFR4)-Jn?Y85P)s)t# z8%`?;0x%FG;s2mbNf@3qt7LxCtO3`78^BHA7BEEtoHPf3J-}YzFmM7m16%+u16P2n zz%}4Ha09pr+ybV^uhc%U2iOZ722KEHfD6E7;0kaRxCUGYZU8rdTfkI1+6VRkdx68i z3E&KH0k{lY0j>hqfa|~w;3jYjn4$$u_5*u>y})7M1aJnp09*#H09S!)z;)mTa1*!% zOwo2s?E`y&y})7M1aJnp09*#H09S!)z;)mTa1*!%Or_C2um{)+90pDRXMhX9W#9^M z6}Sdm2W|j2fm^^-2igbr0DFPMzzN_CZ~?dsTmh~E*MRH54d5nl3z(v%O8x=%0DFPM zzzN_CZ~?dsTmh~E*MRH54d5nl3z*u6_JKXXUf?ir0yqO)04@VpfUCeY;5u*vxCz_> zrm(pj0QLZTfy2NF;0$m9xC~qYt^(J9>%a}*CU6UwdJgsjdw{*bVc-OC2DkuR2Ce{C zfos5Z;0ACLxCKnn`APl<_5gcy})7M1aJnp09+>Q zGAo2T)8f+KEiL`*Zl4PCQmwYHc@_zm8BR5s;m{n3-g zlSlPx8B{#cdGJKz#KF#l-WxOd#Y`r%nD>S^Ey+wzdrf?sXM>XH`R%EHMW!ya1I|$j zI;1OGx{>y}=SH$_!_9_!tyZi4fQUab zGr4(ci;~VysV3?*ZIk3gK9NY&N}`|c&KK`B$mD|}H)t}RhRSm;$u&x<-=O+3X3;Nk zQK+2ri&Q^7FXcQm$_3_ovNv3qM_!|wnkKSbjc3B;G9Iy%Qu}EdUCA4xgt zKdjZJdqw7+(4F?j!H1;nA4D`z{HQ;^q^{=Ysnai|{v#L3@2~c|MuVo4lD7Zl)rzzlOXPHs*_ZHvj=xd+j3@7|7k_zKF4?S>^A2_^*X{3Dd09T`G|G84rQHbR zO`3vZN6CD;YgrU#M}?mjFhI|WLu=`@SJ3^Lvl+ot8MJ<=-{k>!k}c~BX;JTGCH$=sO)zZUcB ztL&e#Dx*G!XIN%3_Whyl`zWP*58bfBGSi8ncej78<$R2XWfIfRJ6X2hPx`apReDSASuz_z7PJPJbk^jWD{#iq|*uU7nQZPf5(!koKh_2 z)i<$M-hBO~_KrP=bh@byTKwiQa|{g#jX9DpB*Vi=c8lZ< zkK0Qhd_L28LiQ7uP5hIkZR*5dzbXgoU&^72^&gU%%%3{s6sooAtv;xT{Lf7?tv@bj zBSl|iS~Hz3vBP}_QI*$QSeEuoyp7gS3#NoM!ZJ4XP&sPEUU=b$fA#67Pv=c*Yl>dE z1hO>P^1@46ZZMC5?6|JueD{0)dUK|2nHOtUW*?82?I&w2nRnTETiaj4pXiI%d7^#a z7fVY^|JW$$e&PF1_X}SpQ)RzUbupKApuRy!!@i<4E59!jrx8$lIU1^T!XD%tgLJb`m(rqBbCEA~Ro}-!*Z?3xju;N;itw|G}pP*3oVfq1~ zT=*n3KgaF)qi}fTZusNQ+V;gf$;Ak#Xa=qB1!Msz3q;QDMfKof;a69`pUiE@w1?MsEA(bAkQ=L zhUULd&jHO}r04sZpQh&}&3{DC+nWEBo?eiCLHT+5a9W|y737Th`%wNTl>ae(*sPz^ zXM{eS?$hTUeVG4O`h2DNLqu$8{(F?CT?Z*kdCymWN_lVL3{ZZEKJ?$bOR%i^=AHBB z#?SSi9lSI;cxq^DeDtC@J3DuKa$(Xrb#3y)4<|3v4t2Xd4F)|)ah}dM$Oon{&VBz-0a+q$)Xt>9DjdkVEnWcn*M=- zOJm~~&kTw@GIU|^%%!oRi9s`Re(2n|WJd?b&YyX2eCYhSOBYN?xM)tAv623hL+4JJ z{y!TW?LRem35}bfv7yl+zD%2wr~5~#&tOci`_$mMljjGx?zj4l=j8d3i=#X&9i6#w z=`@CE-hHosK>KAE8ZXoXOW|S9|13z1a%`qegJRf;;0h6(YjJx~w`_4q^B>e+MY%ZL z8@)AAwe)12)O{|{g9JeQR%T`_CDi$Yot5#j%>K505 z@v=c;ANL`gqg)K*O`HED9~7E6_Ot8P4c0?Bf~)u(_mM!q)rj`$5gh$YYlt?UEtp^B z_#U4$?dB=l7s0s}mxNx~;-qfH;!+rIHG-@ATrgfk=MdW$r*Zl5r<~Z_VZLVjloOjJ z)?AB|-KA`CVoSy1B*v@C#Y`*ajr*u87q-RFkIp;nQ%?4C^`CNLvv96omrsK|_?wBc zUzdH~X11u`igGQalO%h1j;fYk3S8adWE|u+*k{eJa^fq|D@1T^1XqsWDiK^Yf~!Yx zG(^}Jw#89S#w&AFP%aK1$ar1lWNf;>SX{g8FBT_yRpr9{)-6u-$l*Kfi{J_ooEyQF zBe+TgSB>E65gaYgo$;q!cx;6T&W+&85nLsLt44732#ybUULT$O0Gwf3?y!Ks7Pvb8_uVU$Sn#a6;eU48aIyflRt-2l1 z<1d1N|Jt$69gEZTYjL9ITAb*WEl%_*%7y)0ZPH^4>lUZ`3;hzkWB*gmYme&|lneXR zji_6;^whoxt{TDBn>cutw*9dGm~)yq%x?teDkt|6^}%p+ zpK_j0nRAtseNyd<(5qPOb>MqQ)#7B2tt%(@Cb^gJmjSjfMp4T57rv`F%JIqQaRue% z%%hEplH0_w@5>gq7wuInPWr7{oU~VO;xNDTOT74xZAprK7N_?sixWN9;zX}(aiUkT zIJM8>+R<;_;-s#jU-HBDao({wwJ(Bmn>empwzy95Uj$dRIGMM)#YtWM(iqsM^Q)Z1 zfp7&&PyJ_c>OYIq`L(!qiY40rEKYX7y3d8~fApT4?Q1c7|7%5EM>$ywvhNm@^Y&+s zQ`ge#K;5!(vJdI~PdV#;<+sOoF1b_JeNOJ8+=rnr{A^#iUq`tZY?ga*!RPp1my+)v z%E{Q;FqdWJ#J;5YhWe;9anzluMsRhjJ-Pds7j64^-*A)*?(}DwVnC^G zaT53Zwl|1BT_4IxzhX;4IcxuG;;{c&oURXxQ~NAVzK7N$IP;R&=k?3BIu@6P{RQP@ zO-tOn7AN~b+2Y!;W-1n!23L*X>dJ{NZRpn=2;0{I&apVrD_ES^>{^`oz8t|-EN(CQ zs9K!9KWO5xeqRpTC;d7Wr~9A9iLYFX6Tg&|lk-yFA6R-Ru}?Xf57`sz%C%60^Bw{F z==T+#Q*VAbh8*R>drl#ObCt8!M+8^#IbK_`-l~3kye@^SD<`(d9%kq->jV4Z_zvqR z=iN(q90gxb);V*o&+&LQ{w%H?ZC5N#&WftV?SWohIoWsh{!BlZuzkYC5xb6Z-aA;n zj~6VxPV{cvJd|I_Q^`CMh^q!O6G+wx%nQtpglrrw7T@UPfVAlh? m9@zE3t_OBKuw*7|9{4YmiE4}h diff --git a/runtime/doc/farsi.txt b/runtime/doc/farsi.txt index 493714e4d6..27298593f0 100644 --- a/runtime/doc/farsi.txt +++ b/runtime/doc/farsi.txt @@ -1,4 +1,4 @@ -*farsi.txt* For Vim version 8.1. Last change: 2015 Aug 29 +*farsi.txt* For Vim version 8.1. Last change: 2019 Feb 16 VIM REFERENCE MANUAL by Mortaza Ghassab Shiran @@ -9,261 +9,12 @@ Right to Left and Farsi Mapping for Vim *farsi* *Farsi* {Vi does not have any of these commands} *E27* -In order to use right-to-left and Farsi mapping support, it is necessary to -compile Vim with the |+farsi| feature. +Farsi support has been removed in patch 8.1.0932. At that time it was +outdated and unused. -These functions have been made by Mortaza G. Shiran +If you would like to bring Farsi support back, please have a look at the old +Farsi code, as it was present at the 8.1 release. It should be merged with +Arabic support using the Unicode character set. -Introduction ------------- -In right-to-left oriented files the characters appear on the screen from right -to left. This kind of file is most useful when writing Farsi documents, -composing faxes or writing Farsi memos. - -The commands, prompts and help files are not in Farsi, therefore the user -interface remains the standard Vi interface. - - -Highlights ----------- -o Editing left-to-right files as in the original Vim, no change. - -o Viewing and editing files in right-to-left windows. File orientation is - per window, so it is possible to view the same file in right-to-left and - left-to-right modes, simultaneously. - -o Compatibility to the original Vim. Almost all features work in - right-to-left mode (see bugs below). - -o Changing keyboard mapping and reverse insert modes using a single - command. - -o Backing from reverse insert mode to the correct place in the file - (if possible). - -o While in Farsi mode, numbers are entered from left to right. Upon entering - a none number character, that character will be inserted just into the - left of the last number. - -o No special terminal with right-to-left capabilities is required. The - right-to-left changes are completely hardware independent. Only - Farsi font is necessary. - -o Farsi keymapping on the command line in reverse insert mode. - -o Toggling between left-to-right and right-to-left via F8 function key. - -o Toggling between Farsi ISIR-3342 standard encoding and Vim Farsi via F9 - function key. Since this makes sense only for the text written in - right-to-left mode, this function is also supported only in right-to-left - mode. - -Farsi Fonts *farsi-fonts* ------------ - -The following files are found in the subdirectories of the '$VIM/farsi/fonts' -directory: - - + far-a01.pcf X Windows fonts for Unix including Linux systems - + far-a01.bf X Windows fonts for SunOS - + far-a01.f16 a screen fonts for Unix including Linux systems - + far-a01.fon a monospaced fonts for Windows NT/95/98 - + far-a01.com a screen fonts for DOS - - -Font Installation ------------------ - -o Installation of fonts for MS Window systems (NT/95/98) - - From 'Control Panel' folder, start the 'Fonts' program. Then from 'file' - menu item select 'Install New Fonts ...'. Browse and select the - 'far-a01.fon', then follow the installation guide. - NOTE: several people have reported that this does not work. The solution - is unknown. - -o Installation of fonts for X Window systems (Unix/Linux) - - Depending on your system, copy far-a01.pcf.Z or far-a01.pcf.gz into a - directory of your choice. Change to the directory containing the Farsi - fonts and execute the following commands: - - > mkfontdir - > xset +fp path_name_of_farsi_fonts_directory - -o Installation of fonts for X Window systems (SunOS) - - Copy far-a01.bf font into a directory of your choice. - Change to the directory containing the far-a01.fb fonts and - execute the following commands: - - > fldfamily - > xset +fp path_name_of_fonts_directory - -o Installation of ASCII screen fonts (Unix/Linux) - - For Linux system, copy the far-a01.f16 fonts into /usr/lib/kbd/consolefonts - directory and execute the setfont program as "setfont far-a01.f16". For - other systems (e.g. SCO Unix), please refer to the fonts installation - section of your system administration manuals. - -o Installation of ASCII screen fonts (DOS) - - After system power on, prior to the first use of Vim, upload the Farsi - fonts by executing the far-a01.com font uploading program. - - -Usage ------ -Prior to starting Vim, the environment in which Vim can run in Farsi mode, -must be set. In addition to installation of Farsi fonts, following points -refer to some of the system environments, which you may need to set: -Key code mapping, loading graphic card in ASCII screen mode, setting the IO -driver in 8 bit clean mode ... . - -o Setting the Farsi fonts - - + For Vim GUI set the 'guifont' to far-a01. This is done by entering - ':set guifont=far-a01' in the Vim window. - - You can have 'guifont' set to far-a01 by Vim during the Vim startup - by appending the ':set guifont=far-a01' into your .vimrc file - (in case of NT/95/98 platforms _vimrc). - - Under the X Window environment, you can also start Vim with the - '-fn far-a01' option. - - + For Vim within a xterm, start a xterm with the Farsi fonts (e.g. - kterm -fn far-a01). Then start Vim inside the kterm. - - + For Vim under DOS, prior to the first usage of Vim, upload the Farsi - fonts by executing the far-a01.com fonts uploading program. - -o Farsi Keymapping Activation - - To activate the Farsi keymapping, set either 'altkeymap' or 'fkmap'. - This is done by entering ':set akm' or ':set fk' in the Vim window. - You can have 'altkeymap' or 'fkmap' set as default by appending ':set akm' - or ':set fk' in your .vimrc file or _vimrc in case of NT/95/98 platforms. - - To turn off the Farsi keymapping as a default second language keymapping, - reset the 'altkeymap' by entering ':set noakm'. - -o right-to-left Farsi Mode - - By default Vim starts in Left-to-right mode. Following are ways to change - the window orientation: - - + Start Vim with the -F option (e.g. vim -F ...). - - + Use the F8 function key to toggle between left-to-right and right-to-left. - - + While in Left-to-right mode, enter 'set rl' in the command line ('rl' is - the abbreviation for rightleft). - - + Put the 'set rl' line in your '.vimrc' file to start Vim in - right-to-left mode permanently. - -Encoding --------- - -The letter encoding used is the Vim extended ISIR-3342 standard with a built -in function to convert between Vim extended ISIR-3342 and ISIR-3342 standard. - -For document portability reasons, the letter encoding is kept the same across -different platforms (i.e. UNIX's, NT/95/98, MS DOS, ...). - - -o Keyboard - - + CTRL-_ in insert/replace modes toggles between Farsi(akm)/Latin - mode as follows: - - + CTRL-_ moves the cursor to the end of the typed text in edit mode. - - + CTRL-_ in command mode only toggles keyboard mapping between Farsi(akm)/ - Latin. The Farsi text is then entered in reverse insert mode. - - + F8 - Toggles between left-to-right and right-to-left. - - + F9 - Toggles the encoding between ISIR-3342 standard and Vim extended - ISIR-3342 (supported only in right-to-left mode). - - + Keyboard mapping is based on the Iranian ISIRI-2901 standard. - Following table shows the keyboard mapping while Farsi(akm) mode set: - - ------------------------------------- - ` 1 2 3 4 5 6 7 8 9 0 - = - ¢ ± ² ³ ´ µ ¶ · ¸ ¹ ° ­ ½ - ------------------------------------- - ~ ! @ # $ % ^ & * ( ) _ + - ~ £ § ® ¤ ¥ ª ¬ è ¨ © é « - ------------------------------------- - q w e r t z u i o p [ ] - Ó Ò Æ Ù Ø Õ Ö à Ê É Ç ˆ - ------------------------------------- - Q W E R T Z U I O P { } - ÷ õ ô ó ò ý ð ö [ ] { } - ------------------------------------- - a s d f g h j k l ; ' \ - Ñ Ð á Ã Ü Á Å Þ Ý Ú Û ë - ------------------------------------- - A S D F G H J K L : " | - ù û  þ ú ø À ü æ ç º » ê - ------------------------------------- - < y x c v b n m , . / - ¾ × Ô Î Í Ì Ë Ä ß ¦ ¯ - ------------------------------------- - > Y X C V B N M < > ? - ¼ ñ Ô Ï Í ¡ Ë Â ¾ ¼ ¿ - ------------------------------------- - -Note: - ¡ stands for Farsi PSP (break without space) - - ¢ stands for Farsi PCN (for HAMZE attribute) - -Restrictions ------------- - -o In insert/replace mode and fkmap (Farsi mode) set, CTRL-B is not - supported. - -o If you change the character mapping between Latin/Farsi, the redo buffer - will be reset (emptied). That is, redo is valid and will function (using - '.') only within the mode you are in. - -o While numbers are entered in Farsi mode, the redo buffer will be reset - (emptied). That is, you cannot redo the last changes (using '.') after - entering numbers. - -o While in left-to-right mode and Farsi mode set, CTRL-R is not supported. - -o While in right-to-left mode, the search on 'Latin' pattern does not work, - except if you enter the Latin search pattern in reverse. - -o In command mode there is no support for entering numbers from left - to right and also for the sake of flexibility the keymapping logic is - restricted. - -o Under the X Window environment, if you want to run Vim within a xterm - terminal emulator and Farsi mode set, you need to have an ANSI compatible - xterm terminal emulator. This is because the letter codes above 128 decimal - have certain meanings in the standard xterm terminal emulator. - - Note: Under X Window environment, Vim GUI works fine in Farsi mode. - This eliminates the need of any xterm terminal emulator. - - -Bugs ----- -While in insert/replace and Farsi mode set, if you repeatedly change the -cursor position (via cursor movement) and enter new text and then try to undo -the last change, the undo will lag one change behind. But as you continue to -undo, you will reach the original line of text. You can also use U to undo all -changes made in the current line. - -For more information about the bugs refer to rileft.txt. - vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 3b62c0f530..e664c96217 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -688,13 +688,8 @@ A jump table for the options with a short description can be found at |Q_op|. {not in Vi} {only available when compiled with the |+farsi| feature} - When on, the second language is Farsi. In editing mode CTRL-_ toggles - the keyboard map between Farsi and English, when 'allowrevins' set. - - When off, the keyboard map toggles between Hebrew and English. This - is useful to start the Vim in native mode i.e. English (left-to-right - mode) and have default second language Farsi or Hebrew (right-to-left - mode). See |farsi.txt|. + This option was for using Farsi, which has been removed. See + |farsi.txt|. *'ambiwidth'* *'ambw'* 'ambiwidth' 'ambw' string (default: "single") @@ -3301,9 +3296,8 @@ A jump table for the options with a short description can be found at |Q_op|. {not in Vi} {only available when compiled with the |+rightleft| feature} - When on, the keyboard is mapped for the Farsi character set. - Normally you would set 'allowrevins' and use CTRL-_ in insert mode to - toggle this option |i_CTRL-_|. See |farsi.txt|. + This option was for using Farsi, which has been removed. See + |farsi.txt|. *'foldclose'* *'fcl'* 'foldclose' 'fcl' string (default "") diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 75f400f6d7..4c6e249e8a 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -600,7 +600,6 @@ In Insert or Command-line mode: Short explanation of each option: *option-list* 'aleph' 'al' ASCII code of the letter Aleph (Hebrew) 'allowrevins' 'ari' allow CTRL-_ in Insert and Command-line mode -'altkeymap' 'akm' for default second language (Farsi/Hebrew) 'ambiwidth' 'ambw' what to do with Unicode chars of ambiguous width 'antialias' 'anti' Mac OS X: use smooth, antialiased fonts 'autochdir' 'acd' change directory to the file in the current window @@ -700,7 +699,6 @@ Short explanation of each option: *option-list* 'filetype' 'ft' type of file, used for autocommands 'fillchars' 'fcs' characters to use for displaying special items 'fixendofline' 'fixeol' make sure last line in file has -'fkmap' 'fk' Farsi keyboard mapping 'foldclose' 'fcl' close a fold when the cursor leaves it 'foldcolumn' 'fdc' width of the column used to indicate folds 'foldenable' 'fen' set to display all folds open diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 6289e9c8f7..9f6472670c 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -321,9 +321,8 @@ a slash. Thus "-R" means recovery and "-/R" readonly. and exits.) {not in Vi} *-F* --F Farsi mode. Sets the 'fkmap' and 'rightleft' options on. - (Only when compiled with |+rightleft| and |+farsi| features, - otherwise Vim gives an error message and exits.) {not in Vi} +-F This was used for Farsi mode, which has been removed. + See |farsi.txt|. *-H* -H Hebrew mode. Sets the 'hkmap' and 'rightleft' options on. diff --git a/src/Make_bc5.mak b/src/Make_bc5.mak index eb38dd7ccd..30fe727b2e 100644 --- a/src/Make_bc5.mak +++ b/src/Make_bc5.mak @@ -542,7 +542,6 @@ vimobj = \ $(OBJDIR)\ex_docmd.obj \ $(OBJDIR)\ex_eval.obj \ $(OBJDIR)\ex_getln.obj \ - $(OBJDIR)\farsi.obj \ $(OBJDIR)\fileio.obj \ $(OBJDIR)\findfile.obj \ $(OBJDIR)\fold.obj \ diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak index 48ce3974d6..f6ae85316f 100644 --- a/src/Make_cyg_ming.mak +++ b/src/Make_cyg_ming.mak @@ -714,7 +714,6 @@ OBJ = \ $(OUTDIR)/ex_docmd.o \ $(OUTDIR)/ex_eval.o \ $(OUTDIR)/ex_getln.o \ - $(OUTDIR)/farsi.o \ $(OUTDIR)/fileio.o \ $(OUTDIR)/findfile.o \ $(OUTDIR)/fold.o \ @@ -1005,7 +1004,7 @@ endif $(MAKE) -C tee clean ########################################################################### -INCL = vim.h alloc.h arabic.h ascii.h ex_cmds.h farsi.h feature.h globals.h \ +INCL = vim.h alloc.h arabic.h ascii.h ex_cmds.h feature.h globals.h \ keymap.h macros.h option.h os_dos.h os_win32.h proto.h regexp.h \ spell.h structs.h term.h beval.h $(NBDEBUG_INCL) GUI_INCL = gui.h diff --git a/src/Make_dice.mak b/src/Make_dice.mak index ffce805d3c..2025974fc5 100644 --- a/src/Make_dice.mak +++ b/src/Make_dice.mak @@ -44,7 +44,6 @@ SRC = \ ex_docmd.c \ ex_eval.c \ ex_getln.c \ - farsi.c \ fileio.c \ findfile.c \ fold.c \ @@ -104,7 +103,6 @@ OBJ = o/arabic.o \ o/ex_docmd.o \ o/ex_eval.o \ o/ex_getln.o \ - o/farsi.o \ o/fileio.o \ o/findfile.o \ o/fold.o \ @@ -201,8 +199,6 @@ o/ex_eval.o: ex_eval.c $(SYMS) ex_cmds.h o/ex_getln.o: ex_getln.c $(SYMS) -o/farsi.o: farsi.c $(SYMS) - o/fileio.o: fileio.c $(SYMS) o/findfile.o: findfile.c $(SYMS) diff --git a/src/Make_ivc.mak b/src/Make_ivc.mak index a02ba960f1..26367e096b 100644 --- a/src/Make_ivc.mak +++ b/src/Make_ivc.mak @@ -228,7 +228,6 @@ LINK32_OBJS= \ "$(INTDIR)/ex_docmd.obj" \ "$(INTDIR)/ex_eval.obj" \ "$(INTDIR)/ex_getln.obj" \ - "$(INTDIR)/farsi.obj" \ "$(INTDIR)/fileio.obj" \ "$(INTDIR)/findfile.obj" \ "$(INTDIR)/fold.obj" \ @@ -413,10 +412,6 @@ SOURCE=.\ex_getln.c # End Source File # Begin Source File -SOURCE=.\farsi.c -# End Source File -# Begin Source File - SOURCE=.\fileio.c # End Source File # Begin Source File diff --git a/src/Make_manx.mak b/src/Make_manx.mak index 5314a86a13..2cbc3df6aa 100644 --- a/src/Make_manx.mak +++ b/src/Make_manx.mak @@ -54,7 +54,6 @@ SRC = arabic.c \ ex_docmd.c \ ex_eval.c \ ex_getln.c \ - farsi.c \ fileio.c \ findfile.c \ fold.c \ @@ -116,7 +115,6 @@ OBJ = obj/arabic.o \ obj/ex_docmd.o \ obj/ex_eval.o \ obj/ex_getln.o \ - obj/farsi.o \ obj/fileio.o \ obj/findfile.o \ obj/fold.o \ @@ -176,7 +174,6 @@ PRO = proto/arabic.pro \ proto/ex_docmd.pro \ proto/ex_eval.pro \ proto/ex_getln.pro \ - proto/farsi.pro \ proto/fileio.pro \ proto/findfile.pro \ proto/fold.pro \ @@ -317,9 +314,6 @@ obj/ex_eval.o: ex_eval.c ex_cmds.h obj/ex_getln.o: ex_getln.c $(CCSYM) $@ ex_getln.c -obj/farsi.o: farsi.c - $(CCSYM) $@ farsi.c - obj/fileio.o: fileio.c $(CCSYM) $@ fileio.c diff --git a/src/Make_morph.mak b/src/Make_morph.mak index a6e0dae178..af231fb7b5 100644 --- a/src/Make_morph.mak +++ b/src/Make_morph.mak @@ -42,7 +42,6 @@ SRC = arabic.c \ ex_docmd.c \ ex_eval.c \ ex_getln.c \ - farsi.c \ fileio.c \ findfile.c \ fold.c \ diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index c948f37719..c81fbd2961 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -694,7 +694,7 @@ CFLAGS = $(CFLAGS) /Zl /MTd !include Make_all.mak !include testdir\Make_all.mak -INCL = vim.h alloc.h arabic.h ascii.h ex_cmds.h farsi.h feature.h globals.h \ +INCL = vim.h alloc.h arabic.h ascii.h ex_cmds.h feature.h globals.h \ keymap.h macros.h option.h os_dos.h os_win32.h proto.h regexp.h \ spell.h structs.h term.h beval.h $(NBDEBUG_INCL) @@ -719,7 +719,6 @@ OBJ = \ $(OUTDIR)\ex_docmd.obj \ $(OUTDIR)\ex_eval.obj \ $(OUTDIR)\ex_getln.obj \ - $(OUTDIR)\farsi.obj \ $(OUTDIR)\fileio.obj \ $(OUTDIR)\findfile.obj \ $(OUTDIR)\fold.obj \ @@ -1404,8 +1403,6 @@ $(OUTDIR)/ex_eval.obj: $(OUTDIR) ex_eval.c $(INCL) $(OUTDIR)/ex_getln.obj: $(OUTDIR) ex_getln.c $(INCL) -$(OUTDIR)/farsi.obj: $(OUTDIR) farsi.c $(INCL) - $(OUTDIR)/fileio.obj: $(OUTDIR) fileio.c $(INCL) $(OUTDIR)/findfile.obj: $(OUTDIR) findfile.c $(INCL) @@ -1646,7 +1643,6 @@ proto.h: \ proto/ex_docmd.pro \ proto/ex_eval.pro \ proto/ex_getln.pro \ - proto/farsi.pro \ proto/fileio.pro \ proto/findfile.pro \ proto/getchar.pro \ diff --git a/src/Make_sas.mak b/src/Make_sas.mak index deaa5eb5d6..6ba00fbd67 100644 --- a/src/Make_sas.mak +++ b/src/Make_sas.mak @@ -107,7 +107,6 @@ SRC = \ ex_docmd.c \ ex_eval.c \ ex_getln.c \ - farsi.c \ fileio.c \ findfile.c \ fold.c \ @@ -168,7 +167,6 @@ OBJ = \ ex_docmd.o \ ex_eval.o \ ex_getln.o \ - farsi.o \ fileio.o \ findfile.o \ fold.o \ @@ -229,7 +227,6 @@ PRO = \ proto/ex_docmd.pro \ proto/ex_eval.pro \ proto/ex_getln.pro \ - proto/farsi.pro \ proto/fileio.pro \ proto/findfile.pro \ proto/fold.pro \ @@ -362,8 +359,6 @@ ex_eval.o: ex_eval.c ex_cmds.h proto/ex_eval.pro: ex_eval.c ex_cmds.h ex_getln.o: ex_getln.c proto/ex_getln.pro: ex_getln.c -farsi.o: farsi.c -proto/farsi.pro: farsi.c fileio.o: fileio.c proto/fileio.pro: fileio.c findfile.o: findfile.c diff --git a/src/Make_vms.mms b/src/Make_vms.mms index 92f5ab12ef..d40c82022d 100644 --- a/src/Make_vms.mms +++ b/src/Make_vms.mms @@ -2,7 +2,7 @@ # Makefile for Vim on OpenVMS # # Maintainer: Zoltan Arpadffy -# Last change: 2019 Jan 18 +# Last change: 2019 Feb 16 # # This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64 # with MMS and MMK @@ -315,7 +315,7 @@ ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \ SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c charset.c \ crypt.c crypt_zip.c dict.c diff.c digraph.c edit.c eval.c evalfunc.c \ ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c if_cscope.c \ - if_xcmdsrv.c farsi.c fileio.c findfile.c fold.c getchar.c hardcopy.c \ + if_xcmdsrv.c fileio.c findfile.c fold.c getchar.c hardcopy.c \ hashtab.c indent.c json.c list.c main.c mark.c menu.c mbyte.c \ memfile.c memline.c message.c misc1.c misc2.c move.c normal.c ops.c \ option.c popupmnu.c quickfix.c regexp.c search.c sha256.c sign.c \ @@ -328,7 +328,7 @@ SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c charset.c \ OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj \ charset.obj crypt.obj crypt_zip.obj dict.obj diff.obj digraph.obj \ edit.obj eval.obj evalfunc.obj ex_cmds.obj ex_cmds2.obj ex_docmd.obj \ - ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj farsi.obj \ + ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj \ fileio.obj findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \ indent.obj json.obj list.obj main.obj mark.obj menu.obj memfile.obj \ memline.obj message.obj misc1.obj misc2.obj move.obj mbyte.obj \ @@ -514,279 +514,278 @@ blob.obj : blob.c vim.h [.auto]config.h feature.h os_unix.h buffer.obj : buffer.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h charset.obj : charset.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h crypt.obj : crypt.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h crypt_zip.obj : crypt_zip.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h dict.obj : dict.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h diff.obj : diff.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h digraph.obj : digraph.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h edit.obj : edit.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h eval.obj : eval.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h version.h evalfunc.obj : evalfunc.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h ex_cmds.obj : ex_cmds.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h ex_cmds2.obj : ex_cmds2.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h ex_docmd.obj : ex_docmd.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h ex_eval.obj : ex_eval.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h ex_getln.obj : ex_getln.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h -farsi.obj : farsi.c vim.h + globals.h arabic.h fileio.obj : fileio.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h findfile.obj : findfile.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h fold.obj : fold.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h getchar.obj : getchar.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h hardcopy.obj : hardcopy.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h hashtab.obj : hashtab.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h if_cscope.obj : if_cscope.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h if_cscope.h + globals.h arabic.h if_cscope.h if_xcmdsrv.obj : if_xcmdsrv.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h if_mzsch.obj : if_mzsch.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro ex_cmds.h proto.h \ - globals.h farsi.h arabic.h if_mzsch.h + globals.h arabic.h if_mzsch.h indent.obj : indent.c vim.h [.auto]config.h feature.h os_unix.h json.obj : json.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h version.h list.obj : list.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h main.obj : main.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ - arabic.h farsi.c arabic.c + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ + arabic.h arabic.c mark.obj : mark.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h memfile.obj : memfile.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h memline.obj : memline.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h menu.obj : menu.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h message.obj : message.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h misc1.obj : misc1.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h version.h misc2.obj : misc2.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h move.obj : move.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h mbyte.obj : mbyte.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h normal.obj : normal.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h ops.obj : ops.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h option.obj : option.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h os_unix.obj : os_unix.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h os_unixx.h + globals.h arabic.h os_unixx.h os_vms.obj : os_vms.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h os_unixx.h + globals.h arabic.h os_unixx.h pathdef.obj : pathdef.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h popupmnu.obj : popupmnu.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h quickfix.obj : quickfix.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h regexp.obj : regexp.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h screen.obj : screen.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h search.obj : search.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h sha256.obj : sha256.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h sign.obj : sign.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h spell.obj : spell.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h spellfile.obj : spellfile.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h syntax.obj : syntax.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h tag.obj : tag.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h term.obj : term.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h termlib.obj : termlib.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h textprop.obj : textprop.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h ui.obj : ui.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h undo.obj : undo.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h userfunc.obj : userfunc.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h version.obj : version.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h window.obj : window.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h gui.obj : gui.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h gui_gtk.obj : gui_gtk.c gui_gtk_f.h vim.h [.auto]config.h feature.h \ os_unix.h ascii.h keymap.h term.h macros.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h \ - proto.h globals.h farsi.h arabic.h [-.pixmaps]stock_icons.h + proto.h globals.h arabic.h [-.pixmaps]stock_icons.h gui_gtk_f.obj : gui_gtk_f.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h gui_gtk_f.h + globals.h arabic.h gui_gtk_f.h gui_motif.obj : gui_motif.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h [-.pixmaps]alert.xpm [-.pixmaps]error.xpm \ + globals.h arabic.h [-.pixmaps]alert.xpm [-.pixmaps]error.xpm \ [-.pixmaps]generic.xpm [-.pixmaps]info.xpm [-.pixmaps]quest.xpm gui_athena.obj : gui_athena.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h gui_at_sb.h + globals.h arabic.h gui_at_sb.h gui_gtk_x11.obj : gui_gtk_x11.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h gui_gtk_f.h [-.runtime]vim32x32.xpm \ + globals.h arabic.h gui_gtk_f.h [-.runtime]vim32x32.xpm \ [-.runtime]vim16x16.xpm [-.runtime]vim48x48.xpm gui_x11.obj : gui_x11.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h [-.runtime]vim32x32.xpm \ + globals.h arabic.h [-.runtime]vim32x32.xpm \ [-.runtime]vim16x16.xpm [-.runtime]vim48x48.xpm [-.pixmaps]tb_new.xpm \ [-.pixmaps]tb_open.xpm [-.pixmaps]tb_close.xpm [-.pixmaps]tb_save.xpm \ [-.pixmaps]tb_print.xpm [-.pixmaps]tb_cut.xpm [-.pixmaps]tb_copy.xpm \ @@ -806,60 +805,60 @@ gui_x11.obj : gui_x11.c vim.h [.auto]config.h feature.h os_unix.h \ gui_at_sb.obj : gui_at_sb.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h gui_at_sb.h + globals.h arabic.h gui_at_sb.h gui_at_fs.obj : gui_at_fs.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h gui_at_sb.h + globals.h arabic.h gui_at_sb.h pty.obj : pty.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \ - [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ + [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \ arabic.h hangulin.obj : hangulin.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h if_perl.obj : [.auto]if_perl.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h if_perlsfio.obj : if_perlsfio.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h if_python.obj : if_python.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h if_tcl.obj : if_tcl.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h if_ruby.obj : if_ruby.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h beval.obj : beval.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h gui_beval.obj : gui_beval.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h + globals.h arabic.h workshop.obj : workshop.c [.auto]config.h integration.h vim.h feature.h \ os_unix.h ascii.h keymap.h term.h macros.h structs.h \ regexp.h gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h \ - proto.h globals.h farsi.h arabic.h version.h workshop.h + proto.h globals.h arabic.h version.h workshop.h wsdebug.obj : wsdebug.c integration.obj : integration.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h integration.h + globals.h arabic.h integration.h netbeans.obj : netbeans.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ - globals.h farsi.h arabic.h version.h + globals.h arabic.h version.h gui_xmdlg.obj : gui_xmdlg.c [.auto]config.h vim.h feature.h os_unix.h gui_xmebw.obj : gui_xmebw.c [.auto]config.h vim.h feature.h os_unix.h xdiffi.obj : [.xdiff]xdiffi.c [.xdiff]xinclude.h [.auto]config.h vim.h feature.h os_unix.h diff --git a/src/Makefile b/src/Makefile index 5575902a3d..be41f7725b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -492,9 +492,9 @@ CClink = $(CC) # MULTIBYTE - To edit multi-byte characters. # This is now always enabled. -# When building with at least "big" features, right-left, Arabic and Farsi +# When building with at least "big" features, right-left and Arabic # features are enabled. Use this to disable them. -#CONF_OPT_MULTIBYTE = --disable-rightleft --disable-farsi --disable-arabic +#CONF_OPT_MULTIBYTE = --disable-rightleft --disable-arabic # NLS - National Language Support # Uncomment this when you do not want to support translated messages, even @@ -1590,7 +1590,6 @@ BASIC_SRC = \ ex_docmd.c \ ex_eval.c \ ex_getln.c \ - farsi.c \ fileio.c \ findfile.c \ fold.c \ @@ -1704,7 +1703,6 @@ OBJ_COMMON = \ objects/ex_docmd.o \ objects/ex_eval.o \ objects/ex_getln.o \ - objects/farsi.o \ objects/fileio.o \ objects/findfile.o \ objects/fold.o \ @@ -1831,7 +1829,6 @@ PRO_AUTO = \ ex_docmd.pro \ ex_eval.pro \ ex_getln.pro \ - farsi.pro \ fileio.pro \ findfile.pro \ fold.pro \ @@ -2996,9 +2993,6 @@ objects/ex_eval.o: ex_eval.c objects/ex_getln.o: ex_getln.c $(CCC) -o $@ ex_getln.c -objects/farsi.o: farsi.c - $(CCC) -o $@ farsi.c - objects/fileio.o: fileio.c $(CCC) -o $@ fileio.c @@ -3392,290 +3386,286 @@ $(APPDIR)/Contents: objects/arabic.o: arabic.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/autocmd.o: autocmd.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/beval.o: beval.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/blob.o: blob.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/blowfish.o: blowfish.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/buffer.o: buffer.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/charset.o: charset.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/crypt.o: crypt.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/crypt_zip.o: crypt_zip.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/dict.o: dict.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/diff.o: diff.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h xdiff/xdiff.h vim.h + proto.h globals.h arabic.h xdiff/xdiff.h vim.h objects/digraph.o: digraph.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/edit.o: edit.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/eval.o: eval.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/evalfunc.o: evalfunc.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/ex_cmds.o: ex_cmds.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/ex_cmds2.o: ex_cmds2.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/ex_docmd.o: ex_docmd.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h ex_cmdidxs.h + proto.h globals.h arabic.h ex_cmdidxs.h objects/ex_eval.o: ex_eval.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/ex_getln.o: ex_getln.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h -objects/farsi.o: farsi.c vim.h protodef.h auto/config.h feature.h os_unix.h \ - auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ - proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/fileio.o: fileio.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/findfile.o: findfile.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h libvterm/include/vterm.h \ + proto.h globals.h arabic.h libvterm/include/vterm.h \ libvterm/include/vterm_keycodes.h objects/fold.o: fold.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/getchar.o: getchar.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/hardcopy.o: hardcopy.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/hashtab.o: hashtab.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/if_cscope.o: if_cscope.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h if_cscope.h + proto.h globals.h arabic.h if_cscope.h objects/if_xcmdsrv.o: if_xcmdsrv.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/indent.o: indent.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/json.o: json.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/list.o: list.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/main.o: main.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/mark.o: mark.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/memfile.o: memfile.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/memline.o: memline.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/menu.o: menu.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/message.o: message.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/misc1.o: misc1.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/misc2.o: misc2.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/move.o: move.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/mbyte.o: mbyte.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/normal.o: normal.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/ops.o: ops.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/option.o: option.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/os_unix.o: os_unix.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h os_unixx.h + proto.h globals.h arabic.h os_unixx.h objects/pathdef.o: auto/pathdef.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/popupmnu.o: popupmnu.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/pty.o: pty.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/quickfix.o: quickfix.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/regexp.o: regexp.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h regexp_nfa.c + proto.h globals.h arabic.h regexp_nfa.c objects/screen.o: screen.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/search.o: search.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/sha256.o: sha256.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/sign.o: sign.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/spell.o: spell.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/spellfile.o: spellfile.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/syntax.o: syntax.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/tag.o: tag.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/term.o: term.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h libvterm/include/vterm.h \ + proto.h globals.h arabic.h libvterm/include/vterm.h \ libvterm/include/vterm_keycodes.h objects/terminal.o: terminal.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h libvterm/include/vterm.h \ + proto.h globals.h arabic.h libvterm/include/vterm.h \ libvterm/include/vterm_keycodes.h objects/textprop.o: textprop.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/ui.o: ui.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/undo.o: undo.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/userfunc.o: userfunc.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/version.o: version.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/window.o: window.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/gui.o: gui.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/gui_gtk.o: gui_gtk.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_gtk_f.h + proto.h globals.h arabic.h gui_gtk_f.h objects/gui_gtk_f.o: gui_gtk_f.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_gtk_f.h + proto.h globals.h arabic.h gui_gtk_f.h objects/gui_motif.o: gui_motif.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_xmebw.h ../pixmaps/alert.xpm \ + proto.h globals.h arabic.h gui_xmebw.h ../pixmaps/alert.xpm \ ../pixmaps/error.xpm ../pixmaps/generic.xpm ../pixmaps/info.xpm \ ../pixmaps/quest.xpm gui_x11_pm.h ../pixmaps/tb_new.xpm \ ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm ../pixmaps/tb_save.xpm \ @@ -3696,15 +3686,15 @@ objects/gui_motif.o: gui_motif.c vim.h protodef.h auto/config.h feature.h \ objects/gui_xmdlg.o: gui_xmdlg.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/gui_xmebw.o: gui_xmebw.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_xmebwp.h gui_xmebw.h + proto.h globals.h arabic.h gui_xmebwp.h gui_xmebw.h objects/gui_athena.o: gui_athena.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_at_sb.h gui_x11_pm.h \ + proto.h globals.h arabic.h gui_at_sb.h gui_x11_pm.h \ ../pixmaps/tb_new.xpm ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm \ ../pixmaps/tb_save.xpm ../pixmaps/tb_print.xpm ../pixmaps/tb_cut.xpm \ ../pixmaps/tb_copy.xpm ../pixmaps/tb_paste.xpm ../pixmaps/tb_find.xpm \ @@ -3723,85 +3713,85 @@ objects/gui_athena.o: gui_athena.c vim.h protodef.h auto/config.h feature.h \ objects/gui_gtk_x11.o: gui_gtk_x11.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h auto/gui_gtk_gresources.h gui_gtk_f.h \ + proto.h globals.h arabic.h auto/gui_gtk_gresources.h gui_gtk_f.h \ ../runtime/vim32x32.xpm ../runtime/vim16x16.xpm ../runtime/vim48x48.xpm objects/gui_x11.o: gui_x11.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h ../runtime/vim32x32.xpm \ + proto.h globals.h arabic.h ../runtime/vim32x32.xpm \ ../runtime/vim16x16.xpm ../runtime/vim48x48.xpm objects/gui_at_sb.o: gui_at_sb.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_at_sb.h + proto.h globals.h arabic.h gui_at_sb.h objects/gui_at_fs.o: gui_at_fs.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h gui_at_sb.h + proto.h globals.h arabic.h gui_at_sb.h objects/json_test.o: json_test.c main.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h json.c + proto.h globals.h arabic.h json.c objects/kword_test.o: kword_test.c main.c vim.h protodef.h auto/config.h \ feature.h os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h \ option.h beval.h proto/gui_beval.pro structs.h regexp.h gui.h alloc.h \ - ex_cmds.h spell.h proto.h globals.h farsi.h arabic.h charset.c + ex_cmds.h spell.h proto.h globals.h arabic.h charset.c objects/memfile_test.o: memfile_test.c main.c vim.h protodef.h auto/config.h \ feature.h os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h \ option.h beval.h proto/gui_beval.pro structs.h regexp.h gui.h alloc.h \ - ex_cmds.h spell.h proto.h globals.h farsi.h arabic.h memfile.c + ex_cmds.h spell.h proto.h globals.h arabic.h memfile.c objects/message_test.o: message_test.c main.c vim.h protodef.h auto/config.h \ feature.h os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h \ option.h beval.h proto/gui_beval.pro structs.h regexp.h gui.h alloc.h \ - ex_cmds.h spell.h proto.h globals.h farsi.h arabic.h message.c + ex_cmds.h spell.h proto.h globals.h arabic.h message.c objects/hangulin.o: hangulin.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/if_lua.o: if_lua.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/if_mzsch.o: if_mzsch.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h if_mzsch.h + proto.h globals.h arabic.h if_mzsch.h objects/if_perl.o: auto/if_perl.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/if_perlsfio.o: if_perlsfio.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/if_python.o: if_python.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h if_py_both.h + proto.h globals.h arabic.h if_py_both.h objects/if_python3.o: if_python3.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h if_py_both.h + proto.h globals.h arabic.h if_py_both.h objects/if_tcl.o: if_tcl.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/if_ruby.o: if_ruby.c protodef.h auto/config.h vim.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/gui_beval.o: gui_beval.c vim.h protodef.h auto/config.h feature.h \ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/netbeans.o: netbeans.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h version.h + proto.h globals.h arabic.h version.h objects/channel.o: channel.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h farsi.h arabic.h + proto.h globals.h arabic.h objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c objects/encoding.o: libvterm/src/encoding.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ @@ -3833,7 +3823,7 @@ objects/xdiffi.o: xdiff/xdiffi.c xdiff/xinclude.h auto/config.h \ macros.h option.h beval.h proto/gui_beval.pro \ structs.h regexp.h gui.h alloc.h \ ex_cmds.h spell.h proto.h globals.h \ - farsi.h arabic.h xdiff/xtypes.h xdiff/xutils.h \ + arabic.h xdiff/xtypes.h xdiff/xutils.h \ xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h objects/xemit.o: xdiff/xemit.c xdiff/xinclude.h auto/config.h \ xdiff/xmacros.h xdiff/xdiff.h vim.h protodef.h \ @@ -3842,7 +3832,7 @@ objects/xemit.o: xdiff/xemit.c xdiff/xinclude.h auto/config.h \ macros.h option.h beval.h proto/gui_beval.pro \ structs.h regexp.h gui.h alloc.h \ ex_cmds.h spell.h proto.h globals.h \ - farsi.h arabic.h xdiff/xtypes.h xdiff/xutils.h \ + arabic.h xdiff/xtypes.h xdiff/xutils.h \ xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h objects/xprepare.o: xdiff/xprepare.c xdiff/xinclude.h auto/config.h \ xdiff/xmacros.h xdiff/xdiff.h vim.h protodef.h \ @@ -3851,7 +3841,7 @@ objects/xprepare.o: xdiff/xprepare.c xdiff/xinclude.h auto/config.h \ macros.h option.h beval.h proto/gui_beval.pro \ structs.h regexp.h gui.h alloc.h \ ex_cmds.h spell.h proto.h globals.h \ - farsi.h arabic.h xdiff/xtypes.h xdiff/xutils.h \ + arabic.h xdiff/xtypes.h xdiff/xutils.h \ xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h objects/xutils.o: xdiff/xutils.c xdiff/xinclude.h auto/config.h \ xdiff/xmacros.h xdiff/xdiff.h vim.h protodef.h \ @@ -3860,7 +3850,7 @@ objects/xutils.o: xdiff/xutils.c xdiff/xinclude.h auto/config.h \ macros.h option.h beval.h proto/gui_beval.pro \ structs.h regexp.h gui.h alloc.h \ ex_cmds.h spell.h proto.h globals.h \ - farsi.h arabic.h xdiff/xtypes.h xdiff/xutils.h \ + arabic.h xdiff/xtypes.h xdiff/xutils.h \ xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h objects/xhistogram.o: xdiff/xhistogram.c xdiff/xinclude.h auto/config.h \ xdiff/xmacros.h xdiff/xdiff.h vim.h protodef.h \ @@ -3869,7 +3859,7 @@ objects/xhistogram.o: xdiff/xhistogram.c xdiff/xinclude.h auto/config.h \ macros.h option.h beval.h proto/gui_beval.pro \ structs.h regexp.h gui.h alloc.h \ ex_cmds.h spell.h proto.h globals.h \ - farsi.h arabic.h xdiff/xtypes.h xdiff/xutils.h \ + arabic.h xdiff/xtypes.h xdiff/xutils.h \ xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h objects/xpatience.o: xdiff/xpatience.c xdiff/xinclude.h auto/config.h \ xdiff/xmacros.h xdiff/xdiff.h vim.h protodef.h \ @@ -3878,5 +3868,5 @@ objects/xpatience.o: xdiff/xpatience.c xdiff/xinclude.h auto/config.h \ macros.h option.h beval.h proto/gui_beval.pro \ structs.h regexp.h gui.h alloc.h \ ex_cmds.h spell.h proto.h globals.h \ - farsi.h arabic.h xdiff/xtypes.h xdiff/xutils.h \ + arabic.h xdiff/xtypes.h xdiff/xutils.h \ xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h diff --git a/src/auto/configure b/src/auto/configure index 8052cebf6e..db3e3b1e45 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -1498,7 +1498,7 @@ Optional Features: --enable-multibyte Include multibyte editing support. --disable-rightleft Do not include Right-to-Left language support. --disable-arabic Do not include Arabic language support. - --disable-farsi Do not include Farsi language support. + --disable-farsi Deprecated. --enable-hangulinput Include Hangul input support. --enable-xim Include XIM input support. --enable-fontset Include X fontset output support. @@ -7980,24 +7980,11 @@ $as_echo "yes" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-farsi argument" >&5 -$as_echo_n "checking --disable-farsi argument... " >&6; } # Check whether --enable-farsi was given. if test "${enable_farsi+set}" = set; then : enableval=$enable_farsi; -else - enable_farsi="yes" fi -if test "$enable_farsi" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - $as_echo "#define DISABLE_FARSI 1" >>confdefs.h - -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-hangulinput argument" >&5 $as_echo_n "checking --enable-hangulinput argument... " >&6; } diff --git a/src/charset.c b/src/charset.c index 5b091ec4d1..1d66d617ad 100644 --- a/src/charset.c +++ b/src/charset.c @@ -98,13 +98,6 @@ buf_init_chartab( while (c <= '~') #endif g_chartab[c++] = 1 + CT_PRINT_CHAR; -#ifdef FEAT_FKMAP - if (p_altkeymap) - { - while (c < YE) - g_chartab[c++] = 1 + CT_PRINT_CHAR; - } -#endif while (c < 256) { /* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */ @@ -218,11 +211,7 @@ buf_init_chartab( /* Use the MB_ functions here, because isalpha() doesn't * work properly when 'encoding' is "latin1" and the locale is * "C". */ - if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c) -#ifdef FEAT_FKMAP - || (p_altkeymap && (F_isalpha(c) || F_isdigit(c))) -#endif - ) + if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c)) { if (i == 0) /* (re)set ID flag */ { @@ -236,10 +225,6 @@ buf_init_chartab( if ((c < ' ' #ifndef EBCDIC || c > '~' -#endif -#ifdef FEAT_FKMAP - || (p_altkeymap - && (F_isalpha(c) || F_isdigit(c))) #endif // For double-byte we keep the cell width, so // that we can detect it from the first byte. @@ -539,9 +524,6 @@ transchar(int c) (c >= 64 && c < 255) #else (c >= ' ' && c <= '~') -#endif -#ifdef FEAT_FKMAP - || (p_altkeymap && F_ischar(c)) #endif )) || (c < 256 && vim_isprintc_strict(c))) { diff --git a/src/config.h.in b/src/config.h.in index d1aaf708ea..7fe65de570 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -391,9 +391,6 @@ /* Define if you don't want to include right-left support. */ #undef DISABLE_RIGHTLEFT -/* Define if you don't want to include Farsi support. */ -#undef DISABLE_FARSI - /* Define if you don't want to include Arabic support. */ #undef DISABLE_ARABIC diff --git a/src/configure.ac b/src/configure.ac index 2b7725b0a7..2d409b3ca0 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -2155,18 +2155,9 @@ else AC_DEFINE(DISABLE_ARABIC) fi -dnl Farsi language support for vim will be included with big features, -dnl unless ENABLE_FARSI is undefined. -AC_MSG_CHECKING(--disable-farsi argument) +dnl Farsi language support has been removed, ignore --disable-farsi AC_ARG_ENABLE(farsi, - [ --disable-farsi Do not include Farsi language support.], - , [enable_farsi="yes"]) -if test "$enable_farsi" = "yes"; then - AC_MSG_RESULT(no) -else - AC_MSG_RESULT(yes) - AC_DEFINE(DISABLE_FARSI) -fi + [ --disable-farsi Deprecated.],,) AC_MSG_CHECKING(--enable-hangulinput argument) AC_ARG_ENABLE(hangulinput, diff --git a/src/edit.c b/src/edit.c index 042826a872..62ff03d962 100644 --- a/src/edit.c +++ b/src/edit.c @@ -467,15 +467,6 @@ edit( if (cmdchar == 'R') { -#ifdef FEAT_FKMAP - if (p_fkmap && p_ri) - { - beep_flush(); - emsg(farsi_text_3); /* encoded in Farsi */ - State = INSERT; - } - else -#endif State = REPLACE; } else if (cmdchar == 'V' || cmdchar == 'v') @@ -812,10 +803,6 @@ edit( if (p_hkmap && KeyTyped) c = hkmap(c); /* Hebrew mode mapping */ #endif -#ifdef FEAT_FKMAP - if (p_fkmap && KeyTyped) - c = fkmap(c); /* Farsi mode mapping */ -#endif #ifdef FEAT_INS_EXPAND /* @@ -6281,9 +6268,6 @@ insertchar( && !ISSPECIAL(c) && (!has_mbyte || MB_BYTE2LEN_CHECK(c) == 1) && i < INPUT_BUFLEN -# ifdef FEAT_FKMAP - && !(p_fkmap && KeyTyped) /* Farsi mode mapping moves cursor */ -# endif && (textwidth == 0 || (virtcol += byte2cells(buf[i - 1])) < (colnr_T)textwidth) && !(!no_abbr && !vim_iswordc(c) && vim_iswordc(buf[i - 1]))) @@ -8406,23 +8390,7 @@ ins_ctrl_(void) } else revins_scol = -1; -#ifdef FEAT_FKMAP - if (p_altkeymap) - { - /* - * to be consistent also for redo command, using '.' - * set arrow_used to true and stop it - causing to redo - * characters entered in one mode (normal/reverse insert). - */ - arrow_used = TRUE; - (void)stop_arrow(); - p_fkmap = curwin->w_p_rl ^ p_ri; - if (p_fkmap && p_ri) - State = INSERT; - } - else -#endif - p_hkmap = curwin->w_p_rl ^ p_ri; /* be consistent! */ + p_hkmap = curwin->w_p_rl ^ p_ri; // be consistent! showmode(); } #endif @@ -8488,21 +8456,12 @@ ins_start_select(int c) static void ins_insert(int replaceState) { -#ifdef FEAT_FKMAP - if (p_fkmap && p_ri) - { - beep_flush(); - emsg(farsi_text_3); /* encoded in Farsi */ - return; - } -#endif - -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL set_vim_var_string(VV_INSERTMODE, (char_u *)((State & REPLACE_FLAG) ? "i" : replaceState == VREPLACE ? "v" : "r"), 1); -# endif +#endif ins_apply_autocmds(EVENT_INSERTCHANGE); if (State & REPLACE_FLAG) State = INSERT | (State & LANGMAP); @@ -9916,10 +9875,6 @@ ins_eol(int c) coladvance(getviscol()); #ifdef FEAT_RIGHTLEFT -# ifdef FEAT_FKMAP - if (p_altkeymap && p_fkmap) - fkmap(NL); -# endif /* NL in reverse insert will always start in the end of * current line. */ if (revins_on) diff --git a/src/evalfunc.c b/src/evalfunc.c index f1cb9dc607..e9f63423a8 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6268,9 +6268,6 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_SEARCH_EXTRA "extra_search", #endif -#ifdef FEAT_FKMAP - "farsi", -#endif #ifdef FEAT_SEARCHPATH "file_in_path", #endif diff --git a/src/ex_cmds.c b/src/ex_cmds.c index e9fa94f678..79b9bc11d4 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4911,10 +4911,6 @@ do_sub(exarg_T *eap) } else /* find the end of the regexp */ { -#ifdef FEAT_FKMAP /* reverse the flow of the Farsi characters */ - if (p_altkeymap && curwin->w_p_rl) - lrF_sub(cmd); -#endif which_pat = RE_LAST; /* use last used regexp */ delimiter = *cmd++; /* remember delimiter character */ pat = cmd; /* remember start of search pat */ @@ -6070,11 +6066,6 @@ ex_global(exarg_T *eap) *cmd++ = NUL; /* replace it with a NUL */ } -#ifdef FEAT_FKMAP /* when in Farsi mode, reverse the character flow */ - if (p_altkeymap && curwin->w_p_rl) - lrFswap(pat,0); -#endif - if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL) { emsg(_(e_invcmd)); diff --git a/src/ex_getln.c b/src/ex_getln.c index cba082a0bd..0096737b01 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -81,10 +81,6 @@ static int hist_char2type(int c); static int cmd_hkmap = 0; /* Hebrew mapping during command line */ #endif -#ifdef FEAT_FKMAP -static int cmd_fkmap = 0; /* Farsi mapping during command line */ -#endif - static char_u *getcmdline_int(int firstc, long count, int indent, int init_ccline); static int cmdline_charsize(int idx); static void set_cmdspos(void); @@ -1043,10 +1039,6 @@ getcmdline_int( #ifdef FEAT_RIGHTLEFT if (cmd_hkmap) c = hkmap(c); -# ifdef FEAT_FKMAP - if (cmd_fkmap) - c = cmdl_fkmap(c); -# endif if (cmdmsg_rl && !KeyStuffed) { /* Invert horizontal movements and operations. Only when @@ -1595,10 +1587,6 @@ getcmdline_int( case K_DEL: case K_KDEL: case Ctrl_W: -#ifdef FEAT_FKMAP - if (cmd_fkmap && c == K_BS) - c = K_DEL; -#endif if (c == K_KDEL) c = K_DEL; @@ -1694,13 +1682,6 @@ getcmdline_int( case K_INS: case K_KINS: -#ifdef FEAT_FKMAP - /* if Farsi mode set, we are in reverse insert mode - - Do not change the mode */ - if (cmd_fkmap) - beep_flush(); - else -#endif ccline.overstrike = !ccline.overstrike; #ifdef CURSOR_SHAPE ui_cursor_shape(); /* may show different cursor shape */ @@ -2309,16 +2290,7 @@ getcmdline_int( case Ctrl__: /* CTRL-_: switch language mode */ if (!p_ari) break; -# ifdef FEAT_FKMAP - if (p_altkeymap) - { - cmd_fkmap = !cmd_fkmap; - if (cmd_fkmap) /* in Farsi always in Insert mode */ - ccline.overstrike = FALSE; - } - else /* Hebrew is default */ -# endif - cmd_hkmap = !cmd_hkmap; + cmd_hkmap = !cmd_hkmap; goto cmdline_not_changed; #endif @@ -2421,10 +2393,6 @@ returncmd: cmdmsg_rl = FALSE; #endif -#ifdef FEAT_FKMAP - cmd_fkmap = 0; -#endif - ExpandCleanup(&xpc); ccline.xpc = NULL; @@ -3463,44 +3431,35 @@ put_on_cmdline(char_u *str, int len, int redraw) msg_clr_eos(); msg_no_more = FALSE; } -#ifdef FEAT_FKMAP - /* - * If we are in Farsi command mode, the character input must be in - * Insert mode. So do not advance the cmdpos. - */ - if (!cmd_fkmap) -#endif + if (KeyTyped) { - if (KeyTyped) - { - m = Columns * Rows; - if (m < 0) /* overflow, Columns or Rows at weird value */ - m = MAXCOL; - } - else + m = Columns * Rows; + if (m < 0) /* overflow, Columns or Rows at weird value */ m = MAXCOL; - for (i = 0; i < len; ++i) - { - c = cmdline_charsize(ccline.cmdpos); - /* count ">" for a double-wide char that doesn't fit. */ - if (has_mbyte) - correct_cmdspos(ccline.cmdpos, c); - /* Stop cursor at the end of the screen, but do increment the - * insert position, so that entering a very long command - * works, even though you can't see it. */ - if (ccline.cmdspos + c < m) - ccline.cmdspos += c; + } + else + m = MAXCOL; + for (i = 0; i < len; ++i) + { + c = cmdline_charsize(ccline.cmdpos); + /* count ">" for a double-wide char that doesn't fit. */ + if (has_mbyte) + correct_cmdspos(ccline.cmdpos, c); + /* Stop cursor at the end of the screen, but do increment the + * insert position, so that entering a very long command + * works, even though you can't see it. */ + if (ccline.cmdspos + c < m) + ccline.cmdspos += c; - if (has_mbyte) - { - c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; - if (c > len - i - 1) - c = len - i - 1; - ccline.cmdpos += c; - i += c; - } - ++ccline.cmdpos; + if (has_mbyte) + { + c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; + if (c > len - i - 1) + c = len - i - 1; + ccline.cmdpos += c; + i += c; } + ++ccline.cmdpos; } } if (redraw) @@ -7126,35 +7085,6 @@ write_viminfo_history(FILE *fp, int merge) } #endif /* FEAT_VIMINFO */ -#if defined(FEAT_FKMAP) || defined(PROTO) -/* - * Write a character at the current cursor+offset position. - * It is directly written into the command buffer block. - */ - void -cmd_pchar(int c, int offset) -{ - if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) - { - emsg(_("E198: cmd_pchar beyond the command length")); - return; - } - ccline.cmdbuff[ccline.cmdpos + offset] = (char_u)c; - ccline.cmdbuff[ccline.cmdlen] = NUL; -} - - int -cmd_gchar(int offset) -{ - if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) - { - // emsg(_("cmd_gchar beyond the command length")); - return NUL; - } - return (int)ccline.cmdbuff[ccline.cmdpos + offset]; -} -#endif - #if defined(FEAT_CMDWIN) || defined(PROTO) /* * Open a window on the current command line and history. Allow editing in diff --git a/src/farsi.c b/src/farsi.c deleted file mode 100644 index 48dd991b07..0000000000 --- a/src/farsi.c +++ /dev/null @@ -1,2179 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 noet: - * - * VIM - Vi IMproved by Bram Moolenaar - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -/* - * farsi.c: functions for Farsi language - */ - -#include "vim.h" - -#if defined(FEAT_FKMAP) || defined(PROTO) - -static int F_is_TyB_TyC_TyD(int src, int offset); - -/* - * Convert the given Farsi character into a _X or _X_ type - */ - static int -toF_Xor_X_(int c) -{ - int tempc; - - switch (c) - { - case BE: return _BE; - case PE: return _PE; - case TE: return _TE; - case SE: return _SE; - case JIM: return _JIM; - case CHE: return _CHE; - case HE_J: return _HE_J; - case XE: return _XE; - case SIN: return _SIN; - case SHIN: return _SHIN; - case SAD: return _SAD; - case ZAD: return _ZAD; - case AYN: return _AYN; - case AYN_: return _AYN_; - case GHAYN: return _GHAYN; - case GHAYN_: return _GHAYN_; - case FE: return _FE; - case GHAF: return _GHAF; - case KAF: return _KAF; - case GAF: return _GAF; - case LAM: return _LAM; - case MIM: return _MIM; - case NOON: return _NOON; - case YE: - case YE_: return _YE; - case YEE: - case YEE_: return _YEE; - case IE: - case IE_: return _IE; - case F_HE: - tempc = _HE; - - if (p_ri && (curwin->w_cursor.col + 1 - < (colnr_T)STRLEN(ml_get_curline()))) - { - inc_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = _HE_; - - dec_cursor(); - } - if (!p_ri && STRLEN(ml_get_curline())) - { - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = _HE_; - - inc_cursor(); - } - - return tempc; - } - return 0; -} - -/* - * Convert the given Farsi character into Farsi capital character. - */ - static int -toF_TyA(int c) -{ - switch (c) - { - case ALEF_: return ALEF; - case ALEF_U_H_: return ALEF_U_H; - case _BE: return BE; - case _PE: return PE; - case _TE: return TE; - case _SE: return SE; - case _JIM: return JIM; - case _CHE: return CHE; - case _HE_J: return HE_J; - case _XE: return XE; - case _SIN: return SIN; - case _SHIN: return SHIN; - case _SAD: return SAD; - case _ZAD: return ZAD; - case _AYN: - case AYN_: - case _AYN_: return AYN; - case _GHAYN: - case GHAYN_: - case _GHAYN_: return GHAYN; - case _FE: return FE; - case _GHAF: return GHAF; - /* I am not sure what it is !!! case _KAF_H: */ - case _KAF: return KAF; - case _GAF: return GAF; - case _LAM: return LAM; - case _MIM: return MIM; - case _NOON: return NOON; - case _YE: - case YE_: return YE; - case _YEE: - case YEE_: return YEE; - case TEE_: return TEE; - case _IE: - case IE_: return IE; - case _HE: - case _HE_: return F_HE; - } - return c; -} - -/* - * Is the character under the cursor+offset in the given buffer a join type. - * That is a character that is combined with the others. - * Note: the offset is used only for command line buffer. - */ - static int -F_is_TyB_TyC_TyD(int src, int offset) -{ - int c; - - if (src == SRC_EDT) - c = gchar_cursor(); - else - c = cmd_gchar(AT_CURSOR+offset); - - switch (c) - { - case _LAM: - case _BE: - case _PE: - case _TE: - case _SE: - case _JIM: - case _CHE: - case _HE_J: - case _XE: - case _SIN: - case _SHIN: - case _SAD: - case _ZAD: - case _TA: - case _ZA: - case _AYN: - case _AYN_: - case _GHAYN: - case _GHAYN_: - case _FE: - case _GHAF: - case _KAF: - case _KAF_H: - case _GAF: - case _MIM: - case _NOON: - case _YE: - case _YEE: - case _IE: - case _HE_: - case _HE: - return TRUE; - } - return FALSE; -} - -/* - * Is the Farsi character one of the terminating only type. - */ - static int -F_is_TyE(int c) -{ - switch (c) - { - case ALEF_A: - case ALEF_D_H: - case DAL: - case ZAL: - case RE: - case ZE: - case JE: - case WAW: - case WAW_H: - case HAMZE: - return TRUE; - } - return FALSE; -} - -/* - * Is the Farsi character one of the none leading type. - */ - static int -F_is_TyC_TyD(int c) -{ - switch (c) - { - case ALEF_: - case ALEF_U_H_: - case _AYN_: - case AYN_: - case _GHAYN_: - case GHAYN_: - case _HE_: - case YE_: - case IE_: - case TEE_: - case YEE_: - return TRUE; - } - return FALSE; -} - -/* - * Convert a none leading Farsi char into a leading type. - */ - static int -toF_TyB(int c) -{ - switch (c) - { - case ALEF_: return ALEF; - case ALEF_U_H_: return ALEF_U_H; - case _AYN_: return _AYN; - case AYN_: return AYN; /* exception - there are many of them */ - case _GHAYN_: return _GHAYN; - case GHAYN_: return GHAYN; /* exception - there are many of them */ - case _HE_: return _HE; - case YE_: return YE; - case IE_: return IE; - case TEE_: return TEE; - case YEE_: return YEE; - } - return c; -} - - - static void -put_and_redo(int c) -{ - pchar_cursor(c); - AppendCharToRedobuff(K_BS); - AppendCharToRedobuff(c); -} - -/* - * Overwrite the current redo and cursor characters + left adjust. - */ - static void -put_curr_and_l_to_X(int c) -{ - int tempc; - - if (curwin->w_p_rl && p_ri) - return; - - if ((curwin->w_cursor.col < (colnr_T)STRLEN(ml_get_curline()))) - { - if ((p_ri && curwin->w_cursor.col) || !p_ri) - { - if (p_ri) - dec_cursor(); - else - inc_cursor(); - - if (F_is_TyC_TyD((tempc = gchar_cursor()))) - { - pchar_cursor(toF_TyB(tempc)); - AppendCharToRedobuff(K_BS); - AppendCharToRedobuff(tempc); - } - - if (p_ri) - inc_cursor(); - else - dec_cursor(); - } - } - - put_and_redo(c); -} - -/* - * Change the char. under the cursor to a X_ or X type - */ - static void -chg_c_toX_orX(void) -{ - int tempc, curc; - - switch ((curc = gchar_cursor())) - { - case _BE: - tempc = BE; - break; - case _PE: - tempc = PE; - break; - case _TE: - tempc = TE; - break; - case _SE: - tempc = SE; - break; - case _JIM: - tempc = JIM; - break; - case _CHE: - tempc = CHE; - break; - case _HE_J: - tempc = HE_J; - break; - case _XE: - tempc = XE; - break; - case _SIN: - tempc = SIN; - break; - case _SHIN: - tempc = SHIN; - break; - case _SAD: - tempc = SAD; - break; - case _ZAD: - tempc = ZAD; - break; - case _FE: - tempc = FE; - break; - case _GHAF: - tempc = GHAF; - break; - case _KAF_H: - case _KAF: - tempc = KAF; - break; - case _GAF: - tempc = GAF; - break; - case _AYN: - tempc = AYN; - break; - case _AYN_: - tempc = AYN_; - break; - case _GHAYN: - tempc = GHAYN; - break; - case _GHAYN_: - tempc = GHAYN_; - break; - case _LAM: - tempc = LAM; - break; - case _MIM: - tempc = MIM; - break; - case _NOON: - tempc = NOON; - break; - case _HE: - case _HE_: - tempc = F_HE; - break; - case _YE: - case _IE: - case _YEE: - if (p_ri) - { - inc_cursor(); - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = (curc == _YE ? YE_ : - (curc == _IE ? IE_ : YEE_)); - else - tempc = (curc == _YE ? YE : - (curc == _IE ? IE : YEE)); - dec_cursor(); - } - else - { - if (curwin->w_cursor.col) - { - dec_cursor(); - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = (curc == _YE ? YE_ : - (curc == _IE ? IE_ : YEE_)); - else - tempc = (curc == _YE ? YE : - (curc == _IE ? IE : YEE)); - inc_cursor(); - } - else - tempc = (curc == _YE ? YE : - (curc == _IE ? IE : YEE)); - } - break; - default: - tempc = 0; - } - - if (tempc) - put_and_redo(tempc); -} - -/* - * Change the char. under the cursor to a _X_ or X_ type - */ - static void -chg_c_to_X_orX_(void) -{ - int tempc; - - switch (gchar_cursor()) - { - case ALEF: - tempc = ALEF_; - break; - case ALEF_U_H: - tempc = ALEF_U_H_; - break; - case _AYN: - tempc = _AYN_; - break; - case AYN: - tempc = AYN_; - break; - case _GHAYN: - tempc = _GHAYN_; - break; - case GHAYN: - tempc = GHAYN_; - break; - case _HE: - tempc = _HE_; - break; - case YE: - tempc = YE_; - break; - case IE: - tempc = IE_; - break; - case TEE: - tempc = TEE_; - break; - case YEE: - tempc = YEE_; - break; - default: - tempc = 0; - } - - if (tempc) - put_and_redo(tempc); -} - -/* - * Change the char. under the cursor to a _X_ or _X type - */ - static void -chg_c_to_X_or_X(void) -{ - int tempc; - - tempc = gchar_cursor(); - - if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline())) - { - inc_cursor(); - - if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) - { - tempc = _HE_; - - dec_cursor(); - - put_and_redo(tempc); - return; - } - - dec_cursor(); - } - - if ((tempc = toF_Xor_X_(tempc)) != 0) - put_and_redo(tempc); -} - -/* - * Change the character left to the cursor to a _X_ or X_ type - */ - static void -chg_l_to_X_orX_(void) -{ - int tempc; - - if (curwin->w_cursor.col != 0 && - (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) - return; - - if (!curwin->w_cursor.col && p_ri) - return; - - if (p_ri) - dec_cursor(); - else - inc_cursor(); - - switch (gchar_cursor()) - { - case ALEF: - tempc = ALEF_; - break; - case ALEF_U_H: - tempc = ALEF_U_H_; - break; - case _AYN: - tempc = _AYN_; - break; - case AYN: - tempc = AYN_; - break; - case _GHAYN: - tempc = _GHAYN_; - break; - case GHAYN: - tempc = GHAYN_; - break; - case _HE: - tempc = _HE_; - break; - case YE: - tempc = YE_; - break; - case IE: - tempc = IE_; - break; - case TEE: - tempc = TEE_; - break; - case YEE: - tempc = YEE_; - break; - default: - tempc = 0; - } - - if (tempc) - put_and_redo(tempc); - - if (p_ri) - inc_cursor(); - else - dec_cursor(); -} - -/* - * Change the character left to the cursor to a X or _X type - */ - static void -chg_l_toXor_X(void) -{ - int tempc; - - if (curwin->w_cursor.col != 0 && - (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) - return; - - if (!curwin->w_cursor.col && p_ri) - return; - - if (p_ri) - dec_cursor(); - else - inc_cursor(); - - switch (gchar_cursor()) - { - case ALEF_: - tempc = ALEF; - break; - case ALEF_U_H_: - tempc = ALEF_U_H; - break; - case _AYN_: - tempc = _AYN; - break; - case AYN_: - tempc = AYN; - break; - case _GHAYN_: - tempc = _GHAYN; - break; - case GHAYN_: - tempc = GHAYN; - break; - case _HE_: - tempc = _HE; - break; - case YE_: - tempc = YE; - break; - case IE_: - tempc = IE; - break; - case TEE_: - tempc = TEE; - break; - case YEE_: - tempc = YEE; - break; - default: - tempc = 0; - } - - if (tempc) - put_and_redo(tempc); - - if (p_ri) - inc_cursor(); - else - dec_cursor(); -} - -/* - * Change the character right to the cursor to a _X or _X_ type - */ - static void -chg_r_to_Xor_X_(void) -{ - int tempc, c; - - if (curwin->w_cursor.col) - { - if (!p_ri) - dec_cursor(); - - tempc = gchar_cursor(); - - if ((c = toF_Xor_X_(tempc)) != 0) - put_and_redo(c); - - if (!p_ri) - inc_cursor(); - - } -} - -/* - * Map Farsi keyboard when in fkmap mode. - */ - int -fkmap(int c) -{ - int tempc; - int insert_mode = (State & INSERT); - static int revins = 0; - - if (IS_SPECIAL(c)) - return c; - - if (insert_mode) - { - if (VIM_ISDIGIT(c) || ((c == '.' || c == '+' || c == '-' || - c == '^' || c == '%' || c == '#' || c == '=') && revins)) - { - /* Numbers are entered left-to-right. */ - if (!revins) - { - if (curwin->w_cursor.col) - { - if (!p_ri) - dec_cursor(); - - chg_c_toX_orX (); - chg_l_toXor_X (); - - if (!p_ri) - inc_cursor(); - } - } - - arrow_used = TRUE; - (void)stop_arrow(); - - if (!curwin->w_p_rl && revins) - inc_cursor(); - - ++revins; - p_ri = 1; - } - else if (revins) - { - /* Stop entering number. */ - arrow_used = TRUE; - (void)stop_arrow(); - - revins = 0; - if (curwin->w_p_rl) - { - while ((F_isdigit(gchar_cursor()) - || (gchar_cursor() == F_PERIOD - || gchar_cursor() == F_PLUS - || gchar_cursor() == F_MINUS - || gchar_cursor() == F_MUL - || gchar_cursor() == F_DIVIDE - || gchar_cursor() == F_PERCENT - || gchar_cursor() == F_EQUALS)) - && gchar_cursor() != NUL) - ++curwin->w_cursor.col; - } - else - { - if (curwin->w_cursor.col) - while ((F_isdigit(gchar_cursor()) - || (gchar_cursor() == F_PERIOD - || gchar_cursor() == F_PLUS - || gchar_cursor() == F_MINUS - || gchar_cursor() == F_MUL - || gchar_cursor() == F_DIVIDE - || gchar_cursor() == F_PERCENT - || gchar_cursor() == F_EQUALS)) - && --curwin->w_cursor.col) - ; - - if (!F_isdigit(gchar_cursor())) - ++curwin->w_cursor.col; - } - } - } - - if (!revins) - { - if (curwin->w_p_rl) - p_ri = 0; - if (!curwin->w_p_rl) - p_ri = 1; - } - - if ((c < 0x100) && (isalpha(c) || c == '&' || c == '^' || c == ';' || - c == '\''|| c == ',' || c == '[' || - c == ']' || c == '{' || c == '}')) - chg_r_to_Xor_X_(); - - tempc = 0; - - switch (c) - { - case '`': - case ' ': - case '.': - case '!': - case '"': - case '$': - case '%': - case '^': - case '&': - case '/': - case '(': - case ')': - case '=': - case '\\': - case '?': - case '+': - case '-': - case '_': - case '*': - case ':': - case '#': - case '~': - case '@': - case '<': - case '>': - case '{': - case '}': - case '|': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'B': - case 'E': - case 'F': - case 'H': - case 'I': - case 'K': - case 'L': - case 'M': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'T': - case 'U': - case 'W': - case 'Y': - case NL: - case TAB: - - if (p_ri && c == NL && curwin->w_cursor.col && insert_mode) - { - /* - * If the char before the cursor is _X_ or X_ do not change - * the one under the cursor with X type. - */ - dec_cursor(); - - if (F_isalpha(gchar_cursor())) - { - inc_cursor(); - return NL; - } - - inc_cursor(); - } - - if (!p_ri && !curwin->w_cursor.col) - { - switch (c) - { - case '0': return FARSI_0; - case '1': return FARSI_1; - case '2': return FARSI_2; - case '3': return FARSI_3; - case '4': return FARSI_4; - case '5': return FARSI_5; - case '6': return FARSI_6; - case '7': return FARSI_7; - case '8': return FARSI_8; - case '9': return FARSI_9; - case 'B': return F_PSP; - case 'E': return JAZR_N; - case 'F': return ALEF_D_H; - case 'H': return ALEF_A; - case 'I': return TASH; - case 'K': return F_LQUOT; - case 'L': return F_RQUOT; - case 'M': return HAMZE; - case 'O': return '['; - case 'P': return ']'; - case 'Q': return OO; - case 'R': return MAD_N; - case 'T': return OW; - case 'U': return MAD; - case 'W': return OW_OW; - case 'Y': return JAZR; - case '`': return F_PCN; - case '!': return F_EXCL; - case '@': return F_COMMA; - case '#': return F_DIVIDE; - case '$': return F_CURRENCY; - case '%': return F_PERCENT; - case '^': return F_MUL; - case '&': return F_BCOMMA; - case '*': return F_STAR; - case '(': return F_LPARENT; - case ')': return F_RPARENT; - case '-': return F_MINUS; - case '_': return F_UNDERLINE; - case '=': return F_EQUALS; - case '+': return F_PLUS; - case '\\': return F_BSLASH; - case '|': return F_PIPE; - case ':': return F_DCOLON; - case '"': return F_SEMICOLON; - case '.': return F_PERIOD; - case '/': return F_SLASH; - case '<': return F_LESS; - case '>': return F_GREATER; - case '?': return F_QUESTION; - case ' ': return F_BLANK; - } - break; - } - - if (insert_mode) - { - if (!p_ri) - dec_cursor(); - - switch ((tempc = gchar_cursor())) - { - case _BE: - case _PE: - case _TE: - case _SE: - case _JIM: - case _CHE: - case _HE_J: - case _XE: - case _SIN: - case _SHIN: - case _SAD: - case _ZAD: - case _FE: - case _GHAF: - case _KAF: - case _KAF_H: - case _GAF: - case _LAM: - case _MIM: - case _NOON: - case _HE: - case _HE_: - case _TA: - case _ZA: - put_curr_and_l_to_X(toF_TyA(tempc)); - break; - case _AYN: - case _AYN_: - - if (!p_ri) - if (!curwin->w_cursor.col) - { - put_curr_and_l_to_X(AYN); - break; - } - - if (p_ri) - inc_cursor(); - else - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = AYN_; - else - tempc = AYN; - - if (p_ri) - dec_cursor(); - else - inc_cursor(); - - put_curr_and_l_to_X(tempc); - - break; - case _GHAYN: - case _GHAYN_: - - if (!p_ri) - if (!curwin->w_cursor.col) - { - put_curr_and_l_to_X(GHAYN); - break; - } - - if (p_ri) - inc_cursor(); - else - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = GHAYN_; - else - tempc = GHAYN; - - if (p_ri) - dec_cursor(); - else - inc_cursor(); - - put_curr_and_l_to_X(tempc); - break; - case _YE: - case _IE: - case _YEE: - if (!p_ri) - if (!curwin->w_cursor.col) - { - put_curr_and_l_to_X((tempc == _YE ? YE : - (tempc == _IE ? IE : YEE))); - break; - } - - if (p_ri) - inc_cursor(); - else - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = (tempc == _YE ? YE_ : - (tempc == _IE ? IE_ : YEE_)); - else - tempc = (tempc == _YE ? YE : - (tempc == _IE ? IE : YEE)); - - if (p_ri) - dec_cursor(); - else - inc_cursor(); - - put_curr_and_l_to_X(tempc); - break; - } - - if (!p_ri) - inc_cursor(); - } - - tempc = 0; - - switch (c) - { - case '0': return FARSI_0; - case '1': return FARSI_1; - case '2': return FARSI_2; - case '3': return FARSI_3; - case '4': return FARSI_4; - case '5': return FARSI_5; - case '6': return FARSI_6; - case '7': return FARSI_7; - case '8': return FARSI_8; - case '9': return FARSI_9; - case 'B': return F_PSP; - case 'E': return JAZR_N; - case 'F': return ALEF_D_H; - case 'H': return ALEF_A; - case 'I': return TASH; - case 'K': return F_LQUOT; - case 'L': return F_RQUOT; - case 'M': return HAMZE; - case 'O': return '['; - case 'P': return ']'; - case 'Q': return OO; - case 'R': return MAD_N; - case 'T': return OW; - case 'U': return MAD; - case 'W': return OW_OW; - case 'Y': return JAZR; - case '`': return F_PCN; - case '!': return F_EXCL; - case '@': return F_COMMA; - case '#': return F_DIVIDE; - case '$': return F_CURRENCY; - case '%': return F_PERCENT; - case '^': return F_MUL; - case '&': return F_BCOMMA; - case '*': return F_STAR; - case '(': return F_LPARENT; - case ')': return F_RPARENT; - case '-': return F_MINUS; - case '_': return F_UNDERLINE; - case '=': return F_EQUALS; - case '+': return F_PLUS; - case '\\': return F_BSLASH; - case '|': return F_PIPE; - case ':': return F_DCOLON; - case '"': return F_SEMICOLON; - case '.': return F_PERIOD; - case '/': return F_SLASH; - case '<': return F_LESS; - case '>': return F_GREATER; - case '?': return F_QUESTION; - case ' ': return F_BLANK; - } - break; - - case 'a': - tempc = _SHIN; - break; - case 'A': - tempc = WAW_H; - break; - case 'b': - tempc = ZAL; - break; - case 'c': - tempc = ZE; - break; - case 'C': - tempc = JE; - break; - case 'd': - tempc = _YE; - break; - case 'D': - tempc = _YEE; - break; - case 'e': - tempc = _SE; - break; - case 'f': - tempc = _BE; - break; - case 'g': - tempc = _LAM; - break; - case 'G': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - - if (gchar_cursor() == _LAM) - chg_c_toX_orX (); - else if (p_ri) - chg_c_to_X_or_X (); - } - - if (!p_ri) - if (!curwin->w_cursor.col) - return ALEF_U_H; - - if (!p_ri) - dec_cursor(); - - if (gchar_cursor() == _LAM) - { - chg_c_toX_orX (); - chg_l_toXor_X (); - tempc = ALEF_U_H; - } - else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - { - tempc = ALEF_U_H_; - chg_l_toXor_X (); - } - else - tempc = ALEF_U_H; - - if (!p_ri) - inc_cursor(); - - return tempc; - case 'h': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - if (p_ri) - chg_c_to_X_or_X (); - - } - - if (!p_ri) - if (!curwin->w_cursor.col) - return ALEF; - - if (!p_ri) - dec_cursor(); - - if (gchar_cursor() == _LAM) - { - chg_l_toXor_X(); - del_char(FALSE); - AppendCharToRedobuff(K_BS); - - if (!p_ri) - dec_cursor(); - - tempc = LA; - } - else - { - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - { - tempc = ALEF_; - chg_l_toXor_X (); - } - else - tempc = ALEF; - } - - if (!p_ri) - inc_cursor(); - - return tempc; - case 'i': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - if (!p_ri && !F_is_TyE(tempc)) - chg_c_to_X_orX_ (); - if (p_ri) - chg_c_to_X_or_X (); - - } - - if (!p_ri && !curwin->w_cursor.col) - return _HE; - - if (!p_ri) - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = _HE_; - else - tempc = _HE; - - if (!p_ri) - inc_cursor(); - break; - case 'j': - tempc = _TE; - break; - case 'J': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - if (p_ri) - chg_c_to_X_or_X (); - - } - - if (!p_ri) - if (!curwin->w_cursor.col) - return TEE; - - if (!p_ri) - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - { - tempc = TEE_; - chg_l_toXor_X (); - } - else - tempc = TEE; - - if (!p_ri) - inc_cursor(); - - return tempc; - case 'k': - tempc = _NOON; - break; - case 'l': - tempc = _MIM; - break; - case 'm': - tempc = _PE; - break; - case 'n': - case 'N': - tempc = DAL; - break; - case 'o': - tempc = _XE; - break; - case 'p': - tempc = _HE_J; - break; - case 'q': - tempc = _ZAD; - break; - case 'r': - tempc = _GHAF; - break; - case 's': - tempc = _SIN; - break; - case 'S': - tempc = _IE; - break; - case 't': - tempc = _FE; - break; - case 'u': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - if (!p_ri && !F_is_TyE(tempc)) - chg_c_to_X_orX_ (); - if (p_ri) - chg_c_to_X_or_X (); - - } - - if (!p_ri && !curwin->w_cursor.col) - return _AYN; - - if (!p_ri) - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = _AYN_; - else - tempc = _AYN; - - if (!p_ri) - inc_cursor(); - break; - case 'v': - case 'V': - tempc = RE; - break; - case 'w': - tempc = _SAD; - break; - case 'x': - case 'X': - tempc = _TA; - break; - case 'y': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - if (!p_ri && !F_is_TyE(tempc)) - chg_c_to_X_orX_ (); - if (p_ri) - chg_c_to_X_or_X (); - - } - - if (!p_ri && !curwin->w_cursor.col) - return _GHAYN; - - if (!p_ri) - dec_cursor(); - - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = _GHAYN_; - else - tempc = _GHAYN; - - if (!p_ri) - inc_cursor(); - - break; - case 'z': - tempc = _ZA; - break; - case 'Z': - tempc = _KAF_H; - break; - case ';': - tempc = _KAF; - break; - case '\'': - tempc = _GAF; - break; - case ',': - tempc = WAW; - break; - case '[': - tempc = _JIM; - break; - case ']': - tempc = _CHE; - break; - } - - if (F_isalpha(tempc) || F_isdigit(tempc)) - { - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { - if (!p_ri && !F_is_TyE(tempc)) - chg_c_to_X_orX_(); - if (p_ri) - chg_c_to_X_or_X(); - } - - if (curwin->w_cursor.col) - { - if (!p_ri) - dec_cursor(); - - if (F_is_TyE(tempc)) - chg_l_toXor_X(); - else - chg_l_to_X_orX_(); - - if (!p_ri) - inc_cursor(); - } - } - if (tempc) - return tempc; - return c; -} - -/* - * Convert a none leading Farsi char into a leading type. - */ - static int -toF_leading(int c) -{ - switch (c) - { - case ALEF_: return ALEF; - case ALEF_U_H_: return ALEF_U_H; - case BE: return _BE; - case PE: return _PE; - case TE: return _TE; - case SE: return _SE; - case JIM: return _JIM; - case CHE: return _CHE; - case HE_J: return _HE_J; - case XE: return _XE; - case SIN: return _SIN; - case SHIN: return _SHIN; - case SAD: return _SAD; - case ZAD: return _ZAD; - - case AYN: - case AYN_: - case _AYN_: return _AYN; - - case GHAYN: - case GHAYN_: - case _GHAYN_: return _GHAYN; - - case FE: return _FE; - case GHAF: return _GHAF; - case KAF: return _KAF; - case GAF: return _GAF; - case LAM: return _LAM; - case MIM: return _MIM; - case NOON: return _NOON; - - case _HE_: - case F_HE: return _HE; - - case YE: - case YE_: return _YE; - - case IE_: - case IE: return _IE; - - case YEE: - case YEE_: return _YEE; - } - return c; -} - -/* - * Convert a given Farsi char into right joining type. - */ - static int -toF_Rjoin(int c) -{ - switch (c) - { - case ALEF: return ALEF_; - case ALEF_U_H: return ALEF_U_H_; - case BE: return _BE; - case PE: return _PE; - case TE: return _TE; - case SE: return _SE; - case JIM: return _JIM; - case CHE: return _CHE; - case HE_J: return _HE_J; - case XE: return _XE; - case SIN: return _SIN; - case SHIN: return _SHIN; - case SAD: return _SAD; - case ZAD: return _ZAD; - - case AYN: - case AYN_: - case _AYN: return _AYN_; - - case GHAYN: - case GHAYN_: - case _GHAYN_: return _GHAYN_; - - case FE: return _FE; - case GHAF: return _GHAF; - case KAF: return _KAF; - case GAF: return _GAF; - case LAM: return _LAM; - case MIM: return _MIM; - case NOON: return _NOON; - - case _HE: - case F_HE: return _HE_; - - case YE: - case YE_: return _YE; - - case IE_: - case IE: return _IE; - - case TEE: return TEE_; - - case YEE: - case YEE_: return _YEE; - } - return c; -} - -/* - * Can a given Farsi character join via its left edj. - */ - static int -canF_Ljoin(int c) -{ - switch (c) - { - case _BE: - case BE: - case PE: - case _PE: - case TE: - case _TE: - case SE: - case _SE: - case JIM: - case _JIM: - case CHE: - case _CHE: - case HE_J: - case _HE_J: - case XE: - case _XE: - case SIN: - case _SIN: - case SHIN: - case _SHIN: - case SAD: - case _SAD: - case ZAD: - case _ZAD: - case _TA: - case _ZA: - case AYN: - case _AYN: - case _AYN_: - case AYN_: - case GHAYN: - case GHAYN_: - case _GHAYN_: - case _GHAYN: - case FE: - case _FE: - case GHAF: - case _GHAF: - case _KAF_H: - case KAF: - case _KAF: - case GAF: - case _GAF: - case LAM: - case _LAM: - case MIM: - case _MIM: - case NOON: - case _NOON: - case IE: - case _IE: - case IE_: - case YE: - case _YE: - case YE_: - case YEE: - case _YEE: - case YEE_: - case F_HE: - case _HE: - case _HE_: - return TRUE; - } - return FALSE; -} - -/* - * Can a given Farsi character join via its right edj. - */ - static int -canF_Rjoin(int c) -{ - switch (c) - { - case ALEF: - case ALEF_: - case ALEF_U_H: - case ALEF_U_H_: - case DAL: - case ZAL: - case RE: - case JE: - case ZE: - case TEE: - case TEE_: - case WAW: - case WAW_H: - return TRUE; - } - - return canF_Ljoin(c); - -} - -/* - * is a given Farsi character a terminating type. - */ - static int -F_isterm(int c) -{ - switch (c) - { - case ALEF: - case ALEF_: - case ALEF_U_H: - case ALEF_U_H_: - case DAL: - case ZAL: - case RE: - case JE: - case ZE: - case WAW: - case WAW_H: - case TEE: - case TEE_: - return TRUE; - } - - return FALSE; -} - -/* - * Convert the given Farsi character into a ending type . - */ - static int -toF_ending(int c) -{ - switch (c) - { - case _BE: return BE; - case _PE: return PE; - case _TE: return TE; - case _SE: return SE; - case _JIM: return JIM; - case _CHE: return CHE; - case _HE_J: return HE_J; - case _XE: return XE; - case _SIN: return SIN; - case _SHIN: return SHIN; - case _SAD: return SAD; - case _ZAD: return ZAD; - case _AYN: return AYN; - case _AYN_: return AYN_; - case _GHAYN: return GHAYN; - case _GHAYN_: return GHAYN_; - case _FE: return FE; - case _GHAF: return GHAF; - case _KAF_H: - case _KAF: return KAF; - case _GAF: return GAF; - case _LAM: return LAM; - case _MIM: return MIM; - case _NOON: return NOON; - case _YE: return YE_; - case YE_: return YE; - case _YEE: return YEE_; - case YEE_: return YEE; - case TEE: return TEE_; - case _IE: return IE_; - case IE_: return IE; - case _HE: - case _HE_: return F_HE; - } - return c; -} - -/* - * Convert the Farsi 3342 standard into Farsi VIM. - */ - static void -conv_to_pvim(void) -{ - char_u *ptr; - int lnum, llen, i; - - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) - { - ptr = ml_get((linenr_T)lnum); - - llen = (int)STRLEN(ptr); - - for (i = 0; i < llen-1; i++) - { - if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i+1])) - { - ptr[i] = toF_leading(ptr[i]); - ++i; - - while (i < llen && canF_Rjoin(ptr[i])) - { - ptr[i] = toF_Rjoin(ptr[i]); - if (F_isterm(ptr[i]) || !F_isalpha(ptr[i])) - break; - ++i; - } - if (!F_isalpha(ptr[i]) || !canF_Rjoin(ptr[i])) - ptr[i-1] = toF_ending(ptr[i-1]); - } - else - ptr[i] = toF_TyA(ptr[i]); - } - } - - /* - * Following lines contains Farsi encoded character. - */ - - do_cmdline_cmd((char_u *)"%s/\202\231/\232/ge"); - do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/ge"); - - /* Assume the screen has been messed up: clear it and redraw. */ - redraw_later(CLEAR); - msg_attr(farsi_text_1, HL_ATTR(HLF_S)); -} - -/* - * Convert the Farsi VIM into Farsi 3342 standard. - */ - static void -conv_to_pstd(void) -{ - char_u *ptr; - int lnum, llen, i; - - /* - * Following line contains Farsi encoded character. - */ - do_cmdline_cmd((char_u *)"%s/\232/\202\231/ge"); - - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) - { - ptr = ml_get((linenr_T)lnum); - llen = (int)STRLEN(ptr); - - for (i = 0; i < llen; i++) - ptr[i] = toF_TyA(ptr[i]); - } - - /* Assume the screen has been messed up: clear it and redraw. */ - redraw_later(CLEAR); - msg_attr(farsi_text_2, HL_ATTR(HLF_S)); -} - -/* - * left-right swap the characters in buf[len]. - */ - static void -lrswapbuf(char_u *buf, int len) -{ - char_u *s, *e; - int c; - - s = buf; - e = buf + len - 1; - - while (e > s) - { - c = *s; - *s = *e; - *e = c; - ++s; - --e; - } -} - -/* - * swap all the characters in reverse direction - */ - char_u * -lrswap(char_u *ibuf) -{ - if (ibuf != NULL && *ibuf != NUL) - lrswapbuf(ibuf, (int)STRLEN(ibuf)); - return ibuf; -} - -/* - * swap all the Farsi characters in reverse direction - */ - char_u * -lrFswap(char_u *cmdbuf, int len) -{ - int i, cnt; - - if (cmdbuf == NULL) - return cmdbuf; - - if (len == 0 && (len = (int)STRLEN(cmdbuf)) == 0) - return cmdbuf; - - for (i = 0; i < len; i++) - { - for (cnt = 0; i + cnt < len - && (F_isalpha(cmdbuf[i + cnt]) - || F_isdigit(cmdbuf[i + cnt]) - || cmdbuf[i + cnt] == ' '); ++cnt) - ; - - lrswapbuf(cmdbuf + i, cnt); - i += cnt; - } - return cmdbuf; -} - -/* - * Reverse the characters in the search path and substitute section - * accordingly. - * TODO: handle different separator characters. Use skip_regexp(). - */ - char_u * -lrF_sub(char_u *ibuf) -{ - char_u *p, *ep; - int i, cnt; - - p = ibuf; - - /* Find the boundary of the search path */ - while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '\\') - ; - - if (p == NULL) - return ibuf; - - /* Reverse the Farsi characters in the search path. */ - lrFswap(ibuf, (int)(p-ibuf)); - - /* Now find the boundary of the substitute section */ - if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL) - cnt = (int)(ep - p); - else - cnt = (int)STRLEN(p); - - /* Reverse the characters in the substitute section and take care of '\' */ - for (i = 0; i < cnt-1; i++) - if (p[i] == '\\') - { - p[i] = p[i+1] ; - p[++i] = '\\'; - } - - lrswapbuf(p, cnt); - - return ibuf; -} - -/* - * Map Farsi keyboard when in cmd_fkmap mode. - */ - int -cmdl_fkmap(int c) -{ - int tempc; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '`': - case ' ': - case '.': - case '!': - case '"': - case '$': - case '%': - case '^': - case '&': - case '/': - case '(': - case ')': - case '=': - case '\\': - case '?': - case '+': - case '-': - case '_': - case '*': - case ':': - case '#': - case '~': - case '@': - case '<': - case '>': - case '{': - case '}': - case '|': - case 'B': - case 'E': - case 'F': - case 'H': - case 'I': - case 'K': - case 'L': - case 'M': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'T': - case 'U': - case 'W': - case 'Y': - case NL: - case TAB: - - switch ((tempc = cmd_gchar(AT_CURSOR))) - { - case _BE: - case _PE: - case _TE: - case _SE: - case _JIM: - case _CHE: - case _HE_J: - case _XE: - case _SIN: - case _SHIN: - case _SAD: - case _ZAD: - case _AYN: - case _GHAYN: - case _FE: - case _GHAF: - case _KAF: - case _GAF: - case _LAM: - case _MIM: - case _NOON: - case _HE: - case _HE_: - cmd_pchar(toF_TyA(tempc), AT_CURSOR); - break; - case _AYN_: - cmd_pchar(AYN_, AT_CURSOR); - break; - case _GHAYN_: - cmd_pchar(GHAYN_, AT_CURSOR); - break; - case _IE: - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) - cmd_pchar(IE_, AT_CURSOR); - else - cmd_pchar(IE, AT_CURSOR); - break; - case _YEE: - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) - cmd_pchar(YEE_, AT_CURSOR); - else - cmd_pchar(YEE, AT_CURSOR); - break; - case _YE: - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) - cmd_pchar(YE_, AT_CURSOR); - else - cmd_pchar(YE, AT_CURSOR); - } - - switch (c) - { - case '0': return FARSI_0; - case '1': return FARSI_1; - case '2': return FARSI_2; - case '3': return FARSI_3; - case '4': return FARSI_4; - case '5': return FARSI_5; - case '6': return FARSI_6; - case '7': return FARSI_7; - case '8': return FARSI_8; - case '9': return FARSI_9; - case 'B': return F_PSP; - case 'E': return JAZR_N; - case 'F': return ALEF_D_H; - case 'H': return ALEF_A; - case 'I': return TASH; - case 'K': return F_LQUOT; - case 'L': return F_RQUOT; - case 'M': return HAMZE; - case 'O': return '['; - case 'P': return ']'; - case 'Q': return OO; - case 'R': return MAD_N; - case 'T': return OW; - case 'U': return MAD; - case 'W': return OW_OW; - case 'Y': return JAZR; - case '`': return F_PCN; - case '!': return F_EXCL; - case '@': return F_COMMA; - case '#': return F_DIVIDE; - case '$': return F_CURRENCY; - case '%': return F_PERCENT; - case '^': return F_MUL; - case '&': return F_BCOMMA; - case '*': return F_STAR; - case '(': return F_LPARENT; - case ')': return F_RPARENT; - case '-': return F_MINUS; - case '_': return F_UNDERLINE; - case '=': return F_EQUALS; - case '+': return F_PLUS; - case '\\': return F_BSLASH; - case '|': return F_PIPE; - case ':': return F_DCOLON; - case '"': return F_SEMICOLON; - case '.': return F_PERIOD; - case '/': return F_SLASH; - case '<': return F_LESS; - case '>': return F_GREATER; - case '?': return F_QUESTION; - case ' ': return F_BLANK; - } - - break; - - case 'a': return _SHIN; - case 'A': return WAW_H; - case 'b': return ZAL; - case 'c': return ZE; - case 'C': return JE; - case 'd': return _YE; - case 'D': return _YEE; - case 'e': return _SE; - case 'f': return _BE; - case 'g': return _LAM; - case 'G': - if (cmd_gchar(AT_CURSOR) == _LAM) - { - cmd_pchar(LAM, AT_CURSOR); - return ALEF_U_H; - } - - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) - return ALEF_U_H_; - else - return ALEF_U_H; - case 'h': - if (cmd_gchar(AT_CURSOR) == _LAM) - { - cmd_pchar(LA, AT_CURSOR); - redrawcmdline(); - return K_IGNORE; - } - - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) - return ALEF_; - else - return ALEF; - case 'i': - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) - return _HE_; - else - return _HE; - case 'j': return _TE; - case 'J': - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) - return TEE_; - else - return TEE; - case 'k': return _NOON; - case 'l': return _MIM; - case 'm': return _PE; - case 'n': - case 'N': return DAL; - case 'o': return _XE; - case 'p': return _HE_J; - case 'q': return _ZAD; - case 'r': return _GHAF; - case 's': return _SIN; - case 'S': return _IE; - case 't': return _FE; - case 'u': - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) - return _AYN_; - else - return _AYN; - case 'v': - case 'V': return RE; - case 'w': return _SAD; - case 'x': - case 'X': return _TA; - case 'y': - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) - return _GHAYN_; - else - return _GHAYN; - case 'z': - case 'Z': return _ZA; - case ';': return _KAF; - case '\'': return _GAF; - case ',': return WAW; - case '[': return _JIM; - case ']': return _CHE; - } - - return c; -} - -/* - * F_isalpha returns TRUE if 'c' is a Farsi alphabet - */ - int -F_isalpha(int c) -{ - return ((c >= TEE_ && c <= _YE) - || (c >= ALEF_A && c <= YE) - || (c >= _IE && c <= YE_)); -} - -/* - * F_isdigit returns TRUE if 'c' is a Farsi digit - */ - int -F_isdigit(int c) -{ - return (c >= FARSI_0 && c <= FARSI_9); -} - -/* - * F_ischar returns TRUE if 'c' is a Farsi character. - */ - int -F_ischar(int c) -{ - return (c >= TEE_ && c <= YE_); -} - - void -farsi_f8(cmdarg_T *cap UNUSED) -{ - if (p_altkeymap) - { - if (curwin->w_farsi & W_R_L) - { - p_fkmap = 0; - do_cmdline_cmd((char_u *)"set norl"); - msg(""); - } - else - { - p_fkmap = 1; - do_cmdline_cmd((char_u *)"set rl"); - msg(""); - } - - curwin->w_farsi = curwin->w_farsi ^ W_R_L; - } -} - - void -farsi_f9(cmdarg_T *cap UNUSED) -{ - if (p_altkeymap && curwin->w_p_rl) - { - curwin->w_farsi = curwin->w_farsi ^ W_CONV; - if (curwin->w_farsi & W_CONV) - conv_to_pvim(); - else - conv_to_pstd(); - } -} - -#endif /* FEAT_FKMAP */ diff --git a/src/farsi.h b/src/farsi.h deleted file mode 100644 index e91bdf7272..0000000000 --- a/src/farsi.h +++ /dev/null @@ -1,234 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 noet: - * - * VIM - Vi IMproved by Bram Moolenaar - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - */ - -/* - * Farsi characters are categorized into following types: - * - * TyA (for capital letter representation) - * TyB (for types that look like _X e.g. AYN) - * TyC (for types that look like X_ e.g. YE_) - * TyD (for types that look like _X_ e.g. _AYN_) - * TyE (for types that look like X e.g. RE) - */ - -/* - * Farsi character set definition - */ - -/* - * Begin of the non-standard part - */ - -#define TEE_ 0x80 -#define ALEF_U_H_ 0x81 -#define ALEF_ 0x82 -#define _BE 0x83 -#define _PE 0x84 -#define _TE 0x85 -#define _SE 0x86 -#define _JIM 0x87 -#define _CHE 0x88 -#define _HE_J 0x89 -#define _XE 0x8a -#define _SIN 0x8b -#define _SHIN 0x8c -#define _SAD 0x8d -#define _ZAD 0x8e -#define _AYN 0x8f -#define _AYN_ 0x90 -#define AYN_ 0x91 -#define _GHAYN 0x92 -#define _GHAYN_ 0x93 -#define GHAYN_ 0x94 -#define _FE 0x95 -#define _GHAF 0x96 -#define _KAF 0x97 -#define _GAF 0x98 -#define _LAM 0x99 -#define LA 0x9a -#define _MIM 0x9b -#define _NOON 0x9c -#define _HE 0x9d -#define _HE_ 0x9e -#define _YE 0x9f -#define _IE 0xec -#define IE_ 0xed -#define IE 0xfb -#define _YEE 0xee -#define YEE_ 0xef -#define YE_ 0xff - -/* - * End of the non-standard part - */ - -/* - * Standard part - */ - -#define F_BLANK 0xa0 /* Farsi ' ' (SP) character */ -#define F_PSP 0xa1 /* PSP for capitalizing of a character */ -#define F_PCN 0xa2 /* PCN for redefining of the hamye meaning */ -#define F_EXCL 0xa3 /* Farsi ! character */ -#define F_CURRENCY 0xa4 /* Farsi Rial character */ -#define F_PERCENT 0xa5 /* Farsi % character */ -#define F_PERIOD 0xa6 /* Farsi '.' character */ -#define F_COMMA 0xa7 /* Farsi ',' character */ -#define F_LPARENT 0xa8 /* Farsi '(' character */ -#define F_RPARENT 0xa9 /* Farsi ')' character */ -#define F_MUL 0xaa /* Farsi 'x' character */ -#define F_PLUS 0xab /* Farsi '+' character */ -#define F_BCOMMA 0xac /* Farsi comma character */ -#define F_MINUS 0xad /* Farsi '-' character */ -#define F_DIVIDE 0xae /* Farsi divide (/) character */ -#define F_SLASH 0xaf /* Farsi '/' character */ - -#define FARSI_0 0xb0 -#define FARSI_1 0xb1 -#define FARSI_2 0xb2 -#define FARSI_3 0xb3 -#define FARSI_4 0xb4 -#define FARSI_5 0xb5 -#define FARSI_6 0xb6 -#define FARSI_7 0xb7 -#define FARSI_8 0xb8 -#define FARSI_9 0xb9 - -#define F_DCOLON 0xba /* Farsi ':' character */ -#define F_SEMICOLON 0xbb /* Farsi ';' character */ -#define F_GREATER 0xbc /* Farsi '>' character */ -#define F_EQUALS 0xbd /* Farsi '=' character */ -#define F_LESS 0xbe /* Farsi '<' character */ -#define F_QUESTION 0xbf /* Farsi ? character */ - -#define ALEF_A 0xc0 -#define ALEF 0xc1 -#define HAMZE 0xc2 -#define BE 0xc3 -#define PE 0xc4 -#define TE 0xc5 -#define SE 0xc6 -#define JIM 0xc7 -#define CHE 0xc8 -#define HE_J 0xc9 -#define XE 0xca -#define DAL 0xcb -#define ZAL 0xcc -#define RE 0xcd -#define ZE 0xce -#define JE 0xcf -#define SIN 0xd0 -#define SHIN 0xd1 -#define SAD 0xd2 -#define ZAD 0xd3 -#define _TA 0xd4 -#define _ZA 0xd5 -#define AYN 0xd6 -#define GHAYN 0xd7 -#define FE 0xd8 -#define GHAF 0xd9 -#define KAF 0xda -#define GAF 0xdb -#define LAM 0xdc -#define MIM 0xdd -#define NOON 0xde -#define WAW 0xdf -#define F_HE 0xe0 /* F_ added for name clash with Perl */ -#define YE 0xe1 -#define TEE 0xfc -#define _KAF_H 0xfd -#define YEE 0xfe - -#define F_LBRACK 0xe2 /* Farsi '[' character */ -#define F_RBRACK 0xe3 /* Farsi ']' character */ -#define F_LBRACE 0xe4 /* Farsi '{' character */ -#define F_RBRACE 0xe5 /* Farsi '}' character */ -#define F_LQUOT 0xe6 /* Farsi left quotation character */ -#define F_RQUOT 0xe7 /* Farsi right quotation character */ -#define F_STAR 0xe8 /* Farsi '*' character */ -#define F_UNDERLINE 0xe9 /* Farsi '_' character */ -#define F_PIPE 0xea /* Farsi '|' character */ -#define F_BSLASH 0xeb /* Farsi '\' character */ - -#define MAD 0xf0 -#define JAZR 0xf1 -#define OW 0xf2 -#define MAD_N 0xf3 -#define JAZR_N 0xf4 -#define OW_OW 0xf5 -#define TASH 0xf6 -#define OO 0xf7 -#define ALEF_U_H 0xf8 -#define WAW_H 0xf9 -#define ALEF_D_H 0xfa - -/* - * global definitions - * ================== - */ - -#define SRC_EDT 0 -#define SRC_CMD 1 - -#define AT_CURSOR 0 - -/* - * definitions for the window dependent functions (w_farsi). - */ -#define W_CONV 0x1 -#define W_R_L 0x2 - - -/* special Farsi text messages */ - -EXTERN char farsi_text_1[] -#ifdef DO_INIT - = { YE_, _SIN, RE, ALEF_, _FE, ' ', 'V', 'I', 'M', - ' ', F_HE, _BE, ' ', SHIN, RE, _GAF, DAL,' ', NOON, - ALEF_, _YE, ALEF_, _PE, '\0'} -#endif - ; - -EXTERN char farsi_text_2[] -#ifdef DO_INIT - = { YE_, _SIN, RE, ALEF_, _FE, ' ', FARSI_3, FARSI_3, - FARSI_4, FARSI_2, ' ', DAL, RE, ALEF, DAL, _NOON, - ALEF_, _TE, _SIN, ALEF, ' ', F_HE, _BE, ' ', SHIN, - RE, _GAF, DAL, ' ', NOON, ALEF_, _YE, ALEF_, _PE, '\0'} -#endif - ; - -EXTERN char farsi_text_3[] -#ifdef DO_INIT - = { DAL, WAW, _SHIN, _YE, _MIM, _NOON, ' ', YE_, _NOON, - ALEF_,_BE, _YE, _TE, _SHIN, _PE, ' ', 'R','E','P','L', - 'A','C','E', ' ', NOON, ALEF_, _MIM, RE, _FE, ZE, ALEF, - ' ', 'R', 'E', 'V', 'E', 'R', 'S', 'E', ' ', 'I', 'N', - 'S', 'E', 'R', 'T', ' ', SHIN, WAW, RE, ' ', ALEF_, _BE, - ' ', YE_, _SIN, RE, ALEF_, _FE, ' ', RE, DAL, ' ', RE, - ALEF_, _KAF,' ', MIM, ALEF_, _GAF, _NOON, _HE, '\0'} -#endif - ; - -#if 0 /* not used */ -EXTERN char_u farsi_text_4[] -#ifdef DO_INIT - = { DAL, WAW, _SHIN, _YE, _MIM, _NOON, ' ', YE_, _NOON, - ALEF_, _BE, _YE, _TE, _SHIN, _PE, ' ', '<', 'C','T','R', - 'L','-','B','>', ' ', NOON, ALEF_, _MIM, RE, _FE, ZE, - ALEF, ' ', YE_, _SIN, RE, ALEF_, _FE, ' ', RE, DAL, ' ', - RE, ALEF_, _KAF,' ', MIM, ALEF_, _GAF, _NOON, _HE, '\0'} -#endif - ; -#endif - -EXTERN char farsi_text_5[] -#ifdef DO_INIT - = { ' ', YE_, _SIN, RE, ALEF_, _FE, '\0'} -#endif - ; diff --git a/src/getchar.c b/src/getchar.c index fe74dbfa1c..eaef1ab7e4 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -3361,15 +3361,6 @@ do_map( rhs = replace_termcodes(rhs, &arg_buf, FALSE, TRUE, special); } -#ifdef FEAT_FKMAP - /* - * When in right-to-left mode and alternate keymap option set, - * reverse the character flow in the rhs in Farsi. - */ - if (p_altkeymap && curwin->w_p_rl) - lrswap(rhs); -#endif - /* * check arguments and translate function keys */ diff --git a/src/globals.h b/src/globals.h index 6cc3be2158..82e663e9c6 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1450,9 +1450,7 @@ EXTERN char e_nogvim[] INIT(= N_("E25: GUI cannot be used: Not enabled at compil #ifndef FEAT_RIGHTLEFT EXTERN char e_nohebrew[] INIT(= N_("E26: Hebrew cannot be used: Not enabled at compile time\n")); #endif -#ifndef FEAT_FKMAP -EXTERN char e_nofarsi[] INIT(= N_("E27: Farsi cannot be used: Not enabled at compile time\n")); -#endif +EXTERN char e_nofarsi[] INIT(= N_("E27: Farsi support has been removed\n")); #ifndef FEAT_ARABIC EXTERN char e_noarabic[] INIT(= N_("E800: Arabic cannot be used: Not enabled at compile time\n")); #endif @@ -1655,13 +1653,6 @@ EXTERN int ctrl_break_was_pressed INIT(= FALSE); EXTERN int text_prop_frozen INIT(= 0); #endif -/* - * Optional Farsi support. Include it here, so EXTERN and INIT are defined. - */ -#ifdef FEAT_FKMAP -# include "farsi.h" -#endif - /* * Optional Arabic support. Include it here, so EXTERN and INIT are defined. */ diff --git a/src/main.c b/src/main.c index df204bc0a9..6ad6fff7c5 100644 --- a/src/main.c +++ b/src/main.c @@ -535,17 +535,6 @@ vim_main2(void) if (params.no_swap_file) p_uc = 0; -#ifdef FEAT_FKMAP - if (curwin->w_p_rl && p_altkeymap) - { - p_hkmap = FALSE; /* Reset the Hebrew keymap mode */ -# ifdef FEAT_ARABIC - curwin->w_p_arab = FALSE; /* Reset the Arabic keymap mode */ -# endif - p_fkmap = TRUE; /* Set the Farsi keymap mode */ - } -#endif - #ifdef FEAT_GUI if (gui.starting) { @@ -2025,14 +2014,9 @@ command_line_scan(mparm_T *parmp) main_start_gui(); break; - case 'F': /* "-F" start in Farsi mode: rl + fkmap set */ -#ifdef FEAT_FKMAP - p_fkmap = TRUE; - set_option_value((char_u *)"rl", 1L, NULL, 0); -#else + case 'F': /* "-F" was for Farsi mode */ mch_errmsg(_(e_nofarsi)); mch_exit(2); -#endif break; case '?': /* "-?" give help message (for MS-Windows) */ @@ -3350,9 +3334,6 @@ usage(void) #endif #ifdef FEAT_RIGHTLEFT main_msg(_("-H\t\t\tStart in Hebrew mode")); -#endif -#ifdef FEAT_FKMAP - main_msg(_("-F\t\t\tStart in Farsi mode")); #endif main_msg(_("-T \tSet terminal type to ")); main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal")); diff --git a/src/normal.c b/src/normal.c index 41af966288..624e34751c 100644 --- a/src/normal.c +++ b/src/normal.c @@ -397,10 +397,6 @@ static const struct nv_cmd {K_TABLINE, nv_tabline, 0, 0}, {K_TABMENU, nv_tabmenu, 0, 0}, #endif -#ifdef FEAT_FKMAP - {K_F8, farsi_f8, 0, 0}, - {K_F9, farsi_f9, 0, 0}, -#endif #ifdef FEAT_NETBEANS_INTG {K_F21, nv_nbcmd, NV_NCH_ALW, 0}, #endif @@ -987,11 +983,6 @@ getcount: /* adjust Hebrew mapped char */ if (p_hkmap && lang && KeyTyped) *cp = hkmap(*cp); -# ifdef FEAT_FKMAP - /* adjust Farsi mapped char */ - if (p_fkmap && lang && KeyTyped) - *cp = fkmap(*cp); -# endif #endif } diff --git a/src/option.c b/src/option.c index c8808be041..b9fe3dabef 100644 --- a/src/option.c +++ b/src/option.c @@ -542,11 +542,7 @@ static struct vimoption options[] = #endif {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"altkeymap", "akm", P_BOOL|P_VI_DEF, -#ifdef FEAT_FKMAP - (char_u *)&p_altkeymap, PV_NONE, -#else (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR, (char_u *)&p_ambw, PV_NONE, @@ -1141,11 +1137,7 @@ static struct vimoption options[] = (char_u *)&p_fixeol, PV_FIXEOL, {(char_u *)TRUE, (char_u *)0L} SCTX_INIT}, {"fkmap", "fk", P_BOOL|P_VI_DEF, -#ifdef FEAT_FKMAP - (char_u *)&p_fkmap, PV_NONE, -#else (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"flash", "fl", P_BOOL|P_VI_DEF, (char_u *)NULL, PV_NONE, @@ -8707,69 +8699,6 @@ set_bool_option( } #endif -#ifdef FEAT_FKMAP - else if ((int *)varp == &p_altkeymap) - { - if (old_value != p_altkeymap) - { - if (!p_altkeymap) - { - p_hkmap = p_fkmap; - p_fkmap = 0; - } - else - { - p_fkmap = p_hkmap; - p_hkmap = 0; - } - (void)init_chartab(); - } - } - - /* - * In case some second language keymapping options have changed, check - * and correct the setting in a consistent way. - */ - - /* - * If hkmap or fkmap are set, reset Arabic keymapping. - */ - if ((p_hkmap || p_fkmap) && p_altkeymap) - { - p_altkeymap = p_fkmap; -# ifdef FEAT_ARABIC - curwin->w_p_arab = FALSE; -# endif - (void)init_chartab(); - } - - /* - * If hkmap set, reset Farsi keymapping. - */ - if (p_hkmap && p_altkeymap) - { - p_altkeymap = 0; - p_fkmap = 0; -# ifdef FEAT_ARABIC - curwin->w_p_arab = FALSE; -# endif - (void)init_chartab(); - } - - /* - * If fkmap set, reset Hebrew keymapping. - */ - if (p_fkmap && !p_altkeymap) - { - p_altkeymap = 1; - p_hkmap = 0; -# ifdef FEAT_ARABIC - curwin->w_p_arab = FALSE; -# endif - (void)init_chartab(); - } -#endif - #ifdef FEAT_ARABIC if ((int *)varp == &curwin->w_p_arab) { @@ -8815,12 +8744,6 @@ set_bool_option( /* Force-set the necessary keymap for arabic */ set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", OPT_LOCAL); -# endif -# ifdef FEAT_FKMAP - p_altkeymap = 0; - p_hkmap = 0; - p_fkmap = 0; - (void)init_chartab(); # endif } else @@ -11085,12 +11008,6 @@ win_copy_options(win_T *wp_from, win_T *wp_to) { copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); -# ifdef FEAT_RIGHTLEFT -# ifdef FEAT_FKMAP - /* Is this right? */ - wp_to->w_farsi = wp_from->w_farsi; -# endif -# endif #if defined(FEAT_LINEBREAK) briopt_check(wp_to); #endif diff --git a/src/proto.h b/src/proto.h index 1ab5cf78c3..c19d155169 100644 --- a/src/proto.h +++ b/src/proto.h @@ -99,9 +99,6 @@ extern int _stricoll(char *a, char *b); # ifdef FEAT_MENU # include "menu.pro" # endif -# ifdef FEAT_FKMAP -# include "farsi.pro" -# endif # ifdef FEAT_ARABIC # include "arabic.pro" # endif diff --git a/src/proto/farsi.pro b/src/proto/farsi.pro deleted file mode 100644 index b6e1836511..0000000000 --- a/src/proto/farsi.pro +++ /dev/null @@ -1,12 +0,0 @@ -/* farsi.c */ -int fkmap(int c); -char_u *lrswap(char_u *ibuf); -char_u *lrFswap(char_u *cmdbuf, int len); -char_u *lrF_sub(char_u *ibuf); -int cmdl_fkmap(int c); -int F_isalpha(int c); -int F_isdigit(int c); -int F_ischar(int c); -void farsi_f8(cmdarg_T *cap); -void farsi_f9(cmdarg_T *cap); -/* vim: set ft=c : */ diff --git a/src/screen.c b/src/screen.c index caf6e2c8ba..d06cc3fcb7 100644 --- a/src/screen.c +++ b/src/screen.c @@ -10247,10 +10247,6 @@ showmode(void) #ifdef FEAT_RIGHTLEFT if (p_hkmap) msg_puts_attr(_(" Hebrew"), attr); -# ifdef FEAT_FKMAP - if (p_fkmap) - msg_puts_attr(farsi_text_5, attr); -# endif #endif #ifdef FEAT_KEYMAP if (State & LANGMAP) diff --git a/src/search.c b/src/search.c index df7067b08f..9a47ed4608 100644 --- a/src/search.c +++ b/src/search.c @@ -1477,12 +1477,8 @@ do_search( } } -#ifdef FEAT_FKMAP /* when in Farsi mode, reverse the character flow */ - if (p_altkeymap && curwin->w_p_rl) - lrFswap(searchstr,0); -#endif - - c = searchit(curwin, curbuf, &pos, NULL, dirc == '/' ? FORWARD : BACKWARD, + c = searchit(curwin, curbuf, &pos, NULL, + dirc == '/' ? FORWARD : BACKWARD, searchstr, count, spats[0].off.end + (options & (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS + SEARCH_MSG + SEARCH_START @@ -2976,10 +2972,6 @@ cls(void) int c; c = gchar_cursor(); -#ifdef FEAT_FKMAP /* when 'akm' (Farsi mode), take care of Farsi blank */ - if (p_altkeymap && c == F_BLANK) - return 0; -#endif if (c == ' ' || c == '\t' || c == NUL) return 0; if (enc_dbcs != 0 && c > 0xFF) diff --git a/src/structs.h b/src/structs.h index 4464c4b8d1..fdef811e47 100644 --- a/src/structs.h +++ b/src/structs.h @@ -2952,10 +2952,6 @@ struct window_S dict_T *w_vars; /* internal variables, local to window */ #endif -#if defined(FEAT_RIGHTLEFT) && defined(FEAT_FKMAP) - int w_farsi; /* for the window dependent Farsi functions */ -#endif - /* * The w_prev_pcmark field is used to check whether we really did jump to * a new line after setting the w_pcmark. If not, then we revert to diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 92e2ae3680..7cc5e7eae6 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -118,7 +118,6 @@ NEW_TESTS = \ test_expand_func \ test_expr \ test_expr_utf8 \ - test_farsi \ test_feedkeys \ test_file_perm \ test_file_size \ @@ -318,7 +317,6 @@ NEW_TESTS_RES = \ test_exists.res \ test_exists_autocmd.res \ test_exit.res \ - test_farsi.res \ test_file_size.res \ test_filechanged.res \ test_find_complete.res \ diff --git a/src/testdir/test_farsi.vim b/src/testdir/test_farsi.vim deleted file mode 100644 index dcfa0248c1..0000000000 --- a/src/testdir/test_farsi.vim +++ /dev/null @@ -1,133 +0,0 @@ -" Simplistic testing of Farsi mode. -" Note: must be edited with latin1 encoding. - -if !has('farsi') - finish -endif -" Farsi uses a single byte encoding. -set enc=latin1 - -func Test_farsi_toggle() - new - - set altkeymap - call assert_equal(0, &fkmap) - call assert_equal(0, &rl) - call feedkeys("\", 'x') - call assert_equal(1, &fkmap) - call assert_equal(1, &rl) - call feedkeys("\", 'x') - call assert_equal(0, &fkmap) - call assert_equal(0, &rl) - - set rl - " conversion from Farsi 3342 to Farsi VIM. - call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), '')) - call feedkeys("\", 'x') - let exp = [0xfc, 0xf8, 0xc1, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - \ 0xc8, 0xc9, 0xca, 0xd0, 0xd1, 0xd2, 0xd3, 0xd6, - \ 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd9, 0xda, - \ 0xdb, 0xdc, 0xdc, 0xc1, 0xdd, 0xde, 0xe0, 0xe0, - \ 0xe1, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, - \ 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, - \ 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - \ 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, - \ 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, - \ 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, - \ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, - \ 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, - \ 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, - \ 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xfb, 0xfb, 0xfe, - \ 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, - \ 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xe1, - \ ] - call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1)) - - " conversion from Farsi VIM to Farsi 3342. - call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), '')) - call feedkeys("\", 'x') - let exp = [0xfc, 0xf8, 0xc1, 0x83, 0x84, 0x85, 0x86, 0x87, - \ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x90, - \ 0x90, 0x90, 0x92, 0x93, 0x93, 0x95, 0x96, 0x97, - \ 0x98, 0xdc, 0x9a, 0x9b, 0x9c, 0x9e, 0x9e, 0xff, - \ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - \ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - \ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - \ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - \ 0xc0, 0xc1, 0xc2, 0x83, 0x84, 0x85, 0x86, 0x87, - \ 0x88, 0x89, 0x8a, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - \ 0x8b, 0x8c, 0x8d, 0x8e, 0xd4, 0xd5, 0x90, 0x93, - \ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0xdf, - \ 0x9d, 0xff, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - \ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xec, 0xee, 0xef, - \ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - \ 0xf8, 0xf9, 0xfa, 0xec, 0x80, 0xfd, 0xee, 0xff, - \ ] - call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1)) - - bwipe! -endfunc - -func Test_farsi_map() - new - - set altkeymap - set rl - " RHS of mapping is reversed. - imap xyz abc - call feedkeys("axyz\", 'tx') - call assert_equal('cba', getline(1)) - - set norl - iunmap xyz - set noaltkeymap - bwipe! -endfunc - -func Test_input_farsi() - new - setlocal rightleft fkmap - " numbers switch input direction - call feedkeys("aabc0123456789.+-^%#=xyz\", 'tx') - call assert_equal("\x8cÌν®¥ª­«¦¹¸·¶µ´³²±°Ô\x93Õ", getline('.')) - - " all non-number special chars with spaces - call feedkeys("oB E F H I K L M O P Q R T U W Y ` ! @ # $ % ^ & * () - _ = + \\ | : \" . / < > ? \", 'tx') - call assert_equal("¡ ô ú À ö æ ç Â [ ] ÷ ó ò ð õ ñ ¢ £  § ® ¤ ¥ ª ¬ è ¨© ­ é ½ « ë ê º » ¦  ¯ ¾ ¼ ¿ ", getline('.')) - - " all non-number special chars without spaces - call feedkeys("oBEFHIKLMOPQRTUWY`!@#$%^&*()-_=+\\|:\"./<>?\",'tx') - call assert_equal("¡ôúÀöæçÂ[]÷óòðõñ¢£§®¤¥ª¬è¨©­é½«ë꺻¦¯¾¼¿", getline('.')) - - " all letter chars with spaces - call feedkeys("oa A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \ , [ ] \", 'tx') - call assert_equal("Ñ ù Ì Î Ï á þ Æ Ã Ü ø Á à Å ü Þ Ý Ä Ë Ë Ê É Ó Ù Ð û Ø Ö Í Í Ò Ô Ô × Õ ý Ú  ß Ç È ", getline('.')) - - " all letter chars without spaces - call feedkeys("oaAbcCdDefgGhijJklmnNopqrsStuvVwxXyzZ;\,[]\", 'tx') - call assert_equal("\x8cùÌÎÏ\x9fî\x86\x83ÜøÁ\x9d\x85\x80\x9c\x9b\x84ËË\x8a\x89\x8e\x96\x8bì\x95\x90ÍÍ\x8dÔÔ\x93Õý\x97ß\x87\x88", getline('.')) - - bwipe! -endfunc - -func Test_command_line_farsi() - set allowrevins altkeymap - - " letter characters with spaces - call feedkeys(":\"\a A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \\ , [ ]\", 'tx') - call assert_equal("\"\x88 Ç ß ë Ú Õ Õ × Ô Ô Ò Í Í Ö Ø û Ð Ù Ó É Ê Ë Ë Ä Ý Þ ü Å à Á ø Ü Ã Æ þ á Ï Î Ì ù Ñ", getreg(':')) - - " letter characters without spaces - call feedkeys(":\"\aAbcCdDefgGhijJklmnNopqrsStuvVwxXyzZ;\\,[]\", 'tx') - call assert_equal("\"\x88\x87ßëÚÕÕ\x93ÔÔ\x8dÍÍ\x90\x95ì\x8b\x96\x8e\x89\x8aËË\x84\x9b\x9c\x80\x85\x9dÁøÜ\x83\x86î\x9fÏÎÌù\x8c", getreg(':')) - - " other characters with spaces - call feedkeys(":\"\0 1 2 3 4 5 6 7 8 9 ` . ! \" $ % ^ & / () = \\ ? + - _ * : # ~ @ < > { } | B E F H I K L M O P Q R T U W Y\", 'tx') - call assert_equal("\"ñ õ ð ò ó ÷ ] [ Â ç æ ö À ú ô ¡ ê } { ¼ ¾ § ~ ® º è é ­ «  ¿ ë ½ ©¨ ¯ ¬ ª ¥ ¤ »  £  ¦ ¢ ¹ ¸ · ¶ µ ´ ³ ² ± °", getreg(':')) - - " other characters without spaces - call feedkeys(":\"\0123456789`.!\"$%^&/()=\\?+-_*:#~@<>{}|BEFHIKLMOPQRTUWY\", 'tx') - call assert_equal("\"ñõðòó÷][ÂçæöÀúô¡ê}{¼¾§~®ºèé­«¿ë½©¨¯¬ª¥¤»£¦¢¹¸·¶µ´³²±°", getreg(':')) - - set noallowrevins noaltkeymap -endfunc diff --git a/src/version.c b/src/version.c index 00c63e53ce..aa73ebd878 100644 --- a/src/version.c +++ b/src/version.c @@ -255,11 +255,7 @@ static char *(features[]) = #else "-extra_search", #endif -#ifdef FEAT_FKMAP - "+farsi", -#else "-farsi", -#endif #ifdef FEAT_SEARCHPATH "+file_in_path", #else @@ -783,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 932, /**/ 931, /**/ diff --git a/src/window.c b/src/window.c index 7dc3848e42..c4b543de39 100644 --- a/src/window.c +++ b/src/window.c @@ -3445,12 +3445,6 @@ win_init_empty(win_T *wp) wp->w_topfill = 0; #endif wp->w_botline = 2; -#ifdef FEAT_FKMAP - if (wp->w_p_rl) - wp->w_farsi = W_CONV + W_R_L; - else - wp->w_farsi = W_CONV; -#endif #ifdef FEAT_SYN_HL wp->w_s = &wp->w_buffer->b_s; #endif From 6982f42f33b2868e4b9884514cfe8e357b727498 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 16:48:01 +0100 Subject: [PATCH 61/75] patch 8.1.0933: When using VTP scroll region isn't used properly Problem: When using VTP scroll region isn't used properly. Solution: Make better use of the scroll region. (Nobuhiro Takasaki, closes #3974) --- src/os_win32.c | 122 +++++++++++++++++++++++++++++++------------------ src/term.c | 76 ++++++++++++++++-------------- src/version.c | 2 + 3 files changed, 120 insertions(+), 80 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index 816c3a59cf..3627532cac 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -171,6 +171,9 @@ static int g_fForceExit = FALSE; /* set when forcefully exiting */ static void scroll(unsigned cLines); static void set_scroll_region(unsigned left, unsigned top, unsigned right, unsigned bottom); +static void set_scroll_region_tb(unsigned top, unsigned bottom); +static void set_scroll_region_lr(unsigned left, unsigned right); +static void insert_lines(unsigned cLines); static void delete_lines(unsigned cLines); static void gotoxy(unsigned x, unsigned y); static void standout(void); @@ -5392,7 +5395,7 @@ create_pipe_pair(HANDLE handles[2]) if (handles[0] == INVALID_HANDLE_VALUE) { - CloseHandle(handles[1]); + CloseHandle(handles[1]); return FALSE; } @@ -5976,9 +5979,30 @@ set_scroll_region( g_srScrollRegion.Top = top; g_srScrollRegion.Right = right; g_srScrollRegion.Bottom = bottom; +} - if (USE_VTP) - vtp_printf("\033[%d;%dr", top + 1, bottom + 1); + static void +set_scroll_region_tb( + unsigned top, + unsigned bottom) +{ + if (top >= bottom || bottom > (unsigned)Rows - 1) + return; + + g_srScrollRegion.Top = top; + g_srScrollRegion.Bottom = bottom; +} + + static void +set_scroll_region_lr( + unsigned left, + unsigned right) +{ + if (left >= right || right > (unsigned)Columns - 1) + return; + + g_srScrollRegion.Left = left; + g_srScrollRegion.Right = right; } @@ -5988,47 +6012,49 @@ set_scroll_region( static void insert_lines(unsigned cLines) { - SMALL_RECT source; + SMALL_RECT source, clip; COORD dest; CHAR_INFO fill; - dest.X = 0; + dest.X = g_srScrollRegion.Left; dest.Y = g_coord.Y + cLines; - source.Left = 0; + source.Left = g_srScrollRegion.Left; source.Top = g_coord.Y; source.Right = g_srScrollRegion.Right; source.Bottom = g_srScrollRegion.Bottom - cLines; - if (!USE_VTP) + clip.Left = g_srScrollRegion.Left; + clip.Top = g_coord.Y; + clip.Right = g_srScrollRegion.Right; + clip.Bottom = g_srScrollRegion.Bottom; + { fill.Char.AsciiChar = ' '; - fill.Attributes = g_attrCurrent; + fill.Attributes = g_attrDefault; - ScrollConsoleScreenBuffer(g_hConOut, &source, NULL, dest, &fill); - } - else - { set_console_color_rgb(); - gotoxy(1, source.Top + 1); - vtp_printf("\033[%dT", cLines); + ScrollConsoleScreenBuffer(g_hConOut, &source, &clip, dest, &fill); } - - /* Here we have to deal with a win32 console flake: If the scroll - * region looks like abc and we scroll c to a and fill with d we get - * cbd... if we scroll block c one line at a time to a, we get cdd... - * vim expects cdd consistently... So we have to deal with that - * here... (this also occurs scrolling the same way in the other - * direction). */ + // Here we have to deal with a win32 console flake: If the scroll + // region looks like abc and we scroll c to a and fill with d we get + // cbd... if we scroll block c one line at a time to a, we get cdd... + // vim expects cdd consistently... So we have to deal with that + // here... (this also occurs scrolling the same way in the other + // direction). if (source.Bottom < dest.Y) { COORD coord; + int i; - coord.X = 0; - coord.Y = source.Bottom; - clear_chars(coord, Columns * (dest.Y - source.Bottom)); + coord.X = source.Left; + for (i = clip.Top; i < dest.Y; ++i) + { + coord.Y = i; + clear_chars(coord, source.Right - source.Left + 1); + } } } @@ -6039,50 +6065,48 @@ insert_lines(unsigned cLines) static void delete_lines(unsigned cLines) { - SMALL_RECT source; + SMALL_RECT source, clip; COORD dest; CHAR_INFO fill; int nb; - dest.X = 0; + dest.X = g_srScrollRegion.Left; dest.Y = g_coord.Y; - source.Left = 0; + source.Left = g_srScrollRegion.Left; source.Top = g_coord.Y + cLines; source.Right = g_srScrollRegion.Right; source.Bottom = g_srScrollRegion.Bottom; - if (!USE_VTP) + clip.Left = g_srScrollRegion.Left; + clip.Top = g_coord.Y; + clip.Right = g_srScrollRegion.Right; + clip.Bottom = g_srScrollRegion.Bottom; + { fill.Char.AsciiChar = ' '; - fill.Attributes = g_attrCurrent; + fill.Attributes = g_attrDefault; - ScrollConsoleScreenBuffer(g_hConOut, &source, NULL, dest, &fill); - } - else - { set_console_color_rgb(); - gotoxy(1, source.Top + 1); - vtp_printf("\033[%dS", cLines); + ScrollConsoleScreenBuffer(g_hConOut, &source, &clip, dest, &fill); } - - /* Here we have to deal with a win32 console flake: If the scroll - * region looks like abc and we scroll c to a and fill with d we get - * cbd... if we scroll block c one line at a time to a, we get cdd... - * vim expects cdd consistently... So we have to deal with that - * here... (this also occurs scrolling the same way in the other - * direction). */ + // Here we have to deal with a win32 console flake; See insert_lines() + // above. nb = dest.Y + (source.Bottom - source.Top) + 1; if (nb < source.Top) { COORD coord; + int i; - coord.X = 0; - coord.Y = nb; - clear_chars(coord, Columns * (source.Top - nb)); + coord.X = source.Left; + for (i = nb; i < clip.Bottom; ++i) + { + coord.Y = i; + clear_chars(coord, source.Right - source.Left + 1); + } } } @@ -6508,6 +6532,14 @@ mch_write( { set_scroll_region(0, arg1 - 1, Columns - 1, arg2 - 1); } + else if (argc == 2 && *p == 'R') + { + set_scroll_region_tb(arg1, arg2); + } + else if (argc == 2 && *p == 'V') + { + set_scroll_region_lr(arg1, arg2); + } else if (argc == 1 && *p == 'A') { gotoxy(g_coord.X + 1, diff --git a/src/term.c b/src/term.c index be33fb92d5..9eebd28cb1 100644 --- a/src/term.c +++ b/src/term.c @@ -540,63 +540,65 @@ static struct builtin_term builtin_termcaps[] = * are also translated in os_win32.c. */ {(int)KS_NAME, "win32"}, - {(int)KS_CE, "\033|K"}, /* clear to end of line */ - {(int)KS_AL, "\033|L"}, /* add new blank line */ + {(int)KS_CE, "\033|K"}, // clear to end of line + {(int)KS_AL, "\033|L"}, // add new blank line # ifdef TERMINFO - {(int)KS_CAL, "\033|%p1%dL"}, /* add number of new blank lines */ + {(int)KS_CAL, "\033|%p1%dL"}, // add number of new blank lines # else - {(int)KS_CAL, "\033|%dL"}, /* add number of new blank lines */ + {(int)KS_CAL, "\033|%dL"}, // add number of new blank lines # endif - {(int)KS_DL, "\033|M"}, /* delete line */ + {(int)KS_DL, "\033|M"}, // delete line # ifdef TERMINFO - {(int)KS_CDL, "\033|%p1%dM"}, /* delete number of lines */ + {(int)KS_CDL, "\033|%p1%dM"}, // delete number of lines + {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, # else - {(int)KS_CDL, "\033|%dM"}, /* delete number of lines */ + {(int)KS_CDL, "\033|%dM"}, // delete number of lines + {(int)KS_CSV, "\033|%d;%dV"}, # endif - {(int)KS_CL, "\033|J"}, /* clear screen */ - {(int)KS_CD, "\033|j"}, /* clear to end of display */ - {(int)KS_VI, "\033|v"}, /* cursor invisible */ - {(int)KS_VE, "\033|V"}, /* cursor visible */ + {(int)KS_CL, "\033|J"}, // clear screen + {(int)KS_CD, "\033|j"}, // clear to end of display + {(int)KS_VI, "\033|v"}, // cursor invisible + {(int)KS_VE, "\033|V"}, // cursor visible - {(int)KS_ME, "\033|0m"}, /* normal */ - {(int)KS_MR, "\033|112m"}, /* reverse: black on lightgray */ - {(int)KS_MD, "\033|15m"}, /* bold: white on black */ + {(int)KS_ME, "\033|0m"}, // normal + {(int)KS_MR, "\033|112m"}, // reverse: black on lightgray + {(int)KS_MD, "\033|15m"}, // bold: white on black #if 1 - {(int)KS_SO, "\033|31m"}, /* standout: white on blue */ - {(int)KS_SE, "\033|0m"}, /* standout end */ + {(int)KS_SO, "\033|31m"}, // standout: white on blue + {(int)KS_SE, "\033|0m"}, // standout end #else - {(int)KS_SO, "\033|F"}, /* standout: high intensity */ - {(int)KS_SE, "\033|f"}, /* standout end */ + {(int)KS_SO, "\033|F"}, // standout: high intensity + {(int)KS_SE, "\033|f"}, // standout end #endif - {(int)KS_CZH, "\033|225m"}, /* italic: blue text on yellow */ - {(int)KS_CZR, "\033|0m"}, /* italic end */ - {(int)KS_US, "\033|67m"}, /* underscore: cyan text on red */ - {(int)KS_UE, "\033|0m"}, /* underscore end */ - {(int)KS_CCO, "16"}, /* allow 16 colors */ + {(int)KS_CZH, "\033|225m"}, // italic: blue text on yellow + {(int)KS_CZR, "\033|0m"}, // italic end + {(int)KS_US, "\033|67m"}, // underscore: cyan text on red + {(int)KS_UE, "\033|0m"}, // underscore end + {(int)KS_CCO, "16"}, // allow 16 colors # ifdef TERMINFO - {(int)KS_CAB, "\033|%p1%db"}, /* set background color */ - {(int)KS_CAF, "\033|%p1%df"}, /* set foreground color */ + {(int)KS_CAB, "\033|%p1%db"}, // set background color + {(int)KS_CAF, "\033|%p1%df"}, // set foreground color # else - {(int)KS_CAB, "\033|%db"}, /* set background color */ - {(int)KS_CAF, "\033|%df"}, /* set foreground color */ + {(int)KS_CAB, "\033|%db"}, // set background color + {(int)KS_CAF, "\033|%df"}, // set foreground color # endif - {(int)KS_MS, "y"}, /* save to move cur in reverse mode */ + {(int)KS_MS, "y"}, // save to move cur in reverse mode {(int)KS_UT, "y"}, {(int)KS_XN, "y"}, {(int)KS_LE, "\b"}, # ifdef TERMINFO - {(int)KS_CM, "\033|%i%p1%d;%p2%dH"},/* cursor motion */ + {(int)KS_CM, "\033|%i%p1%d;%p2%dH"}, // cursor motion # else - {(int)KS_CM, "\033|%i%d;%dH"},/* cursor motion */ + {(int)KS_CM, "\033|%i%d;%dH"}, // cursor motion # endif - {(int)KS_VB, "\033|B"}, /* visual bell */ - {(int)KS_TI, "\033|S"}, /* put terminal in termcap mode */ - {(int)KS_TE, "\033|E"}, /* out of termcap mode */ + {(int)KS_VB, "\033|B"}, // visual bell + {(int)KS_TI, "\033|S"}, // put terminal in termcap mode + {(int)KS_TE, "\033|E"}, // out of termcap mode # ifdef TERMINFO - {(int)KS_CS, "\033|%i%p1%d;%p2%dr"},/* scroll region */ + {(int)KS_CS, "\033|%i%p1%d;%p2%dr"}, // scroll region # else - {(int)KS_CS, "\033|%i%d;%dr"},/* scroll region */ + {(int)KS_CS, "\033|%i%d;%dr"}, // scroll region # endif # ifdef FEAT_TERMGUICOLORS {(int)KS_8F, "\033|38;2;%lu;%lu;%lum"}, @@ -6778,9 +6780,13 @@ static struct ks_tbl_s ks_tbl[] = # ifdef TERMINFO {(int)KS_CAB, "\033|%p1%db", "\033|%p14%dm"}, // set background color {(int)KS_CAF, "\033|%p1%df", "\033|%p13%dm"}, // set foreground color + {(int)KS_CS, "\033|%p1%d;%p2%dR", "\033|%p1%d;%p2%dR"}, + {(int)KS_CSV, "\033|%p1%d;%p2%dV", "\033|%p1%d;%p2%dV"}, # else {(int)KS_CAB, "\033|%db", "\033|4%dm"}, // set background color {(int)KS_CAF, "\033|%df", "\033|3%dm"}, // set foreground color + {(int)KS_CS, "\033|%d;%dR", "\033|%d;%dR"}, + {(int)KS_CSV, "\033|%d;%dV", "\033|%d;%dV"}, # endif {(int)KS_CCO, "256", "256"}, // colors {(int)KS_NAME} // terminator diff --git a/src/version.c b/src/version.c index aa73ebd878..21b9217878 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 933, /**/ 932, /**/ From 985079c514e9ab85598b7bca019c77d3e42526f5 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 17:07:47 +0100 Subject: [PATCH 62/75] patch 8.1.0934: invalid memory access in search pattern Problem: Invalid memory access in search pattern. (Kuang-che Wu) Solution: Check for incomplete equivalence class. (closes #3970) --- src/regexp.c | 2 +- src/testdir/test_regexp_latin.vim | 7 +++++++ src/version.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/regexp.c b/src/regexp.c index f06e15c833..30a604b236 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -730,7 +730,7 @@ get_equi_class(char_u **pp) int l = 1; char_u *p = *pp; - if (p[1] == '=') + if (p[1] == '=' && p[2] != NUL) { if (has_mbyte) l = (*mb_ptr2len)(p + 2); diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index bcac6c72c8..09104a1423 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -97,3 +97,10 @@ func Test_out_of_memory() " This will be slow... call assert_fails('call search("\\v((n||<)+);")', 'E363:') endfunc + +func Test_get_equi_class() + new + " Incomplete equivalence class caused invalid memory access + s/^/[[= + call assert_equal(1, search(getline(1))) +endfunc diff --git a/src/version.c b/src/version.c index 21b9217878..dbf4083419 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 934, /**/ 933, /**/ From 8bfd9469cef536f171e6666f9d9217192e09d161 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 18:07:57 +0100 Subject: [PATCH 63/75] patch 8.1.0935: old regexp engine may use invalid buffer Problem: Old regexp engine may use invalid buffer for 'iskeyword' or uninitialized buffer pointer. (Kuang-che Wu) Solution: Set rex.reg_buf when compiling the pattern. (closes #3972) --- src/regexp.c | 2 ++ src/testdir/test_regexp_latin.vim | 16 ++++++++++++++++ src/version.c | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/regexp.c b/src/regexp.c index 30a604b236..8362048951 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -7998,6 +7998,8 @@ vim_regcomp(char_u *expr_arg, int re_flags) bt_regengine.expr = expr; nfa_regengine.expr = expr; #endif + // reg_iswordc() uses rex.reg_buf + rex.reg_buf = curbuf; /* * First try the NFA engine, unless backtracking was requested. diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index 09104a1423..d63b4f9580 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -104,3 +104,19 @@ func Test_get_equi_class() s/^/[[= call assert_equal(1, search(getline(1))) endfunc + +func Test_rex_init() + set noincsearch + set re=1 + new + setlocal iskeyword=a-z + call setline(1, ['abc', 'ABC']) + call assert_equal(1, search('[[:keyword:]]')) + new + setlocal iskeyword=A-Z + call setline(1, ['abc', 'ABC']) + call assert_equal(2, search('[[:keyword:]]')) + bwipe! + bwipe! + set re=0 +endfunc diff --git a/src/version.c b/src/version.c index dbf4083419..8dd86f0b00 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 935, /**/ 934, /**/ From 55c77cf2ea9c15e1ec75d1faf702ec3c9e325271 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Feb 2019 19:05:11 +0100 Subject: [PATCH 64/75] patch 8.1.0936: may leak memory when using 'vartabstop' Problem: May leak memory when using 'vartabstop'. (Kuang-che Wu) Solution: Fix handling allocated memory for 'vartabstop'. (closes #3976) --- src/buffer.c | 4 +--- src/option.c | 13 +++++++++---- src/version.c | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index db0c591613..49d38ed31d 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2170,9 +2170,7 @@ free_buf_options( vim_free(buf->b_p_vsts_array); buf->b_p_vsts_array = NULL; clear_string_option(&buf->b_p_vts); - if (buf->b_p_vts_array) - vim_free(buf->b_p_vts_array); - buf->b_p_vts_array = NULL; + VIM_CLEAR(buf->b_p_vts_array); #endif #ifdef FEAT_KEYMAP clear_string_option(&buf->b_p_keymap); diff --git a/src/option.c b/src/option.c index b9fe3dabef..eec8fe0520 100644 --- a/src/option.c +++ b/src/option.c @@ -5594,7 +5594,9 @@ didset_options2(void) (void)check_clipboard_option(); #endif #ifdef FEAT_VARTABS + vim_free(curbuf->b_p_vsts_array); tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); + vim_free(curbuf->b_p_vts_array); tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array); #endif } @@ -7572,14 +7574,14 @@ did_set_string_option( if (errmsg == NULL) { int *oldarray = curbuf->b_p_vts_array; + if (tabstop_set(*varp, &(curbuf->b_p_vts_array))) { - if (oldarray) - vim_free(oldarray); + vim_free(oldarray); #ifdef FEAT_FOLDING if (foldmethodIsIndent(curwin)) foldUpdateAll(curwin); -#endif /* FEAT_FOLDING */ +#endif } else errmsg = e_invarg; @@ -12706,10 +12708,11 @@ check_ff_value(char_u *p) return check_opt_strings(p, p_ff_values, FALSE); } -#ifdef FEAT_VARTABS +#if defined(FEAT_VARTABS) || defined(PROTO) /* * Set the integer values corresponding to the string setting of 'vartabstop'. + * "array" will be set, caller must free it if needed. */ int tabstop_set(char_u *var, int **array) @@ -12752,6 +12755,8 @@ tabstop_set(char_u *var, int **array) } *array = (int *)alloc((unsigned) ((valcount + 1) * sizeof(int))); + if (*array == NULL) + return FALSE; (*array)[0] = valcount; t = 1; diff --git a/src/version.c b/src/version.c index 8dd86f0b00..81bafe5781 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 936, /**/ 935, /**/ From f1b57ab2ab18032d19f64bff7d22f3adb3fe93f7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 13:53:34 +0100 Subject: [PATCH 65/75] patch 8.1.0937: invalid memory access in search pattern Problem: Invalid memory access in search pattern. (Kuang-che Wu) Solution: Check for incomplete collation element. (Dominique Pelle, closes #3985) --- src/regexp.c | 2 +- src/testdir/test_regexp_latin.vim | 2 ++ src/version.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/regexp.c b/src/regexp.c index 8362048951..e37c065079 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -1111,7 +1111,7 @@ get_coll_element(char_u **pp) int l = 1; char_u *p = *pp; - if (p[0] != NUL && p[1] == '.') + if (p[0] != NUL && p[1] == '.' && p[2] != NUL) { if (has_mbyte) l = (*mb_ptr2len)(p + 2); diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index d63b4f9580..d30312a11e 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -103,6 +103,8 @@ func Test_get_equi_class() " Incomplete equivalence class caused invalid memory access s/^/[[= call assert_equal(1, search(getline(1))) + s/.*/[[. + call assert_equal(1, search(getline(1))) endfunc func Test_rex_init() diff --git a/src/version.c b/src/version.c index 81bafe5781..8509e0666c 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 937, /**/ 936, /**/ From 21edde87426eeeaf46e118a137a7fa0e86ad167e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 14:10:56 +0100 Subject: [PATCH 66/75] patch 8.1.0938: background color is wrong in MS-Windows console Problem: Background color is wrong in MS-Windows console when not using VTP. Solution: Use g_attrCurrent. (Nobuhiro Takasaki, closes #3987) --- src/os_win32.c | 10 ++++++++-- src/version.c | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index 3627532cac..97fc2a401b 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -6031,7 +6031,10 @@ insert_lines(unsigned cLines) { fill.Char.AsciiChar = ' '; - fill.Attributes = g_attrDefault; + if (!USE_VTP) + fill.Attributes = g_attrCurrent; + else + fill.Attributes = g_attrDefault; set_console_color_rgb(); @@ -6085,7 +6088,10 @@ delete_lines(unsigned cLines) { fill.Char.AsciiChar = ' '; - fill.Attributes = g_attrDefault; + if (!USE_VTP) + fill.Attributes = g_attrCurrent; + else + fill.Attributes = g_attrDefault; set_console_color_rgb(); diff --git a/src/version.c b/src/version.c index 8509e0666c..df3aa4813c 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 938, /**/ 937, /**/ From 3678f65d43d10b36dc62738aab2f341fa1e18a32 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 14:50:25 +0100 Subject: [PATCH 67/75] patch 8.1.0939: no completion for sign group names Problem: No completion for sign group names. Solution: Add completion for sign group names and buffer names. (Yegappan Lakshmanan, closes #3980) --- src/sign.c | 128 ++++++++++++++++++++++++++----------- src/testdir/test_signs.vim | 64 +++++++++++++++++-- src/version.c | 2 + 3 files changed, 153 insertions(+), 41 deletions(-) diff --git a/src/sign.c b/src/sign.c index 44b638caff..cc51901072 100644 --- a/src/sign.c +++ b/src/sign.c @@ -1767,10 +1767,58 @@ static enum EXP_SUBCMD, // expand :sign sub-commands EXP_DEFINE, // expand :sign define {name} args EXP_PLACE, // expand :sign place {id} args + EXP_LIST, // expand :sign place args EXP_UNPLACE, // expand :sign unplace" - EXP_SIGN_NAMES // expand with name of placed signs + EXP_SIGN_NAMES, // expand with name of placed signs + EXP_SIGN_GROUPS // expand with name of placed sign groups } expand_what; +/* + * Return the n'th sign name (used for command line completion) + */ + static char_u * +get_nth_sign_name(int idx) +{ + int current_idx; + sign_T *sp; + + // Complete with name of signs already defined + current_idx = 0; + for (sp = first_sign; sp != NULL; sp = sp->sn_next) + if (current_idx++ == idx) + return sp->sn_name; + return NULL; +} + +/* + * Return the n'th sign group name (used for command line completion) + */ + static char_u * +get_nth_sign_group_name(int idx) +{ + int current_idx; + int todo; + hashitem_T *hi; + signgroup_T *group; + + // Complete with name of sign groups already defined + current_idx = 0; + todo = (int)sg_table.ht_used; + for (hi = sg_table.ht_array; todo > 0; ++hi) + { + if (!HASHITEM_EMPTY(hi)) + { + --todo; + if (current_idx++ == idx) + { + group = HI2SG(hi); + return group->sg_name; + } + } + } + return NULL; +} + /* * Function given to ExpandGeneric() to obtain the sign command * expansion. @@ -1778,9 +1826,6 @@ static enum char_u * get_sign_name(expand_T *xp UNUSED, int idx) { - sign_T *sp; - int current_idx; - switch (expand_what) { case EXP_SUBCMD: @@ -1802,18 +1847,23 @@ get_sign_name(expand_T *xp UNUSED, int idx) }; return (char_u *)place_arg[idx]; } + case EXP_LIST: + { + char *list_arg[] = + { + "group=", "file=", "buffer=", NULL + }; + return (char_u *)list_arg[idx]; + } case EXP_UNPLACE: { char *unplace_arg[] = { "group=", "file=", "buffer=", NULL }; return (char_u *)unplace_arg[idx]; } case EXP_SIGN_NAMES: - // Complete with name of signs already defined - current_idx = 0; - for (sp = first_sign; sp != NULL; sp = sp->sn_next) - if (current_idx++ == idx) - return sp->sn_name; - return NULL; + return get_nth_sign_name(idx); + case EXP_SIGN_GROUPS: + return get_nth_sign_group_name(idx); default: return NULL; } @@ -1848,28 +1898,6 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg) // | // begin_subcmd_args begin_subcmd_args = skipwhite(end_subcmd); - p = skiptowhite(begin_subcmd_args); - if (*p == NUL) - { - // - // Expand first argument of subcmd when possible. - // For ":jump {id}" and ":unplace {id}", we could - // possibly expand the ids of all signs already placed. - // - xp->xp_pattern = begin_subcmd_args; - switch (cmd_idx) - { - case SIGNCMD_LIST: - case SIGNCMD_UNDEFINE: - // :sign list - // :sign undefine - expand_what = EXP_SIGN_NAMES; - break; - default: - xp->xp_context = EXPAND_NOTHING; - } - return; - } // expand last argument of subcmd @@ -1878,6 +1906,7 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg) // p // Loop until reaching last argument. + p = begin_subcmd_args; do { p = skipwhite(p); @@ -1900,7 +1929,19 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg) expand_what = EXP_DEFINE; break; case SIGNCMD_PLACE: - expand_what = EXP_PLACE; + // List placed signs + if (VIM_ISDIGIT(*begin_subcmd_args)) + // :sign place {id} {args}... + expand_what = EXP_PLACE; + else + // :sign place {args}... + expand_what = EXP_LIST; + break; + case SIGNCMD_LIST: + case SIGNCMD_UNDEFINE: + // :sign list + // :sign undefine + expand_what = EXP_SIGN_NAMES; break; case SIGNCMD_JUMP: case SIGNCMD_UNPLACE: @@ -1917,17 +1958,30 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg) switch (cmd_idx) { case SIGNCMD_DEFINE: - if (STRNCMP(last, "texthl", p - last) == 0 - || STRNCMP(last, "linehl", p - last) == 0) + if (STRNCMP(last, "texthl", 6) == 0 + || STRNCMP(last, "linehl", 6) == 0) xp->xp_context = EXPAND_HIGHLIGHT; - else if (STRNCMP(last, "icon", p - last) == 0) + else if (STRNCMP(last, "icon", 4) == 0) xp->xp_context = EXPAND_FILES; else xp->xp_context = EXPAND_NOTHING; break; case SIGNCMD_PLACE: - if (STRNCMP(last, "name", p - last) == 0) + if (STRNCMP(last, "name", 4) == 0) expand_what = EXP_SIGN_NAMES; + else if (STRNCMP(last, "group", 5) == 0) + expand_what = EXP_SIGN_GROUPS; + else if (STRNCMP(last, "file", 4) == 0) + xp->xp_context = EXPAND_BUFFERS; + else + xp->xp_context = EXPAND_NOTHING; + break; + case SIGNCMD_UNPLACE: + case SIGNCMD_JUMP: + if (STRNCMP(last, "group", 5) == 0) + expand_what = EXP_SIGN_GROUPS; + else if (STRNCMP(last, "file", 4) == 0) + xp->xp_context = EXPAND_BUFFERS; else xp->xp_context = EXPAND_NOTHING; break; diff --git a/src/testdir/test_signs.vim b/src/testdir/test_signs.vim index 49bd986c35..426998d6d7 100644 --- a/src/testdir/test_signs.vim +++ b/src/testdir/test_signs.vim @@ -210,13 +210,16 @@ func Test_sign_completion() call assert_equal('"sign define Sign linehl=SpellBad SpellCap ' . \ 'SpellLocal SpellRare', @:) - call writefile(['foo'], 'XsignOne') - call writefile(['bar'], 'XsignTwo') + call feedkeys(":sign define Sign texthl=Spell\\\"\", 'tx') + call assert_equal('"sign define Sign texthl=SpellBad SpellCap ' . + \ 'SpellLocal SpellRare', @:) + + call writefile(repeat(["Sun is shining"], 30), "XsignOne") + call writefile(repeat(["Sky is blue"], 30), "XsignTwo") call feedkeys(":sign define Sign icon=Xsig\\\"\", 'tx') call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:) - call delete('XsignOne') - call delete('XsignTwo') + " Test for completion of arguments to ':sign undefine' call feedkeys(":sign undefine \\\"\", 'tx') call assert_equal('"sign undefine Sign1 Sign2', @:) @@ -227,17 +230,70 @@ func Test_sign_completion() call feedkeys(":sign place 1 name=\\\"\", 'tx') call assert_equal('"sign place 1 name=Sign1 Sign2', @:) + edit XsignOne + sign place 1 name=Sign1 line=5 + sign place 1 name=Sign1 group=g1 line=10 + edit XsignTwo + sign place 1 name=Sign2 group=g2 line=15 + + " Test for completion of group= and file= arguments to ':sign place' + call feedkeys(":sign place 1 name=Sign1 file=Xsign\\\"\", 'tx') + call assert_equal('"sign place 1 name=Sign1 file=XsignOne XsignTwo', @:) + call feedkeys(":sign place 1 name=Sign1 group=\\\"\", 'tx') + call assert_equal('"sign place 1 name=Sign1 group=g1 g2', @:) + + " Test for completion of arguments to 'sign place' without sign identifier + call feedkeys(":sign place \\\"\", 'tx') + call assert_equal('"sign place buffer= file= group=', @:) + call feedkeys(":sign place file=Xsign\\\"\", 'tx') + call assert_equal('"sign place file=XsignOne XsignTwo', @:) + call feedkeys(":sign place group=\\\"\", 'tx') + call assert_equal('"sign place group=g1 g2', @:) + call feedkeys(":sign place group=g1 file=\\\"\", 'tx') + call assert_equal('"sign place group=g1 file=XsignOne XsignTwo', @:) + + " Test for completion of arguments to ':sign unplace' call feedkeys(":sign unplace 1 \\\"\", 'tx') call assert_equal('"sign unplace 1 buffer= file= group=', @:) + call feedkeys(":sign unplace 1 file=Xsign\\\"\", 'tx') + call assert_equal('"sign unplace 1 file=XsignOne XsignTwo', @:) + call feedkeys(":sign unplace 1 group=\\\"\", 'tx') + call assert_equal('"sign unplace 1 group=g1 g2', @:) + call feedkeys(":sign unplace 1 group=g2 file=Xsign\\\"\", 'tx') + call assert_equal('"sign unplace 1 group=g2 file=XsignOne XsignTwo', @:) + " Test for completion of arguments to ':sign list' call feedkeys(":sign list \\\"\", 'tx') call assert_equal('"sign list Sign1 Sign2', @:) + " Test for completion of arguments to ':sign jump' call feedkeys(":sign jump 1 \\\"\", 'tx') call assert_equal('"sign jump 1 buffer= file= group=', @:) + call feedkeys(":sign jump 1 file=Xsign\\\"\", 'tx') + call assert_equal('"sign jump 1 file=XsignOne XsignTwo', @:) + call feedkeys(":sign jump 1 group=\\\"\", 'tx') + call assert_equal('"sign jump 1 group=g1 g2', @:) + " Error cases + call feedkeys(":sign here\\\"\", 'tx') + call assert_equal('"sign here', @:) + call feedkeys(":sign define Sign here=\\\"\", 'tx') + call assert_equal("\"sign define Sign here=\", @:) + call feedkeys(":sign place 1 here=\\\"\", 'tx') + call assert_equal("\"sign place 1 here=\", @:) + call feedkeys(":sign jump 1 here=\\\"\", 'tx') + call assert_equal("\"sign jump 1 here=\", @:) + call feedkeys(":sign here there\\\"\", 'tx') + call assert_equal("\"sign here there\", @:) + call feedkeys(":sign here there=\\\"\", 'tx') + call assert_equal("\"sign here there=\", @:) + + sign unplace * group=* sign undefine Sign1 sign undefine Sign2 + enew + call delete('XsignOne') + call delete('XsignTwo') endfunc func Test_sign_invalid_commands() diff --git a/src/version.c b/src/version.c index df3aa4813c..06500bd790 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 939, /**/ 938, /**/ From 78d21dae9c3a39efb30316d3e38dce120bc1abbd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 15:00:52 +0100 Subject: [PATCH 68/75] patch 8.1.0940: MS-Windows console resizing not handled properly Problem: MS-Windows console resizing not handled properly. Solution: Handle resizing the console better. (Nobuhiro Takasaki, closes #3968, closes #3611) --- src/ex_docmd.c | 3 +++ src/normal.c | 3 +++ src/os_win32.c | 48 ++++++++++++++++++++++++++++++++++++------ src/proto/os_win32.pro | 1 + src/version.c | 2 ++ 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index ccca2f98fa..8cdb046747 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -9852,6 +9852,9 @@ ex_redraw(exarg_T *eap) #ifdef FEAT_TITLE if (need_maketitle) maketitle(); +#endif +#if defined(WIN3264) && !defined(FEAT_GUI_W32) + resize_console_buf(); #endif RedrawingDisabled = r; p_lz = p; diff --git a/src/normal.c b/src/normal.c index 624e34751c..ca0d8ff876 100644 --- a/src/normal.c +++ b/src/normal.c @@ -5401,6 +5401,9 @@ nv_clear(cmdarg_T *cap) # endif #endif redraw_later(CLEAR); +#if defined(WIN3264) && !defined(FEAT_GUI_W32) + resize_console_buf(); +#endif } } diff --git a/src/os_win32.c b/src/os_win32.c index 97fc2a401b..a392d13b27 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1492,6 +1492,8 @@ handle_focus_event(INPUT_RECORD ir) ui_focus_change((int)g_fJustGotFocus); } +static void ResizeConBuf(HANDLE hConsole, COORD coordScreen); + /* * Wait until console input from keyboard or mouse is available, * or the time is up. @@ -1657,11 +1659,18 @@ WaitForChar(long msec, int ignore_input) handle_focus_event(ir); else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT) { - /* Only call shell_resized() when the size actually change to - * avoid the screen is cleard. */ - if (ir.Event.WindowBufferSizeEvent.dwSize.X != Columns - || ir.Event.WindowBufferSizeEvent.dwSize.Y != Rows) + COORD dwSize = ir.Event.WindowBufferSizeEvent.dwSize; + + // Only call shell_resized() when the size actually change to + // avoid the screen is cleard. + if (dwSize.X != Columns || dwSize.Y != Rows) + { + CONSOLE_SCREEN_BUFFER_INFO csbi; + GetConsoleScreenBufferInfo(g_hConOut, &csbi); + dwSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; + ResizeConBuf(g_hConOut, dwSize); shell_resized(); + } } #ifdef FEAT_MOUSE else if (ir.EventType == MOUSE_EVENT @@ -6327,7 +6336,7 @@ write_chars( * character was written, otherwise we get stuck. */ if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length, coord, &cchwritten) == 0 - || cchwritten == 0) + || cchwritten == 0 || cchwritten == (DWORD)-1) cchwritten = 1; } else @@ -6361,7 +6370,7 @@ write_chars( * character was written, otherwise we get stuck. */ if (WriteConsoleOutputCharacter(g_hConOut, (LPCSTR)pchBuf, cbToWrite, coord, &written) == 0 - || written == 0) + || written == 0 || written == (DWORD)-1) written = 1; } else @@ -7707,7 +7716,7 @@ vtp_flag_init(void) } -#ifndef FEAT_GUI_W32 +#if !defined(FEAT_GUI_W32) || defined(PROTO) static void vtp_init(void) @@ -7931,3 +7940,28 @@ is_conpty_stable(void) { return conpty_stable; } + +#if !defined(FEAT_GUI_W32) || defined(PROTO) + void +resize_console_buf(void) +{ + CONSOLE_SCREEN_BUFFER_INFO csbi; + COORD coord; + SMALL_RECT newsize; + + if (GetConsoleScreenBufferInfo(g_hConOut, &csbi)) + { + coord.X = SRWIDTH(csbi.srWindow); + coord.Y = SRHEIGHT(csbi.srWindow); + SetConsoleScreenBufferSize(g_hConOut, coord); + + newsize.Left = 0; + newsize.Top = 0; + newsize.Right = coord.X - 1; + newsize.Bottom = coord.Y - 1; + SetConsoleWindowInfo(g_hConOut, TRUE, &newsize); + + SetConsoleScreenBufferSize(g_hConOut, coord); + } +} +#endif diff --git a/src/proto/os_win32.pro b/src/proto/os_win32.pro index 6157e011fd..ca5bad629c 100644 --- a/src/proto/os_win32.pro +++ b/src/proto/os_win32.pro @@ -75,4 +75,5 @@ int is_term_win32(void); int has_vtp_working(void); int has_conpty_working(void); int is_conpty_stable(void); +void resize_console_buf(void); /* vim: set ft=c : */ diff --git a/src/version.c b/src/version.c index 06500bd790..e042578cca 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 940, /**/ 939, /**/ From 4f97475d326c2773a78561fb874e4f23c25cbcd9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 17:44:42 +0100 Subject: [PATCH 69/75] patch 8.1.0941: macros for MS-Windows are inconsistent Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes #3932) --- src/GvimExt/gvimext.h | 2 +- src/Make_bc5.mak | 2 +- src/Make_cyg_ming.mak | 2 +- src/Make_ivc.mak | 24 +++++++-------- src/Make_mvc.mak | 4 +-- src/beval.h | 6 ++-- src/blowfish.c | 2 +- src/channel.c | 56 ++++++++++++++++----------------- src/edit.c | 6 ++-- src/eval.c | 18 +++++------ src/evalfunc.c | 44 +++++++++++++------------- src/ex_cmds.c | 10 +++--- src/ex_cmds2.c | 46 +++++++++++++-------------- src/ex_docmd.c | 6 ++-- src/ex_getln.c | 6 ++-- src/feature.h | 48 ++++++++++++++--------------- src/fileio.c | 54 ++++++++++++++++---------------- src/getchar.c | 6 ++-- src/glbl_ime.cpp | 2 +- src/globals.h | 10 +++--- src/gui.c | 18 ++++++----- src/gui.h | 4 +-- src/gui_beval.c | 12 ++++---- src/gui_gtk.c | 2 +- src/gui_gtk_f.c | 2 +- src/gui_gtk_x11.c | 2 +- src/if_cscope.c | 24 +++++++-------- src/if_cscope.h | 4 +-- src/if_lua.c | 2 +- src/if_mzsch.c | 12 ++++---- src/if_ole.cpp | 2 +- src/if_perl.xs | 6 ++-- src/if_python.c | 4 +-- src/if_python3.c | 4 +-- src/if_ruby.c | 10 +++--- src/if_tcl.c | 6 ++-- src/macros.h | 8 ++--- src/main.c | 62 ++++++++++++++++++------------------- src/mbyte.c | 40 ++++++++++++------------ src/memfile.c | 4 +-- src/memline.c | 22 ++++++------- src/menu.c | 46 +++++++++++++-------------- src/message.c | 14 ++++----- src/misc1.c | 18 +++++------ src/misc2.c | 14 ++++----- src/nbdebug.c | 2 +- src/netbeans.c | 6 ++-- src/normal.c | 2 +- src/option.c | 62 ++++++++++++++++++------------------- src/option.h | 14 +++------ src/os_mswin.c | 4 +-- src/os_unix.c | 2 +- src/os_w32exe.c | 4 +-- src/os_win32.c | 72 +++++++++++++++++++++---------------------- src/os_win32.h | 4 +-- src/proto.h | 4 +-- src/screen.c | 4 +-- src/search.c | 2 +- src/structs.h | 16 +++++----- src/syntax.c | 8 ++--- src/term.c | 15 ++++----- src/terminal.c | 50 +++++++++++++++--------------- src/ui.c | 8 ++--- src/undo.c | 4 +-- src/version.c | 18 ++++++----- src/vim.h | 55 ++++++++++++++++----------------- src/vim.rc | 4 +-- src/winclip.c | 20 ++++++------ 68 files changed, 537 insertions(+), 539 deletions(-) diff --git a/src/GvimExt/gvimext.h b/src/GvimExt/gvimext.h index e17f2ac2c9..7a4e009fdb 100644 --- a/src/GvimExt/gvimext.h +++ b/src/GvimExt/gvimext.h @@ -31,7 +31,7 @@ # define STRICT #endif -#define INC_OLE2 // WIN32, get ole2 from windows.h +#define INC_OLE2 // MS-Windows, get ole2 from windows.h /* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */ #if defined(_MSC_VER) && _MSC_VER >= 1400 diff --git a/src/Make_bc5.mak b/src/Make_bc5.mak index 30fe727b2e..04f78854d9 100644 --- a/src/Make_bc5.mak +++ b/src/Make_bc5.mak @@ -405,7 +405,7 @@ DEFINES = $(DEFINES) -DFEAT_CSCOPE !endif !if ("$(GUI)"=="yes") -DEFINES = $(DEFINES) -DFEAT_GUI_W32 -DFEAT_CLIPBOARD +DEFINES = $(DEFINES) -DFEAT_GUI -DFEAT_CLIPBOARD !if ("$(DEBUG)"=="yes") TARGET = gvimd.exe !else diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak index f6ae85316f..06bf07a105 100644 --- a/src/Make_cyg_ming.mak +++ b/src/Make_cyg_ming.mak @@ -491,7 +491,7 @@ endif # RUBY # See feature.h for a list of options. # Any other defines can be included here. -DEF_GUI=-DFEAT_GUI_W32 -DFEAT_CLIPBOARD +DEF_GUI=-DFEAT_GUI -DFEAT_CLIPBOARD DEFINES=-DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \ -DHAVE_PATHDEF -DFEAT_$(FEATURES) -DHAVE_STDINT_H ifeq ($(ARCH),x86-64) diff --git a/src/Make_ivc.mak b/src/Make_ivc.mak index 26367e096b..02910bcf43 100644 --- a/src/Make_ivc.mak +++ b/src/Make_ivc.mak @@ -92,8 +92,8 @@ LINK32_FLAGS= oldnames.lib kernel32.lib user32.lib gdi32.lib version.lib comdlg3 # ADD LINK32 oldnames.lib kernel32.lib user32.lib gdi32.lib version.lib comdlg32.lib comctl32.lib advapi32.lib shell32.lib ole32.lib uuid.lib /nologo /machine:I386 /nodefaultlib # SUBTRACT LINK32 /incremental:yes -RSC_PROJ= /l 0x409 /d "FEAT_GUI_W32" -# ADD RSC /l 0x409 /d "FEAT_GUI_W32" +RSC_PROJ= /l 0x409 /d "FEAT_GUI" +# ADD RSC /l 0x409 /d "FEAT_GUI" !IF "$(CFG)" == "Vim - Win32 Release gvim OLE" @@ -105,8 +105,8 @@ INTDIR=.\oleRel VIM=gvim EXTRAS="$(INTDIR)/if_ole.obj" "$(INTDIR)/vim.res" "$(INTDIR)/gui.obj" "$(INTDIR)/gui_w32.obj" "$(INTDIR)/gui_beval.obj" "$(INTDIR)/os_w32exe.obj" -CPP_PROJ=$(CPP_PROJ) /Zi /O2 /D "NDEBUG" /D "FEAT_GUI_W32" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleRel/ /Fo.\oleRel/ -# ADD CPP /Zi /O2 /D "NDEBUG" /D "FEAT_GUI_W32" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleRel/ /Fo.\oleRel/ +CPP_PROJ=$(CPP_PROJ) /Zi /O2 /D "NDEBUG" /D "FEAT_GUI" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleRel/ /Fo.\oleRel/ +# ADD CPP /Zi /O2 /D "NDEBUG" /D "FEAT_GUI" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleRel/ /Fo.\oleRel/ RSC_PROJ=$(RSC_PROJ) /I ".\oleRel" /d "NDEBUG" /d "FEAT_OLE" /fo.\oleRel\vim.res # ADD RSC /I ".\oleRel" /d "NDEBUG" /d "FEAT_OLE" /fo.\oleRel\vim.res @@ -124,8 +124,8 @@ INTDIR=.\oleDbg VIM=gvimd EXTRAS="$(INTDIR)/if_ole.obj" "$(INTDIR)/vim.res" "$(INTDIR)/gui.obj" "$(INTDIR)/gui_w32.obj" "$(INTDIR)/gui_beval.obj" "$(INTDIR)/os_w32exe.obj" -CPP_PROJ=$(CPP_PROJ) /Zi /Od /D "_DEBUG" /D "FEAT_GUI_W32" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleDbg/ /Fo.\oleDbg/ -# ADD CPP /Zi /Od /D "_DEBUG" /D "FEAT_GUI_W32" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleDbg/ /Fo.\oleDbg/ +CPP_PROJ=$(CPP_PROJ) /Zi /Od /D "_DEBUG" /D "FEAT_GUI" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleDbg/ /Fo.\oleDbg/ +# ADD CPP /Zi /Od /D "_DEBUG" /D "FEAT_GUI" /D "DYNAMIC_GETTEXT" /D "FEAT_OLE" /Fd.\oleDbg/ /Fo.\oleDbg/ RSC_PROJ=$(RSC_PROJ) /I .\oleDbg /d "_DEBUG" /d "FEAT_OLE" /fo.\oleDbg\vim.res # ADD RSC /I .\oleDbg /d "_DEBUG" /d "FEAT_OLE" /fo.\oleDbg\vim.res @@ -144,8 +144,8 @@ INTDIR=.\gRel VIM=gvim EXTRAS="$(INTDIR)/vim.res" "$(INTDIR)/gui.obj" "$(INTDIR)/gui_w32.obj" "$(INTDIR)/gui_beval.obj" "$(INTDIR)/os_w32exe.obj" -CPP_PROJ=$(CPP_PROJ) /Zi /O2 /D "NDEBUG" /D "FEAT_GUI_W32" /Fd.\gRel/ /Fo.\gRel/ -# ADD CPP /Zi /O2 /D "NDEBUG" /D "FEAT_GUI_W32" /Fd.\gRel/ /Fo.\gRel/ +CPP_PROJ=$(CPP_PROJ) /Zi /O2 /D "NDEBUG" /D "FEAT_GUI" /Fd.\gRel/ /Fo.\gRel/ +# ADD CPP /Zi /O2 /D "NDEBUG" /D "FEAT_GUI" /Fd.\gRel/ /Fo.\gRel/ RSC_PROJ=$(RSC_PROJ) /d "NDEBUG" /fo.\gRel\vim.res # ADD RSC /d "NDEBUG" /fo.\gRel\vim.res @@ -163,8 +163,8 @@ INTDIR=.\gDbg VIM=gvimd EXTRAS="$(INTDIR)/vim.res" "$(INTDIR)/gui.obj" "$(INTDIR)/gui_w32.obj" "$(INTDIR)/gui_beval.obj" "$(INTDIR)/os_w32exe.obj" -CPP_PROJ=$(CPP_PROJ) /Zi /Od /D "_DEBUG" /D "FEAT_GUI_W32" /Fd.\gDbg/ /Fo.\gDbg/ -# ADD CPP /Zi /Od /D "_DEBUG" /D "FEAT_GUI_W32" /Fd.\gDbg/ /Fo.\gDbg/ +CPP_PROJ=$(CPP_PROJ) /Zi /Od /D "_DEBUG" /D "FEAT_GUI" /Fd.\gDbg/ /Fo.\gDbg/ +# ADD CPP /Zi /Od /D "_DEBUG" /D "FEAT_GUI" /Fd.\gDbg/ /Fo.\gDbg/ RSC_PROJ=$(RSC_PROJ) /d "_DEBUG" /fo.\gDbg\vim.res # ADD RSC /d "_DEBUG" /fo.\gDbg\vim.res @@ -508,7 +508,7 @@ SOURCE=.\if_ole.cpp # Begin Custom Build "$(INTDIR)\if_ole.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\if_ole.h" - cl.exe /nologo /MT /W3 /GX /I ".\proto" /D "WIN32" /c /Zi /O2 /D "NDEBUG" /D "FEAT_GUI_W32" /D "FEAT_OLE" /Fd.\oleRel/ /Fo.\oleRel/ /I ".\oleRel" .\if_ole.cpp + cl.exe /nologo /MT /W3 /GX /I ".\proto" /D "WIN32" /c /Zi /O2 /D "NDEBUG" /D "FEAT_GUI" /D "FEAT_OLE" /Fd.\oleRel/ /Fo.\oleRel/ /I ".\oleRel" .\if_ole.cpp @rem This is the default rule with /I "$(IntDir)" added # End Custom Build @@ -519,7 +519,7 @@ SOURCE=.\if_ole.cpp # Begin Custom Build "$(INTDIR)\if_ole.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\if_ole.h" - cl.exe /nologo /MT /W3 /GX /I ".\proto" /D "WIN32" /c /Zi /Od /D "_DEBUG" /D "FEAT_GUI_W32" /D "FEAT_OLE" /Fd.\oleDbg/ /Fo.\oleDbg/ /I ".\oleDbg" .\if_ole.cpp + cl.exe /nologo /MT /W3 /GX /I ".\proto" /D "WIN32" /c /Zi /Od /D "_DEBUG" /D "FEAT_GUI" /D "FEAT_OLE" /Fd.\oleDbg/ /Fo.\oleDbg/ /I ".\oleDbg" .\if_ole.cpp @rem This is the default rule with /I "$(IntDir)" added # End Custom Build diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index c81fbd2961..391277fe71 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -791,8 +791,8 @@ OBJ = $(OBJ) $(OUTDIR)\dimm_i.obj $(OUTDIR)\glbl_ime.obj !if "$(GUI)" == "yes" SUBSYSTEM = windows -CFLAGS = $(CFLAGS) -DFEAT_GUI_W32 -RCFLAGS = $(RCFLAGS) -DFEAT_GUI_W32 +CFLAGS = $(CFLAGS) -DFEAT_GUI +RCFLAGS = $(RCFLAGS) -DFEAT_GUI VIM = g$(VIM) GUI_INCL = \ gui.h diff --git a/src/beval.h b/src/beval.h index 21900c5ad4..090c5fb55c 100644 --- a/src/beval.h +++ b/src/beval.h @@ -43,7 +43,7 @@ typedef struct BalloonEvalStruct int y; unsigned int state; /* Button/Modifier key state */ # else -# if !defined(FEAT_GUI_W32) +# if !defined(FEAT_GUI_MSWIN) Widget target; /* widget we are monitoring */ Widget balloonShell; Widget balloonLabel; @@ -63,7 +63,7 @@ typedef struct BalloonEvalStruct BeState showState; /* tells us whats currently going on */ # endif # endif -# if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_W32) +# if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MSWIN) Dimension screen_width; /* screen width in pixels */ Dimension screen_height; /* screen height in pixels */ # endif @@ -76,7 +76,7 @@ typedef struct BalloonEvalStruct int *vts; // vartabstop setting for this buffer #endif char_u *msg; -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN void *tofree; #endif } BalloonEval; diff --git a/src/blowfish.c b/src/blowfish.c index 8ca0e2848c..7bc3e31d35 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -34,7 +34,7 @@ typedef union { char_u uc[8]; } block8; -#if defined(WIN3264) +#if defined(MSWIN) /* MS-Windows is always little endian */ #else # ifdef HAVE_CONFIG_H diff --git a/src/channel.c b/src/channel.c index d728c77d9f..57bb4ccffa 100644 --- a/src/channel.c +++ b/src/channel.c @@ -20,7 +20,7 @@ #endif /* Note: when making changes here also adjust configure.ac. */ -#ifdef WIN32 +#ifdef MSWIN /* WinSock API is separated from C API, thus we can't use read(), write(), * errno... */ # define SOCK_ERRNO errno = WSAGetLastError() @@ -65,7 +65,7 @@ static int safe_to_invoke_callback = 0; static char *part_names[] = {"sock", "out", "err", "in"}; -#ifdef WIN32 +#ifdef MSWIN static int fd_read(sock_T fd, char *buf, size_t len) { @@ -234,7 +234,7 @@ ch_error(channel_T *ch, const char *fmt, ...) } } -#ifdef _WIN32 +#ifdef MSWIN # undef PERROR # define PERROR(msg) (void)semsg("%s: %s", msg, strerror_win32(errno)) @@ -687,7 +687,7 @@ channel_open( int sd = -1; struct sockaddr_in server; struct hostent *host; -#ifdef WIN32 +#ifdef MSWIN u_short port = port_in; u_long val = 1; #else @@ -696,7 +696,7 @@ channel_open( channel_T *channel; int ret; -#ifdef WIN32 +#ifdef MSWIN channel_init_winsock(); #endif @@ -758,7 +758,7 @@ channel_open( { /* Make connect() non-blocking. */ if ( -#ifdef _WIN32 +#ifdef MSWIN ioctlsocket(sd, FIONBIO, &val) < 0 #else fcntl(sd, F_SETFL, O_NONBLOCK) < 0 @@ -804,14 +804,14 @@ channel_open( /* If connect() didn't finish then try using select() to wait for the * connection to be made. For Win32 always use select() to wait. */ -#ifndef WIN32 +#ifndef MSWIN if (errno != ECONNREFUSED) #endif { struct timeval tv; fd_set rfds; fd_set wfds; -#ifndef WIN32 +#ifndef MSWIN int so_error = 0; socklen_t so_error_len = sizeof(so_error); struct timeval start_tv; @@ -824,7 +824,7 @@ channel_open( tv.tv_sec = waitnow / 1000; tv.tv_usec = (waitnow % 1000) * 1000; -#ifndef WIN32 +#ifndef MSWIN gettimeofday(&start_tv, NULL); #endif ch_log(channel, @@ -842,7 +842,7 @@ channel_open( return NULL; } -#ifdef WIN32 +#ifdef MSWIN /* On Win32: select() is expected to work and wait for up to * "waitnow" msec for the socket to be open. */ if (FD_ISSET(sd, &wfds)) @@ -893,7 +893,7 @@ channel_open( #endif } -#ifndef WIN32 +#ifndef MSWIN if (waittime > 1 && elapsed_msec < waittime) { /* The port isn't ready but we also didn't get an error. @@ -930,7 +930,7 @@ channel_open( if (waittime >= 0) { -#ifdef _WIN32 +#ifdef MSWIN val = 0; ioctlsocket(sd, FIONBIO, &val); #else @@ -1029,7 +1029,7 @@ ch_close_part(channel_T *channel, ch_part_T part) && (part == PART_OUT || channel->CH_OUT_FD != *fd) && (part == PART_ERR || channel->CH_ERR_FD != *fd)) { -#ifdef WIN32 +#ifdef MSWIN if (channel->ch_named_pipe) DisconnectNamedPipe((HANDLE)fd); #endif @@ -1427,7 +1427,7 @@ can_write_buf_line(channel_T *channel) in_part->ch_block_write = 1; /* TODO: Win32 implementation, probably using WaitForMultipleObjects() */ -#ifndef WIN32 +#ifndef MSWIN { # if defined(HAVE_SELECT) struct timeval tval; @@ -1759,7 +1759,7 @@ channel_get_all(channel_T *channel, ch_part_T part, int *outlen) { if (*p == NUL) *p = NL; -#ifdef WIN32 +#ifdef MSWIN else if (*p == 0x1b) { // crush the escape sequence OSC 0/1/2: ESC ]0; @@ -2064,7 +2064,7 @@ channel_parse_json(channel_T *channel, ch_part_T part) (int)buflen); reader.js_used = 0; chanpart->ch_wait_len = buflen; -#ifdef WIN32 +#ifdef MSWIN chanpart->ch_deadline = GetTickCount() + 100L; #else gettimeofday(&chanpart->ch_deadline, NULL); @@ -2079,7 +2079,7 @@ channel_parse_json(channel_T *channel, ch_part_T part) else { int timeout; -#ifdef WIN32 +#ifdef MSWIN timeout = GetTickCount() > chanpart->ch_deadline; #else { @@ -3198,7 +3198,7 @@ channel_wait(channel_T *channel, sock_T fd, int timeout) if (timeout > 0) ch_log(channel, "Waiting for up to %d msec", timeout); -# ifdef WIN32 +# ifdef MSWIN if (fd != channel->CH_SOCK_FD) { DWORD nread; @@ -3554,7 +3554,7 @@ channel_read_json_block( timeout = timeout_arg; if (chanpart->ch_wait_len > 0) { -#ifdef WIN32 +#ifdef MSWIN timeout = chanpart->ch_deadline - GetTickCount() + 1; #else { @@ -3680,7 +3680,7 @@ theend: free_job_options(&opt); } -# if defined(WIN32) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ +# if defined(MSWIN) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ || defined(PROTO) /* * Lookup the channel from the socket. Set "partp" to the fd index. @@ -3707,7 +3707,7 @@ channel_fd2channel(sock_T fd, ch_part_T *partp) } # endif -# if defined(WIN32) || defined(FEAT_GUI) || defined(PROTO) +# if defined(MSWIN) || defined(FEAT_GUI) || defined(PROTO) /* * Check the channels for anything that is ready to be read. * The data is put in the read queue. @@ -3772,7 +3772,7 @@ channel_set_nonblock(channel_T *channel, ch_part_T part) if (fd != INVALID_FD) { -#ifdef _WIN32 +#ifdef MSWIN u_long val = 1; ioctlsocket(fd, FIONBIO, &val); @@ -3853,7 +3853,7 @@ channel_send( else { res = fd_write(fd, (char *)buf, len); -#ifdef WIN32 +#ifdef MSWIN if (channel->ch_named_pipe && res < 0) { DisconnectNamedPipe((HANDLE)fd); @@ -4213,7 +4213,7 @@ channel_poll_check(int ret_in, void *fds_in) } # endif /* UNIX && !HAVE_SELECT */ -# if (!defined(WIN32) && defined(HAVE_SELECT)) || defined(PROTO) +# if (!defined(MSWIN) && defined(HAVE_SELECT)) || defined(PROTO) /* * The "fd_set" type is hidden to avoid problems with the function proto. @@ -4313,7 +4313,7 @@ channel_select_check(int ret_in, void *rfds_in, void *wfds_in) return ret; } -# endif /* !WIN32 && HAVE_SELECT */ +# endif /* !MSWIN && HAVE_SELECT */ /* * Execute queued up commands. @@ -5039,7 +5039,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) break; opt->jo_cwd = tv_get_string_buf_chk(item, opt->jo_cwd_buf); if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd) -#ifndef WIN32 // Win32 directories don't have the concept of "executable" +#ifndef MSWIN // Win32 directories don't have the concept of "executable" || mch_access((char *)opt->jo_cwd, X_OK) != 0 #endif ) @@ -5199,7 +5199,7 @@ job_free_contents(job_T *job) #ifdef UNIX vim_free(job->jv_termsig); #endif -#ifdef WIN3264 +#ifdef MSWIN vim_free(job->jv_tty_type); #endif free_callback(job->jv_exit_cb, job->jv_exit_partial); @@ -5971,7 +5971,7 @@ job_info(job_T *job, dict_T *dict) #ifdef UNIX dict_add_string(dict, "termsig", job->jv_termsig); #endif -#ifdef WIN3264 +#ifdef MSWIN dict_add_string(dict, "tty_type", job->jv_tty_type); #endif diff --git a/src/edit.c b/src/edit.c index 62ff03d962..2f81b52dff 100644 --- a/src/edit.c +++ b/src/edit.c @@ -1247,9 +1247,9 @@ doESCkey: did_cursorhold = TRUE; break; -#ifdef FEAT_GUI_W32 - /* On Win32 ignore , we get it when closing the window was - * cancelled. */ +#ifdef FEAT_GUI_MSWIN + /* On MS-Windows ignore , we get it when closing the window + * was cancelled. */ case K_F4: if (mod_mask != MOD_MASK_ALT) goto normalchar; diff --git a/src/eval.c b/src/eval.c index 56a26b1aea..f66d296502 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7460,7 +7460,7 @@ tv_get_string_buf_chk(typval_T *varp, char_u *buf) # ifdef UNIX vim_snprintf((char *)buf, NUMBUFLEN, "process %ld %s", (long)job->jv_pid, status); -# elif defined(WIN32) +# elif defined(MSWIN) vim_snprintf((char *)buf, NUMBUFLEN, "process %ld %s", (long)job->jv_proc_info.dwProcessId, @@ -9956,7 +9956,7 @@ var_exists(char_u *var) #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO) -#ifdef WIN3264 +#ifdef MSWIN /* * Functions for ":8" filename modifier: get 8.3 version of a filename. */ @@ -10191,7 +10191,7 @@ shortpath_for_partial( return OK; } -#endif /* WIN3264 */ +#endif // MSWIN /* * Adjust a filename, according to a string of modifiers. @@ -10215,7 +10215,7 @@ modify_fname( char_u dirname[MAXPATHL]; int c; int has_fullname = 0; -#ifdef WIN3264 +#ifdef MSWIN char_u *fname_start = *fnamep; int has_shortname = 0; #endif @@ -10270,7 +10270,7 @@ repeat: return -1; } -#ifdef WIN3264 +#ifdef MSWIN # if _WIN32_WINNT >= 0x0500 if (vim_strchr(*fnamep, '~') != NULL) { @@ -10313,7 +10313,7 @@ repeat: *usedlen += 2; if (c == '8') { -#ifdef WIN3264 +#ifdef MSWIN has_shortname = 1; /* Postpone this. */ #endif continue; @@ -10406,12 +10406,12 @@ repeat: if (src[*usedlen] == ':' && src[*usedlen + 1] == '8') { *usedlen += 2; -#ifdef WIN3264 +#ifdef MSWIN has_shortname = 1; #endif } -#ifdef WIN3264 +#ifdef MSWIN /* * Handle ":8" after we have done 'heads' and before we do 'tails'. */ @@ -10455,7 +10455,7 @@ repeat: *fnamelen = l; } } -#endif /* WIN3264 */ +#endif // MSWIN /* ":t" - tail, just the basename */ if (src[*usedlen] == ':' && src[*usedlen + 1] == 't') diff --git a/src/evalfunc.c b/src/evalfunc.c index e9f63423a8..e94d875da9 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -123,7 +123,7 @@ static void f_cosh(typval_T *argvars, typval_T *rettv); static void f_count(typval_T *argvars, typval_T *rettv); static void f_cscope_connection(typval_T *argvars, typval_T *rettv); static void f_cursor(typval_T *argsvars, typval_T *rettv); -#ifdef WIN3264 +#ifdef MSWIN static void f_debugbreak(typval_T *argvars, typval_T *rettv); #endif static void f_deepcopy(typval_T *argvars, typval_T *rettv); @@ -599,7 +599,7 @@ static struct fst {"count", 2, 4, f_count}, {"cscope_connection",0,3, f_cscope_connection}, {"cursor", 1, 3, f_cursor}, -#ifdef WIN3264 +#ifdef MSWIN {"debugbreak", 1, 1, f_debugbreak}, #endif {"deepcopy", 1, 2, f_deepcopy}, @@ -2884,7 +2884,7 @@ f_cursor(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = 0; } -#ifdef WIN3264 +#ifdef MSWIN /* * "debugbreak()" function */ @@ -4137,7 +4137,7 @@ f_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED) if (gui.in_use) gui_mch_set_foreground(); #else -# ifdef WIN32 +# ifdef MSWIN win32_set_foreground(); # endif #endif @@ -6152,7 +6152,7 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef VMS "vms", #endif -#ifdef WIN32 +#ifdef MSWIN "win32", #endif #if defined(UNIX) && (defined(__CYGWIN32__) || defined(__CYGWIN__)) @@ -6182,7 +6182,7 @@ f_has(typval_T *argvars, typval_T *rettv) #endif #ifdef FEAT_BEVAL_GUI "balloon_eval", -# ifndef FEAT_GUI_W32 /* other GUIs always have multiline balloons */ +# ifndef FEAT_GUI_MSWIN /* other GUIs always have multiline balloons */ "balloon_multiline", # endif #endif @@ -6196,7 +6196,7 @@ f_has(typval_T *argvars, typval_T *rettv) # endif #endif #if defined(FEAT_BROWSE) && (defined(USE_FILE_CHOOSER) \ - || defined(FEAT_GUI_W32) \ + || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_MOTIF)) "browsefilter", #endif @@ -6322,7 +6322,7 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_GUI_PHOTON "gui_photon", #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN "gui_win32", #endif #ifdef FEAT_HANGULIN @@ -6526,7 +6526,7 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_TERMGUICOLORS "termguicolors", #endif -#if defined(FEAT_TERMINAL) && !defined(WIN3264) +#if defined(FEAT_TERMINAL) && !defined(MSWIN) "terminal", #endif #ifdef TERMINFO @@ -6658,7 +6658,7 @@ f_has(typval_T *argvars, typval_T *rettv) n = stdout_isatty; else if (STRICMP(name, "multi_byte_encoding") == 0) n = has_mbyte; -#if defined(FEAT_BEVAL) && defined(FEAT_GUI_W32) +#if defined(FEAT_BEVAL) && defined(FEAT_GUI_MSWIN) else if (STRICMP(name, "balloon_multiline") == 0) n = multiline_balloon_available(); #endif @@ -6731,11 +6731,11 @@ f_has(typval_T *argvars, typval_T *rettv) else if (STRICMP(name, "netbeans_enabled") == 0) n = netbeans_active(); #endif -#if defined(FEAT_TERMINAL) && defined(WIN3264) +#if defined(FEAT_TERMINAL) && defined(MSWIN) else if (STRICMP(name, "terminal") == 0) n = terminal_enabled(); #endif -#if defined(FEAT_TERMINAL) && defined(WIN3264) +#if defined(FEAT_TERMINAL) && defined(MSWIN) else if (STRICMP(name, "conpty") == 0) n = use_conpty(); #endif @@ -9309,7 +9309,7 @@ list2proftime(typval_T *arg, proftime_T *tm) return FAIL; n1 = list_find_nr(arg->vval.v_list, 0L, &error); n2 = list_find_nr(arg->vval.v_list, 1L, &error); -# ifdef WIN3264 +# ifdef MSWIN tm->HighPart = n1; tm->LowPart = n2; # else @@ -9354,7 +9354,7 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { long n1, n2; -# ifdef WIN3264 +# ifdef MSWIN n1 = res.HighPart; n2 = res.LowPart; # else @@ -9443,7 +9443,7 @@ remote_common(typval_T *argvars, typval_T *rettv, int expr) char_u *r = NULL; char_u buf[NUMBUFLEN]; int timeout = 0; -# ifdef WIN32 +# ifdef MSWIN HWND w; # else Window w; @@ -9464,7 +9464,7 @@ remote_common(typval_T *argvars, typval_T *rettv, int expr) if (server_name == NULL) return; /* type error; errmsg already given */ keys = tv_get_string_buf(&argvars[1], buf); -# ifdef WIN32 +# ifdef MSWIN if (serverSendToVim(server_name, keys, &r, &w, expr, timeout, TRUE) < 0) # else if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, timeout, @@ -9522,7 +9522,7 @@ f_remote_expr(typval_T *argvars UNUSED, typval_T *rettv) f_remote_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { #ifdef FEAT_CLIENTSERVER -# ifdef WIN32 +# ifdef MSWIN /* On Win32 it's done in this application. */ { char_u *server_name = tv_get_string_chk(&argvars[0]); @@ -9549,7 +9549,7 @@ f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv) #ifdef FEAT_CLIENTSERVER dictitem_T v; char_u *s = NULL; -# ifdef WIN32 +# ifdef MSWIN long_u n = 0; # endif char_u *serverid; @@ -9565,7 +9565,7 @@ f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv) rettv->vval.v_number = -1; return; /* type error; errmsg already given */ } -# ifdef WIN32 +# ifdef MSWIN sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n); if (n == 0) rettv->vval.v_number = -1; @@ -9609,7 +9609,7 @@ f_remote_read(typval_T *argvars UNUSED, typval_T *rettv) if (serverid != NULL && !check_restricted() && !check_secure()) { int timeout = 0; -# ifdef WIN32 +# ifdef MSWIN /* The server's HWND is encoded in the 'id' parameter */ long_u n = 0; # endif @@ -9617,7 +9617,7 @@ f_remote_read(typval_T *argvars UNUSED, typval_T *rettv) if (argvars[1].v_type != VAR_UNKNOWN) timeout = tv_get_number(&argvars[1]); -# ifdef WIN32 +# ifdef MSWIN sscanf((char *)serverid, SCANF_HEX_LONG_U, &n); if (n != 0) r = serverGetReply((HWND)n, FALSE, TRUE, TRUE, timeout); @@ -10789,7 +10789,7 @@ f_serverlist(typval_T *argvars UNUSED, typval_T *rettv) char_u *r = NULL; #ifdef FEAT_CLIENTSERVER -# ifdef WIN32 +# ifdef MSWIN r = serverGetVimNames(); # else make_connection(); diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 79b9bc11d4..da10c1291a 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -1618,7 +1618,7 @@ do_shell( */ #ifndef FEAT_GUI_MSWIN if (cmd == NULL -# ifdef WIN3264 +# ifdef MSWIN || (winstart && !need_wait_return) # endif ) @@ -1643,7 +1643,7 @@ do_shell( # endif no_wait_return = save_nwr; } -#endif /* FEAT_GUI_W32 */ +#endif /* FEAT_GUI_MSWIN */ #ifdef MSWIN if (!winstart) /* if winstart==TRUE, never stopped termcap! */ @@ -1935,7 +1935,7 @@ write_viminfo(char_u *file, int forceit) int shortname = FALSE; /* use 8.3 file name */ stat_T st_old; /* mch_stat() of existing viminfo file */ #endif -#ifdef WIN3264 +#ifdef MSWIN int hidden = FALSE; #endif @@ -1999,7 +1999,7 @@ write_viminfo(char_u *file, int forceit) goto end; } #endif -#ifdef WIN3264 +#ifdef MSWIN /* Get the file attributes of the existing viminfo file. */ hidden = mch_ishidden(fname); #endif @@ -2195,7 +2195,7 @@ write_viminfo(char_u *file, int forceit) ++viminfo_errcnt; semsg(_("E886: Can't rename viminfo file to %s!"), fname); } -# ifdef WIN3264 +# ifdef MSWIN /* If the viminfo file was hidden then also hide the new file. */ else if (hidden) mch_hide(fname); diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 4bf2072723..5418804c58 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1048,7 +1048,7 @@ dbg_breakpoint(char_u *name, linenr_T lnum) void profile_start(proftime_T *tm) { -# ifdef WIN3264 +# ifdef MSWIN QueryPerformanceCounter(tm); # else gettimeofday(tm, NULL); @@ -1063,7 +1063,7 @@ profile_end(proftime_T *tm) { proftime_T now; -# ifdef WIN3264 +# ifdef MSWIN QueryPerformanceCounter(&now); tm->QuadPart = now.QuadPart - tm->QuadPart; # else @@ -1084,7 +1084,7 @@ profile_end(proftime_T *tm) void profile_sub(proftime_T *tm, proftime_T *tm2) { -# ifdef WIN3264 +# ifdef MSWIN tm->QuadPart -= tm2->QuadPart; # else tm->tv_usec -= tm2->tv_usec; @@ -1106,7 +1106,7 @@ profile_msg(proftime_T *tm) { static char buf[50]; -# ifdef WIN3264 +# ifdef MSWIN LARGE_INTEGER fr; QueryPerformanceFrequency(&fr); @@ -1124,7 +1124,7 @@ profile_msg(proftime_T *tm) float_T profile_float(proftime_T *tm) { -# ifdef WIN3264 +# ifdef MSWIN LARGE_INTEGER fr; QueryPerformanceFrequency(&fr); @@ -1145,7 +1145,7 @@ profile_setlimit(long msec, proftime_T *tm) profile_zero(tm); else { -# ifdef WIN3264 +# ifdef MSWIN LARGE_INTEGER fr; QueryPerformanceCounter(tm); @@ -1170,7 +1170,7 @@ profile_passed_limit(proftime_T *tm) { proftime_T now; -# ifdef WIN3264 +# ifdef MSWIN if (tm->QuadPart == 0) /* timer was not set */ return FALSE; QueryPerformanceCounter(&now); @@ -1190,7 +1190,7 @@ profile_passed_limit(proftime_T *tm) void profile_zero(proftime_T *tm) { -# ifdef WIN3264 +# ifdef MSWIN tm->QuadPart = 0; # else tm->tv_usec = 0; @@ -1207,7 +1207,7 @@ static long last_timer_id = 0; long proftime_time_left(proftime_T *due, proftime_T *now) { -# ifdef WIN3264 +# ifdef MSWIN LARGE_INTEGER fr; if (now->QuadPart > due->QuadPart) @@ -1592,7 +1592,7 @@ profile_divide(proftime_T *tm, int count, proftime_T *tm2) profile_zero(tm2); else { -# ifdef WIN3264 +# ifdef MSWIN tm2->QuadPart = tm->QuadPart / count; # else double usec = (tm->tv_sec * 1000000.0 + tm->tv_usec) / count; @@ -1617,7 +1617,7 @@ static proftime_T prof_wait_time; void profile_add(proftime_T *tm, proftime_T *tm2) { -# ifdef WIN3264 +# ifdef MSWIN tm->QuadPart += tm2->QuadPart; # else tm->tv_usec += tm2->tv_usec; @@ -1638,7 +1638,7 @@ profile_self(proftime_T *self, proftime_T *total, proftime_T *children) { /* Check that the result won't be negative. Can happen with recursive * calls. */ -#ifdef WIN3264 +#ifdef MSWIN if (total->QuadPart <= children->QuadPart) return; #else @@ -1678,7 +1678,7 @@ profile_sub_wait(proftime_T *tm, proftime_T *tma) int profile_equal(proftime_T *tm1, proftime_T *tm2) { -# ifdef WIN3264 +# ifdef MSWIN return (tm1->QuadPart == tm2->QuadPart); # else return (tm1->tv_usec == tm2->tv_usec && tm1->tv_sec == tm2->tv_sec); @@ -1691,7 +1691,7 @@ profile_equal(proftime_T *tm1, proftime_T *tm2) int profile_cmp(const proftime_T *tm1, const proftime_T *tm2) { -# ifdef WIN3264 +# ifdef MSWIN return (int)(tm2->QuadPart - tm1->QuadPart); # else if (tm1->tv_sec == tm2->tv_sec) @@ -4286,7 +4286,7 @@ source_level(void *cookie) static char_u *get_one_sourceline(struct source_cookie *sp); -#if (defined(WIN32) && defined(FEAT_CSCOPE)) || defined(HAVE_FD_CLOEXEC) +#if (defined(MSWIN) && defined(FEAT_CSCOPE)) || defined(HAVE_FD_CLOEXEC) # define USE_FOPEN_NOINH /* * Special function to open a file without handle inheritance. @@ -4295,7 +4295,7 @@ static char_u *get_one_sourceline(struct source_cookie *sp); static FILE * fopen_noinh_readbin(char *filename) { -# ifdef WIN32 +# ifdef MSWIN int fd_tmp = mch_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0); # else int fd_tmp = mch_open(filename, O_RDONLY, 0); @@ -5201,7 +5201,7 @@ get_locale_val(int what) /* Obtain the locale value from the libraries. */ loc = (char_u *)setlocale(what, NULL); -# ifdef WIN32 +# ifdef MSWIN if (loc != NULL) { char_u *p; @@ -5230,7 +5230,7 @@ get_locale_val(int what) #endif -#ifdef WIN32 +#ifdef MSWIN /* * On MS-Windows locale names are strings like "German_Germany.1252", but * gettext expects "de". Try to translate one into another here for a few @@ -5307,7 +5307,7 @@ get_mess_lang(void) p = mch_getenv((char_u *)"LANG"); } # endif -# ifdef WIN32 +# ifdef MSWIN p = gettext_lang(p); # endif return is_valid_mess_lang(p) ? p : NULL; @@ -5479,7 +5479,7 @@ ex_language(exarg_T *eap) /* Clear $LANGUAGE because GNU gettext uses it. */ vim_setenv((char_u *)"LANGUAGE", (char_u *)""); -# ifdef WIN32 +# ifdef MSWIN /* Apparently MS-Windows printf() may cause a crash when * we give it 8-bit text while it's expecting text in the * current locale. This call avoids that. */ @@ -5489,7 +5489,7 @@ ex_language(exarg_T *eap) if (what != LC_CTYPE) { char_u *mname; -#ifdef WIN32 +#ifdef MSWIN mname = gettext_lang(name); #else mname = name; @@ -5516,7 +5516,7 @@ ex_language(exarg_T *eap) static char_u **locales = NULL; /* Array of all available locales */ -# ifndef WIN32 +# ifndef MSWIN static int did_init_locales = FALSE; /* Return an array of strings for all available locales + NULL for the @@ -5567,7 +5567,7 @@ find_locales(void) static void init_locales(void) { -# ifndef WIN32 +# ifndef MSWIN if (!did_init_locales) { did_init_locales = TRUE; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 8cdb046747..6e61cca9b3 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -177,7 +177,7 @@ static void ex_edit(exarg_T *eap); # define ex_gui ex_nogui static void ex_nogui(exarg_T *eap); #endif -#if defined(FEAT_GUI_W32) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) static void ex_tearoff(exarg_T *eap); #else # define ex_tearoff ex_ni @@ -8866,7 +8866,7 @@ ex_nogui(exarg_T *eap) } #endif -#if defined(FEAT_GUI_W32) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) static void ex_tearoff(exarg_T *eap) { @@ -9853,7 +9853,7 @@ ex_redraw(exarg_T *eap) if (need_maketitle) maketitle(); #endif -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) resize_console_buf(); #endif RedrawingDisabled = r; diff --git a/src/ex_getln.c b/src/ex_getln.c index 0096737b01..3d38d2c742 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1899,9 +1899,9 @@ getcmdline_int( /* Ignore mouse event or open_cmdwin() result. */ goto cmdline_not_changed; -#ifdef FEAT_GUI_W32 - /* On Win32 ignore , we get it when closing the window was - * cancelled. */ +#ifdef FEAT_GUI_MSWIN + /* On MS-Windows ignore , we get it when closing the window + * was cancelled. */ case K_F4: if (mod_mask == MOD_MASK_ALT) { diff --git a/src/feature.h b/src/feature.h index a41e79f6f2..1be1833bfe 100644 --- a/src/feature.h +++ b/src/feature.h @@ -61,7 +61,7 @@ */ #if !defined(FEAT_TINY) && !defined(FEAT_SMALL) && !defined(FEAT_NORMAL) \ && !defined(FEAT_BIG) && !defined(FEAT_HUGE) -# if defined(UNIX) || defined(WIN3264) || defined(MACOS_X) +# if defined(UNIX) || defined(MSWIN) || defined(MACOS_X) # define FEAT_HUGE # else # if defined(MSWIN) || defined(VMS) || defined(AMIGA) @@ -343,10 +343,10 @@ */ #ifdef FEAT_NORMAL # define FEAT_EVAL -# if defined(HAVE_FLOAT_FUNCS) || defined(WIN3264) || defined(MACOS_X) +# if defined(HAVE_FLOAT_FUNCS) || defined(MSWIN) || defined(MACOS_X) # define FEAT_FLOAT # endif -# if defined(HAVE_STDINT_H) || defined(WIN3264) || (VIM_SIZEOF_LONG >= 8) +# if defined(HAVE_STDINT_H) || defined(MSWIN) || (VIM_SIZEOF_LONG >= 8) # define FEAT_NUM64 # endif #endif @@ -361,7 +361,7 @@ #if defined(FEAT_HUGE) \ && defined(FEAT_EVAL) \ && ((defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)) \ - || defined(WIN3264)) + || defined(MSWIN)) # define FEAT_PROFILE #endif @@ -371,14 +371,14 @@ #if defined(FEAT_NORMAL) \ && defined(FEAT_EVAL) \ && ((defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)) \ - || defined(WIN3264)) + || defined(MSWIN)) # define FEAT_RELTIME #endif /* * +timers timer_start() */ -#if defined(FEAT_RELTIME) && (defined(UNIX) || defined(WIN32) || defined(VMS) ) +#if defined(FEAT_RELTIME) && (defined(UNIX) || defined(MSWIN) || defined(VMS) ) # define FEAT_TIMERS #endif @@ -603,7 +603,7 @@ * +multi_byte_ime Win32 IME input method. Only for far-east Windows, so * IME can be used to input chars. Not tested much! */ -#if defined(FEAT_GUI_W32) && !defined(FEAT_MBYTE_IME) +#if defined(FEAT_GUI_MSWIN) && !defined(FEAT_MBYTE_IME) /* #define FEAT_MBYTE_IME */ # endif @@ -659,7 +659,7 @@ #if defined(HAVE_DLOPEN) && defined(HAVE_DLSYM) # define USE_DLOPEN #endif -#if defined(FEAT_EVAL) && (defined(WIN3264) || ((defined(UNIX) || defined(VMS)) \ +#if defined(FEAT_EVAL) && (defined(MSWIN) || ((defined(UNIX) || defined(VMS)) \ && (defined(USE_DLOPEN) || defined(HAVE_SHL_LOAD)))) # define FEAT_LIBCALL #endif @@ -669,7 +669,7 @@ */ #ifdef FEAT_NORMAL # define FEAT_MENU -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN # define FEAT_TEAROFF # endif #endif @@ -757,7 +757,7 @@ #endif #if !defined(FEAT_GUI_DIALOG) && (defined(FEAT_GUI_MOTIF) \ || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) \ - || defined(FEAT_GUI_W32)) + || defined(FEAT_GUI_MSWIN)) /* need a dialog to show error messages when starting from the desktop */ # define FEAT_GUI_DIALOG #endif @@ -828,7 +828,7 @@ */ #if defined(FEAT_NORMAL) \ && ((defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)) \ - || defined(WIN3264)) + || defined(MSWIN)) # define STARTUPTIME 1 #endif @@ -1039,7 +1039,7 @@ # ifdef FEAT_BIG # define FEAT_MOUSE_SGR # endif -# if defined(FEAT_NORMAL) && defined(WIN3264) +# if defined(FEAT_NORMAL) && defined(MSWIN) # define DOS_MOUSE # endif # if defined(FEAT_NORMAL) && defined(__QNX__) @@ -1136,7 +1136,7 @@ * +clientserver Remote control via the remote_send() function * and the --remote argument */ -#if (defined(WIN32) || defined(FEAT_XCLIPBOARD)) && defined(FEAT_EVAL) +#if (defined(MSWIN) || defined(FEAT_XCLIPBOARD)) && defined(FEAT_EVAL) # define FEAT_CLIENTSERVER #endif @@ -1145,7 +1145,7 @@ * when --servername is not passed on the command line. */ #if defined(FEAT_CLIENTSERVER) && !defined(FEAT_AUTOSERVERNAME) -# ifdef WIN3264 +# ifdef MSWIN /* Always enabled on MS-Windows. */ # define FEAT_AUTOSERVERNAME # else @@ -1169,10 +1169,10 @@ */ #ifdef FEAT_NORMAL /* MS-DOS console and Win32 console can change cursor shape */ -# if defined(WIN3264) && !defined(FEAT_GUI_W32) +# if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) # define MCH_CURSOR_SHAPE # endif -# if defined(FEAT_GUI_W32) || defined(FEAT_GUI_MOTIF) \ +# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \ || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) \ || defined(FEAT_GUI_PHOTON) # define FEAT_MOUSESHAPE @@ -1189,7 +1189,7 @@ # define CURSOR_SHAPE #endif -#if defined(FEAT_MZSCHEME) && (defined(FEAT_GUI_W32) || defined(FEAT_GUI_GTK) \ +#if defined(FEAT_MZSCHEME) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \ || defined(FEAT_GUI_MAC)) # define MZSCHEME_GUI_THREADS @@ -1263,7 +1263,7 @@ # if ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \ && defined(HAVE_X11_XPM_H)) \ || defined(FEAT_GUI_GTK) \ - || (defined(WIN32) && defined(FEAT_GUI)) + || (defined(MSWIN) && defined(FEAT_GUI)) # define FEAT_SIGN_ICONS # endif #endif @@ -1274,13 +1274,13 @@ * Only for GUIs where it was implemented. */ #if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \ - || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)) \ + || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)) \ && ( ((defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)) \ - && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_W32)) \ + && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MSWIN)) \ || defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL)) # define FEAT_BEVAL_GUI # if !defined(FEAT_XFONTSET) && !defined(FEAT_GUI_GTK) \ - && !defined(FEAT_GUI_W32) + && !defined(FEAT_GUI_MSWIN) # define FEAT_XFONTSET # endif #endif @@ -1293,7 +1293,7 @@ * +balloon_eval_term Allow balloon expression evaluation in the terminal. */ #if defined(FEAT_HUGE) && defined(FEAT_TIMERS) && \ - (defined(UNIX) || defined(VMS) || (defined(WIN32) && !defined(FEAT_GUI_W32))) + (defined(UNIX) || defined(VMS) || (defined(MSWIN) && !defined(FEAT_GUI_MSWIN))) # define FEAT_BEVAL_TERM #endif @@ -1340,13 +1340,13 @@ * +filterpipe */ #if (defined(UNIX) && !defined(USE_SYSTEM)) \ - || (defined(WIN3264) && defined(FEAT_GUI_W32)) + || (defined(MSWIN) && defined(FEAT_GUI_MSWIN)) # define FEAT_FILTERPIPE #endif /* * +vtp: Win32 virtual console. */ -#if !defined(FEAT_GUI) && defined(WIN3264) +#if !defined(FEAT_GUI) && defined(MSWIN) # define FEAT_VTP #endif diff --git a/src/fileio.c b/src/fileio.c index 85d2df3bbf..841de1cf01 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -49,7 +49,7 @@ static int time_differs(long t1, long t2); #define FIO_UCS2 0x04 /* convert UCS-2 */ #define FIO_UCS4 0x08 /* convert UCS-4 */ #define FIO_UTF16 0x10 /* convert UTF-16 */ -#ifdef WIN3264 +#ifdef MSWIN # define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */ # define FIO_PUT_CP(x) (((x) & 0xffff) << 16) /* put codepage in top word */ # define FIO_GET_CP(x) (((x)>>16) & 0xffff) /* get codepage from top word */ @@ -106,7 +106,7 @@ static int need_conversion(char_u *fenc); static int get_fio_flags(char_u *ptr); static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags); static int make_bom(char_u *buf, char_u *name); -#ifdef WIN3264 +#ifdef MSWIN static int get_win_fio_flags(char_u *ptr); #endif #ifdef MACOS_CONVERT @@ -1038,7 +1038,7 @@ retry: else if (enc_utf8 || STRCMP(p_enc, "latin1") == 0) fio_flags = get_fio_flags(fenc); -#ifdef WIN3264 +#ifdef MSWIN /* * Conversion from an MS-Windows codepage to UTF-8 or another codepage * is handled with MultiByteToWideChar(). @@ -1229,7 +1229,7 @@ retry: size = (size * 2 / 3) & ~3; else if (fio_flags == FIO_UCSBOM) size = size / ICONV_MULT; /* worst case */ -#ifdef WIN3264 +#ifdef MSWIN else if (fio_flags & FIO_CODEPAGE) size = size / ICONV_MULT; /* also worst case */ #endif @@ -1590,7 +1590,7 @@ retry: } #endif -#ifdef WIN3264 +#ifdef MSWIN if (fio_flags & FIO_CODEPAGE) { char_u *src, *dst; @@ -2559,7 +2559,7 @@ failed: curbuf->b_op_end.lnum = from + linecnt; curbuf->b_op_end.col = 0; -#ifdef WIN32 +#ifdef MSWIN /* * Work around a weird problem: When a file has two links (only * possible on NTFS) and we write through one link, then stat() it @@ -3601,13 +3601,13 @@ buf_write( */ if (!(append && *p_pm == NUL) && !filtering && perm >= 0 && dobackup) { -#if defined(UNIX) || defined(WIN32) +#if defined(UNIX) || defined(MSWIN) stat_T st; #endif if ((bkc & BKC_YES) || append) /* "yes" */ backup_copy = TRUE; -#if defined(UNIX) || defined(WIN32) +#if defined(UNIX) || defined(MSWIN) else if ((bkc & BKC_AUTO)) /* "auto" */ { int i; @@ -3632,7 +3632,7 @@ buf_write( backup_copy = TRUE; else # else -# ifdef WIN32 +# ifdef MSWIN /* On NTFS file systems hard links are possible. */ if (mch_is_linked(fname)) backup_copy = TRUE; @@ -3715,7 +3715,7 @@ buf_write( && (lstat_res != 0 || st.st_ino == st_old.st_ino)) backup_copy = FALSE; # else -# if defined(WIN32) +# if defined(MSWIN) /* Symlinks. */ if ((bkc & BKC_BREAKSYMLINK) && mch_is_symbolic_link(fname)) backup_copy = FALSE; @@ -3744,7 +3744,7 @@ buf_write( stat_T st_new; char_u *dirp; char_u *rootname; -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) char_u *p; #endif #if defined(UNIX) @@ -3785,7 +3785,7 @@ buf_write( */ (void)copy_option_part(&dirp, copybuf, BUFSIZE, ","); -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) p = copybuf + STRLEN(copybuf); if (after_pathsep(copybuf, p) && p[-1] == p[-2]) // Ends with '//', use full path @@ -4018,7 +4018,7 @@ buf_write( */ (void)copy_option_part(&dirp, IObuff, IOSIZE, ","); -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) p = IObuff + STRLEN(IObuff); if (after_pathsep(IObuff, p) && p[-1] == p[-2]) // path ends with '//', use full path @@ -4177,7 +4177,7 @@ buf_write( } } -#ifdef WIN3264 +#ifdef MSWIN if (converted && wb_flags == 0 && (wb_flags = get_win_fio_flags(fenc)) != 0) { /* Convert UTF-8 -> UCS-2 and UCS-2 -> DBCS. Worst-case * 4: */ @@ -4416,7 +4416,7 @@ restore_backup: vim_ignored = ftruncate(fd, (off_t)0); #endif -#if defined(WIN3264) +#if defined(MSWIN) if (backup != NULL && overwriting && !append) { if (backup_copy) @@ -5430,7 +5430,7 @@ buf_write_bytes(struct bw_info *ip) } } -#ifdef WIN3264 +#ifdef MSWIN else if (flags & FIO_CODEPAGE) { /* @@ -5869,7 +5869,7 @@ get_fio_flags(char_u *ptr) return 0; } -#ifdef WIN3264 +#ifdef MSWIN /* * Check "ptr" for a MS-Windows codepage name and return the FIO_ flags needed * for the conversion MS-Windows can do for us. Also accept "utf-8". @@ -6041,9 +6041,9 @@ shorten_fname(char_u *full_path, char_u *dir_name) p = full_path + len; #if defined(MSWIN) /* - * MSWIN: when a file is in the root directory, dir_name will end in a - * slash, since C: by itself does not define a specific dir. In this - * case p may already be correct. + * MS-Windows: when a file is in the root directory, dir_name will end + * in a slash, since C: by itself does not define a specific dir. In + * this case p may already be correct. */ if (!((len > 2) && (*(p - 2) == ':'))) #endif @@ -6298,7 +6298,7 @@ buf_modname( else if ((int)STRLEN(e) + extlen > 4) s = e + 4 - extlen; } -#ifdef WIN3264 +#ifdef MSWIN /* * If there is no file name, and the extension starts with '.', put a * '_' before the dot, because just ".ext" may be invalid if it's on a @@ -6427,7 +6427,7 @@ vim_rename(char_u *from, char_u *to) use_tmp_file = TRUE; } #endif -#ifdef WIN3264 +#ifdef MSWIN { BY_HANDLE_FILE_INFORMATION info1, info2; @@ -7189,7 +7189,7 @@ delete_recursive(char_u *name) /* A symbolic link to a directory itself is deleted, not the directory it * points to. */ if ( -# if defined(UNIX) || defined(WIN32) +# if defined(UNIX) || defined(MSWIN) mch_isrealdir(name) # else mch_isdir(name) @@ -7276,7 +7276,7 @@ vim_tempname( { #ifdef USE_TMPNAM char_u itmp[L_tmpnam]; /* use tmpnam() */ -#elif defined(WIN3264) +#elif defined(MSWIN) WCHAR itmp[TEMPNAMELEN]; #else char_u itmp[TEMPNAMELEN]; @@ -7398,7 +7398,7 @@ vim_tempname( #else /* TEMPDIRNAMES */ -# ifdef WIN3264 +# ifdef MSWIN WCHAR wszTempFile[_MAX_PATH + 1]; WCHAR buf4[4]; char_u *retval; @@ -7428,7 +7428,7 @@ vim_tempname( *p = '/'; return retval; -# else /* WIN3264 */ +# else // MSWIN # ifdef USE_TMPNAM char_u *p; @@ -7466,7 +7466,7 @@ vim_tempname( # endif return vim_strsave(itmp); -# endif /* WIN3264 */ +# endif // MSWIN #endif /* TEMPDIRNAMES */ } diff --git a/src/getchar.c b/src/getchar.c index eaef1ab7e4..7039c9c76b 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1623,7 +1623,7 @@ vgetc(void) } c = TO_SPECIAL(c2, c); -#if defined(FEAT_GUI_W32) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) /* Handle K_TEAROFF here, the caller of vgetc() doesn't need to * know that a menu was torn off */ if (c == K_TEAROFF) @@ -1679,7 +1679,7 @@ vgetc(void) case K_KMULTIPLY: c = '*'; break; case K_KENTER: c = CAR; break; case K_KPOINT: -#ifdef WIN32 +#ifdef MSWIN // Can be either '.' or a ',', // depending on the type of keypad. c = MapVirtualKey(VK_DECIMAL, 2); break; @@ -3107,7 +3107,7 @@ fix_input_buffer(char_u *buf, int len) if (p[0] == NUL || (p[0] == K_SPECIAL /* timeout may generate K_CURSORHOLD */ && (i < 2 || p[1] != KS_EXTRA || p[2] != (int)KE_CURSORHOLD) -#if defined(WIN3264) && !defined(FEAT_GUI) +#if defined(MSWIN) && !defined(FEAT_GUI) /* Win32 console passes modifiers */ && (i < 2 || p[1] != KS_MODIFIER) #endif diff --git a/src/glbl_ime.cpp b/src/glbl_ime.cpp index 91d52edf17..1661990742 100644 --- a/src/glbl_ime.cpp +++ b/src/glbl_ime.cpp @@ -134,7 +134,7 @@ global_ime_DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) if (pIApp == NULL || pIApp->OnDefWindowProc(hWnd, Msg, wParam, lParam, &lResult) != S_OK) { -#if defined(WIN3264) +#if defined(MSWIN) if (wide_WindowProc) lResult = DefWindowProcW(hWnd, Msg, wParam, lParam); else diff --git a/src/globals.h b/src/globals.h index 82e663e9c6..729a269d09 100644 --- a/src/globals.h +++ b/src/globals.h @@ -19,7 +19,7 @@ */ EXTERN long Rows /* nr of rows in the screen */ #ifdef DO_INIT -# if defined(WIN3264) +# if defined(MSWIN) = 25L # else = 24L @@ -818,7 +818,7 @@ EXTERN int enc_dbcs INIT(= 0); /* One of DBCS_xxx values if EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */ EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */ EXTERN int enc_latin1like INIT(= TRUE); /* 'encoding' is latin1 comp. */ -#if defined(WIN3264) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) +#if defined(MSWIN) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) /* Codepage nr of 'encoding'. Negative means it's not been set yet, zero * means 'encoding' is not a valid codepage. */ EXTERN int enc_codepage INIT(= -1); @@ -826,7 +826,7 @@ EXTERN int enc_latin9 INIT(= FALSE); /* 'encoding' is latin9 */ #endif EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */ -#if defined(WIN3264) +#if defined(MSWIN) EXTERN int wide_WindowProc INIT(= FALSE); /* use wide WindowProc() */ #endif @@ -1296,7 +1296,7 @@ EXTERN guint32 gtk_socket_id INIT(= 0); EXTERN int echo_wid_arg INIT(= FALSE); /* --echo-wid argument */ #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN /* * The value of the --windowid argument. * For embedding gvim inside another application. @@ -1645,7 +1645,7 @@ EXTERN int did_echo_string_emsg INIT(= FALSE); EXTERN int *eval_lavars_used INIT(= NULL); #endif -#ifdef WIN3264 +#ifdef MSWIN EXTERN int ctrl_break_was_pressed INIT(= FALSE); #endif diff --git a/src/gui.c b/src/gui.c index d993bc6b00..ada338f7f2 100644 --- a/src/gui.c +++ b/src/gui.c @@ -749,7 +749,7 @@ gui_init(void) &general_beval_cb, NULL); } # else -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN balloonEval = gui_mch_create_beval_area(NULL, NULL, &general_beval_cb, NULL); # endif @@ -2432,7 +2432,7 @@ gui_outstr_nowrap( int curr_wide = FALSE; /* use 'guifontwide' */ int prev_wide = FALSE; int wide_changed; -# ifdef WIN3264 +# ifdef MSWIN int sep_comp = FALSE; /* Don't separate composing chars. */ # else int sep_comp = TRUE; /* Separate composing chars. */ @@ -2568,7 +2568,7 @@ gui_outstr_nowrap( /* Draw the sign on top of the spaces. */ gui_mch_drawsign(gui.row, col, gui.highlight_mask); # if defined(FEAT_NETBEANS_INTG) && (defined(FEAT_GUI_X11) \ - || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)) + || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)) if (multi_sign) netbeans_draw_multisign_indicator(gui.row); # endif @@ -3561,7 +3561,7 @@ gui_init_which_components(char_u *oldval UNUSED) fix_size = TRUE; } #endif -#if defined(FEAT_MENU) && !(defined(WIN3264) && !defined(FEAT_TEAROFF)) +#if defined(FEAT_MENU) && !(defined(MSWIN) && !defined(FEAT_TEAROFF)) if (using_tearoff != prev_tearoff) { gui_mch_toggle_tearoffs(using_tearoff); @@ -4125,7 +4125,7 @@ gui_update_scrollbars( /* Update the horizontal scrollbar */ gui_update_horiz_scrollbar(force); -#ifndef WIN3264 +#ifndef MSWIN /* Return straight away if there is neither a left nor right scrollbar. * On MS-Windows this is required anyway for scrollwheel messages. */ if (!gui.which_scrollbars[SBAR_LEFT] && !gui.which_scrollbars[SBAR_RIGHT]) @@ -4879,9 +4879,10 @@ gui_mouse_correct(void) /* * Find window where the mouse pointer "x" / "y" coordinate is in. + * As a side effect update the shape of the mouse pointer. */ static win_T * -xy2win(int x UNUSED, int y UNUSED) +xy2win(int x, int y) { int row; int col; @@ -4951,8 +4952,9 @@ ex_gui(exarg_T *eap) ex_next(eap); } -#if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \ - || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO) +#if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)) \ + && defined(FEAT_TOOLBAR)) || defined(PROTO) /* * This is shared between Athena, Motif and GTK. */ diff --git a/src/gui.h b/src/gui.h index a57b0a3403..f5f05706f2 100644 --- a/src/gui.h +++ b/src/gui.h @@ -90,7 +90,7 @@ * X_2_COL - Convert X pixel coord into character column. * Y_2_ROW - Convert Y pixel coord into character row. */ -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN # define TEXT_X(col) ((col) * gui.char_width) # define TEXT_Y(row) ((row) * gui.char_height + gui.char_ascent) # define FILL_X(col) ((col) * gui.char_width) @@ -406,7 +406,7 @@ typedef struct Gui #endif /* FEAT_GUI_GTK */ #if defined(FEAT_GUI_TABLINE) \ - && (defined(FEAT_GUI_W32) || defined(FEAT_GUI_MOTIF) \ + && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \ || defined(FEAT_GUI_MAC)) int tabline_height; #endif diff --git a/src/gui_beval.c b/src/gui_beval.c index 3a282181ac..e1e093f375 100644 --- a/src/gui_beval.c +++ b/src/gui_beval.c @@ -13,7 +13,7 @@ #if defined(FEAT_BEVAL_GUI) || defined(PROTO) /* on Win32 only get_beval_info() is required */ -#if !defined(FEAT_GUI_W32) || defined(PROTO) +#if !defined(FEAT_GUI_MSWIN) || defined(PROTO) #ifdef FEAT_GUI_GTK # if GTK_CHECK_VERSION(3,0,0) @@ -197,10 +197,10 @@ gui_mch_currently_showing_beval(void) return current_beval; } #endif -#endif /* !FEAT_GUI_W32 */ +#endif /* !FEAT_GUI_MSWIN */ #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL) || defined(PROTO) -# if !defined(FEAT_GUI_W32) || defined(PROTO) +# if !defined(FEAT_GUI_MSWIN) || defined(PROTO) /* * Show a balloon with "mesg". @@ -214,10 +214,10 @@ gui_mch_post_balloon(BalloonEval *beval, char_u *mesg) else undrawBalloon(beval); } -# endif /* !FEAT_GUI_W32 */ +# endif /* !FEAT_GUI_MSWIN */ #endif /* FEAT_NETBEANS_INTG || PROTO */ -#if !defined(FEAT_GUI_W32) || defined(PROTO) +#if !defined(FEAT_GUI_MSWIN) || defined(PROTO) #if defined(FEAT_BEVAL_TIP) || defined(PROTO) /* * Hide the given balloon. @@ -1220,6 +1220,6 @@ createBalloonEvalWindow(BalloonEval *beval) } #endif /* !FEAT_GUI_GTK */ -#endif /* !FEAT_GUI_W32 */ +#endif /* !FEAT_GUI_MSWIN */ #endif /* FEAT_BEVAL_GUI */ diff --git a/src/gui_gtk.c b/src/gui_gtk.c index 3d08934840..ba8fd9dc15 100644 --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -76,7 +76,7 @@ # include # endif # include -# ifdef WIN3264 +# ifdef MSWIN # include # else # include diff --git a/src/gui_gtk_f.c b/src/gui_gtk_f.c index 3f376c0484..d81474b3f7 100644 --- a/src/gui_gtk_f.c +++ b/src/gui_gtk_f.c @@ -32,7 +32,7 @@ #if !GTK_CHECK_VERSION(3,0,0) # include #endif -#ifdef WIN3264 +#ifdef MSWIN # include #else # include diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index b76aacd9cc..5e74adcebe 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -86,7 +86,7 @@ extern void bonobo_dock_item_set_behavior(BonoboDockItem *dock_item, BonoboDockI # include # endif # include -# ifdef WIN3264 +# ifdef MSWIN # include # else # include diff --git a/src/if_cscope.c b/src/if_cscope.c index 4cc053ed0f..03346749c9 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -548,7 +548,7 @@ staterr: goto add_err; while (fname[strlen(fname)-1] == '/' -#ifdef WIN32 +#ifdef MSWIN || fname[strlen(fname)-1] == '\\' #endif ) @@ -790,7 +790,7 @@ cs_create_connection(int i) #endif int len; char *prog, *cmd, *ppath = NULL; -#ifdef WIN32 +#ifdef MSWIN int fd; SECURITY_ATTRIBUTES sa; PROCESS_INFORMATION pi; @@ -844,7 +844,7 @@ err_closing: (void)close(to_cs[1]); (void)close(from_cs[0]); #else - /* WIN32 */ + /* MSWIN */ /* Create pipes to communicate with cscope */ sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; @@ -874,7 +874,7 @@ err_closing: #ifdef UNIX return CSCOPE_FAILURE; #else - /* WIN32 */ + /* MSWIN */ goto err_closing; #endif } @@ -891,7 +891,7 @@ err_closing: #ifdef UNIX return CSCOPE_FAILURE; #else - /* WIN32 */ + /* MSWIN */ goto err_closing; #endif } @@ -910,7 +910,7 @@ err_closing: #ifdef UNIX return CSCOPE_FAILURE; #else - /* WIN32 */ + /* MSWIN */ goto err_closing; #endif } @@ -919,7 +919,7 @@ err_closing: #if defined(UNIX) (void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname); #else - /* WIN32 */ + /* MSWIN */ (void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname); #endif if (csinfo[i].ppath != NULL) @@ -971,7 +971,7 @@ err_closing: } #else - /* WIN32 */ + /* MSWIN */ /* Create a new process to run cscope and use pipes to talk with it */ GetStartupInfo(&si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; @@ -1330,7 +1330,7 @@ clear_csinfo(int i) csinfo[i].pid = 0; csinfo[i].fr_fp = NULL; csinfo[i].to_fp = NULL; -#if defined(WIN32) +#if defined(MSWIN) csinfo[i].hProc = NULL; #endif } @@ -1940,13 +1940,13 @@ cs_pathcomponents(char *path) s = path + strlen(path) - 1; for (i = 0; i < p_cspc; ++i) while (s > path && *--s != '/' -#ifdef WIN32 +#ifdef MSWIN && *--s != '\\' #endif ) ; if ((s > path && *s == '/') -#ifdef WIN32 +#ifdef MSWIN || (s > path && *s == '\\') #endif ) @@ -2433,7 +2433,7 @@ cs_resolve_file(int i, char *name) if (csinfo[i].ppath != NULL && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) && (name[0] != '/') -#ifdef WIN32 +#ifdef MSWIN && name[0] != '\\' && name[1] != ':' #endif ) diff --git a/src/if_cscope.h b/src/if_cscope.h index 419c469467..6f3b02dbd7 100644 --- a/src/if_cscope.h +++ b/src/if_cscope.h @@ -11,7 +11,7 @@ #if defined(FEAT_CSCOPE) || defined(PROTO) -#if defined (WIN32) +#if defined (MSWIN) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif @@ -45,7 +45,7 @@ typedef struct csi { dev_t st_dev; /* ID of dev containing cscope db */ ino_t st_ino; /* inode number of cscope db */ #else -# if defined(WIN32) +# if defined(MSWIN) DWORD pid; /* PID of the connected cscope process. */ HANDLE hProc; /* cscope process handle */ DWORD nVolume; /* Volume serial number, instead of st_dev */ diff --git a/src/if_lua.c b/src/if_lua.c index e650e5e7d1..12643f90c8 100644 --- a/src/if_lua.c +++ b/src/if_lua.c @@ -80,7 +80,7 @@ static luaV_Funcref *luaV_pushfuncref(lua_State *L, typval_T *tv); #ifdef DYNAMIC_LUA -#ifndef WIN3264 +#ifndef MSWIN # include # define HANDLE void* # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) diff --git a/src/if_mzsch.c b/src/if_mzsch.c index 16c4c88df5..27925afb3c 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -47,7 +47,7 @@ typedef int HINSTANCE; * racket-6.3. See * http://docs.racket-lang.org/inside/im_memoryalloc.html?q=scheme_register_tls_space */ -#if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) \ +#if MZSCHEME_VERSION_MAJOR >= 500 && defined(MSWIN) \ && defined(USE_THREAD_LOCAL) \ && (!defined(_WIN64) || MZSCHEME_VERSION_MAJOR >= 603) # define HAVE_TLS_SPACE 1 @@ -807,7 +807,7 @@ static long range_end; /* MzScheme threads scheduling stuff */ static int mz_threads_allow = 0; -#if defined(FEAT_GUI_W32) +#if defined(FEAT_GUI_MSWIN) static void CALLBACK timer_proc(HWND, UINT, UINT_PTR, DWORD); static UINT timer_id = 0; #elif defined(FEAT_GUI_GTK) @@ -822,7 +822,7 @@ static EventLoopTimerRef timer_id = NULL; static EventLoopTimerUPP timerUPP; #endif -#ifndef FEAT_GUI_W32 /* Win32 console and Unix */ +#ifndef FEAT_GUI_MSWIN /* Win32 console and Unix */ void mzvim_check_threads(void) { @@ -847,7 +847,7 @@ static void setup_timer(void); static void remove_timer(void); /* timers are presented in GUI only */ -# if defined(FEAT_GUI_W32) +# if defined(FEAT_GUI_MSWIN) static void CALLBACK timer_proc(HWND hwnd UNUSED, UINT uMsg UNUSED, UINT_PTR idEvent UNUSED, DWORD dwTime UNUSED) # elif defined(FEAT_GUI_GTK) @@ -875,7 +875,7 @@ timer_proc(EventLoopTimerRef theTimer UNUSED, void *userData UNUSED) static void setup_timer(void) { -# if defined(FEAT_GUI_W32) +# if defined(FEAT_GUI_MSWIN) timer_id = SetTimer(NULL, 0, p_mzq, timer_proc); # elif defined(FEAT_GUI_GTK) timer_id = g_timeout_add((guint)p_mzq, (GSourceFunc)timer_proc, NULL); @@ -891,7 +891,7 @@ setup_timer(void) static void remove_timer(void) { -# if defined(FEAT_GUI_W32) +# if defined(FEAT_GUI_MSWIN) KillTimer(NULL, timer_id); # elif defined(FEAT_GUI_GTK) g_source_remove(timer_id); diff --git a/src/if_ole.cpp b/src/if_ole.cpp index 0888883630..8ee348d662 100644 --- a/src/if_ole.cpp +++ b/src/if_ole.cpp @@ -6,7 +6,7 @@ * Do ":help credits" in Vim to see a list of people who contributed. */ -#if defined(FEAT_OLE) && defined(FEAT_GUI_W32) +#if defined(FEAT_OLE) && defined(WIN32) && defined(FEAT_GUI) /* * OLE server implementation. * diff --git a/src/if_perl.xs b/src/if_perl.xs index 67d0b94888..2655640755 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -100,7 +100,7 @@ // Work around for ActivePerl 5.20.3+: Avoid generating (g)vim.lib. #if defined(ACTIVEPERL_VERSION) && (ACTIVEPERL_VERSION >= 2003) \ - && defined(WIN32) && defined(USE_DYNAMIC_LOADING) + && defined(MSWIN) && defined(USE_DYNAMIC_LOADING) # undef XS_EXTERNAL # define XS_EXTERNAL(name) XSPROTO(name) #endif @@ -154,7 +154,7 @@ EXTERN_C void boot_DynaLoader(pTHX_ CV*); #if defined(DYNAMIC_PERL) || defined(PROTO) # ifndef DYNAMIC_PERL /* just generating prototypes */ -# ifdef WIN3264 +# ifdef MSWIN typedef int HANDLE; # endif typedef int XSINIT_t; @@ -164,7 +164,7 @@ typedef int XSUBADDR_t; typedef int perl_key; # endif -# ifndef WIN3264 +# ifndef MSWIN # include # define HANDLE void* # define PERL_PROC void* diff --git a/src/if_python.c b/src/if_python.c index 343804668b..06c46bc37b 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -35,7 +35,7 @@ # undef _POSIX_THREADS #endif -#if defined(_WIN32) && defined(HAVE_FCNTL_H) +#if defined(MSWIN) && defined(HAVE_FCNTL_H) # undef HAVE_FCNTL_H #endif @@ -127,7 +127,7 @@ struct PyMethodDef { Py_ssize_t a; }; # define HINSTANCE long_u /* for generating prototypes */ # endif -# ifndef WIN3264 +# ifndef MSWIN # include # define FARPROC void* # define HINSTANCE void* diff --git a/src/if_python3.c b/src/if_python3.c index 4bbbdd1963..8b4bee9f75 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -34,7 +34,7 @@ #include -#if defined(_WIN32) && defined(HAVE_FCNTL_H) +#if defined(MSWIN) && defined(HAVE_FCNTL_H) # undef HAVE_FCNTL_H #endif @@ -112,7 +112,7 @@ typedef PySliceObject PySliceObject_T; #if defined(DYNAMIC_PYTHON3) || defined(PROTO) -# ifndef WIN3264 +# ifndef MSWIN # include # define FARPROC void* # define HINSTANCE void* diff --git a/src/if_ruby.c b/src/if_ruby.c index 24814a2326..85f94c4f09 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -64,7 +64,7 @@ # define RUBY_EXPORT # endif -#if !(defined(WIN32) || defined(_WIN64)) +#if !defined(MSWIN) # include # define HINSTANCE void* # define RUBY_PROC void* @@ -331,7 +331,7 @@ static void ruby_vim_init(void); # endif # define ruby_init dll_ruby_init # define ruby_init_loadpath dll_ruby_init_loadpath -# ifdef WIN3264 +# ifdef MSWIN # ifdef RUBY19_OR_LATER # define ruby_sysinit dll_ruby_sysinit # else @@ -447,7 +447,7 @@ static VALUE *dll_ruby_errinfo; # endif static void (*dll_ruby_init) (void); static void (*dll_ruby_init_loadpath) (void); -# ifdef WIN3264 +# ifdef MSWIN # ifdef RUBY19_OR_LATER static void (*dll_ruby_sysinit) (int*, char***); # else @@ -666,7 +666,7 @@ static struct # endif {"ruby_init", (RUBY_PROC*)&dll_ruby_init}, {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, -# ifdef WIN3264 +# ifdef MSWIN # ifdef RUBY19_OR_LATER {"ruby_sysinit", (RUBY_PROC*)&dll_ruby_sysinit}, # else @@ -949,7 +949,7 @@ static int ensure_ruby_initialized(void) if (ruby_enabled(TRUE)) { #endif -#ifdef _WIN32 +#ifdef MSWIN /* suggested by Ariya Mizutani */ int argc = 1; char *argv[] = {"gvim.exe"}; diff --git a/src/if_tcl.c b/src/if_tcl.c index eb6684c8f1..46378a27fb 100644 --- a/src/if_tcl.c +++ b/src/if_tcl.c @@ -160,7 +160,7 @@ static struct ref refsdeleted; /* dummy object for deleted ref list */ typedef int HANDLE; # endif -# ifndef WIN3264 +# ifndef MSWIN # include # define HANDLE void* # define TCL_PROC void* @@ -1741,11 +1741,11 @@ tclinit(exarg_T *eap) #endif Tcl_SetChannelOption(interp, ch1, "-buffering", "line"); -#ifdef WIN3264 +#ifdef MSWIN Tcl_SetChannelOption(interp, ch1, "-translation", "lf"); #endif Tcl_SetChannelOption(interp, ch2, "-buffering", "line"); -#ifdef WIN3264 +#ifdef MSWIN Tcl_SetChannelOption(interp, ch2, "-translation", "lf"); #endif diff --git a/src/macros.h b/src/macros.h index 29607db179..b81af8c60e 100644 --- a/src/macros.h +++ b/src/macros.h @@ -160,11 +160,11 @@ # define mch_stat(n, p) stat(vms_fixfilename(n), (p)) # define mch_rmdir(n) rmdir(vms_fixfilename(n)) #else -# ifndef WIN32 +# ifndef MSWIN # define mch_access(n, p) access((n), (p)) # endif # define mch_fstat(n, p) fstat((n), (p)) -# ifdef MSWIN /* has its own mch_stat() function */ +# ifdef MSWIN // has its own mch_stat() function # define mch_stat(n, p) vim_stat((n), (p)) # else # ifdef STAT_IGNORES_SLASH @@ -194,7 +194,7 @@ #if defined(UNIX) || defined(VMS) /* open in rw------- mode */ # define mch_open_rw(n, f) mch_open((n), (f), (mode_t)0600) #else -# if defined(MSWIN) /* open read/write */ +# if defined(MSWIN) // open read/write # define mch_open_rw(n, f) mch_open((n), (f), S_IREAD | S_IWRITE) # else # define mch_open_rw(n, f) mch_open((n), (f), 0) @@ -269,7 +269,7 @@ # include # endif # ifdef USING_FLOAT_STUFF -# if defined(WIN32) +# ifdef MSWIN # ifndef isnan # define isnan(x) _isnan(x) static __inline int isinf(double x) { return !_finite(x) && !_isnan(x); } diff --git a/src/main.c b/src/main.c index 6ad6fff7c5..d4e034963d 100644 --- a/src/main.c +++ b/src/main.c @@ -11,7 +11,7 @@ #include "vim.h" #ifdef __CYGWIN__ -# ifndef WIN32 +# ifndef MSWIN # include # include /* for cygwin_conv_to_posix_path() and/or * cygwin_conv_path() */ @@ -19,7 +19,7 @@ # include #endif -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) # include "iscygpty.h" #endif @@ -119,7 +119,7 @@ main */ mch_early_init(); -#if defined(WIN32) +#ifdef MSWIN /* * MinGW expands command line arguments, which confuses our code to * convert when 'encoding' changes. Get the unexpanded arguments. @@ -250,7 +250,7 @@ main params.fname = alist_name(&GARGLIST[0]); } -#if defined(WIN32) +#ifdef MSWIN { extern void set_alist_count(void); @@ -854,7 +854,7 @@ vim_main2(void) } #endif -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) mch_set_winsize_now(); /* Allow winsize changes from now on */ #endif @@ -880,7 +880,7 @@ vim_main2(void) { # ifdef FEAT_GUI # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \ - && !defined(FEAT_GUI_W32) + && !defined(FEAT_GUI_MSWIN) if (gui.in_use) { mch_errmsg(_("netbeans is not supported with this GUI\n")); @@ -1534,7 +1534,7 @@ getout(int exitval) if (garbage_collect_at_exit) garbage_collect(FALSE); #endif -#if defined(WIN32) +#ifdef MSWIN free_cmd_argsW(); #endif @@ -1559,7 +1559,7 @@ init_locale(void) setlocale(LC_NUMERIC, "C"); # endif -# ifdef WIN32 +# ifdef MSWIN /* Apparently MS-Windows printf() may cause a crash when we give it 8-bit * text while it's expecting text in the current locale. This call avoids * that. */ @@ -1642,8 +1642,8 @@ early_arg_scan(mparm_T *parmp UNUSED) } # endif -# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) -# ifdef FEAT_GUI_W32 +# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) +# ifdef FEAT_GUI_MSWIN else if (STRICMP(argv[i], "--windowid") == 0) # else else if (STRICMP(argv[i], "--socketid") == 0) @@ -1661,7 +1661,7 @@ early_arg_scan(mparm_T *parmp UNUSED) if (count != 1) mainerr(ME_INVALID_ARG, (char_u *)argv[i]); else -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN win_socket_id = id; # else gtk_socket_id = id; @@ -1942,7 +1942,7 @@ command_line_scan(mparm_T *parmp) } } #endif -#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) # ifdef FEAT_GUI_GTK else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) # else @@ -2237,7 +2237,7 @@ command_line_scan(mparm_T *parmp) case 'u': /* "-u {vimrc}" vim inits file */ case 'U': /* "-U {gvimrc}" gvim inits file */ case 'W': /* "-W {scriptout}" overwrite */ -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN case 'P': /* "-P {parent title}" MDI parent */ #endif want_argument = TRUE; @@ -2399,7 +2399,7 @@ scripterror: } break; -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN case 'P': /* "-P {parent title}" MDI parent */ gui_mch_set_parent(argv[0]); break; @@ -2445,7 +2445,7 @@ scripterror: } } #endif -#if defined(__CYGWIN32__) && !defined(WIN32) +#if defined(__CYGWIN32__) && !defined(MSWIN) /* * If vim is invoked by non-Cygwin tools, convert away any * DOS paths, so things like .swp files are created correctly. @@ -2481,7 +2481,7 @@ scripterror: #endif ); -#if defined(WIN32) +#ifdef MSWIN { /* Remember this argument has been added to the argument list. * Needed when 'encoding' is changed. */ @@ -2561,7 +2561,7 @@ check_tty(mparm_T *parmp) exit(1); } #endif -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) if (is_cygpty_used()) { # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \ @@ -3423,7 +3423,7 @@ usage(void) main_msg(_("--socketid \tOpen Vim inside another GTK widget")); main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout")); #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN main_msg(_("-P \tOpen Vim inside parent application")); main_msg(_("--windowid \tOpen Vim inside another win32 widget")); #endif @@ -3460,7 +3460,7 @@ check_swap_exists_action(void) #if defined(STARTUPTIME) || defined(PROTO) static struct timeval prev_timeval; -# ifdef WIN3264 +# ifdef MSWIN /* * Windows doesn't have gettimeofday(), although it does have struct timeval. */ @@ -3567,7 +3567,7 @@ set_progpath(char_u *argv0) { char_u *val = argv0; -# if defined(WIN32) +# ifdef MSWIN /* 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 @@ -3600,7 +3600,7 @@ set_progpath(char_u *argv0) set_vim_var_string(VV_PROGPATH, val, -1); -# ifdef WIN32 +# ifdef MSWIN vim_free(path); # endif } @@ -3623,7 +3623,7 @@ exec_on_server(mparm_T *parmp) { if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL) { -# ifdef WIN32 +# ifdef MSWIN /* Initialise the client/server messaging infrastructure. */ serverInitMessaging(); # endif @@ -3645,7 +3645,7 @@ exec_on_server(mparm_T *parmp) * clipboard first, it's further down. */ parmp->servername = serverMakeName(parmp->serverName_arg, parmp->argv[0]); -# ifdef WIN32 +# ifdef MSWIN if (parmp->servername != NULL) { serverSetName(parmp->servername); @@ -3842,7 +3842,7 @@ cmdsrv_main( break; } -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN /* Guess that when the server name starts with "g" it's a GUI * server, which we can bring to the foreground here. * Foreground() in the server doesn't work very well. */ @@ -3860,7 +3860,7 @@ cmdsrv_main( int j; char_u *done = alloc(numFiles); char_u *p; -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN NOTIFYICONDATA ni; int count = 0; extern HWND message_window; @@ -3870,7 +3870,7 @@ cmdsrv_main( /* Skip "+cmd" argument, don't wait for it to be edited. */ --numFiles; -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN ni.cbSize = sizeof(ni); ni.hWnd = message_window; ni.uID = 0; @@ -3884,7 +3884,7 @@ cmdsrv_main( vim_memset(done, 0, numFiles); while (memchr(done, 0, numFiles) != NULL) { -# ifdef WIN32 +# ifdef MSWIN p = serverGetReply(srv, NULL, TRUE, TRUE, 0); if (p == NULL) break; @@ -3895,7 +3895,7 @@ cmdsrv_main( j = atoi((char *)p); if (j >= 0 && j < numFiles) { -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN ++count; sprintf(ni.szTip, _("%d of %d edited"), count, numFiles); @@ -3904,7 +3904,7 @@ cmdsrv_main( done[j] = 1; } } -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN Shell_NotifyIcon(NIM_DELETE, &ni); # endif } @@ -3913,7 +3913,7 @@ cmdsrv_main( { if (i == *argc - 1) mainerr_arg_missing((char_u *)argv[i]); -# ifdef WIN32 +# ifdef MSWIN /* Win32 always works? */ if (serverSendToVim(sname, (char_u *)argv[i + 1], &res, NULL, 1, 0, FALSE) < 0) @@ -3935,7 +3935,7 @@ cmdsrv_main( } else if (STRICMP(argv[i], "--serverlist") == 0) { -# ifdef WIN32 +# ifdef MSWIN /* Win32 always works? */ res = serverGetVimNames(); # else diff --git a/src/mbyte.c b/src/mbyte.c index aa10d5e32b..9ad6404606 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -97,7 +97,7 @@ # define WINBYTE BYTE #endif -#if (defined(WIN3264) || defined(WIN32UNIX)) && !defined(__MINGW32__) +#if (defined(MSWIN) || defined(WIN32UNIX)) && !defined(__MINGW32__) # include #endif @@ -117,7 +117,7 @@ # else # include # endif -# ifdef WIN3264 +# ifdef MSWIN # include # else # include @@ -364,7 +364,7 @@ enc_alias_table[] = {"cyrillic", IDX_ISO_5}, {"arabic", IDX_ISO_6}, {"greek", IDX_ISO_7}, -#ifdef WIN3264 +#ifdef MSWIN {"hebrew", IDX_CP1255}, #else {"hebrew", IDX_ISO_8}, @@ -412,7 +412,7 @@ enc_alias_table[] = {"euccn", IDX_EUC_CN}, {"gb2312", IDX_EUC_CN}, {"euctw", IDX_EUC_TW}, -#if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS_X) +#if defined(MSWIN) || defined(WIN32UNIX) || defined(MACOS_X) {"japan", IDX_CP932}, {"korea", IDX_CP949}, {"prc", IDX_CP936}, @@ -465,7 +465,7 @@ enc_canon_props(char_u *name) i = enc_canon_search(name); if (i >= 0) return enc_canon_table[i].prop; -#ifdef WIN3264 +#ifdef MSWIN if (name[0] == 'c' && name[1] == 'p' && VIM_ISDIGIT(name[2])) { CPINFO cpinfo; @@ -509,7 +509,7 @@ mb_init(void) int idx; int n; int enc_dbcs_new = 0; -#if defined(USE_ICONV) && !defined(WIN3264) && !defined(WIN32UNIX) \ +#if defined(USE_ICONV) && !defined(MSWIN) && !defined(WIN32UNIX) \ && !defined(MACOS_CONVERT) # define LEN_FROM_CONV vimconv_T vimconv; @@ -527,7 +527,7 @@ mb_init(void) return NULL; } -#ifdef WIN3264 +#ifdef MSWIN if (p_enc[0] == 'c' && p_enc[1] == 'p' && VIM_ISDIGIT(p_enc[2])) { CPINFO cpinfo; @@ -566,7 +566,7 @@ codepage_invalid: } else if (STRNCMP(p_enc, "2byte-", 6) == 0) { -#ifdef WIN3264 +#ifdef MSWIN /* Windows: accept only valid codepage numbers, check below. */ if (p_enc[6] != 'c' || p_enc[7] != 'p' || (enc_dbcs_new = atoi((char *)p_enc + 8)) == 0) @@ -607,7 +607,7 @@ codepage_invalid: if (enc_dbcs_new != 0) { -#ifdef WIN3264 +#ifdef MSWIN /* Check if the DBCS code page is OK. */ if (!IsValidCodePage(enc_dbcs_new)) goto codepage_invalid; @@ -618,7 +618,7 @@ codepage_invalid: enc_dbcs = enc_dbcs_new; has_mbyte = (enc_dbcs != 0 || enc_utf8); -#if defined(WIN3264) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) +#if defined(MSWIN) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) enc_codepage = encname2codepage(p_enc); enc_latin9 = (STRCMP(p_enc, "iso-8859-15") == 0); #endif @@ -699,7 +699,7 @@ codepage_invalid: n = 1; else { -#if defined(WIN3264) || defined(WIN32UNIX) +#if defined(MSWIN) || defined(WIN32UNIX) /* enc_dbcs is set by setting 'fileencoding'. It becomes a Windows * CodePage identifier, which we can pass directly in to Windows * API */ @@ -783,7 +783,7 @@ codepage_invalid: enc_utf8 ? "utf-8" : (char *)p_enc); #endif -#ifdef WIN32 +#ifdef MSWIN /* When changing 'encoding' while starting up, then convert the command * line arguments from the active codepage to 'encoding'. */ if (starting != 0) @@ -909,7 +909,7 @@ dbcs_class(unsigned lead, unsigned trail) unsigned char tb = trail; /* convert process code to JIS */ -# if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS_X) +# if defined(MSWIN) || defined(WIN32UNIX) || defined(MACOS_X) /* process code is SJIS */ if (lb <= 0x9f) lb = (lb - 0x81) * 2 + 0x21; @@ -1006,7 +1006,7 @@ dbcs_class(unsigned lead, unsigned trail) if (c1 >= 0xB0 && c1 <= 0xC8) /* Hangul */ return 20; -#if defined(WIN3264) || defined(WIN32UNIX) +#if defined(MSWIN) || defined(WIN32UNIX) else if (c1 <= 0xA0 || c2 <= 0xA0) /* Extended Hangul Region : MS UHC(Unified Hangul Code) */ /* c1: 0x81-0xA0 with c2: 0x41-0x5A, 0x61-0x7A, 0x81-0xFE @@ -4393,7 +4393,7 @@ enc_alias_search(char_u *name) # include #endif -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN /* * Get the canonicalized encoding from the specified locale string "locale" * or from the environment variables LC_ALL, LC_CTYPE and LANG. @@ -4460,7 +4460,7 @@ enc_locale_env(char *locale) char_u * enc_locale(void) { -#ifdef WIN3264 +#ifdef MSWIN char buf[50]; long acp = GetACP(); @@ -4487,7 +4487,7 @@ enc_locale(void) #endif } -# if defined(WIN3264) || defined(PROTO) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) +# if defined(MSWIN) || defined(PROTO) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD) /* * Convert an encoding name to an MS-Windows codepage. * Returns zero if no codepage can be figured out. @@ -6570,7 +6570,7 @@ convert_setup_ext( /* Internal utf-8 -> latin9 conversion. */ vcp->vc_type = CONV_TO_LATIN9; } -#ifdef WIN3264 +#ifdef MSWIN /* Win32-specific codepage <-> codepage conversion without iconv. */ else if ((from_is_utf8 || encname2codepage(from) > 0) && (to_is_utf8 || encname2codepage(to) > 0)) @@ -6620,7 +6620,7 @@ convert_setup_ext( return OK; } -#if defined(FEAT_GUI) || defined(AMIGA) || defined(WIN3264) \ +#if defined(FEAT_GUI) || defined(AMIGA) || defined(MSWIN) \ || defined(PROTO) /* * Do conversion on typed input characters in-place. @@ -6870,7 +6870,7 @@ string_convert_ext( retval = iconv_string(vcp, ptr, len, unconvlenp, lenp); break; # endif -# ifdef WIN3264 +# ifdef MSWIN case CONV_CODEPAGE: /* codepage -> codepage */ { int retlen; diff --git a/src/memfile.c b/src/memfile.c index 1a527340ad..1827bcf2b3 100644 --- a/src/memfile.c +++ b/src/memfile.c @@ -621,7 +621,7 @@ mf_sync(memfile_T *mfp, int flags) status = FAIL; } #endif -#ifdef WIN32 +#ifdef MSWIN if (_commit(mfp->mf_fd)) status = FAIL; #endif @@ -1265,7 +1265,7 @@ mf_do_open( * try to open the file */ flags |= O_EXTRA | O_NOFOLLOW; -#ifdef WIN32 +#ifdef MSWIN /* Prevent handle inheritance that cause problems with Cscope * (swap file may not be deleted if cscope connection was open after * the file) */ diff --git a/src/memline.c b/src/memline.c index c62ea5f60c..66be0f3334 100644 --- a/src/memline.c +++ b/src/memline.c @@ -1807,7 +1807,7 @@ recover_names( #else names[0] = vim_strsave((char_u *)"*.sw?"); #endif -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) /* For Unix names starting with a dot are special. MS-Windows * supports this too, on some file systems. */ names[1] = vim_strsave((char_u *)".*.sw?"); @@ -1834,7 +1834,7 @@ recover_names( #else names[0] = concat_fnames(dir_name, (char_u *)"*.sw?", TRUE); #endif -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) /* For Unix names starting with a dot are special. MS-Windows * supports this too, on some file systems. */ names[1] = concat_fnames(dir_name, (char_u *)".*.sw?", TRUE); @@ -1851,7 +1851,7 @@ recover_names( } else { -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) int len = (int)STRLEN(dir_name); p = dir_name + len; @@ -1999,7 +1999,7 @@ recover_names( return file_count; } -#if defined(UNIX) || defined(WIN3264) || defined(PROTO) +#if defined(UNIX) || defined(MSWIN) || defined(PROTO) /* * Need _very_ long file names. * Append the full path to name with path separators made into percent @@ -2207,7 +2207,7 @@ recov_file_names(char_u **names, char_u *path, int prepend_dot) */ char_u *p; int i; -# ifndef WIN3264 +# ifndef MSWIN int shortname = curbuf->b_shortname; curbuf->b_shortname = FALSE; @@ -2252,7 +2252,7 @@ recov_file_names(char_u **names, char_u *path, int prepend_dot) else ++num_names; -# ifndef WIN3264 +# ifndef MSWIN /* * Also try with 'shortname' set, in case the file is on a DOS filesystem. */ @@ -2279,7 +2279,7 @@ recov_file_names(char_u **names, char_u *path, int prepend_dot) # endif end: -# ifndef WIN3264 +# ifndef MSWIN curbuf->b_shortname = shortname; # endif @@ -4253,7 +4253,7 @@ makeswapname( char_u fname_buf[MAXPATHL]; #endif -#if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */ +#if defined(UNIX) || defined(MSWIN) // Need _very_ long file names int len = (int)STRLEN(dir_name); s = dir_name + len; @@ -4343,7 +4343,7 @@ get_file_in_dir( else retval = concat_fnames(dname, tail, TRUE); -#ifdef WIN3264 +#ifdef MSWIN if (retval != NULL) for (t = gettail(retval); *t != NUL; MB_PTR_ADV(t)) if (*t == ':') @@ -4474,7 +4474,7 @@ findswapname( # define CREATE_DUMMY_FILE FILE *dummyfd = NULL; -# ifdef WIN3264 +# ifdef MSWIN if (buf_fname != NULL && !mch_isFullName(buf_fname) && vim_strchr(gettail(buf_fname), ':')) { @@ -4927,7 +4927,7 @@ findswapname( mch_remove(buf_fname); } #endif -#ifdef WIN3264 +#ifdef MSWIN if (buf_fname != buf->b_fname) vim_free(buf_fname); #endif diff --git a/src/menu.c b/src/menu.c index 085d0e79ca..41669ed4ca 100644 --- a/src/menu.c +++ b/src/menu.c @@ -18,7 +18,7 @@ #define MENUDEPTH 10 /* maximum depth of menus */ -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *, int); #else static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *); @@ -35,7 +35,7 @@ static int get_menu_cmd_modes(char_u *, int, int *, int *); static char_u *popup_mode_name(char_u *name, int idx); static char_u *menu_text(char_u *text, int *mnemonic, char_u **actext); -#if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF) static void gui_create_tearoffs_recurse(vimmenu_T *menu, const char_u *pname, int *pri_tab, int pri_idx); static void gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx); static void gui_destroy_tearoffs_recurse(vimmenu_T *menu); @@ -43,7 +43,7 @@ static int s_tearoffs = FALSE; #endif static int menu_is_hidden(char_u *name); -#if defined(FEAT_CMDL_COMPL) || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) +#if defined(FEAT_CMDL_COMPL) || (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) static int menu_is_tearoff(char_u *name); #endif @@ -122,7 +122,7 @@ ex_menu( int i; #if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK) int old_menu_height; -# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) int old_toolbar_height; # endif #endif @@ -295,7 +295,7 @@ ex_menu( } #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)) old_menu_height = gui.menu_height; -# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) old_toolbar_height = gui.toolbar_height; # endif #endif @@ -381,7 +381,7 @@ ex_menu( menuarg.noremap[0] = noremap; menuarg.silent[0] = silent; add_menu_path(menu_path, &menuarg, pri_tab, map_to -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN , TRUE #endif ); @@ -405,7 +405,7 @@ ex_menu( menuarg.icon_builtin = FALSE; #endif add_menu_path(p, &menuarg, pri_tab, map_to -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN , TRUE #endif ); @@ -421,7 +421,7 @@ ex_menu( /* If the menubar height changed, resize the window */ if (gui.in_use && (gui.menu_height != old_menu_height -# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) || gui.toolbar_height != old_toolbar_height # endif )) @@ -455,7 +455,7 @@ add_menu_path( icon_builtin, silent[0], noremap[0] */ int *pri_tab, char_u *call_data -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN , int addtearoff /* may add tearoff item */ #endif ) @@ -537,7 +537,7 @@ add_menu_path( goto erret; } if (*next_name != NUL && menu->children == NULL -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN && addtearoff #endif ) @@ -630,7 +630,7 @@ add_menu_path( if (*next_name == NUL && menuarg->iconfile != NULL) menu->iconfile = vim_strsave(menuarg->iconfile); #endif -#if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF) /* the tearoff item must be present in the modes of each item. */ if (parent != NULL && menu_is_tearoff(parent->children->dname)) parent->children->modes |= modes; @@ -645,7 +645,7 @@ add_menu_path( * modes, then make sure it's available for this one now * Also enable a menu when it's created or changed. */ -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN /* If adding a tearbar (addtearoff == FALSE) don't update modes */ if (addtearoff) #endif @@ -680,7 +680,7 @@ add_menu_path( } } -# if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) +# if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) /* When adding a new submenu, may add a tearoff item */ if ( addtearoff && *next_name @@ -758,7 +758,7 @@ add_menu_path( c = 0; d = 0; if (amenu && call_data != NULL && *call_data != NUL -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN && addtearoff #endif ) @@ -808,7 +808,7 @@ add_menu_path( menu->silent[i] = menuarg->silent[0]; } } -#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) \ +#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \ && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK)) /* Need to update the menu tip. */ if (modes & MENU_TIP_MODE) @@ -938,7 +938,7 @@ remove_menu( } if ((menu->modes & modes) != 0x0) { -#if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) /* * If we are removing all entries for this menu,MENU_ALL_MODES, * Then kill any tearoff before we start @@ -992,7 +992,7 @@ remove_menu( /* Recalculate modes for menu based on the new updated children */ menu->modes &= ~modes; -#if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) if ((s_tearoffs) && (menu->children != NULL)) /* there's a tear bar.. */ child = menu->children->next; /* don't count tearoff bar */ else @@ -1003,7 +1003,7 @@ remove_menu( if (modes & MENU_TIP_MODE) { free_menu_string(menu, MENU_INDEX_TIP); -#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) \ +#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \ && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK)) /* Need to update the menu tip. */ if (gui.in_use) @@ -1013,7 +1013,7 @@ remove_menu( if ((menu->modes & MENU_ALL_MODES) == 0) { /* The menu item is no longer valid in ANY mode, so delete it */ -#if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) +#if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) if (s_tearoffs && menu->children != NULL) /* there's a tear bar.. */ free_menu(&menu->children); #endif @@ -1867,7 +1867,7 @@ menu_is_hidden(char_u *name) } #if defined(FEAT_CMDL_COMPL) \ - || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) + || (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) /* * Return TRUE if the menu is the tearoff menu. */ @@ -2031,7 +2031,7 @@ gui_update_menus_recurse(vimmenu_T *menu, int mode) while (menu) { if ((menu->modes & menu->enabled & mode) -# if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF) +# if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF) || menu_is_tearoff(menu->dname) # endif ) @@ -2105,7 +2105,7 @@ gui_is_menu_shortcut(int key) # endif #endif /* FEAT_GUI */ -#if (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) || defined(PROTO) +#if (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) || defined(PROTO) /* * Deal with tearoff items that are added like a menu item. @@ -2257,7 +2257,7 @@ gui_destroy_tearoffs_recurse(vimmenu_T *menu) } } -#endif /* FEAT_GUI_W32 && FEAT_TEAROFF */ +#endif /* FEAT_GUI_MSWIN && FEAT_TEAROFF */ /* * Execute "menu". Use by ":emenu" and the window toolbar. diff --git a/src/message.c b/src/message.c index ed59d1b435..621edb9701 100644 --- a/src/message.c +++ b/src/message.c @@ -2556,7 +2556,7 @@ t_puts( msg_use_printf(void) { return (!msg_check_screen() -#if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) || !termcap_active #endif || (swapping_screen() && !termcap_active) @@ -2573,7 +2573,7 @@ msg_puts_printf(char_u *str, int maxlen) char_u *buf = NULL; char_u *p = s; -#ifdef WIN3264 +#ifdef MSWIN if (!(silent_mode && p_verbose == 0)) mch_settmode(TMODE_COOK); /* handle CR and NL correctly */ #endif @@ -2633,7 +2633,7 @@ msg_puts_printf(char_u *str, int maxlen) msg_didout = TRUE; // assume that line is not empty -#ifdef WIN3264 +#ifdef MSWIN if (!(silent_mode && p_verbose == 0)) mch_settmode(TMODE_RAW); #endif @@ -2934,7 +2934,7 @@ do_more_prompt(int typed_char) void mch_errmsg(char *str) { -#if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) int len = (int)STRLEN(str); DWORD nwrite = 0; DWORD mode = 0; @@ -3022,7 +3022,7 @@ mch_errmsg(char *str) void mch_msg(char *str) { -#if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) int len = (int)STRLEN(str); DWORD nwrite = 0; DWORD mode; @@ -4008,7 +4008,7 @@ do_browse( filter = BROWSE_FILTER_DEFAULT; if (flags & BROWSE_DIR) { -# if defined(FEAT_GUI_GTK) || defined(WIN3264) +# if defined(FEAT_GUI_GTK) || defined(MSWIN) /* For systems that have a directory dialog. */ fname = gui_mch_browsedir(title, initdir); # else @@ -4754,7 +4754,7 @@ vim_vsnprintf_typval( else if (length_modifier == 'L') { # ifdef FEAT_NUM64 -# ifdef WIN3264 +# ifdef MSWIN f[f_l++] = 'I'; f[f_l++] = '6'; f[f_l++] = '4'; diff --git a/src/misc1.c b/src/misc1.c index 1d957908eb..75f4ab1ef5 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -14,7 +14,7 @@ #include "vim.h" #include "version.h" -#if defined(FEAT_CMDL_COMPL) && defined(WIN3264) +#if defined(FEAT_CMDL_COMPL) && defined(MSWIN) # include #endif @@ -3852,7 +3852,7 @@ init_homedir(void) var = mch_getenv((char_u *)"HOME"); #endif -#ifdef WIN3264 +#ifdef MSWIN /* * Typically, $HOME is not defined on Windows, unless the user has * specifically defined it for Vim's sake. However, on Windows NT @@ -4318,7 +4318,7 @@ vim_getenv(char_u *name, int *mustfree) if (p != NULL) { -#if defined(WIN3264) +#if defined(MSWIN) if (enc_utf8) { int len; @@ -4362,7 +4362,7 @@ vim_getenv(char_u *name, int *mustfree) else p = mch_getenv((char_u *)"VIM"); -#if defined(WIN3264) +#if defined(MSWIN) if (enc_utf8) { int len; @@ -4688,7 +4688,7 @@ init_users(void) add_user((char_u *)pw->pw_name, TRUE); endpwent(); } -# elif defined(WIN3264) +# elif defined(MSWIN) { DWORD nusers = 0, ntotal = 0, i; PUSER_INFO_0 uinfo; @@ -4820,7 +4820,7 @@ home_replace( #else homedir_env_orig = homedir_env = mch_getenv((char_u *)"HOME"); #endif -#ifdef WIN3264 +#ifdef MSWIN if (homedir_env == NULL) homedir_env_orig = homedir_env = mch_getenv((char_u *)"USERPROFILE"); #endif @@ -5619,7 +5619,7 @@ static int vim_backtick(char_u *p); static int expand_backtick(garray_T *gap, char_u *pat, int flags); # endif -# if defined(WIN3264) +# if defined(MSWIN) /* * File name expansion code for MS-DOS, Win16 and Win32. It's here because * it's shared between these systems. @@ -5898,7 +5898,7 @@ mch_expandpath( { return dos_expandpath(gap, path, 0, flags, FALSE); } -# endif /* WIN3264 */ +# endif // MSWIN #if (defined(UNIX) && !defined(VMS)) || defined(USE_UNIXFILENAME) \ || defined(PROTO) @@ -6646,7 +6646,7 @@ get_isolated_shell_name(void) { char_u *p; -#ifdef WIN3264 +#ifdef MSWIN p = gettail(p_sh); p = vim_strnsave(p, (int)(skiptowhite(p) - p)); #else diff --git a/src/misc2.c b/src/misc2.c index d323fe512f..e513c1b61d 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1427,7 +1427,7 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline) length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */ for (p = string; *p != NUL; MB_PTR_ADV(p)) { -# ifdef WIN32 +# ifdef MSWIN if (!p_ssl) { if (*p == '"') @@ -1458,7 +1458,7 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline) d = escaped_string; /* add opening quote */ -# ifdef WIN32 +# ifdef MSWIN if (!p_ssl) *d++ = '"'; else @@ -1467,7 +1467,7 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline) for (p = string; *p != NUL; ) { -# ifdef WIN32 +# ifdef MSWIN if (!p_ssl) { if (*p == '"') @@ -1510,7 +1510,7 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline) } /* add terminating quote and finish with a NUL */ -# ifdef WIN32 +# ifdef MSWIN if (!p_ssl) *d++ = '"'; else @@ -2169,7 +2169,7 @@ ga_append(garray_T *gap, int c) } } -#if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264) \ +#if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(MSWIN) \ || defined(PROTO) /* * Append the text in "gap" below the cursor line and clear "gap". @@ -4185,7 +4185,7 @@ filewritable(char_u *fname) perm = mch_getperm(fname); #endif if ( -# ifdef WIN3264 +# ifdef MSWIN mch_writable(fname) && # else # if defined(UNIX) || defined(VMS) @@ -4437,7 +4437,7 @@ parse_queued_messages(void) for (i = 0; i < MAX_REPEAT_PARSE; ++i) { // For Win32 mch_breakcheck() does not check for input, do it here. -# if defined(WIN32) && defined(FEAT_JOB_CHANNEL) +# if defined(MSWIN) && defined(FEAT_JOB_CHANNEL) channel_handle_events(FALSE); # endif diff --git a/src/nbdebug.c b/src/nbdebug.c index 991bc6633f..b76d9caf07 100644 --- a/src/nbdebug.c +++ b/src/nbdebug.c @@ -124,7 +124,7 @@ lookup( expand_env((char_u *) file, (char_u *) buf, BUFSIZ); return -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN (access(buf, F_OK) == 0); #else (access(buf, 0) == 0); diff --git a/src/netbeans.c b/src/netbeans.c index ecc7625e9b..2682d1c0b6 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -27,7 +27,7 @@ #if defined(FEAT_NETBEANS_INTG) || defined(PROTO) -#ifndef WIN32 +#ifndef MSWIN # include # ifdef HAVE_LIBGEN_H # include @@ -2347,7 +2347,7 @@ ex_nbstart( { #ifdef FEAT_GUI # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \ - && !defined(FEAT_GUI_W32) + && !defined(FEAT_GUI_MSWIN) if (gui.in_use) { emsg(_("E838: netbeans is not supported with this GUI")); @@ -2567,7 +2567,7 @@ set_ref_in_nb_channel(int copyID) } #endif -#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_W32) || defined(PROTO) +#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_MSWIN) || defined(PROTO) /* * Tell netbeans that the window was moved or resized. */ diff --git a/src/normal.c b/src/normal.c index ca0d8ff876..5ae9ff1aee 100644 --- a/src/normal.c +++ b/src/normal.c @@ -5401,7 +5401,7 @@ nv_clear(cmdarg_T *cap) # endif #endif redraw_later(CLEAR); -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) resize_console_buf(); #endif } diff --git a/src/option.c b/src/option.c index eec8fe0520..b71093b86a 100644 --- a/src/option.c +++ b/src/option.c @@ -505,7 +505,7 @@ static struct vimoption options[] = (char_u *)NULL, PV_NONE, #endif { -#if (defined(WIN3264)) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) (char_u *)128L, #else (char_u *)224L, @@ -575,7 +575,7 @@ static struct vimoption options[] = {"background", "bg", P_STRING|P_VI_DEF|P_RCLR, (char_u *)&p_bg, PV_NONE, { -#if (defined(WIN3264)) && !defined(FEAT_GUI) +#if (defined(MSWIN)) && !defined(FEAT_GUI) (char_u *)"dark", #else (char_u *)"light", @@ -1309,7 +1309,7 @@ static struct vimoption options[] = #ifdef FEAT_QUICKFIX (char_u *)&p_gp, PV_GP, { -# ifdef WIN3264 +# ifdef MSWIN /* may be changed to "grep -n" in os_win32.c */ (char_u *)"findstr /n", # else @@ -1739,7 +1739,7 @@ static struct vimoption options[] = {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, (char_u *)&Rows, PV_NONE, { -#if defined(WIN3264) +#if defined(MSWIN) (char_u *)25L, #else (char_u *)24L, @@ -1751,7 +1751,7 @@ static struct vimoption options[] = #else (char_u *)NULL, PV_NONE, #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN {(char_u *)1L, (char_u *)0L} #else {(char_u *)0L, (char_u *)0L} @@ -1897,7 +1897,7 @@ static struct vimoption options[] = {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST, (char_u *)&p_mouse, PV_NONE, { -#if defined(WIN3264) +#if defined(MSWIN) (char_u *)"a", #else (char_u *)"", @@ -2260,7 +2260,7 @@ static struct vimoption options[] = (char_u *)&p_report, PV_NONE, {(char_u *)2L, (char_u *)0L} SCTX_INIT}, {"restorescreen", "rs", P_BOOL|P_VI_DEF, -#ifdef WIN3264 +#ifdef MSWIN (char_u *)&p_rs, PV_NONE, #else (char_u *)NULL, PV_NONE, @@ -2363,7 +2363,7 @@ static struct vimoption options[] = #ifdef VMS (char_u *)"-", #else -# if defined(WIN3264) +# if defined(MSWIN) (char_u *)"", /* set in set_init_1() */ # else (char_u *)"sh", @@ -2429,7 +2429,7 @@ static struct vimoption options[] = {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE, (char_u *)&p_sxe, PV_NONE, { -#if defined(WIN3264) +#if defined(MSWIN) (char_u *)"\"&|<>()@^", #else (char_u *)"", @@ -2720,7 +2720,7 @@ static struct vimoption options[] = #endif SCTX_INIT}, {"termwintype", "twt", P_STRING|P_ALLOCED|P_VI_DEF, -#if defined(WIN3264) && defined(FEAT_TERMINAL) +#if defined(MSWIN) && defined(FEAT_TERMINAL) (char_u *)&p_twt, PV_NONE, {(char_u *)"", (char_u *)NULL} #else @@ -2795,7 +2795,7 @@ static struct vimoption options[] = #endif {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP, -#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) (char_u *)&p_toolbar, PV_NONE, {(char_u *)"icons,tooltips", (char_u *)0L} #else @@ -2857,7 +2857,7 @@ static struct vimoption options[] = {"undolevels", "ul", P_NUM|P_VI_DEF, (char_u *)&p_ul, PV_UL, { -#if defined(UNIX) || defined(WIN3264) || defined(VMS) +#if defined(UNIX) || defined(MSWIN) || defined(VMS) (char_u *)1000L, #else (char_u *)100L, @@ -3033,7 +3033,7 @@ static struct vimoption options[] = (char_u *)&p_wmw, PV_NONE, {(char_u *)1L, (char_u *)0L} SCTX_INIT}, {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, -#if defined(WIN3264) && defined(FEAT_TERMINAL) +#if defined(MSWIN) && defined(FEAT_TERMINAL) (char_u *)&p_winptydll, PV_NONE, { # ifdef _WIN64 (char_u *)"winpty64.dll", @@ -3209,7 +3209,7 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noins #ifdef FEAT_SIGNS static char *(p_scl_values[]) = {"yes", "no", "auto", NULL}; #endif -#if defined(WIN3264) && defined(FEAT_TERMINAL) +#if defined(MSWIN) && defined(FEAT_TERMINAL) static char *(p_twt_values[]) = {"winpty", "conpty", "", NULL}; #endif @@ -3306,7 +3306,7 @@ set_init_1(int clean_arg) if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) #if defined(MSWIN) || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) -# ifdef WIN3264 +# ifdef MSWIN || ((p = (char_u *)default_shell()) != NULL && *p != NUL) # endif #endif @@ -3575,7 +3575,7 @@ set_init_1(int clean_arg) didset_options2(); -# if defined(WIN3264) && defined(FEAT_GETTEXT) +# if defined(MSWIN) && defined(FEAT_GETTEXT) /* * If $LANG isn't set, try to get a good value for it. This makes the * right language be used automatically. Don't do this for English. @@ -3658,7 +3658,7 @@ set_init_1(int clean_arg) } #endif -#if defined(WIN3264) && !defined(FEAT_GUI) +#if defined(MSWIN) && !defined(FEAT_GUI) /* Win32 console: When GetACP() returns a different value from * GetConsoleCP() set 'termencoding'. */ if (GetACP() != GetConsoleCP()) @@ -3687,7 +3687,7 @@ set_init_1(int clean_arg) p_tenc = empty_option; } #endif -#if defined(WIN3264) +#if defined(MSWIN) /* $HOME may have characters in active code page. */ init_homedir(); #endif @@ -3922,7 +3922,7 @@ set_init_2(void) set_number_default("window", Rows - 1); /* For DOS console the default is always black. */ -#if !((defined(WIN3264)) && !defined(FEAT_GUI)) +#if !((defined(MSWIN)) && !defined(FEAT_GUI)) /* * If 'background' wasn't set by the user, try guessing the value, * depending on the terminal name. Only need to check for terminals @@ -3965,7 +3965,7 @@ set_init_2(void) static char_u * term_bg_default(void) { -#if defined(WIN3264) +#if defined(MSWIN) /* DOS console is nearly always black */ return (char_u *)"dark"; #else @@ -3990,7 +3990,7 @@ term_bg_default(void) void set_init_3(void) { -#if defined(UNIX) || defined(WIN3264) +#if defined(UNIX) || defined(MSWIN) /* * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. * This is done after other initializations, where 'shell' might have been @@ -4025,7 +4025,7 @@ set_init_3(void) */ if ( fnamecmp(p, "csh") == 0 || fnamecmp(p, "tcsh") == 0 -# if defined(WIN3264) /* also check with .exe extension */ +# if defined(MSWIN) // also check with .exe extension || fnamecmp(p, "csh.exe") == 0 || fnamecmp(p, "tcsh.exe") == 0 # endif @@ -4034,7 +4034,7 @@ set_init_3(void) # if defined(FEAT_QUICKFIX) if (do_sp) { -# ifdef WIN3264 +# ifdef MSWIN p_sp = (char_u *)">&"; # else p_sp = (char_u *)"|& tee"; @@ -4058,7 +4058,7 @@ set_init_3(void) || fnamecmp(p, "zsh-beta") == 0 || fnamecmp(p, "bash") == 0 || fnamecmp(p, "fish") == 0 -# ifdef WIN3264 +# ifdef MSWIN || fnamecmp(p, "cmd") == 0 || fnamecmp(p, "sh.exe") == 0 || fnamecmp(p, "ksh.exe") == 0 @@ -4074,7 +4074,7 @@ set_init_3(void) # if defined(FEAT_QUICKFIX) if (do_sp) { -# ifdef WIN3264 +# ifdef MSWIN p_sp = (char_u *)">%s 2>&1"; # else p_sp = (char_u *)"2>&1| tee"; @@ -4092,7 +4092,7 @@ set_init_3(void) } #endif -#if defined(WIN3264) +#if defined(MSWIN) /* * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the * 'shell' option. @@ -5553,7 +5553,7 @@ didset_options(void) (void)compile_cap_prog(curwin->w_s); (void)did_set_spell_option(TRUE); #endif -#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); #endif #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) @@ -6403,7 +6403,7 @@ did_set_string_option( } } -#if defined(WIN3264) +#if defined(MSWIN) /* $HOME may have characters in active code page. */ if (varp == &p_enc) init_homedir(); @@ -6810,7 +6810,7 @@ did_set_string_option( { out_str(T_ME); redraw_later(CLEAR); -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) /* Since t_me has been set, this probably means that the user * wants to use this as default colors. Need to reset default * background/foreground colors. */ @@ -7228,7 +7228,7 @@ did_set_string_option( #endif -#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) /* 'toolbar' */ else if (varp == &p_toolbar) { @@ -7498,7 +7498,7 @@ did_set_string_option( errmsg = e_invarg; } } -# if defined(WIN3264) +# if defined(MSWIN) // 'termwintype' else if (varp == &p_twt) { diff --git a/src/option.h b/src/option.h index 2f1d322bf1..7824520067 100644 --- a/src/option.h +++ b/src/option.h @@ -18,7 +18,7 @@ #ifdef AMIGA # define DFLT_EFM "%f>%l:%c:%t:%n:%m,%f:%l: %t%*\\D%n: %m,%f %l %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f:%l:%m,%f|%l| %m" #else -# if defined(WIN3264) +# if defined(MSWIN) # define DFLT_EFM "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m" # else # if defined(__QNX__) @@ -546,10 +546,6 @@ EXTERN long p_hi; /* 'history' */ #ifdef FEAT_RIGHTLEFT EXTERN int p_hkmap; /* 'hkmap' */ EXTERN int p_hkmapp; /* 'hkmapp' */ -# ifdef FEAT_FKMAP -EXTERN int p_fkmap; /* 'fkmap' */ -EXTERN int p_altkeymap; /* 'altkeymap' */ -# endif # ifdef FEAT_ARABIC EXTERN int p_arshape; /* 'arabicshape' */ # endif @@ -694,7 +690,7 @@ EXTERN long p_report; /* 'report' */ #if defined(FEAT_QUICKFIX) EXTERN long p_pvh; /* 'previewheight' */ #endif -#ifdef WIN3264 +#ifdef MSWIN EXTERN int p_rs; /* 'restorescreen' */ #endif #ifdef FEAT_RIGHTLEFT @@ -827,7 +823,7 @@ EXTERN char_u *p_tenc; /* 'termencoding' */ #ifdef FEAT_TERMGUICOLORS EXTERN int p_tgc; /* 'termguicolors' */ #endif -#if defined(WIN3264) && defined(FEAT_TERMINAL) +#if defined(MSWIN) && defined(FEAT_TERMINAL) EXTERN char_u *p_twt; // 'termwintype' #endif EXTERN int p_terse; /* 'terse' */ @@ -848,7 +844,7 @@ EXTERN int p_ttimeout; /* 'ttimeout' */ EXTERN long p_ttm; /* 'ttimeoutlen' */ EXTERN int p_tbi; /* 'ttybuiltin' */ EXTERN int p_tf; /* 'ttyfast' */ -#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) +#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) EXTERN char_u *p_toolbar; /* 'toolbar' */ EXTERN unsigned toolbar_flags; # ifdef IN_OPTION_C @@ -945,7 +941,7 @@ EXTERN long p_wh; /* 'winheight' */ EXTERN long p_wmh; /* 'winminheight' */ EXTERN long p_wmw; /* 'winminwidth' */ EXTERN long p_wiw; /* 'winwidth' */ -#if defined(WIN3264) && defined(FEAT_TERMINAL) +#if defined(MSWIN) && defined(FEAT_TERMINAL) EXTERN char_u *p_winptydll; /* 'winptydll' */ #endif EXTERN int p_ws; /* 'wrapscan' */ diff --git a/src/os_mswin.c b/src/os_mswin.c index 9da72b0a4d..27a2cc6ace 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -32,7 +32,7 @@ #endif #ifndef PROTO -# if defined(FEAT_TITLE) && !defined(FEAT_GUI_W32) +# if defined(FEAT_TITLE) && !defined(FEAT_GUI_MSWIN) # include # endif @@ -3091,7 +3091,7 @@ get_logfont( } if (STRCMP(name, "*") == 0) { -#if defined(FEAT_GUI_W32) +#if defined(FEAT_GUI_MSWIN) CHOOSEFONT cf; /* if name is "*", bring up std font dialog: */ vim_memset(&cf, 0, sizeof(cf)); diff --git a/src/os_unix.c b/src/os_unix.c index 425498c6bc..001f085751 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -49,7 +49,7 @@ static int selinux_enabled = -1; #endif #ifdef __CYGWIN__ -# ifndef WIN32 +# ifndef MSWIN # include # include /* for cygwin_conv_to_posix_path() and/or * for cygwin_conv_path() */ diff --git a/src/os_w32exe.c b/src/os_w32exe.c index f96bff4c8e..197d65da4c 100644 --- a/src/os_w32exe.c +++ b/src/os_w32exe.c @@ -22,7 +22,7 @@ /* cproto doesn't create a prototype for main() */ int _cdecl -#if defined(FEAT_GUI_W32) +#if defined(FEAT_GUI_MSWIN) VimMain #else main @@ -104,7 +104,7 @@ WinMain( pSaveInst = SaveInst; # endif pmain = -# if defined(FEAT_GUI_W32) +# if defined(FEAT_GUI_MSWIN) //&& defined(__MINGW32__) VimMain # else diff --git a/src/os_win32.c b/src/os_win32.c index a392d13b27..b9233156ea 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -10,7 +10,7 @@ * os_win32.c * * Used for both the console version and the Win32 GUI. A lot of code is for - * the console version only, so there is a lot of "#ifndef FEAT_GUI_W32". + * the console version only, so there is a lot of "#ifndef FEAT_GUI_MSWIN". * * Win32 (Windows NT and Windows 95) system-dependent routines. * Portions lifted from the Win32 SDK samples, the MSDOS-dependent code, @@ -45,7 +45,7 @@ #endif #ifndef PROTO -# if defined(FEAT_TITLE) && !defined(FEAT_GUI_W32) +# if defined(FEAT_TITLE) && !defined(FEAT_GUI_MSWIN) # include # endif #endif @@ -151,7 +151,7 @@ typedef int LPSECURITY_ATTRIBUTES; # define wcsicmp(a, b) wcscmpi((a), (b)) #endif -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN /* Win32 Console handles for input and output */ static HANDLE g_hConIn = INVALID_HANDLE_VALUE; static HANDLE g_hConOut = INVALID_HANDLE_VALUE; @@ -193,7 +193,7 @@ static int conpty_working = 0; static int conpty_stable = 0; static void vtp_flag_init(); -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN static int vtp_working = 0; static void vtp_init(); static void vtp_exit(); @@ -227,7 +227,7 @@ static void reset_console_color_rgb(void); # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 #endif -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN static int suppress_winsize = 1; /* don't fiddle with console */ #endif @@ -235,7 +235,7 @@ static char_u *exe_path = NULL; static BOOL win8_or_later = FALSE; -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN /* Dynamic loading for portability */ typedef struct _DYN_CONSOLE_SCREEN_BUFFER_INFOEX { @@ -284,7 +284,7 @@ get_build_number(void) return ver; } -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN /* * Version of ReadConsoleInput() that works with IME. * Works around problems on Windows 8. @@ -830,7 +830,7 @@ PlatformId(void) } } -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN #define SHIFT (SHIFT_PRESSED) #define CTRL (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED) @@ -1122,7 +1122,7 @@ decode_key_event( # pragma optimize("", on) #endif -#endif /* FEAT_GUI_W32 */ +#endif /* FEAT_GUI_MSWIN */ #ifdef FEAT_MOUSE @@ -1130,7 +1130,7 @@ decode_key_event( /* * For the GUI the mouse handling is in gui_w32.c. */ -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN void mch_setmouse(int on UNUSED) { @@ -1441,7 +1441,7 @@ decode_mouse_event( return TRUE; } -# endif /* FEAT_GUI_W32 */ +# endif /* FEAT_GUI_MSWIN */ #endif /* FEAT_MOUSE */ @@ -1481,7 +1481,7 @@ mch_update_cursor(void) } #endif -#ifndef FEAT_GUI_W32 /* this isn't used for the GUI */ +#ifndef FEAT_GUI_MSWIN /* this isn't used for the GUI */ /* * Handle FOCUS_EVENT. */ @@ -1775,7 +1775,7 @@ tgetch(int *pmodifiers, WCHAR *pch2) #endif } } -#endif /* !FEAT_GUI_W32 */ +#endif /* !FEAT_GUI_MSWIN */ /* @@ -1793,7 +1793,7 @@ mch_inchar( long time UNUSED, int tb_change_cnt UNUSED) { -#ifndef FEAT_GUI_W32 /* this isn't used for the GUI */ +#ifndef FEAT_GUI_MSWIN /* this isn't used for the GUI */ int len; int c; @@ -2006,9 +2006,9 @@ theend: } return len; -#else /* FEAT_GUI_W32 */ +#else /* FEAT_GUI_MSWIN */ return 0; -#endif /* FEAT_GUI_W32 */ +#endif /* FEAT_GUI_MSWIN */ } #ifndef PROTO @@ -2123,7 +2123,7 @@ bad_param_handler(const wchar_t *expression, # define SET_INVALID_PARAM_HANDLER #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN /* * GUI version of mch_init(). @@ -2196,7 +2196,7 @@ mch_init(void) } -#else /* FEAT_GUI_W32 */ +#else /* FEAT_GUI_MSWIN */ #define SRWIDTH(sr) ((sr).Right - (sr).Left + 1) #define SRHEIGHT(sr) ((sr).Bottom - (sr).Top + 1) @@ -2751,7 +2751,7 @@ mch_exit(int r) exit(r); } -#endif /* !FEAT_GUI_W32 */ +#endif /* !FEAT_GUI_MSWIN */ /* * Do we have an interactive window? @@ -2763,7 +2763,7 @@ mch_check_win( { get_exe_name(); -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN return OK; /* GUI always has a tty */ #else if (isatty(1)) @@ -3852,7 +3852,7 @@ mch_free_acl(vim_acl_T acl) #endif } -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN /* * handler for ctrl-break, ctrl-c interrupts, and fatal events. @@ -4168,7 +4168,7 @@ mch_set_winsize_now(void) } suppress_winsize = 0; } -#endif /* FEAT_GUI_W32 */ +#endif /* FEAT_GUI_MSWIN */ static BOOL vim_create_process( @@ -4249,7 +4249,7 @@ vim_shell_execute( } -#if defined(FEAT_GUI_W32) || defined(PROTO) +#if defined(FEAT_GUI_MSWIN) || defined(PROTO) /* * Specialised version of system() for Win32 GUI mode. @@ -5124,7 +5124,7 @@ mch_call_shell( else { x = -1; -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN emsg(_("E371: Command not found")); #endif } @@ -5144,7 +5144,7 @@ mch_call_shell( else { cmdlen = ( -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN (!p_stmp ? 0 : STRLEN(vimrun_path)) + #endif STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10); @@ -5152,7 +5152,7 @@ mch_call_shell( newcmd = lalloc(cmdlen, TRUE); if (newcmd != NULL) { -#if defined(FEAT_GUI_W32) +#if defined(FEAT_GUI_MSWIN) if (need_vimrun_warning) { char *msg = _("VIMRUN.EXE not found in your $PATH.\n" @@ -5196,7 +5196,7 @@ mch_call_shell( /* Print the return value, unless "vimrun" was used. */ if (x != 0 && !(options & SHELL_SILENT) && !emsg_silent -#if defined(FEAT_GUI_W32) +#if defined(FEAT_GUI_MSWIN) && ((options & SHELL_DOOUT) || s_dont_use_vimrun || !p_stmp) #endif ) @@ -5736,7 +5736,7 @@ mch_clear_job(job_T *job) #endif -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN /* * Start termcap mode @@ -5852,10 +5852,10 @@ termcap_mode_end(void) g_fTermcapMode = FALSE; } -#endif /* FEAT_GUI_W32 */ +#endif /* FEAT_GUI_MSWIN */ -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN void mch_write( char_u *s UNUSED, @@ -6692,7 +6692,7 @@ mch_write( #endif } -#endif /* FEAT_GUI_W32 */ +#endif /* FEAT_GUI_MSWIN */ /* @@ -6703,7 +6703,7 @@ mch_delay( long msec, int ignoreinput UNUSED) { -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN Sleep((int)msec); /* never wait for input */ #else /* Console */ if (ignoreinput) @@ -6771,7 +6771,7 @@ mch_remove(char_u *name) void mch_breakcheck(int force) { -#ifndef FEAT_GUI_W32 /* never used */ +#ifndef FEAT_GUI_MSWIN /* never used */ if (g_fCtrlCPressed || g_fCBrkPressed) { ctrl_break_was_pressed = g_fCBrkPressed; @@ -7696,7 +7696,7 @@ mch_setenv(char *var, char *value, int x) vtp_flag_init(void) { DWORD ver = get_build_number(); -#ifndef FEAT_GUI_W32 +#ifndef FEAT_GUI_MSWIN DWORD mode; HANDLE out; @@ -7716,7 +7716,7 @@ vtp_flag_init(void) } -#if !defined(FEAT_GUI_W32) || defined(PROTO) +#if !defined(FEAT_GUI_MSWIN) || defined(PROTO) static void vtp_init(void) @@ -7941,7 +7941,7 @@ is_conpty_stable(void) return conpty_stable; } -#if !defined(FEAT_GUI_W32) || defined(PROTO) +#if !defined(FEAT_GUI_MSWIN) || defined(PROTO) void resize_console_buf(void) { diff --git a/src/os_win32.h b/src/os_win32.h index 6c4a349f98..6ebe0373e7 100644 --- a/src/os_win32.h +++ b/src/os_win32.h @@ -70,7 +70,7 @@ #if defined(__DATE__) && defined(__TIME__) # define HAVE_DATE_TIME #endif -#ifndef FEAT_GUI_W32 /* GUI works different */ +#ifndef FEAT_GUI_MSWIN /* GUI works different */ # define BREAKCHECK_SKIP 1 /* call mch_breakcheck() each time, it's fast */ #endif @@ -78,7 +78,7 @@ #define HAVE_PUTENV /* at least Bcc 5.2 and MSC have it */ -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN # define NO_CONSOLE /* don't included console-only code */ #endif diff --git a/src/proto.h b/src/proto.h index c19d155169..43192ffd52 100644 --- a/src/proto.h +++ b/src/proto.h @@ -38,7 +38,7 @@ # if defined(UNIX) || defined(VMS) # include "os_unix.pro" # endif -# ifdef WIN3264 +# ifdef MSWIN # include "os_win32.pro" # include "os_mswin.pro" # include "winclip.pro" @@ -266,7 +266,7 @@ extern int putenv(const char *string); /* in misc2.c */ extern char_u *vimpty_getenv(const char_u *string); /* in misc2.c */ # endif # endif -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN # include "gui_w32.pro" # endif # ifdef FEAT_GUI_GTK diff --git a/src/screen.c b/src/screen.c index d06cc3fcb7..4973b510de 100644 --- a/src/screen.c +++ b/src/screen.c @@ -7974,7 +7974,7 @@ screen_start_highlight(int attr) screen_attr = attr; if (full_screen -#ifdef WIN3264 +#ifdef MSWIN && termcap_active #endif ) @@ -8081,7 +8081,7 @@ screen_stop_highlight(void) int do_ME = FALSE; /* output T_ME code */ if (screen_attr != 0 -#ifdef WIN3264 +#ifdef MSWIN && termcap_active #endif ) diff --git a/src/search.c b/src/search.c index 9a47ed4608..20f6299eea 100644 --- a/src/search.c +++ b/src/search.c @@ -1246,7 +1246,7 @@ do_search( } if (options & SEARCH_REV) { -#ifdef WIN32 +#ifdef MSWIN /* There is a bug in the Visual C++ 2.2 compiler which means that * dirc always ends up being '/' */ dirc = (dirc == '/') ? '?' : '/'; diff --git a/src/structs.h b/src/structs.h index fdef811e47..ab84eaeaa1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1073,7 +1073,7 @@ typedef struct { int vc_type; /* zero or one of the CONV_ values */ int vc_factor; /* max. expansion factor */ -# ifdef WIN3264 +# ifdef MSWIN int vc_cpfrom; /* codepage to convert from (CONV_CODEPAGE) */ int vc_cpto; /* codepage to convert to (CONV_CODEPAGE) */ # endif @@ -1101,7 +1101,7 @@ typedef struct #define CONV_TO_LATIN1 3 #define CONV_TO_LATIN9 4 #define CONV_ICONV 5 -#ifdef WIN3264 +#ifdef MSWIN # define CONV_CODEPAGE 10 /* codepage -> codepage */ #endif #ifdef MACOS_X @@ -1187,7 +1187,7 @@ typedef long_u hash_T; /* Type for hi_hash */ #ifdef FEAT_NUM64 /* Use 64-bit Number. */ -# ifdef WIN3264 +# ifdef MSWIN # ifdef PROTO typedef long varnumber_T; typedef unsigned long uvarnumber_T; @@ -1543,7 +1543,7 @@ struct jobvar_S #ifdef UNIX pid_t jv_pid; #endif -#ifdef WIN32 +#ifdef MSWIN PROCESS_INFORMATION jv_proc_info; HANDLE jv_job_object; #endif @@ -1554,7 +1554,7 @@ struct jobvar_S #ifdef UNIX char_u *jv_termsig; /* allocated */ #endif -#ifdef WIN3264 +#ifdef MSWIN char_u *jv_tty_type; // allocated #endif int jv_exitval; @@ -1670,7 +1670,7 @@ typedef struct { * message when the deadline was set. If it gets longer (something was * received) the deadline is reset. */ size_t ch_wait_len; -#ifdef WIN32 +#ifdef MSWIN DWORD ch_deadline; #else struct timeval ch_deadline; @@ -1720,7 +1720,7 @@ struct channel_S { /* callback for Netbeans when channel is * closed */ -#ifdef WIN32 +#ifdef MSWIN int ch_named_pipe; /* using named pipe instead of pty */ #endif char_u *ch_callback; /* call when any msg is not handled */ @@ -3225,7 +3225,7 @@ struct VimMenu #ifdef FEAT_BEVAL_TIP BalloonEval *tip; /* tooltip for this menu item */ #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN UINT id; /* Id of menu item */ HMENU submenu_id; /* If this is submenu, add children here */ HWND tearoff_handle; /* hWnd of tearoff if created */ diff --git a/src/syntax.c b/src/syntax.c index 16c75f27d1..df351a31a4 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -8274,7 +8274,7 @@ free_highlight(void) void restore_cterm_colors(void) { -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) /* Since t_me has been set, this probably means that the user * wants to use this as default colors. Need to reset default * background/foreground colors. */ @@ -9559,7 +9559,7 @@ set_hl_attr( at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; # ifdef FEAT_TERMGUICOLORS -# ifdef WIN3264 +# ifdef MSWIN { int id; guicolor_T fg, bg; @@ -9822,8 +9822,8 @@ syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp) } #endif -#if (defined(WIN3264) \ - && !defined(FEAT_GUI_W32) \ +#if (defined(MSWIN) \ + && !defined(FEAT_GUI_MSWIN) \ && defined(FEAT_TERMGUICOLORS)) || defined(PROTO) void syn_id2cterm_bg(int hl_id, int *fgp, int *bgp) diff --git a/src/term.c b/src/term.c index 9eebd28cb1..8ee9264da4 100644 --- a/src/term.c +++ b/src/term.c @@ -533,7 +533,7 @@ static struct builtin_term builtin_termcaps[] = {K_PAGEUP, "\316I"}, # endif -# if defined(WIN3264) || defined(ALL_BUILTIN_TCAPS) +# if defined(MSWIN) || defined(ALL_BUILTIN_TCAPS) /* * These codes are valid for the Win32 Console . The entries that start with * ESC | are translated into console calls in os_win32.c. The function keys @@ -2036,7 +2036,7 @@ set_termname(char_u *term) /* termcap failed to report size */ /* set defaults, in case ui_get_shellsize() also fails */ width = 80; -#if defined(WIN3264) +#if defined(MSWIN) height = 25; /* console is often 25 lines */ #else height = 24; /* most terminals are 24 lines */ @@ -4082,7 +4082,7 @@ add_termcode(char_u *name, char_u *string, int flags) return; } -#if defined(WIN3264) && !defined(FEAT_GUI) +#if defined(MSWIN) && !defined(FEAT_GUI) s = vim_strnsave(string, (int)STRLEN(string) + 1); #else s = vim_strsave(string); @@ -4097,7 +4097,7 @@ add_termcode(char_u *name, char_u *string, int flags) s[0] = term_7to8bit(string); } -#if defined(WIN3264) && !defined(FEAT_GUI) +#if defined(MSWIN) && !defined(FEAT_GUI) if (s[0] == K_NUL) { STRMOVE(s + 1, s); @@ -6721,7 +6721,7 @@ translate_mapping( } #endif -#if (defined(WIN3264) && !defined(FEAT_GUI)) || defined(PROTO) +#if (defined(MSWIN) && !defined(FEAT_GUI)) || defined(PROTO) static char ksme_str[20]; static char ksmr_str[20]; static char ksmd_str[20]; @@ -6917,7 +6917,7 @@ gui_get_color_cmn(char_u *name) /* On MS-Windows an RGB macro is available and it produces 0x00bbggrr color * values as used by the MS-Windows GDI api. It should be used only for * MS-Windows GDI builds. */ -# if defined(RGB) && defined(WIN32) && !defined(FEAT_GUI) +# if defined(RGB) && defined(MSWIN) && !defined(FEAT_GUI) # undef RGB # endif # ifndef RGB @@ -7085,7 +7085,7 @@ gui_get_rgb_color_cmn(int r, int g, int b) } #endif -#if (defined(WIN3264) && !defined(FEAT_GUI_W32)) || defined(FEAT_TERMINAL) \ +#if (defined(MSWIN) && !defined(FEAT_GUI_MSWIN)) || defined(FEAT_TERMINAL) \ || defined(PROTO) static int cube_value[] = { 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF @@ -7162,3 +7162,4 @@ cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) } } #endif + diff --git a/src/terminal.c b/src/terminal.c index 899d3b687a..7e67314f96 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -66,7 +66,7 @@ typedef struct sb_line_S { char_u *sb_text; // for tl_scrollback_postponed } sb_line_T; -#ifdef WIN3264 +#ifdef MSWIN # ifndef HPCON # define HPCON VOID* # endif @@ -112,7 +112,7 @@ struct terminal_S { char_u *tl_arg0_cmd; // To format the status bar -#ifdef WIN3264 +#ifdef MSWIN void *tl_winpty_config; void *tl_winpty; @@ -172,7 +172,7 @@ static term_T *first_term = NULL; /* Terminal active in terminal_loop(). */ static term_T *in_terminal_loop = NULL; -#ifdef WIN3264 +#ifdef MSWIN static BOOL has_winpty = FALSE; static BOOL has_conpty = FALSE; #endif @@ -324,7 +324,7 @@ init_job_options(jobopt_T *opt) static void setup_job_options(jobopt_T *opt, int rows, int cols) { -#ifndef WIN3264 +#ifndef MSWIN /* Win32: Redirecting the job output won't work, thus always connect stdout * here. */ if (!(opt->jo_set & JO_OUT_IO)) @@ -337,7 +337,7 @@ setup_job_options(jobopt_T *opt, int rows, int cols) opt->jo_set |= JO_OUT_IO + JO_OUT_BUF + JO_OUT_MODIFIABLE; } -#ifndef WIN3264 +#ifndef MSWIN /* Win32: Redirecting the job output won't work, thus always connect stderr * here. */ if (!(opt->jo_set & JO_ERR_IO)) @@ -570,7 +570,7 @@ term_start( curbuf->b_p_ma = FALSE; set_term_and_win_size(term); -#ifdef WIN3264 +#ifdef MSWIN mch_memmove(orig_opt.jo_io, opt->jo_io, sizeof(orig_opt.jo_io)); #endif setup_job_options(opt, term->tl_rows, term->tl_cols); @@ -748,7 +748,7 @@ ex_terminal(exarg_T *eap) vim_free(buf); *p = ' '; } -#ifdef WIN3264 +#ifdef MSWIN else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "type", 4) == 0 && ep != NULL) { @@ -824,7 +824,7 @@ term_write_session(FILE *fd, win_T *wp) if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ", term->tl_cols, term->tl_rows) < 0) return FAIL; -#ifdef WIN3264 +#ifdef MSWIN if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0) return FAIL; #endif @@ -932,7 +932,7 @@ free_unused_terminals() vim_free(term->tl_opencmd); vim_free(term->tl_eof_chars); vim_free(term->tl_arg0_cmd); -#ifdef WIN3264 +#ifdef MSWIN if (term->tl_out_fd != NULL) fclose(term->tl_out_fd); #endif @@ -1027,7 +1027,7 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel) size_t len = STRLEN(msg); term_T *term = buffer->b_term; -#ifdef WIN3264 +#ifdef MSWIN /* Win32: Cannot redirect output of the job, intercept it here and write to * the file. */ if (term->tl_out_fd != NULL) @@ -1471,7 +1471,7 @@ add_scrollback_line_to_buffer(term_T *term, char_u *text, int len) int empty = (buf->b_ml.ml_flags & ML_EMPTY); linenr_T lnum = buf->b_ml.ml_line_count; -#ifdef WIN3264 +#ifdef MSWIN if (!enc_utf8 && enc_codepage > 0) { WCHAR *ret = NULL; @@ -1875,7 +1875,7 @@ term_vgetc() State = TERMINAL; got_int = FALSE; -#ifdef WIN3264 +#ifdef MSWIN ctrl_break_was_pressed = FALSE; #endif c = vgetc(); @@ -2016,7 +2016,7 @@ term_paste_register(int prev_c UNUSED) for (item = l->lv_first; item != NULL; item = item->li_next) { char_u *s = tv_get_string(&item->li_tv); -#ifdef WIN3264 +#ifdef MSWIN char_u *tmp = s; if (!enc_utf8 && enc_codepage > 0) @@ -2036,7 +2036,7 @@ term_paste_register(int prev_c UNUSED) #endif channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN, s, (int)STRLEN(s), NULL); -#ifdef WIN3264 +#ifdef MSWIN if (tmp != s) vim_free(s); #endif @@ -2293,7 +2293,7 @@ terminal_loop(int blocking) } #endif -#ifdef WIN3264 +#ifdef MSWIN /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT. * Use CTRL-BREAK to kill the job. */ if (ctrl_break_was_pressed) @@ -2370,7 +2370,7 @@ terminal_loop(int blocking) goto theend; } } -# ifdef WIN3264 +# ifdef MSWIN if (!enc_utf8 && has_mbyte && c >= 0x80) { WCHAR wc; @@ -2719,7 +2719,7 @@ handle_settermprop( // Empty corrupted data of winpty else if (STRNCMP(" - ", (char_u *)value->string, 4) == 0) term->tl_title = NULL; -#ifdef WIN3264 +#ifdef MSWIN else if (!enc_utf8 && enc_codepage > 0) { WCHAR *ret = NULL; @@ -3072,7 +3072,7 @@ term_channel_closed(channel_T *ch) VIM_CLEAR(term->tl_title); VIM_CLEAR(term->tl_status_text); -#ifdef WIN3264 +#ifdef MSWIN if (term->tl_out_fd != NULL) { fclose(term->tl_out_fd); @@ -3184,7 +3184,7 @@ term_line2screenline(VTermScreen *screen, VTermPos *pos, int max_col) ScreenLinesUC[off] = NUL; } } -#ifdef WIN3264 +#ifdef MSWIN else if (has_mbyte && c >= 0x80) { char_u mb[MB_MAXBYTES+1]; @@ -3557,7 +3557,7 @@ init_default_colors(term_T *term) } else { -#if defined(WIN3264) && !defined(FEAT_GUI_W32) +#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) int tmp; #endif @@ -3565,7 +3565,7 @@ init_default_colors(term_T *term) if (cterm_normal_fg_color > 0) { cterm_color2vterm(cterm_normal_fg_color - 1, fg); -# if defined(WIN3264) && !defined(FEAT_GUI_W32) +# if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) tmp = fg->red; fg->red = fg->blue; fg->blue = tmp; @@ -3579,7 +3579,7 @@ init_default_colors(term_T *term) if (cterm_normal_bg_color > 0) { cterm_color2vterm(cterm_normal_bg_color - 1, bg); -# if defined(WIN3264) && !defined(FEAT_GUI_W32) +# if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) tmp = bg->red; bg->red = bg->blue; bg->blue = tmp; @@ -3922,7 +3922,7 @@ create_vterm(term_T *term, int rows, int cols) /* For unix do not use a blinking cursor. In an xterm this causes the * cursor to blink if it's blinking in the xterm. * For Windows we respect the system wide setting. */ -#ifdef WIN3264 +#ifdef MSWIN if (GetCaretBlinkTime() == INFINITE) value.boolean = 0; else @@ -5588,7 +5588,7 @@ term_send_eof(channel_T *ch) (int)STRLEN(term->tl_eof_chars), NULL); channel_send(ch, PART_IN, (char_u *)"\r", 1, NULL); } -# ifdef WIN3264 +# ifdef MSWIN else /* Default: CTRL-D */ channel_send(ch, PART_IN, (char_u *)"\004\r", 2, NULL); @@ -5604,7 +5604,7 @@ term_getjob(term_T *term) } #endif -# if defined(WIN3264) || defined(PROTO) +# if defined(MSWIN) || defined(PROTO) /************************************** * 2. MS-Windows implementation. diff --git a/src/ui.c b/src/ui.c index 0823d2dd23..e21e8013fd 100644 --- a/src/ui.c +++ b/src/ui.c @@ -40,7 +40,7 @@ ui_write(char_u *s, int len) /* Don't output anything in silent mode ("ex -s") unless 'verbose' set */ if (!(silent_mode && p_verbose == 0)) { -#if !defined(WIN3264) +#if !defined(MSWIN) char_u *tofree = NULL; if (output_conv.vc_type != CONV_NONE) @@ -54,7 +54,7 @@ ui_write(char_u *s, int len) mch_write(s, len); -# if !defined(WIN3264) +# if !defined(MSWIN) if (output_conv.vc_type != CONV_NONE) vim_free(tofree); # endif @@ -62,7 +62,7 @@ ui_write(char_u *s, int len) #endif } -#if defined(UNIX) || defined(VMS) || defined(PROTO) || defined(WIN3264) +#if defined(UNIX) || defined(VMS) || defined(PROTO) || defined(MSWIN) /* * When executing an external program, there may be some typed characters that * are not consumed by it. Give them back to ui_inchar() and they are stored @@ -3435,7 +3435,7 @@ vcol2col(win_T *wp, linenr_T lnum, int vcol) #endif /* FEAT_MOUSE */ -#if defined(FEAT_GUI) || defined(WIN3264) || defined(PROTO) +#if defined(FEAT_GUI) || defined(MSWIN) || defined(PROTO) /* * Called when focus changed. Used for the GUI or for systems where this can * be done in the console (Win32). diff --git a/src/undo.c b/src/undo.c index 6b6dd479b0..b2d1d9f115 100644 --- a/src/undo.c +++ b/src/undo.c @@ -645,7 +645,7 @@ u_savecommon( u_getbot(); } -#if !defined(UNIX) && !defined(WIN32) +#if !defined(UNIX) && !defined(MSWIN) /* * With Amiga we can't handle big undo's, because * then u_alloc_line would have to allocate a block larger than 32K @@ -1740,7 +1740,7 @@ write_error: if (!write_ok) semsg(_("E829: write error in undo file: %s"), file_name); -#if defined(WIN3264) +#if defined(MSWIN) /* Copy file attributes; for systems where this can only be done after * closing the file. */ if (buf->b_ffname != NULL) diff --git a/src/version.c b/src/version.c index e042578cca..5ffbc56ebb 100644 --- a/src/version.c +++ b/src/version.c @@ -222,7 +222,7 @@ static char *(features[]) = #else "-digraphs", #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN # ifdef FEAT_DIRECTX "+directx", # else @@ -481,7 +481,7 @@ static char *(features[]) = #else "-num64", #endif -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI_MSWIN # ifdef FEAT_OLE "+ole", # else @@ -700,7 +700,7 @@ static char *(features[]) = "-viminfo", #endif "+vreplace", -#ifdef WIN3264 +#ifdef MSWIN # ifdef FEAT_VTP "+vtp", # else @@ -740,7 +740,7 @@ static char *(features[]) = #else "-xim", #endif -#ifdef WIN3264 +#ifdef MSWIN # ifdef FEAT_XPM_W32 "+xpm_w32", # else @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 941, /**/ 940, /**/ @@ -2852,16 +2854,16 @@ list_version(void) */ init_longVersion(); msg(longVersion); -#ifdef WIN3264 -# ifdef FEAT_GUI_W32 +#ifdef MSWIN +# ifdef FEAT_GUI_MSWIN # ifdef _WIN64 msg_puts(_("\nMS-Windows 64-bit GUI version")); # else msg_puts(_("\nMS-Windows 32-bit GUI version")); # endif -# ifdef FEAT_OLE +# ifdef FEAT_OLE msg_puts(_(" with OLE support")); -# endif +# endif # else # ifdef _WIN64 msg_puts(_("\nMS-Windows 64-bit console version")); diff --git a/src/vim.h b/src/vim.h index be1ec1d317..3f7388e614 100644 --- a/src/vim.h +++ b/src/vim.h @@ -11,8 +11,17 @@ #include "protodef.h" -/* use fastcall for Borland, when compiling for Win32 */ -#if defined(__BORLANDC__) && defined(WIN32) && !defined(DEBUG) +// _WIN32 is defined as 1 when the compilation target is 32-bit or 64-bit. +// Note: If you want to check for 64-bit use the _WIN64 macro. +#if defined(WIN32) || defined(_WIN32) +# define MSWIN +# ifdef FEAT_GUI +# define FEAT_GUI_MSWIN +# endif +#endif + +// use fastcall for Borland, when compiling for MS-Windows +#if defined(__BORLANDC__) && defined(MSWIN) && !defined(DEBUG) #if defined(FEAT_PERL) || \ defined(FEAT_PYTHON) || \ defined(FEAT_PYTHON3) || \ @@ -29,7 +38,7 @@ # endif #endif -#if defined(WIN32) || defined(_WIN64) +#ifdef MSWIN # include "vimio.h" #endif @@ -103,7 +112,7 @@ || defined(FEAT_GUI_GTK) \ || defined(FEAT_GUI_ATHENA) \ || defined(FEAT_GUI_MAC) \ - || defined(FEAT_GUI_W32) \ + || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_PHOTON) # define FEAT_GUI_ENABLED /* also defined with NO_X11_INCLUDES */ # if !defined(FEAT_GUI) && !defined(NO_X11_INCLUDES) @@ -124,22 +133,11 @@ # define _CRT_NONSTDC_NO_DEPRECATE #endif -#if defined(FEAT_GUI_W32) -# define FEAT_GUI_MSWIN -#endif -#if defined(WIN32) || defined(_WIN64) -# define MSWIN -#endif -/* Practically everything is common to both Win32 and Win64 */ -#if defined(WIN32) || defined(_WIN64) -# define WIN3264 -#endif - /* * VIM_SIZEOF_INT is used in feature.h, and the system-specific included files * need items from feature.h. Therefore define VIM_SIZEOF_INT here. */ -#ifdef WIN3264 +#ifdef MSWIN # define VIM_SIZEOF_INT 4 #endif @@ -276,7 +274,7 @@ # include "os_amiga.h" #endif -#ifdef WIN3264 +#ifdef MSWIN # include "os_win32.h" #endif @@ -456,8 +454,7 @@ typedef unsigned int u8char_T; // int is 32 bits or more # include #endif -#if defined(HAVE_ERRNO_H) \ - || defined(WIN32) || defined(_WIN64) +#if defined(HAVE_ERRNO_H) || defined(MSWIN) # include #endif @@ -509,7 +506,7 @@ typedef unsigned int u8char_T; // int is 32 bits or more #ifndef HAVE_SELECT # ifdef HAVE_SYS_POLL_H # include -# elif defined(WIN32) +# elif defined(MSWIN) # define HAVE_SELECT # else # ifdef HAVE_POLL_H @@ -1752,7 +1749,7 @@ void *vim_memset(void *, int, size_t); #define MB_MAXBYTES 21 #if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO) -# ifdef WIN3264 +# ifdef MSWIN typedef LARGE_INTEGER proftime_T; # else typedef struct timeval proftime_T; @@ -1769,7 +1766,7 @@ typedef int proftime_T; /* dummy for function prototypes */ #ifdef PROTO typedef long time_T; #else -# ifdef WIN3264 +# ifdef MSWIN typedef __time64_t time_T; # else typedef time_t time_T; @@ -2005,7 +2002,7 @@ typedef int sock_T; # define SELECT_MODE_WORD 1 # define SELECT_MODE_LINE 2 -# ifdef FEAT_GUI_W32 +# ifdef FEAT_GUI_MSWIN # ifdef FEAT_OLE # define WM_OLE (WM_APP+0) # endif @@ -2103,7 +2100,7 @@ typedef enum { #endif # if defined(FEAT_EVAL) \ - && (!defined(FEAT_GUI_W32) \ + && (!defined(FEAT_GUI_MSWIN) \ || !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \ && !(defined(FEAT_GUI_MAC) && defined(MACOS_CONVERT)) /* Whether IME is supported by im_get_status() defined in mbyte.c. @@ -2115,7 +2112,7 @@ typedef enum { #if defined(FEAT_XIM) \ || defined(IME_WITHOUT_XIM) \ - || (defined(FEAT_GUI_W32) \ + || (defined(FEAT_GUI_MSWIN) \ && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \ || defined(FEAT_GUI_MAC) /* im_set_active() is available */ @@ -2129,7 +2126,7 @@ typedef enum { /* This must come after including proto.h. * For VMS this is defined in macros.h. */ -#if !defined(WIN3264) && !defined(VMS) +#if !defined(MSWIN) && !defined(VMS) # define mch_open(n, m, p) open((n), (m), (p)) # define mch_fopen(n, p) fopen((n), (p)) #endif @@ -2169,7 +2166,7 @@ typedef enum { #endif /* stop using fastcall for Borland */ -#if defined(__BORLANDC__) && defined(WIN32) && !defined(DEBUG) +#if defined(__BORLANDC__) && defined(MSWIN) && !defined(DEBUG) #pragma option -p. #endif @@ -2461,7 +2458,7 @@ typedef enum { # define MAX_OPEN_CHANNELS 0 #endif -#if defined(WIN32) +#if defined(MSWIN) # define MAX_NAMED_PIPE_SIZE 65535 #endif @@ -2579,7 +2576,7 @@ typedef enum { # define ELAPSED_FUNC(v) elapsed(&v) typedef struct timeval elapsed_T; long elapsed(struct timeval *start_tv); -#elif defined(WIN32) +#elif defined(MSWIN) # define ELAPSED_TICKCOUNT # define ELAPSED_INIT(v) v = GetTickCount() # define ELAPSED_FUNC(v) elapsed(v) diff --git a/src/vim.rc b/src/vim.rc index 492c74b60f..c3d3f5f350 100644 --- a/src/vim.rc +++ b/src/vim.rc @@ -23,7 +23,7 @@ // IDR_VIM ICON "vim.ico" -#ifdef FEAT_GUI_W32 +#ifdef FEAT_GUI IDR_VIM_ERROR ICON "vim_error.ico" IDR_VIM_ALERT ICON "vim_alert.ico" IDR_VIM_INFO ICON "vim_info.ico" @@ -46,7 +46,7 @@ IDR_TOOLBAR1 BITMAP DISCARDABLE "tools.bmp" #endif CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gvim.exe.mnf" -#endif // FEAT_GUI_W32 +#endif // FEAT_GUI // // Type Library diff --git a/src/winclip.c b/src/winclip.c index 0285dc592c..2d4d97e78b 100644 --- a/src/winclip.c +++ b/src/winclip.c @@ -22,7 +22,7 @@ * posix environment. */ #ifdef FEAT_CYGWIN_WIN32_CLIPBOARD -# define WIN3264 +# define MSWIN # define WIN32_LEAN_AND_MEAN # include # include "winclip.pro" @@ -299,7 +299,7 @@ clip_mch_request_selection(VimClipboard *cbd) VimClipType_t metadata = { -1, -1, -1, -1 }; HGLOBAL hMem = NULL; char_u *str = NULL; -#if defined(WIN3264) +#if defined(MSWIN) char_u *to_free = NULL; #endif HGLOBAL rawh = NULL; @@ -361,7 +361,7 @@ clip_mch_request_selection(VimClipboard *cbd) } if (str == NULL) { -#if defined(WIN3264) +#if defined(MSWIN) /* Try to get the clipboard in Unicode if it's not an empty string. */ if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0) { @@ -417,7 +417,7 @@ clip_mch_request_selection(VimClipboard *cbd) break; } -#if defined(WIN3264) +#if defined(MSWIN) /* The text is in the active codepage. Convert to * 'encoding', going through UTF-16. */ acp_to_enc(str, str_size, &to_free, &maxlen); @@ -454,7 +454,7 @@ clip_mch_request_selection(VimClipboard *cbd) if (rawh != NULL) GlobalUnlock(rawh); CloseClipboard(); -#if defined(WIN3264) +#if defined(MSWIN) vim_free(to_free); #endif } @@ -471,7 +471,7 @@ clip_mch_set_selection(VimClipboard *cbd) HGLOBAL hMemRaw = NULL; HGLOBAL hMem = NULL; HGLOBAL hMemVim = NULL; -# if defined(WIN3264) +# if defined(MSWIN) HGLOBAL hMemW = NULL; # endif @@ -508,7 +508,7 @@ clip_mch_set_selection(VimClipboard *cbd) metadata.rawlen = 0; } -# if defined(WIN3264) +# if defined(MSWIN) { WCHAR *out; int len = metadata.txtlen; @@ -590,7 +590,7 @@ clip_mch_set_selection(VimClipboard *cbd) { SetClipboardData(cbd->format, hMemVim); hMemVim = 0; -# if defined(WIN3264) +# if defined(MSWIN) if (hMemW != NULL) { if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL) @@ -611,7 +611,7 @@ clip_mch_set_selection(VimClipboard *cbd) GlobalFree(hMemRaw); if (hMem) GlobalFree(hMem); -# if defined(WIN3264) +# if defined(MSWIN) if (hMemW) GlobalFree(hMemW); # endif @@ -746,7 +746,7 @@ utf16_to_enc(short_u *str, int *lenp) return enc_str; } -#if defined(WIN3264) || defined(PROTO) +#if defined(MSWIN) || defined(PROTO) /* * Convert from the active codepage to 'encoding'. * Input is "str[str_size]". From 76cbe811dafea0609e87ee4b9d025e2387e20fac Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 17:53:49 +0100 Subject: [PATCH 70/75] patch 8.1.0942: options window still checks for the multi_byte feature Problem: Options window still checks for the multi_byte feature. Solution: Remove the unnecessary check. (Dominique Pelle, closes #3990) --- runtime/optwin.vim | 68 +++++++++++++++++++++------------------------- src/version.c | 2 ++ 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/runtime/optwin.vim b/runtime/optwin.vim index d929836e74..a2ef90cc80 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -685,12 +685,10 @@ if has("printer") call append("$", "printencoding\tencoding used to print the PostScript file for :hardcopy") call OptionG("penc", &penc) endif - if has("multi_byte") - call append("$", "printmbcharset\tthe CJK character set to be used for CJK output from :hardcopy") - call OptionG("pmbcs", &pmbcs) - call append("$", "printmbfont\tlist of font names to be used for CJK output from :hardcopy") - call OptionG("pmbfn", &pmbfn) - endif + call append("$", "printmbcharset\tthe CJK character set to be used for CJK output from :hardcopy") + call OptionG("pmbcs", &pmbcs) + call append("$", "printmbfont\tlist of font names to be used for CJK output from :hardcopy") + call OptionG("pmbfn", &pmbfn) endif call Header("messages and info") @@ -996,11 +994,9 @@ call BinOptionL("eol") call append("$", "fixendofline\tfixes missing end-of-line at end of text file") call append("$", "\t(local to buffer)") call BinOptionL("fixeol") -if has("multi_byte") - call append("$", "bomb\tprepend a Byte Order Mark to the file") - call append("$", "\t(local to buffer)") - call BinOptionL("bomb") -endif +call append("$", "bomb\tprepend a Byte Order Mark to the file") +call append("$", "\t(local to buffer)") +call BinOptionL("bomb") call append("$", "fileformat\tend-of-line format: \"dos\", \"unix\" or \"mac\"") call append("$", "\t(local to buffer)") call OptionL("ff") @@ -1252,33 +1248,31 @@ if has("xim") endif -if has("multi_byte") - call Header("multi-byte characters") - call append("$", "encoding\tcharacter encoding used in Vim: \"latin1\", \"utf-8\"") - call append("$", "\t\"euc-jp\", \"big5\", etc.") - call OptionG("enc", &enc) - call append("$", "fileencoding\tcharacter encoding for the current file") - call append("$", "\t(local to buffer)") - call OptionL("fenc") - call append("$", "fileencodings\tautomatically detected character encodings") - call OptionG("fencs", &fencs) - call append("$", "termencoding\tcharacter encoding used by the terminal") - call OptionG("tenc", &tenc) - call append("$", "charconvert\texpression used for character encoding conversion") - call OptionG("ccv", &ccv) - call append("$", "delcombine\tdelete combining (composing) characters on their own") - call BinOptionG("deco", &deco) - call append("$", "maxcombine\tmaximum number of combining (composing) characters displayed") - call OptionG("mco", &mco) - if has("xim") && has("gui_gtk") - call append("$", "imactivatekey\tkey that activates the X input method") - call OptionG("imak", &imak) - endif - call append("$", "ambiwidth\twidth of ambiguous width characters") - call OptionG("ambw", &ambw) - call append("$", "emoji\temoji characters are full width") - call BinOptionG("emo", &emo) +call Header("multi-byte characters") +call append("$", "encoding\tcharacter encoding used in Vim: \"latin1\", \"utf-8\"") +call append("$", "\t\"euc-jp\", \"big5\", etc.") +call OptionG("enc", &enc) +call append("$", "fileencoding\tcharacter encoding for the current file") +call append("$", "\t(local to buffer)") +call OptionL("fenc") +call append("$", "fileencodings\tautomatically detected character encodings") +call OptionG("fencs", &fencs) +call append("$", "termencoding\tcharacter encoding used by the terminal") +call OptionG("tenc", &tenc) +call append("$", "charconvert\texpression used for character encoding conversion") +call OptionG("ccv", &ccv) +call append("$", "delcombine\tdelete combining (composing) characters on their own") +call BinOptionG("deco", &deco) +call append("$", "maxcombine\tmaximum number of combining (composing) characters displayed") +call OptionG("mco", &mco) +if has("xim") && has("gui_gtk") + call append("$", "imactivatekey\tkey that activates the X input method") + call OptionG("imak", &imak) endif +call append("$", "ambiwidth\twidth of ambiguous width characters") +call OptionG("ambw", &ambw) +call append("$", "emoji\temoji characters are full width") +call BinOptionG("emo", &emo) call Header("various") diff --git a/src/version.c b/src/version.c index 5ffbc56ebb..19da7a6e33 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 942, /**/ 941, /**/ From 749f07c0db58d4f2fed2017f5a55bb053c9475ab Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 18:59:10 +0100 Subject: [PATCH 71/75] patch 8.1.0943: still a trace of Farsi support Problem: Still a trace of Farsi support. Solution: Remove defining macros. --- src/feature.h | 12 +----------- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/feature.h b/src/feature.h index 1be1833bfe..284c8e0801 100644 --- a/src/feature.h +++ b/src/feature.h @@ -265,18 +265,8 @@ /* * +farsi Farsi (Persian language) Keymap support. - * Requires FEAT_RIGHTLEFT. - * - * Disabled for EBCDIC as it requires multibyte. + * Removed in patch 8.1.0932 */ -#if defined(FEAT_BIG) && !defined(DISABLE_FARSI) && !defined(EBCDIC) -# define FEAT_FKMAP -#endif -#ifdef FEAT_FKMAP -# ifndef FEAT_RIGHTLEFT -# define FEAT_RIGHTLEFT -# endif -#endif /* * +arabic Arabic keymap and shaping support. diff --git a/src/version.c b/src/version.c index 19da7a6e33..a59e18565a 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 943, /**/ 942, /**/ From c85c8fcb9fad565da78e01248c12f662f6bc04c8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 19:12:21 +0100 Subject: [PATCH 72/75] patch 8.1.0944: format of nbdbg() arguments is not checked Problem: Format of nbdbg() arguments is not checked. Solution: Add format attribute. Fix reported problems. (Dominique Pelle, closes #3992) --- src/nbdebug.h | 6 +++++- src/netbeans.c | 10 +++++----- src/version.c | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/nbdebug.h b/src/nbdebug.h index 6331f49c3a..16dd847989 100644 --- a/src/nbdebug.h +++ b/src/nbdebug.h @@ -42,7 +42,11 @@ typedef enum { } WtWait; -void nbdbg(char *, ...); +void nbdbg(char *, ...) +#ifdef USE_PRINTF_FORMAT_ATTRIBUTE + __attribute__((format(printf, 1, 2))) +#endif +; void nbdebug_wait(u_int wait_flags, char *wait_var, u_int wait_secs); void nbdebug_log_init(char *log_var, char *level_var); diff --git a/src/netbeans.c b/src/netbeans.c index 2682d1c0b6..e49797a322 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -934,7 +934,7 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last) { mch_memmove(newtext, oldtext, first); STRMOVE(newtext + first, oldtext + lastbyte + 1); - nbdebug((" NEW LINE %d: %s\n", lnum, newtext)); + nbdebug((" NEW LINE %ld: %s\n", lnum, newtext)); ml_replace(lnum, newtext, FALSE); } } @@ -1166,7 +1166,7 @@ nb_do_cmd( return FAIL; } first = *pos; - nbdebug((" FIRST POS: line %d, col %d\n", + nbdebug((" FIRST POS: line %ld, col %d\n", first.lnum, first.col)); pos = off2pos(buf->bufp, off+count-1); if (!pos) @@ -1178,7 +1178,7 @@ nb_do_cmd( return FAIL; } last = *pos; - nbdebug((" LAST POS: line %d, col %d\n", + nbdebug((" LAST POS: line %ld, col %d\n", last.lnum, last.col)); del_from_lnum = first.lnum; del_to_lnum = last.lnum; @@ -1264,7 +1264,7 @@ nb_do_cmd( } } - nbdebug((" Deleting lines %d through %d\n", + nbdebug((" Deleting lines %ld through %ld\n", del_from_lnum, del_to_lnum)); curwin->w_cursor.lnum = del_from_lnum; curwin->w_cursor.col = 0; @@ -1540,7 +1540,7 @@ nb_do_cmd( { if (!buf->bufp->b_netbeans_file) { - nbdebug(("E658: NetBeans connection lost for buffer %ld\n", buf->bufp->b_fnum)); + nbdebug(("E658: NetBeans connection lost for buffer %d\n", buf->bufp->b_fnum)); semsg(_("E658: NetBeans connection lost for buffer %d"), buf->bufp->b_fnum); } diff --git a/src/version.c b/src/version.c index a59e18565a..b3244c168b 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 944, /**/ 943, /**/ From a5483448cba6997517003a22a8029f0de1007d0e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 20:17:02 +0100 Subject: [PATCH 73/75] patch 8.1.0945: internal error when using pattern with NL in the range Problem: Internal error when using pattern with NL in the range. Solution: Use an actual newline for the range. (closes #3989) Also fix error message. (Dominique Pelle) --- src/regexp_nfa.c | 5 +++-- src/testdir/test_regexp_latin.vim | 8 ++++++++ src/version.c | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index b83e309f7c..9633791bcf 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -245,7 +245,7 @@ static int nfa_classcodes[] = { static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely"); static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c"); -static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %ld"); +static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d"); // Variables only used in nfa_regcomp() and descendants. static int nfa_re_flags; // re_flags passed to nfa_regcomp() @@ -1785,7 +1785,8 @@ collection: MB_PTR_ADV(regparse); if (*regparse == 'n') - startc = reg_string ? NL : NFA_NEWL; + startc = (reg_string || emit_range + || regparse[1] == '-') ? NL : NFA_NEWL; else if (*regparse == 'd' || *regparse == 'o' diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index d30312a11e..d603acdbce 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -122,3 +122,11 @@ func Test_rex_init() bwipe! set re=0 endfunc + +func Test_range_with_newline() + new + call setline(1, "a") + call assert_equal(0, search("[ -*\\n- ]")) + call assert_equal(0, search("[ -*\\t-\\n]")) + bwipe! +endfunc diff --git a/src/version.c b/src/version.c index b3244c168b..0d44663a2e 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 945, /**/ 944, /**/ From 4c92e75dd4ddb68dd92a86dd02d53c70dd4af33a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 21:18:32 +0100 Subject: [PATCH 74/75] Update runtime files. --- nsis/lang/danish.nsi | 10 +- runtime/doc/change.txt | 4 +- runtime/doc/develop.txt | 26 +- runtime/doc/digraph.txt | 20 +- runtime/doc/eval.txt | 16 +- runtime/doc/filetype.txt | 9 + runtime/doc/mbyte.txt | 13 - runtime/doc/options.txt | 44 +-- runtime/doc/pattern.txt | 2 +- runtime/doc/print.txt | 7 +- runtime/doc/quickref.txt | 2 +- runtime/doc/repeat.txt | 2 - runtime/doc/russian.txt | 3 +- runtime/doc/starting.txt | 2 +- runtime/doc/tags | 11 +- runtime/doc/tagsrch.txt | 5 +- runtime/doc/terminal.txt | 4 +- runtime/doc/todo.txt | 105 ++++-- runtime/doc/usr_11.txt | 3 +- runtime/doc/usr_45.txt | 6 - runtime/doc/various.txt | 6 +- runtime/filetype.vim | 5 +- runtime/ftplugin/8th.vim | 25 ++ runtime/ftplugin/rst.vim | 2 +- runtime/lang/menu_da.latin1.vim | 2 +- runtime/lang/menu_da.utf-8.vim | 89 ++++++ runtime/syntax/8th.vim | 335 +++++++++++++++++++ runtime/syntax/c.vim | 4 +- runtime/syntax/make.vim | 9 +- runtime/syntax/spec.vim | 6 +- runtime/tutor/tutor | 2 +- runtime/tutor/tutor.da | 2 +- runtime/tutor/tutor.da.utf-8 | 2 +- runtime/tutor/tutor.nl | 2 +- runtime/tutor/tutor.nl.utf-8 | 2 +- runtime/tutor/tutor.utf-8 | 2 +- src/po/da.po | 5 +- src/po/fr.po | 547 +++++++++++++++++++++----------- src/testdir/Makefile | 4 +- 39 files changed, 984 insertions(+), 361 deletions(-) create mode 100644 runtime/ftplugin/8th.vim create mode 100644 runtime/syntax/8th.vim diff --git a/nsis/lang/danish.nsi b/nsis/lang/danish.nsi index 141bc17eb8..3f792bc87b 100644 --- a/nsis/lang/danish.nsi +++ b/nsis/lang/danish.nsi @@ -74,7 +74,7 @@ LangString str_group_plugin ${LANG_DANISH} "Opret plugin-mapper" LangString str_desc_plugin ${LANG_DANISH} "Opret plugin-mapper. Plugin-mapper giver mulighed for at udvide Vim ved at slippe en fil i en mappen." LangString str_section_plugin_home ${LANG_DANISH} "Private" -LangString str_desc_plugin_home ${LANG_DANISH} "Opret plugin-mapper i HOME-mappen." +LangString str_desc_plugin_home ${LANG_DANISH} "Opret plugin-mapper i HOME (hvis du har defineret et) eller Vim-installationsmappe." LangString str_section_plugin_vim ${LANG_DANISH} "Delte" LangString str_desc_plugin_vim ${LANG_DANISH} "Opret plugin-mapper i Vim-installationsmappe, det bruges af alle pÃ¥ systemet." @@ -92,9 +92,9 @@ LangString str_unsection_exe ${LANG_DANISH} "Fjern Vim-eksekverbare-/ LangString str_desc_rm_exe ${LANG_DANISH} "Fjern alle Vim-eksekverbare- og afviklingsfiler." LangString str_ungroup_plugin ${LANG_DANISH} "Fjern plugin-mapper" -LangString str_desc_rm_plugin ${LANG_DANISH} "Fjern plugin-mapperne hvis de er tomme." +LangString str_desc_rm_plugin ${LANG_DANISH} "Fjern plugin-mapperne, hvis de er tomme." -LangString str_unsection_plugin_home ${LANG_DANISH} "Privat" +LangString str_unsection_plugin_home ${LANG_DANISH} "Private" LangString str_desc_rm_plugin_home ${LANG_DANISH} "Fjern plugin-mapperne fra HOME-mappen." LangString str_unsection_plugin_vim ${LANG_DANISH} "Delte" @@ -164,9 +164,9 @@ LangString str_msg_compat_defaults ${LANG_DANISH} "Vim med nogle forbedringe LangString str_msg_compat_all ${LANG_DANISH} "Vim med alle forbedringer (indlæs vimrc_example.vim) (standard)" LangString str_msg_keymap_title ${LANG_DANISH} " Tilknytninger " -LangString str_msg_keymap_desc ${LANG_DANISH} "&Gentilknyt nogle fÃ¥ taster (Ctrl-V, Ctrl-C, Ctrl-A, Ctrl-S, Ctrl-F osv.)" +LangString str_msg_keymap_desc ${LANG_DANISH} "&Gentilknyt nogle fÃ¥ taster for Windows (Ctrl-V, Ctrl-C, Ctrl-A, Ctrl-S, Ctrl-F osv.)" LangString str_msg_keymap_default ${LANG_DANISH} "Gentilknyt ikke taster (standard)" -LangString str_msg_keymap_windows ${LANG_DANISH} "Gentilknyt nogle fÃ¥ taster til Windows" +LangString str_msg_keymap_windows ${LANG_DANISH} "Gentilknyt nogle fÃ¥ taster" LangString str_msg_mouse_title ${LANG_DANISH} " Mus " LangString str_msg_mouse_desc ${LANG_DANISH} "&Opførsel af højre og venstre knapper" diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index bef7500647..4c5b402a7e 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1,4 +1,4 @@ -*change.txt* For Vim version 8.1. Last change: 2018 Dec 14 +*change.txt* For Vim version 8.1. Last change: 2019 Feb 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -640,11 +640,11 @@ For other systems the tmpnam() library function is used. For the {pattern} see |pattern|. {string} can be a literal string, or something special; see |sub-replace-special|. - *E939* When [range] and [count] are omitted, replace in the current line only. When [count] is given, replace in [count] lines, starting with the last line in [range]. When [range] is omitted start in the current line. + *E939* [count] must be a positive number. Also see |cmdline-ranges|. diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index b1b3cc49ec..2d0cc2278d 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -1,4 +1,4 @@ -*develop.txt* For Vim version 8.1. Last change: 2018 May 02 +*develop.txt* For Vim version 8.1. Last change: 2019 Feb 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -355,6 +355,24 @@ OK: if (cond) cmd; } +When a block has one line the braces can be left out. When an if/else has +braces on one block, it usually looks better when the other block also has +braces: +OK: if (cond) + cmd; + else + cmd; + +OK: if (cond) + { + cmd; + } + else + { + cmd; + cmd; + } + Use ANSI (new style) function declarations with the return type on a separate indented line. @@ -367,10 +385,10 @@ OK: /* */ int function_name( - int arg1, /* short comment about arg1 */ - int arg2) /* short comment about arg2 */ + int arg1, // short comment about arg1 + int arg2) // short comment about arg2 { - int local; /* comment about local */ + int local; // comment about local local = arg1 * arg2; diff --git a/runtime/doc/digraph.txt b/runtime/doc/digraph.txt index 600692e25b..a174d3cfca 100644 --- a/runtime/doc/digraph.txt +++ b/runtime/doc/digraph.txt @@ -1,4 +1,4 @@ -*digraph.txt* For Vim version 8.1. Last change: 2018 Dec 14 +*digraph.txt* For Vim version 8.1. Last change: 2019 Feb 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -59,18 +59,9 @@ conversion to be available, it might fail. For the NUL character you will see "10". That's because NUL characters are internally represented with a NL character. When you write the file it will become a NUL character. -When Vim was compiled without the |+multi_byte| feature, you need to specify -the character in the encoding given with 'encoding'. You might want to use -something like this: > - - if has("multi_byte") - digraph oe 339 - elseif &encoding == "iso-8859-15" - digraph oe 189 - endif - -This defines the "oe" digraph for a character that is number 339 in Unicode -and 189 in latin9 (iso-8859-15). +Example: > + digraph oe 339 +This defines the "oe" digraph for a character that is number 339 in Unicode. ============================================================================== 2. Using digraphs *digraphs-use* @@ -164,8 +155,7 @@ a standard meaning: Example: a: is ä and o: is ö These are the RFC1345 digraphs for the one-byte characters. See the output of -":digraphs" for the others. The characters above 255 are only available when -Vim was compiled with the |+multi_byte| feature. +":digraphs" for the others. EURO diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 535517d21d..951b06856c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.1. Last change: 2019 Feb 03 +*eval.txt* For Vim version 8.1. Last change: 2019 Feb 16 VIM REFERENCE MANUAL by Bram Moolenaar @@ -5538,7 +5538,6 @@ iconv({expr}, {from}, {to}) *iconv()* < Note that Vim uses UTF-8 for all Unicode encodings, conversion from/to UCS-2 is automatically changed to use UTF-8. You cannot use UCS-2 in a string anyway, because of the NUL bytes. - {only available when compiled with the |+multi_byte| feature} *indent()* indent({lnum}) The result is a Number, which is indent of line {lnum} in the @@ -6816,8 +6815,7 @@ printf({fmt}, {expr1} ...) *printf()* *printf-S* S The text of the String argument is used. If a precision is specified, no more display cells than the - number specified are used. Without the |+multi_byte| - feature works just like 's'. + number specified are used. *printf-f* *E807* f F The Float argument is converted into a string of the @@ -8611,10 +8609,10 @@ strcharpart({src}, {start} [, {len}]) *strcharpart()* strdisplaywidth({expr} [, {col}]) *strdisplaywidth()* The result is a Number, which is the number of display cells - String {expr} occupies on the screen when it starts at {col}. - When {col} is omitted zero is used. Otherwise it is the - screen column where to start. This matters for Tab - characters. + String {expr} occupies on the screen when it starts at {col} + (first column is zero). When {col} is omitted zero is used. + Otherwise it is the screen column where to start. This + matters for Tab characters. The option settings of the current window are used. This matters for anything that's displayed differently, such as 'tabstop' and 'display'. @@ -10272,7 +10270,7 @@ mouse_sgr Compiled with support for sgr mouse. mouse_urxvt Compiled with support for urxvt mouse. mouse_xterm Compiled with support for xterm mouse. mouseshape Compiled with support for 'mouseshape'. -multi_byte Compiled with support for 'encoding' +multi_byte Compiled with support for 'encoding' (always true) multi_byte_encoding 'encoding' is set to a multi-byte encoding. multi_byte_ime Compiled with support for IME input method. multi_lang Compiled with support for multiple languages. diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index da3f260d1a..7a36804b33 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -663,6 +663,15 @@ your |vimrc|: > let rrst_dynamic_comments = 0 +RESTRUCTUREDTEXT *ft-rst-plugin* + +The following formatting setting are optionally available: > + setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8 + +To enable this behavior, set the following variable in your vimrc: > + let g:rst_style = 1 + + RPM SPEC *ft-spec-plugin* Since the text for this plugin is rather long it has been put in a separate diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt index 24fed6d7d9..a645cab124 100644 --- a/runtime/doc/mbyte.txt +++ b/runtime/doc/mbyte.txt @@ -14,9 +14,6 @@ For an introduction to the most common features, see |usr_45.txt| in the user manual. For changing the language of messages and menus see |mlang.txt|. -{not available when compiled without the |+multi_byte| feature} - - 1. Getting started |mbyte-first| 2. Locale |mbyte-locale| 3. Encoding |mbyte-encoding| @@ -44,16 +41,6 @@ features. Unfortunately, every system has its own way to deal with multibyte languages and it is quite complicated. -COMPILING - -If you already have a compiled Vim program, check if the |+multi_byte| feature -is included. The |:version| command can be used for this. - -If +multi_byte is not included, you should compile Vim with "normal", "big" or -"huge" features. You can further tune what features are included. See the -INSTALL files in the source directory. - - LOCALE First of all, you must make sure your current locale is set correctly. If diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index e664c96217..f48ccb812b 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 8.1. Last change: 2019 Feb 03 +*options.txt* For Vim version 8.1. Last change: 2019 Feb 16 VIM REFERENCE MANUAL by Bram Moolenaar @@ -695,8 +695,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'ambiwidth' 'ambw' string (default: "single") global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} Only effective when 'encoding' is "utf-8" or another Unicode encoding. Tells Vim what to do with characters with East Asian Width Class Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek @@ -1277,8 +1275,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'bomb' boolean (default off) local to buffer {not in Vi} - {only available when compiled with the |+multi_byte| - feature} When writing a file and the following conditions are met, a BOM (Byte Order Mark) is prepended to the file: - this option is on @@ -1440,8 +1436,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'casemap' 'cmp' string (default: "internal,keepascii") global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} Specifies details about changing the case of letters. It may contain these words, separated by a comma: internal Use internal case mapping functions, the current @@ -1497,8 +1491,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'charconvert'* *'ccv'* *E202* *E214* *E513* 'charconvert' 'ccv' string (default "") global - {only available when compiled with the |+multi_byte| - and |+eval| features} + {only available when compiled with the |+eval| feature} {not in Vi} An expression that is used for character encoding conversion. It is evaluated when a file that is to be read or has been written has a @@ -1657,7 +1650,6 @@ A jump table for the options with a short description can be found at |Q_op|. You probably want to add this only temporarily, possibly use BufEnter autocommands. Only supported for GTK version 2 and later. - Only available with the |+multi_byte| feature. *clipboard-exclude* exclude:{pattern} @@ -2552,8 +2544,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'delcombine' 'deco' boolean (default off) global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} If editing Unicode and this option is set, backspace and Normal mode "x" delete each combining character on its own. When it is off (the default) the character along with its combining characters are @@ -2804,16 +2794,12 @@ A jump table for the options with a short description can be found at |Q_op|. 'emoji' 'emo' boolean (default: on) global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} When on all Unicode emoji characters are considered to be full width. *'encoding'* *'enc'* *E543* 'encoding' 'enc' string (default: "latin1" or value from $LANG) global - {only available when compiled with the |+multi_byte| - feature} {not in Vi} Sets the character encoding used inside Vim. It applies to text in the buffers, registers, Strings in expressions, text stored in the @@ -3016,8 +3002,6 @@ A jump table for the options with a short description can be found at |Q_op|. *'fileencoding'* *'fenc'* *E213* 'fileencoding' 'fenc' string (default: "") local to buffer - {only available when compiled with the |+multi_byte| - feature} {not in Vi} Sets the character encoding for the file of this buffer. @@ -3073,8 +3057,6 @@ A jump table for the options with a short description can be found at |Q_op|. "ucs-bom,utf-8,default,latin1" when 'encoding' is set to a Unicode value) global - {only available when compiled with the |+multi_byte| - feature} {not in Vi} This is a list of character encodings considered when starting to edit an existing file. When a file is read, Vim tries to use the first @@ -4318,8 +4300,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'imactivatefunc' 'imaf' string (default "") global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} This option specifies a function that will be called to activate or deactivate the Input Method. It is not used in the GUI. @@ -4371,8 +4351,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'imcmdline' 'imc' boolean (default off) global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} When set the Input Method is always on when starting to edit a command line, unless entering a search pattern (see 'imsearch' for that). Setting this option is useful when your input method allows entering @@ -4383,8 +4361,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'imdisable' 'imd' boolean (default off, on for some systems (SGI)) global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} When set the Input Method is never used. This is useful to disable the IM when it doesn't work properly. Currently this option is on by default for SGI/IRIX machines. This @@ -4437,8 +4413,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'imstatusfunc' 'imsf' string (default "") global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} This option specifies a function that is called to obtain the status of Input Method. It must return a positive number when IME is active. It is not used in the GUI. @@ -5183,8 +5157,6 @@ A jump table for the options with a short description can be found at |Q_op|. *'makeencoding'* *'menc'* 'makeencoding' 'menc' string (default "") global or local to buffer |global-local| - {only available when compiled with the |+multi_byte| - feature} {not in Vi} Encoding used for reading the output of external commands. When empty, encoding is not converted. @@ -5251,8 +5223,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'maxcombine' 'mco' number (default 2) global {not in Vi} - {only available when compiled with the |+multi_byte| - feature} The maximum number of combining characters supported for displaying. Only used when 'encoding' is "utf-8". The default is OK for most languages. Hebrew may require 4. @@ -6020,8 +5990,8 @@ A jump table for the options with a short description can be found at |Q_op|. 'printmbcharset' 'pmbcs' string (default "") global {not in Vi} - {only available when compiled with the |+printer|, - |+postscript| and |+multi_byte| features} + {only available when compiled with the |+printer| + and |+postscript| features} The CJK character set to be used for CJK output from |:hardcopy|. See |pmbcs-option|. @@ -6029,8 +5999,8 @@ A jump table for the options with a short description can be found at |Q_op|. 'printmbfont' 'pmbfn' string (default "") global {not in Vi} - {only available when compiled with the |+printer|, - |+postscript| and |+multi_byte| features} + {only available when compiled with the |+printer| + and |+postscript| features} List of font names to be used for CJK output from |:hardcopy|. See |pmbfn-option|. @@ -7997,8 +7967,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'termencoding' 'tenc' string (default ""; with GTK+ GUI: "utf-8"; with Macintosh GUI: "macroman") global - {only available when compiled with the |+multi_byte| - feature} {not in Vi} Encoding used for the terminal. This specifies what character encoding the keyboard produces and the display will understand. For diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index f17db96829..a4ddd8d646 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1135,7 +1135,7 @@ x A single character, with no special meaning, matches itself The "Func" column shows what library function is used. The implementation depends on the system. Otherwise: (1) Uses islower() for ASCII and Vim builtin rules for other - characters when built with the |+multi_byte| feature. + characters. (2) Uses Vim builtin rules (3) As with (1) but using isupper() */[[=* *[==]* diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt index 2f5a1a96c9..6018d44b52 100644 --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -111,10 +111,9 @@ not recognized by Vim will just be converted to lower case and underscores replaced with '-' signs. If 'printencoding' is empty or Vim cannot find the file then it will use -'encoding' (if Vim is compiled with |+multi_byte| and it is set an 8-bit -encoding) to find the print character encoding file. If Vim is unable to find -a character encoding file then it will use the "latin1" print character -encoding file. +'encoding' (if it is set an 8-bit encoding) to find the print character +encoding file. If Vim is unable to find a character encoding file then it +will use the "latin1" print character encoding file. When 'encoding' is set to a multi-byte encoding, Vim will try to convert characters to the printing encoding for printing (if 'printencoding' is empty diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 4c6e249e8a..eb88bfd853 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 8.1. Last change: 2019 Feb 08 +*quickref.txt* For Vim version 8.1. Last change: 2019 Feb 16 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 03a2799883..eed064ac8f 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -323,8 +323,6 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. set encoding=utf-8 scriptencoding utf-8 < - When compiled without the |+multi_byte| feature this - command is ignored. {not in Vi} *:scr* *:scriptnames* diff --git a/runtime/doc/russian.txt b/runtime/doc/russian.txt index fae8690df1..b390f05dd9 100644 --- a/runtime/doc/russian.txt +++ b/runtime/doc/russian.txt @@ -55,8 +55,7 @@ automatic installs. Vim also needs to be compiled with |+gettext| feature for user interface items translations to work. After downloading an archive from RuVim project, unpack it into your -$VIMRUNTIME directory. We recommend using UTF-8 archive, if your version of -Vim is compiled with |+multi_byte| feature enabled. +$VIMRUNTIME directory. We recommend using UTF-8 archive. In order to use the Russian documentation, make sure you have set the 'helplang' option to "ru". diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 9f6472670c..595f595df0 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 8.1. Last change: 2018 May 05 +*starting.txt* For Vim version 8.1. Last change: 2019 Feb 16 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/tags b/runtime/doc/tags index 988d11b47b..29208d68ae 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -1092,10 +1092,10 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'termbidi' options.txt /*'termbidi'* 'termencoding' options.txt /*'termencoding'* 'termguicolors' options.txt /*'termguicolors'* -'termmode' options.txt /*'termmode'* 'termwinkey' options.txt /*'termwinkey'* 'termwinscroll' options.txt /*'termwinscroll'* 'termwinsize' options.txt /*'termwinsize'* +'termwintype' options.txt /*'termwintype'* 'terse' options.txt /*'terse'* 'textauto' options.txt /*'textauto'* 'textmode' options.txt /*'textmode'* @@ -1113,7 +1113,6 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'titlestring' options.txt /*'titlestring'* 'tl' options.txt /*'tl'* 'tm' options.txt /*'tm'* -'tmod' options.txt /*'tmod'* 'to' options.txt /*'to'* 'toolbar' options.txt /*'toolbar'* 'toolbariconsize' options.txt /*'toolbariconsize'* @@ -1137,6 +1136,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'twk' options.txt /*'twk'* 'tws' options.txt /*'tws'* 'twsl' options.txt /*'twsl'* +'twt' options.txt /*'twt'* 'tx' options.txt /*'tx'* 'uc' options.txt /*'uc'* 'udf' options.txt /*'udf'* @@ -2521,6 +2521,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* :lefta windows.txt /*:lefta* :leftabove windows.txt /*:leftabove* :let eval.txt /*:let* +:let%= eval.txt /*:let%=* :let+= eval.txt /*:let+=* :let-$ eval.txt /*:let-$* :let-& eval.txt /*:let-&* @@ -2531,6 +2532,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* :let-register eval.txt /*:let-register* :let-unpack eval.txt /*:let-unpack* :let.= eval.txt /*:let.=* +:let/= eval.txt /*:let\/=* +:letstar= eval.txt /*:letstar=* :lex quickfix.txt /*:lex* :lexpr quickfix.txt /*:lexpr* :lf quickfix.txt /*:lf* @@ -4688,6 +4691,8 @@ E978 eval.txt /*E978* E979 eval.txt /*E979* E98 diff.txt /*E98* E980 eval.txt /*E980* +E981 starting.txt /*E981* +E982 terminal.txt /*E982* E99 diff.txt /*E99* EX intro.txt /*EX* EXINIT starting.txt /*EXINIT* @@ -6128,7 +6133,6 @@ f motion.txt /*f* false-variable eval.txt /*false-variable* faq intro.txt /*faq* farsi farsi.txt /*farsi* -farsi-fonts farsi.txt /*farsi-fonts* farsi.txt farsi.txt /*farsi.txt* fasm.vim syntax.txt /*fasm.vim* fcs_choice-variable eval.txt /*fcs_choice-variable* @@ -6354,6 +6358,7 @@ ft-rmd-plugin filetype.txt /*ft-rmd-plugin* ft-rmd-syntax syntax.txt /*ft-rmd-syntax* ft-rrst-plugin filetype.txt /*ft-rrst-plugin* ft-rrst-syntax syntax.txt /*ft-rrst-syntax* +ft-rst-plugin filetype.txt /*ft-rst-plugin* ft-rst-syntax syntax.txt /*ft-rst-syntax* ft-ruby-omni insert.txt /*ft-ruby-omni* ft-ruby-syntax syntax.txt /*ft-ruby-syntax* diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index f9cc1efdc0..865fcb19c7 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -1,4 +1,4 @@ -*tagsrch.txt* For Vim version 8.1. Last change: 2018 May 04 +*tagsrch.txt* For Vim version 8.1. Last change: 2019 Feb 13 VIM REFERENCE MANUAL by Bram Moolenaar @@ -613,8 +613,7 @@ ignored. (Case is ignored when 'ignorecase' is set and 'tagcase' is The value '2' should be used then: !_TAG_FILE_SORTED2{anything} ~ -The other tag that Vim recognizes, but only when compiled with the -|+multi_byte| feature, is the encoding of the tags file: +The other tag that Vim recognizes is the encoding of the tags file: !_TAG_FILE_ENCODINGutf-8{anything} ~ Here "utf-8" is the encoding used for the tags. Vim will then convert the tag being searched for from 'encoding' to the encoding of the tags file. And when diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index 42fe2c9d9d..da89be4362 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -1,4 +1,4 @@ -*terminal.txt* For Vim version 8.1. Last change: 2019 Feb 03 +*terminal.txt* For Vim version 8.1. Last change: 2019 Feb 16 VIM REFERENCE MANUAL by Bram Moolenaar @@ -44,7 +44,7 @@ If the result is "1" you have it. {Vi does not have any of these commands} {only available when compiled with the |+terminal| feature} -The terminal feature requires the |+multi_byte|, |+job| and |+channel| features. +The terminal feature requires the |+job| and |+channel| features. ============================================================================== 1. Basic use *terminal-use* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index cb8733fe1b..0ba254993b 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 8.1. Last change: 2019 Feb 02 +*todo.txt* For Vim version 8.1. Last change: 2019 Feb 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -38,6 +38,11 @@ browser use: https://github.com/vim/vim/issues/1234 *known-bugs* -------------------- Known bugs and current work ----------------------- +Patch to add farsi handling to arabic.c (Ali Gholami Rudi, 2009 May 2) +Added test, updates, June 23. +Updated for 7.4: http://litcave.rudi.ir/farsi_vim.diff +Remark from Ameretat Reith (2014 Oct 13) with patch on top. + Timer test doesn't work on MS-Windows console, any way to make it work? 'incsearch' with :s: (#3321) @@ -74,15 +79,15 @@ Terminal debugger: with another Vim instance. Terminal emulator window: +- When the job in the terminal doesn't use mouse events, let the scroll wheel + scroll the scrollback, like a terminal does at the shell prompt. #2490 + And use modeless selection. #2962 - When Vim runs in the terminal and changes the title, the statusline needs to be redrawn. - GUI: When using ":set go+=!" a system() call causes the hit-enter prompt. (#3327) - Terminal API: Add more functionality? (Ozaki Kiichi 2018 May 13, #2907) - GUI: hang until key typed. (#3530) -- When the job in the terminal doesn't use mouse events, let the scroll wheel - scroll the scrollback, like a terminal does at the shell prompt. #2490 - And use modeless selection. #2962 - Allow for specifying the directory, with ++cwd={dir}. - With a vertical split only one window is updated. (Linwei, 2018 Jun 2, #2977) @@ -117,18 +122,17 @@ Does not build with MinGW out of the box: Crash when mixing matchadd and substitute()? (Max Christian Pohle, 2018 May 13, #2910) Can't reproduce? -Merge checking for 'cursorline' and 'concealcursor', see neovim #9492. - Errors found with random data: heap-buffer-overflow in alist_add (#2472) -Win32 key codes are messy. Mike Williams tried to fix that, but now old -mappings no longer work. Create a new terminal for the better solution? - Improve fallback for menu translations, to avoid having to create lots of files that source the actual file. E.g. menu_da_de -> menu_da Include part of #3242? +Improvement for :terminal winpty/conpty option. Ozaki Kiichi, #3905 + +Patch to change WIN32 macro names. (Hirohito Higashi, #3932) + When a terminal exit_cb closes the window, a following typed key is lost, if it's in a mapping. (2018 Oct 6, #2302, #3522) @@ -143,6 +147,9 @@ Williams, 2018 Oct 30) Problem with :tlmenu: Detach item added with all modes? Issue #3563. +Patch to reduce amount of memory used by functions that keep reference. +(ichizok, #3961) + When using a timer callback vgetc_busy is reset, allowing for using input(). But in a channel callback this does not happen. We need to do something similar to check_due_timer(). Also see #3809. @@ -167,17 +174,43 @@ Another request: #3811. More warnings from static analysis: https://lgtm.com/projects/g/vim/vim/alerts/?mode=list +When using 'k' in 'guioptions' gvim may open with a tiny window. (#3808) +Suggested patch on the issue. + nvo-mode mapping works on Windows, not on Linux. (#3678) Patch to be able to separately map CTRL-H and BS on Windows. (Linwei, 2017 Jul 11, #1833) +Patch to fix encoding of messages on MS-Windows. (Yasuhiro Matsumoto, 2019 Feb +13, #3914) + +Patch to fix encoding conversion in messages. (#3969) + +Incsearch test fails when locale is "C". (Dominique Pelle, #3986) +Also run all tests with C locale? + Patch to improve readability of complicated if(). (ichizok, 2019 Jan 29, #3879) +"vat" doesn't work well on XML when the closing > is on another line. +#3927 + +Patch to include ARM64 support. (Leendert van Doorn, 2019 Feb 9) + +Patch to fix hang when opening file where an intermediate directory is not +readable on MS-Windows. (link on #3923) + Pasting foo} causes Vim to behave weird. (John Little, 2018 Jun 17) Related to bracketed paste. I cannot reproduce it. +Patch to add tagfunc(). Cleaned up by Christian Brabandt, 2013 Jun 22. +New update 2017 Apr 10, #1628 +https://github.com/chrisbra/vim-mq-patches/blob/master/tagfunc +Updated by Andy Massimino, 2018 Feb 7: +https://github.com/andymass/vim/commit/4e3aa0a5dab96d2799567622f3f537e357aa479e +Or should we make it asynchronous? + When 'confirm' is set a "silent q" doesn't show the prompt. It should in this case. (Nate Peterson, 2019 Jan 31, #3892) For "silent! q" it should not prompt and just fail. @@ -187,16 +220,13 @@ character in the file. (Smylers, 2018 Nov 17, #3620) Suggested patch by Hirohito Higashi, 2018 Nov 18. Using CTRL-L to add a character to the search string that contains \v, -punctiuation is repeated. (Smylers, 2018 Nov 17, #3621) +punctuation is repeated. (Smylers, 2018 Nov 17, #3621) Using CTRL-L during search only picks up the base character, not a combining character. (Rick, 2018 Dec 11, #3682) ml_get error: (Israel Chauca Fuentes, 2018 Oct 17, #3550). -Patch to convert temp file name. (Yasuhiro Matsumoto, #3520) -Not ready to include yet. - Problem with two buffers with the same name a/b, if it didn't exist before and is created outside of Vim. (dskloetg, 2018 Jul 16, #3219) @@ -211,12 +241,22 @@ Invalid memory access with old regexp engine. (Dominique Pelle, 2018 Sep 3, Patch to add complete_mode(). Shougo - #3866. Alternate patch by Hirohito Higashi, 2019 Jan 27, included now? +Patch to make winnr() return the window above/below/beside a window. +(Yegappan Lakshmanan, #3993) + Patch for ConPTY support, new one: #3794 Does this work now? It should. (Nobuhiro Takasaki) Add function to make use of internal diff, working on two lists and returning unified diff (list of lines). +When splitting a window with few text lines, the relative cursor position is +kept, which means part of the text isn't displayed. Better show all the text +when possible. (Dylan Lloyd, #3973) + +Tag stack is incorrect after CTRL-T and then :tag. (Andy Massimino, 2019 Feb +12, #3944) With Patch for a solution. Needs a test. + Patch to implement 'diffref' option. (#3535) Easier to use a 'diffmaster' option, is the extra complexity needed? @@ -231,6 +271,15 @@ Patch by Christian, Oct 30. Patch to clean up CI configs. (Ozaki Kiichi, 2019 Feb 1, #3890) +Patch to filter marks. (Marcin Szamotulski, 2019 Feb 7, #3895) + +Patch to add environ(), gets a dict with all environment vars, and getenv(), +useful for environment vars that are not made of keyword chars. +(Yasuhiro Matsumoto, #2875) + +Patch to add optional arguments with default values. +(Andy Massimino, #3952) under development + Memory leaks in test_channel? (or is it because of fork()) Using uninitialized value in test_crypt. Memory leak in test_terminal: @@ -243,6 +292,7 @@ Memory leak in test_terminal: ==23530== by 0x35C923: term_start (terminal.c:421) ==23530== by 0x2AFF30: mch_call_shell_terminal (os_unix.c:4377) ==23530== by 0x2B16BE: mch_call_shell (os_unix.c:5383) +Memory leak in test_alot with pyeval() (allocating partial) gethostbyname() is old, use getaddrinfo() if available. (#3227) @@ -252,6 +302,12 @@ Patch to add match count and current index "3/44" when using "n" command. matchaddpos() gets slow with many matches. Proposal by Rick Howe, 2018 Jul 19. +Patch to specify color for cterm=underline and cterm=undercurl, like "guisp". +Does #2405 do this? + +Patch to add an interrupt() function: sets got_int. Useful in an autocommand +such as BufWritePre that checks the file name or contents. + Should make 'listchars' global-local. Local to window or to buffer? Probably window. Add something like 'fillchars' local to window, but allow for specifying a @@ -318,6 +374,11 @@ Better name? MS-Windows: .lnk file not resolved properly when 'encoding' is set. (lkintact, 2018 Sep 22, #3473) +Merge checking for 'cursorline' and 'concealcursor', see neovim #9492. + +Win32 key codes are messy. Mike Williams tried to fix that, but now old +mappings no longer work. Create a new terminal for the better solution? + Script generated by :mksession does not work well if there are windows with modified buffers change "silent only" into "silent only!" @@ -350,6 +411,9 @@ Height of quickfix window is not retained with vertical splits. (Lifepillar, Window size is wrong when using quickfix window. (Lifepillar, 2018 Aug 24, #2999) +Add more testing of the GTK GUI. +- gtk_test_widget_click() can be used to simulate a click in a widget. + Tests failing for "make testgui" with GTK: - Test_setbufvar_options() - Test_exit_callback_interval() @@ -822,10 +886,6 @@ Implement optional arguments for functions. call Foo(12, all = 0) call Foo(12, 15, 0) -Change the Farsi code to work with UTF-8. Possibly combined with the Arabic -support, or similar. -Invalid read error in Farsi mode. (Dominique Pelle, 2009 Aug 2) - Add a command to take a range of lines, filter them and put the output somewhere else. :{range}copy {dest} !cmd @@ -1005,9 +1065,6 @@ Add an argument to choose binary or non-binary (like readfile()), when omitted use the current behavior. Include the test. -Patch to add tagfunc(). Cleaned up by Christian Brabandt, 2013 Jun 22. -New update 2017 Apr 10, #1628 - When 'keywordprg' starts with ":" the argument is still escaped as a shell command argument. (Romain Lafourcade, 2016 Oct 16, #1175) @@ -2079,12 +2136,6 @@ to avoid changing 'eventignore'? Patch for displaying 0x200c and 0x200d. (Ali Gholami Rudi, 2009 May 6) Probably needs a bit of work. -Patch to add farsi handling to arabic.c (Ali Gholami Rudi, 2009 May 2) -Added test, updates, June 23. -Updated for 7.4: http://litcave.rudi.ir/farsi_vim.diff -With modification for Tatweel character: https://dpaste.de/VmFw -Remark from Ameretat Reith (2014 Oct 13) - List of encoding aliases. (Takao Fujiwara, 2009 Jul 18) Are they all OK? Update Jul 22. @@ -3091,8 +3142,6 @@ Win32 GUI known bugs: 8 The -P argument doesn't work very well with many MDI applications. The last argument of CreateWindowEx() should be used, see MSDN docs. Tutorial: http://win32assembly.online.fr/tut32.html -8 In eval.c, io.h is included when MSWIN32 is defined. Shouldn't this be - WIN32? Or can including io.h be moved to vim.h? (Dan Sharp) 6 Win32 GUI: With "-u NONE -U NONE" and doing "CTRL-W v" "CTRL-W o", the ":" of ":only" is highlighted like the cursor. (Lipelis) 8 When 'encoding' is "utf-8", should use 'guifont' for both normal and wide diff --git a/runtime/doc/usr_11.txt b/runtime/doc/usr_11.txt index cd0b72643e..bf09d2e079 100644 --- a/runtime/doc/usr_11.txt +++ b/runtime/doc/usr_11.txt @@ -1,4 +1,4 @@ -*usr_11.txt* For Vim version 8.1. Last change: 2019 Jan 30 +*usr_11.txt* For Vim version 8.1. Last change: 2019 Feb 04 VIM USER MANUAL - by Bram Moolenaar @@ -284,6 +284,7 @@ If you really don't want to see this message, you can add the 'A' flag to the 'shortmess' option. But it's very unusual that you need this. For remarks about encryption and the swap file, see |:recover-crypt|. +For programatic access to the swap file, see |swapinfo()|. ============================================================================== *11.4* Further reading diff --git a/runtime/doc/usr_45.txt b/runtime/doc/usr_45.txt index 3830eab2f1..fee7b98eb5 100644 --- a/runtime/doc/usr_45.txt +++ b/runtime/doc/usr_45.txt @@ -153,12 +153,6 @@ language than the text. language, the default should work fine and you don't need to do anything. The following is only relevant when you want to edit different languages. - Note: - Using different encodings only works when Vim was compiled to handle - it. To find out if it works, use the ":version" command and check the - output for "+multi_byte". If it's there, you are OK. If you see - "-multi_byte" you will have to find another Vim. - USING UNICODE IN THE GUI diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 2a9c9cfcb0..eb50bdc179 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -82,8 +82,7 @@ g8 Print the hex values of the bytes used in the value of 'maxcombine' doesn't matter. Example of a character with two composing characters: e0 b8 81 + e0 b8 b9 + e0 b9 89 ~ - {not in Vi} {only when compiled with the |+multi_byte| - feature} + {not in Vi} *8g8* 8g8 Find an illegal UTF-8 byte sequence at or after the @@ -98,8 +97,7 @@ g8 Print the hex values of the bytes used in the Note that when the cursor is on an illegal byte or the cursor is halfway a multi-byte character the command won't move the cursor. - {not in Vi} {only when compiled with the |+multi_byte| - feature} + {not in Vi} *:p* *:pr* *:print* *E749* :[range]p[rint] [flags] diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 76b7aa1a7c..26f5483243 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2019 Jan 28 +" Last Change: 2019 Feb 07 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -54,6 +54,9 @@ au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help " Abaqus or Trasys au BufNewFile,BufRead *.inp call dist#ft#Check_inp() +" 8th (Firth-derivative) +au BufNewFile,BufRead *.8th setf 8th + " A-A-P recipe au BufNewFile,BufRead *.aap setf aap diff --git a/runtime/ftplugin/8th.vim b/runtime/ftplugin/8th.vim new file mode 100644 index 0000000000..14301187d6 --- /dev/null +++ b/runtime/ftplugin/8th.vim @@ -0,0 +1,25 @@ +" Vim ftplugin file +" Language: 8th +" Version: any +" Last Change: 2015/11/08 +" Maintainer: Ron Aaron +" URL: https://8th-dev.com/ +" Filetypes: *.8th +" NOTE: 8th allows any non-whitespace in a name, so you need to do: +" setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 +" This goes with the syntax/8th.vim file. + +" Only do this when not done yet for this buffer +if exists("b:did_8thplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_8thplugin = 1 + +setlocal ts=2 sts=2 sw=2 et +setlocal com=s1:/*,mb:*,ex:*/,:\|,:\\ +setlocal fo=tcrqol +setlocal matchpairs+=\::; +setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 +setlocal suffixesadd=.8th diff --git a/runtime/ftplugin/rst.vim b/runtime/ftplugin/rst.vim index 8ab56b052a..f0646e9f36 100644 --- a/runtime/ftplugin/rst.vim +++ b/runtime/ftplugin/rst.vim @@ -30,7 +30,7 @@ setlocal formatoptions+=tcroql " " More sophisticated indentation rules should be revisted in the future. -if !exists("g:rst_style") || g:rst_style != 0 +if exists("g:rst_style") && g:rst_style != 0 setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8 endif diff --git a/runtime/lang/menu_da.latin1.vim b/runtime/lang/menu_da.latin1.vim index b258495653..3187c9e383 100644 --- a/runtime/lang/menu_da.latin1.vim +++ b/runtime/lang/menu_da.latin1.vim @@ -1,3 +1,3 @@ " Menu Translations: Danish for iso-8859-1 encoding -source :p:h/menu_da.utf-8.vim +source :p:h/menu_da.utf-8.vim \ No newline at end of file diff --git a/runtime/lang/menu_da.utf-8.vim b/runtime/lang/menu_da.utf-8.vim index 8bb1944359..751dad0947 100644 --- a/runtime/lang/menu_da.utf-8.vim +++ b/runtime/lang/menu_da.utf-8.vim @@ -368,6 +368,95 @@ let g:menutrans_spell_change_ARG_to = 'Ændr\ "%s"\ til' let g:menutrans_spell_add_ARG_to_word_list = 'Tilføj\ "%s"\ til\ ordliste' let g:menutrans_spell_ignore_ARG = 'Ignorer "%s"' + + +" Forsøg pÃ¥ at oversætte netrw-menuen +menut Help Hjælp +" -Sep1- +menut Go\ Up\ Directory- GÃ¥\ mappe\ op- +menut Apply\ Special\ Viewerx Anvend\ speciel\ fremviserx + +menut Bookmarks\ and\ History Bogmærker\ og\ historik:echo "(disabled)" +menut Bookmark\ Current\ Directorymb Sæt\ bogmærke\ for\ nuværende\ mappemb +menut Goto\ Prev\ Dir\ (History)u GÃ¥\ til\ forrige\ mappe\ (historik)u +menut Goto\ Next\ Dir\ (History)U GÃ¥\ til\ næste\ mappe\ (historik)U +menut Listqb Oplistqb + +menut Browsing\ Control Gennemgangskontol +menut Horizontal\ Splito Vandret\ opdelingo +menut Vertical\ Splitv Lodret\ opdelingv +menut New\ Tabt Nyt\ fanebladt +menut Previewp ForhÃ¥ndsvisp +menut Edit\ File\ Hiding\ List Rediger\ liste\ til\ filskjulning +menut Edit\ Sorting\ SequenceS Rediger\ sorteringssekvensS +menut Quick\ Hide/Unhide\ Dot\ Filesgh Hurtig\ skjul/vis\ punktum-filergh +menut Refresh\ Listing Genopfrisk\ oplistning\ ikke sikker det med \ er korrekt +menut Settings/Options:NetrwSettings Indstillinger/valgmuligheder + +menut Delete\ File/DirectoryD Slet\ fil/mappeD + +menut Edit\ File/Dir Rediger\ fil/mappe +menut Create\ New\ File% Opret\ ny\ fil% +menut In\ Current\ Window I\ nuværende\ vindue +menut Preview\ File/Directoryp ForhÃ¥ndsvis\ fil/mappep +menut In\ Previous\ WindowP I\ forrige\ vindueP +menut In\ New\ Windowo I\ nyt\ vindueo +menut In\ New\ Tabt I\ nyt\ fanebladt +menut In\ New\ Vertical\ Windowv I\ nyt\ lodret\ vinduev + +menut Explore Gennemse +menut Directory\ Name Mappenavn:Explore +menut Filenames\ Matching\ Pattern\ (curdir\ only):Explore\ */ test29:Explore */ +menut Filenames\ Matching\ Pattern\ (+subdirs):Explore\ **/ test30:Explore **/ +menut Files\ Containing\ String\ Pattern\ (curdir\ only):Explore\ *// test31:Explore *// +menut Files\ Containing\ String\ Pattern\ (+subdirs):Explore\ **// test32:Explore **// +menut Next\ Match:Nexplore Næste\ match:Nexplore +menut Prev\ Match:Pexplore Forrige\ match:Pexplore + +menut Make\ Subdirectoryd Opret\ undermapped + +menut Marked\ Files Mærkede\ filer +menut Mark\ Filemf Mærk\ filmf +menut Mark\ Files\ by\ Regexpmr Mærk\ filer\ efter\ regulært\ udtrkmr +menut Hide-Show-List\ Controla test38a +menut Copy\ To\ Targetmc Kopiér\ til\ mÃ¥lmc +menut DeleteD SletD +menut Diffmd Diffmd +menut Editme Redigerme +menut Exe\ Cmdmx test43mx +menut Move\ To\ Targetmm Flyt\ til\ mÃ¥lmm +menut ObtainO IndhentO +menut Printmp Udskrivmp +menut ReplaceR ErstatR +menut Set\ Targetmt Sæt\ mÃ¥lmt +menut TagmT test49mT +menut Zip/Unzip/Compress/Uncompressmz Zip/unzip/komprimér/udpakmz + +menut Obtain\ FileO Indhent\ filO + +menut Style Stile +menut Listing Oplisting +menut thini tynd +menut longi lang +menut widei bred +menut treei træ +menut Normal-Hide-Show Normal-skjul-vis +menut Show\ Alla Vis\ alle +menut Normala Normal +menut Hidden\ Onlya Kun\ skulte +menut Reverse\ Sorting\ Order Omvendt\ sorteringsrækkefølge +menut Sorting\ Method Sorteringsmetode +menut Names Navn +menut Times Tidspunkt +menut Sizes Størrelse +menut Extens Endelse +menut Rename\ File/DirectoryR Omdøb\ fil/mappeR +menut Set\ Current\ Directoryc Sæt\ nuværende\ mappec + +menut History Historik + +menut Targets MÃ¥l + let &cpo = s:keepcpo unlet s:keepcpo diff --git a/runtime/syntax/8th.vim b/runtime/syntax/8th.vim new file mode 100644 index 0000000000..ddc1084c9f --- /dev/null +++ b/runtime/syntax/8th.vim @@ -0,0 +1,335 @@ +" Vim syntax file +" Language: 8th +" Version: 19.01d +" Maintainer: Ron Aaron +" URL: https://8th-dev.com/ +" Filetypes: *.8th +" NOTE: You should also have the ftplugin/8th.vim file to set 'isk' + +if version < 600 + syntax clear + finish +elseif exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim +syn clear +" Synchronization method +syn sync ccomment +syn sync maxlines=100 +syn case match +syn match eighthColonName "\S\+" contained +syn match eighthColonDef ":\s\+\S\+" contains=eighthColonName + +" new words +syn match eighthClasses "\<\S\+:" contained +syn match eighthClassWord "\<\S\+:.\+" contains=eighthClasses + +syn keyword eighthEndOfColonDef ; i; +syn keyword eighthDefine var var, + +" Built in words +com! -nargs=+ Builtin syn keyword eighthBuiltin +"Builtin ^ < <# <#> = > - -- ,# ; ;; ! ??? / . .# ' () @ * */ \ + +Builtin ! G:! #! G:#! ## G:## #> G:#> #if G:#if ' G:' ( G:( (* G:(* (:) G:(:) (code) G:(code) (getc) G:(getc) +Builtin (gets) G:(gets) (interp) G:(interp) (needs) G:(needs) (putc) G:(putc) (puts) G:(puts) (putslim) G:(putslim) +Builtin (say) G:(say) (stat) G:(stat) ) G:) +listener G:+listener +ref G:+ref ,# G:,# -- G:-- -----BEGIN G:-----BEGIN +Builtin -Inf G:-Inf -Inf? G:-Inf? -listener G:-listener -ref G:-ref -rot G:-rot . G:. .# G:.# .needs G:.needs +Builtin .r G:.r .s G:.s .stats G:.stats .ver G:.ver .with G:.with 0; G:0; 2dip G:2dip 2drop G:2drop +Builtin 2dup G:2dup 2over G:2over 2swap G:2swap 3drop G:3drop 4drop G:4drop 8thdt? G:8thdt? 8thver? G:8thver? +Builtin : G:: ; G:; ;; G:;; ;;; G:;;; ;then G:;then ;with G:;with <# G:<# <#> G:<#> >clip G:>clip >json G:>json +Builtin >kind G:>kind >n G:>n >r G:>r >s G:>s ?: G:?: ??? G:??? @ G:@ Inf G:Inf Inf? G:Inf? NaN G:NaN +Builtin NaN? G:NaN? SED-CHECK G:SED-CHECK SED: G:SED: SED: G:SED: \ G:\ ` G:` `` G:`` actor: G:actor: +Builtin again G:again ahead G:ahead and G:and appname G:appname apropos G:apropos argc G:argc args G:args +Builtin array? G:array? assert G:assert base G:base bi G:bi bits G:bits break G:break break? G:break? +Builtin build? G:build? buildver? G:buildver? bye G:bye c# G:c# c/does G:c/does case G:case caseof G:caseof +Builtin chdir G:chdir clip> G:clip> clone G:clone clone-shallow G:clone-shallow cold G:cold compat-level G:compat-level +Builtin compile G:compile compile? G:compile? conflict G:conflict const G:const container? G:container? +Builtin cr G:cr curlang G:curlang curry G:curry curry: G:curry: decimal G:decimal defer: G:defer: deg>rad G:deg>rad +Builtin depth G:depth die G:die dip G:dip drop G:drop dstack G:dstack dump G:dump dup G:dup dup? G:dup? +Builtin else G:else enum: G:enum: eval G:eval eval! G:eval! eval0 G:eval0 execnull G:execnull expect G:expect +Builtin extra! G:extra! extra@ G:extra@ false G:false fnv G:fnv fourth G:fourth free G:free func: G:func: +Builtin getc G:getc getcwd G:getcwd getenv G:getenv gets G:gets handler G:handler header G:header help G:help +Builtin hex G:hex i: G:i: i; G:i; if G:if if; G:if; isa? G:isa? items-used G:items-used jcall G:jcall +Builtin jclass G:jclass jmethod G:jmethod json-nesting G:json-nesting json-pretty G:json-pretty json-throw G:json-throw +Builtin json> G:json> k32 G:k32 keep G:keep l: G:l: last G:last lib G:lib libbin G:libbin libc G:libc +Builtin listener@ G:listener@ literal G:literal locals: G:locals: lock G:lock lock-to G:lock-to locked? G:locked? +Builtin log G:log log-async G:log-async log-task G:log-task log-time G:log-time log-time-local G:log-time-local +Builtin long-days G:long-days long-months G:long-months loop G:loop loop- G:loop- map? G:map? mark G:mark +Builtin mark? G:mark? memfree G:memfree mobile? G:mobile? n# G:n# name>os G:name>os name>sem G:name>sem +Builtin ndrop G:ndrop needs G:needs new G:new next-arg G:next-arg nip G:nip noop G:noop not G:not ns G:ns +Builtin ns: G:ns: ns>ls G:ns>ls ns>s G:ns>s ns? G:ns? null G:null null; G:null; null? G:null? number? G:number? +Builtin off G:off on G:on onexit G:onexit only G:only op! G:op! or G:or os G:os os-names G:os-names +Builtin os>long-name G:os>long-name os>name G:os>name over G:over p: G:p: pack G:pack parse G:parse +Builtin parsech G:parsech parseln G:parseln parsews G:parsews pick G:pick poke G:poke pool-clear G:pool-clear +Builtin prior G:prior private G:private process-args G:process-args prompt G:prompt public G:public +Builtin putc G:putc puts G:puts putslim G:putslim quote G:quote r! G:r! r> G:r> r@ G:r@ rad>deg G:rad>deg +Builtin rand G:rand rand-pcg G:rand-pcg rand-pcg-seed G:rand-pcg-seed randbuf G:randbuf randbuf-pcg G:randbuf-pcg +Builtin rdrop G:rdrop recurse G:recurse recurse-stack G:recurse-stack ref@ G:ref@ reg! G:reg! reg@ G:reg@ +Builtin regbin@ G:regbin@ remaining-args G:remaining-args repeat G:repeat reset G:reset roll G:roll +Builtin rop! G:rop! rot G:rot rpick G:rpick rroll G:rroll rstack G:rstack rswap G:rswap rusage G:rusage +Builtin s>ns G:s>ns same? G:same? scriptdir G:scriptdir scriptfile G:scriptfile sem G:sem sem-post G:sem-post +Builtin sem-rm G:sem-rm sem-wait G:sem-wait sem-wait? G:sem-wait? sem>name G:sem>name semi-throw G:semi-throw +Builtin set-wipe G:set-wipe setenv G:setenv settings! G:settings! settings![] G:settings![] settings@ G:settings@ +Builtin settings@? G:settings@? settings@[] G:settings@[] sh G:sh sh$ G:sh$ short-days G:short-days +Builtin short-months G:short-months sleep G:sleep space G:space stack-check G:stack-check stack-size G:stack-size +Builtin step G:step string? G:string? struct: G:struct: swap G:swap syslang G:syslang sysregion G:sysregion +Builtin tab-hook G:tab-hook tell-conflict G:tell-conflict tempdir G:tempdir tempfilename G:tempfilename +Builtin then G:then third G:third throw G:throw thrownull G:thrownull times G:times tlog G:tlog tri G:tri +Builtin true G:true tuck G:tuck type-check G:type-check typeassert G:typeassert unlock G:unlock unpack G:unpack +Builtin until G:until until! G:until! var G:var var, G:var, while G:while while! G:while! with: G:with: +Builtin words G:words words-like G:words-like words/ G:words/ xchg G:xchg xor G:xor >auth HTTP:>auth +Builtin sh I:sh tpush I:tpush trace-word I:trace-word call JSONRPC:call auth-string OAuth:auth-string +Builtin gen-nonce OAuth:gen-nonce params OAuth:params call SOAP:call ! a:! + a:+ - a:- 2each a:2each +Builtin 2map a:2map 2map+ a:2map+ 2map= a:2map= = a:= >map a:>map @ a:@ @@ a:@@ bsearch a:bsearch clear a:clear +Builtin close a:close diff a:diff dot a:dot each a:each each-slice a:each-slice exists? a:exists? filter a:filter +Builtin generate a:generate group a:group indexof a:indexof insert a:insert intersect a:intersect join a:join +Builtin len a:len map a:map map+ a:map+ map= a:map= mean a:mean mean&variance a:mean&variance new a:new +Builtin op a:op op! a:op! op= a:op= open a:open pop a:pop push a:push qsort a:qsort randeach a:randeach +Builtin reduce a:reduce reduce+ a:reduce+ rev a:rev shift a:shift shuffle a:shuffle slice a:slice slice+ a:slice+ +Builtin slide a:slide sort a:sort union a:union when a:when when! a:when! x a:x x-each a:x-each xchg a:xchg +Builtin y a:y zip a:zip 8thdir app:8thdir asset app:asset atrun app:atrun atrun app:atrun atrun app:atrun +Builtin basedir app:basedir current app:current datadir app:datadir exename app:exename isgui app:isgui +Builtin main app:main oncrash app:oncrash orientation app:orientation pid app:pid restart app:restart +Builtin resumed app:resumed shared? app:shared? standalone app:standalone subdir app:subdir suspended app:suspended +Builtin sysquit app:sysquit (here) asm:(here) >n asm:>n avail asm:avail c, asm:c, here! asm:here! n> asm:n> +Builtin used asm:used w, asm:w, ! b:! + b:+ / b:/ = b:= >base64 b:>base64 >hex b:>hex >mpack b:>mpack +Builtin @ b:@ append b:append base64> b:base64> bit! b:bit! bit@ b:bit@ clear b:clear compress b:compress +Builtin conv b:conv each b:each each-slice b:each-slice expand b:expand fill b:fill getb b:getb hex> b:hex> +Builtin len b:len mem> b:mem> move b:move mpack-date b:mpack-date mpack-ignore b:mpack-ignore mpack> b:mpack> +Builtin new b:new op b:op rev b:rev search b:search shmem b:shmem slice b:slice splice b:splice ungetb b:ungetb +Builtin writable b:writable xor b:xor +block bc:+block .blocks bc:.blocks add-block bc:add-block block-hash bc:block-hash +Builtin block@ bc:block@ first-block bc:first-block hash bc:hash last-block bc:last-block load bc:load +Builtin new bc:new save bc:save set-sql bc:set-sql validate bc:validate validate-block bc:validate-block +Builtin add bloom:add filter bloom:filter in? bloom:in? accept bt:accept ch! bt:ch! ch@ bt:ch@ connect bt:connect +Builtin disconnect bt:disconnect err? bt:err? leconnect bt:leconnect lescan bt:lescan listen bt:listen +Builtin on? bt:on? read bt:read scan bt:scan service? bt:service? services? bt:services? write bt:write +Builtin * c:* * c:* + c:+ + c:+ = c:= = c:= >ri c:>ri >ri c:>ri abs c:abs abs c:abs arg c:arg arg c:arg +Builtin conj c:conj conj c:conj im c:im n> c:n> new c:new new c:new re c:re >aes128gcm cr:>aes128gcm +Builtin >aes256gcm cr:>aes256gcm >cp cr:>cp >cpe cr:>cpe >decrypt cr:>decrypt >edbox cr:>edbox >encrypt cr:>encrypt +Builtin >nbuf cr:>nbuf >rsabox cr:>rsabox >uuid cr:>uuid CBC cr:CBC CFB cr:CFB CTR cr:CTR ECB cr:ECB +Builtin GCM cr:GCM OFB cr:OFB aad? cr:aad? aes128box-sig cr:aes128box-sig aes128gcm> cr:aes128gcm> +Builtin aes256box-sig cr:aes256box-sig aes256gcm> cr:aes256gcm> aesgcm cr:aesgcm blakehash cr:blakehash +Builtin chacha20box-sig cr:chacha20box-sig chachapoly cr:chachapoly cipher! cr:cipher! cipher@ cr:cipher@ +Builtin cp> cr:cp> cpe> cr:cpe> decrypt cr:decrypt decrypt+ cr:decrypt+ decrypt> cr:decrypt> dh-genkey cr:dh-genkey +Builtin dh-secret cr:dh-secret dh-sign cr:dh-sign dh-verify cr:dh-verify ebox-sig cr:ebox-sig ecc-genkey cr:ecc-genkey +Builtin ecc-secret cr:ecc-secret ecc-sign cr:ecc-sign ecc-verify cr:ecc-verify edbox-sig cr:edbox-sig +Builtin edbox> cr:edbox> encrypt cr:encrypt encrypt+ cr:encrypt+ encrypt> cr:encrypt> ensurekey cr:ensurekey +Builtin err? cr:err? gcm-tag-size cr:gcm-tag-size genkey cr:genkey hash cr:hash hash! cr:hash! hash+ cr:hash+ +Builtin hash>b cr:hash>b hash>s cr:hash>s hash@ cr:hash@ hmac cr:hmac hotp cr:hotp iv? cr:iv? mode cr:mode +Builtin mode@ cr:mode@ randkey cr:randkey restore cr:restore root-certs cr:root-certs rsa_decrypt cr:rsa_decrypt +Builtin rsa_encrypt cr:rsa_encrypt rsa_sign cr:rsa_sign rsa_verify cr:rsa_verify rsabox-sig cr:rsabox-sig +Builtin rsabox> cr:rsabox> rsagenkey cr:rsagenkey save cr:save sbox-sig cr:sbox-sig sha1-hmac cr:sha1-hmac +Builtin shard cr:shard tag? cr:tag? totp cr:totp totp-epoch cr:totp-epoch totp-time-step cr:totp-time-step +Builtin unshard cr:unshard uuid cr:uuid uuid> cr:uuid> validate-pgp-sig cr:validate-pgp-sig (.hebrew) d:(.hebrew) +Builtin (.islamic) d:(.islamic) + d:+ +day d:+day +hour d:+hour +min d:+min +msec d:+msec - d:- .hebrew d:.hebrew +Builtin .islamic d:.islamic .time d:.time / d:/ = d:= >fixed d:>fixed >hebepoch d:>hebepoch >msec d:>msec +Builtin >unix d:>unix >ymd d:>ymd Adar d:Adar Adar2 d:Adar2 Adar2 d:Adar2 Av d:Av Elul d:Elul Fri d:Fri +Builtin Heshvan d:Heshvan Iyar d:Iyar Kislev d:Kislev Mon d:Mon Nissan d:Nissan Sat d:Sat Shevat d:Shevat +Builtin Sivan d:Sivan Sun d:Sun Tammuz d:Tammuz Tevet d:Tevet Thu d:Thu Tishrei d:Tishrei Tue d:Tue +Builtin Wed d:Wed adjust-dst d:adjust-dst between d:between d. d:d. dawn d:dawn days-in-hebrew-year d:days-in-hebrew-year +Builtin displaying-hebrew d:displaying-hebrew do-dawn d:do-dawn do-dusk d:do-dusk do-rise d:do-rise +Builtin doy d:doy dst? d:dst? dstquery d:dstquery dstzones? d:dstzones? dusk d:dusk elapsed-timer d:elapsed-timer +Builtin elapsed-timer-seconds d:elapsed-timer-seconds first-dow d:first-dow fixed> d:fixed> fixed>dow d:fixed>dow +Builtin fixed>hebrew d:fixed>hebrew fixed>islamic d:fixed>islamic format d:format hanukkah d:hanukkah +Builtin hebrew-epoch d:hebrew-epoch hebrew>fixed d:hebrew>fixed hebrewtoday d:hebrewtoday hmonth-name d:hmonth-name +Builtin islamic.epoch d:islamic.epoch islamic>fixed d:islamic>fixed islamictoday d:islamictoday join d:join +Builtin last-day-of-hebrew-month d:last-day-of-hebrew-month last-dow d:last-dow last-month d:last-month +Builtin last-week d:last-week last-year d:last-year latitude d:latitude longitude d:longitude longitude d:longitude +Builtin msec d:msec msec> d:msec> new d:new next-dow d:next-dow next-month d:next-month next-week d:next-week +Builtin next-year d:next-year number>hebrew d:number>hebrew omer d:omer parse d:parse pesach d:pesach +Builtin prev-dow d:prev-dow purim d:purim rosh-chodesh? d:rosh-chodesh? rosh-hashanah d:rosh-hashanah +Builtin shavuot d:shavuot start-timer d:start-timer sunrise d:sunrise taanit-esther d:taanit-esther +Builtin ticks d:ticks ticks/sec d:ticks/sec timer d:timer tisha-beav d:tisha-beav tzadjust d:tzadjust +Builtin unix> d:unix> updatetz d:updatetz year@ d:year@ ymd d:ymd ymd> d:ymd> yom-haatsmaut d:yom-haatsmaut +Builtin yom-kippur d:yom-kippur add-func db:add-func bind db:bind close db:close col db:col col[] db:col[] +Builtin col{} db:col{} err? db:err? errmsg db:errmsg exec db:exec exec-cb db:exec-cb key db:key mysql? db:mysql? +Builtin odbc? db:odbc? open db:open open? db:open? prepare db:prepare query db:query query-all db:query-all +Builtin rekey db:rekey sqlerrmsg db:sqlerrmsg bp dbg:bp except-task@ dbg:except-task@ go dbg:go line-info dbg:line-info +Builtin prompt dbg:prompt stop dbg:stop trace dbg:trace trace-enter dbg:trace-enter trace-leave dbg:trace-leave +Builtin abspath f:abspath append f:append associate f:associate atime f:atime canwrite? f:canwrite? +Builtin chmod f:chmod close f:close copy f:copy copydir f:copydir create f:create ctime f:ctime dir? f:dir? +Builtin dname f:dname eachbuf f:eachbuf eachline f:eachline enssep f:enssep eof? f:eof? err? f:err? +Builtin exists? f:exists? flush f:flush fname f:fname getb f:getb getc f:getc getline f:getline getmod f:getmod +Builtin glob f:glob glob-nocase f:glob-nocase include f:include launch f:launch link f:link link> f:link> +Builtin link? f:link? mkdir f:mkdir mmap f:mmap mmap-range f:mmap-range mmap-range? f:mmap-range? mtime f:mtime +Builtin mv f:mv open f:open open-ro f:open-ro popen f:popen print f:print read f:read relpath f:relpath +Builtin rglob f:rglob rm f:rm rmdir f:rmdir seek f:seek sep f:sep show f:show size f:size slurp f:slurp +Builtin stderr f:stderr stdin f:stdin stdout f:stdout tell f:tell times f:times trash f:trash ungetb f:ungetb +Builtin ungetc f:ungetc unzip f:unzip unzip-entry f:unzip-entry watch f:watch write f:write writen f:writen +Builtin zip+ f:zip+ zip@ f:zip@ zipentry f:zipentry zipnew f:zipnew zipopen f:zipopen zipsave f:zipsave +Builtin bold font:bold face? font:face? glyph-path font:glyph-path glyph-pos font:glyph-pos info font:info +Builtin italic font:italic ls font:ls measure font:measure new font:new pixels font:pixels pixels? font:pixels? +Builtin points font:points points? font:points? styles font:styles styles? font:styles? underline font:underline +Builtin +child g:+child +kind g:+kind +path g:+path -child g:-child /path g:/path >img g:>img >progress g:>progress +Builtin add-items g:add-items adjustwidth g:adjustwidth allow-orient g:allow-orient arc g:arc arc2 g:arc2 +Builtin autohide g:autohide back g:back bezier g:bezier bg g:bg bg? g:bg? bounds g:bounds bounds? g:bounds? +Builtin box-label g:box-label btn-font g:btn-font bubble g:bubble button-size g:button-size buttons-visible g:buttons-visible +Builtin c-text g:c-text callout g:callout center g:center child g:child clear g:clear clearpath g:clearpath +Builtin clr>n g:clr>n coleven g:coleven colordlg g:colordlg colwidth g:colwidth connectededges g:connectededges +Builtin contrasting g:contrasting cp g:cp curmouse? g:curmouse? default-font g:default-font deselect-row g:deselect-row +Builtin dismiss g:dismiss do g:do draw-fitted-text g:draw-fitted-text draw-text g:draw-text draw-text-at g:draw-text-at +Builtin each g:each edit-on-double-click g:edit-on-double-click editable g:editable editdlg g:editdlg +Builtin empty-text g:empty-text enable g:enable enabled? g:enabled? fade g:fade fb-files g:fb-files +Builtin fcolor g:fcolor fg g:fg fg? g:fg? file-filter g:file-filter file-name g:file-name filedlg g:filedlg +Builtin fill g:fill fillall g:fillall fit-text g:fit-text flex! g:flex! focus g:focus fontdlg g:fontdlg +Builtin forward g:forward fullscreen g:fullscreen get-lasso-items g:get-lasso-items get-tab g:get-tab +Builtin getclr g:getclr getfont g:getfont getimage g:getimage getpath g:getpath getroot g:getroot gradient g:gradient +Builtin gui? g:gui? handle g:handle headerheight g:headerheight hide g:hide image g:image image-at g:image-at +Builtin invalidate g:invalidate ix? g:ix? justify g:justify keyinfo g:keyinfo l-text g:l-text laf g:laf +Builtin laf! g:laf! laf? g:laf? len g:len line-width g:line-width lineto g:lineto list+ g:list+ list- g:list- +Builtin loadcontent g:loadcontent localize g:localize m! g:m! m@ g:m@ menu-font g:menu-font menu-update g:menu-update +Builtin menuenabled g:menuenabled mouse? g:mouse? mousepos? g:mousepos? moveto g:moveto msgdlg g:msgdlg +Builtin multi g:multi name g:name named-skin g:named-skin new g:new new-laf g:new-laf next g:next obj g:obj +Builtin on g:on on? g:on? ontop g:ontop oshandle g:oshandle outlinethickness g:outlinethickness panel-size g:panel-size +Builtin panel-size? g:panel-size? parent g:parent path g:path path>s g:path>s pie g:pie pix! g:pix! +Builtin pop g:pop popmenu g:popmenu pos? g:pos? prev g:prev propval! g:propval! propval@ g:propval@ +Builtin push g:push qbezier g:qbezier quit g:quit r-text g:r-text readonly g:readonly rect g:rect refresh g:refresh +Builtin restore g:restore root g:root root-item-visible g:root-item-visible rotate g:rotate rowheight g:rowheight +Builtin rrect g:rrect s>path g:s>path save g:save say g:say scale g:scale scolor g:scolor scrollthickness g:scrollthickness +Builtin sectionenable g:sectionenable select! g:select! select@ g:select@ selected-rows g:selected-rows +Builtin set-lasso g:set-lasso set-long-press g:set-long-press set-popup-font g:set-popup-font set-range g:set-range +Builtin set-swipe g:set-swipe set-value g:set-value setcursor g:setcursor setfont g:setfont setheader g:setheader +Builtin sethtml g:sethtml setimage g:setimage setname g:setname setroot g:setroot settab g:settab show g:show +Builtin show-line-numbers g:show-line-numbers show-pct g:show-pct showmenu g:showmenu showtooltip g:showtooltip +Builtin size g:size size? g:size? skin g:skin skin-class g:skin-class stackix g:stackix state g:state +Builtin state? g:state? stepsize g:stepsize stroke g:stroke stroke-fill g:stroke-fill style g:style +Builtin tabname g:tabname text g:text text-box-style g:text-box-style text? g:text? textcolor g:textcolor +Builtin textsize g:textsize timer! g:timer! timer@ g:timer@ toback g:toback tofront g:tofront toggle-row g:toggle-row +Builtin tooltip g:tooltip top g:top transition g:transition translate g:translate tree-open g:tree-open +Builtin triangle g:triangle update g:update updateitems g:updateitems url g:url user g:user user! g:user! +Builtin vertical g:vertical view g:view visible? g:visible? vpos! g:vpos! vpos@ g:vpos@ waitcursor g:waitcursor +Builtin winding g:winding xy g:xy xy? g:xy? +edge gr:+edge +edge+w gr:+edge+w +node gr:+node connect gr:connect +Builtin edges gr:edges m! gr:m! m@ gr:m@ neighbors gr:neighbors new gr:new node-edges gr:node-edges +Builtin nodes gr:nodes traverse gr:traverse + h:+ clear h:clear len h:len new h:new peek h:peek pop h:pop +Builtin push h:push unique h:unique arm? hw:arm? camera hw:camera camera-fmt hw:camera-fmt camera-img hw:camera-img +Builtin camera? hw:camera? cpu? hw:cpu? device? hw:device? displays? hw:displays? displaysize? hw:displaysize? +Builtin err? hw:err? gpio hw:gpio gpio! hw:gpio! gpio-mmap hw:gpio-mmap gpio@ hw:gpio@ i2c hw:i2c i2c! hw:i2c! +Builtin i2c!reg hw:i2c!reg i2c@ hw:i2c@ i2c@reg hw:i2c@reg isround? hw:isround? iswatch? hw:iswatch? +Builtin mac? hw:mac? mem? hw:mem? poll hw:poll sensor hw:sensor start hw:start stop hw:stop fetch-full imap:fetch-full +Builtin fetch-uid-mail imap:fetch-uid-mail login imap:login new imap:new select-inbox imap:select-inbox +Builtin >file img:>file copy img:copy crop img:crop data img:data desat img:desat fill img:fill filter img:filter +Builtin flip img:flip from-svg img:from-svg new img:new pix! img:pix! pix@ img:pix@ qr-gen img:qr-gen +Builtin qr-parse img:qr-parse rotate img:rotate scale img:scale scroll img:scroll size img:size countries iso:countries +Builtin find loc:find sort loc:sort ! m:! !? m:!? + m:+ +? m:+? - m:- @ m:@ @? m:@? @@ m:@@ clear m:clear +Builtin data m:data each m:each exists? m:exists? iter m:iter iter-all m:iter-all keys m:keys len m:len +Builtin map m:map new m:new op! m:op! open m:open vals m:vals xchg m:xchg ! mat:! * mat:* + mat:+ = mat:= +Builtin @ mat:@ col mat:col data mat:data det mat:det dim? mat:dim? get-n mat:get-n ident mat:ident +Builtin m. mat:m. minor mat:minor n* mat:n* new mat:new row mat:row same-size? mat:same-size? trans mat:trans +Builtin ! n:! * n:* */ n:*/ + n:+ +! n:+! - n:- / n:/ /mod n:/mod 1+ n:1+ 1- n:1- < n:< = n:= > n:> +Builtin BIGE n:BIGE BIGPI n:BIGPI E n:E PI n:PI ^ n:^ abs n:abs acos n:acos acos n:acos asin n:asin +Builtin asin n:asin atan n:atan atan n:atan atan2 n:atan2 band n:band between n:between bfloat n:bfloat +Builtin bic n:bic bint n:bint binv n:binv bnot n:bnot bor n:bor bxor n:bxor ceil n:ceil clamp n:clamp +Builtin cmp n:cmp comb n:comb cos n:cos cosd n:cosd exp n:exp expmod n:expmod float n:float floor n:floor +Builtin fmod n:fmod frac n:frac gcd n:gcd int n:int invmod n:invmod kind? n:kind? lcm n:lcm ln n:ln +Builtin max n:max median n:median min n:min mod n:mod neg n:neg odd? n:odd? perm n:perm prime? n:prime? +Builtin quantize n:quantize quantize! n:quantize! r+ n:r+ range n:range rot32l n:rot32l rot32r n:rot32r +Builtin round n:round round2 n:round2 running-variance n:running-variance running-variance-finalize n:running-variance-finalize +Builtin sgn n:sgn shl n:shl shr n:shr sin n:sin sind n:sind sqr n:sqr sqrt n:sqrt tan n:tan tand n:tand +Builtin trunc n:trunc ~= n:~= ! net:! >url net:>url @ net:@ DGRAM net:DGRAM INET4 net:INET4 INET6 net:INET6 +Builtin PROTO_TCP net:PROTO_TCP PROTO_UDP net:PROTO_UDP STREAM net:STREAM accept net:accept addrinfo>o net:addrinfo>o +Builtin again? net:again? alloc-and-read net:alloc-and-read alloc-buf net:alloc-buf bind net:bind browse net:browse +Builtin close net:close connect net:connect err>s net:err>s err? net:err? get net:get getaddrinfo net:getaddrinfo +Builtin getpeername net:getpeername head net:head ifaces? net:ifaces? listen net:listen net-socket net:net-socket +Builtin opts net:opts port-is-ssl? net:port-is-ssl? post net:post proxy! net:proxy! read net:read recvfrom net:recvfrom +Builtin s>url net:s>url sendto net:sendto server net:server setsockopt net:setsockopt socket net:socket +Builtin tlshello net:tlshello url> net:url> user-agent net:user-agent wait net:wait write net:write +Builtin MAX ns:MAX cast ptr:cast len ptr:len pack ptr:pack unpack ptr:unpack unpack_orig ptr:unpack_orig +Builtin + q:+ clear q:clear len q:len new q:new notify q:notify overwrite q:overwrite peek q:peek pick q:pick +Builtin pop q:pop push q:push shift q:shift size q:size slide q:slide throwing q:throwing wait q:wait +Builtin ++match r:++match +/ r:+/ +match r:+match / r:/ @ r:@ err? r:err? len r:len match r:match new r:new +Builtin rx r:rx str r:str ! s:! * s:* + s:+ - s:- / s:/ /scripts s:/scripts <+ s:<+ = s:= =ic s:=ic +Builtin >base64 s:>base64 >ucs2 s:>ucs2 @ s:@ append s:append base64> s:base64> clear s:clear cmp s:cmp +Builtin cmpi s:cmpi compress s:compress days! s:days! each s:each eachline s:eachline expand s:expand +Builtin fill s:fill fmt s:fmt gershayim s:gershayim globmatch s:globmatch hexupr s:hexupr insert s:insert +Builtin intl s:intl intl! s:intl! lang s:lang lc s:lc len s:len lsub s:lsub ltrim s:ltrim map s:map +Builtin months! s:months! new s:new replace s:replace replace! s:replace! rev s:rev rsearch s:rsearch +Builtin rsub s:rsub rtrim s:rtrim script? s:script? search s:search size s:size slice s:slice strfmap s:strfmap +Builtin strfmt s:strfmt trim s:trim tsub s:tsub uc s:uc ucs2> s:ucs2> utf8? s:utf8? zt s:zt close sio:close +Builtin enum sio:enum open sio:open opts! sio:opts! opts@ sio:opts@ read sio:read write sio:write new smtp:new +Builtin send smtp:send apply-filter snd:apply-filter devices? snd:devices? end-record snd:end-record +Builtin filter snd:filter formats? snd:formats? freq snd:freq gain snd:gain gain? snd:gain? len snd:len +Builtin loop snd:loop mix snd:mix new snd:new pause snd:pause play snd:play played snd:played rate snd:rate +Builtin record snd:record seek snd:seek stop snd:stop stopall snd:stopall unmix snd:unmix volume snd:volume +Builtin volume? snd:volume? + st:+ . st:. clear st:clear len st:len ndrop st:ndrop new st:new op! st:op! +Builtin peek st:peek pick st:pick pop st:pop push st:push roll st:roll shift st:shift size st:size +Builtin slide st:slide swap st:swap throwing st:throwing >buf struct:>buf arr> struct:arr> buf struct:buf +Builtin buf> struct:buf> byte struct:byte double struct:double field! struct:field! field@ struct:field@ +Builtin float struct:float ignore struct:ignore int struct:int long struct:long struct; struct:struct; +Builtin word struct:word ! t:! @ t:@ assign t:assign curtask t:curtask def-queue t:def-queue def-stack t:def-stack +Builtin done? t:done? err! t:err! err? t:err? getq t:getq guitask t:guitask handler t:handler kill t:kill +Builtin list t:list main t:main name! t:name! name@ t:name@ notify t:notify pop t:pop priority t:priority +Builtin push t:push push< t:push< q-notify t:q-notify q-wait t:q-wait qlen t:qlen result t:result task t:task +Builtin task-n t:task-n task-stop t:task-stop wait t:wait ! w:! @ w:@ alias: w:alias: cb w:cb deprecate w:deprecate +Builtin exec w:exec exec? w:exec? ffifail w:ffifail find w:find forget w:forget is w:is undo w:undo +Builtin >s xml:>s >txt xml:>txt parse xml:parse parse-html xml:parse-html parse-stream xml:parse-stream +Builtin getmsg[] zmq:getmsg[] sendmsg[] zmq:sendmsg[] +" numbers +syn keyword eighthMath decimal hex base@ base! +syn match eighthInteger '\<-\=[0-9.]*[0-9.]\+\>' +" recognize hex and binary numbers, the '$' and '%' notation is for eighth +syn match eighthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess +syn match eighthInteger '\<\x*\d\x*\>' " *2* --- this order! +syn match eighthInteger '\<%[0-1]*[0-1]\+\>' +syn match eighthInteger "\<'.\>" + +" Strings +syn region eighthString start=+\.\?\"+ skip=+"+ end=+$+ +syn keyword jsonNull null +syn keyword jsonBool /\(true\|false\)/ + syn region eighthString start=/\<"/ end=/"\>/ +syn match jsonObjEntry /"\"[^"]\+\"\ze\s*:/ + +"syn region jsonObject start=/{/ end=/}/ contained contains=jsonObjEntry,jsonArray,jsonObject, jsonBool, eighthString +"syn region jsonArray start=/\[/ end=/\]/ contained contains=jsonArray,jsonObject, jsonBool, eighthString + +" Include files +" syn match eighthInclude '\<\(libinclude\|include\|needs\)\s\+\S\+' +syn region eighthComment start="\zs\\" end="$" contains=eighthTodo + +" Define the default highlighting. +if !exists("did_eighth_syntax_inits") + let did_eighth_syntax_inits=1 + " The default methods for highlighting. Can be overriden later. + hi def link eighthTodo Todo + hi def link eighthOperators Operator + hi def link eighthMath Number + hi def link eighthInteger Number + hi def link eighthStack Special + hi def link eighthFStack Special + hi def link eighthSP Special + hi def link eighthColonDef Define + hi def link eighthColonName Operator + hi def link eighthEndOfColonDef Define + hi def link eighthDefine Define + hi def link eighthDebug Debug + hi def link eighthCharOps Character + hi def link eighthConversion String + hi def link eighthForth Statement + hi def link eighthVocs Statement + hi def link eighthString String + hi def link eighthComment Comment + hi def link eighthClassDef Define + hi def link eighthEndOfClassDef Define + hi def link eighthObjectDef Define + hi def link eighthEndOfObjectDef Define + hi def link eighthInclude Include + hi def link eighthBuiltin Define + hi def link eighthClasses Define + hi def link eighthClassWord Keyword + + hi def link jsonObject Delimiter + hi def link jsonObjEntry Label + hi def link jsonArray Special + hi def link jsonNull Function + hi def link jsonBool Boolean +endif + +let b:current_syntax = "8th" +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: ts=8:sw=4:nocindent:smartindent: diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index 95d3455dde..2eb7881f67 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2018 Sep 21 +" Last Change: 2019 Feb 11 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -342,7 +342,7 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") syn keyword cConstant EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE syn keyword cConstant EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA syn keyword cConstant ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENOPROTOOPT ENOSPC ENOSR - syn keyword cConstant ENOSTR ENOSYS ENOTCONN ENOTDIR ENOTEMPTY ENOTRECOVERABLE ENOTSOCK ENOTSUP + syn keyword cConstant ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTRECOVERABLE ENOTSOCK ENOTSUP syn keyword cConstant ENOTTY ENXIO EOPNOTSUPP EOVERFLOW EOWNERDEAD EPERM EPIPE EPROTO syn keyword cConstant EPROTONOSUPPORT EPROTOTYPE ERANGE EROFS ESPIPE ESRCH ESTALE ETIME ETIMEDOUT syn keyword cConstant ETXTBSY EWOULDBLOCK EXDEV diff --git a/runtime/syntax/make.vim b/runtime/syntax/make.vim index 7072bab988..16e66bc8f2 100644 --- a/runtime/syntax/make.vim +++ b/runtime/syntax/make.vim @@ -1,8 +1,9 @@ " Vim syntax file " Language: Makefile -" Maintainer: Claudio Fleiner -" URL: http://www.fleiner.com/vim/syntax/make.vim -" Last Change: 2015 Feb 28 +" Maintainer: Roland Hieber +" Previous Maintainer: Claudio Fleiner +" URL: https://github.com/vim/vim/syntax/make.vim +" Last Change: 2019 Feb 08 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -64,7 +65,7 @@ syn match makeCmdNextLine "\\\n."he=e-1 contained " Statements / Functions (GNU make) -syn match makeStatement contained "(\(subst\|abspath\|addprefix\|addsuffix\|and\|basename\|call\|dir\|error\|eval\|filter-out\|filter\|findstring\|firstword\|flavor\|foreach\|if\|info\|join\|lastword\|notdir\|or\|origin\|patsubst\|realpath\|shell\|sort\|strip\|suffix\|value\|warning\|wildcard\|word\|wordlist\|words\)\>"ms=s+1 +syn match makeStatement contained "(\(abspath\|addprefix\|addsuffix\|and\|basename\|call\|dir\|error\|eval\|file\|filter-out\|filter\|findstring\|firstword\|flavor\|foreach\|guile\|if\|info\|join\|lastword\|notdir\|or\|origin\|patsubst\|realpath\|shell\|sort\|strip\|subst\|suffix\|value\|warning\|wildcard\|word\|wordlist\|words\)\>"ms=s+1 " Comment if exists("make_microsoft") diff --git a/runtime/syntax/spec.vim b/runtime/syntax/spec.vim index 3a7dc9e422..ae93fe51a4 100644 --- a/runtime/syntax/spec.vim +++ b/runtime/syntax/spec.vim @@ -3,7 +3,7 @@ " Language: SPEC: Build/install scripts for Linux RPM packages " Maintainer: Igor Gnatenko i.gnatenko.brain@gmail.com " Former Maintainer: Donovan Rebbechi elflord@panix.com (until March 2014) -" Last Change: Sat Apr 9 15:30 2016 Filip SzymaÅ„ski +" Last Change: 2019 Feb 12 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -86,9 +86,9 @@ syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start "%% Files Section %% "TODO %config valid parameters: missingok\|noreplace "TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\) -syn region specFilesArea matchgroup=specSection start='^%[Ff][Ii][Ll][Ee][Ss]\>' skip='%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\)\>' end='^%[a-zA-Z]'me=e-2 contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier +syn region specFilesArea matchgroup=specSection start='^%[Ff][Ii][Ll][Ee][Ss]\>' skip='%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\)\>' end='^%[a-zA-Z]'me=e-2 contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier "tip: remember to include new itens in specFilesArea above -syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\)\>' +syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\)\>' "valid options for certain section headers syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1 diff --git a/runtime/tutor/tutor b/runtime/tutor/tutor index c076e3bfdc..426fb57569 100644 --- a/runtime/tutor/tutor +++ b/runtime/tutor/tutor @@ -99,7 +99,7 @@ NOTE: As you go through this tutor, do not try to memorize, learn by usage. 1. Move the cursor to the first line below marked --->. 2. To make the first line the same as the second, move the cursor on top - of the first character AFTER where the text is to be inserted. + of the character BEFORE which the text is to be inserted. 3. Press i and type in the necessary additions. diff --git a/runtime/tutor/tutor.da b/runtime/tutor/tutor.da index 8a874d3274..fe72405cc0 100644 --- a/runtime/tutor/tutor.da +++ b/runtime/tutor/tutor.da @@ -967,6 +967,6 @@ BEM Ændret til Vim af Bram Moolenaar. - Oversat til dansk af scootergrisen. + Oversat af scootergrisen. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/runtime/tutor/tutor.da.utf-8 b/runtime/tutor/tutor.da.utf-8 index 407170edec..fc46d977b8 100644 --- a/runtime/tutor/tutor.da.utf-8 +++ b/runtime/tutor/tutor.da.utf-8 @@ -967,6 +967,6 @@ BEMÆRK: Fuldførelse virker til mange kommandoer. Prøv blot at trykke pÃ¥ Ændret til Vim af Bram Moolenaar. - Oversat til dansk af scootergrisen. + Oversat af scootergrisen. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/runtime/tutor/tutor.nl b/runtime/tutor/tutor.nl index 7b4d392e30..3afa8a583d 100644 --- a/runtime/tutor/tutor.nl +++ b/runtime/tutor/tutor.nl @@ -100,7 +100,7 @@ 1. Ga met de cursor naar de eerste regel verderop met --->. 2. Maak de eerste regel gelijk aan de tweede. Zet daarvoor de cursor op - de plaats waar tekst moet worden ingevoegd. + het karakter waarvoor tekst moet worden ingevoegd. 3. Tik i en daarna de nodige aanvullingen. diff --git a/runtime/tutor/tutor.nl.utf-8 b/runtime/tutor/tutor.nl.utf-8 index 715c8d3d7f..2884ce3149 100644 --- a/runtime/tutor/tutor.nl.utf-8 +++ b/runtime/tutor/tutor.nl.utf-8 @@ -100,7 +100,7 @@ 1. Ga met de cursor naar de eerste regel verderop met --->. 2. Maak de eerste regel gelijk aan de tweede. Zet daarvoor de cursor op - de plaats waar tekst moet worden ingevoegd. + het karakter waarvoor tekst moet worden ingevoegd. 3. Tik i en daarna de nodige aanvullingen. diff --git a/runtime/tutor/tutor.utf-8 b/runtime/tutor/tutor.utf-8 index c076e3bfdc..426fb57569 100644 --- a/runtime/tutor/tutor.utf-8 +++ b/runtime/tutor/tutor.utf-8 @@ -99,7 +99,7 @@ NOTE: As you go through this tutor, do not try to memorize, learn by usage. 1. Move the cursor to the first line below marked --->. 2. To make the first line the same as the second, move the cursor on top - of the first character AFTER where the text is to be inserted. + of the character BEFORE which the text is to be inserted. 3. Press i and type in the necessary additions. diff --git a/src/po/da.po b/src/po/da.po index f5e11da004..b45a65f4cd 100644 --- a/src/po/da.po +++ b/src/po/da.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Vim 8.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-07-18 21:20+0200\n" -"PO-Revision-Date: 2018-08-17 00:15+0200\n" +"PO-Revision-Date: 2019-02-13 00:00+0200\n" "Last-Translator: scootergrisen\n" "Language-Team: Danish\n" "Language: da\n" @@ -2937,7 +2937,7 @@ msgstr "" "\n" "Mere info med: \"vim -h\"\n" -msgid "[file ..] edit specified file(s)" +msgid "[file ..] edit specified file(s)" msgstr "[fil ..] rediger angivne fil(er)" msgid "- read text from stdin" @@ -5014,7 +5014,6 @@ msgstr "E389: Kunne ikke finde mønster" msgid "Substitute " msgstr "Erstatning " -# scootergrisen: find ud af om "Søgemønster" skal være med stort eller lille #, c-format msgid "" "\n" diff --git a/src/po/fr.po b/src/po/fr.po index 30d8b8e0b9..999493219d 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -12,8 +12,8 @@ msgid "" msgstr "" "Project-Id-Version: Vim 8.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-30 09:47+0100\n" -"PO-Revision-Date: 2018-10-30 10:09+0100\n" +"POT-Creation-Date: 2019-02-09 21:16+0100\n" +"PO-Revision-Date: 2018-02-10 11:40+0100\n" "Last-Translator: Dominique Pellé \n" "Language-Team: French\n" "Language: fr\n" @@ -22,6 +22,68 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +msgid "--Deleted--" +msgstr "--Effacé--" + +#, c-format +msgid "auto-removing autocommand: %s " +msgstr "Autocommandes marquées pour auto-suppression : %s " + +#, c-format +msgid "E367: No such group: \"%s\"" +msgstr "E367: Aucun groupe \"%s\"" + +msgid "E936: Cannot delete the current group" +msgstr "E936: Impossible de supprimer le groupe courant" + +msgid "W19: Deleting augroup that is still in use" +msgstr "W19: Effacement d'augroup toujours en usage" + +#, c-format +msgid "E215: Illegal character after *: %s" +msgstr "E215: Caractère non valide après * : %s" + +#, c-format +msgid "E216: No such event: %s" +msgstr "E216: Aucun événement %s" + +#, c-format +msgid "E216: No such group or event: %s" +msgstr "E216: Aucun événement ou groupe %s" + +msgid "" +"\n" +"--- Autocommands ---" +msgstr "" +"\n" +"--- Auto-commandes ---" + +#, c-format +msgid "E680: : invalid buffer number " +msgstr "E680: : numéro de tampon invalide" + +msgid "E217: Can't execute autocommands for ALL events" +msgstr "" +"E217: Impossible d'exécuter les autocommandes pour TOUS les événements (ALL)" + +msgid "No matching autocommands" +msgstr "Aucune autocommande correspondante" + +msgid "E218: autocommand nesting too deep" +msgstr "E218: autocommandes trop imbriquées" + +#, c-format +msgid "%s Autocommands for \"%s\"" +msgstr "Autocommandes %s pour \"%s\"" + +#, c-format +msgid "Executing %s" +msgstr "Exécution de %s" + +#, c-format +msgid "autocommand %s" +msgstr "autocommande %s" + msgid "E831: bf_key_init() called with empty password" msgstr "E831: bf_key_init() appelée avec un mot de passe vide" @@ -110,9 +172,9 @@ msgid "E88: Cannot go before first buffer" msgstr "E88: Impossible d'aller avant le premier tampon" #, c-format -msgid "E89: No write since last change for buffer %ld (add ! to override)" +msgid "E89: No write since last change for buffer %d (add ! to override)" msgstr "" -"E89: Le tampon %ld n'a pas été enregistré (ajoutez ! pour passer outre)" +"E89: Le tampon %d n'a pas été enregistré (ajoutez ! pour passer outre)" msgid "E948: Job still running (add ! to end the job)" msgstr "E948: Tâche en cours d'exécution (ajouter ! pour terminer la tâche)" @@ -132,8 +194,8 @@ msgstr "W14: Alerte : La liste des noms de fichier d # AB - Vu le code source, la version française est meilleure que la # version anglaise. Ce message est similaire au message E86. #, c-format -msgid "E92: Buffer %ld not found" -msgstr "E92: Le tampon %ld n'existe pas" +msgid "E92: Buffer %d not found" +msgstr "E92: Le tampon %d n'existe pas" # AB - Il faut respecter l'esprit plus que la lettre. #, c-format @@ -229,21 +291,6 @@ msgstr "[Invite]" msgid "[Scratch]" msgstr "[Brouillon]" -msgid "" -"\n" -"--- Signs ---" -msgstr "" -"\n" -"--- Symboles ---" - -#, c-format -msgid "Signs for %s:" -msgstr "Symboles dans %s :" - -#, c-format -msgid " line=%ld id=%d name=%s" -msgstr " ligne=%ld id=%d nom=%s" - msgid "E902: Cannot connect to port" msgstr "E902: Impossible de se connecter au port" @@ -339,12 +386,13 @@ msgid "E737: Key already exists: %s" msgstr "E737: La clé existe déjà : %s" #, c-format -msgid "E96: Cannot diff more than %ld buffers" -msgstr "E96: Impossible d'utiliser diff sur plus de %ld tampons" +msgid "E96: Cannot diff more than %d buffers" +msgstr "E96: Impossible d'utiliser diff sur plus de %d tampons" #, c-format msgid "Not enough memory to use internal diff for buffer \"%s\"" -msgstr "Pas assez de mémoire pour utiliser l'outil diff interne pour le tampon \"%s\"" +msgstr "" +"Pas assez de mémoire pour utiliser l'outil diff interne pour le tampon \"%s\"" msgid "E810: Cannot read or write temp files" msgstr "E810: Impossible de lire ou écrire des fichiers temporaires" @@ -397,6 +445,81 @@ msgstr "E787: Le tampon a msgid "E104: Escape not allowed in digraph" msgstr "E104: Un digraphe ne peut contenir le caractère d'échappement" +msgid "Custom" +msgstr "Personnalisé" + +msgid "Latin supplement" +msgstr "Supplément latin" + +msgid "Greek and Coptic" +msgstr "Grec et copte" + +msgid "Cyrillic" +msgstr "Cyrillique" + +msgid "Hebrew" +msgstr "Hébreu" + +msgid "Arabic" +msgstr "Arabe" + +msgid "Latin extended" +msgstr "Latin étendu" + +msgid "Greek extended" +msgstr "Grec étendu" + +msgid "Punctuation" +msgstr "Ponctuation" + +msgid "Super- and subscripts" +msgstr "Exposants et indices" + +msgid "Currency" +msgstr "Symboles monétaires" + +msgid "Other" +msgstr "Autres" + +msgid "Roman numbers" +msgstr "Nombres romains" + +msgid "Arrows" +msgstr "Flèches" + +msgid "Mathematical operators" +msgstr "Opérateurs mathématiques" + +msgid "Technical" +msgstr "Signes techniques" + +msgid "Box drawing" +msgstr "Filets" + +msgid "Block elements" +msgstr "Pavés" + +msgid "Geometric shapes" +msgstr "Formes géométriques" + +msgid "Symbols" +msgstr "Symboles divers" + +msgid "Dingbats" +msgstr "Symboles iconographiques" + +msgid "CJK symbols and punctuation" +msgstr "Symboles et ponctuation CJC" + +msgid "Hiragana" +msgstr "Hiragana" + +msgid "Katakana" +msgstr "Katakana" + +msgid "Bopomofo" +msgstr "Bopomofo" + # AB - La version française est trop verbeuse. msgid "E544: Keymap file not found" msgstr "E544: Le fichier descripteur de clavier est introuvable" @@ -577,14 +700,17 @@ msgstr "Double ; dans une liste de variables" msgid "E738: Can't list variables for %s" msgstr "E738: Impossible de lister les variables de %s" -msgid "E689: Can only index a List or Dictionary" -msgstr "E689: Seul une Liste ou un Dictionnaire peut être indexé" +msgid "E689: Can only index a List, Dictionary or Blob" +msgstr "E689: Seul une Liste, un Dictionnaire ou un Blob peut être indexé" msgid "E708: [:] must come last" msgstr "E708: [:] ne peut être spécifié qu'en dernier" -msgid "E709: [:] requires a List value" -msgstr "E709: [:] nécessite une Liste" +msgid "E709: [:] requires a List or Blob value" +msgstr "E709: [:] nécessite une Liste ou un blob" + +msgid "E972: Blob value does not have the right number of bytes" +msgstr "E972: Le Blob n'a pas le bon nombre d'octets" msgid "E710: List value has more items than target" msgstr "E710: La Liste a plus d'éléments que la destination" @@ -614,6 +740,9 @@ msgstr "E109: Il manque ':' apr msgid "E804: Cannot use '%' with Float" msgstr "E804: Impossible d'utiliser '%' avec un Flottant" +msgid "E973: Blob literal should have an even number of hex characters" +msgstr "E973: Un littéral de Blob doit avoir un nombre pair de caractères hexadécimaux" + msgid "E110: Missing ')'" msgstr "E110: ')' manquant" @@ -669,6 +798,9 @@ msgstr "E910: Utilisation d'une T msgid "E913: Using a Channel as a Number" msgstr "E913: Utilisation d'un Canal comme un Nombre" +msgid "E974: Using a Blob as a Number" +msgstr "E974: Utilisation d'un Blob comme un Nombre" + msgid "E891: Using a Funcref as a Float" msgstr "E891: Utilisation d'une Funcref comme un Flottant" @@ -690,6 +822,9 @@ msgstr "E911: Utilisation d'une T msgid "E914: Using a Channel as a Float" msgstr "E914: Utilisation d'un Canal comme un Flottant" +msgid "E975: Using a Blob as a Float" +msgstr "E975: Utilisation d'un Blob comme un Flottant" + msgid "E729: using Funcref as a String" msgstr "E729: Utilisation d'une Funcref comme une Chaîne" @@ -699,9 +834,16 @@ msgstr "E730: Utilisation d'une Liste comme une Cha msgid "E731: using Dictionary as a String" msgstr "E731: Utilisation d'un Dictionnaire comme une Chaîne" +msgid "E976: using Blob as a String" +msgstr "E976: Utilisation d'un Blob comme une Chaîne" + msgid "E908: using an invalid value as a String" msgstr "E908: Utilisation d'une valeur invalide comme une Chaîne" +#, c-format +msgid "E963: setting %s to value with wrong type" +msgstr "E963: type incorrect lors de l'affectation de %s" + #, c-format msgid "E795: Cannot delete variable %s" msgstr "E795: Impossible de supprimer la variable %s" @@ -748,6 +890,9 @@ msgstr "" msgid " line " msgstr " ligne " +msgid "E977: Can only compare Blob with Blob" +msgstr "E977: Un Blob ne peut être comparé qu'avec un Blob" + msgid "E691: Can only compare List with List" msgstr "E691: Une Liste ne peut être comparée qu'avec une Liste" @@ -773,6 +918,10 @@ msgstr "argument de filter()" msgid "E686: Argument of %s must be a List" msgstr "E686: L'argument de %s doit être une Liste" +#, c-format +msgid "E899: Argument of %s must be a List or Blob" +msgstr "E899: L'argument de %s doit être une Liste ou un Blob" + msgid "E928: String required" msgstr "E928: Chaîne requis" @@ -782,6 +931,12 @@ msgstr "E808: Nombre ou Flottant requis" msgid "add() argument" msgstr "argument de add()" +# AB - Vu le code source, la version française est meilleure que la +# version anglaise. Ce message est similaire au message E102. +#, c-format +msgid "E158: Invalid buffer name: %s" +msgstr "E158: Le tampon %s est introuvable" + msgid "E785: complete() can only be used in Insert mode" msgstr "E785: complete() n'est utilisable que dans le mode Insertion" @@ -790,6 +945,9 @@ msgstr "E785: complete() n'est utilisable que dans le mode Insertion" msgid "&Ok" msgstr "&Ok" +msgid "E980: lowlevel input not supported" +msgstr "E980: entrée de bas niveau non supportée" + #, c-format msgid "+-%s%3ld line: " msgid_plural "+-%s%3ld lines: " @@ -835,8 +993,8 @@ msgid "E957: Invalid window number" msgstr "E957: numéro de fenêtre invalide" #, c-format -msgid "E798: ID is reserved for \":match\": %ld" -msgstr "E798: ID est réservé pour \":match\": %ld" +msgid "E798: ID is reserved for \":match\": %d" +msgstr "E798: ID est réservé pour \":match\": %d" msgid "E726: Stride is zero" msgstr "E726: Le pas est nul" @@ -881,6 +1039,10 @@ msgstr "E258: La r msgid "E927: Invalid action: '%s'" msgstr "E927: Action invalide : « %s »" +#, c-format +msgid "E962: Invalid action: '%s'" +msgstr "E962: Action invalide : « %s »" + msgid "sort() argument" msgstr "argument de sort()" @@ -932,7 +1094,7 @@ msgstr "> %d, Hexa %08x, Octal %o" # AB - La version anglaise est très mauvaise, ce qui m'oblige a inventer une # version française. -msgid "E134: Move lines into themselves" +msgid "E134: Cannot move a range of lines into itself" msgstr "E134: La destination est dans la plage d'origine" #, c-format @@ -1129,11 +1291,8 @@ msgstr "E143: Une autocommande a effac msgid "E144: non-numeric argument to :z" msgstr "E144: L'argument de :z n'est pas numérique" -# AB - La version française fera peut-être mieux passer l'amère pilule. -# La consultation de l'aide donnera l'explication complète à ceux qui -# ne comprendraient pas à quoi ce message est dû. -msgid "E145: Shell commands not allowed in rvim" -msgstr "E145: Les commandes externes sont indisponibles dans rvim" +msgid "E145: Shell commands and some functionality not allowed in rvim" +msgstr "E145: Les commandes shell sont indisponibles dans rvim" msgid "E146: Regular expressions can't be delimited by letters" msgstr "" @@ -1251,60 +1410,6 @@ msgstr "E154: Marqueur \"%s\" dupliqu msgid "E150: Not a directory: %s" msgstr "E150: %s n'est pas un répertoire" -# AB - Il faut respecter l'esprit plus que la lettre. -#, c-format -msgid "E160: Unknown sign command: %s" -msgstr "E160: Commande inconnue : :sign %s" - -# AB - La version française est meilleure que la version anglaise. -msgid "E156: Missing sign name" -msgstr "E156: Il manque le nom du symbole" - -msgid "E612: Too many signs defined" -msgstr "E612: Trop de symboles sont définis" - -# AB - Cette traduction ne me satisfait pas. -# DB - Suggestion. -#, c-format -msgid "E239: Invalid sign text: %s" -msgstr "E239: Le texte du symbole est invalide : %s" - -#, c-format -msgid "E155: Unknown sign: %s" -msgstr "E155: Symbole inconnu : %s" - -# AB - La version française est meilleure que la version anglaise. -msgid "E159: Missing sign number" -msgstr "E159: Il manque l'ID du symbole" - -# AB - Vu le code source, la version française est meilleure que la -# version anglaise. Ce message est similaire au message E102. -#, c-format -msgid "E158: Invalid buffer name: %s" -msgstr "E158: Le tampon %s est introuvable" - -msgid "E934: Cannot jump to a buffer that does not have a name" -msgstr "E934: Impossible de sauter à un tampon sans nom" - -# AB - Vu le code source, la version française est meilleure que la -# version anglaise. -#, c-format -msgid "E157: Invalid sign ID: %ld" -msgstr "E157: Le symbole %ld est introuvable" - -#, c-format -msgid "E885: Not possible to change sign %s" -msgstr "E885: Impossible de changer le symbole %s" - -msgid " (NOT FOUND)" -msgstr " (INTROUVABLE)" - -msgid " (not supported)" -msgstr " (non supporté)" - -msgid "[Deleted]" -msgstr "[Effacé]" - msgid "No old files" msgstr "Aucun vieux fichier" @@ -1367,7 +1472,7 @@ msgstr "Enregistrer \"%s\" ?" #, c-format msgid "E947: Job still running in buffer \"%s\"" -msgstr "E947: Tâche en cours d'exécution dans le buffer \"%s\"" +msgstr "E947: Tâche en cours d'exécution dans le tampon \"%s\"" # AB - Il faut respecter l'esprit plus que la lettre. # AB - Ce message est similaire au message E89. @@ -1503,6 +1608,9 @@ msgstr "E464: Utilisation ambigu msgid "E492: Not an editor command" msgstr "E492: Commande inconnue" +msgid "E981: Command not allowed in rvim" +msgstr "E981: commande indisponibles dans rvim" + msgid "E493: Backwards range given" msgstr "E493: La plage spécifiée est inversée" @@ -1526,13 +1634,14 @@ msgstr[0] "Encore %d fichier msgstr[1] "Encore %d fichiers à éditer. Quitter tout de même ?" #, c-format -msgid "E173: %ld more file to edit" -msgid_plural "E173: %ld more files to edit" -msgstr[0] "E173: encore %ld fichier à éditer" -msgstr[1] "E173: encore %ld fichiers à éditer" +msgid "E173: %d more file to edit" +msgid_plural "E173: %d more files to edit" +msgstr[0] "E173: encore %d fichier à éditer" +msgstr[1] "E173: encore %d fichiers à éditer" -msgid "E174: Command already exists: add ! to replace it" -msgstr "E174: La commande existe déjà : ajoutez ! pour la redéfinir" +#, c-format +msgid "E174: Command already exists: add ! to replace it: %s" +msgstr "E174: La commande existe déjà : ajoutez ! pour la redéfinir : %s" msgid "" "\n" @@ -2199,68 +2308,6 @@ msgstr "E462: Impossible de pr msgid "E321: Could not reload \"%s\"" msgstr "E321: Impossible de recharger \"%s\"" -msgid "--Deleted--" -msgstr "--Effacé--" - -#, c-format -msgid "auto-removing autocommand: %s " -msgstr "Autocommandes marquées pour auto-suppression : %s " - -#, c-format -msgid "E367: No such group: \"%s\"" -msgstr "E367: Aucun groupe \"%s\"" - -msgid "E936: Cannot delete the current group" -msgstr "E936: Impossible de supprimer le groupe courant" - -msgid "W19: Deleting augroup that is still in use" -msgstr "W19: Effacement d'augroup toujours en usage" - -#, c-format -msgid "E215: Illegal character after *: %s" -msgstr "E215: Caractère non valide après * : %s" - -#, c-format -msgid "E216: No such event: %s" -msgstr "E216: Aucun événement %s" - -#, c-format -msgid "E216: No such group or event: %s" -msgstr "E216: Aucun événement ou groupe %s" - -msgid "" -"\n" -"--- Autocommands ---" -msgstr "" -"\n" -"--- Auto-commandes ---" - -#, c-format -msgid "E680: : invalid buffer number " -msgstr "E680: : numéro de tampon invalide" - -msgid "E217: Can't execute autocommands for ALL events" -msgstr "" -"E217: Impossible d'exécuter les autocommandes pour TOUS les événements (ALL)" - -msgid "No matching autocommands" -msgstr "Aucune autocommande correspondante" - -msgid "E218: autocommand nesting too deep" -msgstr "E218: autocommandes trop imbriquées" - -#, c-format -msgid "%s Autocommands for \"%s\"" -msgstr "Autocommandes %s pour \"%s\"" - -#, c-format -msgid "Executing %s" -msgstr "Exécution de %s" - -#, c-format -msgid "autocommand %s" -msgstr "autocommande %s" - msgid "E219: Missing {." msgstr "E219: { manquant." @@ -2560,20 +2607,20 @@ msgid "Font0: %s" msgstr "Font0: %s" #, c-format -msgid "Font1: %s" -msgstr "Font1: %s" +msgid "Font%d: %s" +msgstr "Font%d: %s" #, c-format -msgid "Font%ld width is not twice that of font0" -msgstr "La largeur de Font%ld n'est pas le double de celle de Font0" +msgid "Font%d width is not twice that of font0" +msgstr "La largeur de Font%d n'est pas le double de celle de Font0" #, c-format -msgid "Font0 width: %ld" -msgstr "Largeur de Font0 : %ld" +msgid "Font0 width: %d" +msgstr "Largeur de Font0 : %d" #, c-format -msgid "Font1 width: %ld" -msgstr "Largeur de Font1 : %ld" +msgid "Font%d width: %d" +msgstr "Largeur de Font%d : %d" # DB - todo : Pas certain de mon coup, ici... msgid "Invalid font specification" @@ -2754,8 +2801,8 @@ msgid "Added cscope database %s" msgstr "Base de données cscope %s ajoutée" #, c-format -msgid "E262: error reading cscope connection %ld" -msgstr "E262: erreur lors de la lecture de la connexion cscope %ld" +msgid "E262: error reading cscope connection %d" +msgstr "E262: erreur lors de la lecture de la connexion cscope %d" msgid "E561: unknown cscope search type" msgstr "E561: type de recherche cscope inconnu" @@ -4083,11 +4130,6 @@ msgstr "E326: Trop de fichiers d' msgid "E327: Part of menu-item path is not sub-menu" msgstr "E327: Une partie du chemin de l'élément de menu n'est pas un sous-menu" -# DB - todo : J'hésite avec -# msgstr "E328: Le menu n'existe pas dans ce mode" -msgid "E328: Menu only exists in another mode" -msgstr "E328: Le menu n'existe que dans un autre mode" - #, c-format msgid "E329: No menu \"%s\"" msgstr "E329: Aucun menu \"%s\"" @@ -4320,8 +4362,8 @@ msgstr "" "\"" #, c-format -msgid "E658: NetBeans connection lost for buffer %ld" -msgstr "E658: Connexion NetBeans perdue pour le tampon %ld" +msgid "E658: NetBeans connection lost for buffer %d" +msgstr "E658: Connexion NetBeans perdue pour le tampon %d" msgid "E838: netbeans is not supported with this GUI" msgstr "E838: netbeans n'est pas supporté avec cette interface graphique" @@ -5280,6 +5322,73 @@ msgstr "" "# Dernier motif de recherche %s :\n" "~" +msgid "[Deleted]" +msgstr "[Effacé]" + +msgid "" +"\n" +"--- Signs ---" +msgstr "" +"\n" +"--- Symboles ---" + +#, c-format +msgid "Signs for %s:" +msgstr "Symboles dans %s :" + +#, c-format +msgid " group=%s" +msgstr " groupe=%s" + +#, c-format +msgid " line=%ld id=%d%s name=%s priority=%d" +msgstr " ligne=%ld id=%d%s nom=%s priorité=%d" + +msgid "E612: Too many signs defined" +msgstr "E612: Trop de symboles sont définis" + +# AB - Cette traduction ne me satisfait pas. +# DB - Suggestion. +#, c-format +msgid "E239: Invalid sign text: %s" +msgstr "E239: Le texte du symbole est invalide : %s" + +#, c-format +msgid "E155: Unknown sign: %s" +msgstr "E155: Symbole inconnu : %s" + +#, c-format +msgid "E885: Not possible to change sign %s" +msgstr "E885: Impossible de changer le symbole %s" + +# AB - La version française est meilleure que la version anglaise. +msgid "E159: Missing sign number" +msgstr "E159: Il manque l'ID du symbole" + +# AB - Vu le code source, la version française est meilleure que la +# version anglaise. +#, c-format +msgid "E157: Invalid sign ID: %d" +msgstr "E157: Le symbole %d est introuvable" + +msgid "E934: Cannot jump to a buffer that does not have a name" +msgstr "E934: Impossible de sauter à un tampon sans nom" + +# AB - Il faut respecter l'esprit plus que la lettre. +#, c-format +msgid "E160: Unknown sign command: %s" +msgstr "E160: Commande inconnue : :sign %s" + +# AB - La version française est meilleure que la version anglaise. +msgid "E156: Missing sign name" +msgstr "E156: Il manque le nom du symbole" + +msgid " (NOT FOUND)" +msgstr " (INTROUVABLE)" + +msgid " (not supported)" +msgstr " (non supporté)" + msgid "E756: Spell checking is not enabled" msgstr "E756: La vérification orthographique n'est pas activée" @@ -5389,10 +5498,6 @@ msgstr " msgid "Conversion in %s not supported: from %s to %s" msgstr "La conversion dans %s non supportée : de %s vers %s" -#, c-format -msgid "Conversion in %s not supported" -msgstr "La conversion dans %s non supportée" - #, c-format msgid "Invalid value for FLAG in %s line %d: %s" msgstr "Valeur de FLAG invalide dans %s ligne %d : %s" @@ -5614,8 +5719,8 @@ msgid "E751: Output file name must not have region name" msgstr "E751: Le nom du fichier ne doit pas contenir de nom de région" #, c-format -msgid "E754: Only up to %ld regions supported" -msgstr "E754: %ld régions au maximum supportées" +msgid "E754: Only up to %d regions supported" +msgstr "E754: %d régions au maximum supportées" #, c-format msgid "E755: Invalid region in %s" @@ -5633,8 +5738,8 @@ msgstr "Termin # DB - todo : perfectible. #, c-format -msgid "E765: 'spellfile' does not have %ld entries" -msgstr "E765: 'spellfile' n'a pas %ld entrées" +msgid "E765: 'spellfile' does not have %d entries" +msgstr "E765: 'spellfile' n'a pas %d entrées" #, c-format msgid "Word '%.*s' removed from %s" @@ -6043,7 +6148,36 @@ msgid "E953: File exists: %s" msgstr "E953: Le fichier existe déjà : %s" msgid "E955: Not a terminal buffer" -msgstr "E955: Ce n'est pas un buffer de terminal" +msgstr "E955: Ce n'est pas un tampon de terminal" + +#, c-format +msgid "E971: Property type %s does not exist" +msgstr "E971: Le type de propriété %s n'existe pas" + +#, c-format +msgid "E964: Invalid column number: %ld" +msgstr "E964: Numéro de colonne invalide : %ld" + +#, c-format +msgid "E966: Invalid line number: %ld" +msgstr "E966: Numéro de ligne invalide : %ld" + +msgid "E965: missing property type name" +msgstr "E965: nom du type de propriété absent" + +msgid "E967: text property info corrupted" +msgstr "E967: information de propriété de texte corrompu" + +msgid "E968: Need at least one of 'id' or 'type'" +msgstr "E968: Au moins « id » ou « type » sont nécessaires" + +#, c-format +msgid "E969: Property type %s already defined" +msgstr "E969: Type de propriété %s déjà défini" + +#, c-format +msgid "E970: Unknown highlight group name: '%s'" +msgstr "E970: Nom de groupe de surbrillance inconnu : « %s »" msgid "new shell started\n" msgstr "nouveau shell démarré\n" @@ -6631,6 +6765,12 @@ msgstr "menu Aide->Sponsor/Enregistrement pour plus d'info" msgid "Already only one window" msgstr "Il n'y a déjà plus qu'une fenêtre" +# AB - Vu le code source, la version française est meilleure que la +# version anglaise. Ce message est similaire au message E86. +#, c-format +msgid "E92: Buffer %ld not found" +msgstr "E92: Le tampon %ld n'existe pas" + msgid "E441: There is no preview window" msgstr "E441: Il n'y a pas de fenêtre de prévisualisation" @@ -6662,23 +6802,23 @@ msgid "E447: Can't find file \"%s\" in path" msgstr "E447: Le fichier \"%s\" est introuvable dans 'path'" #, c-format -msgid "E799: Invalid ID: %ld (must be greater than or equal to 1)" -msgstr "E799: ID invalide : %ld (doit être plus grand ou égal à 1)" +msgid "E799: Invalid ID: %d (must be greater than or equal to 1)" +msgstr "E799: ID invalide : %d (doit être plus grand ou égal à 1)" #, c-format -msgid "E801: ID already taken: %ld" -msgstr "E801: ID déjà pris: %ld" +msgid "E801: ID already taken: %d" +msgstr "E801: ID déjà pris: %d" msgid "List or number required" msgstr "Liste ou nombre requis" #, c-format -msgid "E802: Invalid ID: %ld (must be greater than or equal to 1)" -msgstr "E802: ID invalide : %ld (doit être plus grand ou égal à 1)" +msgid "E802: Invalid ID: %d (must be greater than or equal to 1)" +msgstr "E802: ID invalide : %d (doit être plus grand ou égal à 1)" #, c-format -msgid "E803: ID not found: %ld" -msgstr "E803: ID introuvable : %ld" +msgid "E803: ID not found: %d" +msgstr "E803: ID introuvable : %d" #, c-format msgid "E370: Could not load library %s" @@ -6988,7 +7128,14 @@ msgstr "E715: Dictionnaire requis" #, c-format msgid "E684: list index out of range: %ld" -msgstr "E684: index de Liste hors limites : %ld au-delà de la fin" +msgstr "E684: index de Liste hors limites : %ld" + +#, c-format +msgid "E979: Blob index out of range: %ld" +msgstr "E979: index de Blob hors limites : %ld" + +msgid "E978: Invalid operation for Blob" +msgstr "E978: Opération invalide avec un Blob" # DB : Suggestion #, c-format @@ -7002,10 +7149,17 @@ msgstr "E716: La cl msgid "E714: List required" msgstr "E714: Liste requise" +msgid "E897: List or Blob required" +msgstr "E897: Liste ou Blob requis" + #, c-format msgid "E712: Argument of %s must be a List or Dictionary" msgstr "E712: L'argument de %s doit être une Liste ou un Dictionnaire" +#, c-format +msgid "E896: Argument of %s must be a List, Dictionary or Blob" +msgstr "E896: L'argument de %s doit être une Liste, Dictionnaire ou un Blob" + msgid "E47: Error while reading errorfile" msgstr "E47: Erreur lors de la lecture du fichier d'erreurs" @@ -7109,6 +7263,11 @@ msgstr "E919: R msgid "E952: Autocommand caused recursive behavior" msgstr "E952: Une autocommande a causé une récursivité" +# DB - todo : J'hésite avec +# msgstr "E328: Le menu n'existe pas dans ce mode" +msgid "E328: Menu only exists in another mode" +msgstr "E328: Le menu n'existe que dans un autre mode" + msgid "search hit TOP, continuing at BOTTOM" msgstr "La recherche a atteint le HAUT, et continue en BAS" diff --git a/src/testdir/Makefile b/src/testdir/Makefile index c3ba8abdcf..8e979a8056 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -12,13 +12,13 @@ SCRIPTSOURCE = ../../runtime # Comment out this line to see the verbose output of tests. # # Catches SwapExists to avoid hanging at the ATTENTION prompt. -REDIR_TEST_TO_NULL = --cmd 'au SwapExists * let v:swapchoice = "e"' > /dev/null +#REDIR_TEST_TO_NULL = --cmd 'au SwapExists * let v:swapchoice = "e"' > /dev/null # Uncomment this line to use valgrind for memory leaks and extra warnings. # The output goes into a file "valgrind.testN" # Vim should be compiled with EXITFREE to avoid false warnings. # This will make testing about 10 times as slow. -# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$* +#VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$* default: nongui From b0e2da2b23e7497d0a145ecce9c1e08b6fab6dbf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Feb 2019 23:26:50 +0100 Subject: [PATCH 75/75] patch 8.1.0946: Coveralls is not very useful Problem: Coveralls is not very useful. Solution: Remove Coveralls badge, add badge for packages. --- README.md | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 92257d39a5..c579ccc4c1 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ![Vim Logo](https://github.com/vim/vim/blob/master/runtime/vimlogo.gif) [![Build Status](https://travis-ci.org/vim/vim.svg?branch=master)](https://travis-ci.org/vim/vim) -[![Coverage Status](https://codecov.io/gh/vim/vim/coverage.svg?branch=master)](https://codecov.io/gh/vim/vim?branch=master) -[![Coverage Status](https://coveralls.io/repos/github/vim/vim/badge.svg?branch=master)](https://coveralls.io/github/vim/vim?branch=master) [![Appveyor Build status](https://ci.appveyor.com/api/projects/status/o2qht2kjm02sgghk?svg=true)](https://ci.appveyor.com/project/chrisbra/vim) +[![Coverage Status](https://codecov.io/gh/vim/vim/coverage.svg?branch=master)](https://codecov.io/gh/vim/vim?branch=master) [![Coverity Scan](https://scan.coverity.com/projects/241/badge.svg)](https://scan.coverity.com/projects/vim) [![Language Grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/vim/vim.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/vim/vim/context:cpp) [![Debian CI](https://badges.debian.net/badges/debian/testing/vim/version.svg)](https://buildd.debian.org/vim) +[![Packages](https://repology.org/badge/tiny-repos/vim.svg)](https://repology.org/metapackage/vim) ## What is Vim? ## diff --git a/src/version.c b/src/version.c index 0d44663a2e..ad062ae06b 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 946, /**/ 945, /**/