~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/helpers/apr_rename.pl

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
use strict;
 
3
use ExtUtils::MakeMaker qw(prompt);
 
4
use File::Find;
 
5
 
 
6
my $just_check = @ARGV ? $ARGV[0] eq '-c' : 0;
 
7
shift if $just_check;
 
8
my $dir = shift || '.';
 
9
my %names;
 
10
 
 
11
my $prefix = 'apr_';
 
12
 
 
13
while (<DATA>) {
 
14
    chomp;
 
15
    my($old, $new) = grep { s/^$prefix//o } split;
 
16
    next unless $old and $new;
 
17
    $names{$old} = $new;
 
18
}
 
19
 
 
20
my $pattern = join '|', keys %names;
 
21
#print "replacement pattern=$pattern\n";
 
22
 
 
23
find sub {
 
24
    chomp;
 
25
    return unless /\.[ch]$/;
 
26
    my $file = "$File::Find::dir/$_";
 
27
    print "looking in $file\n";
 
28
 
 
29
    replace($_, !$just_check);
 
30
 
 
31
}, $dir;
 
32
 
 
33
sub replace {
 
34
    my($file, $replace) = @_;
 
35
    local *IN, *OUT;
 
36
    my @lines;
 
37
    my $found = 0;
 
38
 
 
39
    open IN, $file or die "open $file: $!";
 
40
 
 
41
    while (<IN>) {
 
42
        for (m/[^_\"]*$prefix($pattern)\b/og) {
 
43
            $found++;
 
44
            print "   $file:$. apr_$_ -> apr_$names{$_}\n";
 
45
        }
 
46
        push @lines, $_ if $replace;
 
47
    }
 
48
 
 
49
    close IN;
 
50
 
 
51
    return unless $found and $replace;
 
52
 
 
53
#    my $ans = prompt("replace?", 'y');
 
54
#    return unless $ans =~ /^y/i;
 
55
 
 
56
    open OUT, ">$file" or die "open $file: $!";
 
57
 
 
58
    for (@lines) {
 
59
        unless (/^\#include/) {
 
60
            s/([^_\"]*$prefix)($pattern)\b/$1$names{$2}/og;
 
61
        }
 
62
        print OUT $_;
 
63
    }
 
64
 
 
65
    close OUT;
 
66
}
 
67
 
 
68
__DATA__
 
69
apr_time_t:
 
70
apr_implode_gmt              apr_time_exp_gmt_get
 
71
 
 
72
apr_socket_t:
 
73
apr_close_socket             apr_socket_close
 
74
apr_create_socket            apr_socket_create
 
75
apr_get_sockaddr             apr_socket_addr_get
 
76
apr_get_socketdata           apr_socket_data_get
 
77
apr_set_socketdata           apr_socket_data_set
 
78
apr_shutdown                 apr_socket_shutdown
 
79
apr_bind                     apr_socket_bind
 
80
apr_listen                   apr_socket_listen
 
81
apr_accept                   apr_socket_accept
 
82
apr_connect                  apr_socket_connect
 
83
apr_send                     apr_socket_send
 
84
apr_sendv                    apr_socket_sendv
 
85
apr_sendto                   apr_socket_sendto
 
86
apr_recvfrom                 apr_socket_recvfrom
 
87
apr_sendfile                 apr_socket_sendfile
 
88
apr_recv                     apr_socket_recv
 
89
 
 
90
apr_filepath_*:
 
91
apr_filename_of_pathname     apr_filepath_name_get
 
92
 
 
93
apr_gid_t:
 
94
apr_get_groupid              apr_gid_get
 
95
apr_get_groupname            apr_gid_name_get
 
96
apr_group_name_get           apr_gid_name_get
 
97
apr_compare_groups           apr_gid_compare
 
98
 
 
99
apr_uid_t:
 
100
apr_get_home_directory       apr_uid_homepath_get
 
101
apr_get_userid               apr_uid_get
 
102
apr_current_userid           apr_uid_current
 
103
apr_compare_users            apr_uid_compare
 
104
apr_get_username             apr_uid_name_get
 
105
apr_compare_users            apr_uid_compare
 
106