| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# $Header: /home/domi/perlDev/Text_Vpp/RCS/Vpp.pm,v 1.27 2005/06/09 13:52:13 domi Exp $ |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# $Source: /home/domi/perlDev/Text_Vpp/RCS/Vpp.pm,v $ |
|
6
|
|
|
|
|
|
|
# $Revision: 1.27 $ |
|
7
|
|
|
|
|
|
|
# $Locker: $ |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
############################################################ |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Text::Vpp; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require 5.6.0; |
|
14
|
1
|
|
|
1
|
|
2805
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
56
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
58
|
|
|
16
|
1
|
|
|
1
|
|
1096
|
use IO::File ; |
|
|
1
|
|
|
|
|
14369
|
|
|
|
1
|
|
|
|
|
175
|
|
|
17
|
1
|
|
|
1
|
|
11
|
use Carp ; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
123
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
1210
|
use AutoLoader qw/AUTOLOAD/ ; |
|
|
1
|
|
|
|
|
2048
|
|
|
|
1
|
|
|
|
|
6
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$VERSION = '1.17' ; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# tiny FiFo "package" |
|
24
|
|
|
|
|
|
|
|
|
25
|
15
|
|
|
15
|
0
|
52
|
sub F_new { return [1]; } |
|
26
|
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
0
|
8
|
sub F_reset { my $FiFo = $_[0]; $FiFo->[0]= 1; $#$FiFo= 0; } |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
13
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
11
|
|
|
11
|
0
|
31
|
sub F_tell { return $_[0]->[0]; } |
|
30
|
|
|
|
|
|
|
|
|
31
|
31
|
|
|
31
|
0
|
64
|
sub F_seek { $_[0]->[0]= $_[1]; } |
|
32
|
|
|
|
|
|
|
|
|
33
|
23
|
|
|
23
|
0
|
29
|
sub F_print { push @{$_[0]}, $_[1]; } |
|
|
23
|
|
|
|
|
93
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
120
|
|
|
120
|
0
|
306
|
sub F_getline { my $FiFo = $_[0]; return $FiFo->[($FiFo->[0])++]; } |
|
|
120
|
|
|
|
|
717
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#--------------------- |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
15
|
|
|
15
|
1
|
14572
|
my $type = shift ; |
|
43
|
|
|
|
|
|
|
|
|
44
|
15
|
|
|
|
|
43
|
my $self = {} ; |
|
45
|
15
|
|
|
|
|
36
|
my $file = shift ; |
|
46
|
15
|
|
|
|
|
23
|
my $ref = shift ; |
|
47
|
15
|
|
|
|
|
28
|
my $action = shift ; |
|
48
|
15
|
|
|
|
|
23
|
my $comment = shift ; |
|
49
|
15
|
|
|
|
|
17
|
my $prefix = shift; |
|
50
|
15
|
|
|
|
|
24
|
my $suffix = shift; |
|
51
|
15
|
|
|
|
|
25
|
my $substitute= shift; |
|
52
|
15
|
|
|
|
|
19
|
my $backslash = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
15
|
100
|
66
|
|
|
63
|
if (defined $ref && (ref($ref) eq "HASH")) |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
4
|
|
|
|
|
12
|
$self->{var} = $ref ; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
15
|
100
|
|
|
|
61
|
$self->{action} = defined $action ? $action : '@' ; |
|
60
|
15
|
100
|
|
|
|
48
|
$self->{comment} = defined $comment ? $comment : '#' ; |
|
61
|
15
|
100
|
|
|
|
44
|
$prefix= '$' unless defined($prefix); #'; # for xemacs |
|
62
|
15
|
|
|
|
|
31
|
$self->{prefix} = $prefix ; |
|
63
|
15
|
|
|
|
|
32
|
$self->{suffix} = $suffix; |
|
64
|
15
|
|
|
|
|
30
|
$self->{substitute}= $substitute; |
|
65
|
15
|
100
|
|
|
|
43
|
$self->{backslash} = defined $backslash ? $backslash : 1 ; |
|
66
|
15
|
100
|
|
|
|
111
|
if ( UNIVERSAL::can($file,'getline') ) |
|
67
|
1
|
|
|
|
|
4
|
{ $self->{fileDesc}= $file; $self->{name}= ref($file); } |
|
|
1
|
|
|
|
|
5
|
|
|
68
|
|
|
|
|
|
|
else |
|
69
|
14
|
|
|
|
|
129
|
{ $self->{fileDesc} = new IO::File; |
|
70
|
14
|
50
|
|
|
|
766
|
$self->{fileDesc}->open($file) || die "can't open $file \n"; |
|
71
|
14
|
|
|
|
|
946
|
$self->{name} = $file ; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
15
|
|
|
|
|
52
|
$self->{Fifo}= F_new; |
|
75
|
|
|
|
|
|
|
|
|
76
|
15
|
|
|
|
|
39
|
$self= bless $self,$type ; |
|
77
|
|
|
|
|
|
|
|
|
78
|
15
|
|
|
|
|
775
|
$self->setActionChar($self->{action}); |
|
79
|
15
|
|
|
|
|
792
|
$self->setPrefixChar($self->{prefix}); |
|
80
|
15
|
|
|
|
|
618
|
$self->setSuffixChar($self->{suffix}); |
|
81
|
15
|
|
|
|
|
595
|
$self->setSubstitute($self->{substitute}); |
|
82
|
15
|
|
|
|
|
498
|
$self->setCommentChar($self->{comment}); |
|
83
|
|
|
|
|
|
|
|
|
84
|
15
|
|
|
|
|
50
|
return $self; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub myEval |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
11
|
|
|
11
|
0
|
19
|
my $self = shift ; |
|
91
|
11
|
|
|
|
|
17
|
my $expression = shift ; |
|
92
|
11
|
|
|
|
|
16
|
my $out = shift ; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# transform each $xxx into $self->{var}{$xxx} |
|
95
|
|
|
|
|
|
|
# this allows for the creation of new variables |
|
96
|
|
|
|
|
|
|
# one may use the construction ${\w} to protect against this |
|
97
|
11
|
|
|
|
|
44
|
$expression =~ s[\$(\w+)\b] [\$self->{var}{$1}]g ; |
|
98
|
|
|
|
|
|
|
|
|
99
|
5
|
|
|
5
|
|
44
|
local *Vpp_Out= ref $out ? sub{push @$out,@_;} : |
|
100
|
11
|
100
|
|
0
|
|
89
|
sub {die "Cannot call Vpp_Out in \@INCLUDE line";} ; |
|
|
0
|
|
|
|
|
0
|
|
|
101
|
11
|
|
|
|
|
950
|
my $return = eval($expression) ; |
|
102
|
|
|
|
|
|
|
|
|
103
|
11
|
50
|
|
|
|
50
|
if ($@ ne "") |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
0
|
|
|
|
|
0
|
die "Error in eval : $@ \n", |
|
106
|
|
|
|
|
|
|
"line : $expression \nfile: $self->{name} line $.\n"; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
11
|
|
|
|
|
56
|
return ($return); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub ReplaceVars |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
56
|
|
|
56
|
0
|
74
|
my $self = shift ; |
|
115
|
|
|
|
|
|
|
|
|
116
|
56
|
|
|
|
|
311
|
$_[0] =~ s[\$({?)(\w+)\b(}?)] |
|
117
|
42
|
50
|
|
|
|
142
|
[if (defined($self->{var}{$2})) |
|
118
|
42
|
50
|
|
|
|
244
|
{ "\$self->{var}{$2}" . ( !$1 ? $3 : '' ); } |
|
|
0
|
|
|
|
|
0
|
|
|
119
|
|
|
|
|
|
|
else {"\$$1$2$3";} |
|
120
|
|
|
|
|
|
|
]ge ; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub myExpression |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
41
|
|
|
41
|
0
|
63
|
my $self = shift ; |
|
127
|
41
|
|
|
|
|
61
|
my $expression = shift ; |
|
128
|
|
|
|
|
|
|
|
|
129
|
41
|
|
|
|
|
87
|
$self->ReplaceVars($expression); |
|
130
|
|
|
|
|
|
|
|
|
131
|
41
|
|
|
|
|
12608
|
my $return = eval($expression) ; |
|
132
|
|
|
|
|
|
|
|
|
133
|
41
|
50
|
|
|
|
166
|
if ($@ ne "") |
|
134
|
|
|
|
|
|
|
{ |
|
135
|
0
|
|
|
|
|
0
|
die "Error in eval : $@ \n", |
|
136
|
|
|
|
|
|
|
"line : $expression \nfile: $self->{name} line $.\n"; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
41
|
|
|
|
|
203
|
return ($return); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub substitute |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
|
|
|
|
|
|
#return array ref made of new file |
|
146
|
16
|
|
|
16
|
1
|
213
|
my ($self,$fileOut) = @_ ; |
|
147
|
|
|
|
|
|
|
|
|
148
|
16
|
|
|
|
|
43
|
$self->{errorText} = [] ; |
|
149
|
16
|
|
|
|
|
37
|
$self->{error} = 0; |
|
150
|
|
|
|
|
|
|
|
|
151
|
16
|
|
|
|
|
27
|
$self->{IF_Level}= 0; $self->{FOR_Level}= 0; |
|
|
16
|
|
|
|
|
26
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
16
|
|
|
|
|
82
|
my $res = $self->processBlock(1,1,0,0,0) ; |
|
154
|
|
|
|
|
|
|
|
|
155
|
16
|
|
|
|
|
59
|
chomp @$res ; |
|
156
|
|
|
|
|
|
|
|
|
157
|
16
|
100
|
|
|
|
32
|
if (defined $fileOut) |
|
158
|
|
|
|
|
|
|
{ |
|
159
|
1
|
50
|
|
|
|
13
|
if ( UNIVERSAL::can($fileOut,'print') ) |
|
160
|
|
|
|
|
|
|
{ |
|
161
|
1
|
|
|
|
|
10
|
$fileOut->print(join("\n",@$res) ,"\n") ; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
else |
|
164
|
|
|
|
|
|
|
{ |
|
165
|
0
|
|
|
|
|
0
|
print "writing $fileOut\n"; |
|
166
|
0
|
|
|
|
|
0
|
my $FileOut = $fileOut; |
|
167
|
0
|
0
|
|
|
|
0
|
$FileOut= ">$fileOut" unless $fileOut =~/^>/; |
|
168
|
0
|
|
|
|
|
0
|
my $SubsOut = new IO::File; |
|
169
|
0
|
0
|
|
|
|
0
|
unless( $SubsOut->open($FileOut) ) |
|
170
|
|
|
|
|
|
|
{ |
|
171
|
0
|
|
|
|
|
0
|
$self->snitch("cannot open $fileOut") ; |
|
172
|
0
|
|
|
|
|
0
|
return 0 ; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
0
|
|
|
|
|
0
|
print $SubsOut join("\n",@$res) ,"\n" ; |
|
175
|
0
|
|
|
|
|
0
|
close $SubsOut ; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
else |
|
179
|
|
|
|
|
|
|
{ |
|
180
|
15
|
|
|
|
|
104
|
$self->{result} = $res ; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
16
|
|
|
|
|
100
|
return (not $self->{error} ) ; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub getText |
|
187
|
|
|
|
|
|
|
{ |
|
188
|
15
|
|
|
15
|
1
|
14217
|
my $self = shift ; |
|
189
|
15
|
|
|
|
|
117
|
return $self->{result} ; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub getErrors |
|
193
|
|
|
|
|
|
|
{ |
|
194
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
|
195
|
0
|
|
|
|
|
0
|
return $self->{errorText} ; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
0
|
0
|
0
|
sub Vpp_Out {croak "Original Vpp_Out called";} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub do_shell |
|
201
|
|
|
|
|
|
|
{ |
|
202
|
3
|
|
|
3
|
0
|
9
|
my $self=shift; |
|
203
|
3
|
|
|
|
|
12
|
my $shell_code = shift; |
|
204
|
3
|
|
|
|
|
47521
|
my $out= `$shell_code`; |
|
205
|
3
|
50
|
|
|
|
104
|
warn "Error in SHELL code : status is $? \n", |
|
206
|
|
|
|
|
|
|
"in file: $self->{name} line $.\n", |
|
207
|
|
|
|
|
|
|
"code was\n$shell_code" if $? > 0; |
|
208
|
3
|
|
|
|
|
143
|
split(/\n/,$out) ; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub processBlock |
|
212
|
|
|
|
|
|
|
{ |
|
213
|
|
|
|
|
|
|
# three parameters : |
|
214
|
|
|
|
|
|
|
# GlobExpand : false if nothing should be expanded |
|
215
|
|
|
|
|
|
|
# Expand : true if the calling ifdef is true |
|
216
|
92
|
|
|
92
|
0
|
200
|
my ($self,$globExpand,$expand,$EnterLoop,$useFiFo,$ScanOnly)=@_ ; |
|
217
|
92
|
100
|
|
|
|
188
|
$expand= 0 unless $globExpand; |
|
218
|
92
|
|
|
|
|
145
|
my $FiFo = $self->{Fifo}; |
|
219
|
|
|
|
|
|
|
|
|
220
|
92
|
|
|
|
|
141
|
my $out = [] ; |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# Done is used to evaluate the elsif |
|
223
|
92
|
|
|
|
|
140
|
my ($done) = $expand ; |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# Stage is used for syntax check |
|
226
|
92
|
100
|
100
|
|
|
388
|
my ($stage) = ($self->{IF_Level} == 0 || $EnterLoop) ? 0 : 1 ; |
|
227
|
|
|
|
|
|
|
|
|
228
|
92
|
|
|
|
|
90
|
my ($line,$keep,$SubsIt) ; |
|
229
|
92
|
|
|
|
|
449
|
local $/ = "\n"; # revert to standard line ending |
|
230
|
|
|
|
|
|
|
|
|
231
|
92
|
|
|
|
|
107
|
my $Within_Perl_Input = 0; |
|
232
|
92
|
|
|
|
|
86
|
my $Perl_Input_Termination; |
|
233
|
|
|
|
|
|
|
my $Perl_Code; |
|
234
|
|
|
|
|
|
|
|
|
235
|
92
|
|
|
|
|
789
|
my $Within_Shell_Input = 0; |
|
236
|
92
|
|
|
|
|
91
|
my $Shell_Input_Termination; |
|
237
|
|
|
|
|
|
|
my $Shell_Code; |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# attention: keep the following declaration in sync with |
|
240
|
|
|
|
|
|
|
# the assignments whence processing 'EVAL' line |
|
241
|
92
|
|
|
|
|
850
|
my $action = $self->{action} ; |
|
242
|
92
|
|
|
|
|
134
|
my $comment = $self->{comment}; |
|
243
|
92
|
|
|
|
|
129
|
my $prefix = $self->{prefix} ; |
|
244
|
92
|
|
|
|
|
115
|
my $suffix = $self->{suffix} ; |
|
245
|
92
|
|
|
|
|
114
|
my $substitute= $self->{substitute}; |
|
246
|
92
|
|
|
|
|
245
|
my $backslash = $self->{backslash}; |
|
247
|
92
|
|
|
|
|
122
|
my $VarPat = $self->{VarPat}; |
|
248
|
92
|
|
|
|
|
98
|
my $commentPat = $self->{commentPat}; |
|
249
|
92
|
|
|
|
|
115
|
my $actionPat = $self->{actionPat}; |
|
250
|
92
|
|
|
|
|
107
|
my $ifPat = $self->{ifPat}; |
|
251
|
92
|
|
|
|
|
112
|
my $elsifPat = $self->{elsifPat}; |
|
252
|
92
|
|
|
|
|
146
|
my $elsePat = $self->{elsePat}; |
|
253
|
92
|
|
|
|
|
108
|
my $endifPat = $self->{endifPat}; |
|
254
|
92
|
|
|
|
|
103
|
my $includePat = $self->{includePat}; |
|
255
|
92
|
|
|
|
|
104
|
my $evalPat = $self->{evalPat}; |
|
256
|
92
|
|
|
|
|
108
|
my $quotePat = $self->{quotePat}; |
|
257
|
92
|
|
|
|
|
112
|
my $endquotePat= $self->{endquotePat}; |
|
258
|
92
|
|
|
|
|
102
|
my $subsPat = $self->{subsPat}; |
|
259
|
92
|
|
|
|
|
114
|
my $subsLeadPat= $self->{subsLeadPat}; |
|
260
|
92
|
|
|
|
|
102
|
my $foreachPat = $self->{foreachPat}; |
|
261
|
92
|
|
|
|
|
113
|
my $endforPat = $self->{endforPat}; |
|
262
|
92
|
|
|
|
|
131
|
my $perlPat = $self->{perlPat}; |
|
263
|
92
|
|
|
|
|
107
|
my $shellPat = $self->{shellPat}; |
|
264
|
|
|
|
|
|
|
|
|
265
|
92
|
100
|
|
|
|
157
|
if ( $useFiFo ) |
|
266
|
|
|
|
|
|
|
{ |
|
267
|
49
|
|
|
|
|
104
|
$line= F_getline($FiFo); |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
else |
|
270
|
|
|
|
|
|
|
{ |
|
271
|
43
|
|
|
|
|
1605
|
$line = $self->{fileDesc}->getline; |
|
272
|
43
|
100
|
|
|
|
1590
|
F_print($FiFo,$line) if $ScanOnly; |
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
|
|
275
|
92
|
|
|
|
|
226
|
while (defined($line)) |
|
276
|
|
|
|
|
|
|
{ |
|
277
|
332
|
100
|
|
|
|
864
|
if ( $Within_Perl_Input ) { |
|
278
|
33
|
100
|
|
|
|
116
|
if ( $line =~ /$Perl_Input_Termination/ ) { |
|
279
|
2
|
|
|
|
|
5
|
$Within_Perl_Input= 0; |
|
280
|
2
|
50
|
|
|
|
11
|
if ( $expand ) { |
|
281
|
|
|
|
|
|
|
# $VAR may be used in eval'ed code |
|
282
|
2
|
|
|
|
|
8
|
my $VAR = $self->{var} ; |
|
283
|
2
|
|
|
0
|
|
41
|
local *Vpp_Out= sub {push @$out, @_; }; |
|
|
0
|
|
|
|
|
0
|
|
|
284
|
2
|
50
|
|
2
|
0
|
670
|
my $res = eval($Perl_Code); |
|
|
2
|
|
|
1
|
0
|
3
|
|
|
|
2
|
|
|
1
|
0
|
3
|
|
|
|
2
|
|
|
2
|
0
|
5
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
6
|
|
|
|
13
|
|
|
|
|
25
|
|
|
|
2
|
|
|
|
|
21
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
21
|
|
|
285
|
2
|
50
|
|
|
|
20
|
die "Error in eval(uating) PERL code : $@ \n", |
|
286
|
|
|
|
|
|
|
"in file: $self->{name} line $.\n", |
|
287
|
|
|
|
|
|
|
"code was\n$Perl_Code" if $@; |
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
} else { |
|
290
|
31
|
|
|
|
|
48
|
$Perl_Code.= $line; |
|
291
|
|
|
|
|
|
|
} |
|
292
|
33
|
|
|
|
|
48
|
next; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
299
|
100
|
|
|
|
527
|
if ( $Within_Shell_Input ) { |
|
296
|
3
|
100
|
|
|
|
11
|
if ( $line =~ /$Shell_Input_Termination/ ) { |
|
297
|
1
|
|
|
|
|
2
|
$Within_Shell_Input= 0; |
|
298
|
1
|
50
|
|
|
|
7
|
push (@$out, $self->do_shell($Shell_Code)) if ( $expand ); |
|
299
|
|
|
|
|
|
|
} else { |
|
300
|
2
|
|
|
|
|
3
|
$Shell_Code.= $line; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
3
|
|
|
|
|
14
|
next; |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
|
|
305
|
296
|
|
|
|
|
491
|
chomp($line); |
|
306
|
|
|
|
|
|
|
#skip commented lines |
|
307
|
296
|
100
|
66
|
|
|
2228
|
next if (defined $commentPat and $line =~ $commentPat); |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
# get following line if the line is ended by \ |
|
310
|
|
|
|
|
|
|
# (followed by tab or whitespaces) |
|
311
|
288
|
100
|
100
|
|
|
1274
|
if ($backslash == 1 and $line =~ s/\\\s*$//) |
|
312
|
|
|
|
|
|
|
{ |
|
313
|
5
|
|
|
|
|
18
|
$keep .= $line ; |
|
314
|
5
|
|
|
|
|
14
|
next ; |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
283
|
|
|
|
|
612
|
my $lineIn; |
|
318
|
283
|
100
|
|
|
|
690
|
if (defined $keep) |
|
319
|
|
|
|
|
|
|
{ |
|
320
|
5
|
|
|
|
|
12
|
$lineIn = $keep.$line ; |
|
321
|
5
|
|
|
|
|
9
|
undef $keep ; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
else |
|
324
|
|
|
|
|
|
|
{ |
|
325
|
278
|
|
|
|
|
390
|
$lineIn = $line ; |
|
326
|
|
|
|
|
|
|
} |
|
327
|
|
|
|
|
|
|
|
|
328
|
283
|
|
|
|
|
281
|
study $lineIn; |
|
329
|
283
|
100
|
66
|
|
|
6631
|
if ($lineIn =~ s/$ifPat//i) |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
{ |
|
331
|
|
|
|
|
|
|
# process the lines after the IF, |
|
332
|
|
|
|
|
|
|
# don't evaluate the boolean expression if ! $expand |
|
333
|
29
|
|
100
|
|
|
123
|
my ($expandLoc) = $expand && $self->myExpression($lineIn) ; |
|
334
|
29
|
|
|
|
|
68
|
my $Current_IF_Level = $self->{IF_Level}++; |
|
335
|
29
|
|
|
|
|
102
|
push @$out, |
|
336
|
29
|
|
|
|
|
40
|
@{$self->processBlock($expand,$expandLoc,0,$useFiFo,$ScanOnly)}; |
|
337
|
|
|
|
|
|
|
|
|
338
|
29
|
50
|
|
|
|
100
|
if ( $self->{IF_Level} != $Current_IF_Level ) |
|
339
|
|
|
|
|
|
|
{ |
|
340
|
0
|
|
|
|
|
0
|
$self->snitch("illegal nesting of FOREACH and IF"); return []; |
|
|
0
|
|
|
|
|
0
|
|
|
341
|
|
|
|
|
|
|
} |
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
elsif ($lineIn =~ s/$elsifPat//) |
|
344
|
|
|
|
|
|
|
{ |
|
345
|
|
|
|
|
|
|
# process the lines after the ELSIF, done is set if the block |
|
346
|
|
|
|
|
|
|
# is expanded |
|
347
|
2
|
50
|
66
|
|
|
12
|
unless ($stage == 1 or $stage ==2) |
|
348
|
|
|
|
|
|
|
{ |
|
349
|
0
|
|
|
|
|
0
|
$self->snitch("unexpected elsif"); |
|
350
|
|
|
|
|
|
|
} |
|
351
|
2
|
|
|
|
|
3
|
$stage = 2 ; |
|
352
|
2
|
50
|
|
|
|
4
|
if ( $done ) # if-condition was true |
|
353
|
0
|
|
|
|
|
0
|
{ $expand= 0; } # now we are in the else |
|
354
|
|
|
|
|
|
|
else |
|
355
|
|
|
|
|
|
|
{ # if-condition was false, so here we have a new chance |
|
356
|
2
|
|
66
|
|
|
9
|
$expand = $globExpand && $self->myExpression($lineIn) ; |
|
357
|
2
|
|
|
|
|
5
|
$done = $expand ; |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
elsif ($lineIn =~ $elsePat) |
|
361
|
|
|
|
|
|
|
{ |
|
362
|
6
|
50
|
33
|
|
|
30
|
if ($stage == 0 || $stage == 3 ) |
|
363
|
|
|
|
|
|
|
{ |
|
364
|
0
|
|
|
|
|
0
|
$self->snitch("unexpected else"); |
|
365
|
|
|
|
|
|
|
} |
|
366
|
6
|
|
|
|
|
8
|
$stage = 3 ; |
|
367
|
6
|
|
66
|
|
|
24
|
$expand = $globExpand && !$done ; |
|
368
|
|
|
|
|
|
|
} |
|
369
|
|
|
|
|
|
|
elsif ($lineIn =~ $endifPat) |
|
370
|
|
|
|
|
|
|
{ |
|
371
|
29
|
50
|
|
|
|
62
|
if ($stage == 0) {$self->snitch("unexpected endif");} |
|
|
0
|
|
|
|
|
0
|
|
|
372
|
29
|
|
|
|
|
46
|
$self->{IF_Level}--; |
|
373
|
29
|
|
|
|
|
189
|
return $out ; |
|
374
|
|
|
|
|
|
|
} |
|
375
|
|
|
|
|
|
|
elsif ($lineIn =~ s/$foreachPat//) |
|
376
|
|
|
|
|
|
|
{ |
|
377
|
27
|
|
|
|
|
63
|
my ($emptyLoop,$Current_FOR_Level,$Start_of_Loop) |
|
378
|
|
|
|
|
|
|
= (1,$self->{FOR_Level},1); |
|
379
|
|
|
|
|
|
|
|
|
380
|
27
|
100
|
|
|
|
58
|
if ( $expand ) |
|
381
|
|
|
|
|
|
|
{ |
|
382
|
15
|
|
|
|
|
25
|
my $LoopExpr = $lineIn; |
|
383
|
15
|
|
|
|
|
25
|
$LoopExpr =~ s/^\s*my\s//; # remove my if there |
|
384
|
15
|
|
|
|
|
15
|
my $LoopVar ; |
|
385
|
15
|
50
|
|
|
|
84
|
$LoopVar = $1 if $LoopExpr =~ s/\$(\w+)//; |
|
386
|
|
|
|
|
|
|
|
|
387
|
15
|
|
|
|
|
38
|
$self->ReplaceVars($LoopExpr); |
|
388
|
15
|
|
|
|
|
995
|
my @LoopList= eval $LoopExpr; |
|
389
|
15
|
50
|
|
|
|
51
|
if ( $@ ) |
|
390
|
|
|
|
|
|
|
{ |
|
391
|
0
|
|
|
|
|
0
|
die "Error in FOREACH-List-Expression: $@\n", |
|
392
|
|
|
|
|
|
|
"line : $lineIn\nfile: $self->{name} line $.\n"; |
|
393
|
|
|
|
|
|
|
} |
|
394
|
15
|
|
|
|
|
26
|
$emptyLoop= scalar(@LoopList) == 0; |
|
395
|
|
|
|
|
|
|
|
|
396
|
15
|
100
|
|
|
|
37
|
unless ($emptyLoop) |
|
397
|
|
|
|
|
|
|
{ |
|
398
|
14
|
100
|
|
|
|
35
|
if ( $self->{FOR_Level} == 0 ) |
|
399
|
|
|
|
|
|
|
{ |
|
400
|
3
|
|
|
|
|
12
|
F_reset($FiFo); |
|
401
|
3
|
|
|
|
|
6
|
$self->{FOR_Level}++; |
|
402
|
3
|
|
|
|
|
10
|
$self->processBlock(0,0,1,0,1); # Scan Only |
|
403
|
3
|
50
|
|
|
|
14
|
if ( $Current_FOR_Level != $self->{FOR_Level} ) |
|
404
|
|
|
|
|
|
|
{ |
|
405
|
0
|
|
|
|
|
0
|
$self->snitch("illegal nesting for IF and FOREACH"); |
|
406
|
0
|
|
|
|
|
0
|
return []; |
|
407
|
|
|
|
|
|
|
} |
|
408
|
3
|
|
|
|
|
8
|
$Start_of_Loop= 1; |
|
409
|
|
|
|
|
|
|
} |
|
410
|
11
|
|
|
|
|
27
|
else { $Start_of_Loop= F_tell($FiFo); } |
|
411
|
|
|
|
|
|
|
|
|
412
|
14
|
|
|
|
|
33
|
foreach my $LpVar (@LoopList) |
|
413
|
|
|
|
|
|
|
{ |
|
414
|
31
|
|
|
|
|
70
|
$self->{var}{$LoopVar}= $LpVar; |
|
415
|
31
|
|
|
|
|
42
|
$self->{FOR_Level}++; |
|
416
|
31
|
|
|
|
|
215
|
F_seek($FiFo,$Start_of_Loop); |
|
417
|
|
|
|
|
|
|
|
|
418
|
31
|
|
|
|
|
35
|
push @$out, @{$self->processBlock(1,1,1,1,0)} ; |
|
|
31
|
|
|
|
|
76
|
|
|
419
|
|
|
|
|
|
|
|
|
420
|
31
|
50
|
|
|
|
148
|
if ( $Current_FOR_Level != $self->{FOR_Level} ) |
|
421
|
|
|
|
|
|
|
{ |
|
422
|
0
|
|
|
|
|
0
|
$self->snitch("illegal nesting for IF and FOREACH"); |
|
423
|
0
|
|
|
|
|
0
|
return []; |
|
424
|
|
|
|
|
|
|
} |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
} |
|
427
|
|
|
|
|
|
|
} |
|
428
|
|
|
|
|
|
|
|
|
429
|
27
|
100
|
|
|
|
76
|
if ($emptyLoop) # loop has never been executed |
|
430
|
|
|
|
|
|
|
{ |
|
431
|
13
|
100
|
|
|
|
33
|
if ( $self->{FOR_Level} == 0 ) |
|
432
|
|
|
|
|
|
|
{ |
|
433
|
3
|
|
|
|
|
7
|
$self->{FOR_Level}++; |
|
434
|
3
|
|
|
|
|
10
|
$self->processBlock(0,0,1,0,0); # just skip |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
else |
|
437
|
|
|
|
|
|
|
{ |
|
438
|
10
|
|
|
|
|
15
|
$self->{FOR_Level}++; |
|
439
|
10
|
|
|
|
|
43
|
$self->processBlock(0,0,1,$useFiFo,$ScanOnly); # process but don't expand |
|
440
|
|
|
|
|
|
|
} |
|
441
|
13
|
50
|
|
|
|
41
|
if ( $Current_FOR_Level != $self->{FOR_Level} ) |
|
442
|
|
|
|
|
|
|
{ |
|
443
|
0
|
|
|
|
|
0
|
$self->snitch("illegal nesting for IF and FOREACH"); |
|
444
|
0
|
|
|
|
|
0
|
return []; |
|
445
|
|
|
|
|
|
|
} |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
} |
|
448
|
|
|
|
|
|
|
elsif ($lineIn =~ $endforPat) |
|
449
|
|
|
|
|
|
|
{ |
|
450
|
47
|
|
|
|
|
86
|
$self->{FOR_Level}--; return $out; |
|
|
47
|
|
|
|
|
596
|
|
|
451
|
|
|
|
|
|
|
} |
|
452
|
|
|
|
|
|
|
elsif ($lineIn =~ $includePat) |
|
453
|
|
|
|
|
|
|
{ |
|
454
|
3
|
50
|
|
|
|
10
|
if ( $expand ) |
|
455
|
|
|
|
|
|
|
{ |
|
456
|
|
|
|
|
|
|
# look like we've got a new file to slurp |
|
457
|
3
|
|
|
|
|
39
|
$lineIn =~ s/$includePat//; |
|
458
|
3
|
|
|
|
|
8
|
my $newFile; |
|
459
|
3
|
100
|
|
|
|
25
|
my $Incl = $lineIn =~ /^[\w_\-.]+$/ ? |
|
460
|
|
|
|
|
|
|
$lineIn : $self->myEval($lineIn); |
|
461
|
|
|
|
|
|
|
|
|
462
|
3
|
100
|
|
|
|
10
|
if ( ref($Incl) eq 'HASH' ) |
|
463
|
|
|
|
|
|
|
{ |
|
464
|
1
|
50
|
|
|
|
6
|
$Incl->{action}= $action unless defined $Incl->{action}; |
|
465
|
1
|
50
|
|
|
|
5
|
$Incl->{comment}= $comment unless defined $Incl->{comment}; |
|
466
|
1
|
50
|
|
|
|
5
|
$Incl->{prefix}= $prefix unless defined $Incl->{prefix}; |
|
467
|
1
|
50
|
|
|
|
6
|
$Incl->{suffix}= $suffix unless defined $Incl->{suffix}; |
|
468
|
1
|
50
|
|
|
|
6
|
$Incl->{substitute}= $substitute unless defined $Incl->{substitute}; |
|
469
|
1
|
50
|
|
|
|
6
|
$Incl->{backslash}= $backslash unless defined $Incl->{backslash}; |
|
470
|
1
|
50
|
|
|
|
5
|
unless ( defined $Incl->{file} ) |
|
471
|
|
|
|
|
|
|
{ |
|
472
|
0
|
|
|
|
|
0
|
$self->snitch("illegal file at include $lineIn"); |
|
473
|
0
|
|
|
|
|
0
|
return []; |
|
474
|
|
|
|
|
|
|
} |
|
475
|
|
|
|
|
|
|
|
|
476
|
1
|
|
|
|
|
13
|
$newFile = Text::Vpp-> new ($Incl->{file}, $self->{var}, |
|
477
|
|
|
|
|
|
|
$Incl->{action}, $Incl->{comment}, |
|
478
|
|
|
|
|
|
|
$Incl->{prefix}, $Incl->{suffix}, |
|
479
|
|
|
|
|
|
|
$Incl->{substitute}, $Incl->{backslash}); |
|
480
|
|
|
|
|
|
|
} |
|
481
|
|
|
|
|
|
|
else |
|
482
|
|
|
|
|
|
|
{ |
|
483
|
2
|
|
|
|
|
251
|
$newFile = Text::Vpp-> new ($Incl, $self->{var}, |
|
484
|
|
|
|
|
|
|
$action,$comment,$prefix,$suffix, |
|
485
|
|
|
|
|
|
|
$substitute,$backslash) ; |
|
486
|
|
|
|
|
|
|
} |
|
487
|
|
|
|
|
|
|
|
|
488
|
3
|
50
|
|
|
|
17
|
if ($newFile->substitute()) |
|
489
|
|
|
|
|
|
|
{ |
|
490
|
3
|
|
|
|
|
13
|
my $res = $newFile->getText() ; |
|
491
|
3
|
|
|
|
|
140
|
push @$out, @$res ; |
|
492
|
|
|
|
|
|
|
} |
|
493
|
|
|
|
|
|
|
else |
|
494
|
|
|
|
|
|
|
{ |
|
495
|
|
|
|
|
|
|
# an error occured |
|
496
|
0
|
|
|
|
|
0
|
push @{$self->{errorText}}, @{$newFile->getErrors()} ; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
497
|
0
|
|
|
|
|
0
|
$self->{error} = 1; |
|
498
|
0
|
|
|
|
|
0
|
return $out ; |
|
499
|
|
|
|
|
|
|
} |
|
500
|
3
|
|
|
|
|
39
|
undef $newFile ; |
|
501
|
|
|
|
|
|
|
} |
|
502
|
|
|
|
|
|
|
} |
|
503
|
|
|
|
|
|
|
elsif ($lineIn =~ s/$evalPat//) |
|
504
|
|
|
|
|
|
|
{ |
|
505
|
9
|
50
|
|
|
|
25
|
if ( $expand ) {$self->myEval($lineIn, $out);} |
|
|
9
|
|
|
|
|
45
|
|
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
# reassign in case there was a change to some |
|
508
|
|
|
|
|
|
|
# of the following |
|
509
|
|
|
|
|
|
|
# attention: keep the following assignments in sync with |
|
510
|
|
|
|
|
|
|
# with the declarations at the beginning of this sub |
|
511
|
9
|
|
|
|
|
61
|
$action = $self->{action} ; |
|
512
|
9
|
|
|
|
|
15
|
$comment = $self->{comment}; |
|
513
|
9
|
|
|
|
|
17
|
$prefix = $self->{prefix} ; |
|
514
|
9
|
|
|
|
|
15
|
$suffix = $self->{suffix} ; |
|
515
|
9
|
|
|
|
|
223
|
$substitute = $self->{substitute}; |
|
516
|
9
|
|
|
|
|
15
|
$backslash = $self->{backslash}; |
|
517
|
9
|
|
|
|
|
15
|
$VarPat = $self->{VarPat}; |
|
518
|
9
|
|
|
|
|
13
|
$commentPat = $self->{commentPat}; |
|
519
|
9
|
|
|
|
|
19
|
$actionPat = $self->{actionPat}; |
|
520
|
9
|
|
|
|
|
16
|
$ifPat = $self->{ifPat}; |
|
521
|
9
|
|
|
|
|
13
|
$elsifPat = $self->{elsifPat}; |
|
522
|
9
|
|
|
|
|
14
|
$elsePat = $self->{elsePat}; |
|
523
|
9
|
|
|
|
|
15
|
$endifPat = $self->{endifPat}; |
|
524
|
9
|
|
|
|
|
14
|
$includePat = $self->{includePat}; |
|
525
|
9
|
|
|
|
|
11
|
$evalPat = $self->{evalPat}; |
|
526
|
9
|
|
|
|
|
12
|
$quotePat = $self->{quotePat}; |
|
527
|
9
|
|
|
|
|
16
|
$endquotePat= $self->{endquotePat}; |
|
528
|
9
|
|
|
|
|
14
|
$subsPat = $self->{subsPat}; |
|
529
|
9
|
|
|
|
|
12
|
$subsLeadPat= $self->{subsLeadPat}; |
|
530
|
9
|
|
|
|
|
11
|
$foreachPat = $self->{foreachPat}; |
|
531
|
9
|
|
|
|
|
14
|
$endforPat = $self->{endforPat}; |
|
532
|
9
|
|
|
|
|
15
|
$perlPat = $self->{perlPat}; |
|
533
|
9
|
|
|
|
|
18
|
$shellPat = $self->{shellPat}; |
|
534
|
|
|
|
|
|
|
} |
|
535
|
|
|
|
|
|
|
elsif ($lineIn =~ s/$perlPat//) |
|
536
|
2
|
|
|
|
|
5
|
{ $Within_Perl_Input= 1; |
|
537
|
2
|
|
|
|
|
8
|
$Perl_Code= ""; |
|
538
|
2
|
|
|
|
|
21
|
$lineIn =~ s/\s*$//; |
|
539
|
2
|
|
|
|
|
31
|
$Perl_Input_Termination= qr/$lineIn/; |
|
540
|
|
|
|
|
|
|
} |
|
541
|
|
|
|
|
|
|
elsif ($lineIn =~ s/$shellPat//) |
|
542
|
|
|
|
|
|
|
{ |
|
543
|
3
|
100
|
|
|
|
17
|
if ($lineIn =~ s/<<\s*//) |
|
544
|
|
|
|
|
|
|
{ |
|
545
|
1
|
|
|
|
|
2
|
$Within_Shell_Input= 1; |
|
546
|
1
|
|
|
|
|
2
|
$Shell_Code= ""; |
|
547
|
1
|
|
|
|
|
5
|
$lineIn =~ s/\s*$//; |
|
548
|
1
|
|
|
|
|
12
|
$Shell_Input_Termination= qr/$lineIn/; |
|
549
|
|
|
|
|
|
|
} |
|
550
|
|
|
|
|
|
|
else |
|
551
|
|
|
|
|
|
|
{ |
|
552
|
2
|
|
|
|
|
30
|
push @$out, $self->do_shell($lineIn); |
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
} |
|
555
|
|
|
|
|
|
|
elsif ( $lineIn =~ /$quotePat/ ) |
|
556
|
|
|
|
|
|
|
{ |
|
557
|
1
|
|
|
|
|
2
|
my $Str = $lineIn; $Str =~ s/$quotePat//; |
|
|
1
|
|
|
|
|
3
|
|
|
558
|
1
|
|
|
|
|
3
|
my ($ListSeparator,$ListPrefix); |
|
559
|
|
|
|
|
|
|
# format @QUOTE (ListPrefix,ListSeparator) |
|
560
|
1
|
50
|
|
|
|
6
|
if ( $Str =~ /^\(/ ) |
|
561
|
|
|
|
|
|
|
{ |
|
562
|
1
|
50
|
|
|
|
7
|
if ( $Str =~ /^\(\s*(\S)([^\1]*?)\1\s*(?:,\s*(\S)([^\2]*?)\3\s*\))?/ ) |
|
563
|
1
|
|
|
|
|
2
|
{ $ListPrefix= $2; $ListSeparator= $4; } |
|
|
1
|
|
|
|
|
3
|
|
|
564
|
0
|
|
|
|
|
0
|
else { $self->snitch("illegal QUOTE action : $lineIn"); } |
|
565
|
|
|
|
|
|
|
} |
|
566
|
1
|
|
|
|
|
3
|
$Str= ''; |
|
567
|
|
|
|
|
|
|
|
|
568
|
1
|
|
|
|
|
1
|
while(1) |
|
569
|
|
|
|
|
|
|
{ |
|
570
|
6
|
50
|
|
|
|
9
|
if ( $useFiFo ) { $line= F_getline($FiFo); } |
|
|
0
|
|
|
|
|
0
|
|
|
571
|
|
|
|
|
|
|
else |
|
572
|
|
|
|
|
|
|
{ |
|
573
|
6
|
|
|
|
|
128
|
$line = $self->{fileDesc}->getline; |
|
574
|
6
|
50
|
|
|
|
160
|
F_print($FiFo,$line) if $ScanOnly; |
|
575
|
|
|
|
|
|
|
} |
|
576
|
6
|
100
|
|
|
|
25
|
last if $line =~ $endquotePat; |
|
577
|
|
|
|
|
|
|
|
|
578
|
5
|
50
|
|
|
|
17
|
unless ( defined $line ) |
|
579
|
|
|
|
|
|
|
{ |
|
580
|
0
|
|
|
|
|
0
|
$self->snitch("EOF while scanning QUOTE"); |
|
581
|
0
|
|
|
|
|
0
|
return []; |
|
582
|
|
|
|
|
|
|
} |
|
583
|
|
|
|
|
|
|
|
|
584
|
5
|
50
|
|
|
|
13
|
$Str.= $line if ( $expand ); |
|
585
|
|
|
|
|
|
|
} |
|
586
|
|
|
|
|
|
|
|
|
587
|
1
|
50
|
|
|
|
4
|
if ( $expand ) |
|
588
|
|
|
|
|
|
|
{ |
|
589
|
|
|
|
|
|
|
# protect '$' and '@' |
|
590
|
1
|
50
|
33
|
|
|
11
|
if ( "$prefix$suffix" !~ /\$/ |
|
|
|
|
33
|
|
|
|
|
|
591
|
|
|
|
|
|
|
&& ( !defined($ListPrefix) || $ListPrefix !~ /\$/ ) ) |
|
592
|
1
|
|
|
|
|
6
|
{ $Str =~ s/(?
|
|
593
|
|
|
|
|
|
|
|
|
594
|
1
|
50
|
33
|
|
|
13
|
if ( "$prefix$suffix" !~ /\@/ |
|
|
|
|
33
|
|
|
|
|
|
595
|
|
|
|
|
|
|
&& ( !defined($ListPrefix) || $ListPrefix !~ /\@/ ) ) |
|
596
|
1
|
|
|
|
|
2
|
{ $Str =~ s/(?
|
|
597
|
|
|
|
|
|
|
|
|
598
|
1
|
50
|
|
|
|
4
|
if ( defined $ListPrefix ) { $Str =~ s/\Q$ListPrefix\E/\@/g; } |
|
|
1
|
|
|
|
|
12
|
|
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# substitute variables |
|
601
|
1
|
50
|
|
|
|
5
|
if ( defined $suffix ) |
|
602
|
|
|
|
|
|
|
{ |
|
603
|
1
|
|
|
|
|
20
|
$Str =~ s[$VarPat][\$self->{var}{$1}]g; |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
else |
|
606
|
|
|
|
|
|
|
{ |
|
607
|
0
|
|
|
|
|
0
|
$Str =~ s[$VarPat] |
|
608
|
0
|
0
|
|
|
|
0
|
[ { "\$self->{var}{$2}" . ( !$1 ? $3 : '' ) ;} ]ge ; |
|
|
0
|
|
|
|
|
0
|
|
|
609
|
|
|
|
|
|
|
} |
|
610
|
|
|
|
|
|
|
|
|
611
|
1
|
50
|
|
|
|
4
|
if ( defined $ListSeparator ) |
|
612
|
1
|
|
|
|
|
2
|
{ local $"= $ListSeparator; $Str = eval("qq($Str)"); } |
|
|
1
|
|
|
|
|
122
|
|
|
613
|
0
|
|
|
|
|
0
|
else { $Str = eval("qq($Str)"); } |
|
614
|
|
|
|
|
|
|
|
|
615
|
1
|
50
|
|
|
|
8
|
if ($@ ne "") |
|
616
|
|
|
|
|
|
|
{ |
|
617
|
0
|
|
|
|
|
0
|
die "Error in QUOTE/eval : $@ \n", |
|
618
|
|
|
|
|
|
|
"expression:\n$Str\n\nfile: $self->{name} line $.\n"; |
|
619
|
|
|
|
|
|
|
} |
|
620
|
|
|
|
|
|
|
|
|
621
|
1
|
|
|
|
|
4
|
chomp $Str; |
|
622
|
1
|
|
|
|
|
7
|
push @$out, split /\n/,$Str; |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
} |
|
625
|
|
|
|
|
|
|
elsif ( $SubsIt=($lineIn =~ $subsLeadPat) || $lineIn !~ $actionPat ) |
|
626
|
|
|
|
|
|
|
{ |
|
627
|
|
|
|
|
|
|
# process the line |
|
628
|
125
|
100
|
|
|
|
476
|
if ($expand) |
|
629
|
|
|
|
|
|
|
{ |
|
630
|
93
|
50
|
|
|
|
157
|
if ( $SubsIt ) # eval substitution parts |
|
631
|
|
|
|
|
|
|
{ |
|
632
|
93
|
|
|
|
|
387
|
$lineIn =~ s/$subsPat/$self->myExpression($1)/ge; |
|
|
15
|
|
|
|
|
49
|
|
|
633
|
|
|
|
|
|
|
} |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
# substitute variables |
|
636
|
93
|
100
|
|
|
|
163
|
if ( defined $suffix ) |
|
637
|
|
|
|
|
|
|
{ |
|
638
|
1
|
|
|
|
|
4
|
$lineIn =~ s[$VarPat] |
|
639
|
0
|
0
|
|
|
|
0
|
[ if (defined($self->{var}{$1})) |
|
640
|
0
|
|
|
|
|
0
|
{ $self->{var}{$1};} |
|
|
0
|
|
|
|
|
0
|
|
|
641
|
|
|
|
|
|
|
else {"$prefix$1$suffix" ;} |
|
642
|
|
|
|
|
|
|
]ge ; |
|
643
|
|
|
|
|
|
|
} |
|
644
|
|
|
|
|
|
|
else |
|
645
|
|
|
|
|
|
|
{ |
|
646
|
92
|
|
|
|
|
5912
|
$lineIn =~ s[$VarPat] |
|
647
|
68
|
50
|
|
|
|
2211
|
[ if (defined($self->{var}{$2})) |
|
648
|
68
|
100
|
|
|
|
400
|
{ $self->{var}{$2} . ( !$1 ? $3 : '' ) ;} |
|
|
0
|
|
|
|
|
0
|
|
|
649
|
|
|
|
|
|
|
else {"$prefix$1$2$3" ;} |
|
650
|
|
|
|
|
|
|
]ge ; |
|
651
|
|
|
|
|
|
|
} |
|
652
|
|
|
|
|
|
|
|
|
653
|
93
|
|
|
|
|
423
|
push @$out, $lineIn ; |
|
654
|
|
|
|
|
|
|
} |
|
655
|
|
|
|
|
|
|
} |
|
656
|
|
|
|
|
|
|
else |
|
657
|
|
|
|
|
|
|
{ |
|
658
|
0
|
|
|
|
|
0
|
$self->snitch("Unknown command :$lineIn") ; |
|
659
|
|
|
|
|
|
|
} |
|
660
|
|
|
|
|
|
|
} |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
continue |
|
663
|
|
|
|
|
|
|
{ |
|
664
|
256
|
100
|
|
|
|
424
|
if ( $useFiFo ) |
|
665
|
71
|
|
|
|
|
125
|
{ $line= F_getline($FiFo); } |
|
666
|
|
|
|
|
|
|
else |
|
667
|
|
|
|
|
|
|
{ |
|
668
|
185
|
|
|
|
|
5610
|
$line = $self->{fileDesc}->getline; |
|
669
|
185
|
100
|
|
|
|
6454
|
F_print($FiFo,$line) if $ScanOnly; |
|
670
|
|
|
|
|
|
|
} |
|
671
|
|
|
|
|
|
|
} |
|
672
|
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
|
|
674
|
16
|
50
|
|
|
|
88
|
if ($self->{IF_Level} > 0 ) |
|
|
|
50
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
{ |
|
676
|
0
|
|
|
|
|
0
|
$self->snitch("Finished inside a conditionnal block"); |
|
677
|
|
|
|
|
|
|
} |
|
678
|
|
|
|
|
|
|
elsif ( $self->{FOR_Level} > 0 ) |
|
679
|
|
|
|
|
|
|
{ |
|
680
|
0
|
|
|
|
|
0
|
$self->snitch("Finished inside a FOREACH block"); |
|
681
|
|
|
|
|
|
|
} |
|
682
|
|
|
|
|
|
|
|
|
683
|
16
|
|
|
|
|
146
|
return $out ; |
|
684
|
|
|
|
|
|
|
} |
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
1; |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
__END__ |