rurban / Cpanel-JSON-XS

Improved fork of JSON-XS

Home Page:http://search.cpan.org/dist/Cpanel-JSON-XS/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BBC - undefined symbol: utf8n_to_uvuni

leonerd opened this issue · comments

We have a blead-breaks-CPAN report due to a long-deprecated function that has now been removed.

Perl/perl5#19842

t/00_load.t ................ 1/1 Can't load '/src/perl/Cpanel-JSON-XS-4.29/blib/arch/auto/Cpanel/JSON/XS/XS.so'
  for module Cpanel::JSON::XS: /src/perl/Cpanel-JSON-XS-4.29/blib/arch/auto/Cpanel/JSON/XS/XS.so:
  undefined symbol: utf8n_to_uvuni at lib/perl5/5.37.1/x86_64-linux/DynaLoader.pm line 206.
 at t/00_load.t line 3.
Compilation failed in require at t/00_load.t line 3.
BEGIN failed--compilation aborted at t/00_load.t line 3.
t/00_load.t ................ Dubious, test returned 255 (wstat 65280, 0xff00)

The documentation on the now-deleted function suggests an alternative to use:

Instead use L</utf8_to_uvchr_buf>, or rarely, L</utf8n_to_uvchr>.

This function was useful for code that wanted to handle both EBCDIC and
ASCII platforms with Unicode properties, but starting in Perl v5.20, the
distinctions between the platforms have mostly been made invisible to most
code, so this function is quite unlikely to be what you want. If you do need
this precise functionality, use instead
C<L<NATIVE_TO_UNI(utf8_to_uvchr_buf(...))|/utf8_to_uvchr_buf>>
or C<L<NATIVE_TO_UNI(utf8n_to_uvchr(...))|/utf8n_to_uvchr>>.

we tried the replacement long time ago, and found that it's new functionality was not sufficient. it is also documented there.
will check again if p5p just kept on with their destruction, or if they fixed it.

As far as I can tell this is easy to fix, what isn't clear to me is what behavior you would want.

It seems like only difference between utf8n_to_uvchr and utf8n_to_uvuni is that on EBCDIC platforms the latter will assume UTF-EBCDIC instead of ETF-8. I don't know what behavior you would want or not.

Look at my code which is there since 5.32: Try to workaround 5.32 utf8n_to_uvuni deprecation.

The correct replacement looks like utf8n_to_uvchr now.

/* Since perl 5.14 we can disallow illegal unicode above U+10FFFF.
   Before we could only warn with warnings 'utf8'.
   We accept only valid unicode, unless we are in the relaxed mode.
    
   perl 5.32 deprecated utf8n_to_uvuni accepting illegal unicode, so relaxed does not
   allow such illegal unicode anymore, rather throws a warning in the 'utf8' category.
   Still looking for a way to get the old correct behavior. */
#if PERL_VERSION > 36
    UV c = utf8n_to_uvchr (s, len, clen,
                          UTF8_CHECK_ONLY | (relaxed ? 0 : UTF8_DISALLOW_SUPER));
#elif PERL_VERSION > 12
    UV c = utf8n_to_uvuni (s, len, clen,
                           UTF8_CHECK_ONLY | (relaxed ? 0 : UTF8_DISALLOW_SUPER));
#elif PERL_VERSION >= 8
    UV c = utf8n_to_uvuni (s, len, clen, UTF8_CHECK_ONLY);
#endif

Encode is in a worse situation than me, he wrote everything by himself to be independent on this mess.

BTW: JSON::XS needs the same workaround now. He has no bugtracker.

Fixed with 4.30