diff options
Diffstat (limited to 'src/nvim/version.c')
-rw-r--r-- | src/nvim/version.c | 496 |
1 files changed, 219 insertions, 277 deletions
diff --git a/src/nvim/version.c b/src/nvim/version.c index 417e5116a5..cb9088afae 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file version.c /// /// Nvim was forked from Vim 7.4.160. @@ -9,33 +6,33 @@ #include <assert.h> #include <limits.h> #include <stdbool.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "auto/config.h" #include "auto/versiondef.h" // version info generated by the build system #include "auto/versiondef_git.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/drawscreen.h" #include "nvim/ex_cmds_defs.h" +#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/highlight_defs.h" +#include "nvim/highlight.h" #include "nvim/lua/executor.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" -#include "nvim/os/os_defs.h" +#include "nvim/option_vars.h" +#include "nvim/os/os.h" #include "nvim/strings.h" #include "nvim/version.h" -#include "nvim/vim.h" // for ":version", ":intro", and "nvim --version" #ifndef NVIM_VERSION_MEDIUM @@ -57,17 +54,6 @@ char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS; # include "version.c.generated.h" #endif -static char *features[] = { -#ifdef HAVE_ACL - "+acl", -#else - "-acl", -#endif - - "+tui", - NULL -}; - // clang-format off static const int included_patches[] = { 2424, @@ -91,7 +77,7 @@ static const int included_patches[] = { 2406, 2405, 2404, - // 2403, + 2403, 2402, 2401, 2400, @@ -121,7 +107,7 @@ static const int included_patches[] = { 2376, 2375, 2374, - // 2373, + 2373, 2372, // 2371, 2370, @@ -218,7 +204,7 @@ static const int included_patches[] = { // 2279, 2278, // 2277, - // 2276, + 2276, 2275, 2274, // 2273, @@ -346,7 +332,7 @@ static const int included_patches[] = { 2151, 2150, 2149, - // 2148, + 2148, 2147, // 2146, 2145, @@ -395,12 +381,12 @@ static const int included_patches[] = { 2102, 2101, 2100, - // 2099, + 2099, 2098, 2097, 2096, 2095, - // 2094, + 2094, // 2093, // 2092, 2091, @@ -424,15 +410,15 @@ static const int included_patches[] = { 2073, 2072, // 2071, - // 2070, - // 2069, - // 2068, - // 2067, - // 2066, + 2070, + 2069, + 2068, + 2067, + 2066, 2065, 2064, 2063, - // 2062, + 2062, 2061, 2060, 2059, @@ -441,16 +427,16 @@ static const int included_patches[] = { 2056, 2055, 2054, - // 2053, + 2053, 2052, 2051, 2050, 2049, - // 2048, - // 2047, - // 2046, + 2048, + 2047, + 2046, 2045, - // 2044, + 2044, 2043, 2042, 2041, @@ -667,7 +653,7 @@ static const int included_patches[] = { 1830, 1829, 1828, - // 1827, + 1827, 1826, 1825, 1824, @@ -795,7 +781,7 @@ static const int included_patches[] = { 1702, 1701, // 1700, - // 1699, + 1699, 1698, 1697, 1696, @@ -972,43 +958,43 @@ static const int included_patches[] = { // 1525, 1524, // 1523, - // 1522, - // 1521, - // 1520, + 1522, + 1521, + 1520, 1519, - // 1518, - // 1517, + 1518, + 1517, 1516, - // 1515, + 1515, 1514, - // 1513, + 1513, 1512, - // 1511, + 1511, 1510, 1509, - // 1508, + 1508, 1507, 1506, 1505, 1504, 1503, - // 1502, + 1502, 1501, 1500, - // 1499, + 1499, 1498, - // 1497, - // 1496, - // 1495, - // 1494, - // 1493, + 1497, + 1496, + 1495, + 1494, + 1493, 1492, 1491, 1490, 1489, 1488, 1487, - // 1486, + 1486, 1485, 1484, 1483, @@ -1031,83 +1017,83 @@ static const int included_patches[] = { 1466, 1465, 1464, - // 1463, + 1463, 1462, 1461, - // 1460, - // 1459, + 1460, + 1459, 1458, 1457, 1456, - // 1455, + 1455, 1454, - // 1453, - // 1452, - // 1451, - // 1450, - // 1449, - // 1448, - // 1447, - // 1446, - // 1445, - // 1444, - // 1443, - // 1442, - // 1441, + 1453, + 1452, + 1451, + 1450, + 1449, + 1448, + 1447, + 1446, + 1445, + 1444, + 1443, + 1442, + 1441, 1440, 1439, - // 1438, + 1438, 1437, 1436, 1435, 1434, 1433, - // 1432, - // 1431, - // 1430, - // 1429, - // 1428, - // 1427, - // 1426, + 1432, + 1431, + 1430, + 1429, + 1428, + 1427, + 1426, 1425, 1424, - // 1423, - // 1422, - // 1421, - // 1420, - // 1419, + 1423, + 1422, + 1421, + 1420, + 1419, 1418, // 1417, - // 1416, + 1416, 1415, - // 1414, + 1414, // 1413, 1412, 1411, - // 1410, + 1410, 1409, - // 1408, - // 1407, - // 1406, - // 1405, + 1408, + 1407, + 1406, + 1405, 1404, 1403, - // 1402, + 1402, 1401, - // 1400, - // 1399, + 1400, + 1399, 1398, 1397, - // 1396, + 1396, // 1395, 1394, 1393, 1392, - // 1391, + 1391, 1390, // 1389, - // 1388, - // 1387, + 1388, + 1387, 1386, 1385, 1384, @@ -1118,7 +1104,7 @@ static const int included_patches[] = { 1379, 1378, 1377, - // 1376, + 1376, 1375, 1374, 1373, @@ -1130,12 +1116,12 @@ static const int included_patches[] = { 1367, 1366, 1365, - // 1364, + 1364, 1363, 1362, 1361, 1360, - // 1359, + 1359, 1358, 1357, 1356, @@ -1143,38 +1129,38 @@ static const int included_patches[] = { 1354, 1353, 1352, - // 1351, + 1351, 1350, 1349, 1348, 1347, 1346, 1345, - // 1344, - // 1343, + 1344, + 1343, 1342, - // 1341, - // 1340, + 1341, + 1340, 1339, 1338, - // 1337, + 1337, 1336, - // 1335, + 1335, 1334, - // 1333, - // 1332, + 1333, + 1332, 1331, 1330, - // 1329, - // 1328, + 1329, + 1328, 1327, - // 1326, + 1326, 1325, 1324, 1323, 1322, - // 1321, - // 1320, + 1321, + 1320, 1319, 1318, 1317, @@ -1214,11 +1200,11 @@ static const int included_patches[] = { 1283, 1282, 1281, - // 1280, + 1280, 1279, - // 1278, + 1278, 1277, - // 1276, + 1276, 1275, 1274, 1273, @@ -1227,9 +1213,9 @@ static const int included_patches[] = { 1270, 1269, 1268, - // 1267, + 1267, 1266, - // 1265, + 1265, 1264, 1263, 1262, @@ -1268,7 +1254,7 @@ static const int included_patches[] = { 1229, 1228, 1227, - // 1226, + 1226, 1225, // 1224, 1223, @@ -1361,7 +1347,7 @@ static const int included_patches[] = { // 1136, 1135, 1134, - // 1133, + 1133, 1132, 1131, 1130, @@ -1391,7 +1377,7 @@ static const int included_patches[] = { // 1106, 1105, 1104, - // 1103, + 1103, 1102, 1101, 1100, @@ -1404,7 +1390,7 @@ static const int included_patches[] = { 1093, 1092, 1091, - // 1090, + 1090, 1089, 1088, 1087, @@ -1459,14 +1445,14 @@ static const int included_patches[] = { 1038, 1037, 1036, - // 1035, + 1035, 1034, 1033, 1032, 1031, 1030, 1029, - // 1028, + 1028, 1027, 1026, 1025, @@ -1475,7 +1461,7 @@ static const int included_patches[] = { 1022, 1021, 1020, - // 1019, + 1019, 1018, 1017, 1016, @@ -1524,7 +1510,7 @@ static const int included_patches[] = { 973, 972, 971, - // 970, + 970, // 969, 968, 967, @@ -1554,7 +1540,7 @@ static const int included_patches[] = { 943, 942, 941, - // 940, + 940, 939, 938, 937, @@ -1566,7 +1552,7 @@ static const int included_patches[] = { 931, 930, 929, - // 928, + 928, 927, 926, 925, @@ -1576,7 +1562,7 @@ static const int included_patches[] = { 921, 920, 919, - // 918, + 918, 917, 916, 915, @@ -1585,10 +1571,10 @@ static const int included_patches[] = { 912, 911, 910, - // 909, + 909, 908, 907, - // 906, + 906, 905, 904, 903, @@ -1599,12 +1585,12 @@ static const int included_patches[] = { 898, 897, 896, - // 895, + 895, // 894, 893, 892, 891, - // 890, + 890, 889, 888, 887, @@ -1614,8 +1600,8 @@ static const int included_patches[] = { 883, 882, 881, - // 880, - // 879, + 880, + 879, 878, 877, // 876, @@ -1624,7 +1610,7 @@ static const int included_patches[] = { 873, 872, 871, - // 870, + 870, 869, 868, 867, @@ -1649,7 +1635,7 @@ static const int included_patches[] = { 848, 847, 846, - // 845, + 845, 844, 843, 842, @@ -1670,11 +1656,11 @@ static const int included_patches[] = { 827, 826, 825, - // 824, + 824, 823, 822, 821, - // 820, + 820, 819, 818, 817, @@ -1733,7 +1719,7 @@ static const int included_patches[] = { 764, 763, 762, - // 761, + 761, 760, 759, 758, @@ -1787,11 +1773,11 @@ static const int included_patches[] = { // 710, 709, 708, - // 707, + 707, 706, 705, 704, - // 703, + 703, 702, 701, 700, @@ -1800,26 +1786,26 @@ static const int included_patches[] = { 697, 696, 695, - // 694, + 694, 693, 692, - // 691, - // 690, - // 689, - // 688, + 691, + 690, + 689, + 688, 687, 686, 685, - // 684, + 684, 683, - // 682, - // 681, + 682, + 681, 680, 679, 678, 677, - // 676, - // 675, + 676, + 675, 674, 673, 672, @@ -1827,11 +1813,11 @@ static const int included_patches[] = { 670, 669, 668, - // 667, + 667, 666, - // 665, + 665, 664, - // 663, + 663, 662, 661, 660, @@ -1839,8 +1825,8 @@ static const int included_patches[] = { 658, 657, 656, - // 655, - // 654, + 655, + 654, 653, 652, 651, @@ -1851,16 +1837,16 @@ static const int included_patches[] = { 646, 645, 644, - // 643, + 643, 642, 641, 640, - // 639, - // 638, + 639, + 638, 637, // 636, 635, - // 634, + 634, 633, 632, 631, @@ -1882,7 +1868,7 @@ static const int included_patches[] = { 615, 614, 613, - // 612, + 612, 611, 610, 609, @@ -1893,7 +1879,7 @@ static const int included_patches[] = { 604, 603, 602, - // 601, + 601, 600, 599, 598, @@ -1912,10 +1898,10 @@ static const int included_patches[] = { 585, 584, 583, - // 582, + 582, 581, 580, - // 579, + 579, 578, 577, 576, @@ -2127,7 +2113,7 @@ static const int included_patches[] = { 370, 369, 368, - // 367, + 367, 366, 365, 364, @@ -2182,7 +2168,7 @@ static const int included_patches[] = { 315, 314, 313, - // 312, + 312, 311, 310, 309, @@ -2190,7 +2176,7 @@ static const int included_patches[] = { 307, 306, 305, - // 304, + 304, 303, 302, 301, @@ -2422,7 +2408,7 @@ static const int included_patches[] = { 75, 74, 73, - // 72, + 72, 71, 70, 69, @@ -2432,7 +2418,7 @@ static const int included_patches[] = { // 65, 64, 63, - // 62, + 62, 61, 60, 59, @@ -2444,8 +2430,8 @@ static const int included_patches[] = { 53, 52, 51, - // 50, - // 49, + 50, + 49, 48, 47, 46, @@ -2507,14 +2493,13 @@ bool has_nvim_version(const char *const version_str) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { const char *p = version_str; - int major = 0; int minor = 0; int patch = 0; if (!ascii_isdigit(*p)) { return false; } - major = atoi(p); + int major = atoi(p); p = strchr(p, '.'); // Find the next dot. if (p) { @@ -2571,6 +2556,11 @@ Dictionary version_dict(void) PUT(d, "major", INTEGER_OBJ(NVIM_VERSION_MAJOR)); PUT(d, "minor", INTEGER_OBJ(NVIM_VERSION_MINOR)); PUT(d, "patch", INTEGER_OBJ(NVIM_VERSION_PATCH)); +#ifndef NVIM_VERSION_BUILD + PUT(d, "build", NIL); +#else + PUT(d, "build", CSTR_AS_OBJ(NVIM_VERSION_BUILD)); +#endif PUT(d, "prerelease", BOOLEAN_OBJ(NVIM_VERSION_PRERELEASE[0] != '\0')); PUT(d, "api_level", INTEGER_OBJ(NVIM_API_LEVEL)); PUT(d, "api_compatible", INTEGER_OBJ(NVIM_API_LEVEL_COMPAT)); @@ -2619,21 +2609,6 @@ static void version_msg(char *s) version_msg_wrap(s, false); } -/// List all features. -/// This does not use list_in_columns (as in Vim), because there are only a -/// few, and we do not start at a new line. -static void list_features(void) -{ - version_msg(_("\n\nFeatures: ")); - for (int i = 0; features[i] != NULL; i++) { - version_msg(features[i]); - if (features[i + 1] != NULL) { - version_msg(" "); - } - } - version_msg("\nSee \":help feature-compile\"\n\n"); -} - /// List string items nicely aligned in columns. /// When "size" is < 0 then the last entry is marked with NULL. /// The entry with index "current" is inclosed in []. @@ -2643,8 +2618,7 @@ void list_in_columns(char **items, int size, int current) int width = 0; // Find the length of the longest item, use that + 1 as the column width. - int i; - for (i = 0; size < 0 ? items[i] != NULL : i < size; i++) { + for (int i = 0; size < 0 ? items[i] != NULL : i < size; i++) { int l = vim_strsize(items[i]) + (i == current ? 2 : 0); if (l > width) { @@ -2656,7 +2630,7 @@ void list_in_columns(char **items, int size, int current) if (Columns < width) { // Not enough screen columns - show one per line - for (i = 0; i < item_count; i++) { + for (int i = 0; i < item_count; i++) { version_msg_wrap(items[i], i == current); if (msg_col > 0 && i < item_count - 1) { msg_putchar('\n'); @@ -2672,7 +2646,7 @@ void list_in_columns(char **items, int size, int current) int cur_row = 1; // "i" counts columns then rows. "idx" counts rows then columns. - for (i = 0; !got_int && i < nrow * ncol; i++) { + for (int i = 0; !got_int && i < nrow * ncol; i++) { int idx = (i / ncol) + (i % ncol) * nrow; if (idx < item_count) { int last_col = (i + 1) % ncol == 0; @@ -2712,59 +2686,48 @@ void list_lua_version(void) Object ret = nlua_exec(cstr_as_string(code), (Array)ARRAY_DICT_INIT, &err); assert(!ERROR_SET(&err)); assert(ret.type == kObjectTypeString); - msg(ret.data.string.data); + msg(ret.data.string.data, 0); api_free_object(ret); } void list_version(void) { - msg(longVersion); - msg(version_buildtype); + msg(longVersion, 0); + msg(version_buildtype, 0); list_lua_version(); + + if (p_verbose > 0) { #ifndef NDEBUG - msg(version_cflags); + msg(version_cflags, 0); #endif + version_msg("\n\n"); -#ifdef HAVE_PATHDEF - - if ((*compiled_user != NUL) || (*compiled_sys != NUL)) { - msg_puts(_("\nCompiled ")); +#ifdef SYS_VIMRC_FILE + version_msg(_(" system vimrc file: \"")); + version_msg(SYS_VIMRC_FILE); + version_msg("\"\n"); +#endif - if (*compiled_user != NUL) { - msg_puts(_("by ")); - msg_puts((const char *)compiled_user); +#ifdef HAVE_PATHDEF + if (*default_vim_dir != NUL) { + version_msg(_(" fall-back for $VIM: \"")); + version_msg(default_vim_dir); + version_msg("\"\n"); } - if (*compiled_sys != NUL) { - msg_puts("@"); - msg_puts((const char *)compiled_sys); + if (*default_vimruntime_dir != NUL) { + version_msg(_(" f-b for $VIMRUNTIME: \"")); + version_msg(default_vimruntime_dir); + version_msg("\"\n"); } +#endif } -#endif // ifdef HAVE_PATHDEF - - list_features(); - -#ifdef SYS_VIMRC_FILE - version_msg(_(" system vimrc file: \"")); - version_msg(SYS_VIMRC_FILE); - version_msg("\"\n"); -#endif // ifdef SYS_VIMRC_FILE -#ifdef HAVE_PATHDEF - - if (*default_vim_dir != NUL) { - version_msg(_(" fall-back for $VIM: \"")); - version_msg(default_vim_dir); - version_msg("\"\n"); - } - - if (*default_vimruntime_dir != NUL) { - version_msg(_(" f-b for $VIMRUNTIME: \"")); - version_msg(default_vimruntime_dir); - version_msg("\"\n"); - } -#endif // ifdef HAVE_PATHDEF - version_msg("\nRun :checkhealth for more info"); + version_msg(p_verbose > 0 + ? "\nRun :checkhealth for more info" + : (starting + ? "\nRun \"nvim -V1 -v\" for more info" + : "\nRun \":verbose version\" for more info")); } /// Show the intro message when not editing a file. @@ -2785,13 +2748,6 @@ void maybe_intro_message(void) /// @param colon true for ":intro" void intro_message(int colon) { - int i; - long row; - long blanklines; - int sponsor; - char *p; - char *mesg; - int mesg_size; static char *(lines[]) = { N_(NVIM_VERSION_LONG), "", @@ -2813,7 +2769,7 @@ void intro_message(int colon) size_t lines_size = ARRAY_SIZE(lines); assert(lines_size <= LONG_MAX); - blanklines = Rows - ((long)lines_size - 1L); + int blanklines = Rows - ((int)lines_size - 1); // Don't overwrite a statusline. Depends on 'cmdheight'. if (p_ls > 1) { @@ -2826,17 +2782,17 @@ void intro_message(int colon) // Show the sponsor and register message one out of four times, the Uganda // message two out of four times. - sponsor = (int)time(NULL); + int sponsor = (int)time(NULL); sponsor = ((sponsor & 2) == 0) - ((sponsor & 4) == 0); // start displaying the message lines after half of the blank lines - row = blanklines / 2; + int row = blanklines / 2; if (((row >= 2) && (Columns >= 50)) || colon) { - for (i = 0; i < (int)ARRAY_SIZE(lines); i++) { - p = lines[i]; - mesg = NULL; - mesg_size = 0; + for (int i = 0; i < (int)ARRAY_SIZE(lines); i++) { + char *p = lines[i]; + char *mesg = NULL; + int mesg_size = 0; if (strstr(p, "news") != NULL) { p = _(p); @@ -2846,18 +2802,15 @@ void intro_message(int colon) mesg = xmallocz((size_t)mesg_size); snprintf(mesg, (size_t)mesg_size + 1, p, STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR)); - } - - if (sponsor != 0) { + } else if (sponsor != 0) { if (strstr(p, "children") != NULL) { - mesg = sponsor < 0 - ? _("Sponsor Vim development!") - : _("Become a registered Vim user!"); - } - if (strstr(p, "iccf") != NULL) { - mesg = sponsor < 0 - ? _("type :help sponsor<Enter> for information ") - : _("type :help register<Enter> for information "); + p = sponsor < 0 + ? N_("Sponsor Vim development!") + : N_("Become a registered Vim user!"); + } else if (strstr(p, "iccf") != NULL) { + p = sponsor < 0 + ? N_("type :help sponsor<Enter> for information ") + : N_("type :help register<Enter> for information "); } } @@ -2879,22 +2832,14 @@ void intro_message(int colon) } } } - - // Make the wait-return message appear just below the text. - if (colon) { - assert(row <= INT_MAX); - msg_row = (int)row; - } } -static void do_intro_line(long row, char *mesg, int attr) +static void do_intro_line(int row, char *mesg, int attr) { - char *p; int l; - int clen; // Center the message horizontally. - long col = vim_strsize(mesg); + int col = vim_strsize(mesg); col = (Columns - col) / 2; @@ -2902,21 +2847,18 @@ static void do_intro_line(long row, char *mesg, int attr) col = 0; } + grid_line_start(&default_grid, row); // Split up in parts to highlight <> items differently. - for (p = mesg; *p != NUL; p += l) { - clen = 0; - + for (char *p = mesg; *p != NUL; p += l) { for (l = 0; p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); l++) { - clen += ptr2cells(p + l); l += utfc_ptr2len(p + l) - 1; } assert(row <= INT_MAX && col <= INT_MAX); - grid_puts_len(&default_grid, p, l, (int)row, (int)col, - *p == '<' ? HL_ATTR(HLF_8) : attr); - col += clen; + col += grid_line_puts(col, p, l, *p == '<' ? HL_ATTR(HLF_8) : attr); } + grid_line_flush(); } /// ":intro": clear screen, display intro screen and wait for return. |