@@ -811,25 +811,17 @@ static char *canonicalize_repo_path_if_exists(char *repo_path) {
811811 }
812812
813813 char real [CBM_SZ_4K ];
814- #ifdef _WIN32
815- if (_access (repo_path , 0 ) == 0 && _fullpath (real , repo_path , sizeof (real ))) {
814+ /* Wide-path canonicalization: the old _access/_fullpath pair decoded the
815+ * UTF-8 repo_path through the ANSI codepage and corrupted CJK paths on
816+ * CJK-locale systems (#973). */
817+ if (cbm_canonical_path (repo_path , real , sizeof (real ))) {
816818 cbm_normalize_path_sep (real );
817819 char * canonical = heap_strdup (real );
818820 if (canonical ) {
819821 free (repo_path );
820822 return canonical ;
821823 }
822824 }
823- #else
824- if (realpath (repo_path , real )) {
825- cbm_normalize_path_sep (real );
826- char * canonical = heap_strdup (real );
827- if (canonical ) {
828- free (repo_path );
829- return canonical ;
830- }
831- }
832- #endif
833825
834826 return repo_path ;
835827}
@@ -5056,16 +5048,17 @@ static yyjson_doc *enrich_node_properties(yyjson_mut_doc *doc, yyjson_mut_val *o
50565048 * across preprocessor branches, which defeats source-level tooling that parses
50575049 * without the preprocessor (and left this function unindexed in the graph). */
50585050static bool resolve_canonical_path (const char * path , char * out , size_t out_sz ) {
5059- #ifdef _WIN32
5060- if (!_fullpath (out , path , out_sz )) {
5051+ /* cbm_canonical_path: realpath on POSIX; wide existence check +
5052+ * GetFullPathNameW on Windows (the old bare _fullpath was ANSI —
5053+ * CJK-locale corruption, #973 — and, unlike POSIX realpath, resolved
5054+ * nonexistent paths too; requiring existence aligns the platforms). */
5055+ if (!cbm_canonical_path (path , out , out_sz )) {
50615056 return false;
50625057 }
5058+ #ifdef _WIN32
50635059 cbm_normalize_path_sep (out );
5064- return true;
5065- #else
5066- (void )out_sz ;
5067- return realpath (path , out ) != NULL ;
50685060#endif
5061+ return true;
50695062}
50705063
50715064bool cbm_path_within_root (const char * root_path , const char * abs_path ) {
0 commit comments