Le 06/11/11 23:36, [email protected] a écrit :
Author: lasgouttes
Date: Sun Nov 6 23:36:14 2011
New Revision: 40149
URL: http://www.lyx.org/trac/changeset/40149
Log:
Fix shortenng of file names in MakeDisplayPath: it is not a good idea to slice
an utf8 string at arbitrary offsets, we have to work on a docstring instead. We
need unfortunately to switch back and orth between utf8 and docstring.
This is a candidate for branch too, although the bug is minor.
I never asked for putting this on string, but it helps with hebrew file
names, for example. OK?
JMarc
Modified:
lyx-devel/trunk/src/support/filetools.cpp
Modified: lyx-devel/trunk/src/support/filetools.cpp
==============================================================================
--- lyx-devel/trunk/src/support/filetools.cpp Sun Nov 6 19:56:26 2011
(r40148)
+++ lyx-devel/trunk/src/support/filetools.cpp Sun Nov 6 23:36:14 2011
(r40149)
@@ -802,25 +802,26 @@
return from_utf8(os::external_path(str));
string const prefix = ".../";
- string temp;
+ docstring dstr = from_utf8(str);
+ docstring temp;
- while (str.length() > threshold)
- str = split(str, temp, '/');
+ while (dstr.length() > threshold)
+ dstr = split(dstr, temp, '/');
// Did we shorten everything away?
- if (str.empty()) {
+ if (dstr.empty()) {
// Yes, filename itself is too long.
// Pick the start and the end of the filename.
- str = onlyFileName(path);
- string const head = str.substr(0, threshold / 2 - 3);
+ dstr = from_utf8(onlyFileName(path));
+ docstring const head = dstr.substr(0, threshold / 2 - 3);
- string::size_type len = str.length();
- string const tail =
- str.substr(len - threshold / 2 - 2, len - 1);
- str = head + "..." + tail;
+ docstring::size_type len = dstr.length();
+ docstring const tail =
+ dstr.substr(len - threshold / 2 - 2, len - 1);
+ dstr = head + from_ascii("...") + tail;
}
- return from_utf8(os::external_path(prefix + str));
+ return from_utf8(os::external_path(prefix + to_utf8(dstr)));
}