http://qs321.pair.com?node_id=251848

For those into (voluntarily or otherwise) maintenance of someone else's code---in this case 25 megabytes of C++ written over time by various and sundry hands (of various and sundry talent), here is a script that might be of use. It uses the output of ctags as input (pipe fans out there know what to do...) with the result of a reasonably useful table in mySQL.

#!/perl/bin/perl # # tag2msql.pl -- convert ctags -x output into a mysql table. use strict; use warnings; use diagnostics; use DBI; my $dbh = DBI->connect( 'DBI:mysql:host=localhost;database=blitzen', '', '', { PrintError => 0, RaiseError => 1 } ) or die "Cannot connect to Database\n"; my $theQuery; my ($symbol,$type,$line_number,$file_name,$source); while (<>) { if (/^operator/i) { /(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*)/; ($symbol,$type,$line_number,$file_name,$source) = ("$1 $2",$3, +$4,$5,$6); } else { /(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*)/; ($symbol,$type,$line_number,$file_name,$source) = ($1,$2,$3,$4 +,$5); } $symbol = $dbh->quote($symbol); $type = $dbh->quote($type); $line_number = $dbh->quote($line_number); $file_name = $dbh->quote($file_name); $source = $dbh->quote($source); $theQuery = qq{ INSERT symbols(symbol,type,line_number,file_name,source) VALUES($symbol,$type,$line_number,$file_name,$source) }; $dbh->do($theQuery) or warn("Cannot do query\n"); } $dbh->disconnect(); #mysql> describe symbol; #+-------------+--------------+------+-----+---------+-------+ #| Field | Type | Null | Key | Default | Extra | #+-------------+--------------+------+-----+---------+-------+ #| symbol | varchar(250) | | PRI | | | #| type | varchar(250) | | MUL | | | #| line_number | smallint(6) | | PRI | 0 | | #| file_name | varchar(200) | | PRI | | | #| source | varchar(250) | | | | | #+-------------+--------------+------+-----+---------+-------+ #5 rows in set (0.00 sec)

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."