Fix the texinfo dialog and associated cleanup.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7196 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-06-20 14:03:49 +00:00
parent 2d8eb4b9d4
commit 2b1a447714
23 changed files with 181 additions and 182 deletions

View File

@ -1,3 +1,9 @@
2003-06-20 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org> 2003-06-19 Angus Leeming <leeming@lyx.org>
* lib/bind/cua.bind: * lib/bind/cua.bind:

View File

@ -72,7 +72,7 @@ for type in $types ; do
rm -f $outfile rm -f $outfile
touch $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 for dir in $dirs ; do
find $dir -follow -name "*.$type" >>$outfile 2>/dev/null find $dir -follow -name "*.$type" >>$outfile 2>/dev/null

View File

@ -6,6 +6,7 @@ src/LaTeX.C
src/MenuBackend.C src/MenuBackend.C
src/ParagraphParameters.C src/ParagraphParameters.C
src/buffer.C src/buffer.C
src/buffer_funcs.C
src/bufferlist.C src/bufferlist.C
src/bufferparams.C src/bufferparams.C
src/bufferview_funcs.C src/bufferview_funcs.C

View File

@ -1,3 +1,15 @@
2003-06-20 Angus Leeming <leeming@lyx.org>
* tex_helpers.[Ch] (getTexFileList): changed to
void getTexFileList(string const & file, vector<string> & contents);
* ControlBibtex.[Ch] (getBibFiles, getBibStyles): now passed a
vector<string> 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 <leeming@lyx.org> 2003-06-19 Angus Leeming <leeming@lyx.org>
* ControlTexinfo.[Ch]: rewritten to use the Dialog-based scheme. * ControlTexinfo.[Ch]: rewritten to use the Dialog-based scheme.

View File

@ -21,7 +21,10 @@
#include "tex_helpers.h" #include "tex_helpers.h"
#include "gettext.h" #include "gettext.h"
#include "support/filetools.h"
using std::pair; using std::pair;
using std::vector;
ControlBibtex::ControlBibtex(Dialog & d) 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<string> & data) const
{ {
string list = getTexFileList("bstFiles.lst", false); data.clear();
getTexFileList("bstFiles.lst", data);
// test, if we have a valid list, otherwise run rescan // test, if we have a valid list, otherwise run rescan
if (list.empty()) { if (data.empty()) {
rescanBibStyles(); rescanBibStyles();
list = getTexFileList("bstFiles.lst", false); getTexFileList("bstFiles.lst", data);
}
vector<string>::iterator it = data.begin();
vector<string>::iterator end = data.end();
for (; it != end; ++it) {
*it = OnlyFilename(*it);
} }
return list;
} }
string const ControlBibtex::getBibFiles() const void ControlBibtex::getBibFiles(vector<string> & data) const
{ {
string list = getTexFileList("bibFiles.lst", false); data.clear();
getTexFileList("bibFiles.lst", data);
// test, if we have a valid list, otherwise run rescan // test, if we have a valid list, otherwise run rescan
if (list.empty()) { if (data.empty()) {
rescanBibStyles(); rescanBibStyles();
list = getTexFileList("bibFiles.lst", false); getTexFileList("bibFiles.lst", data);
}
vector<string>::iterator it = data.begin();
vector<string>::iterator end = data.end();
for (; it != end; ++it) {
*it = OnlyFilename(*it);
} }
return list;
} }

View File

