diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-03-08 08:11:38 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-08-29 09:56:01 -0600 |
commit | c4c8e61502fd5289a080f20332c6e3f9f23ce6e2 (patch) | |
tree | 3b3f73c432784abfb2f725d4c8a9afc584bb9e8a /regen | |
parent | 4ed7d5f0cb38287a10b5b2650dc8f62e5f67eafc (diff) | |
download | perl-c4c8e61502fd5289a080f20332c6e3f9f23ce6e2.tar.gz |
regen/regcharclass.pl: Make more EBCDIC-friendly
This commit changes the code generated by the macros so that they work
right out-of-the-box on non-ASCII platforms for non-UTF-8 inputs. THEY
ARE WRONG for UTF-8, but this is good enough to get perl bootstrapped
onto the target platform, and regcharclass.pl can be run there,
generating macros with correct UTF-8.
Diffstat (limited to 'regen')
-rwxr-xr-x | regen/regcharclass.pl | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/regen/regcharclass.pl b/regen/regcharclass.pl index 976582a7e1..bb290d5496 100755 --- a/regen/regcharclass.pl +++ b/regen/regcharclass.pl @@ -495,10 +495,26 @@ sub _optree { # can return the "else" value. return $else if !@conds; + # Assuming Perl is being released from an ASCII platform, the below makes + # it work for non-UTF-8 out-of-the box when porting to non-ASCII, by + # adding a translation back to ASCII. This is the wrong thing to do for + # UTF-EBCDIC, as that is different from UTF-8. But the intent here is + # that this regen should be run on the target system, which will omit the + # translation, and generate the correct UTF-EBCDIC. On ASCII systems, the + # translation macros expand to just their argument, so there is no harm + # done nor performance penalty by including them. + my $test; + if ($test_type =~ /^cp/) { + $test = "cp"; + $test = "NATIVE_TO_UNI($test)" if ASCII_PLATFORM; + } + else { + $test = "((U8*)s)[$depth]"; + $test = "NATIVE_TO_LATIN1($test)" if ASCII_PLATFORM; + } - my $test= $test_type =~ /^cp/ ? "cp" : "((U8*)s)[$depth]"; - # first we loop over the possible keys/conditions and find out what they look like - # we group conditions with the same optree together. + # first we loop over the possible keys/conditions and find out what they + # look like we group conditions with the same optree together. my %dmp_res; my @res_order; local $Data::Dumper::Sortkeys=1; |