utf8_heavy: Allow to be called from regcomp.c
authorKarl Williamson <public@khwilliamson.com>
Sat, 19 Nov 2011 21:49:20 +0000 (14:49 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 13 Jan 2012 16:58:33 +0000 (09:58 -0700)
Future commits will cause regcomp.c to try to compile user-defined
properties.  The caller stack is different for this, and there may be a
package name as well that differs from the existing scheme.  This commit
allows for this.

lib/utf8_heavy.pl

index e63999f..6f639f0 100644 (file)
@@ -120,7 +120,7 @@ sub _loose_name ($) {
 
             # regcomp.c surrounds the property name with '__" and '_i' if this
             # is to be caseless matching.
-            my $caseless = $type =~ s/^__(.*)_i$/$1/;
+            my $caseless = $type =~ s/^(.*)__(.*)_i$/$1$2/;
 
             print STDERR __LINE__, ": type=$type, caseless=$caseless\n" if DEBUG;
 
@@ -131,7 +131,10 @@ sub _loose_name ($) {
                 ## package if no package given
                 ##
 
-                my $caller1 = $type =~ s/(.+)::// ? $1 : caller(1);
+
+                my $caller0 = caller(0);
+                my $caller1 = $type =~ s/(.+)::// ? $1 : $caller0 eq 'main' ?
+                'main' : caller(1);
 
                 if (defined $caller1 && $type =~ /^I[ns]\w+$/) {
                     my $prop = "${caller1}::$type";