summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-03-08 10:59:53 -0700
committerKarl Williamson <khw@cpan.org>2018-03-12 10:17:14 -0600
commit6201c2203671c3e78f25fa02205bd962d5bd92b1 (patch)
tree02357dbfcbe38f5d7542e8651af0727a1fc05b22 /ext
parent4e6826bf86819426cea8be0677b2a3282834ced5 (diff)
downloadperl-6201c2203671c3e78f25fa02205bd962d5bd92b1.tar.gz
Actually make I18N::Langinfo avail on all platforms
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.
Diffstat (limited to 'ext')
-rw-r--r--ext/I18N-Langinfo/Langinfo.pm88
-rw-r--r--ext/I18N-Langinfo/Langinfo.xs4
2 files changed, 76 insertions, 16 deletions
diff --git a/ext/I18N-Langinfo/Langinfo.pm b/ext/I18N-Langinfo/Langinfo.pm
index 7a7005f7ab..bbbc4d1766 100644
--- a/ext/I18N-Langinfo/Langinfo.pm
+++ b/ext/I18N-Langinfo/Langinfo.pm
@@ -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.
diff --git a/ext/I18N-Langinfo/Langinfo.xs b/ext/I18N-Langinfo/Langinfo.xs
index aae48c2b28..663cb2a665 100644
--- a/ext/I18N-Langinfo/Langinfo.xs
+++ b/ext/I18N-Langinfo/Langinfo.xs
@@ -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