annotate runtime/doc/doctags.c @ 33846:bc2505818986

runtime(html): Update syntax file (#13591) Commit: https://github.com/vim/vim/commit/a9058440b7b9d7f5d0027c8cd44366e9200ca241 Author: dkearns <dougkearns@gmail.com> Date: Wed Nov 29 06:41:41 2023 +1100 runtime(html): Update syntax file (https://github.com/vim/vim/issues/13591) Add missing search element and update ARIA attribute list. Add a very basic test file to check all elements are matched. Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 28 Nov 2023 20:45:07 +0100
parents af4ffc4b2a26
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vim:set ts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 7837
diff changeset
3 * This program makes a tags file for help text.
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 7837
diff changeset
4 *
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 7837
diff changeset
5 * Usage: doctags *.txt ... >tags
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * A tag in this context is an identifier between stars, e.g. *c_files*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 #include <string.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 #include <ctype.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 #include <stdlib.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #define LINELEN 200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 int
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
18 main(int argc, char **argv)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 char line[LINELEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char *p1, *p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 FILE *fd;
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
24 int len;
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
25 int in_example;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 if (argc <= 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 fprintf(stderr, "Usage: doctags docfile ... >tags\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 exit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 printf("help-tags\ttags\t1\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 while (--argc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 ++argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 fd = fopen(argv[0], "r");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 fprintf(stderr, "Unable to open %s for reading\n", argv[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 }
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
42 in_example = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 while (fgets(line, LINELEN, fd) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 {
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
45 if (in_example)
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
46 {
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
47 // skip over example; non-blank in first column ends example
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
48 if (strchr(" \t\n\r", line[0]) != NULL)
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
49 continue;
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
50 in_example = 0;
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
51 }
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
52 p1 = strchr(line, '*'); // find first '*'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 while (p1 != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 {
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
55 p2 = strchr(p1 + 1, '*'); // find second '*'
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
56 if (p2 != NULL && p2 > p1 + 1) // skip "*" and "**"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 for (p = p1 + 1; p < p2; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 if (*p == ' ' || *p == '\t' || *p == '|')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 break;
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
61 // Only accept a *tag* when it consists of valid
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
62 // characters, there is white space before it and is
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
63 // followed by a white character or end-of-line.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 if (p == p2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 && (p1 == line || p1[-1] == ' ' || p1[-1] == '\t')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 && (strchr(" \t\n\r", p[1]) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 || p[1] == '\0'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 *p2 = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 ++p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 printf("%s\t%s\t/*", p1, argv[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 while (*p1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 {
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
74 // insert backslash before '\\' and '/'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 if (*p1 == '\\' || *p1 == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 putchar('\\');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 putchar(*p1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 ++p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 printf("*\n");
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
81 p2 = strchr(p2 + 1, '*'); // find next '*'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 p1 = p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 }
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
86 len = strlen(line);
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
87 if ((len == 2 && strcmp(&line[len - 2], ">\n") == 0)
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
88 || (len >= 3 && strcmp(&line[len - 3], " >\n") == 0))
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
89 in_example = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 }