File: remove_virtual_prefix.pl

package info (click to toggle)
kde-dev-scripts 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,612 kB
  • sloc: perl: 15,615; lisp: 5,627; sh: 4,560; python: 3,892; ruby: 1,386; makefile: 13; sed: 9
file content (71 lines) | stat: -rwxr-xr-x 2,415 bytes parent folder | download | duplicates (3)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl -w

# Usage: remove_virtual_prefix.pl *.h 
# remove virtual when we have Q_DECL_OVERRIDE

use strict;
use File::Basename;
use lib dirname($0);
use functionUtilkde;

foreach my $file (@ARGV) {

    # I don't use functionUtilkde::substInFile because it touches all files, even those which were not modified.
    my $modified;
    open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n";
    my @l = map {
        my $orig = $_;

        my $regexp = qr/
           ^(\s*)                        # (1) Indentation
           virtual\s*                    # (2) virtual
           (.*)                          # (3) function
           Q_DECL_OVERRIDE(.*)$
           /x; # /x Enables extended whitespace mode
        if (my ($indent, $function, $end) = $_ =~ $regexp) {
           $_ = $indent . $function . "Q_DECL_OVERRIDE" . $end . "\n";
        }

        my $regexpComment = qr/
           ^(\s*)                        # (1) Indentation
           \/\*\s*reimp\s*\*\/\s*                    # (2) reimp comment
           (.*)                          # (3) function
           Q_DECL_OVERRIDE(.*)$
           /x; # /x Enables extended whitespace mode
        if (my ($indent, $function, $end) = $_ =~ $regexpComment) {
           $_ = $indent . $function . "Q_DECL_OVERRIDE" . $end . "\n";
        }

        my $regexp2 = qr/
           ^(\s*)                        # (1) Indentation
           virtual\s*                    # (2) virtual
           (.*)                          # (3) function
           override(.*)$
           /x; # /x Enables extended whitespace mode
        if (my ($indent, $function, $end) = $_ =~ $regexp2) {
           $_ = $indent . $function . "override" . $end . "\n";
        }

        my $regexpComment2 = qr/
           ^(\s*)                        # (1) Indentation
           \/\*\s*reimp\s*\*\/\s*                    # (2) reimp comment
           (.*)                          # (3) function
           override(.*)$
           /x; # /x Enables extended whitespace mode
        if (my ($indent, $function, $end) = $_ =~ $regexpComment2) {
           $_ = $indent . $function . "override" . $end . "\n";
        }
        
        
        $modified ||= $orig ne $_;
        $_;
    } <$FILE>;

    if ($modified) {
        open (my $OUT, ">", $file);
        print $OUT @l;
        close ($OUT);
    }
}

functionUtilkde::diffFile( "@ARGV" );