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