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."
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.