annotate runtime/doc/doctags.c @ 14910:69e45d17a823

Added tag v8.1.0466 for changeset c97b4b537572bd9f167c43da52a20584d96c7c2d
author Christian Brabandt <cb@256bit.org>
date Sun, 07 Oct 2018 23:30:07 +0200
parents 33ba2adb6065
children c002c4899529
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 * this program makes a tags file for vim_ref.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * Usage: doctags vim_ref.txt vim_win.txt ... >tags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * A tag in this context is an identifier between stars, e.g. *c_files*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 #include <string.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 #include <ctype.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 #include <stdlib.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #define LINELEN 200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 int
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
17 main(int argc, char **argv)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 char line[LINELEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 char *p1, *p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 if (argc <= 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 fprintf(stderr, "Usage: doctags docfile ... >tags\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 exit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 printf("help-tags\ttags\t1\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 while (--argc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 ++argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 fd = fopen(argv[0], "r");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 fprintf(stderr, "Unable to open %s for reading\n", argv[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 while (fgets(line, LINELEN, fd) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 p1 = strchr(line, '*'); /* find first '*' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 while (p1 != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 p2 = strchr(p1 + 1, '*'); /* find second '*' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if (p2 != NULL && p2 > p1 + 1) /* skip "*" and "**" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 for (p = p1 + 1; p < p2; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if (*p == ' ' || *p == '\t' || *p == '|')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 * Only accept a *tag* when it consists of valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 * characters, there is white space before it and is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 * followed by a white character or end-of-line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if (p == p2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 && (p1 == line || p1[-1] == ' ' || p1[-1] == '\t')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 && (strchr(" \t\n\r", p[1]) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 || p[1] == '\0'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 *p2 = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 ++p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 printf("%s\t%s\t/*", p1, argv[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 while (*p1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 /* insert backslash before '\\' and '/' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 if (*p1 == '\\' || *p1 == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 putchar('\\');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 putchar(*p1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 ++p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 printf("*\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 p2 = strchr(p2 + 1, '*'); /* find next '*' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 p1 = p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 }