From bb2dc9c83f992dd6e237037402844be2ce710a5e Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Wed, 29 Nov 2006 21:47:37 +0000 Subject: [PATCH] convert some more filenames for unicode git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16112 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Chktex.C | 8 ++++++-- src/LaTeX.C | 8 ++++---- src/LaTeX.h | 2 +- src/lyxfunc.C | 5 +++-- src/lyxrc.C | 4 ++-- src/lyxrc.h | 2 +- src/lyxtextclasslist.C | 11 ++++------- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Chktex.C b/src/Chktex.C index 09c48a7eab..22754cc06a 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -27,6 +27,8 @@ namespace lyx { using support::changeExtension; +using support::FileName; +using support::makeAbsPath; using support::onlyFilename; using support::split; using support::Systemcall; @@ -62,7 +64,9 @@ int Chktex::scanLogFile(TeXErrors & terr) { int retval = 0; - string const tmp = onlyFilename(changeExtension(file, ".log")); + // FIXME: Find out whether we can onlyFilename() is really needed, + // or whether makeAbsPath(onlyFilename()) is a noop here + FileName const tmp(makeAbsPath(onlyFilename(changeExtension(file, ".log")))); #if USE_BOOST_FORMAT boost::basic_format msg(_("ChkTeX warning id # %1$d")); @@ -72,7 +76,7 @@ int Chktex::scanLogFile(TeXErrors & terr) docstring token; // FIXME UNICODE // We have no idea what the encoding of the error file is - idocfstream ifs(tmp.c_str()); + idocfstream ifs(tmp.toFilesystemEncoding().c_str()); while (getline(ifs, token)) { docstring srcfile; docstring line; diff --git a/src/LaTeX.C b/src/LaTeX.C index 0557b7ab7d..d320b72d99 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -454,16 +454,16 @@ Aux_Info const LaTeX::scanAuxFile(string const & file) { Aux_Info result; result.aux_file = file; - scanAuxFile(file, result); + scanAuxFile(FileName(makeAbsPath(file)), result); return result; } -void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info) +void LaTeX::scanAuxFile(FileName const & file, Aux_Info & aux_info) { lyxerr[Debug::LATEX] << "Scanning aux file: " << file << endl; - ifstream ifs(file.c_str()); + ifstream ifs(file.toFilesystemEncoding().c_str()); string token; static regex const reg1("\\\\citation\\{([^}]+)\\}"); static regex const reg2("\\\\bibdata\\{([^}]+)\\}"); @@ -504,7 +504,7 @@ void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info) aux_info.styles.insert(style); } else if (regex_match(token, sub, reg4)) { string const file2 = sub.str(1); - scanAuxFile(file2, aux_info); + scanAuxFile(FileName(makeAbsPath(file2)), aux_info); } } } diff --git a/src/LaTeX.h b/src/LaTeX.h index 9af22c954f..a7c1301939 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -172,7 +172,7 @@ private: Aux_Info const scanAuxFile(std::string const &); /// - void scanAuxFile(std::string const &, Aux_Info &); + void scanAuxFile(support::FileName const &, Aux_Info &); /// void updateBibtexDependencies(DepTable &, diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 728116849b..805c0af6b3 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1419,8 +1419,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } case LFUN_PREFERENCES_SAVE: { - support::Path p(package().user_support()); - lyxrc.write("preferences", false); + lyxrc.write(FileName(makeAbsPath("preferences", + package().user_support())), + false); break; } diff --git a/src/lyxrc.C b/src/lyxrc.C index 8e070db6e8..00aeb0b56c 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -1215,9 +1215,9 @@ int LyXRC::read(LyXLex & lexrc) } -void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const +void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const { - ofstream ofs(filename.c_str()); + ofstream ofs(filename.toFilesystemEncoding().c_str()); if (ofs) write(ofs, ignore_system_lyxrc); } diff --git a/src/lyxrc.h b/src/lyxrc.h index a7c17d8887..25d88edf98 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -162,7 +162,7 @@ private: int read(LyXLex &); public: /// - void write(std::string const & filename, + void write(support::FileName const & filename, bool ignore_system_lyxrc) const; /// void write(std::ostream & os, diff --git a/src/lyxtextclasslist.C b/src/lyxtextclasslist.C index bec917d8b0..39b0f2faba 100644 --- a/src/lyxtextclasslist.C +++ b/src/lyxtextclasslist.C @@ -27,6 +27,7 @@ namespace lyx { namespace fs = boost::filesystem; +using support::FileName; using support::libFileSearch; using support::makeDisplayPath; @@ -34,10 +35,6 @@ using boost::bind; using boost::regex; using boost::smatch; -#ifndef CXX_GLOBAL_CSTD -using std::exit; -#endif - using std::endl; using std::equal_to; using std::find_if; @@ -182,15 +179,15 @@ LyXTextClassList::addTextClass(std::string const & textclass, std::string const { // only check for textclass.layout file, .cls can be anywhere in $TEXINPUTS // NOTE: latex class name is defined in textclass.layout, which can be different from textclass - string layout_file = path + "/" + textclass + ".layout"; - if (fs::exists(layout_file)) { + FileName const layout_file(path + '/' + textclass + ".layout"); + if (fs::exists(layout_file.toFilesystemEncoding())) { lyxerr[Debug::TCLASS] << "Adding class " << textclass << " from directory " << path << endl; // Read .layout file and get description, real latex classname etc // // This is a C++ version of function processLayoutFile in configure.py, // which uses the following regex // \Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)} - ifstream ifs(layout_file.c_str()); + ifstream ifs(layout_file.toFilesystemEncoding().c_str()); static regex const reg("^#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*" "(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*"); string line;