ExternalConnector: setlocale on init so non-interactive output keeps accented chars (#626) - #629
Merged
Conversation
…amule-project#626) CaMuleExternalConnector::OnInit() never called setlocale(), so any process built on it (amulecmd, amuleweb) stayed on the default "C" locale unless something else (e.g. wxLocale via -l, or readline on first input) re-initialised it. wxConvLibc -- which unicode2char() uses to convert wxString -> char* for Show()'s printf -- consults LC_CTYPE at runtime; with LC_CTYPE=C it collapses every non-ASCII codepoint to '?'. In the interactive amulecmd path readline calls setlocale(LC_ALL, "") on first prompt, which happens to mask the bug -- by the time any Show() output runs the locale has already been pulled from the env. The non-interactive `amulecmd -c "show shared"` path never touches readline, so the locale stays at C and accented filenames in shared/ download listings display as '?' or garbled byte sequences (see danim7's repro in amule-project#626 -- 333_à / 111_é / 555_â / 444_ü all garbled). Call setlocale(LC_ALL, "") at the top of CaMuleExternalConnector:: OnInit() so the locale is sourced from the env (LANG / LC_ALL / LC_CTYPE) before anything has a chance to call unicode2char(). The fix benefits every CaMuleExternalConnector subclass, not just amulecmd. Verified on macOS arm64: amulecmd rebuilds clean. Reported by danim7.
Contributor
|
Very fast! |
got3nks
added a commit
to got3nks/amule
that referenced
this pull request
Jul 27, 2026
…mule-project#629) Add a fully static musl/Alpine build producing self-contained amuled, amulecmd and amuleapi binaries with no runtime shared-library dependencies, wired into the existing Linux packaging pipeline: - packaging/linux/static/ holds the recipe (Dockerfile + README), alongside appimage/ and flatpak/. Versions come from versions.env (wx / Crypto++ / libupnp, SHA256-verified) — no pins in the Dockerfile. - packaging/linux/build.sh gains a 'static' target mirroring the other tracks; packaging.yml gains a linux-static matrix job (x86_64 + aarch64 native runners) that calls it, with a buildx gha layer cache disabled on workflow_call so release builds cold-compile. - release.yml downloads the linux-static-* artifacts into the draft with a manifest check like the other platforms. Feature set: UPnP, IP2Country, BFD backtraces, NLS, wxWebRequest downloads. Monolithic GUI excluded — wxGTK dlopen()s modules, so it cannot be static. Ships one tarball per arch: aMule-<ver>-Linux-<x64|arm64>-static.tar.gz.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CaMuleExternalConnector::OnInit()never callssetlocale(), so anything built on it (amulecmd,amuleweb) stays on the default"C"locale unless-lis passed or readline re-initialises it lazily.Show()emits output via:unicode2chariswxConvLibc.cWX2MB(...), which consultsLC_CTYPEat runtime. WithLC_CTYPE=C, every non-ASCII codepoint collapses to?on output.In the interactive
amulecmdpath, readline callssetlocale(LC_ALL, "")on first prompt, which incidentally fixes the locale before anyShow()output runs. In the non-interactiveamulecmd -c "show shared"path readline is never touched (TextClient.cpp:227-228) and the locale stays atC. @danim7's repro in #626 shows shared-file paths333_à/111_é/555_â/444_üall rendered as?or garbled byte sequences in-cmode while interactive mode displays them correctly — same data over the same EC channel, only the output-encoding path differs.Fix
Call
setlocale(LC_ALL, "")at the top ofCaMuleExternalConnector::OnInit()so the libc locale is sourced fromLANG/LC_ALL/LC_CTYPEbefore anything has a chance to invokeunicode2char(). Adds#include <clocale>for the prototype.The fix benefits every
CaMuleExternalConnectorsubclass —amulecmd(interactive and-c) andamuleweb(which has its own startup flow but shares the conversion path).Validation
macOS arm64:
amulecmdrebuilds clean.The interactive path was already working (readline did the locale init for us); the fix removes the dependency on readline being touched first. Non-interactive
-cpaths now also emit correct UTF-8.Closes #626.