Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Maintenance Archeology 101

by hsmyers (Canon)
on Apr 20, 2003 at 17:26 UTC ( #251848=CUFP: print w/ replies, xml ) Need Help??

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."

Comment on Maintenance Archeology 101
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://251848]
Approved by benn
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-12-20 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls