-
Notifications
You must be signed in to change notification settings - Fork 125
Add file:native_name_encoding/0 #1807
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
Conversation
src/libAtomVM/nifs.c
Outdated
|
||
static bool env_equals(const char *env_var, const char *value) | ||
{ | ||
const char *env_value = getenv(env_var); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POSIX says getenv is not thread safe. You need to hold global->env_spinlock
.
src/libAtomVM/nifs.c
Outdated
UNUSED(ctx) | ||
UNUSED(argc) | ||
UNUSED(argv) | ||
if (env_equals("LC_ALL", "UTF-8") || env_equals("LC_CTYPE", "UTF-8") || env_equals("LANG", "UTF-8")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by this implementation. We could simply always return utf8
, couldn't we? The most important part here is the documentation of the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it simple: I think we should always return utf8 and properly document this.
IMHO in this case this doesn't have to be a NIF.
91e19cf
to
479e989
Compare
@bettio seems like some unrelated tests are timing out/failing on the CI |
That's ok, I will re-run CI before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a file rename is required.
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
% | ||
|
||
-module(test_file_native_name_encoding). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename to test_file
so we can consistent with other tests in tests/libs/estdlib/tests.erl
.
fadedca
to
3893e7e
Compare
Signed-off-by: Mateusz Front <mateusz.front@swmansion.com>
3893e7e
to
c63a2ff
Compare
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later