From 2b1a44771423d1b3b48b88dee304c6285ebe58ce Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 20 Jun 2003 14:03:49 +0000 Subject: [PATCH] Fix the texinfo dialog and associated cleanup. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7196 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 +++ lib/scripts/TeXFiles.sh | 2 +- po/POTFILES.in | 1 + src/frontends/controllers/ChangeLog | 12 +++++ src/frontends/controllers/ControlBibtex.C | 35 +++++++++---- src/frontends/controllers/ControlBibtex.h | 5 +- src/frontends/controllers/ControlTexinfo.C | 60 +++++++--------------- src/frontends/controllers/ControlTexinfo.h | 16 +++--- src/frontends/controllers/tex_helpers.C | 40 +++++---------- src/frontends/controllers/tex_helpers.h | 9 +++- src/frontends/qt2/ChangeLog | 11 +++- src/frontends/qt2/QBibtex.C | 8 +-- src/frontends/qt2/QBibtexDialog.C | 2 +- src/frontends/qt2/QTexinfo.C | 30 ++++------- src/frontends/qt2/QTexinfo.h | 8 ++- src/frontends/qt2/QTexinfoDialog.C | 28 ++-------- src/frontends/xforms/ChangeLog | 7 +++ src/frontends/xforms/FormBibtex.C | 14 +++-- src/frontends/xforms/FormTexinfo.C | 50 +++++++----------- src/frontends/xforms/FormTexinfo.h | 5 ++ src/support/ChangeLog | 4 ++ src/support/filetools.C | 6 +++ src/support/filetools.h | 4 +- 23 files changed, 181 insertions(+), 182 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index c737f720cf..00f58d4560 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2003-06-20 Angus Leeming + + * scripts/TeXFiles.sh (types): Generalise the sed that tries to + normalise paths /foo//bar ==> /foo/bar to work with arbitrary '///' etc + also. + 2003-06-19 Angus Leeming * lib/bind/cua.bind: diff --git a/lib/scripts/TeXFiles.sh b/lib/scripts/TeXFiles.sh index 0572e3c3e1..a84899208b 100755 --- a/lib/scripts/TeXFiles.sh +++ b/lib/scripts/TeXFiles.sh @@ -72,7 +72,7 @@ for type in $types ; do rm -f $outfile touch $outfile - dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%///%/%' -e 's%//%/%g' -e 's%!!%%g'` + dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%/\{2,\}%/%g' -e 's%!!%%g'` for dir in $dirs ; do find $dir -follow -name "*.$type" >>$outfile 2>/dev/null diff --git a/po/POTFILES.in b/po/POTFILES.in index fcc49c6744..9448d1558d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,6 +6,7 @@ src/LaTeX.C src/MenuBackend.C src/ParagraphParameters.C src/buffer.C +src/buffer_funcs.C src/bufferlist.C src/bufferparams.C src/bufferview_funcs.C diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 89e95a567d..594a1b98eb 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,15 @@ +2003-06-20 Angus Leeming + + * tex_helpers.[Ch] (getTexFileList): changed to + void getTexFileList(string const & file, vector & contents); + + * ControlBibtex.[Ch] (getBibFiles, getBibStyles): now passed a + vector to fill rather than returning a string. + + * ControlTexinfo.[Ch] (rescanStyles, runTexhash): removed. No need + for an extra layer of indirection. + (getContents): moved out of class to getTexFileList. + 2003-06-19 Angus Leeming * ControlTexinfo.[Ch]: rewritten to use the Dialog-based scheme. diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 68489fffa0..8e8f076cb9 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -21,7 +21,10 @@ #include "tex_helpers.h" #include "gettext.h" +#include "support/filetools.h" + using std::pair; +using std::vector; ControlBibtex::ControlBibtex(Dialog & d) @@ -40,27 +43,39 @@ string const ControlBibtex::Browse(string const & in_name, } -string const ControlBibtex::getBibStyles() const +void ControlBibtex::getBibStyles(vector & data) const { - string list = getTexFileList("bstFiles.lst", false); + data.clear(); + + getTexFileList("bstFiles.lst", data); // test, if we have a valid list, otherwise run rescan - if (list.empty()) { + if (data.empty()) { rescanBibStyles(); - list = getTexFileList("bstFiles.lst", false); + getTexFileList("bstFiles.lst", data); + } + vector::iterator it = data.begin(); + vector::iterator end = data.end(); + for (; it != end; ++it) { + *it = OnlyFilename(*it); } - return list; } -string const ControlBibtex::getBibFiles() const +void ControlBibtex::getBibFiles(vector & data) const { - string list = getTexFileList("bibFiles.lst", false); + data.clear(); + + getTexFileList("bibFiles.lst", data); // test, if we have a valid list, otherwise run rescan - if (list.empty()) { + if (data.empty()) { rescanBibStyles(); - list = getTexFileList("bibFiles.lst", false); + getTexFileList("bibFiles.lst", data); + } + vector::iterator it = data.begin(); + vector::iterator end = data.end(); + for (; it != end; ++it) { + *it = OnlyFilename(*it); } - return list; } diff --git a/src/frontends/controllers/ControlBibtex.h b/src/frontends/controllers/ControlBibtex.h index c1449f9115..2b0817a196 100644 --- a/src/frontends/controllers/ControlBibtex.h +++ b/src/frontends/controllers/ControlBibtex.h @@ -15,6 +15,7 @@ #include "ControlCommand.h" +#include /** A controller for Bibtex dialogs. @@ -27,9 +28,9 @@ public: /// Browse for a file string const Browse(string const &, string const &, string const &); /// get the list of bst files - string const getBibStyles() const; + void getBibStyles(std::vector & data) const; /// get the list of bib files - string const getBibFiles() const; + void getBibFiles(std::vector & data) const; /// build filelists of all availabe bib/bst/cls/sty-files. done through /// kpsewhich and an external script, saved in *Files.lst void rescanBibStyles() const; diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C index d0ecf3d845..82ca195d40 100644 --- a/src/frontends/controllers/ControlTexinfo.C +++ b/src/frontends/controllers/ControlTexinfo.C @@ -11,65 +11,41 @@ #include #include "ControlTexinfo.h" -#include "tex_helpers.h" #include "funcrequest.h" -namespace { - -string getFileList(ControlTexinfo::texFileSuffix type, bool withFullPath) +void getTexFileList(ControlTexinfo::texFileSuffix type, + std::vector & list) { + string filename; switch (type) { - case ControlTexinfo::bst: - return getTexFileList("bstFiles.lst", withFullPath); + case ControlTexinfo::bst: + filename = "bstFiles.lst"; break; - case ControlTexinfo::cls: - return getTexFileList("clsFiles.lst", withFullPath); + case ControlTexinfo::cls: + filename = "clsFiles.lst"; break; - case ControlTexinfo::sty: - return getTexFileList("styFiles.lst", withFullPath); + case ControlTexinfo::sty: + filename = "styFiles.lst"; break; } - return string(); + getTexFileList(filename, list); + if (list.empty()) { + // build filelists of all availabe bst/cls/sty-files. + // Done through kpsewhich and an external script, + // saved in *Files.lst + rescanTexStyles(); + getTexFileList(filename, list); + } } -} // namespace anon - ControlTexinfo::ControlTexinfo(Dialog & parent) : Dialog::Controller(parent) {} -// build filelists of all availabe bst/cls/sty-files. done through -// kpsewhich and an external script, saved in *Files.lst -void ControlTexinfo::rescanStyles() const -{ - rescanTexStyles(); -} - - -void ControlTexinfo::runTexhash() const -{ - texhash(); -} - - -string const -ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const -{ - string list(getFileList(type, withFullPath)); - - // initial scan - if (list.empty()) { - rescanStyles(); - list = getFileList(type, withFullPath); - } - return list; -} - - -void ControlTexinfo::viewFile(string const filename) const +void ControlTexinfo::viewFile(string const & filename) const { string const arg = "file " + filename; kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg)); diff --git a/src/frontends/controllers/ControlTexinfo.h b/src/frontends/controllers/ControlTexinfo.h index 2edf4ff08a..939493ee84 100644 --- a/src/frontends/controllers/ControlTexinfo.h +++ b/src/frontends/controllers/ControlTexinfo.h @@ -14,6 +14,7 @@ #include "Dialog.h" +#include "tex_helpers.h" /** A controller for Texinfo dialogs. */ @@ -34,18 +35,19 @@ public: /// the file extensions enum texFileSuffix {cls, sty, bst}; /// show contents af a file - void viewFile(string const filename) const; + void viewFile(string const & filename) const; /// show all classoptions string const getClassOptions(string const & filename) const; - /// build new cls bst sty - lists - void rescanStyles() const; - /// build new bst sty cls lists - void runTexhash() const; - /// read filecontents - string const getContents(texFileSuffix type, bool withPath) const; private: /// virtual void apply() {} }; + +/** Fill \c contents from one of the three texfiles. + * Each entry in the file list is returned as a pair + */ +void getTexFileList(ControlTexinfo::texFileSuffix type, + std::vector & contents); + #endif // CONTROLTEXINFO_H diff --git a/src/frontends/controllers/tex_helpers.C b/src/frontends/controllers/tex_helpers.C index 8f684bcc32..3dcb62ee95 100644 --- a/src/frontends/controllers/tex_helpers.C +++ b/src/frontends/controllers/tex_helpers.C @@ -10,7 +10,6 @@ #include - #include "tex_helpers.h" #include "debug.h" @@ -22,6 +21,7 @@ #include "support/path.h" #include "support/lyxalgo.h" +#include #include #include #include @@ -33,18 +33,6 @@ using std::unique; extern string user_lyxdir; // home of *Files.lst -namespace { - -vector listWithoutPath(vector & dbase) -{ - vector::iterator it = dbase.begin(); - vector::iterator end = dbase.end(); - for (; it != end; ++it) - *it = OnlyFilename(*it); - return dbase; -} - -} // namespace anon // build filelists of all availabe bst/cls/sty-files. done through // kpsewhich and an external script, saved in *Files.lst @@ -69,26 +57,24 @@ void texhash() } -string const getTexFileList(string const & filename, bool withFullPath) +void getTexFileList(string const & filename, std::vector & list) { + list.clear(); string const file = LibFileSearch("", filename); if (file.empty()) - return string(); + return; - vector dbase = - getVectorFromString(GetFileContents(file), "\n"); + list = getVectorFromString(GetFileContents(file), "\n"); - if (withFullPath) { - lyx::eliminate_duplicates(dbase); - string const str_out = - getStringFromVector(dbase, "\n"); - return str_out; + // Normalise paths like /foo//bar ==> /foo/bar + boost::RegEx regex("/{2,}"); + std::vector::iterator it = list.begin(); + std::vector::iterator end = list.end(); + for (; it != end; ++it) { + *it = regex.Merge(*it, "/"); } - vector dbaseWP = listWithoutPath(dbase); - lyx::eliminate_duplicates(dbaseWP); - string const str_out = - getStringFromVector(dbaseWP, "\n"); - return str_out; + + lyx::eliminate_duplicates(list); } diff --git a/src/frontends/controllers/tex_helpers.h b/src/frontends/controllers/tex_helpers.h index 523f3ab1a6..7ba376e8eb 100644 --- a/src/frontends/controllers/tex_helpers.h +++ b/src/frontends/controllers/tex_helpers.h @@ -13,6 +13,9 @@ #include "LString.h" +#include +#include + // build filelists of all availabe bst/cls/sty-files. done through // kpsewhich and an external script, saved in *Files.lst @@ -21,8 +24,10 @@ void rescanTexStyles(); /// rebuild the textree void texhash(); -/// return one of the three texfiles -string const getTexFileList(string const & filename, bool withFullPath); +/** Fill \c contents from one of the three texfiles. + * Each entry in the file list is returned as a name_with_path + */ +void getTexFileList(string const & filename, std::vector & contents); /// get the options of stylefile string const getListOfOptions(string const & classname, string const & type); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 9b047d62b7..af224ddd8d 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2003-06-20 Angus Leeming + + * QBibtexDialog.C (browsePressed): fix warning of comparison between + signed and unsigned ints. + + * QBibtex.C (update_contents): changes due to changed controller + interface. + + * QTexinfo.[Ch]: + * QTexinfoDialog.C: clean-up handling of TeX file databases. 2003-06-19 Alfredo Braunstein @@ -125,7 +135,6 @@ * QGraphicsDialog.C: use relative file browsing (bug 1028) ->>>>>>> 1.522 2003-05-24 John Levon * Toolbar_pimpl.C: workaround a Qt bug with combobox diff --git a/src/frontends/qt2/QBibtex.C b/src/frontends/qt2/QBibtex.C index c5fa14bb11..7925a9ba11 100644 --- a/src/frontends/qt2/QBibtex.C +++ b/src/frontends/qt2/QBibtex.C @@ -74,8 +74,8 @@ void QBibtex::update_contents() dialog_->add_->bibLB->clear(); - vector const bib_str = getVectorFromString( - controller().getBibFiles(), "\n"); + vector bib_str; + controller().getBibFiles(bib_str); for (vector::const_iterator it = bib_str.begin(); it != bib_str.end(); ++it) { string bibItem(ChangeExtension(*it, "")); @@ -102,8 +102,8 @@ void QBibtex::update_contents() int item_nr(-1); - vector const str = getVectorFromString( - controller().getBibStyles(), "\n"); + vector str; + controller().getBibStyles(str); for (vector::const_iterator it = str.begin(); it != str.end(); ++it) { string item(ChangeExtension(*it, "")); diff --git a/src/frontends/qt2/QBibtexDialog.C b/src/frontends/qt2/QBibtexDialog.C index e6eec45592..a659786c8c 100644 --- a/src/frontends/qt2/QBibtexDialog.C +++ b/src/frontends/qt2/QBibtexDialog.C @@ -71,7 +71,7 @@ void QBibtexDialog::browsePressed() bool present = false; unsigned int pres = 0; - for (unsigned int i = 0; i != styleCB->count(); i++) { + for (int i = 0; i != styleCB->count(); ++i) { if (fromqstr(styleCB->text(i)) == filen) { present = true; pres = i; diff --git a/src/frontends/qt2/QTexinfo.C b/src/frontends/qt2/QTexinfo.C index b57dde9a68..c19655c06c 100644 --- a/src/frontends/qt2/QTexinfo.C +++ b/src/frontends/qt2/QTexinfo.C @@ -18,6 +18,7 @@ #include "qt_helpers.h" #include "helper_funcs.h" +#include "support/filetools.h" #include "support/lstrings.h" #include @@ -48,28 +49,17 @@ void QTexinfo::build_dialog() void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) { - string const fstr = controller().getContents(whichStyle, true); - - switch (whichStyle) { - case ControlTexinfo::bst: - bst_ = getVectorFromString(fstr, "\n"); - break; - case ControlTexinfo::cls: - cls_ = getVectorFromString(fstr, "\n"); - break; - case ControlTexinfo::sty: - sty_ = getVectorFromString(fstr, "\n"); - break; - } - - dialog_->fileList->clear(); + ContentsType & data = texdata_[whichStyle]; + getTexFileList(whichStyle, data); bool const withFullPath = dialog_->path->isChecked(); - string const str = controller().getContents(whichStyle, withFullPath); - vector flist = getVectorFromString(str, "\n"); - for (vector::const_iterator fitem = flist.begin(); - fitem != flist.end(); ++fitem) { - dialog_->fileList->insertItem(toqstr((*fitem))); + + dialog_->fileList->clear(); + ContentsType::const_iterator it = data.begin(); + ContentsType::const_iterator end = data.end(); + for (; it != end; ++it) { + string const line = withFullPath ? *it : OnlyFilename(*it); + dialog_->fileList->insertItem(toqstr(line)); } activeStyle = whichStyle; diff --git a/src/frontends/qt2/QTexinfo.h b/src/frontends/qt2/QTexinfo.h index e0102bd699..94efbb63db 100644 --- a/src/frontends/qt2/QTexinfo.h +++ b/src/frontends/qt2/QTexinfo.h @@ -16,6 +16,7 @@ #include "QDialogView.h" #include "ControlTexinfo.h" +#include #include class QTexinfoDialog; @@ -44,11 +45,8 @@ private: /// ControlTexinfo::texFileSuffix activeStyle; /// - std::vector cls_; - /// - std::vector sty_; - /// - std::vector bst_; + typedef std::vector ContentsType; + std::map texdata_; }; #endif // QTEXINFO_H diff --git a/src/frontends/qt2/QTexinfoDialog.C b/src/frontends/qt2/QTexinfoDialog.C index deb427a43e..0ec610b2d6 100644 --- a/src/frontends/qt2/QTexinfoDialog.C +++ b/src/frontends/qt2/QTexinfoDialog.C @@ -22,7 +22,7 @@ #include #include -#include +using std::vector; QTexinfoDialog::QTexinfoDialog(QTexinfo * form) @@ -50,7 +50,7 @@ void QTexinfoDialog::closeEvent(QCloseEvent * e) void QTexinfoDialog::rescanClicked() { // build new *Files.lst - form_->controller().rescanStyles(); + rescanTexStyles(); form_->updateStyles(); enableViewPB(); } @@ -58,27 +58,9 @@ void QTexinfoDialog::rescanClicked() void QTexinfoDialog::viewClicked() { - int const fitem = fileList->currentItem(); - - string sel; - switch (whatStyle->currentItem()) { - case 0: - sel = form_->cls_[fitem]; - break; - case 1: - sel = form_->sty_[fitem]; - break; - case 2: - sel = form_->bst_[fitem]; - break; - default: - break; - } - - // a valid entry? - if (!sel.empty()) { - form_->controller().viewFile(sel); - } + vector::size_type const fitem = fileList->currentItem(); + vector const & data = form_->texdata_[form_->activeStyle]; + form_->controller().viewFile(data[fitem]); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 5744d42a83..6f64664c07 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,10 @@ +2003-06-20 Angus Leeming + + * FormBibtex.C (input, update): changes due to changed controller + interface. + + * FormTexinfo.[Ch]: clean-up handling of TeX file databases. + 2003-06-19 Alfredo Braunstein * lyx_gui.C (start): call ::loadLyXFile instead diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index b2c118cfc6..0211e226a7 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -142,9 +142,10 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long ob_value) } else if (ob == dialog_->button_rescan) { fl_clear_browser(dialog_->browser_styles); controller().rescanBibStyles(); - string const str = - controller().getBibStyles(); - fl_add_browser_line(dialog_->browser_styles, str.c_str()); + vector styles; + controller().getBibStyles(styles); + fl_add_browser_line(dialog_->browser_styles, + getStringFromVector(styles, "\n").c_str()); } // with an empty database nothing makes sense ... @@ -175,9 +176,12 @@ void FormBibtex::update() } fl_set_input(dialog_->input_style, bibstyle.c_str()); + vector styles; + controller().getBibStyles(styles); + fl_clear_browser(dialog_->browser_styles); - string const str = controller().getBibStyles(); - fl_add_browser_line(dialog_->browser_styles, str.c_str()); + fl_add_browser_line(dialog_->browser_styles, + getStringFromVector(styles, "\n").c_str()); } namespace { diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index e6d703ad66..e97ca915a4 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -10,8 +10,6 @@ */ #include -#include - #include "xformsBC.h" #include "FormTexinfo.h" @@ -21,11 +19,10 @@ #include "xforms_helpers.h" #include "support/LAssert.h" #include "support/lstrings.h" +#include "support/filetools.h" #include "lyx_forms.h" -using std::vector; - typedef FormController > base_class; FormTexinfo::FormTexinfo(Dialog & parent) @@ -76,40 +73,26 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) { if (ob == dialog_->button_texhash) { // makes only sense if the rights are set well for // users (/var/lib/texmf/ls-R) - controller().runTexhash(); + texhash(); // texhash requires a rescan and an update of the styles - controller().rescanStyles(); + rescanTexStyles(); updateStyles(activeStyle); } else if (ob == dialog_->browser && ob_value == 2) { // double click in browser: view selected file - string selection = getString(dialog_->browser); - if (!fl_get_button(dialog_->check_fullpath)) { - // contents in browser has filenames without path - // reconstruct path from controller getContents - string const files = controller().getContents(activeStyle, true); - vector const vec = getVectorFromString(files, "\n"); - - // find line in files vector - vector::const_iterator it = vec.begin(); - for (; it != vec.end(); ++it) { - if ((*it).find(selection) != string::npos) { - selection = *it; - break; - } - } - } - if (!selection.empty()) { - controller().viewFile(selection); - } + ContentsType::size_type const sel = fl_get_browser(ob); + ContentsType const & data = texdata_[activeStyle]; + if (sel >= 1 && sel <= data.size()) + controller().viewFile(data[sel-1]); - // reset the browser so that the following single-click callback doesn't do anything + // reset the browser so that the following single-click + // callback doesn't do anything fl_deselect_browser(dialog_->browser); } else if (ob == dialog_->button_rescan) { // build new *Files.lst - controller().rescanStyles(); + rescanTexStyles(); updateStyles(activeStyle); } else if (ob == dialog_->check_fullpath) { @@ -135,13 +118,18 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) { void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) { - fl_clear_browser(dialog_->browser); + ContentsType & data = texdata_[whichStyle]; + getTexFileList(whichStyle, data); bool const withFullPath = fl_get_button(dialog_->check_fullpath); - string const str = - controller().getContents(whichStyle, withFullPath); - fl_add_browser_line(dialog_->browser, str.c_str()); + fl_clear_browser(dialog_->browser); + ContentsType::const_iterator it = data.begin(); + ContentsType::const_iterator end = data.end(); + for (; it != end; ++it) { + string const line = withFullPath ? *it : OnlyFilename(*it); + fl_add_browser_line(dialog_->browser, line.c_str()); + } activeStyle = whichStyle; } diff --git a/src/frontends/xforms/FormTexinfo.h b/src/frontends/xforms/FormTexinfo.h index e2f2b1c5d5..f3a460ee91 100644 --- a/src/frontends/xforms/FormTexinfo.h +++ b/src/frontends/xforms/FormTexinfo.h @@ -15,6 +15,7 @@ #include "FormDialogView.h" #include "ControlTexinfo.h" +#include struct FD_texinfo; @@ -36,6 +37,10 @@ private: void updateStyles(ControlTexinfo::texFileSuffix); /// ControlTexinfo::texFileSuffix activeStyle; + + /// + typedef std::vector ContentsType; + std::map texdata_; }; #endif // FORMTEXINFO_H diff --git a/src/support/ChangeLog b/src/support/ChangeLog index ffb7c60d19..5c2aa416f8 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2003-06-20 Angus Leeming + + * filetools.[Ch] (NormalizePath): also change /foo//bar ==> /foo/bar. + 2003-06-18 Angus Leeming * many files: add the standard blurb, "This file is part of LyX" etc diff --git a/src/support/filetools.C b/src/support/filetools.C index 97869ee402..c33023369d 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -37,6 +37,7 @@ #include "Lsstream.h" +#include #include #include #include @@ -676,6 +677,7 @@ string const ExpandPath(string const & path) // Normalize a path // Constracts path/../path // Can't handle "../../" or "/../" (Asger) +// Also converts paths like /foo//bar ==> /foo/bar string const NormalizePath(string const & path) { string TempBase; @@ -688,6 +690,10 @@ string const NormalizePath(string const & path) // Make implicit current directory explicit RTemp = "./" +path; + // Normalise paths like /foo//bar ==> /foo/bar + boost::RegEx regex("/{2,}"); + RTemp = regex.Merge(RTemp, "/"); + while (!RTemp.empty()) { // Split by next / RTemp = split(RTemp, Temp, '/'); diff --git a/src/support/filetools.h b/src/support/filetools.h index fd82342e20..509c4b04af 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -175,7 +175,9 @@ MakeRelPath(string const & abspath, string const & basepath); /// Strip filename from path name string const OnlyPath(string const & fname); -/// Normalize a path. Constracts path/../path +/** Normalize a path. Constracts path/../path + * Also converts paths like /foo//bar ==> /foo/bar + */ string const NormalizePath(string const & path); /// Strips path from filename -- 2.39.2