Sjis.pm

filter: Statementstmt 48.4% 77 / 159 Branchbran 34.0% 30 / 88 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 2 totaltotal 44.0% 118 / 268 CC 44 SCAR 44.6
CC
44
Cov
43%
escape_script
135.2
import
105.0
_escapeshellcmd_MSWin32
6.0
CRAP 86.2
« Esjis.pm ↑ Summary
1 package Sjis;
2 395 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 395 ▶BEGIN { $INC{'warnings.pm'} = '' if $] < 5.006 } use warnings;
Subroutine BEGIN: called CC=2 SCAR=7.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.006" 0 395 395
4 ######################################################################
5 #
6 # Sjis - Source code filter to escape ShiftJIS script
7 #
8 # http://search.cpan.org/dist/Char-Sjis/
9 #
10 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi <ina@cpan.org>
11 ######################################################################
12  
13 395 ▶use 5.00503; # Galapagos Consensus 1998 for primetools
Subroutine BEGIN: called CC=1 SCAR=0.0
14 # use 5.008001; # Lancaster Consensus 2013 for toolchains
15  
16 # 12.3. Delaying use Until Runtime
17 # in Chapter 12. Packages, Libraries, and Modules
18 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
19 # (and so on)
20  
21 # Version numbers should be boring
22 # http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/
23 # For the impatient, the disinterested or those who just want to follow
24 # a recipe, my advice for all modules is this:
25 # our $VERSION = "0.001"; # or "0.001_001" for a dev release
26 # $VERSION = CORE::eval $VERSION; # No!! because '1.10' makes '1.1'
27  
28 395 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 395 $VERSION = '1.22';
30 395 $VERSION = $VERSION;
31  
32 395 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
33 395 ▶ if ($^X =~ / jperl /oxmsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^X =~ / jperl /imosx) 0 395 395
34 0 die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n";
35 }
36 395 if (CORE::ord('A') == 193) {
37 die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n";
38 }
39 395 if (CORE::ord('A') != 0x41) {
40 die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n";
41 }
42 }
43  
44 395 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
45 395 (my $dirname = __FILE__) =~ s{^(.+)/[^/]*$}{$1};
46 395 unshift @INC, $dirname;
47 395 CORE::require Esjis;
48 }
49  
50 # instead of Symbol.pm
51 BEGIN {
52 1184 ▶ sub gensym () {
Subroutine gensym: called CC=2 SCAR=9.2
Pod undocumented
53 1184 ▶ if ($] < 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.006) { } 0 1184 1184
54 0 return \do { local *_ };
55 }
56 else {
57 1184 return undef;
58 }
59 }
60 }
61  
62 # P.714 29.2.39. flock
63 # in Chapter 29: Functions
64 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
65  
66 # P.863 flock
67 # in Chapter 27: Functions
68 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
69  
70 # P.228 Inlining Constant Functions
71 # in Chapter 6: Subroutines
72 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
73  
74 # P.331 Inlining Constant Functions
75 # in Chapter 7: Subroutines
76 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
77  
78 sub LOCK_SH() {1}
79 sub LOCK_EX() {2}
80 sub LOCK_UN() {8}
81 sub LOCK_NB() {4}
82  
83 0 ▶sub unimport {}
Subroutine unimport: not called CC=1 SCAR=0.0
84 sub Sjis::escape_script;
85  
86 # 6.18. Matching Multiple-Byte Characters
87 # in Chapter 6. Pattern Matching
88 # of ISBN 978-1-56592-243-3 Perl Perl Cookbook.
89 # (and so on)
90  
91 # regexp of character
92 395 my $qq_char = qr/(?> \\c[\x40-\x5F] | \\? (?:[\x81-\x9F\xE0-\xFC][\x00-\xFF] | [\x00-\xFF]) )/oxms;
93 395 my $q_char = qr/(?> [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [\x00-\xFF] )/oxms;
94  
95 # when this script is main program
96 395 ▶if ($0 eq __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 eq __FILE__) 0 395 395
97  
98 # show usage
99 0 ▶ unless (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ARGV) 0 0 0
100 0 die <<END;
101 $0: usage
102  
103 perl $0 ShiftJIS_script.pl > Escaped_script.pl.e
104 END
105 }
106  
107 0 print Sjis::escape_script($ARGV[0]);
108 0 exit 0;
109 }
110  
111 395 my($package,$filename,$line,$subroutine,$hasargs,$wantarray,$evaltext,$is_require,$hints,$bitmask) = caller 0;
112  
113 # called any package not main
114 395 ▶if ($package ne 'main') {
Branch: 1 branch
BranchTrueFalseTotal
if ($package ne "main") 0 395 395
115 0 die <<END;
116 0 @{[__FILE__]}: escape by manually command '$^X @{[__FILE__]} "$filename" > "@{[__PACKAGE__]}::$filename"'
117 0 and rewrite "use $package;" to "use @{[__PACKAGE__]}::$package;" of script "$0".
118 END
119 }
120  
121 # P.302 Module Privacy and the Exporter
122 # in Chapter 11: Modules
123 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
124 #
125 # A module can do anything it jolly well pleases when it's used, since use just
126 # calls the ordinary import method for the module, and you can define that
127 # method to do anything you like.
128  
129 # P.406 Module Privacy and the Exporter
130 # in Chapter 11: Modules
131 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
132 #
133 # A module can do anything it jolly well pleases when it's used, since use just
134 # calls the ordinary import method for the module, and you can define that
135 # method to do anything you like.
136  
137 395 ▶sub import {
Subroutine import: called CC=22 SCAR=46.5
138  
139 395 ▶ if (Esjis::e("$filename.e")) {
Branch: 1 branch
BranchTrueFalseTotal
if (&Esjis::e("$filename.e")) 0 395 395
140 0 ▶ if (exists $ENV{'CHAR_DEBUG'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $ENV{'CHAR_DEBUG'}) { } 0 0 0
elsif (&Esjis::z("$filename.e")) { } 0 0 0
141 0 Esjis::unlink "$filename.e";
142 }
143 elsif (Esjis::z("$filename.e")) {
144 0 Esjis::unlink "$filename.e";
145 }
146 else {
147  
148 #----------------------------------------------------
149 # older >
150 # newer >>>>>
151 #----------------------------------------------------
152 # Filter >
153 # Source >>>>>
154 # Escape >>> needs re-escape (Source was changed)
155 #
156 # Filter >>>
157 # Source >>>>>
158 # Escape > needs re-escape (Source was changed)
159 #
160 # Filter >>>>>
161 # Source >>>
162 # Escape > needs re-escape (Source was changed)
163 #
164 # Filter >>>>>
165 # Source >
166 # Escape >>> needs re-escape (Filter was changed)
167 #
168 # Filter >
169 # Source >>>
170 # Escape >>>>> executable without re-escape
171 #
172 # Filter >>>
173 # Source >
174 # Escape >>>>> executable without re-escape
175 #----------------------------------------------------
176  
177 0 my $mtime_filter = (Esjis::stat(__FILE__ ))[9];
178 0 my $mtime_source = (Esjis::stat($filename ))[9];
179 0 my $mtime_escape = (Esjis::stat("$filename.e"))[9];
180 0 ▶ if (($mtime_escape < $mtime_source) or ($mtime_escape < $mtime_filter)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mtime_escape < $mtime_source or $mtime_escape < $mtime_filter) 0 0 0
Condition0%0/3
$mtime_escape < $mtime_source or $mtime_escape < $mtime_filter
l!l&&r!l&&!r
000
MC/DC0%0/2
$mtime_escape < $mtime_source or $mtime_escape < $mtime_filter
$mtime_escape < $mtime_source $mtime_escape < $mtime_filter
Truth table0%0/3
A or B
A= $mtime_escape < $mtime_sourceB= $mtime_escape < $mtime_filter
ABresult
1X1
011
000
181 0 Esjis::unlink "$filename.e";
182 }
183 }
184 }
185  
186 395 ▶ if (not Esjis::e("$filename.e")) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&Esjis::e("$filename.e")) 395 0 395
187 395 my $fh = gensym();
188 395 ▶ Esjis::_open_a($fh, "$filename.e") or die __FILE__, ": Can't write open file: $filename.e\n";
Branch: 1 branch
BranchTrueFalseTotal
Esjis::_open_a($fh, "$filename.e") or die __FILE__, ": Can't write open file: $filename.e\n" 395 0 395
189  
190 # 7.19. Flushing Output
191 # in Chapter 7. File Access
192 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
193  
194 395 select((select($fh), $|=1)[0]);
195  
196 395 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $^O eq 'MacOS' }) { } 0 395 395
elsif (exists $ENV{'CHAR_NONBLOCK'}) { } 0 395 395
197 }
198 elsif ($^O eq 'MacOS') {
199 0 CORE::eval q{
200 CORE::require Mac::Files;
201 Mac::Files::FSpSetFLock("$filename.e");
202 };
203 }
204 elsif (exists $ENV{'CHAR_NONBLOCK'}) {
205  
206 # P.419 File Locking
207 # in Chapter 16: Interprocess Communication
208 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
209  
210 # P.524 File Locking
211 # in Chapter 15: Interprocess Communication
212 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
213  
214 # P.571 Handling Race Conditions
215 # in Chapter 23: Security
216 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
217  
218 # P.663 Handling Race Conditions
219 # in Chapter 20: Security
220 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
221  
222 # (and so on)
223  
224 0 CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) };
225 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
226 0 die __FILE__, ": Can't immediately write-lock the file: $filename.e\n";
227 }
228 }
229 else {
230 395 CORE::eval q{ flock($fh, LOCK_EX) };
231 }
232  
233 395 CORE::eval q{ truncate($fh, 0) };
234 395 ▶ seek($fh, 0, 0) or die __FILE__, ": Can't seek file: $filename.e\n";
Branch: 1 branch
BranchTrueFalseTotal
seek $fh, 0, 0 or die __FILE__, ": Can't seek file: $filename.e\n" 395 0 395
235  
236 395 my $e_script = Sjis::escape_script($filename);
237 394 print {$fh} $e_script;
238  
239 394 my $mode = (Esjis::stat($filename))[2] & 0777;
240 394 chmod $mode, "$filename.e";
241  
242 394 ▶ if ($^O eq 'MacOS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MacOS") 0 394 394
243 0 CORE::eval q{
244 CORE::require Mac::Files;
245 Mac::Files::FSpRstFLock("$filename.e");
246 };
247 }
248  
249 394 ▶ close($fh) or die "Can't close file: $filename.e: $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Can't close file: $filename.e: $!" 394 0 394
250 }
251  
252 394 my $fh = gensym();
253 394 ▶ Esjis::_open_r($fh, "$filename.e") or die __FILE__, ": Can't read open file: $filename.e\n";
Branch: 1 branch
BranchTrueFalseTotal
Esjis::_open_r($fh, "$filename.e") or die __FILE__, ": Can't read open file: $filename.e\n" 394 0 394
254  
255 394 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $^O eq 'MacOS' }) { } 0 394 394
elsif (exists $ENV{'CHAR_NONBLOCK'}) { } 0 394 394
256 }
257 elsif ($^O eq 'MacOS') {
258 0 CORE::eval q{
259 CORE::require Mac::Files;
260 Mac::Files::FSpSetFLock("$filename.e");
261 };
262 }
263 elsif (exists $ENV{'CHAR_NONBLOCK'}) {
264 0 CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) };
265 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
266 0 die __FILE__, ": Can't immediately read-lock the file: $filename.e\n";
267 }
268 }
269 else {
270 394 CORE::eval q{ flock($fh, LOCK_SH) };
271 }
272  
273 394 my @switch = ();
274 394 ▶ if ($^W) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^W) 0 394 394
275 0 push @switch, '-w';
276 }
277 394 ▶ if (defined $^I) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $^I) 0 394 394
278 0 push @switch, '-i' . $^I;
279 0 undef $^I;
280 }
281  
282 # P.707 29.2.33. exec
283 # in Chapter 29: Functions
284 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
285 #
286 # If there is more than one argument in LIST, or if LIST is an array with more
287 # than one value, the system shell will never be used. This also bypasses any
288 # shell processing of the command. The presence or absence of metacharacters in
289 # the arguments doesn't affect this list-triggered behavior, which makes it the
290 # preferred from in security-conscious programs that do not with to expose
291 # themselves to potential shell escapes.
292 # Environment variable PERL5SHELL(Microsoft ports only) will never be used, too.
293  
294 # P.855 exec
295 # in Chapter 27: Functions
296 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
297 #
298 # If there is more than one argument in LIST, or if LIST is an array with more
299 # than one value, the system shell will never be used. This also bypasses any
300 # shell processing of the command. The presence or absence of metacharacters in
301 # the arguments doesn't affect this list-triggered behavior, which makes it the
302 # preferred from in security-conscious programs that do not wish to expose
303 # themselves to injection attacks via shell escapes.
304 # Environment variable PERL5SHELL(Microsoft ports only) will never be used, too.
305  
306 # P.489 #! and Quoting on Non-Unix Systems
307 # in Chapter 19: The Command-Line Interface
308 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
309  
310 # P.578 #! and Quoting on Non-Unix Systems
311 # in Chapter 17: The Command-Line Interface
312 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
313  
314 394 my $system = 0;
315  
316 # DOS-like system
317 394 ▶ if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/mosx) { } 0 394 394
elsif ($^O eq 'MacOS') { } 0 394 394
318 $system = Esjis::_systemx(
319 _escapeshellcmd_MSWin32($^X),
320  
321 # -I switch can not treat space included path
322 # (map { '-I' . _escapeshellcmd_MSWin32($_) } @INC),
323 0 (map { '-I' . $_ } @INC),
324  
325 @switch,
326 '--',
327 0 map { _escapeshellcmd_MSWin32($_) } "$filename.e", @ARGV
328 );
329 }
330  
331 # MacOS system
332 elsif ($^O eq 'MacOS') {
333 $system = Esjis::_systemx(
334 _escapeshellcmd_MacOS($^X),
335 0 (map { '-I' . _escapeshellcmd_MacOS($_) } @INC),
336 @switch,
337 '--',
338 0 map { _escapeshellcmd_MacOS($_) } "$filename.e", @ARGV
339 );
340 0 CORE::eval q{
341 CORE::require Mac::Files;
342 Mac::Files::FSpRstFLock("$filename.e");
343 };
344 }
345  
346 # UNIX-like system
347 else {
348 $system = Esjis::_systemx(
349 _escapeshellcmd($^X),
350 3546 (map { '-I' . _escapeshellcmd($_) } @INC),
351 @switch,
352 '--',
353 394 map { _escapeshellcmd($_) } "$filename.e", @ARGV
354 );
355 }
356  
357 # exit with actual exit value
358 394 exit($system >> 8);
359 }
360  
361 # escape shell command line on DOS-like system
362 0 ▶sub _escapeshellcmd_MSWin32 {
Subroutine _escapeshellcmd_MSWin32: not called CC=2 SCAR=17.9
363 0 my($word) = @_;
364 0 ▶ if ($word =~ / [ ] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word =~ / [ ] /mosx) { } 0 0 0
365 0 return qq{"$word"};
366 }
367 else {
368 0 return $word;
369 }
370 }
371  
372 # escape shell command line on Mac OS
373 0 ▶sub _escapeshellcmd_MacOS {
Subroutine _escapeshellcmd_MacOS: not called CC=1 SCAR=6.9
374 0 my($word) = @_;
375 0 return $word;
376 }
377  
378 # escape shell command line on UNIX-like system
379 4334 ▶sub _escapeshellcmd {
Subroutine _escapeshellcmd: called CC=1 SCAR=0.0
380 4334 my($word) = @_;
381 4334 return $word;
382 }
383  
384 # P.619 Source Filters
385 # in Chapter 24: Common Practices
386 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
387  
388 # P.718 Source Filters
389 # in Chapter 21: Common Practices
390 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
391  
392 # escape ShiftJIS script
393 395 ▶sub Sjis::escape_script {
Subroutine escape_script: called CC=19 SCAR=49.1
Pod undocumented
394 395 my($script) = @_;
395 395 my $e_script = '';
396  
397 # read ShiftJIS script
398 395 my $fh = gensym();
399 395 ▶ Esjis::_open_r($fh, $script) or die __FILE__, ": Can't open file: $script\n";
Branch: 1 branch
BranchTrueFalseTotal
Esjis::_open_r($fh, $script) or die __FILE__, ": Can't open file: $script\n" 395 0 395
400 395 local $/ = undef; # slurp mode
401 395 $_ = <$fh>;
402 395 ▶ close($fh) or die "Can't close file: $script: $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Can't close file: ${script}: $!" 395 0 395
403  
404 395 ▶ if (/^ use Esjis(?:(?>\s+)(?>[0-9\.]*))?(?>\s*); $/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^ use Esjis(?:(?>\s+)(?>[0-9\.]*))?(?>\s*); $/mosx) { } 0 395 395
405 0 return $_;
406 }
407 else {
408  
409 # #! shebang line
410 395 ▶ if (s/\A(#!.+?\n)//oms) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/\A(#!.+?\n)//mos) 0 395 395
411 0 my $head = $1;
412 0 $head =~ s/\bjperl\b/perl/gi;
413 0 $e_script .= $head;
414 }
415  
416 # DOS-like system header
417 395 ▶ if (s/\A(\@rem(?>\s*)=(?>\s*)'.*?'(?>\s*);\s*\n)//oms) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/\A(\@rem(?>\s*)=(?>\s*)'.*?'(?>\s*);\s*\n)//mos) 0 395 395
418 0 my $head = $1;
419 0 $head =~ s/\bjperl\b/perl/gi;
420 0 $e_script .= $head;
421 }
422  
423 # P.618 Generating Perl in Other Languages
424 # in Chapter 24: Common Practices
425 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
426  
427 # P.717 Generating Perl in Other Languages
428 # in Chapter 21: Common Practices
429 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
430  
431 395 ▶ if (s/(.*^#(?>\s*)line(?>\s+)(?>[0-9]+)(?:(?>\s+)"(?:$q_char)+?")?\s*\n)//oms) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/(.*^#(?>\s*)line(?>\s+)(?>[0-9]+)(?:(?>\s+)"(?:$q_char)+?")?\s*\n)//mos) 0 395 395
432 0 my $head = $1;
433 0 $head =~ s/\bjperl\b/perl/gi;
434 0 $e_script .= $head;
435 }
436  
437 # P.210 5.10.3.3. Match-time code evaluation
438 # in Chapter 5: Pattern Matching
439 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
440  
441 # P.255 Match-time code evaluation
442 # in Chapter 5: Pattern Matching
443 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
444  
445 # '...' quote to avoid "Octal number in vector unsupported" on perl 5.6
446  
447 395 $e_script .= sprintf("use Esjis '%s.0'; # 'quote' for perl5.6\n", $Sjis::VERSION); # require run-time routines version
448  
449 # use Sjis version qw(ord reverse getc);
450 395 ▶ if (s/^ (?>\s*) use (?>\s+) (?: Char | Sjis ) (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; \s* \n? $//oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^ (?>\s*) use (?>\s+) (?: Char | Sjis ) (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; \s* \n? $//mosx) 395 0 395
451  
452 # require version
453 395 my $list = $1;
454 395 ▶ if ($list =~ s/\A ((?>[0-9]+)\.(?>[0-9]+)) \.0 (?>\s*) //oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($list =~ s/\A ((?>[0-9]+)\.(?>[0-9]+)) \.0 (?>\s*) //mosx) { } 0 395 395
elsif ($list =~ s/\A ((?>[0-9]+)(?>\.[0-9]*)) (?>\s*) //mosx) { } 0 395 395
455 0 my $version = $1;
456 0 ▶ if ($version ne $Sjis::VERSION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version ne $Sjis::VERSION) 0 0 0
457 0 my @file = grep -e, map {qq{$_/Sjis.pm}} @INC;
458 0 my %file = map { $_ => 1 } @file;
459 0 ▶ if (scalar(keys %file) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %file >= 2) 0 0 0
460 0 my $file = join "\n", sort keys %file;
461 0 warn <<END;
462 ****************************************************
463 C A U T I O N
464  
465 CONFLICT Sjis.pm FILE
466  
467 $file
468 ****************************************************
469  
470 END
471 }
472 0 die "Script $0 expects Sjis.pm $version, but @{[__FILE__]} is version $Sjis::VERSION\n";
473 }
474 0 $e_script .= qq{die "Script \$0 expects Esjis.pm $version, but \\\$Esjis::VERSION is \$Esjis::VERSION" if \$Esjis::VERSION ne '$version';\n};
475 }
476 elsif ($list =~ s/\A ((?>[0-9]+)(?>\.[0-9]*)) (?>\s*) //oxms) {
477 0 my $version = $1;
478 0 ▶ if ($version > $Sjis::VERSION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version > $Sjis::VERSION) 0 0 0
479 0 die "Script $0 required Sjis.pm $version, but @{[__FILE__]} is only version $Sjis::VERSION\n";
480 }
481 }
482  
483 # demand ord, reverse, and getc
484 395 ▶ if ($list !~ /\A (?>\s*) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($list =~ /\A (?>\s*) \z/mosx) 0 395 395
485 0 local $@;
486 0 my @list = CORE::eval $list;
487 0 for (@list) {
488 0 ▶ $Esjis::function_ord = 'Sjis::ord' if /\A ord \z/oxms;
Branch: 1 branch
BranchTrueFalseTotal
if /\A ord \z/mosx 0 0 0
489 0 ▶ $Esjis::function_ord_ = 'Sjis::ord_' if /\A ord \z/oxms;
Branch: 1 branch
BranchTrueFalseTotal
if /\A ord \z/mosx 0 0 0
490 0 ▶ $Esjis::function_reverse = 'Sjis::reverse' if /\A reverse \z/oxms;
Branch: 1 branch
BranchTrueFalseTotal
if /\A reverse \z/mosx 0 0 0
491 0 ▶ $Esjis::function_getc = 'Sjis::getc' if /\A getc \z/oxms;
Branch: 1 branch
BranchTrueFalseTotal
if /\A getc \z/mosx 0 0 0
492  
493 # avoid: used only once: possible typo at ...
494 0 $Esjis::function_ord = $Esjis::function_ord;
495 0 $Esjis::function_ord_ = $Esjis::function_ord_;
496 0 $Esjis::function_reverse = $Esjis::function_reverse;
497 0 $Esjis::function_getc = $Esjis::function_getc;
498 }
499 }
500 }
501 }
502  
503 395 $e_script .= Sjis::escape();
504  
505 394 return $e_script;
506 }
507  
508 395 1;
509  
510 __END__
« Esjis.pm ↑ Summary