File indexing completed on 2024-04-21 05:41:56

0001 #!/usr/bin/perl
0002 
0003 # laurent Montel <montel@kde.org> 2006 GPL
0004 # Reinhold Kainhofer <reinhold@kainhofer.com> 2006 GPL
0005 #
0006 # simple script to replace QIODevice::at by either QIODevice::pos or QIODevice::seek
0007 #
0008 # usage:
0009 #    convert-qiodevice_at.pl *.cpp
0010 #
0011 # CAUTION: This script replaces all calls to methods named 'at', even if the 
0012 # object is not a QIODevice. So check whether the file contains only QIODevice 
0013 # calls or also QList etc. Alternatively, I apply the script only to files that 
0014 # throw a deprecated warning and compare the # of deprecated warnings to the nr 
0015 # of replacements.
0016 
0017 
0018 use File::Basename;
0019 use lib dirname( $0 );
0020 use functionUtilkde;
0021 use strict;
0022 
0023 foreach my $file (@ARGV) {
0024     chomp $file;
0025     next if functionUtilkde::excludeFile( $file);
0026 
0027     my $modified;
0028     my @necessaryIncludes = ();
0029     open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n";
0030     my @l = map {
0031       my $orig = $_;
0032       if ( m![\.>]at\s*\(! ) {
0033         s/([\.>])at(\s*)\((\s*)\)/\1pos\2(\3)/g;
0034         s/([\.>])at(\s*)\((\s*[^)])/\1seek\2(\3/g;
0035 # print "Old line:      \n$orig";
0036 # print "New line:      \n$_====================\n";
0037       }
0038       s!.eof\s*\(\s*\)!.atEnd()!;
0039       $modified ||= $orig ne $_;
0040       $_;
0041     } <$FILE>;
0042 
0043     if ($modified) {
0044       print "Modified: $file\n";
0045       open (my $OUT, ">", $file);
0046       print $OUT @l;
0047       close $OUT;
0048     }
0049 
0050 }
0051 functionUtilkde::diffFile( @ARGV );
0052