Permalink
Browse files

Perl_langinfo: Teach about YESSTR and NOSTR

These are items that nl_langinfo() used to be required to return, but
are considered obsolete.  Nonetheless, this drop-in replacement for that
function should know about them for backward compatibility.
  • Loading branch information...
khwilliamson committed Nov 19, 2017
1 parent 79f6951 commit fad4af7fd1be4672fd916249ef5887768094456c
Showing with 34 additions and 8 deletions.
  1. +2 −0 ext/XS-APItest/t/locale.t
  2. +20 −6 locale.c
  3. +12 −2 perl_langinfo.h
@@ -83,12 +83,14 @@ my %correct_C_responses = (
MON_8 => 'August',
MON_9 => 'September',
NOEXPR => undef,
NOSTR => undef,
PM_STR => 'PM',
RADIXCHAR => '.',
THOUSEP => '',
T_FMT => undef,
T_FMT_AMPM => undef,
YESEXPR => undef,
YESSTR => undef,
);
my $hdr = "../../perl_langinfo.h";
View
@@ -1275,11 +1275,15 @@ Unimplemented, so returns C<"">.
=item C<YESEXPR>
=item C<YESSTR>
=item C<NOEXPR>
Only the values for English are returned. Earlier POSIX standards also
specified C<YESSTR> and C<NOSTR>, but these have been removed from POSIX 2008,
and aren't supported by C<Perl_langinfo>.
=item C<NOSTR>
Only the values for English are returned. C<YESSTR> and C<NOSTR> have been
removed from POSIX 2008, and are retained for backwards compatibility. Your
platform's C<nl_langinfo> may not support them.
=item C<D_FMT>
@@ -1409,8 +1413,6 @@ S_my_nl_langinfo(const int item, bool toggle)
LOCALE_UNLOCK;
return PL_langinfo_buf;
# else /* Use nl_langinfo_l(), avoiding both a mutex and changing the locale */
bool do_free = FALSE;
@@ -1434,9 +1436,19 @@ S_my_nl_langinfo(const int item, bool toggle)
freelocale(cur);
}
# endif
if (strEQ(PL_langinfo_buf, "")) {
if (item == PERL_YESSTR) {
return "yes";
}
if (item == PERL_NOSTR) {
return "no";
}
}
return PL_langinfo_buf;
# endif
#else /* Below, emulate nl_langinfo as best we can */
# ifdef HAS_LOCALECONV
@@ -1472,7 +1484,9 @@ S_my_nl_langinfo(const int item, bool toggle)
/* We use only an English set, since we don't know any more */
case PERL_YESEXPR: return "^[+1yY]";
case PERL_YESSTR: return "yes";
case PERL_NOEXPR: return "^[-0nN]";
case PERL_NOSTR: return "no";
# ifdef HAS_LOCALECONV
View
@@ -283,15 +283,25 @@
#else
# define PERL_YESEXPR -53
#endif
#ifdef YESSTR
# define PERL_YESSTR YESSTR
#else
# define PERL_YESSTR -54
#endif
#ifdef NOEXPR
# define PERL_NOEXPR NOEXPR
#else
# define PERL_NOEXPR -54
# define PERL_NOEXPR -55
#endif
#ifdef NOSTR
# define PERL_NOSTR NOSTR
#else
# define PERL_NOSTR -56
#endif
#ifdef CRNCYSTR
# define PERL_CRNCYSTR CRNCYSTR
#else
# define PERL_CRNCYSTR -55
# define PERL_CRNCYSTR -57
#endif
#endif

0 comments on commit fad4af7

Please sign in to comment.