File: adapt-to-new-kconfig2.pl

package info (click to toggle)
kde-dev-scripts 4%3A18.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,496 kB
  • sloc: perl: 15,466; lisp: 5,627; sh: 4,157; python: 3,892; ruby: 2,158; makefile: 16; sed: 9
file content (151 lines) | stat: -rwxr-xr-x 6,399 bytes parent folder | download | duplicates (6)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/perl

# laurent Montel <montel@kde.org> 2006 GPL
# This function allows to adapt file to new kconfig  API
# in KDE4 writePathEntry/deleteEntry/deleteGroup API changed
# Now we used QFLAGS
# 
use File::Basename;
use lib dirname( $0 );
use functionUtilkde;
use strict;

open(my $F, '-|', qw(find . -type f));
my $file;
while ($file = <$F>) {
    chomp $file;
    next if functionUtilkde::excludeFile( $file);

    my $modified;
    my @necessaryIncludes = ();
    open(my $FILE, $file) or warn "We can't open file $file:$!\n";
    my @l = map {
	my $orig = $_;

	# writePathEntry change API
	if (my ($prefix, $parenthese, $end) = /(.*writePathEntry\s*\()(.*)(\).*)/) {
			#warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";	
	    my $changes = $end;
	    $changes =~ s/\)//;
	    if ( my ($firstelement, $secondelement,$thirdelement,$fouthelement,$fifthelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*),\s*(.*),\*(.*)$!) {
				#warn "5 elements : firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement> fouthelement <$fouthelement> fifthelement <fifthelement> \n";
		if ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(true|TRUE)/ && $fifthelement =~ /(true|TRUE)/  )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::Global|KConfigBase::NLS" .  $end . "\n";
	        }
		elsif ( $thirdelement =~ /(false|FALSE)/ && $fouthelement =~ /(true|TRUE)/ && $fifthelement =~ /(true|TRUE)/  )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Global|KConfigBase::NLS" .  $end . "\n";
		}
		elsif ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(false|FALSE)/ && $fifthelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::NLS" .  $end . "\n";
		}
		
	    }
	    elsif ( my ($firstelement, $secondelement,$thirdelement,$fouthelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*),\s*(.*)$!) {
		#warn "4 elements : firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement> fouthelement <$fouthelement> \n";
		if ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::Global" .  $end . "\n";
	        }
		elsif ( $thirdelement =~ /(false|FALSE)/ && $fouthelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Global" .  $end . "\n";
		}
		elsif ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(false|FALSE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
		}
		
	    }
	    elsif ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
				#warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
		if ( $thirdelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
		}
	    }
	}	

	# deleteGroup Change API
	if (my ($prefix, $parenthese, $end) = /(.*deleteGroup\s*\()(.*)(\).*)/) {
	#warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";	
	    my $changes = $end;
	    $changes =~ s/\)//;
	    if ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
		#warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
		if ( $secondelement =~/(false|FALSE)/ && $thirdelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, KConfigBase::Recursive|KConfigBase::Global" .  $end . "\n";
		}
		elsif ( $secondelement =~/(true|TRUE)/ && $thirdelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, KConfigBase::Global" .  $end . "\n";
		}
	    }
	}	
	
	# deleteEntry change API
	if (my ($prefix, $parenthese, $end) = /(.*deleteEntry\s*\()(.*)(\).*)/) {
	    warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";	
	    my $changes = $end;
	    $changes =~ s/\)//;
	    if ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
				#warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
		if ( $secondelement =~/(false|FALSE)/ && $thirdelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, KConfigBase::Global" .  $end . "\n";
		}
		elsif ( $secondelement =~/(true|TRUE)/ && $thirdelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, KConfigBase::NLS|KConfigBase::Global" .  $end . "\n";
		}
		elsif ( $secondelement =~/(true|TRUE)/ && $thirdelement =~ /(false|FALSE)/ )
		{
		    $_ = $prefix . "$firstelement, KConfigBase::NLS" .  $end . "\n";
		}
	    }
	}	

	# writeEntry change API
	if (my ($prefix, $parenthese, $end) = /(.*writeEntry\s*\()(.*)(\).*)/) {
	#warn "prefix !!!! :<$prefix>  parenthese <$parenthese> end <$end>\n";	
	    my $changes = $end;
	    $changes =~ s/\)//;
	    if ( my ($firstelement, $secondelement,$thirdelement,$fouthelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*),\s*(.*)$!) {
		#warn "4 elements : firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement> fouthelement <$fouthelement> \n";
		if ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal|KConfigBase::Global" .  $end . "\n";
	        }
		elsif ( $thirdelement =~ /(false|FALSE)/ && $fouthelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Global" .  $end . "\n";
		}
		elsif ( $thirdelement =~ /(true|TRUE)/ && $fouthelement =~ /(false|FALSE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
		}
		
	    }
	    elsif ( my ($firstelement, $secondelement,$thirdelement) = $parenthese =~ m!(.*),\s*(.*),\s*(.*)$!) {
				#warn " 3 elements :  firstelement <$firstelement>  secondelement <$secondelement> thirdelement<$thirdelement>\n";
		if ( $thirdelement =~ /(true|TRUE)/ )
		{
		    $_ = $prefix . "$firstelement, $secondelement, KConfigBase::Normal" .  $end . "\n";
		}
	    }
	}	
	$modified ||= $orig ne $_;
	$_;
    } <$FILE>;

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

}
functionUtilkde::diffFile( <$F> );