fix(windows): use _wfopen for non-ASCII project paths#703
Merged
Conversation
2 tasks
Standard fopen on Windows uses the ANSI/system codepage and silently fails to open files whose absolute path contains non-ASCII characters (accented, CJK, etc.). This causes the pipeline to skip parsing those files entirely — File nodes are created by directory traversal (which already uses wide Win32 APIs) but tree-sitter never receives the source, so no Function/Class/Method nodes are extracted. Add cbm_fopen(path, mode) to compat_fs: - Windows: converts the UTF-8 path to UTF-16LE via cbm_utf8_to_wide (existing helper in win_utf8.h) and calls _wfopen. - POSIX: delegates to fopen (no-op change, paths are already UTF-8). Replace every fopen call that operates on user project file paths: - src/pipeline/pass_parallel.c (primary indexing path) - src/pipeline/pass_definitions.c - src/pipeline/pass_calls.c - src/pipeline/pass_semantic.c - src/pipeline/pass_usages.c - src/pipeline/pass_lsp_cross.c - src/pipeline/pass_pkgmap.c - src/pipeline/pass_k8s.c - src/pipeline/pass_envscan.c - src/pipeline/path_alias.c (tsconfig detection) - src/pipeline/artifact.c - src/discover/language.c (content-sniff for language detection) - src/discover/gitignore.c - src/discover/discover.c - src/discover/userconfig.c - src/mcp/mcp.c (read_file_lines, adr.md reader) Fixes DeusData#700 Signed-off-by: ShauryaaSharma <shauryasofficial27@gmail.com>
24cc5f6 to
98218a2
Compare
Owner
|
Huge thanks for opening this PR and for the work you put into it. The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime. |
This was referenced Jul 1, 2026
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.
Fixes #700
What does this PR do?
On Windows,
fopenuses the ANSI/system codepage and silently returnsNULLwhen the file path contains non-ASCII characters (accented letters, CJK, etc.). The indexer's directory traversal already uses wide Win32 APIs (FindFirstFileW), soFilenodes are created correctly, but the subsequent file-read/parse phase callsfopenwith the UTF-8 path, whichfails silently. tree-sitter never receives the source, so no
Function/Class/Methodnodes are extracted for any file whoseabsolute path contains a non-ASCII character.
Add
cbm_fopen(path, mode)tocompat_fs:cbm_utf8_to_widehelper (win_utf8.h) and delegates to_wfopen.fopenpassthrough, no behaviour change.Replace every
fopencall that receives a user project file path:pass_parallel,pass_definitions,pass_calls,pass_semantic,pass_usages,pass_lsp_cross,pass_pkgmap,pass_k8s,pass_envscan,path_alias(×2),artifact,discover/language,discover/gitignore,discover/discover,discover/userconfig,mcp/mcp.c(read_file_linesandadr.mdreader), 18 call sitesacross 17 files.
Checklist
git commit -s) : required, CI rejects unsigned commits.make -f Makefile.cbm test) : full suite requires ASan + 64-bit toolchain unavailable in this environment; the fix was verified with a targeted harness: created a realcbm-test-césar\hello.pyfixture via Win32 wide-char APIs, confirmed plainfopenreturnsNULLfor that path (bug reproduced), then confirmedcbm_fopenopens and reads it correctly. 7 cases including NULL path, missing file, write+round-trip, and non-ASCII in both directory and filename, all passing.make -f Makefile.cbm lint-ci) : clang-tidy unavailable in this environment; please run in CItests/; the affected code paths are Windows-only and not currently covered by the test suite