DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (495129e490bc)

VCS Links

Line Code
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#!/usr/bin/perl
# update-root-xref.pl -- Fixes genxref's paths in case the internal paths change
#
# License: standard mozilla mpl-tri
# orginal author: timeless

######################################################################

use lib 'lib';
use integer;
use DB_File;
use strict;
use Cwd;

my (%fileidx_in, %fileidx);

my ($realpath, $oldpath, $newpath) = ($ARGV[0], $ARGV[1], $ARGV[2]);
$realpath ||= '.';
$realpath .= '/';
$newpath = '' if $newpath eq "''";

sub rewrite {
    my $start = time;
    my $fnum = scalar keys %fileidx_in;
    my $f;


    for (my $curfnum = 1; $curfnum <= $fnum; ++$curfnum) {
        $f = $fileidx_in{$curfnum};
        $f =~ s{$oldpath}{$newpath};
        $fileidx{$curfnum} = $f;
    }

    print(STDERR
          "Completed rewrite ".$fnum." file entries updated.\n\n");
}

chdir($realpath);
tie (%fileidx_in, "DB_File", "fileidx", O_RDONLY, 0660, $DB_HASH)
    || die('Could not open "fileidx" for reading');
tie (%fileidx, "DB_File", "fileidx.out.$$", O_RDWR|O_CREAT, 0660, $DB_HASH)
    || die("Could not open \"fileidx.out.$$\" for writing");


print(STDERR "Rewriting index in $realpath.\n");
chdir($realpath);

rewrite($oldpath, $newpath);

dbmclose(%fileidx);
dbmclose(%fileidx_in);

rename("fileidx.out.$$", "fileidx")
    || die "Couldn't rename fileidx.out.$$ to fileidx";