File: fixtags.c

package info (click to toggle)
levee 4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: ansic: 7,619; pascal: 994; sh: 185; makefile: 74; asm: 29
file content (35 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * replace the weird ctags tag for main() with an actual tag
 * that can be picked by a non-heroic search for the tag main
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>


int
main()
{
    char line[200];
    char *tag, *file, *pattern;
    char *found;


    while (fgets(line, sizeof line, stdin)) {
	tag = strtok(line, "\t");
	file = strtok(0, "\t");
	pattern = strtok(0, "\n");

	if ( tag[0] == 'M' ) {
	    found = strstr(pattern, "main(");

	    if ( found && ((found == pattern) || !isalnum(found[-1])) ) {
		printf("%s\t%s\t%s\n", "main", file, pattern);
		continue;
	    }
	}
	printf("%s\t%s\t%s\n", tag, file, pattern);
    }
    exit(0);
}