Mercurial > vim
annotate runtime/doc/doctags.c @ 9340:387cd517939f v7.4.1952
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 21 23:42:20 2016 +0200
patch 7.4.1952
Problem: Cscope interface does not support finding assignments.
Solution: Add the "a" command. (ppettina, closes https://github.com/vim/vim/issues/882)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 21 Jun 2016 23:45:06 +0200 |
parents | 33ba2adb6065 |
children | c002c4899529 |
rev | line source |
---|---|
7 | 1 /* vim:set ts=4 sw=4: |
2 * this program makes a tags file for vim_ref.txt | |
3 * | |
4 * Usage: doctags vim_ref.txt vim_win.txt ... >tags | |
5 * | |
6 * A tag in this context is an identifier between stars, e.g. *c_files* | |
7 */ | |
8 | |
9 #include <stdio.h> | |
10 #include <string.h> | |
11 #include <ctype.h> | |
12 #include <stdlib.h> | |
13 | |
14 #define LINELEN 200 | |
15 | |
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 | 18 { |
19 char line[LINELEN]; | |
20 char *p1, *p2; | |
21 char *p; | |
22 FILE *fd; | |
23 | |
24 if (argc <= 1) | |
25 { | |
26 fprintf(stderr, "Usage: doctags docfile ... >tags\n"); | |
27 exit(1); | |
28 } | |
29 printf("help-tags\ttags\t1\n"); | |
30 while (--argc > 0) | |
31 { | |
32 ++argv; | |
33 fd = fopen(argv[0], "r"); | |
34 if (fd == NULL) | |
35 { | |
36 fprintf(stderr, "Unable to open %s for reading\n", argv[0]); | |
37 continue; | |
38 } | |
39 while (fgets(line, LINELEN, fd) != NULL) | |
40 { | |
41 p1 = strchr(line, '*'); /* find first '*' */ | |
42 while (p1 != NULL) | |
43 { | |
44 p2 = strchr(p1 + 1, '*'); /* find second '*' */ | |
45 if (p2 != NULL && p2 > p1 + 1) /* skip "*" and "**" */ | |
46 { | |
47 for (p = p1 + 1; p < p2; ++p) | |
48 if (*p == ' ' || *p == '\t' || *p == '|') | |
49 break; | |
50 /* | |
51 * Only accept a *tag* when it consists of valid | |
52 * characters, there is white space before it and is | |
53 * followed by a white character or end-of-line. | |
54 */ | |
55 if (p == p2 | |
56 && (p1 == line || p1[-1] == ' ' || p1[-1] == '\t') | |
57 && (strchr(" \t\n\r", p[1]) != NULL | |
58 || p[1] == '\0')) | |
59 { | |
60 *p2 = '\0'; | |
61 ++p1; | |
62 printf("%s\t%s\t/*", p1, argv[0]); | |
63 while (*p1) | |
64 { | |
65 /* insert backslash before '\\' and '/' */ | |
66 if (*p1 == '\\' || *p1 == '/') | |
67 putchar('\\'); | |
68 putchar(*p1); | |
69 ++p1; | |
70 } | |
71 printf("*\n"); | |
72 p2 = strchr(p2 + 1, '*'); /* find next '*' */ | |
73 } | |
74 } | |
75 p1 = p2; | |
76 } | |
77 } | |
78 fclose(fd); | |
79 } | |
80 return 0; | |
81 } |