Mercurial > vim
annotate runtime/doc/doctags.c @ 27102:4061623aa316 v8.2.4080
patch 8.2.4080: not sufficient test coverage for xxd
Commit: https://github.com/vim/vim/commit/a00e622a294b10671ee78216dcd21169a2b884cf
Author: Erik Auerswald <auerswal@unix-ag.uni-kl.de>
Date: Thu Jan 13 17:42:28 2022 +0000
patch 8.2.4080: not sufficient test coverage for xxd
Problem: Not sufficient test coverage for xxd.
Solution: Add a few more test cases. (Erki Auerswald, closes https://github.com/vim/vim/issues/9515)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Jan 2022 18:45:03 +0100 |
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 } |