Commit | Line | Data |
f600d105 |
1 | |
2 | package Locale::Maketext::GutsLoader; |
3 | use strict; |
4 | sub zorp { return scalar @_ } |
5 | |
6 | BEGIN { |
7 | $Locale::Maketext::GutsLoader::GUTSPATH = __FILE__; |
8 | *Locale::Maketext::DEBUG = sub () {0} |
9 | unless defined &Locale::Maketext::DEBUG; |
10 | } |
11 | |
12 | # |
13 | # This whole drama is so that we can load the utf8'd code |
14 | # in Locale::Maketext::Guts, but if that fails, snip the |
15 | # utf8 and then try THAT. |
16 | # |
17 | |
18 | $Locale::Maketext::GUTSPATH = ''; |
19 | Locale::Maketext::DEBUG and print "Requiring Locale::Maketext::Guts...\n"; |
20 | eval 'require Locale::Maketext::Guts'; |
21 | |
22 | if($@) { |
23 | my $path = $Locale::Maketext::GUTSPATH; |
24 | |
25 | die "Can't load Locale::Maketext::Guts\nAborting" unless $path; |
26 | |
27 | die "No readable file $Locale::Maketext::GutsLoader::GUTSPATH\nAborting" |
28 | unless -e $path and -f _ and -r _; |
29 | |
30 | open(IN, $path) or die "Can't read-open $path\nAborting"; |
31 | |
32 | my $source; |
33 | { local $/; $source = <IN>; } |
34 | close(IN); |
35 | unless( $source =~ s/\b(use utf8)/# $1/ ) { |
36 | Locale::Maketext::DEBUG and |
37 | print "I didn't see 'use utf8' in $path\n"; |
38 | } |
39 | eval $source; |
40 | die "Can't compile $path\n...The error I got was:\n$@\nAborting" if $@; |
41 | Locale::Maketext::DEBUG and print "Non-utf8'd Locale::Maketext::Guts fine\n"; |
42 | } else { |
43 | Locale::Maketext::DEBUG and print "Loaded Locale::Maketext::Guts fine\n"; |
44 | } |
45 | |
46 | 1; |
47 | |