@ -15,6 +15,7 @@
#include "ControlCommand.h" #include "ControlCommand.h"
#include <vector>
/** A controller for Bibtex dialogs. /** A controller for Bibtex dialogs.
@ -27,9 +28,9 @@ public:
/// Browse for a file /// Browse for a file
string const Browse(string const &, string const &, string const &); string const Browse(string const &, string const &, string const &);
/// get the list of bst files /// get the list of bst files
string const getBibStyles() const; void getBibStyles(std::vector<string> & data) const;
/// get the list of bib files /// get the list of bib files
string const getBibFiles() const; void getBibFiles(std::vector<string> & data) const;
/// build filelists of all availabe bib/bst/cls/sty-files. done through /// build filelists of all availabe bib/bst/cls/sty-files. done through
/// kpsewhich and an external script, saved in *Files.lst /// kpsewhich and an external script, saved in *Files.lst
void rescanBibStyles() const; void rescanBibStyles() const;

View File

@ -11,65 +11,41 @@
#include <config.h> #include <config.h>
#include "ControlTexinfo.h" #include "ControlTexinfo.h"
#include "tex_helpers.h"
#include "funcrequest.h" #include "funcrequest.h"
namespace { void getTexFileList(ControlTexinfo::texFileSuffix type,
std::vector<string> & list)
string getFileList(ControlTexinfo::texFileSuffix type, bool withFullPath)
{ {
string filename;
switch (type) { switch (type) {
case ControlTexinfo::bst: case ControlTexinfo::bst:
return getTexFileList("bstFiles.lst", withFullPath); filename = "bstFiles.lst";
break; break;
case ControlTexinfo::cls: case ControlTexinfo::cls:
return getTexFileList("clsFiles.lst", withFullPath); filename = "clsFiles.lst";
break; break;
case ControlTexinfo::sty: case ControlTexinfo::sty:
return getTexFileList("styFiles.lst", withFullPath); filename = "styFiles.lst";
break; 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) ControlTexinfo::ControlTexinfo(Dialog & parent)
: Dialog::Controller(parent) : Dialog::Controller(parent)
{} {}
// build filelists of all availabe bst/cls/sty-files. done through void ControlTexinfo::viewFile(string const & filename) const
// 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
{ {
string const arg = "file " + filename; string const arg = "file " + filename;
kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg)); kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg));

View File

@ -14,6 +14,7 @@
#include "Dialog.h" #include "Dialog.h"
#include "tex_helpers.h"
/** A controller for Texinfo dialogs. */ /** A controller for Texinfo dialogs. */
@ -34,18 +35,19 @@ public:
/// the file extensions /// the file extensions
enum texFileSuffix {cls, sty, bst}; enum texFileSuffix {cls, sty, bst};
/// show contents af a file /// show contents af a file
void viewFile(string const filename) const; void viewFile(string const & filename) const;
/// show all classoptions /// show all classoptions
string const getClassOptions(string const & filename) const; 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: private:
/// ///
virtual void apply() {} virtual void apply() {}
}; };
/** Fill \c contents from one of the three texfiles.
* Each entry in the file list is returned as a pair<name_with_path, name_only>
*/
void getTexFileList(ControlTexinfo::texFileSuffix type,
std::vector<string> & contents);
#endif // CONTROLTEXINFO_H #endif // CONTROLTEXINFO_H

View File

