This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Actually make I18N::Langinfo avail on all platforms
authorKarl Williamson <khw@cpan.org>
Thu, 8 Mar 2018 17:59:53 +0000 (10:59 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 12 Mar 2018 16:17:14 +0000 (10:17 -0600)
I thought I had done this earlier, but testing on Windows demonstrated
that I hadn't.

While at it, move the details in the docs for Perl_langinfo to the
module's pod.

This doesn't follow the paradigm for putting the Configure stuff in all
the related configure files, but I saw no point to doing so.  If you are
reading this because I was wrong, feel free to ticket it or fix it.

Configure
README.symbian
ext/I18N-Langinfo/Langinfo.pm
ext/I18N-Langinfo/Langinfo.xs
locale.c
pod/perldelta.pod
symbian/install.cfg
win32/FindExt.pm

index 135ba4e..e7c6187 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -229,6 +229,7 @@ extensions=''
 known_extensions=''
 nonxs_ext=''
 static_ext=''
+usei18n_lang=''
 useopcode=''
 useposix=''
 extras=''
@@ -1464,6 +1465,8 @@ ignore_versioned_solibs=''
 ccname=''
 ccversion=''
 perllibs=''
+: set usei18n_lang=false in your hint file to disable the I18N_Langinfo extension.
+usei18n_lang=true
 : set useposix=false in your hint file to disable the POSIX extension.
 useposix=true
 : set useopcode=false in your hint file to disable the Opcode extension.
@@ -23273,8 +23276,8 @@ for xxx in $xs_extensions ; do
                esac
                ;;
        I18N/Langinfo|i18n_lan)
-               case "$i_langinfo$d_nl_langinfo" in
-               $define$define) avail_ext="$avail_ext $xxx" ;;
+               case "$usei18n_lang" in
+               true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        IPC/SysV|ipc/sysv)
@@ -24820,6 +24823,7 @@ usedevel='$usedevel'
 usedl='$usedl'
 usedtrace='$usedtrace'
 usefaststdio='$usefaststdio'
+usei18n_lang='$i18n_lang'
 useithreads='$useithreads'
 usekernprocpathname='$usekernprocpathname'
 uselargefiles='$uselargefiles'
index c111f30..cb4a42f 100644 (file)
@@ -367,7 +367,7 @@ The Symbian port is licensed under the same terms as Perl itself.
  - The following extensions are missing for various technical
    reasons:
    B ByteLoader Devel::DProf Devel::PPPort Encode GDBM_File
-   I18N::Langinfo IPC::SysV NDBM_File Opcode PerlIO::encoding POSIX
+   IPC::SysV NDBM_File Opcode PerlIO::encoding POSIX
    re Safe Sys::Hostname Sys::Syslog
    threads threads::shared Unicode::Normalize
  - Using MakeMaker or the Module::* to build and install modules
index 7a7005f..bbbc4d1 100644 (file)
@@ -72,7 +72,7 @@ our @EXPORT_OK = qw(
        YESSTR
 );
 
-our $VERSION = '0.15';
+our $VERSION = '0.16';
 
 XSLoader::load();
 
@@ -140,12 +140,17 @@ for the date-time, date, and time formats used by the strftime() function
 for the locales for which it makes sense to have ante meridiem and post
 meridiem time formats,
 
-    CODESET CRNCYSTR RADIXCHAR
+    CODESET CRNCYSTR
 
 for the character code set being used (such as "ISO8859-1", "cp850",
-"koi8-r", "sjis", "utf8", etc.), for the currency string, for the
+"koi8-r", "sjis", "utf8", etc.), for the currency string
+
+    ALT_DIGITS RADIXCHAR THOUSEP
+
+for an alternate representation of digits, for the
 radix character used between the integer and the fractional part
-of decimal numbers (yes, this is redundant with POSIX::localeconv())
+of decimal numbers, the group separator string for large-ish floating point
+numbers  (yes, the final two are redundant with POSIX::localeconv())
 
     YESSTR YESEXPR NOSTR NOEXPR
 
