diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 2000-05-17 12:26:56 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 2000-05-17 12:26:56 +0000 |
commit | 3b4b3edb4f7ee43d676a2f92cf7c6c469931fcac (patch) | |
tree | 2252639b2d4a5e433118cd44a8d8ee990dbe3647 | |
parent | fb2b608cb5e85dc702644aee8c19aff93e2db455 (diff) |
Add a little tool to help with building tags files my editor groks.
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | mkjtags.c | 73 |
2 files changed, 78 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 18662afb..2be8e604 100644 --- a/Makefile.am +++ b/Makefile.am @@ -194,3 +194,8 @@ stamp-doc-rc: $(srcdir)/init.h makedoc Muttrc.head $(srcdir)/init.h | ./makedoc -c | cat Muttrc.head - > Muttrc touch stamp-doc-rc + +jtags: TAGS mkjtags + ( ./mkjtags TAGS > tags.$$$$ && mv tags.$$$$ tags ) + +.PHONY: jtags diff --git a/mkjtags.c b/mkjtags.c new file mode 100644 index 00000000..da74a44d --- /dev/null +++ b/mkjtags.c @@ -0,0 +1,73 @@ +/* + * convert multi-file etags files to something + * which can be used by jed. + * + * Thomas Roessler <roessler@guug.de> + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void doit (const char *fname, const char *prefix, int crlf_pending); + + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf (stderr, "usage: %s filename\n", argv[0]); + exit (1); + } + + doit (argv[1], NULL, 0); + return 0; +} + +void doit (const char *fname, const char *prefix, int crlf_pending) +{ + char buffer[2048]; + char tmpf[2048]; + FILE *fp; + char *cp; + + size_t l; + + if (!(fp = fopen (fname, "r"))) + { + perror (fname); + exit (1); + } + + while (fgets (buffer, sizeof (buffer), fp)) + { + l = strlen (buffer); + if (*buffer == '\f') + { + if (!crlf_pending) + fputs (buffer, stdout); + } + else if (crlf_pending && l > 9 && !strcmp (buffer + l - 9, ",include\n")) + { + if ((cp = strrchr (buffer, ','))) + *cp = 0; + strcpy (tmpf, buffer); + + if ((cp = strrchr (buffer, '/'))) + *cp = 0; + + doit (tmpf, buffer, crlf_pending); + } + else if (crlf_pending && prefix) + printf ("%s/%s", prefix, buffer); + else + fputs (buffer, stdout); + + crlf_pending = (*buffer == '\f'); + } + + fclose (fp); +} + + |