File: ctags-fix

package info (click to toggle)
infernal 1.1.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,208 kB
  • sloc: ansic: 230,749; perl: 14,433; sh: 6,147; makefile: 3,071; python: 1,247
file content (25 lines) | stat: -rwxr-xr-x 980 bytes parent folder | download | duplicates (11)
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
#! /usr/bin/perl

# To be used in an idiomatic pipe for listing all keywords in a codebase:
#
#  find . -name \*.[ch] -exec ctags -x {} \; | ~/src/easel/trunk/devkit/ctags-fix | sort | tbl-pretty -f3 > 00INDEX
#
# ctags apparently prints a %15s %4d format
# on keywords >15 long + linenumbers > 3 digits long, ctags merges the
# first two fields, as in:
#   esl_msa_FormatDesc1221 ./easel/esl_msa.c esl_msa_FormatDesc(ESL_MSA *msa, const char *desc, ...)
# We try to detect this as best as possible; the possible ambiguity
# is when the keyword name itself ends in a digit. To dismbiguate, we
# assume no files have >=10000 lines.
#
# we also assume ctags has been called in a pipe from 'find',
# so all filenames start with './', as in:
#   find . -name \*.[ch] -exec ctags -x {} \; | ctags-fix > foo
# This allows us to unambiguously find the true third column.


while (<>)
{
    if (/^(\S{16,})(\d{4})\s+(\.\/.+)$/) { printf("%s %d %s\n", $1, $2, $3); }
    else { print; }
}