Skip to content

[CF] Unify common locale macros. #2604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2020

Conversation

3405691582
Copy link
Member

Linux (except Android or Cygwin) and Windows don't support extended
locales, so a number of preprocessor macros are in Prefix to default to
the standard API that uses the C locale. Both Linux and Windows have
some macros in common and some platform specialized definitions; here,
we split out the common macros and keep the platform-specific
definitions separate.

This will let us more simply extend support for different platforms that
also don't support extended locales in a future commit.

@compnerd
Copy link
Member

I think that this is incorrect. It is in fact the opposite I believe. Linux but not android supports the extended locale variant. Windows does not. I'm not certain about cygwin, but I imagine that it does as well. It just Android (below a certain version per interface) and Windows which do not support the extended locales.

@3405691582 3405691582 force-pushed the Prefix_CommonLocaleAliases branch from edf15a3 to 4009bab Compare January 12, 2020 19:10
CF ensures Linux and Windows don't attempt to use the extended locale API
by defining a number of preprocessor macros in Prefix to default to the
standard API that uses the C locale. Both Linux and Windows have some
macros in common and some platform specialized definitions; here, we
split out the common macros and keep the platform-specific definitions
separate.

This will let us more simply extend support for different platforms that
also don't support extended locales in a future commit.
@3405691582 3405691582 force-pushed the Prefix_CommonLocaleAliases branch from 4009bab to 89ecec8 Compare January 12, 2020 19:26
@3405691582
Copy link
Member Author

3405691582 commented Jan 12, 2020

I think I was confused with the earlier PR. Adjusted the commit description to describe what CF is doing rather than what is the state of the world.

The code change is -- in a mechanical sense -- still OK since the macros aren't more specially controlled than TARGET_OS_LINUX.

I'm not sure off the top of my head what the state of locale support is on Linux. CF however thinks Linux doesn't have extended locale APIs, but maybe that's changed. I can look at that later.

(Of course, this is confused by the fact that Android supports xlocale.h, these macros are defined unconditionally for Android because Android is TARGET_OS_LINUX, and then those macros become irrelevant anyway when xlocale.h is #included elsewhere in CFInternal.h. And indeed Cygwin probably supports xlocale.h but in CFInternal.h is prevented from being #include'd, so maybe it didn't in the past?)

@compnerd
Copy link
Member

I think I was confused with the earlier PR. Adjusted the commit description to describe what CF is doing rather than what is the state of the world.

Thanks.

The code change is -- in a mechanical sense -- still OK since the macros aren't more specially controlled than TARGET_OS_LINUX.

Agreed.

I'm not sure off the top of my head what the state of locale support is on Linux. CF however thinks Linux doesn't have extended locale APIs, but maybe that's changed. I can look at that later.

Could you please? That would be a great improvement.

@compnerd
Copy link
Member

@swift-ci please test

@compnerd compnerd merged commit e6e0046 into swiftlang:master Jan 14, 2020
@3405691582 3405691582 deleted the Prefix_CommonLocaleAliases branch January 15, 2020 00:48
@3405691582
Copy link
Member Author

3405691582 commented Jan 15, 2020

Could you please? That would be a great improvement.

Certainly. I'm not very familiar with a lot of the locale stuff, but a cursory look suggests most of the invocations pass NULL for a locale, which uses the C locale default. Nevertheless, there looks like some potential for some cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants