fix crash when ${HOME} is empty

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10419 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2005-09-07 09:44:58 +00:00
parent e2a6073643
commit 742ff585a2
3 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2005-08-31 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* filetools.C (MakeDisplayPath): fix bug when HOME is empty.
* lstrings.C (subst): the string to be replaced should not be empty.
2005-07-17 Michael Schmitt <michael.schmitt@teststep.org> 2005-07-17 Michael Schmitt <michael.schmitt@teststep.org>
* package.C.in: * package.C.in:
@ -6,9 +12,10 @@
2005-07-14 Angus Leeming <leeming@lyx.org> 2005-07-14 Angus Leeming <leeming@lyx.org>
* filename.[Ch] (mangledFilename): add an optional "dir" parameter * filename.[Ch] (mangledFilename): add an optional "dir" parameter
that is used to help determine the length of the mangled file name. that is used to help determine the length of the mangled file
Do this because MiKTeX's YAP (version 2.4.1803) will crash if the string name. Do this because MiKTeX's YAP (version 2.4.1803) will crash
referencing the file name in the .dvi file is "too long". MikTeX bug: if the string referencing the file name in the .dvi file is "too
long". MikTeX bug:
http://sourceforge.net/tracker/index.php?func=detail&aid=1238065&group_id=10783&atid=110783 http://sourceforge.net/tracker/index.php?func=detail&aid=1238065&group_id=10783&atid=110783
2005-07-10 Georg Baum <Georg.Baum@post.rwth-aachen.de> 2005-07-10 Georg Baum <Georg.Baum@post.rwth-aachen.de>

View File

@ -1000,7 +1000,7 @@ string const MakeDisplayPath(string const & path, unsigned int threshold)
string const home = package().home_dir(); string const home = package().home_dir();
// replace /home/blah with ~/ // replace /home/blah with ~/
if (prefixIs(str, home)) if (!home.empty() && prefixIs(str, home))
str = subst(str, home, "~"); str = subst(str, home, "~");
if (str.length() <= threshold) if (str.length() <= threshold)

View File

@ -353,6 +353,7 @@ string const subst(string const & a, char oldchar, char newchar)
string const subst(string const & a, string const subst(string const & a,
string const & oldstr, string const & newstr) string const & oldstr, string const & newstr)
{ {
BOOST_ASSERT(!oldstr.empty());
string lstr = a; string lstr = a;
string::size_type i = 0; string::size_type i = 0;
string::size_type const olen = oldstr.length(); string::size_type const olen = oldstr.length();