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

0001 #!/usr/bin/perl
0002 
0003 # laurent Montel <montel@kde.org> 2006 GPL
0004 # This function allows to adapt file to new kconfig  API
0005 # in KDE4 writePathEntry/deleteEntry/deleteGroup API changed
0006 # Now we used QFLAGS
0007 # 
0008 use File::Basename;
0009 use lib dirname( $0 );
0010 use functionUtilkde;
0011 use strict;
0012 
0013 open(my $F, '-|', qw(find . -type f));
0014 my $file;
0015 while ($file = <$F>) {
0016     chomp $file;
0017     next if functionUtilkde::excludeFile( $file);
0018 
0019     my $modified;
0020     my @necessaryIncludes = ();
0021     open(my $FILE, $file) or warn "We can't open file $file:$!\n";
0022     my @l = map {
0023     my $orig = $_;
0024 
0025     # writePathEntry change API
0026     if (my ($prefix, $parenthese, $end) = /(.*writePathEntry\s*\()(.*)(\).*)/) {
0027             #warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";  
0028         my $changes = $end;
0029         $changes =~ s/\)//;
0030         if ( my ($firstelement, $secondelement,$thirdelement,$fouthelement,$fifthelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*),\s*(.*),\*(.*)$!) {
0031                 #warn "5 elements : firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement> fouthelement <$fouthelement> fifthelement <fifthelement> \n";
0032         if ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(true|TRUE)/ && $fifthelement =~ /(true|TRUE)/  )
0033         {
0034             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::Global|KConfigBase::NLS" .  $end . "\n";
0035             }
0036         elsif ( $thirdelement =~ /(false|FALSE)/ && $fouthelement =~ /(true|TRUE)/ && $fifthelement =~ /(true|TRUE)/  )
0037         {
0038             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Global|KConfigBase::NLS" .  $end . "\n";
0039         }
0040         elsif ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(false|FALSE)/ && $fifthelement =~ /(true|TRUE)/ )
0041         {
0042             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::NLS" .  $end . "\n";
0043         }
0044         
0045         }
0046         elsif ( my ($firstelement, $secondelement,$thirdelement,$fouthelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*),\s*(.*)$!) {
0047         #warn "4 elements : firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement> fouthelement <$fouthelement> \n";
0048         if ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(true|TRUE)/ )
0049         {
0050             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::Global" .  $end . "\n";
0051             }
0052         elsif ( $thirdelement =~ /(false|FALSE)/ && $fouthelement =~ /(true|TRUE)/ )
0053         {
0054             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Global" .  $end . "\n";
0055         }
0056         elsif ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(false|FALSE)/ )
0057         {
0058             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
0059         }
0060         
0061         }
0062         elsif ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
0063                 #warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
0064         if ( $thirdelement =~ /(true|TRUE)/ )
0065         {
0066             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
0067         }
0068         }
0069     }   
0070 
0071     # deleteGroup Change API
0072     if (my ($prefix, $parenthese, $end) = /(.*deleteGroup\s*\()(.*)(\).*)/) {
0073     #warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";  
0074         my $changes = $end;
0075         $changes =~ s/\)//;
0076         if ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
0077         #warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
0078         if ( $secondelement =~/(false|FALSE)/ && $thirdelement =~ /(true|TRUE)/ )
0079         {
0080             $_ = $prefix . "$firstelement, KConfigBase::Recursive|KConfigBase::Global" .  $end . "\n";
0081         }
0082         elsif ( $secondelement =~/(true|TRUE)/ && $thirdelement =~ /(true|TRUE)/ )
0083         {
0084             $_ = $prefix . "$firstelement, KConfigBase::Global" .  $end . "\n";
0085         }
0086         }
0087     }   
0088     
0089     # deleteEntry change API
0090     if (my ($prefix, $parenthese, $end) = /(.*deleteEntry\s*\()(.*)(\).*)/) {
0091         warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";   
0092         my $changes = $end;
0093         $changes =~ s/\)//;
0094         if ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
0095                 #warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
0096         if ( $secondelement =~/(false|FALSE)/ && $thirdelement =~ /(true|TRUE)/ )
0097         {
0098             $_ = $prefix . "$firstelement, KConfigBase::Global" .  $end . "\n";
0099         }
0100         elsif ( $secondelement =~/(true|TRUE)/ && $thirdelement =~ /(true|TRUE)/ )
0101         {
0102             $_ = $prefix . "$firstelement, KConfigBase::NLS|KConfigBase::Global" .  $end . "\n";
0103         }
0104         elsif ( $secondelement =~/(true|TRUE)/ && $thirdelement =~ /(false|FALSE)/ )
0105         {
0106             $_ = $prefix . "$firstelement, KConfigBase::NLS" .  $end . "\n";
0107         }
0108         }
0109     }   
0110 
0111     # writeEntry change API
0112     if (my ($prefix, $parenthese, $end) = /(.*writeEntry\s*\()(.*)(\).*)/) {
0113     #warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";  
0114         my $changes = $end;
0115         $changes =~ s/\)//;
0116         if ( my ($firstelement, $secondelement,$thirdelement,$fouthelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*),\s*(.*)$!) {
0117         #warn "4 elements : firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement> fouthelement <$fouthelement> \n";
0118         if ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(true|TRUE)/ )
0119         {
0120             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::Global" .  $end . "\n";
0121             }
0122         elsif ( $thirdelement =~ /(false|FALSE)/ && $fouthelement =~ /(true|TRUE)/ )
0123         {
0124             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Global" .  $end . "\n";
0125         }
0126         elsif ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(false|FALSE)/ )
0127         {
0128             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
0129         }
0130         
0131         }
0132         elsif ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
0133                 #warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
0134         if ( $thirdelement =~ /(true|TRUE)/ )
0135         {
0136             $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
0137         }
0138         }
0139     }   
0140     $modified ||= $orig ne $_;
0141     $_;
0142     } <$FILE>;
0143 
0144     if ($modified) {
0145     open (my $OUT, ">", $file);
0146     print $OUT @l;
0147     }
0148 
0149 }
0150 functionUtilkde::diffFile( <$F> );
0151