annotate src/kword_test.c @ 35122:739aaccbca74 default tip

runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out Commit: https://github.com/vim/vim/commit/8d8cb45756cb7e6fda17013b8347be3a11b29610 Author: D. Ben Knoble <ben.knoble+github@gmail.com> Date: Mon May 6 19:52:53 2024 +0200 runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out Say you use Vim and set MANPAGER='vim -M +MANPAGER --not-a-term -'; then :{Zs,S}hKeywordPrg (or K) will crap out and spew terminal garbage into less when bash's "help" fails. This was introduced by 2f25e40b1 (runtime: configure keywordpg for some file types (#5566), 2023-08-23) and may be present in other files touched by that commit. Make the "man" invocation sensible by unsetting MANPAGER in the environment. Note that changing MANPAGER for `:terminal` is not needed; Vim within Vim is perfectly fine. closes: #14679 Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 06 May 2024 20:00:09 +0200
parents aadd1cae2ff5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 *
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 *
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 /*
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 * kword_test.c: Unittests for vim_iswordc() and vim_iswordp().
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 #undef NDEBUG
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 #include <assert.h>
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
18800
f41b55f9357c patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
17 // Must include main.c because it contains much more than just main()
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 #define NO_VIM_MAIN
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 #include "main.c"
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
18800
f41b55f9357c patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
21 // This file has to be included because the tested functions are static
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 #include "charset.c"
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 /*
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 * Test the results of vim_iswordc() and vim_iswordp() are matched.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 static void
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 test_isword_funcs_utf8(void)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 buf_T buf;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 int c;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
33 CLEAR_FIELD(buf);
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 p_enc = (char_u *)"utf-8";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 p_isi = (char_u *)"";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 p_isp = (char_u *)"";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 p_isf = (char_u *)"";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 buf.b_p_isk = (char_u *)"@,48-57,_,128-167,224-235";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 curbuf = &buf;
18800
f41b55f9357c patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
41 mb_init(); // calls init_chartab()
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 for (c = 0; c < 0x10000; ++c)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 char_u p[4] = {0};
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 int c1;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 int retc;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 int retp;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 utf_char2bytes(c, p);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 c1 = utf_ptr2char(p);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 if (c != c1)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 fprintf(stderr, "Failed: ");
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 fprintf(stderr,
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 "[c = %#04x, p = {%#02x, %#02x, %#02x}] ",
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 c, p[0], p[1], p[2]);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 fprintf(stderr, "c != utf_ptr2char(p) (=%#04x)\n", c1);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 abort();
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 retc = vim_iswordc_buf(c, &buf);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 retp = vim_iswordp_buf(p, &buf);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 if (retc != retp)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 fprintf(stderr, "Failed: ");
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 fprintf(stderr,
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 "[c = %#04x, p = {%#02x, %#02x, %#02x}] ",
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 c, p[0], p[1], p[2]);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 fprintf(stderr, "vim_iswordc(c) (=%d) != vim_iswordp(p) (=%d)\n",
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 retc, retp);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 abort();
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 int
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 main(void)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18800
diff changeset
79 estack_init();
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 test_isword_funcs_utf8();
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 return 0;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 }