#!/usr/bin/perl # this script should help in the transition from RC4 to RC5 # it will not fix everything - you'll need to adjust it # to the requirements of your codebase. # # and yeah, this code is suboptimal. like most one-offs it # started as a copy of another script entirely, and I never # expected to share it. thus it's not really a good example # of well written or well thought out perl, but it should be # ok for the one time you'll run it. use File::Find; use IO::File; use Getopt::Std; use File::Copy; use strict; # some updates from stas on 20050426 - thanks stas :) my @apache_classes = qw(Access BuildConfig Build CmdParms Command compat Connection Const Directive Filter FilterRec HookRun Log Module MPM ParseSource PerlSections PerlSections porting Process Reload RequestIO RequestRec RequestUtil Resource Response ServerRec ServerUtil SizeLimit SourceTables Status SubProcess SubRequest URI Util XSLoader); my @constants = qw(AUTH_REQUIRED BLOCK_READ CONN_CLOSE CONN_KEEPALIVE CRLF DECLINED DONE EACCES EAGAIN EBUSY EMISMATCH ENOPOLL EOF EXIT FILETYPE_REG FINFO_NORM FORBIDDEN HTTP_UNAUTHORIZED ITERATE LOG_INFO M_GET MODE_GETLINE MODE_READBYTES M_POST M_PUT NO_ARGS NOT_FOUND OK OR_ALL POLLIN REMOTE_HOST REMOTE_NAME RSRC_CONF SERVER_ERROR SO_NONBLOCK SUCCESS SUCCESS TAKE1 TAKE23 TIMEUP URI_UNP_OMITSITEPART URI_UNP_OMITUSER); my %list = (); find(\&grep,"."); sub grep { unless ( -d || -B ) { $list{$File::Find::name}++; } } foreach my $file (sort keys %list) { next if $file =~ m/fixme.pl/g; next if $file =~ m/svn/g; next if $file =~ m/compat.pod/g; my $fh = IO::File->new($file); print "doing $file\n"; my $tmp = IO::File->new(">$file.tmp"); while (my $line = <$fh>) { # methods $line =~ s/Apache2->request/Apache2::RequestUtil->request/g; $line =~ s/Apache2->server/Apache2::ServerUtil->server/g; # classes for (@apache_classes) { $line =~ s/Apache::$_/Apache2::$_/g; } # constants for (@constants) { $line =~ s/APR::$_/APR::Const::$_/g; $line =~ s/Apache::$_/Apache2::Const::$_/g; } print $tmp $line; } undef $fh; undef $tmp; print "done\n"; move("$file.tmp", $file); }