2 * this program makes a tags file for vim_ref.txt
4 * Usage: doctags vim_ref.txt vim_win.txt ... >tags
6 * A tag in this context is an identifier between stars, e.g. *c_files*
28 fprintf(stderr
, "Usage: doctags docfile ... >tags\n");
31 printf("help-tags\ttags\t1\n");
35 fd
= fopen(argv
[0], "r");
38 fprintf(stderr
, "Unable to open %s for reading\n", argv
[0]);
41 while (fgets(line
, LINELEN
, fd
) != NULL
)
43 p1
= strchr(line
, '*'); /* find first '*' */
46 p2
= strchr(p1
+ 1, '*'); /* find second '*' */
47 if (p2
!= NULL
&& p2
> p1
+ 1) /* skip "*" and "**" */
49 for (p
= p1
+ 1; p
< p2
; ++p
)
50 if (*p
== ' ' || *p
== '\t' || *p
== '|')
53 * Only accept a *tag* when it consists of valid
54 * characters, there is white space before it and is
55 * followed by a white character or end-of-line.
58 && (p1
== line
|| p1
[-1] == ' ' || p1
[-1] == '\t')
59 && (strchr(" \t\n\r", p
[1]) != NULL
64 printf("%s\t%s\t/*", p1
, argv
[0]);
67 /* insert backslash before '\\' and '/' */
68 if (*p1
== '\\' || *p1
== '/')
74 p2
= strchr(p2
+ 1, '*'); /* find next '*' */