@@ -155,21 +160,74 @@ for the affirmative and negative responses and expressions, and
 
 for the Japanese Emperor eras (naturally only defined under Japanese locales).
 
+Starting in Perl 5.28, this module is available even on systems that lack a
+nativeC<nl_langinfo>.  On such systems, it uses various methods to construct
+what that function, if present, would return.  But there are potential
+glitches.  These are the items that could be different:
+
+=over
+
+=item C<CODESET>
+
+=item C<ERA>
+
+Unimplemented, so returns C<"">.
+
+=item C<YESEXPR>
+
+=item C<YESSTR>
+
+=item C<NOEXPR>
+
+=item C<NOSTR>
+
+Only the values for English are returned.  C<YESSTR> and C<NOSTR> have been
+removed from POSIX 2008, and are retained here for backwards compatibility.
+Your platform's C<nl_langinfo> may not support them.
+
+=item C<D_FMT>
+
+Always evaluates to C<%x>, the locale's appropriate date representation.
+
+=item C<T_FMT>
+
+Always evaluates to C<%X>, the locale's appropriate time representation.
+
+=item C<D_T_FMT>
+
+Always evaluates to C<%c>, the locale's appropriate date and time
+representation.
+
+=item C<CRNCYSTR>
+
+The return may be incorrect for those rare locales where the currency symbol
+replaces the radix character.
+Send email to L<mailto:perlbug@perl.org> if you have examples of it needing
+to work differently.
+
+=item C<ALT_DIGITS>
+
+Currently this gives the same results as Linux does.
+Send email to L<mailto:perlbug@perl.org> if you have examples of it needing
+to work differently.
+
+=item C<ERA_D_FMT>
+
+=item C<ERA_T_FMT>
+
+=item C<ERA_D_T_FMT>
+
+=item C<T_FMT_AMPM>
+
+These are derived by using C<strftime()>, and not all versions of that function
+know about them.  C<""> is returned for these on such systems.
+
+=back
+
 See your L<langinfo(3)> for more information about the available
 constants.  (Often this means having to look directly at the
 F<langinfo.h> C header file.)
 
-Note that unfortunately none of the above constants are guaranteed
-to be available on a particular platform.  To be on the safe side
-you can wrap the import in an eval like this:
-
-    eval {
-        require I18N::Langinfo;
-        I18N::Langinfo->import(qw(langinfo CODESET));
-        $codeset = langinfo(CODESET()); # note the ()
-    };
-    if ($@) { ... failed ... }
-
 =head2 EXPORT
 
 By default only the C<langinfo()> function is exported.
index aae48c2..663cb2a 100644 (file)
@@ -7,6 +7,8 @@
 #ifdef I_LANGINFO
 #   define __USE_GNU 1 /* Enables YESSTR, otherwise only __YESSTR. */
 #   include <langinfo.h>
+#else
+#   include <perl_langinfo.h>
 #endif
 
 #include "const-c.inc"
@@ -30,7 +32,7 @@ langinfo(code)
             RETVAL = newSVpv(Perl_langinfo(code), 0);
         }
 #else
-       croak("nl_langinfo() not implemented on this architecture");
+        RETVAL = newSVpv(Perl_langinfo(code), 0);
 #endif
   OUTPUT:
        RETVAL
index 052f5ab..85ff971 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -2324,67 +2324,9 @@ using C<localeconv>, the buffer from any previous explicit call to
 C<localeconv> will be overwritten.  This means you must save that buffer's
 contents if you need to access them after a call to this function.
 
