Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

Current Trunk
-------------
- Calls to `newlocale` (and `new std::locale` in C++) with arbirary names will
now succeed. This is the behaviour of musl libc which emscripten had
previously inadvertently disabled.
- System libraries are now compiled with debug info (`-g`). This doesn't
affect release builds (builds without `-g`) but allows DWARF debugging of
types defined in system libraries such as C++ STL types (#13078).
Expand Down
2 changes: 2 additions & 0 deletions system/lib/libc/musl/src/locale/newlocale.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ locale_t __newlocale(int mask, const char *name, locale_t loc)
if (j==1 && tmp.cat[LC_CTYPE]==&__c_dot_utf8)
return UTF8_LOCALE;

if ((loc = malloc(sizeof *loc))) *loc = tmp;

return loc;
}

Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/core/test_newlocale.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <locale.h>
#include <stdio.h>

void test(const char* name) {
locale_t loc = newlocale(LC_ALL_MASK, name, 0);
if (loc)
printf("newlocale '%s' succeeded\n", name);
else
printf("newlocale '%s' failed\n", name);
}

int main(int argc, char* argv[]) {
test("C");
test("waka");
return 0;
}
2 changes: 2 additions & 0 deletions tests/core/test_newlocale.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
newlocale 'C' succeeded
newlocale 'waka' succeeded
11 changes: 11 additions & 0 deletions tests/core/test_setlocale.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>
#include <locale.h>

int main(int argc, char* argv[]) {
char* rtn;
rtn = setlocale(LC_ALL, "C");
printf("done setlocale 'C': '%s'\n", rtn);
rtn = setlocale(LC_ALL, "waka");
printf("done setlocale 'waka': '%s'\n", rtn);
return 0;
}
2 changes: 2 additions & 0 deletions tests/core/test_setlocale.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
done setlocale 'C': 'C;C;C;C;C;C'
done setlocale 'waka': 'waka;waka;waka;waka;waka;waka'
10 changes: 8 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7295,8 +7295,14 @@ def test_noexitruntime(self):
def test_minmax(self):
self.do_runf(path_from_root('tests', 'test_minmax.c'), 'NAN != NAN\nSuccess!')

def test_locale(self):
self.do_run_in_out_file_test('tests', 'test_locale.c')
def test_localeconv(self):
self.do_run_in_out_file_test('tests', 'core', 'test_localeconv.c')

def test_newlocale(self):
self.do_run_in_out_file_test('tests', 'core', 'test_newlocale.c')

def test_setlocale(self):
self.do_run_in_out_file_test('tests', 'core', 'test_setlocale.c')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these feel excessive to me in core as I don't think opt levels matter for them? how about other?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but I think there are a whole lot of tests that fall into that category no? For example this existing test_locale was in the wrong place according your assessment? How should we make this decision about which test suite a give test belongs in? (I'm sure I filed a bug about this discussion at some point but I can't seem to find it now).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning is that core runs on various opt levels, so tests that want that should be there. Otherwise, it can be in other.

A codegen test for exceptions would be in core, for example, to see the optimizer can handle it. A libc issue like this could be in other.

def test_vswprintf_utf8(self):
self.do_run_in_out_file_test('tests', 'vswprintf_utf8.c')
Expand Down
12 changes: 10 additions & 2 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -4679,8 +4679,16 @@ def test_locale_wrong(self):
}
''')
self.run_process([EMCC, 'src.cpp', '-s', 'EXIT_RUNTIME', '-s', 'DISABLE_EXCEPTION_CATCHING=0'])
self.assertContained('Constructed locale "C"\nThis locale is the global locale.\nThis locale is the C locale.', self.run_js('a.out.js', args=['C']))
self.assertContained('''Can't construct locale "waka": collate_byname<char>::collate_byname failed to construct for waka''', self.run_js('a.out.js', args=['waka'], assert_returncode=1))
self.assertContained('''\
Constructed locale "C"
This locale is the global locale.
This locale is the C locale.
''', self.run_js('a.out.js', args=['C']))
self.assertContained('''\
Constructed locale "waka"
This locale is not the global locale.
This locale is not the C locale.
''', self.run_js('a.out.js', args=['waka']))

def test_cleanup_os(self):
# issue 2644
Expand Down