| 657 | } |
| 658 | |
| 659 | bool CaMuleExternalConnector::OnInit() |
| 660 | { |
| 661 | #ifndef __WINDOWS__ |
| 662 | #if wxUSE_ON_FATAL_EXCEPTION |
| 663 | // catch fatal exceptions |
| 664 | wxHandleFatalExceptions(true); |
| 665 | #endif |
| 666 | #endif |
| 667 | |
| 668 | // Pull the libc locale from the environment (LANG / LC_ALL / etc.) |
| 669 | // before any wxString -> char* conversion runs via unicode2char(). |
| 670 | // Otherwise the process stays on the default "C" locale and |
| 671 | // wxConvLibc collapses every non-ASCII codepoint to '?' on output. |
| 672 | // readline does its own setlocale on first read, so paths that go |
| 673 | // through readline appear to work; non-interactive paths (e.g. |
| 674 | // amulecmd -c "...") don't and need the explicit init here. |
| 675 | setlocale(LC_ALL, ""); |
| 676 | |
| 677 | // If we didn't know that OnInit is called only once when creating the |
| 678 | // object, it could cause a memory leak. The two pointers below should |
| 679 | // be free()'d before assigning the new value. |
| 680 | // cppcheck-suppress publicAllocationError |
| 681 | m_strFullVersion = strdup((const char *)unicode2char(GetMuleVersion())); |
| 682 | m_strOSDescription = strdup((const char *)unicode2char(wxGetOsDescription())); |
| 683 | |
| 684 | // Handle uncaught exceptions |
| 685 | InstallMuleExceptionHandler(); |
| 686 | |
| 687 | bool retval = wxApp::OnInit(); |
| 688 | OnInitCommandSet(); |
| 689 | InitCustomLanguages(); |
| 690 | SetLocale(m_language); |
| 691 | |
| 692 | #ifdef HAVE_LIBREADLINE |
| 693 | // Allow conditional parsing of the ~/.inputrc file. |
| 694 | // |
| 695 | // OnInitCmdLine() is called from wxApp::OnInit() above, |
| 696 | // thus m_appname is already set. |
| 697 | // macOS libedit's rl_readline_name is char* (not const char*) and |
| 698 | // rl_completion_entry_function is Function* (not rl_compentry_func_t*). |
| 699 | // GNU readline on Linux has the correct const types. |
| 700 | #ifdef __WXMAC__ |
| 701 | rl_readline_name = const_cast<char *>(m_appname); |
| 702 | theCommands = &m_commands; |
| 703 | rl_completion_entry_function = (Function *)&command_completion; |
| 704 | #else |
| 705 | rl_readline_name = m_appname; |
| 706 | theCommands = &m_commands; |
| 707 | rl_completion_entry_function = &command_completion; |
| 708 | #endif |
| 709 | #endif |
| 710 | |
| 711 | return retval; |
| 712 | } |
| 713 | |
| 714 | wxString CaMuleExternalConnector::SetLocale(const wxString& language) |
| 715 | { |
nothing calls this directly
no test coverage detected