File indexing completed on 2024-04-28 09:37:06

0001 #!/usr/bin/perl -w
0002 
0003 # Usage: remove_virtual_prefix.pl *.h 
0004 # remove virtual when we have Q_DECL_OVERRIDE
0005 
0006 use strict;
0007 use File::Basename;
0008 use lib dirname($0);
0009 use functionUtilkde;
0010 
0011 foreach my $file (@ARGV) {
0012 
0013     # I don't use functionUtilkde::substInFile because it touches all files, even those which were not modified.
0014     my $modified;
0015     open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n";
0016     my @l = map {
0017         my $orig = $_;
0018 
0019         my $regexp = qr/
0020            ^(\s*)                        # (1) Indentation
0021            virtual\s*                    # (2) virtual
0022            (.*)                          # (3) function
0023            Q_DECL_OVERRIDE(.*)$
0024            /x; # /x Enables extended whitespace mode
0025         if (my ($indent, $function, $end) = $_ =~ $regexp) {
0026            $_ = $indent . $function . "Q_DECL_OVERRIDE" . $end . "\n";
0027         }
0028 
0029         my $regexpComment = qr/
0030            ^(\s*)                        # (1) Indentation
0031            \/\*\s*reimp\s*\*\/\s*                    # (2) reimp comment
0032            (.*)                          # (3) function
0033            Q_DECL_OVERRIDE(.*)$
0034            /x; # /x Enables extended whitespace mode
0035         if (my ($indent, $function, $end) = $_ =~ $regexpComment) {
0036            $_ = $indent . $function . "Q_DECL_OVERRIDE" . $end . "\n";
0037         }
0038 
0039         my $regexp2 = qr/
0040            ^(\s*)                        # (1) Indentation
0041            virtual\s*                    # (2) virtual
0042            (.*)                          # (3) function
0043            override(.*)$
0044            /x; # /x Enables extended whitespace mode
0045         if (my ($indent, $function, $end) = $_ =~ $regexp2) {
0046            $_ = $indent . $function . "override" . $end . "\n";
0047         }
0048 
0049         my $regexpComment2 = qr/
0050            ^(\s*)                        # (1) Indentation
0051            \/\*\s*reimp\s*\*\/\s*                    # (2) reimp comment
0052            (.*)                          # (3) function
0053            override(.*)$
0054            /x; # /x Enables extended whitespace mode
0055         if (my ($indent, $function, $end) = $_ =~ $regexpComment2) {
0056            $_ = $indent . $function . "override" . $end . "\n";
0057         }
0058         
0059         
0060         $modified ||= $orig ne $_;
0061         $_;
0062     } <$FILE>;
0063 
0064     if ($modified) {
0065         open (my $OUT, ">", $file);
0066         print $OUT @l;
0067         close ($OUT);
0068     }
0069 }
0070 
0071 functionUtilkde::diffFile( "@ARGV" );