@ -10,7 +10,6 @@
#include <config.h> #include <config.h>
#include "tex_helpers.h" #include "tex_helpers.h"
#include "debug.h" #include "debug.h"
@ -22,6 +21,7 @@
#include "support/path.h" #include "support/path.h"
#include "support/lyxalgo.h" #include "support/lyxalgo.h"
#include <boost/cregex.hpp>
#include <vector> #include <vector>
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
@ -33,18 +33,6 @@ using std::unique;
extern string user_lyxdir; // home of *Files.lst extern string user_lyxdir; // home of *Files.lst
namespace {
vector<string> listWithoutPath(vector<string> & dbase)
{
vector<string>::iterator it = dbase.begin();
vector<string>::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 // build filelists of all availabe bst/cls/sty-files. done through
// kpsewhich and an external script, saved in *Files.lst // 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<string> & list)
{ {
list.clear();
string const file = LibFileSearch("", filename); string const file = LibFileSearch("", filename);
if (file.empty()) if (file.empty())
return string(); return;
vector<string> dbase = list = getVectorFromString(GetFileContents(file), "\n");
getVectorFromString(GetFileContents(file), "\n");
if (withFullPath) { // Normalise paths like /foo//bar ==> /foo/bar
lyx::eliminate_duplicates(dbase); boost::RegEx regex("/{2,}");
string const str_out = std::vector<string>::iterator it = list.begin();
getStringFromVector(dbase, "\n"); std::vector<string>::iterator end = list.end();
return str_out; for (; it != end; ++it) {
*it = regex.Merge(*it, "/");
} }
vector<string> dbaseWP = listWithoutPath(dbase);
lyx::eliminate_duplicates(dbaseWP); lyx::eliminate_duplicates(list);
string const str_out =
getStringFromVector(dbaseWP, "\n");
return str_out;
} }

View File

@ -13,6 +13,9 @@
#include "LString.h" #include "LString.h"
#include <utility>
#include <vector>
// build filelists of all availabe bst/cls/sty-files. done through // build filelists of all availabe bst/cls/sty-files. done through
// kpsewhich and an external script, saved in *Files.lst // kpsewhich and an external script, saved in *Files.lst
@ -21,8 +24,10 @@ void rescanTexStyles();
/// rebuild the textree /// rebuild the textree
void texhash(); void texhash();
/// return one of the three texfiles /** Fill \c contents from one of the three texfiles.
string const getTexFileList(string const & filename, bool withFullPath); * Each entry in the file list is returned as a name_with_path
*/
void getTexFileList(string const & filename, std::vector<string> & contents);
/// get the options of stylefile /// get the options of stylefile
string const getListOfOptions(string const & classname, string const & type); string const getListOfOptions(string const & classname, string const & type);

View File

@ -1,3 +1,13 @@
2003-06-20 Angus Leeming <leeming@lyx.org>
* 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 <abraunst@libero.it> 2003-06-19 Alfredo Braunstein <abraunst@libero.it>
@ -125,7 +135,6 @@
* QGraphicsDialog.C: use relative file browsing * QGraphicsDialog.C: use relative file browsing
(bug 1028) (bug 1028)
>>>>>>> 1.522
2003-05-24 John Levon <levon@movementarian.org> 2003-05-24 John Levon <levon@movementarian.org>
* Toolbar_pimpl.C: workaround a Qt bug with combobox * Toolbar_pimpl.C: workaround a Qt bug with combobox

View File

@ -74,8 +74,8 @@ void QBibtex::update_contents()
dialog_->add_->bibLB->clear(); dialog_->add_->bibLB->clear();
vector<string> const bib_str = getVectorFromString( vector<string> bib_str;
controller().getBibFiles(), "\n"); controller().getBibFiles(bib_str);
for (vector<string>::const_iterator it = bib_str.begin(); for (vector<string>::const_iterator it = bib_str.begin();
it != bib_str.end(); ++it) { it != bib_str.end(); ++it) {
string bibItem(ChangeExtension(*it, "")); string bibItem(ChangeExtension(*it, ""));
@ -102,8 +102,8 @@ void QBibtex::update_contents()
int item_nr(-1); int item_nr(-1);
vector<string> const str = getVectorFromString( vector<string> str;
controller().getBibStyles(), "\n"); controller().getBibStyles(str);
for (vector<string>::const_iterator it = str.begin(); for (vector<string>::const_iterator it = str.begin();
it != str.end(); ++it) { it != str.end(); ++it) {
string item(ChangeExtension(*it, "")); string item(ChangeExtension(*it, ""));

View File

@ -71,7 +71,7 @@ void QBibtexDialog::browsePressed()
bool present = false; bool present = false;
unsigned int pres = 0; 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) { if (fromqstr(styleCB->text(i)) == filen) {
present = true; present = true;
pres = i; pres = i;

View File

@ -18,6 +18,7 @@
#include "qt_helpers.h" #include "qt_helpers.h"
#include "helper_funcs.h" #include "helper_funcs.h"
#include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include <qlistbox.h> #include <qlistbox.h>
@ -48,28 +49,17 @@ void QTexinfo::build_dialog()
void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
{ {
string const fstr = controller().getContents(whichStyle, true); ContentsType & data = texdata_[whichStyle];
getTexFileList(whichStyle, data);
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();
bool const withFullPath = dialog_->path->isChecked(); bool const withFullPath = dialog_->path->isChecked();
string const str = controller().getContents(whichStyle, withFullPath);
vector<string> flist = getVectorFromString(str, "\n"); dialog_->fileList->clear();
for (vector<string>::const_iterator fitem = flist.begin(); ContentsType::const_iterator it = data.begin();
fitem != flist.end(); ++fitem) { ContentsType::const_iterator end = data.end();
dialog_->fileList->insertItem(toqstr((*fitem))); for (; it != end; ++it) {
string const line = withFullPath ? *it : OnlyFilename(*it);
dialog_->fileList->insertItem(toqstr(line));
} }
activeStyle = whichStyle; activeStyle = whichStyle;

View File

@ -16,6 +16,7 @@
#include "QDialogView.h" #include "QDialogView.h"
#include "ControlTexinfo.h" #include "ControlTexinfo.h"
#include <map>
#include <vector> #include <vector>
class QTexinfoDialog; class QTexinfoDialog;
@ -44,11 +45,8 @@ private:
/// ///
ControlTexinfo::texFileSuffix activeStyle; ControlTexinfo::texFileSuffix activeStyle;
/// ///
std::vector<string> cls_; typedef std::vector<string> ContentsType;
/// std::map<ControlTexinfo::texFileSuffix, ContentsType> texdata_;
std::vector<string> sty_;
///
std::vector<string> bst_;
}; };
#endif // QTEXINFO_H #endif // QTEXINFO_H

View File

@ -22,7 +22,7 @@
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qcombobox.h> #include <qcombobox.h>
#include <vector> using std::vector;
QTexinfoDialog::QTexinfoDialog(QTexinfo * form) QTexinfoDialog::QTexinfoDialog(QTexinfo * form)
@ -50,7 +50,7 @@ void QTexinfoDialog::closeEvent(QCloseEvent * e)
void QTexinfoDialog::rescanClicked() void QTexinfoDialog::rescanClicked()
{ {
// build new *Files.lst // build new *Files.lst
form_->controller().rescanStyles(); rescanTexStyles();
form_->updateStyles(); form_->updateStyles();
enableViewPB(); enableViewPB();
} }
@ -58,27 +58,9 @@ void QTexinfoDialog::rescanClicked()
void QTexinfoDialog::viewClicked() void QTexinfoDialog::viewClicked()
{ {
int const fitem = fileList->currentItem(); vector<string>::size_type const fitem = fileList->currentItem();
vector<string> const & data = form_->texdata_[form_->activeStyle];
string sel; form_->controller().viewFile(data[fitem]);
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);
}
} }

View File

@ -1,3 +1,10 @@
2003-06-20 Angus Leeming <leeming@lyx.org>
* FormBibtex.C (input, update): changes due to changed controller
interface.
* FormTexinfo.[Ch]: clean-up handling of TeX file databases.
2003-06-19 Alfredo Braunstein <abraunst@libero.it> 2003-06-19 Alfredo Braunstein <abraunst@libero.it>
* lyx_gui.C (start): call ::loadLyXFile instead * lyx_gui.C (start): call ::loadLyXFile instead

View File

@ -142,9 +142,10 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long ob_value)
} else if (ob == dialog_->button_rescan) { } else if (ob == dialog_->button_rescan) {
fl_clear_browser(dialog_->browser_styles); fl_clear_browser(dialog_->browser_styles);
controller().rescanBibStyles(); controller().rescanBibStyles();
string const str = vector<string> styles;
controller().getBibStyles(); controller().getBibStyles(styles);
fl_add_browser_line(dialog_->browser_styles, str.c_str()); fl_add_browser_line(dialog_->browser_styles,
getStringFromVector(styles, "\n").c_str());
} }
// with an empty database nothing makes sense ... // with an empty database nothing makes sense ...
@ -175,9 +176,12 @@ void FormBibtex::update()
} }
fl_set_input(dialog_->input_style, bibstyle.c_str()); fl_set_input(dialog_->input_style, bibstyle.c_str());
vector<string> styles;
controller().getBibStyles(styles);
fl_clear_browser(dialog_->browser_styles); fl_clear_browser(dialog_->browser_styles);
string const str = controller().getBibStyles(); fl_add_browser_line(dialog_->browser_styles,
fl_add_browser_line(dialog_->browser_styles, str.c_str()); getStringFromVector(styles, "\n").c_str());
} }
namespace { namespace {

View File

@ -10,8 +10,6 @@
*/ */
#include <config.h> #include <config.h>
#include <fstream>
#include "xformsBC.h" #include "xformsBC.h"
#include "FormTexinfo.h" #include "FormTexinfo.h"
@ -21,11 +19,10 @@
#include "xforms_helpers.h" #include "xforms_helpers.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/filetools.h"
#include "lyx_forms.h" #include "lyx_forms.h"
using std::vector;
typedef FormController<ControlTexinfo, FormView<FD_texinfo> > base_class; typedef FormController<ControlTexinfo, FormView<FD_texinfo> > base_class;
FormTexinfo::FormTexinfo(Dialog & parent) FormTexinfo::FormTexinfo(Dialog & parent)
@ -76,40 +73,26 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) {
if (ob == dialog_->button_texhash) { if (ob == dialog_->button_texhash) {
// makes only sense if the rights are set well for // makes only sense if the rights are set well for
// users (/var/lib/texmf/ls-R) // users (/var/lib/texmf/ls-R)
controller().runTexhash(); texhash();
// texhash requires a rescan and an update of the styles // texhash requires a rescan and an update of the styles
controller().rescanStyles(); rescanTexStyles();
updateStyles(activeStyle); updateStyles(activeStyle);
} else if (ob == dialog_->browser && ob_value == 2) { } else if (ob == dialog_->browser && ob_value == 2) {
// double click in browser: view selected file // double click in browser: view selected file
string selection = getString(dialog_->browser); ContentsType::size_type const sel = fl_get_browser(ob);
if (!fl_get_button(dialog_->check_fullpath)) { ContentsType const & data = texdata_[activeStyle];
// contents in browser has filenames without path if (sel >= 1 && sel <= data.size())
// reconstruct path from controller getContents controller().viewFile(data[sel-1]);
string const files = controller().getContents(activeStyle, true);
vector<string> const vec = getVectorFromString(files, "\n");
// find line in files vector // reset the browser so that the following single-click
vector<string>::const_iterator it = vec.begin(); // callback doesn't do anything
for (; it != vec.end(); ++it) {
if ((*it).find(selection) != string::npos) {
selection = *it;
break;
}
}
}
if (!selection.empty()) {
controller().viewFile(selection);
}
// reset the browser so that the following single-click callback doesn't do anything
fl_deselect_browser(dialog_->browser); fl_deselect_browser(dialog_->browser);
} else if (ob == dialog_->button_rescan) { } else if (ob == dialog_->button_rescan) {
// build new *Files.lst // build new *Files.lst
controller().rescanStyles(); rescanTexStyles();
updateStyles(activeStyle); updateStyles(activeStyle);
} else if (ob == dialog_->check_fullpath) { } 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) 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); bool const withFullPath = fl_get_button(dialog_->check_fullpath);
string const str = fl_clear_browser(dialog_->browser);
controller().getContents(whichStyle, withFullPath); ContentsType::const_iterator it = data.begin();
fl_add_browser_line(dialog_->browser, str.c_str()); 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; activeStyle = whichStyle;
} }

