diff --git a/ChangeLog b/ChangeLog index 31aa95c7c5..79fccd09c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2000-11-08 Jean-Marc Lasgouttes + + * src/frontends/xforms/FormPreferences.C (ColoursLoadBrowser): use + lyxlex to parse the rgb.txt file. + + * src/lyxlex.[Ch]: + * src/lyxlex_pimpl.[Ch]: implement setCommentChar method, to + replace the default '#' comment character. + + * src/support/tempname.C: add "using" directive + * src/frontends/ButtonPolicies.C: ditto. + + * src/support/filetools.C (DirList): add an explicit cast to avoid + a compile error (probably not the right fix) + 2000-11-08 Lars Gullik Bjønnes * src/support/filetools.C (DirList): implement using system functions diff --git a/po/POTFILES.in b/po/POTFILES.in index d18943019e..cfcf301617 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -47,35 +47,35 @@ src/frontends/kde/refdlg.C src/frontends/kde/tocdlg.C src/frontends/kde/urldlg.C src/frontends/xforms/FormBase.h -src/frontends/xforms/form_citation.C src/frontends/xforms/FormCitation.C -src/frontends/xforms/form_copyright.C +src/frontends/xforms/form_citation.C src/frontends/xforms/FormCopyright.C -src/frontends/xforms/form_document.C +src/frontends/xforms/form_copyright.C src/frontends/xforms/FormDocument.C -src/frontends/xforms/form_error.C +src/frontends/xforms/form_document.C src/frontends/xforms/FormError.C -src/frontends/xforms/form_graphics.C +src/frontends/xforms/form_error.C src/frontends/xforms/FormGraphics.C -src/frontends/xforms/form_index.C +src/frontends/xforms/form_graphics.C src/frontends/xforms/FormIndex.C +src/frontends/xforms/form_index.C src/frontends/xforms/FormInset.h -src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormParagraph.C -src/frontends/xforms/form_preferences.C +src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormPreferences.C -src/frontends/xforms/form_print.C +src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPrint.C -src/frontends/xforms/form_ref.C +src/frontends/xforms/form_print.C src/frontends/xforms/FormRef.C -src/frontends/xforms/form_tabular.C +src/frontends/xforms/form_ref.C src/frontends/xforms/FormTabular.C -src/frontends/xforms/form_tabular_create.C +src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabularCreate.C -src/frontends/xforms/form_toc.C +src/frontends/xforms/form_tabular_create.C src/frontends/xforms/FormToc.C -src/frontends/xforms/form_url.C +src/frontends/xforms/form_toc.C src/frontends/xforms/FormUrl.C +src/frontends/xforms/form_url.C src/frontends/xforms/Menubar_pimpl.C src/gettext.h src/importer.C diff --git a/src/frontends/ButtonPolicies.C b/src/frontends/ButtonPolicies.C index 23812b42c1..3662facfeb 100644 --- a/src/frontends/ButtonPolicies.C +++ b/src/frontends/ButtonPolicies.C @@ -21,6 +21,7 @@ #include "ButtonPolicies.h" #include "debug.h" +using std::endl; /// Helper function static inline @@ -38,7 +39,7 @@ void nextState(ButtonPolicy::State & state, << in << " from state " << state - << std::endl; + << endl; } } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 0d5f1dc05d..768bf3047f 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -39,8 +39,6 @@ using SigC::slot; using std::find; using std::find_if; -using std::getline; -using std::istream; using std::pair; using std::sort; using std::vector; @@ -426,58 +424,47 @@ bool FormPreferences::inputColours( FL_OBJECT const * const ob ) bool FormPreferences::ColoursLoadBrowser(string const & filename) { LyXLex lex(0, 0); - + lex.setCommentChar('!'); + if (!lex.setFile(filename)) return false; - istream & is = lex.getStream(); - string line; - vector cols; vector names; - while (true) { - getline( is, line ); - if (line.empty() ) - break; + while (lex.next()) { + RGB col; + col.r = lex.GetInteger(); + lex.next(); + col.g = lex.GetInteger(); + lex.next(); + col.b = lex.GetInteger(); + lex.EatLine(); + string name = frontStrip(lex.GetString(), " \t"); - if (line[0] != '!') { - RGB col; - string name; + // remove redundant entries on the fly + bool add = cols.empty(); + if (!add) { + vector::const_iterator it = + find( cols.begin(), cols.end(), col ); + add = (it == cols.end()); + } + + if (add) { + name = lowercase( name ); + if (name == "gray0" ) name = "black"; + if (name == "gray100" ) name = "white"; - istringstream iss(line.c_str()); - iss >> col.r >> col.g >> col.b; - while (iss.good()) { - string next; - iss >> next; - if (!name.empty() ) name += " "; - name += next; + if (name == "black" || name == "white") { + cols.insert(cols.begin(), col); + names.insert(names.begin(), name); + } else { + cols.push_back(col); + names.push_back(name); } - - // remove redundant entries on the fly - bool add = cols.empty(); - if (!add) { - vector::const_iterator it = - find( cols.begin(), cols.end(), col ); - add = (it == cols.end()); - } - - if (add) { - name = lowercase( name ); - if (name == "gray0" ) name = "black"; - if (name == "gray100" ) name = "white"; - - if (name == "black" || name == "white") { - cols.insert(cols.begin(), col); - names.insert(names.begin(), name); - } else { - cols.push_back(col); - names.push_back(name); - } - } - } - } - + } + } + vector::iterator sit = names.begin(); for (vector::const_iterator iit = cols.begin(); iit != cols.end(); ++iit, ++sit) { diff --git a/src/lyxlex.C b/src/lyxlex.C index 4dc6bbfa51..4b93787423 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -104,6 +104,11 @@ void LyXLex::setStream(istream & i) } +void LyXLex::setCommentChar(char c) +{ + pimpl_->setCommentChar(c); +} + int LyXLex::lex() { return pimpl_->lex(); diff --git a/src/lyxlex.h b/src/lyxlex.h index f7113e9c9c..5b2f85e54e 100644 --- a/src/lyxlex.h +++ b/src/lyxlex.h @@ -58,7 +58,9 @@ public: std::istream & getStream(); /// Danger! Don't use it unless you know what you are doing. void setLineNo(int l); - + /// Change the character that begins a comment. Default is '#' + void setCommentChar(char c); + /// returns a lex code int lex(); diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index 2dcd2c054c..94a268f171 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -30,7 +30,7 @@ struct compare_tags { LyXLex::Pimpl::Pimpl(keyword_item * tab, int num) : is(&fb__), table(tab), no_items(num), - status(0), lineno(0) + status(0), lineno(0), commentChar('#') { verifyTable(); } @@ -130,6 +130,11 @@ void LyXLex::Pimpl::setStream(istream & i) lineno = 0; } +void LyXLex::Pimpl::setCommentChar(char c) +{ + commentChar = c; +} + bool LyXLex::Pimpl::next(bool esc /* = false */) { @@ -146,7 +151,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) while (is && !status) { is.get(cc); c = cc; - if (c == '#') { + if (c == commentChar) { // Read rest of line (fast :-) // That is not fast... (Lgb) #if 1 @@ -262,7 +267,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) continue; } - if (c == '#') { + if (c == commentChar) { // Read rest of line (fast :-) // That is still not fast... (Lgb) #if 1 diff --git a/src/lyxlex_pimpl.h b/src/lyxlex_pimpl.h index 0acc50974d..3090b5d6d9 100644 --- a/src/lyxlex_pimpl.h +++ b/src/lyxlex_pimpl.h @@ -37,6 +37,8 @@ struct LyXLex::Pimpl : public noncopyable { /// void setStream(std::istream & i); /// + void setCommentChar(char c); + /// bool next(bool esc = false); /// int search_kw(char const * const tag) const; @@ -66,6 +68,8 @@ struct LyXLex::Pimpl : public noncopyable { int lineno; /// string pushTok; + /// + char commentChar; private: /// void verifyTable(); diff --git a/src/support/filetools.C b/src/support/filetools.C index 5d084b3141..a85f4a1091 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -269,7 +269,13 @@ vector const DirList( string const & dir, string const & ext) // This is a non-error checking C/system implementation // of the above. string extension(ext); - if (extension[0] != '.') extension.insert(0u, 1u, '.'); + if (extension[0] != '.') + // If I do not use the explicit cast below, compaq cxx + // is not able to guess between + // insert(size_type, size_type, value_type) + // and + // insert(iterator, size_type, value_type) + extension.insert(string::size_type(0), 1u, '.'); vector dirlist; DIR * dirp = ::opendir(dir.c_str()); dirent * dire; diff --git a/src/support/tempname.C b/src/support/tempname.C index ee34988735..98adcd0a31 100644 --- a/src/support/tempname.C +++ b/src/support/tempname.C @@ -10,6 +10,8 @@ #include "debug.h" #include "filetools.h" +using std::endl; + extern string system_tempdir; string const lyx::tempName(string const & dir, string const & mask)