annotate runtime/doc/doctags.c @ 1926:43d337097e4c v7.2.223

updated for version 7.2-223
author vimboss
date Thu, 09 Jul 2009 13:55:43 +0000
parents 3fc0f57ecb91
children 33ba2adb6065
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 main(argc, argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 int argc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 char **argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char line[LINELEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 char *p1, *p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if (argc <= 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 fprintf(stderr, "Usage: doctags docfile ... >tags\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 exit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 printf("help-tags\ttags\t1\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 while (--argc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 ++argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 fd = fopen(argv[0], "r");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 fprintf(stderr, "Unable to open %s for reading\n", argv[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 while (fgets(line, LINELEN, fd) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 p1 = strchr(line, '*'); /* find first '*' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 while (p1 != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 p2 = strchr(p1 + 1, '*'); /* find second '*' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if (p2 != NULL && p2 > p1 + 1) /* skip "*" and "**" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 for (p = p1 + 1; p < p2; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 if (*p == ' ' || *p == '\t' || *p == '|')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 * Only accept a *tag* when it consists of valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 * characters, there is white space before it and is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 * followed by a white character or end-of-line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 if (p == p2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 && (p1 == line || p1[-1] == ' ' || p1[-1] == '\t')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 && (strchr(" \t\n\r", p[1]) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 || p[1] == '\0'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 *p2 = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 ++p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 printf("%s\t%s\t/*", p1, argv[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 while (*p1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 /* insert backslash before '\\' and '/' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 if (*p1 == '\\' || *p1 == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 putchar('\\');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 putchar(*p1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 ++p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 printf("*\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 p2 = strchr(p2 + 1, '*'); /* find next '*' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 p1 = p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 }