diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-12-24 20:11:23 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-12-31 08:27:23 -0700 |
commit | 31aa6e0befef7d9d5586b53de01cc20ca71f9a4b (patch) | |
tree | 57dc960b4f24bda930539eb512850b1cd7394f7d /utf8.c | |
parent | 2d88a86a5910c97496b47b7b7c223f2c9a14b57c (diff) | |
download | perl-31aa6e0befef7d9d5586b53de01cc20ca71f9a4b.tar.gz |
Change format of mktables output binary property tables
mktables now outputs the tables for binary properties as inversion
lists, with a size as the first element. This means simpler handling of
these tables in the core, including removal of an entire pass over them
(it was done just to get the size). These tables are marked as for
internal use by the Perl core only, so their format is changeable at
will.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -4140,6 +4140,33 @@ Perl__swash_to_invlist(pTHX_ SV* const swash) loc = (char *) l; lend = l + lcur; + if (*l == 'V') { /* Inversion list format */ + char *after_strtol = (char *) lend; + UV element0; + UV* other_elements_ptr; + + /* The first number is a count of the rest */ + l++; + elements = Strtoul((char *)l, &after_strtol, 10); + l = (U8 *) after_strtol; + + /* Get the 0th element, which is needed to setup the inversion list */ + element0 = (UV) Strtoul((char *)l, &after_strtol, 10); + l = (U8 *) after_strtol; + invlist = _setup_canned_invlist(elements, element0, &other_elements_ptr); + elements--; + + /* Then just populate the rest of the input */ + while (elements-- > 0) { + if (l > lend) { + Perl_croak(aTHX_ "panic: Expecting %"UVuf" more elements than available", elements); + } + *other_elements_ptr++ = (UV) Strtoul((char *)l, &after_strtol, 10); + l = (U8 *) after_strtol; + } + } + else { + /* Scan the input to count the number of lines to preallocate array size * based on worst possible case, which is each line in the input creates 2 * elements in the inversion list: 1) the beginning of a range in the list; @@ -4173,6 +4200,7 @@ Perl__swash_to_invlist(pTHX_ SV* const swash) invlist = _add_range_to_invlist(invlist, start, end); } + } /* Invert if the data says it should be */ if (invert_it_svp && SvUV(*invert_it_svp)) { |