Karl Williamson [Wed, 21 Aug 2013 02:55:44 +0000 (20:55 -0600)]
regcomp.c: Create better estimate of trie match lengths
This commit improves the estimate of the length of a string that a trie
matches. Before this, the estimate gave more false positives, and
required some workarounds which are no longer necessary, and future
commits will remove.
The ultimate answer is to know precisely what will be matched. As noted
in the comments, this information is already largely available in a
global variable. But more work there needs to be done to complete it,
and make it conveniently accessible.
Karl Williamson [Tue, 20 Aug 2013 04:55:14 +0000 (22:55 -0600)]
regcomp.c: Split count variable into two: min, max
This is in preparation in later commits for the min and max to diverge.
This also renames the two variables to emphasize that bytes are what are
being counted, not characters.
Karl Williamson [Tue, 20 Aug 2013 04:38:43 +0000 (22:38 -0600)]
fold_grind.t: Modify trie test
The trie tests just add an alternation of a fixed string. This commit
makes that string the same number of bytes as the first alternative, in
an effort to not bias the test. Otherwise, something that might
otherwise appear to be too short might be long enough to match the fixed
string, defeating properly testing the length.
Karl Williamson [Mon, 19 Aug 2013 19:34:23 +0000 (13:34 -0600)]
regcomp.c: White-space, comment only
Fit into 79 columns, add comment
Karl Williamson [Mon, 19 Aug 2013 18:15:56 +0000 (12:15 -0600)]
regcomp.c: Remove unreachable code
This code no longer gets executed, as the single multi-char fold in the
Latin1 range is pre-folded before this code sees it. The surrounding
code didn't properly handle multi-char folds either.
Not having to deal with this allows us to not have to call the general
purpose function, but we do have to deal with one edge case
Karl Williamson [Mon, 19 Aug 2013 18:09:54 +0000 (12:09 -0600)]
regexec.c: Add comments, assertions
Karl Williamson [Mon, 19 Aug 2013 18:01:37 +0000 (12:01 -0600)]
regcomp.c: White-space only
Reflow comment to fit in 79 columns
Karl Williamson [Mon, 19 Aug 2013 17:57:52 +0000 (11:57 -0600)]
utf8.c: Add comment
Karl Williamson [Sun, 18 Aug 2013 15:00:11 +0000 (09:00 -0600)]
utf8.c: Add omitted fold cases
The LATIN SMALL LETTER SHARP S can't fold to 'ss' under /iaa because the
definition of /aa prohibits it, but it can fold to two consecutive
instances of LATIN SMALL LETTER LONG S. A capital sharp s can do the
same, and that was fixed in
1ca267a5, but this one was overlooked then.
It turns out that another possibility was also overlooked in
1ca267a5.
Both U+FB05 (LATIN SMALL LIGATURE LONG S T) and U+FB06 (LATIN SMALL
LIGATURE ST) fold to the string 'st', except under /iaa these folds are
prohibited. But U+FB05 and U+FB06 are equivalent to each other under
/iaa. This wasn't working until now. This commit changes things so
both fold to FB06.
This bug would only surface during /iaa matching, and I don't believe
there are any current code paths which lead to it, hence no tests are
added by this commit. However, a future commit will lead to this bug,
and existing tests find it then.
Karl Williamson [Sun, 18 Aug 2013 14:51:42 +0000 (08:51 -0600)]
utf8.h: White space only
Vertically align the definitions of a few #defines
Karl Williamson [Sun, 18 Aug 2013 14:50:34 +0000 (08:50 -0600)]
utf8.h, unicode_constants.h: Add some #defines.
These will be used in a future commit
Nicholas Clark [Wed, 28 Aug 2013 14:14:21 +0000 (16:14 +0200)]
In Perl_magic_setdbline, replace the use of atoi() with sv_2iv().
The value on which atoi() is called is actually always the buffer of an SV.
Hence we can use sv_2iv() instead.
Karl Williamson [Thu, 29 Aug 2013 15:57:59 +0000 (09:57 -0600)]
Merge branch 'ebcdic' into blead
Work on getting EBCDIC to work again in blead has slowed to a standstill
due to lack of summertime tuits. I've gotten concerned about bit rot,
and with the Pumpking's permission am merging in this commit the portion
most subject to bit rot. This includes almost all the changes in the
core C language files and a few modules. Omitted from this merge are
most test changes, a very few C language changes that for various
reasons aren't ready for merge, and most module changes, as well as any
totally new files. These will be merged sometime in the future.
With this merge and regenerating some tables, Perl mostly works with
EBCDIC on z/OS, even if many tests fail because they are testing for
ASCII-specific behavior.
This branch also isolates into just a few files the need to
differentiate between running on an ASCII versus an EBCDIC platform.
This will allow easier ripping out of EBCDIC code should we decide to do
so in the future, as well as making it easier to decide to leave it in,
as it now affects only a small amount of code.
One of the major reasons that ASCII and EBCDIC had to be distinguished
in code is that there were two sets of functions, one that worked on
native code points; the other on Unicode code points; the latter was
used when working with Unicode properties. To use the latter, one had
to convert to/from Unicode. This branch collapses those functions by
changing mktables to generate the Unicode property tables in terms of
the native character set. (This was a fairly simple change). Now, only
one set of functions is needed (the other is deprecated in this merge or
will be deprecated in later commits), and the conversions are almost
entirely avoided. Fortunately, most CPAN code did not bother with
distinguishing the two function sets, and so the deprecation affects
only a few modules.
Most of the "#ifdef EBCDIC" lines are removed, retained in only a few
files, most notably toke.c. These are required there for dealing with the
discontinuities in EBCDIC of the A-Z range, specifically in parsing
tr/// commands. (There are also some in utf8.[ch] for the differences
between UTF-8 and UTF-EBCDIC.) And a few smattered in other files,
mostly for performance.
The other major reason for ASCII/EBCDIC differences was due to UTF-8 vs
UTF-EBCDIC. New macros are created and used to hide more of those
differences from code than before.
Quite a few bugs that were only on EBCDIC platforms are now fixed.
These escaped earlier detection because we had no such platform to test
on.
Karl Williamson [Wed, 26 Jun 2013 21:30:59 +0000 (15:30 -0600)]
utf8.c: Move some code around for speed
This is a micro optimization. We now check for a common case and return
if found, before checking for a relatively uncommon case.
Karl Williamson [Wed, 26 Jun 2013 18:05:24 +0000 (12:05 -0600)]
utf8.h: Fix UTF8_IS_SUPER defn for EBCDIC
The parentheses were misplaced, so it wasn't looking at the second byte
of the input string properly.
Karl Williamson [Sat, 4 May 2013 19:29:15 +0000 (13:29 -0600)]
pp.c, regexec.c: Declare buffers large enough
These three buffers are not declared with the proper size. There is
a #define available to use, so use it. These matter only on EBCDIC
platforms, where the one in pp.c prior to this commit could cause a
buffer overrun there.
The others shouldn't because what is being used is known (smaller) size.
Karl Williamson [Sun, 28 Apr 2013 04:14:02 +0000 (22:14 -0600)]
utf8.c: Remove wrapper functions.
Now that the Unicode data is stored in native character set order, it is
rare to need to work with the Unicode order. Traditionally, the real
work was done in functions that worked with the Unicode order, and
wrapper functions (or macros) were used to translate to/from native.
There are two groups of functions: one that translates from code point
to UTF-8, and the other group goes the opposite direction.
This commit changes the base function that translates from UTF-8 to code
point to output native instead of Unicode. Those extremely rare
instances where Unicode output is needed instead will have to hand-wrap
calls to this function with a translation macro, as now described in the
API pod. Prior to this, it was the other way, the native was wrapped,
and the rare, strict Unicode wasn't. This eliminates a layer of
function call overhead for a common case.
The base function that translates from code point to UTF-8 retains its
Unicode input, as that is more natural to process. However, it is
de-emphasized in the pod, with the functionality description moved to
the pod for a native input wrapper function. And, those wrappers are
now macros in all cases; previously there was function call overhead
sometimes. (Equivalent exported functions are retained, however, for XS
code that uses the Perl_foo() form.)
I had hoped to rebase this commit, squashing it with an earlier commit
in this series, eliminating the use of a temporary function name change,
but the work involved turns out to be large, with no real payoff.
Karl Williamson [Tue, 30 Apr 2013 15:13:35 +0000 (09:13 -0600)]
perlapi vis utf8.c: Nits
Karl Williamson [Sat, 20 Apr 2013 23:04:08 +0000 (17:04 -0600)]
gv.c: Add comment
Karl Williamson [Tue, 30 Apr 2013 14:04:45 +0000 (08:04 -0600)]
utf8.c: Move 2 functions to earlier in file
This moves these two functions to be adjacent to the function they each
call, thus keeping like things together.
Karl Williamson [Fri, 19 Apr 2013 19:18:20 +0000 (13:18 -0600)]
regcomp.c: Add missing (parens) to expression
A pair of parentheses were missing leading to this 'if' not acting as
intended.
Karl Williamson [Sat, 13 Apr 2013 19:16:00 +0000 (13:16 -0600)]
toke.c: Fix EBCDIC bugs with single char variable names
Latin1 variable single character variable names should all be legal,
but the test was not for non-ASCII, it was for variant characters. On
EBCDIC platforms, this isn't the same as non-ASCII.
The legal control character variable names are not the same as the C0
and DEL controls, but are \001 .. \037, minus those that traditionally
match \s on ASCII platforms, plus \c?.
Karl Williamson [Sat, 13 Apr 2013 18:55:09 +0000 (12:55 -0600)]
toke.c: An EBCDIC fix
toCTRL(0..31) yields a printing character. This is different from
toCTRL(control) on EBCDIC machines.
Karl Williamson [Sat, 13 Apr 2013 15:18:41 +0000 (09:18 -0600)]
perlio.c: Generalize for EBCDIC
This code had the hex constants for CARRIAGE RETURN and LINE FEED
hard-coded in. It appears to me from the comments that '\r' and '\n'
are not suitable to use instead. This commit changes the constants to
use the native values instead.
Karl Williamson [Sat, 13 Apr 2013 15:51:34 +0000 (09:51 -0600)]
unicode_constants.h: Add #defines for CR, LF
Karl Williamson [Sat, 6 Apr 2013 18:56:52 +0000 (12:56 -0600)]
regcomp.c: In EBCDIC [i-j] exclude also ASCII
i and j are not adjacent in EBCDIC. This excluded any alphabetic
characters between them, but allowed other ascii ones.
Karl Williamson [Sat, 6 Apr 2013 18:54:42 +0000 (12:54 -0600)]
utf8.c: Don't use slower general-purpose function
There is a macro that accomplishes the same task for a two byte UTF-8
encoded character, and avoids the overhead of the general purpose
function call.
Karl Williamson [Sat, 6 Apr 2013 18:53:07 +0000 (12:53 -0600)]
utf8.c: Don't do ++ in macro parameter
The formal parameter gets evaluated multiple times on an EBCDIC
platform, thus incrementing more than the intended once.
Karl Williamson [Sat, 6 Apr 2013 18:50:48 +0000 (12:50 -0600)]
utf8.c: Use macro instead of duplicating code
There is a macro that accomplishes this task, and is easier to read.
Karl Williamson [Thu, 4 Apr 2013 03:59:16 +0000 (21:59 -0600)]
utf8.h: Clarify comments
Karl Williamson [Fri, 29 Mar 2013 20:56:16 +0000 (14:56 -0600)]
utf8.c: Avoid unnecessary UTF-8 conversions
This changes the code so that converting to UTF-8 is avoided unless
necessary. For such inputs, the conversion back from UTF-8 is also
avoided. The cost of doing this is that the first swatches are combined
into one that contains the values for all characters 0-255, instead of
having multiple swatches. That means when first calculating the swatch
it calculates all 256, instead of 128 (160 on EBCDIC).
This also fixes an EBCDIC bug in which characters in this range were
being translated twice.
Karl Williamson [Fri, 29 Mar 2013 19:34:59 +0000 (13:34 -0600)]
utf8.c: No need to check for UTF-8 malformations
This function assumes that the input is well-formed UTF-8, even though
until this commit, the prefatory comments didn't say so. The API does
not pass the buffer length, so there is no way it could check for
reading off the end of the buffer. One code path already calls
valid_utf8_to_uvchr(); this changes the remaining code path to correspond.
Karl Williamson [Sun, 24 Mar 2013 19:16:08 +0000 (13:16 -0600)]
utf8.c: Fix so UTF-16 to UTF-8 conversion works under EBCDIC
Karl Williamson [Sun, 24 Mar 2013 19:14:34 +0000 (13:14 -0600)]
utf8.h, utfebcdic.h: Add #define
Karl Williamson [Mon, 18 Mar 2013 17:45:06 +0000 (11:45 -0600)]
pp.c: White-space only
Make a ternary operation more clear
Karl Williamson [Mon, 18 Mar 2013 17:43:42 +0000 (11:43 -0600)]
Fix valid_utf8_to_uvchr() for EBCDIC
Karl Williamson [Mon, 18 Mar 2013 03:42:20 +0000 (21:42 -0600)]
t/test.pl: Add comment about EBCDIC
Karl Williamson [Sun, 17 Mar 2013 04:41:15 +0000 (22:41 -0600)]
Fix EBCDIC bugs in UTF8_ACUMULATE and utf8.c
Karl Williamson [Sat, 16 Mar 2013 22:52:45 +0000 (16:52 -0600)]
regcomp.c: Fix bug in EBCDIC
The POSIXA and NPOSIXA regnodes need to set the bits on only the ASCII
code points, but under EBCDIC those code points are not 0-127.
Karl Williamson [Wed, 13 Mar 2013 22:20:23 +0000 (16:20 -0600)]
toke.c: Simplify some code
We don't have to test separately for lower vs uppercase here, as
upper/lower case A-Z and a-z are not intermixed in the gaps in A-Z and
a-z under EBCDIC.
Karl Williamson [Wed, 13 Mar 2013 22:14:31 +0000 (16:14 -0600)]
sv.c: Make less ASCII-centric
Karl Williamson [Wed, 13 Mar 2013 22:05:46 +0000 (16:05 -0600)]
dump.c: Make less ASCII-centric:
This has the added advantage of being clearer as to what is going on.
Karl Williamson [Wed, 13 Mar 2013 22:02:52 +0000 (16:02 -0600)]
hv.c: Stop being ASCII-centric
This uses macros which work cross-platform. This has the added advantge
what is going on is much clearer.
Karl Williamson [Thu, 7 Mar 2013 19:08:41 +0000 (12:08 -0700)]
utfebcdic.h: Change 'unsigned char' to U8
This is for consistency with the rest of Perl
Karl Williamson [Fri, 8 Mar 2013 15:11:38 +0000 (08:11 -0700)]
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.
Karl Williamson [Thu, 7 Mar 2013 04:30:01 +0000 (21:30 -0700)]
utfebcdic.h: Add (UV) cast
The operand of this macro is implicitly a UV. Make sure that it is.
Karl Williamson [Thu, 7 Mar 2013 00:04:58 +0000 (17:04 -0700)]
handy.h: Allow bootstrapping to non-ASCII platform
This adds a bunch of macros and moves things around to support
conditional compilation when Configure is called with
-DBOOTSTRAP_CHARSET. Doing so causes the usual macros that are
table-driven to not be used, since the table may not be valid when
bringing Perl up for the first time on a non-ASCII platform.
This allows it to compile using the platform's native C library ctype
functions, which should work enough to compile miniperl, and allow the
table to be changed to be valid. Then Configure can be re-run to not
bootstrap, and normal compilation can proceed
Karl Williamson [Mon, 4 Mar 2013 20:00:47 +0000 (13:00 -0700)]
toke.c: Remove EBCDIC dependency
Karl Williamson [Mon, 4 Mar 2013 16:14:25 +0000 (09:14 -0700)]
toke.c: Remove character set dependency
Instead of hard-coding the bit patterns that comprise the Byte Order
Mark in the UTF-8 or UTF-EBCDIC encodings, use the generated ones for
the current platform.
This removes some EBCDIC-only code.
Karl Williamson [Mon, 4 Mar 2013 16:10:27 +0000 (09:10 -0700)]
unicode_constants.h: Add #defines for Byte Order Mark
These will be used in future commits
Karl Williamson [Sat, 2 Mar 2013 19:33:42 +0000 (12:33 -0700)]
utfebcdic.h: Add comment
Karl Williamson [Sat, 2 Mar 2013 19:12:11 +0000 (12:12 -0700)]
utf8.h: Clean up and use START_MARK definition
The previous definition broke good encapsulation rules. UTF_START_MARK
should return something that fits in a byte; it shouldn't be the caller
that does this. So the mask is moved into the definition. This means
it can apply only to the portion that creates something larger than a
byte. Further, the EBCDIC version can be simplified, since 7 is the
largest possible number of bytes in an EBCDIC UTF8 character.
Karl Williamson [Sat, 2 Mar 2013 19:05:26 +0000 (12:05 -0700)]
utf8.h: Move #includes
These two files were only being #included for non-ebcdic compiles; they
should be included always.
John Goodyear [Sat, 2 Mar 2013 18:49:14 +0000 (11:49 -0700)]
utfebcdic.h: Remove extra parameter expansions
These two macros were improperly expanding the parameters as well as
defining the operation, leading to compile errors.
Karl Williamson [Fri, 1 Mar 2013 15:28:52 +0000 (08:28 -0700)]
utf8.h: Simplify UTF8_EIGHT_BIT_foo on EBCDIC
These macros were previously defined in terms of UTF8_TWO_BYTE_HI and
UTF8_TWO_BYTE_LO. But the EIGHT_BIT versions can use the less general
and simpler NATIVE_TO_LATIN1 instead of NATIVE_TO_UNI because the input
domain is restricted in the EIGHT_BIT. Note that on ASCII platforms,
these both expand to the same thing, so the difference matters only on
EBCDIC.
Karl Williamson [Wed, 27 Feb 2013 15:38:19 +0000 (08:38 -0700)]
handy.h: Remove extraneous parens
Karl Williamson [Tue, 26 Feb 2013 20:45:19 +0000 (13:45 -0700)]
utf8.c: Use more clearly named macro
In the case of invariants these two macros should do the same thing,
but it seems to me that the latter name more clearly indicates what is
going on.
Karl Williamson [Tue, 26 Feb 2013 20:35:12 +0000 (13:35 -0700)]
Add macro OFFUNISKIP
This means use official Unicode code point numbering, not native. Doing
this converts the existing UNISKIP calls in the code to refer to native
code points, which is what they meant anyway. The terminology is
somewhat ambiguous, but I don't think it will cause real confusion.
NATIVE_SKIP is also introduced for situations where it is important to
be precise.
Karl Williamson [Tue, 26 Feb 2013 20:22:19 +0000 (13:22 -0700)]
toke.c: white space only
Karl Williamson [Sun, 17 Feb 2013 21:00:13 +0000 (14:00 -0700)]
toke.c: Don't remap \N{} for EBCDIC
Everything but \N{U+XXXX} is now in native,
Karl Williamson [Tue, 26 Feb 2013 19:08:50 +0000 (12:08 -0700)]
utf8.c: Stop using two functions
This is in preparation for deprecating these functions, to force any
code that has been using these functions to change.
Since the Unicode tables are now stored in native order, these
functions should only rarely be needed.
However, the functionality of these is needed, and in actuality, on
ASCII platforms, the native functions are #defined to these. So what
this commit does is rename the functions to something else, and create
wrappers with the old names, so that anyone using them will get the
deprecation when it actually goes into effect: we are waiting for CPAN
files distributed with the core to change before doing the deprecation.
According to cpan.grep.me, this should affect fewer than 10 additional
CPAN distributions.
Karl Williamson [Tue, 26 Feb 2013 18:26:09 +0000 (11:26 -0700)]
Convert uvuni_to_utf8() to function
Code should almost never be dealing with non-native code points
This is in preparation for later deprecation when our CPAN modules have
been converted away from using it.
Karl Williamson [Tue, 26 Feb 2013 18:02:33 +0000 (11:02 -0700)]
Deprecate utf8_to_uni_buf()
Now that the tables are stored in native order, there is almost no need
for code to be dealing in Unicode order.
According to grep.cpan.me, there are no uses of this function in CPAN.
Karl Williamson [Tue, 26 Feb 2013 03:26:44 +0000 (20:26 -0700)]
Deprecate valid_utf8_to_uvuni()
Now that all the tables are stored in native format, there is very
little reason to use this function; and those who do need this kind of
functionality should be using the bottom level routine, so as to make it
clear they are doing nonstandard stuff.
According to grep.cpan.me, there are no uses of this function in CPAN.
Karl Williamson [Tue, 26 Feb 2013 03:14:26 +0000 (20:14 -0700)]
utf8.c: Swap which fcn wraps the other
This is in preparation for the current wrapee becoming deprecated
Karl Williamson [Tue, 26 Feb 2013 02:29:34 +0000 (19:29 -0700)]
utf8.c: Skip a no-op
Since the value is invariant under both UTF-8 and not, we already have
it in 'uv'; no need to do anything else to get it
Karl Williamson [Tue, 26 Feb 2013 02:26:50 +0000 (19:26 -0700)]
utf8.c: Move comment to where makes more sense
Karl Williamson [Tue, 26 Feb 2013 00:30:10 +0000 (17:30 -0700)]
APItest: Test native code points, instead of Unicode
Karl Williamson [Mon, 25 Feb 2013 00:23:15 +0000 (17:23 -0700)]
Don't refer to U+XXXX when mean native
These messages say the output number is Unicode, but it is really
native, so change to saying is 0xXXXX.
Karl Williamson [Sun, 24 Feb 2013 23:43:59 +0000 (16:43 -0700)]
Convert some uvuni() to uvchr()
All the tables are now based on the native character set, so using
uvuni() in almost all cases is wrong.
Karl Williamson [Sun, 24 Feb 2013 23:25:47 +0000 (16:25 -0700)]
handy.h: White space only
Karl Williamson [Sun, 24 Feb 2013 23:19:49 +0000 (16:19 -0700)]
t/test.pl: Allow native/latin1 string conversions to work on utf8.
These functions no longer have the hard-coded definitions in them,
but now end up resolving to internal functions, so that new encodings
could be added and these would automatically understand them.
Instead of using tr///, these now go character by character and
converting to/from ord, which is slower, but allows them to operate on
utf8 strings.
Peephole optimization should make these essentially no-ops on ascii
platforms.
Karl Williamson [Sun, 24 Feb 2013 23:05:55 +0000 (16:05 -0700)]
t/test.pl: Simplify ord to/from native fcns
This commit changes these functions from converting to/from a string to
calling functions which operate on ordinals instead that are in the
utf8:: namespace.
Karl Williamson [Sun, 24 Feb 2013 22:35:38 +0000 (15:35 -0700)]
Make casing tables native
These are final tables that haven't been converted to native character
set casing.
Karl Williamson [Sun, 24 Feb 2013 22:32:30 +0000 (15:32 -0700)]
utfebcdic.h: Remove trailing spaces
Karl Williamson [Sat, 23 Feb 2013 01:55:26 +0000 (18:55 -0700)]
EBCDIC has the unicode bug too
We have not had a working modern Perl on EBCDIC for some years. When I
started out, comments and code led me to conclude erroneously that
natively it supported semantics for all 256 characters 0-255. It turns
out that I was wrong; it natively (at least on some platforms) has the
same rules (essentially none) for the characters which don't correspond
to ASCII ones, as the rules for these on ASCII platforms.
A previous commit for 5.18 changed the docs about this issue. This
current commit forces ASCII rules on EBCDIC platforms (even should there
be one that natively uses all 256). To get all 256, the same things
like 'use feature "unicode_strings"' must now be done.
Karl Williamson [Thu, 21 Feb 2013 20:47:52 +0000 (13:47 -0700)]
handy.h: Solve a failure to compile problem under EBCDIC
handy.h is included in files that don't include perl.h, and hence not
utf8.h. We can't rely therefore on the ASCII/EBCDIC conversion
macros being available to us. The best way to cope is to use the native
ctype functions. Most, but not all, of the macros in this commit
currently resolve to use those native ones, but a future commit will
change that.
Karl Williamson [Thu, 21 Feb 2013 20:35:12 +0000 (13:35 -0700)]
handy.h: Simplify some macro definitions
Now, only one of the macros relies on magic numbers (isPRINT), leading
to clearer definitions.
Karl Williamson [Thu, 21 Feb 2013 20:26:49 +0000 (13:26 -0700)]
handy.h: Combine macros that are same in ASCII, EBCDIC
These 4 macros can have the same RHS for their ASCII and EBCDIC
versions, so no need to duplicate their definitions
This also enables the EBCDIC versions to not have undefined expansions
when compiling without perl.h
Karl Williamson [Wed, 20 Feb 2013 17:39:48 +0000 (10:39 -0700)]
Deprecate NATIVE_TO_NEED and ASCII_TO_NEED
These macros are no longer called in the Perl core. This commit turns
them into functions so that they can use gcc's deprecation facility.
I believe these were defective right from the beginning, and I have
struggled to understand what's going on. From the name, it appears
NATIVE_TO_NEED taks a native byte and turns it into UTF-8 if the
appropriate parameter indicates that. But that is impossible to do
correctly from that API, as for variant characters, it needs to return
two bytes. It could only work correctly if ch is an I8 byte, which
isn't native, and hence the name would be wrong.
Similar arguments for ASCII_TO_NEED.
The function S_append_utf8_from_native_byte(const U8 byte, U8** dest)
does what I think NATIVE_TO_NEED intended.
Karl Williamson [Wed, 20 Feb 2013 17:26:43 +0000 (10:26 -0700)]
Remove remaining calls of NATIVE_TO_NEED
These calls are just copying the input to the output byte by byte.
There is no need to worry about UTF-8 or not, as the output is just an
exact copy of the input
Karl Williamson [Wed, 20 Feb 2013 15:12:15 +0000 (08:12 -0700)]
toke.c: Remove some NATIVE_TO_NEED calls
I believe NATIVE_TO_NEED is defective, and will remove it in a future
commit. But, just in case I'm wrong, I'm doing it in small steps so
bisects will show the culprit. This removes the calls to it where the
parameter is clearly invariant under UTF-8 and UTF-EBCDIC, and so the
result can't be other than just the parameter.
Karl Williamson [Wed, 20 Feb 2013 15:22:07 +0000 (08:22 -0700)]
toke.c: Emphasize that only [A-Za-z] is used here
This code is attempting to deal with the problem of holes in the ranges
a-z and A-Z in EBCDIC. By using macros with the suffix "_A", we
emphasize that.
Karl Williamson [Tue, 19 Feb 2013 22:13:19 +0000 (15:13 -0700)]
Use real illegal UTF-8 byte
The code here was wrong in assuming that \xFF is not legal in UTF-8
encoded strings. It currently doesn't work due to a bug, but that may
eventually be fixed: [perl #116867]. The comments are also wrong that
all bytes are legal in UTF-EBCDIC.
It turns out that in well-formed UTF-8, the bytes C0 and C1 never appear
(C2, C3, and C4 as well in UTF-EBCDIC), as they would be the start byte
of an illegal overlong sequence.
This creates a #define for an illegal byte using one of the real illegal
ones, and changes the code to use that.
No test is included due to #116867.
Karl Williamson [Sun, 17 Feb 2013 20:50:45 +0000 (13:50 -0700)]
toke.c: Remove remapping for EBCDIC for octal
The code prior to this commit converted something like \04 into its
EBCDIC equivalent only in double-quoted strings. This was not done in
patterns, and so gave inconsistent results. The correct thing to do
should be to do the native thing, what someone who works on a platform
would think \04 do. Platform independent characters are available
through \N{}, either by name or by U+XXXX.
The comment changed by this was wrong, as in some cases it was native,
and in some cases Unicode.
Karl Williamson [Sun, 17 Feb 2013 20:47:13 +0000 (13:47 -0700)]
Remove EBCDIC remappings
Now that the Unicode tables are stored in native format, we shouldn't be
doing remapping.
Note that this assumes that the Latin1 casing tables are stored in
native order; not all of this has been done yet.
Karl Williamson [Sun, 17 Feb 2013 19:46:05 +0000 (12:46 -0700)]
Add and use macro to return EBCDIC
The conversion from UTF-8 to code point should generally be to the
native code point. This adds a macro to do that, and converts the
core calls to the existing macro to use the new one instead. The old
macro is retained for possible backwards compatibility, though it
probably should be deprecated.
Karl Williamson [Sat, 16 Feb 2013 18:05:44 +0000 (11:05 -0700)]
charnames: Make work in EBCDIC
Now that mktables generates native tables, we need to make U+XXXX mean
Unicode instead of native.
Karl Williamson [Sat, 16 Feb 2013 16:35:56 +0000 (09:35 -0700)]
Unicode::UCD: Work on non-ASCII platforms
Now that mktables generates native tables, it is a fairly simple matter
to get Unicode::UCD to work on those platforms.
Karl Williamson [Fri, 15 Feb 2013 05:16:38 +0000 (22:16 -0700)]
mktables: Generate native code-point tables
The output tables for mktables are now in the platform's native
character set. This means there is no change for ASCII platforms, but
is a change for EBCDIC ones.
Code that didn't realize there was a potential difference between EBCDIC
and non-EBCDIC platforms will now start to work; code that tried to do
the right thing under these circumstances will no longer work. Fixing
that comes in later commits.
Karl Williamson [Wed, 3 Apr 2013 03:36:28 +0000 (21:36 -0600)]
mktables: Move table creation code
This code is moved later in the process. This is in preparation for
mktables generating tables in the native character set. By moving it to
later, the translation to native has already been done, and special
coding need not be done.
This also caught 7 code points that were omitted somehow in the previous
logic
Karl Williamson [Thu, 14 Feb 2013 17:50:00 +0000 (10:50 -0700)]
Fix some EBCDIC problems
These spots have native code points, so should be using the macros for
native code points, instead of Unicode ones; this also changes to use
the portable symbolic name of a code point instead of the non-portable
hex.
Karl Williamson [Thu, 14 Feb 2013 05:10:19 +0000 (22:10 -0700)]
Remove unnecessary temp variable in converting to UTF-8
These areas of code included a temporary that is unnecessary.
Karl Williamson [Thu, 14 Feb 2013 05:00:55 +0000 (22:00 -0700)]
utf8.h: Correct macros for EBCDIC
These macros were incorrect for EBCDIC. The 3 step process given in
utfebcdic.h wasn't being followed.
Karl Williamson [Sun, 10 Feb 2013 04:23:30 +0000 (21:23 -0700)]
Extract common code to an inline function
This fairly short paradigm is repeated in several places; a later commit
will improve it.
Karl Williamson [Fri, 8 Feb 2013 04:35:57 +0000 (21:35 -0700)]
Don't use EBCDIC macro for a C language escape
C recognizes '\a' (for BEL); just use that instead of a look-up.
regen/unicode_constants.pl could be used to generate the character for
the ESC (set in nearby code), but I didn't do that because of
potential bootstrapping problems when porting to an EBCDIC platform
without a working perl. (The other characters generated in that .pl are
less likely to cause problems when compiling perl.)
Karl Williamson [Fri, 8 Feb 2013 02:53:38 +0000 (19:53 -0700)]
Use byte domain EBCDIC/LATIN1 macro where appropriate
The macros like NATIVE_TO_UNI will work on EBCDIC, but operate on the
whole Unicode range. In the locations affected by this commit, it is
known that the domain is limited to a single byte, so the simpler ones
whose names contain LATIN1 may be used.
On ASCII platforms, all the macros are null, so there is no effective
change.
Karl Williamson [Thu, 7 Feb 2013 21:31:09 +0000 (14:31 -0700)]
Use new clearer named #defines
This converts several areas of code to use the more clearly named macros
introduced in the previous commit
Karl Williamson [Thu, 7 Feb 2013 20:52:31 +0000 (13:52 -0700)]
utf8.h, utfebcdic.h: Create less confusing #defines
This commit creates macros whose names mean something to me, and which I
don't find confusing. The older names are retained for backwards
compatibility. Future commits will fix bugs I introduced from
misunderstanding the meaning of the older names.
The older names are now #defined in terms of the newer ones, and moved
so that they are only defined once, valid for both ASCII and EBCDIC
platforms.
Karl Williamson [Mon, 4 Feb 2013 21:22:02 +0000 (14:22 -0700)]
pp_ctl.c: Use isCNTRL instead of hard-coded mask
This is clearer and portable to EBCDIC.
There is a subtle difference in the behavior here, which I believe is a
bug fix. Before, the code didn't treat DEL as a control, and now it
does.