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);
}
|