Skip to content

Commit

Permalink
bar
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed Nov 17, 2023
1 parent beaaaaf commit 6161338
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
63 changes: 32 additions & 31 deletions locale.c
Expand Up @@ -5318,7 +5318,13 @@ Perl_localeconv(pTHX)
{

#if ! defined(HAS_LOCALECONV)
/* XXX We could define our own 'struct lconv' if localeconv is not to be
* used and that typedef isn't present, and then fix up localeconv to
* return its canned strings in this situation, then this function could
* always be defined and would return the C localeconv values. But
* localeconv() is C89, so very likely to be present */

// XXX leaks
return newHV();

#else
Expand All @@ -5329,7 +5335,7 @@ Perl_localeconv(pTHX)

}

#if defined(HAS_LOCALECONV)
#if defined(HAS_LOCALECONV)

HV *
S_my_localeconv(pTHX_ const int item)
Expand Down Expand Up @@ -5521,10 +5527,8 @@ S_my_localeconv(pTHX_ const int item)
* parameter is ignored. */
PERL_UNUSED_ARG(item);

# else

/* This only gets compiled for the use-case of using localeconv() to
* emulate an nl_langinfo() missing from the platform. */
# else /* This only gets compiled for the use-case of using localeconv()
to emulate nl_langinfo() when missing from the platform. */

# ifdef USE_LOCALE_NUMERIC

Expand Down Expand Up @@ -5620,10 +5624,9 @@ S_my_localeconv(pTHX_ const int item)

# endif

{ /* Here, the call is for all of localeconv(). It has a bunch of
* items. As in the individual item case, set up the parameters for
* the populate functions */

{
/* Here, the call is for all of localeconv(). It has a bunch of
* items. The first function call always gets the MONETARY values */
index_bits = OFFSET_TO_BIT(MONETARY_OFFSET);

# ifdef USE_LOCALE_MONETARY
Expand Down Expand Up @@ -5732,13 +5735,10 @@ S_my_localeconv(pTHX_ const int item)
*/

for (unsigned int i = 0; i < 2; i++) { /* Try both types of strings */
if (! strings[i]) { /* Skip if no strings of this type */
continue;
}

const char * locale = locales[i];
if (! is_locale_utf8(locale)) {
continue; /* No string can be UTF-8 if the locale isn't */
/* The return from this function is already adjusted */
if (populate[i] == S_populate_hash_from_C_localeconv) {
continue;
}

/* Examine each string */
Expand All @@ -5754,17 +5754,19 @@ S_my_localeconv(pTHX_ const int item)

/* Determine if the string should be marked as UTF-8. */
if (UTF8NESS_YES == (get_locale_string_utf8ness_i(SvPVX(*value),
LOCALE_IS_UTF8,
NULL,
(locale_category_index) 0)))
LOCALE_UTF8NESS_UNKNOWN,
locales[i],
LC_ALL_INDEX_ /* OOB */)))
{
SvUTF8_on(*value);
}
}
} /* End of fixing up UTF8ness */


/* Examine each integer */
/* Examine each integer; again the C locale function returns already
* adjusted values */
if (populate[MONETARY_OFFSET] != S_populate_hash_from_C_localeconv) {
// XXX indent
for (; integers; integers++) {
const char * name = integers->name;

Expand All @@ -5782,6 +5784,7 @@ S_my_localeconv(pTHX_ const int item)
sv_setiv(*value, -1);
}
}
}

return hv;

