static int
get_long_basename (char * name, char * buf, int size)
{
- HANDLE dir_handle;
+ HANDLE dir_handle = INVALID_HANDLE_VALUE;
char fname_utf8[MAX_UTF8_PATH];
int len = 0;
int cstatus = -1;
WIN32_FIND_DATAA find_data_ansi;
filename_to_ansi (name, fname_ansi);
- dir_handle = FindFirstFileA (fname_ansi, &find_data_ansi);
- if (dir_handle != INVALID_HANDLE_VALUE)
- cstatus = filename_from_ansi (find_data_ansi.cFileName, fname_utf8);
+ /* If the ANSI name includes ? characters, it is not encodable
+ in the ANSI codepage. In that case, we deliver the question
+ marks to the caller; calling FindFirstFileA in this case
+ could return some unrelated file name in the same
+ directory. */
+ if (_mbspbrk (fname_ansi, "?"))
+ cstatus = filename_from_ansi (fname_ansi, fname_utf8);
+ else
+ {
+ dir_handle = FindFirstFileA (fname_ansi, &find_data_ansi);
+ if (dir_handle != INVALID_HANDLE_VALUE)
+ cstatus = filename_from_ansi (find_data_ansi.cFileName, fname_utf8);
+ }
}
if (cstatus == 0 && (len = strlen (fname_utf8)) < size)
This variable is set to non-nil by default when Emacs runs on Windows
systems of the NT family, including W2K, XP, Vista, Windows 7 and
-Windows 8. It is set to nil on Windows 9X. */);
+Windows 8. It is set to nil on Windows 9X.
+
+Do NOT change the value of this variable, except for debugging purposes! */);
w32_unicode_filenames = 0;
/* Tell Emacs about this window system. */