-The details for those items which may differ from what this emulation returns
-and what a native C<nl_langinfo()> would return are:
-
-=over
-
-=item C<CODESET>
-
-=item C<ERA>
-
-Unimplemented, so returns C<"">.
-
-=item C<YESEXPR>
-
-=item C<YESSTR>
-
-=item C<NOEXPR>
-
-=item C<NOSTR>
-
-Only the values for English are returned.  C<YESSTR> and C<NOSTR> have been
-removed from POSIX 2008, and are retained here for backwards compatibility.
-Your platform's C<nl_langinfo> may not support them.
-
-=item C<D_FMT>
-
-Always evaluates to C<%x>, the locale's appropriate date representation.
-
-=item C<T_FMT>
-
-Always evaluates to C<%X>, the locale's appropriate time representation.
-
-=item C<D_T_FMT>
-
-Always evaluates to C<%c>, the locale's appropriate date and time
-representation.
-
-=item C<CRNCYSTR>
-
-The return may be incorrect for those rare locales where the currency symbol
-replaces the radix character.
-Send email to L<mailto:perlbug@perl.org> if you have examples of it needing
-to work differently.
-
-=item C<ALT_DIGITS>
-
-Currently this gives the same results as Linux does.
-Send email to L<mailto:perlbug@perl.org> if you have examples of it needing
-to work differently.
-
-=item C<ERA_D_FMT>
-
-=item C<ERA_T_FMT>
-
-=item C<ERA_D_T_FMT>
-
-=item C<T_FMT_AMPM>
-
-These are derived by using C<strftime()>, and not all versions of that function
-know about them.  C<""> is returned for these on such systems.
-
-=back
+The details for those items which may deviate from what this emulation returns
+and what a native C<nl_langinfo()> would return are specified in
+L<I18N::Langinfo>.
 
 =back
 
@@ -4330,7 +4272,7 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
      * calculate it */
 
 #  if        defined(USE_LOCALE_CTYPE)                                  \
-     && (   (defined(HAS_NL_LANGINFO) && defined(CODESET))              \
+     && (    defined(HAS_NL_LANGINFO)                                   \
          || (defined(HAS_MBTOWC) || defined(HAS_MBRTOWC)))
 
     {
@@ -4358,7 +4300,7 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
             }
 
 #    endif
-#    if defined(HAS_NL_LANGINFO) && defined(CODESET)
+#    if defined(HAS_NL_LANGINFO)
 
         { /* The task is easiest if the platform has this POSIX 2001 function.
              Except on some platforms it can wrongly return "", so have to have
index 17dff72..3bf0bd4 100644 (file)
@@ -135,6 +135,14 @@ Carp now avoids using C<overload::StrVal>, partly because older versions
 of L<overload> (included with perl 5.14 and earlier) load L<Scalar::Util>
 at run time, which will fail if Carp has been invoked after a syntax error.
 
+L<I18N::Langinfo> has been upgraded from version 0.15 to 0.16.
+
+This module is now available on all platforms, emulating the system
+L<nl_langinfo(3)> on systems that lack it.  Some caveats apply, as
+L<detailed in its documentation|I18N::Langinfo>, the most severe being
+that the C<CODESET> item is not implemented on those systems, always
+returning C<"">.
+
 =back
 
 =head2 Removed Modules and Pragmata
index 28760b7..918d300 100644 (file)
@@ -99,7 +99,7 @@ ext   XSLoader
 # ext  Devel/DProf             nonconst
 # ext  Devel/PPPort            PORT
 # ext  Encode                  nonconst Encode/encode.h def_t.c encengine.c
-# ext  I18N/Langinfo           PORT
+ext    I18N/Langinfo           PORT
 # ext  IPC/SysV                PORT
 # ext  NDBM_File               PORT
 # ext  ODBM_File               PORT
index 5f45a73..4d46821 100644 (file)
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 
 my $no = join('|',qw(Amiga.* GDBM_File ODBM_File NDBM_File DB_File
-                     VMS.* Sys-Syslog IPC-SysV I18N-Langinfo));
+                     VMS.* Sys-Syslog IPC-SysV));
 $no = qr/^(?:$no)$/i;
 
 sub apply_config {
@@ -18,7 +18,6 @@ sub apply_config {
     # duplicates logic from Configure (mostly)
     push @no, "DB_File" unless $config->{i_db};
     push @no, "GDBM_File" unless $config->{i_gdbm};
-    push @no, "I18N-Langinfo" unless $config->{i_langinfo} && $config->{d_nl_langinfo};
     push @no, "IPC-SysV" unless $config->{d_msg} || $config->{d_sem} || $config->{d_shm};
     push @no, "NDBM_File" unless $config->{d_ndbm};
     push @no, "ODBM_File"