Skip to content

Commit

Permalink
XXX querylocale_l
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed Jan 20, 2023
1 parent cc3b718 commit 8d2ce47
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
3 changes: 3 additions & 0 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -4363,6 +4363,9 @@ S |const char *|setlocale_from_aggregate_LC_ALL \
# if defined(USE_QUERYLOCALE)
S |const char *|calculate_LC_ALL \
|const locale_t cur_obj
S |const char *|querylocale_l \
|const unsigned int index \
|const locale_t locale_obj
# else /* if !defined(USE_QUERYLOCALE) */
S |const char *|update_PL_curlocales_i \
|const unsigned int index \
Expand Down
1 change: 1 addition & 0 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@
# define use_curlocale_scratch() S_use_curlocale_scratch(aTHX)
# if defined(USE_QUERYLOCALE)
# define calculate_LC_ALL(a) S_calculate_LC_ALL(aTHX_ a)
# define querylocale_l(a,b) S_querylocale_l(aTHX_ a,b)
# else /* if !defined(USE_QUERYLOCALE) */
# define update_PL_curlocales_i(a,b,c) S_update_PL_curlocales_i(aTHX_ a,b,c)
# endif /* !defined(USE_QUERYLOCALE) */
Expand Down
46 changes: 27 additions & 19 deletions locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,25 +918,6 @@ S_my_setlocale_i(pTHX_ const unsigned int cat_index,
# define querylocale_i(i) mortalized_pv_copy(my_querylocale_i(i))
# define querylocale_c(cat) querylocale_i(cat##_INDEX_)
# define querylocale_r(cat) querylocale_i(get_category_index(cat,NULL))

# ifdef USE_QUERYLOCALE
# define isSINGLE_BIT_SET(mask) isPOWER_OF_2(mask)

/* This code used to think querylocale() was valid on LC_ALL. Make sure
* all instances of that have been removed */
# define QUERYLOCALE_ASSERT(index) \
__ASSERT_(isSINGLE_BIT_SET(category_masks[index]))
# if ! defined(HAS_QUERYLOCALE) && defined(_NL_LOCALE_NAME)
# define querylocale_l(index, locale_obj) \
(QUERYLOCALE_ASSERT(index) \
mortalized_pv_copy(nl_langinfo_l( \
_NL_LOCALE_NAME(categories[index]), locale_obj)))
# else
# define querylocale_l(index, locale_obj) \
(QUERYLOCALE_ASSERT(index) \
mortalized_pv_copy(querylocale(category_masks[index], locale_obj)))
# endif
# endif
# if defined(__GLIBC__) && defined(USE_LOCALE_MESSAGES)
# define HAS_GLIBC_LC_MESSAGES_BUG
# include <libintl.h>
Expand Down Expand Up @@ -1121,6 +1102,33 @@ S_update_PL_curlocales_i(pTHX_
}

# endif /* Need PL_curlocales[] */
# ifdef USE_QUERYLOCALE
# define isSINGLE_BIT_SET(mask) isPOWER_OF_2(mask)

STATIC const char *
S_querylocale_l(pTHX_ const unsigned int index, const locale_t locale_obj)
{
PERL_ARGS_ASSERT_QUERYLOCALE_L;
assert(isSINGLE_BIT_SET(category_masks[index]));

# if ! defined(HAS_QUERYLOCALE) && defined(_NL_LOCALE_NAME)

return mortalized_pv_copy(nl_langinfo_l(_NL_LOCALE_NAME(categories[index]),
locale_obj));
# else

gwLOCALE_LOCK;
const char * result = mortalized_pv_copy(querylocale(category_masks[index],
locale_obj));
gwLOCALE_UNLOCK;

return result;

# endif

}

# endif

STATIC const char *
S_setlocale_from_aggregate_LC_ALL(pTHX_ const char * locale, const line_t line)
Expand Down
4 changes: 4 additions & 0 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d2ce47

Please sign in to comment.