From 845bc7272f247fc212f9401256808c6e6ac08019 Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Sat, 1 Apr 2006 13:04:23 +0000 Subject: [PATCH] 2006-04-01 Michael Gerz * filename.C (mangledFilename): truncate filename to 100 characters for MiKTeX's pdflatex git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13543 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/filename.C | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/support/filename.C b/src/support/filename.C index 15e2df3331..e46b510584 100644 --- a/src/support/filename.C +++ b/src/support/filename.C @@ -19,6 +19,7 @@ #include #include +#include using std::map; @@ -98,22 +99,13 @@ string const FileName::mangledFilename(std::string const & dir) const s << counter++ << mname; mname = s.str(); - // Experiments show that MiKTeX's YAP (version 2.4.1803) - // will crash if the string referencing the file name in - // the .dvi file is longer than 220 characters. - // This string contains about 50 chars-worth of other data, - // leaving us, say, 160 characters for the file name itself. - // (Erring on the side of caution.) - // Other experiments show that MiKTeX's pdflatex compiler is even - // more picky. A maximum length of 140 has been proven to work. - string::size_type max_length = 140; - if (dir.size() - 1 < max_length) { - // "+ 1" for the directory separator. - max_length -= dir.size() + 1; - } - // If dir.size() > max_length, all bets are off for YAP anyway. - // We truncate the filename nevertheless because of MiKTeX's - // pdflatex compiler. + // MiKTeX's YAP (version 2.4.1803) crashes if the file name + // is longer than about 160 characters. MiKTeX's pdflatex + // is even pickier. A maximum length of 100 has been proven to work. + // If dir.size() > max length, all bets are off for YAP. We truncate + // the filename nevertheless, keeping a minimum of 10 chars. + + string::size_type max_length = std::max(100 - ((int)dir.size() + 1), 10); // If the mangled file name is too long, hack it to fit. // We know we're guaranteed to have a unique file name because