View File

@ -15,6 +15,7 @@
#include "FormDialogView.h" #include "FormDialogView.h"
#include "ControlTexinfo.h" #include "ControlTexinfo.h"
#include <map>
struct FD_texinfo; struct FD_texinfo;
@ -36,6 +37,10 @@ private:
void updateStyles(ControlTexinfo::texFileSuffix); void updateStyles(ControlTexinfo::texFileSuffix);
/// ///
ControlTexinfo::texFileSuffix activeStyle; ControlTexinfo::texFileSuffix activeStyle;
///
typedef std::vector<string> ContentsType;
std::map<ControlTexinfo::texFileSuffix, ContentsType> texdata_;
}; };
#endif // FORMTEXINFO_H #endif // FORMTEXINFO_H

View File

@ -1,3 +1,7 @@
2003-06-20 Angus Leeming <leeming@lyx.org>
* filetools.[Ch] (NormalizePath): also change /foo//bar ==> /foo/bar.
2003-06-18 Angus Leeming <leeming@lyx.org> 2003-06-18 Angus Leeming <leeming@lyx.org>
* many files: add the standard blurb, "This file is part of LyX" etc * many files: add the standard blurb, "This file is part of LyX" etc

View File

@ -37,6 +37,7 @@
#include "Lsstream.h" #include "Lsstream.h"
#include <boost/cregex.hpp>
#include <cctype> #include <cctype>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
@ -676,6 +677,7 @@ string const ExpandPath(string const & path)
// Normalize a path // Normalize a path
// Constracts path/../path // Constracts path/../path
// Can't handle "../../" or "/../" (Asger) // Can't handle "../../" or "/../" (Asger)
// Also converts paths like /foo//bar ==> /foo/bar
string const NormalizePath(string const & path) string const NormalizePath(string const & path)
{ {
string TempBase; string TempBase;
@ -688,6 +690,10 @@ string const NormalizePath(string const & path)
// Make implicit current directory explicit // Make implicit current directory explicit
RTemp = "./" +path; RTemp = "./" +path;
// Normalise paths like /foo//bar ==> /foo/bar
boost::RegEx regex("/{2,}");
RTemp = regex.Merge(RTemp, "/");
while (!RTemp.empty()) { while (!RTemp.empty()) {
// Split by next / // Split by next /
RTemp = split(RTemp, Temp, '/'); RTemp = split(RTemp, Temp, '/');

View File

@ -175,7 +175,9 @@ MakeRelPath(string const & abspath, string const & basepath);
/// Strip filename from path name /// Strip filename from path name
string const OnlyPath(string const & fname); 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); string const NormalizePath(string const & path);
/// Strips path from filename /// Strips path from filename