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