Expand Down Expand Up @@ -5881,9 +5884,6 @@ S_populate_hash_from_localeconv(pTHX_ HV * hv,
PERL_ARGS_ASSERT_POPULATE_HASH_FROM_LOCALECONV;
PERL_UNUSED_ARG(which_mask); /* Some configurations don't use this;
complicated to figure out which */
# ifndef USE_LOCALE
PERL_UNUSED_ARG(locale);
# endif

/* Run localeconv() and copy some or all of its results to the input 'hv'
* hash. Most localeconv() implementations return the values in a global
Expand Down Expand Up @@ -5998,7 +5998,7 @@ S_populate_hash_from_localeconv(pTHX_ HV * hv,
const PERL_UINT_FAST8_T i = lsbit_pos(working_mask);
working_mask &= ~ (1 << i);

/* For each field for the given category ... */
/* For each string field for the given category ... */
const lconv_offset_t * category_strings = strings[i];
while (category_strings->name) {

Expand All @@ -6018,7 +6018,8 @@ S_populate_hash_from_localeconv(pTHX_ HV * hv,
category_strings++;
}

/* Add any int fields to the HV* */
/* Add any int fields to the HV*. We know only MONETARY has integers.
* */
if (i == MONETARY_OFFSET && integers) {
while (integers->name) {
const char value = *((const char *)( lcbuf_as_string
Expand All @@ -6028,7 +6029,7 @@ S_populate_hash_from_localeconv(pTHX_ HV * hv,
integers++;
}
}
} /* End of loop through the fields */
}

/* Done with copying to the hash. Can unwind the critical section locks */

Expand Down Expand Up @@ -6672,14 +6673,14 @@ S_my_langinfo_i(pTHX_

/* The modification is to prefix the localeconv() return with a
* single byte, calculated as follows: */
char prefix = (LIKELY(SvIV(precedes) != -1))
char prefix = (LIKELY(SvIV(precedes) != CHAR_MAX))
? ((precedes != 0) ? '-' : '+')

/* khw couldn't find any documentation that
* CHAR_MAX (which we modify to -1) is the signal,
* but cygwin uses it thusly, and it makes sense
* given that CHAR_MAX indicates the value isn't
* used, so it neither precedes nor succeeds */
* CHAR_MAX is the signal, but cygwin uses it
* thusly, and it makes sense given that CHAR_MAX
* indicates the value isn't used, so it neither
* precedes nor succeeds */
: '.';

/* Now get CRNCYSTR */
Expand Down
2 changes: 1 addition & 1 deletion makedef.pl
Expand Up @@ -186,7 +186,7 @@ BEGIN
}

if ($define{USE_POSIX_2008_LOCALE} && $define{HAS_QUERYLOCALE})
{ # Don't need glibc only code from perl.h
{ # Don't need glibc only code from perl.h XXX except that fails globvar
$define{USE_QUERYLOCALE} = 1;
}

Expand Down
1 change: 1 addition & 0 deletions sv.c
Expand Up @@ -16094,6 +16094,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
#endif

#ifdef USE_LOCALE_NUMERIC
// SAVEPV?
PL_numeric_name = SAVEPV("C");
PL_numeric_radix_sv = newSVpvs(".");
PL_underlying_radix_sv = newSVpvs(".");
Expand Down
1 change: 1 addition & 0 deletions t/test.pl
Expand Up @@ -961,6 +961,7 @@ sub which_perl {
}

sub unlink_all {
#return;
my $count = 0;
foreach my $file (@_) {
1 while unlink $file;
Expand Down
3 changes: 2 additions & 1 deletion win32/GNUmakefile
Expand Up @@ -485,6 +485,7 @@ GCCVER := $(shell $(GCCBIN) -dumpversion)
GCCVER1 := $(shell for /f "delims=. tokens=1,2,3" %%i in ('$(GCCBIN) -dumpversion') do echo %%i)
GCCVER2 := $(shell for /f "delims=. tokens=1,2,3" %%i in ('$(GCCBIN) -dumpversion') do echo %%j)
GCCVER3 := $(shell for /f "delims=. tokens=1,2,3" %%i in ('$(GCCBIN) -dumpversion') do echo %%k)
GCCVER_STRING := $(shell $(GCCBIN) --version)
endif

# Set the install location of the compiler headers/libraries.
Expand Down Expand Up @@ -1459,7 +1460,7 @@ perllibst.h : $(HAVEMINIPERL) $(CONFIGPM) create_perllibst_h.pl

perldll.def : $(HAVEMINIPERL) $(CONFIGPM) ..\embed.fnc ..\makedef.pl
$(MINIPERL) -I..\lib -w ..\makedef.pl PLATFORM=win32 CONFIG_H=$(CONFIG_H) $(OPTIMIZE) $(DEFINES) \
$(BUILDOPT) CCTYPE=$(CCTYPE) TARG_DIR=..\ > perldll.def
$(BUILDOPT) CCTYPE=$(CCTYPE) CRT=$(CRT) TARG_DIR=..\ > perldll.def

$(PERLEXPLIB) : $(PERLIMPLIB)

Expand Down

0 comments on commit 6161338

Please sign in to comment.