Mercurial > octave
diff liboctave/system/lo-sysdep.cc @ 29016:3b90b3b00451
get_ASCII_filename: Short file names might contain non-ASCII characters (bug #59269).
* liboctave/system/lo-sysdep.cc (get_ASCII_filename): Only return short file
name if it consists of only ASCII characters.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 01 Nov 2020 11:31:57 +0100 |
parents | 040aa7a82662 |
children | f873857f5f86 |
line wrap: on
line diff
--- a/liboctave/system/lo-sysdep.cc Sat Oct 31 12:31:11 2020 +0100 +++ b/liboctave/system/lo-sysdep.cc Sun Nov 01 11:31:57 2020 +0100 @@ -600,8 +600,7 @@ } } - // 2. Check if file system stores short filenames (always - // ASCII-only). + // 2. Check if file system stores short filenames (might be ASCII-only). std::wstring w_orig_file_name_str = u8_to_wstring (orig_file_name); const wchar_t *w_orig_file_name = w_orig_file_name_str.c_str (); @@ -627,10 +626,19 @@ std::wstring w_short_file_name_str = std::wstring (w_short_file_name, length); - std::string short_file_name = u8_from_wstring (w_short_file_name_str); if (w_short_file_name_str.compare (0, length-1, w_full_file_name_str) != 0) - return short_file_name; + { + // Check whether short file name contains non-ASCII characters + std::string short_file_name + = u8_from_wstring (w_short_file_name_str); + first_non_ASCII + = std::find_if (short_file_name.begin (), + short_file_name.end (), + [](char c) { return (c < 0 || c >= 128); }); + if (first_non_ASCII == short_file_name.end ()) + return short_file_name; + } } // 3. Create hard link with only-ASCII characters.