Skip to content

Commit

Permalink
locale.c: Collapse duplicate logic into one instance
Browse files Browse the repository at this point in the history
The previous commit move the logic for localeconv() into locale.c.  This
commit takes advantage of that to use it instead of repeating the logic.

On Windows, there is alternative way of finding the radix character for
systems that have a localeconv() that could cause a race.  Prior to this
commit, if that failed to find something that looked like the radix, it
returned a '?'.  Now it will drop down to using this new code, as the
likelihood of the race is small.

Notably, this commit removes the inconsistent duplicate logic that had
been used to deal with the Windows broken localeconv() bug.
  • Loading branch information
khwilliamson committed May 6, 2021
1 parent 745910a commit cf53ed0
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 160 deletions.
9 changes: 8 additions & 1 deletion embed.fnc
Expand Up @@ -3227,7 +3227,7 @@ S |unsigned|get_locale_string_utf8ness_i \
|const int known_utf8
# if (defined(HAS_LOCALECONV) || defined(HAS_LOCALECONV_L)) \
&& (defined(USE_LOCALE_MONETARY) || defined(USE_LOCALE_NUMERIC))
S |HV * |my_localeconv
S |HV * |my_localeconv|const int item
S |HV * |populate_localeconv|NN const struct lconv *lcbuf \
|const int numeric_locale_is_utf8 \
|const int monetary_locale_is_utf8
Expand All @@ -3244,6 +3244,13 @@ S |const char*|my_langinfo_i|const int item \
|NULLOK const char * locale \
|NN const char ** retbufp \
|NULLOK Size_t * retbuf_sizep
# if (defined(HAS_LOCALECONV) || defined(HAS_LOCALECONV_L)) \
&& (defined(USE_LOCALE_MONETARY) || defined(USE_LOCALE_NUMERIC))
S |HV * |get_nl_item_from_localeconv \
|NN const struct lconv *lcbuf \
|const int item \
|const int unused
# endif
# endif
STR |const char *|save_to_buffer|NULLOK const char * string \
|NULLOK const char **buf \
Expand Down
9 changes: 8 additions & 1 deletion embed.h
Expand Up @@ -1503,6 +1503,13 @@
# endif
# endif
# if !(defined(HAS_NL_LANGINFO) || defined(HAS_NL_LANGINFO_L))
# if (defined(HAS_LOCALECONV) || defined(HAS_LOCALECONV_L)) && (defined(USE_LOCALE_MONETARY) || defined(USE_LOCALE_NUMERIC))
# if defined(PERL_IN_LOCALE_C)
# if defined(USE_LOCALE)
#define get_nl_item_from_localeconv(a,b,c) S_get_nl_item_from_localeconv(aTHX_ a,b,c)
# endif
# endif
# endif
# if defined(PERL_IN_LOCALE_C)
# if defined(USE_LOCALE)
#define my_langinfo_i(a,b,c,d,e) S_my_langinfo_i(aTHX_ a,b,c,d,e)
Expand Down Expand Up @@ -1575,7 +1582,7 @@
# if (defined(HAS_LOCALECONV) || defined(HAS_LOCALECONV_L)) && (defined(USE_LOCALE_MONETARY) || defined(USE_LOCALE_NUMERIC))
# if defined(PERL_IN_LOCALE_C)
# if defined(USE_LOCALE)
#define my_localeconv() S_my_localeconv(aTHX)
#define my_localeconv(a) S_my_localeconv(aTHX_ a)
#define populate_localeconv(a,b,c) S_populate_localeconv(aTHX_ a,b,c)
# endif
# endif
Expand Down

0 comments on commit cf53ed0

Please sign in to comment.