diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b8b9ab673..4ca32d60c3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -52,13 +52,14 @@ src/frontends/qt2/QGraphics.C src/frontends/qt2/QInclude.C src/frontends/qt2/QIndex.C src/frontends/qt2/QLog.C +src/frontends/qt2/QLPrintDialog.C src/frontends/qt2/QMathDialog.C +src/frontends/qt2/QMathMatrixDialog.C src/frontends/qt2/QMinipage.C src/frontends/qt2/QParagraph.C src/frontends/qt2/QPreamble.C src/frontends/qt2/QPreambleDialog.C src/frontends/qt2/QPrint.C -src/frontends/qt2/QPrintDialog.C src/frontends/qt2/QRef.C src/frontends/qt2/QSearch.C src/frontends/qt2/QSendto.C @@ -107,6 +108,7 @@ src/frontends/xforms/FormPrint.C src/frontends/xforms/FormRef.C src/frontends/xforms/FormSearch.C src/frontends/xforms/FormSendto.C +src/frontends/xforms/FormShowFile.C src/frontends/xforms/FormSpellchecker.C src/frontends/xforms/FormTabular.C src/frontends/xforms/FormTabularCreate.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index d2fbfa2224..a44049d532 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -638,7 +638,7 @@ void BufferView::Pimpl::savePosition(unsigned int i) if (i > 0) { ostringstream str; str << _("Saved bookmark") << ' ' << i; - owner_->message(str.str().c_str()); + owner_->message(STRCONV(str.str())); } } @@ -670,7 +670,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) if (i > 0) { ostringstream str; str << _("Moved to bookmark") << ' ' << i; - owner_->message(str.str().c_str()); + owner_->message(STRCONV(str.str())); } } @@ -879,18 +879,18 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen) ostringstream s1; s1 << _("Inserting document") << ' ' << disp_fn << " ..."; - owner_->message(s1.str().c_str()); + owner_->message(STRCONV(s1.str())); bool const res = bv_->insertLyXFile(filename); if (res) { ostringstream str; str << _("Document") << ' ' << disp_fn << ' ' << _("inserted."); - owner_->message(str.str().c_str()); + owner_->message(STRCONV(str.str())); } else { ostringstream str; str << _("Could not insert document") << ' ' << disp_fn; - owner_->message(str.str().c_str()); + owner_->message(STRCONV(str.str())); } } @@ -908,7 +908,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev) // e.g. Qt mouse press when no buffer if (!buffer_) return false; - + LyXTextClass const & tclass = buffer_->params.getLyXTextClass(); switch (ev.action) { @@ -1126,7 +1126,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev) inset->setLoadingBuffer(bv_->buffer(), false); updateInset(inset, true); } - + } break; @@ -1175,7 +1175,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev) { InsetBibtex * inset = static_cast(getInsetByCode(Inset::BIBTEX_CODE)); - if (inset) + if (inset) inset->setOptions(ev.argument); } break; diff --git a/src/ChangeLog b/src/ChangeLog index cad0be4c0c..29fe937a77 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,59 @@ 2002-11-04 Lars Gullik Bjønnes + * vc-backend.C: STRCONV + (scanMaster): ditto + + * text2.C (setCounter): STRCONV + + * paragraph.C (asString): STRCONV + + * lyxlength.C (asString): STRCONV + (asLatexString): ditto + + * lyxgluelength.C (asString): STRCONV + (asLatexString): ditto + + * lyxfunc.C (dispatch): STRCONV + (open): ditto + + * lyxfont.C (stateText): STRCONV + + * importer.C (Import): STRCONV + + * counters.C (labelItem): STRCONV + (numberLabel): ditto + (numberLabel): remove unused ostringstream o + + * chset.C: STRCONV + (loadFile): ditto + + * bufferview_funcs.C (currentState): STRCONV + + * buffer.C (readFile): STRCONV + (asciiParagraph): ditto + (makeLaTeXFile): ditto + + * Spacing.C (writeEnvirBegin): STRCONV + + * LaTeXFeatures.C (getLanguages): STRCONV + (getPackages): ditto + (getMacros): ditto + (getBabelOptions): ditto + (getTClassPreamble): ditto + (getLyXSGMLEntities): ditto + (getIncludedFiles): ditto + + * LaTeX.C: STRCONV + (run): ditto + (scanAuxFile): ditto + (deplog): ditto + + * LString.h: add the STRCONV macros + + * BufferView_pimpl.C (savePosition): STRCONV + (restorePosition): ditto + (MenuInsertLyXFile): ditto + * vc-backend.C (scanMaster): change from submatch[...] to submatch.str(...) diff --git a/src/LString.h b/src/LString.h index ac5c6b878a..1e135594b3 100644 --- a/src/LString.h +++ b/src/LString.h @@ -19,9 +19,12 @@ #endif #ifndef USE_INCLUDED_STRING + #include using std::string; +#define STRCONV(STR) STR #else + #ifdef __STRING__ #error The header has been included before LString.h #else @@ -30,5 +33,7 @@ using std::string; #include "support/lyxstring.h" // using lyx::string; typedef lyxstring string; +#define STRCONV(STR) STR.c_str() #endif + #endif diff --git a/src/LaTeX.C b/src/LaTeX.C index 9324e66f23..a4d8ab4f50 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -47,7 +47,12 @@ using std::vector; using std::set; using boost::regex; using boost::regex_match; + +#ifndef USE_INCLUDED_STRING using boost::smatch; +#else +using boost::cmatch; +#endif // TODO: in no particular order // - get rid of the extern BufferList and the call to @@ -104,18 +109,18 @@ void LaTeX::deleteFilesOnError() const // but the reason for the error might be in a generated file... - string ofname = OnlyFilename(file); + string const ofname = OnlyFilename(file); // bibtex file - string bbl = ChangeExtension(ofname, ".bbl"); + string const bbl = ChangeExtension(ofname, ".bbl"); lyx::unlink(bbl); // makeindex file - string ind = ChangeExtension(ofname, ".ind"); + string const ind = ChangeExtension(ofname, ".ind"); lyx::unlink(ind); // Also remove the aux file - string aux = ChangeExtension(ofname, ".aux"); + string const aux = ChangeExtension(ofname, ".aux"); lyx::unlink(aux); } @@ -130,7 +135,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) int scanres = NO_ERRORS; unsigned int count = 0; // number of times run num_errors = 0; // just to make sure. - const unsigned int MAX_RUN = 6; + unsigned int const MAX_RUN = 6; DepTable head; // empty head bool rerun = false; // rerun requested @@ -198,7 +203,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; str << _("LaTeX run number") << ' ' << count; - lfun->dispatch(FuncRequest(LFUN_MESSAGE, str.str().c_str())); + lfun->dispatch(FuncRequest(LFUN_MESSAGE, STRCONV(str.str()))); } this->operator()(); @@ -284,7 +289,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) ostringstream str; str << _("LaTeX run number") << ' ' << count; // check lyxstring string stream and gcc 3.1 before fixing - lfun->dispatch(FuncRequest(LFUN_MESSAGE, str.str().c_str())); + lfun->dispatch(FuncRequest(LFUN_MESSAGE, STRCONV(str.str()))); } this->operator()(); @@ -340,7 +345,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; str << _("LaTeX run number") << ' ' << count; - lfun->dispatch(FuncRequest(LFUN_MESSAGE, str.str().c_str())); + lfun->dispatch(FuncRequest(LFUN_MESSAGE, STRCONV(str.str()))); } this->operator()(); @@ -432,9 +437,13 @@ void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info) while (getline(ifs, token)) { token = rtrim(token, "\r"); +#ifndef USE_INCLUDED_STRING smatch sub; - if (regex_match(token, sub, reg1)) { - string data = sub.str(1); +#else + cmatch sub; +#endif + if (regex_match(STRCONV(token), sub, reg1)) { + string data = STRCONV(sub.str(1)); while (!data.empty()) { string citation; data = split(data, citation, ','); @@ -442,8 +451,8 @@ void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info) << citation << endl; aux_info.citations.insert(citation); } - } else if (regex_match(token, sub, reg2)) { - string data = sub.str(1); + } else if (regex_match(STRCONV(token), sub, reg2)) { + string data = sub.STRCONV(str(1)); // data is now all the bib files separated by ',' // get them one by one and pass them to the helper while (!data.empty()) { @@ -454,16 +463,16 @@ void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info) << database << "'" << endl; aux_info.databases.insert(database); } - } else if (regex_match(token, sub, reg3)) { - string style = sub.str(1); + } else if (regex_match(STRCONV(token), sub, reg3)) { + string style = STRCONV(sub.str(1)); // token is now the style file // pass it to the helper style = ChangeExtension(style, "bst"); lyxerr[Debug::LATEX] << "Bibtex style: `" << style << "'" << endl; aux_info.styles.insert(style); - } else if (regex_match(token, sub, reg4)) { - string file2 = sub.str(1); + } else if (regex_match(STRCONV(token), sub, reg4)) { + string const file2 = STRCONV(sub.str(1)); scanAuxFile(file2, aux_info); } } @@ -683,17 +692,21 @@ void LaTeX::deplog(DepTable & head) token = rtrim(token, "\r"); if (token.empty()) continue; +#ifndef USE_INCLUDED_STRING smatch sub; - if (regex_match(token, sub, reg1)) { - foundfile = sub.str(1); - } else if (regex_match(token, sub, reg2)) { - foundfile = sub.str(1); - } else if (regex_match(token, sub, reg3)) { - foundfile = sub.str(1); - } else if (regex_match(token, sub, reg4)) { - foundfile = sub.str(1); - } else if (regex_match(token, sub, reg5)) { - foundfile = sub.str(1); +#else + cmatch sub; +#endif + if (regex_match(STRCONV(token), sub, reg1)) { + foundfile = STRCONV(sub.str(1)); + } else if (regex_match(STRCONV(token), sub, reg2)) { + foundfile = STRCONV(sub.str(1)); + } else if (regex_match(STRCONV(token), sub, reg3)) { + foundfile = STRCONV(sub.str(1)); + } else if (regex_match(STRCONV(token), sub, reg4)) { + foundfile = STRCONV(sub.str(1)); + } else if (regex_match(STRCONV(token), sub, reg5)) { + foundfile = STRCONV(sub.str(1)); } else { continue; } @@ -726,7 +739,7 @@ void LaTeX::deplog(DepTable & head) // (2) foundfile is in the tmpdir // insert it into head else if (FileInfo(OnlyFilename(foundfile)).exist()) { - if (regex_match(foundfile, unwanted)) { + if (regex_match(STRCONV(foundfile), unwanted)) { lyxerr[Debug::DEPEND] << "We don't want " << OnlyFilename(foundfile) diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index d9d53774a9..c6e65beb99 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -145,7 +145,7 @@ string LaTeXFeatures::getLanguages() const ++cit) languages << (*cit)->babel() << ','; - return languages.str().c_str(); + return STRCONV(languages.str()); } @@ -289,7 +289,7 @@ string const LaTeXFeatures::getPackages() const packages << externalPreambles; - return packages.str().c_str(); + return STRCONV(packages.str()); } @@ -346,7 +346,7 @@ string const LaTeXFeatures::getMacros() const // floats getFloatDefinitions(macros); - return macros.str().c_str(); + return STRCONV(macros.str()); } @@ -361,7 +361,7 @@ string const LaTeXFeatures::getBabelOptions() const if (!params.language->latex_options().empty()) tmp << params.language->latex_options() << '\n'; - return tmp.str().c_str(); + return STRCONV(tmp.str()); } @@ -379,7 +379,7 @@ string const LaTeXFeatures::getTClassPreamble() const tcpreamble << tclass[*cit]->preamble(); } - return tcpreamble.str().c_str(); + return STRCONV(tcpreamble.str()); } @@ -392,7 +392,7 @@ string const LaTeXFeatures::getLyXSGMLEntities() const entities << "" << '\n'; } - return entities.str().c_str(); + return STRCONV(entities.str()); } @@ -408,7 +408,7 @@ string const LaTeXFeatures::getIncludedFiles(string const & fname) const << (IsSGMLFilename(fi->second) ? " SYSTEM \"" : " \"") << MakeRelPath(fi->second, basename) << "\">"; - return sgmlpreamble.str().c_str(); + return STRCONV(sgmlpreamble.str()); } diff --git a/src/Spacing.C b/src/Spacing.C index 1bbb945f9f..26ef6edf13 100644 --- a/src/Spacing.C +++ b/src/Spacing.C @@ -92,7 +92,7 @@ string const Spacing::writeEnvirBegin() const ostringstream ost; ost << "\\begin{spacing}{" << getValue() << "}"; - return ost.str().c_str(); + return STRCONV(ost.str()); } } return string(); diff --git a/src/buffer.C b/src/buffer.C index 1b92711669..fba66f3317 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1180,7 +1180,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename, Paragraph * par) "running the conversion script.")); return false; } - istringstream is(ret.second); + istringstream is(STRCONV(ret.second)); LyXLex tmplex(0, 0); tmplex.setStream(is); return readFile(tmplex, string()); @@ -1588,7 +1588,7 @@ string const Buffer::asciiParagraph(Paragraph const & par, } } buffer << word; - return buffer.str().c_str(); + return STRCONV(buffer.str()); } @@ -1775,7 +1775,7 @@ void Buffer::makeLaTeXFile(ostream & os, options << params.options << ','; } - string strOptions(options.str().c_str()); + string strOptions(STRCONV(options.str())); if (!strOptions.empty()) { strOptions = rtrim(strOptions, ","); os << '[' << strOptions << ']'; @@ -2055,7 +2055,7 @@ void Buffer::makeLaTeXFile(ostream & os, if (!lyxrc.language_global_options && tmp == "\\usepackage{babel}") tmp = string("\\usepackage[") + - language_options.str().c_str() + + STRCONV(language_options.str()) + "]{babel}"; preamble += tmp + "\n"; preamble += features.getBabelOptions(); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 448f177884..2cea223115 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -194,7 +194,7 @@ string const currentState(BufferView * bv) #ifdef DEVEL_VERSION state << _(", Paragraph: ") << text->cursor.par()->id(); #endif - return state.str().c_str(); + return STRCONV(state.str()); } diff --git a/src/chset.C b/src/chset.C index d0258c51e8..20e28319c5 100644 --- a/src/chset.C +++ b/src/chset.C @@ -20,7 +20,13 @@ using std::make_pair; using std::endl; using boost::regex; using boost::regex_match; + +#ifndef USE_INCLUDED_STRING using boost::smatch; +#else +using boost::cmatch; +#endif + bool CharacterSet::loadFile(string const & fname) @@ -50,10 +56,14 @@ bool CharacterSet::loadFile(string const & fname) // without the use of a keyword table. regex reg("^([12][0-9][0-9])[ \t]+\"([^ ]+)\".*"); while (getline(ifs, line)) { +#ifndef USE_INCLUDED_STRING smatch sub; - if (regex_match(line, sub, reg)) { - int const n = lyx::atoi(sub.str(1)); - string const str = sub.str(2); +#else + cmatch sub; +#endif + if (regex_match(STRCONV(line), sub, reg)) { + int const n = lyx::atoi(STRCONV(sub.str(1))); + string const str = STRCONV(sub.str(2)); if (lyxerr.debugging(Debug::KBMAP)) lyxerr << "Chardef: " << n << " to [" << str << "]" << endl; diff --git a/src/counters.C b/src/counters.C index 8203a98cea..cc5d3328ee 100644 --- a/src/counters.C +++ b/src/counters.C @@ -278,7 +278,8 @@ string Counters::labelItem(string const & ctr, } s << o.str(); } - return s.str(); + + return STRCONV(s.str()); } @@ -287,7 +288,8 @@ string Counters::numberLabel(string const & ctr, string const & langtype, int head) { - ostringstream s, o; + ostringstream s; + if (numbertype == "sectioning" || numbertype == "appendix") { if (ctr == "chapter" && head == 0) { s << labelItem("chapter", numbertype, langtype, true); @@ -340,5 +342,6 @@ string Counters::numberLabel(string const & ctr, s << eiv.str(); } } - return s.str(); + + return STRCONV(s.str()); } diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index f34d9b88f1..0b094d62ad 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2002-11-04 Lars Gullik Bjønnes + + * lyx_gui.h: do not use std:: on string + 2002-11-04 Lars Gullik Bjønnes * lyx_gui.h: reindent a bit, change signeture on lyx_gui::start. diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index f540ce3569..193a1067bc 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,5 +1,10 @@ 2002-11-04 Lars Gullik Bjønnes + * biblio.C (regexSearch): STRCONV + (getInfo): ditto + + * ControlAboutlyx.C (getVersion): STRCONV + * ControlMath.C: include config.h 2002-10-31 John Levon diff --git a/src/frontends/controllers/ControlAboutlyx.C b/src/frontends/controllers/ControlAboutlyx.C index 0a2fdf2051..6531654fb9 100644 --- a/src/frontends/controllers/ControlAboutlyx.C +++ b/src/frontends/controllers/ControlAboutlyx.C @@ -91,5 +91,5 @@ string const ControlAboutlyx::getVersion() const << _("User directory: ") << MakeDisplayPath(user_lyxdir); - return ss.str().c_str(); + return STRCONV(ss.str()); } diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index 5c2371a5bc..60c61ad849 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -118,7 +118,7 @@ regexSearch(InfoMap const & theMap, vector::const_iterator start, Direction dir) { - boost::regex reg(expr); + boost::regex reg(STRCONV(expr)); for (vector::const_iterator it = start; // End condition is direction-dependent. @@ -131,7 +131,7 @@ regexSearch(InfoMap const & theMap, if (info != theMap.end()) data += " " + info->second; - if (boost::regex_match(data, reg)) { + if (boost::regex_match(STRCONV(data), reg)) { return it; } } @@ -336,7 +336,7 @@ string const getInfo(InfoMap const & map, string const & key) if (!year.empty()) result << ", " << year; - string const result_str = rtrim(result.str().c_str()); + string const result_str = rtrim(STRCONV(result.str())); if (!result_str.empty()) return result_str; diff --git a/src/frontends/gnome/GAbout.C b/src/frontends/gnome/GAbout.C index efecce720b..1df4a355fc 100644 --- a/src/frontends/gnome/GAbout.C +++ b/src/frontends/gnome/GAbout.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Michael Koziarski + * \author Michael Koziarski * * Full author contact details are available in file CREDITS */ @@ -59,21 +59,21 @@ void GAbout::update() cr += controller().getDisclaimer(); copyright()->get_buffer()->set_text(cr); - + version()->set_text(controller().getVersion()); stringstream in; controller().getCredits(in); - istringstream ss(in.str().c_str()); + istringstream ss(in.str()); string s; string out; Gtk::TextIter e; while (getline(ss, s)) { - + if (prefixIs(s, "@b")) out += s.substr(2); else if (prefixIs(s, "@i")) @@ -88,19 +88,19 @@ void GAbout::update() -Gtk::Button * GAbout::close_btn() const +Gtk::Button * GAbout::close_btn() const { - return getWidget("r_close_btn"); + return getWidget("r_close_btn"); } -Gtk::Label * GAbout::version() const +Gtk::Label * GAbout::version() const { - return getWidget("r_version"); + return getWidget("r_version"); } -Gtk::TextView * GAbout::credits() const +Gtk::TextView * GAbout::credits() const { - return getWidget("r_credits"); + return getWidget("r_credits"); } -Gtk::TextView * GAbout::copyright() const +Gtk::TextView * GAbout::copyright() const { - return getWidget("r_copyright"); + return getWidget("r_copyright"); } diff --git a/src/frontends/lyx_gui.h b/src/frontends/lyx_gui.h index 0ebcebbb09..5885a16ae1 100644 --- a/src/frontends/lyx_gui.h +++ b/src/frontends/lyx_gui.h @@ -14,6 +14,7 @@ #include "LColor.h" #include "LString.h" + #include class Dialogs; @@ -36,7 +37,7 @@ void parse_lyxrc(); * Start the main event loop, after executing the given * batch commands, and loading the given documents */ -void start(string const & batch, std::vector const & files); +void start(string const & batch, std::vector const & files); /** * quit running LyX @@ -70,6 +71,7 @@ void set_read_callback(int fd, LyXComm * comm); /** * remove a I/O read callback + * @param fd file descriptor */ void remove_read_callback(int fd); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 5b20ee25e5..dbb55883d6 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,5 +1,7 @@ 2002-11-04 Lars Gullik Bjønnes + * QAbout.C (build_dialog): do not use str().c_str() when not needed. + * qttableview.C: include config.h * lyx_gui.C: move includes around a bit diff --git a/src/frontends/qt2/QAbout.C b/src/frontends/qt2/QAbout.C index 8c7dfd943d..c04d349924 100644 --- a/src/frontends/qt2/QAbout.C +++ b/src/frontends/qt2/QAbout.C @@ -64,7 +64,7 @@ void QAbout::build_dialog() ostringstream in; controller().getCredits(in); - istringstream ss(in.str().c_str()); + istringstream ss(in.str()); string s; ostringstream out; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 7548a960c4..ae6a09912a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,5 +1,13 @@ 2002-11-04 Lars Gullik Bjønnes + * lyx_gui.C (hexname): STRCONV + + * FormPreferences.C (X11hexname): STRCONV + + * FormMathsMatrix.C (apply): STRCONV + + * FormMathsDelim.C (apply): STRCONV + * lyx_gui.C (start): adjust signature (start): exchange magic integeres for defined values. diff --git a/src/frontends/xforms/FormAboutlyx.C b/src/frontends/xforms/FormAboutlyx.C index dedf4b58b3..bcd6e047fd 100644 --- a/src/frontends/xforms/FormAboutlyx.C +++ b/src/frontends/xforms/FormAboutlyx.C @@ -26,8 +26,6 @@ #include FORMS_H_LOCATION -using std::string; - typedef FormCB > base_class; @@ -50,7 +48,7 @@ void FormAboutlyx::build() fl_add_browser_line(version_->browser_version, vs.str().c_str()); // create credits tab - credits_.reset(build_aboutlyx_credits(this)); + credits_.reset(build_aboutlyx_credits(this)); ostringstream crs; controller().getCredits(crs); @@ -73,7 +71,7 @@ void FormAboutlyx::build() version_->form); fl_addto_tabfolder(dialog_->tabfolder, _("Credits"), credits_->form); - fl_addto_tabfolder(dialog_->tabfolder, _("License"), + fl_addto_tabfolder(dialog_->tabfolder, _("License"), license_->form); // work-around xforms bug re update of folder->x, folder->y coords. diff --git a/src/frontends/xforms/FormMathsDelim.C b/src/frontends/xforms/FormMathsDelim.C index 8e8a5c5273..5a5542a444 100644 --- a/src/frontends/xforms/FormMathsDelim.C +++ b/src/frontends/xforms/FormMathsDelim.C @@ -6,7 +6,7 @@ * \author Alejandro Aguilar Sierra * \author Pablo De Napoli * \author John Levon - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -103,7 +103,7 @@ void FormMathsDelim::apply() ostringstream os; os << delim_values[left] << ' ' << delim_values[right]; - lv_.dispatch(FuncRequest(LFUN_MATH_DELIM, os.str().c_str())); + lv_.dispatch(FuncRequest(LFUN_MATH_DELIM, STRCONV(os.str()))); } @@ -136,13 +136,13 @@ bool FormMathsDelim::input(FL_OBJECT *, long) } } - // Re-initialize button_pix to solid blue + // Re-initialize button_pix to solid blue // (not elegant but works, MV 24.5.2002) fl_free_pixmap_pixmap(dialog_->button_pix); fl_set_pixmap_data(dialog_->button_pix, const_cast(delim1)); Pixmap p1; fl_get_pixmap_pixmap(dialog_->button_pix, &p1, 0); - + fl_draw_bmtable_item(dialog_->bmtable, left, p1, 0, 0); fl_draw_bmtable_item(dialog_->bmtable, right, p1, 16, 0); fl_redraw_object(dialog_->button_pix); diff --git a/src/frontends/xforms/FormMathsMatrix.C b/src/frontends/xforms/FormMathsMatrix.C index 7f8f4cd290..db68165677 100644 --- a/src/frontends/xforms/FormMathsMatrix.C +++ b/src/frontends/xforms/FormMathsMatrix.C @@ -6,7 +6,7 @@ * \author Alejandro Aguilar Sierra * \author Pablo De Napoli * \author John Levon - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -106,7 +106,7 @@ void FormMathsMatrix::apply() ostringstream os; os << nx << ' ' << ny << ' ' << c << ' ' << sh; - lv_.dispatch(FuncRequest(LFUN_INSERT_MATRIX, os.str().c_str())); + lv_.dispatch(FuncRequest(LFUN_INSERT_MATRIX, STRCONV(os.str()))); } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 0bf440b5f0..3df959142a 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -911,7 +911,7 @@ string const FormPreferences::Colors::X11hexname(RGBColor const & col) const << setw(2) << col.g << setw(2) << col.b; - return ostr.str().c_str(); + return STRCONV(ostr.str()); } @@ -1871,7 +1871,7 @@ void FormPreferences::LnFmisc::build() setPrehandler(dialog_->check_dialogs_iconify_with_main); setPrehandler(dialog_->check_preview_latex); setPrehandler(dialog_->counter_wm_jump); - + fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display")); } diff --git a/src/frontends/xforms/FormVCLog.C b/src/frontends/xforms/FormVCLog.C index 948afbaf45..2c6be8eeb7 100644 --- a/src/frontends/xforms/FormVCLog.C +++ b/src/frontends/xforms/FormVCLog.C @@ -35,6 +35,5 @@ void FormVCLog::update() ostringstream ss; controller().getVCLogFile(ss); - fl_add_browser_line(dialog_->browser, - ss.str().c_str()); + fl_add_browser_line(dialog_->browser, ss.str().c_str()); } diff --git a/src/frontends/xforms/lyx_gui.C b/src/frontends/xforms/lyx_gui.C index 42818e8c10..7713c52822 100644 --- a/src/frontends/xforms/lyx_gui.C +++ b/src/frontends/xforms/lyx_gui.C @@ -249,7 +249,7 @@ void lyx_gui::start(string const & batch, vector const & files) int const geometryBitmask = XParseGeometry(geometry, - &xpos, &ypos, &width, &height); + &xpos, &ypos, &width, &height); // if width is not set by geometry, check it against monitor width if (!(geometryBitmask & WidthValue)) { @@ -353,7 +353,7 @@ string const lyx_gui::hexname(LColor::color col) << setw(2) << (xcol.green / 256) << setw(2) << (xcol.blue / 256); - return os.str().c_str(); + return STRCONV(os.str()); } diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index d1a8a30029..390680e43d 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,5 +1,11 @@ 2002-11-04 Lars Gullik Bjønnes + * PreviewLoader.C (IncrementedFileName): STRCONV + (startLoading): ditto + + * GraphicsConverter.C (Impl): STRCONV + (move_file): ditto + * GraphicsTypes.C: include config.h 2002-10-25 Angus Leeming diff --git a/src/graphics/GraphicsConverter.C b/src/graphics/GraphicsConverter.C index 2ca7e1cacf..c8fda70f56 100644 --- a/src/graphics/GraphicsConverter.C +++ b/src/graphics/GraphicsConverter.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -161,7 +161,7 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base, lyxerr[Debug::GRAPHICS] << "\tConversion script:" << "\n--------------------------------------\n" - << script.str().c_str() + << STRCONV(script.str()) << "\n--------------------------------------\n"; // Output the script to file. @@ -173,7 +173,7 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base, if (!fs.good()) return; - fs << script.str().c_str(); + fs << STRCONV(script.str()); fs.close(); // The command needed to run the conversion process @@ -251,7 +251,7 @@ string const move_file(string const & from_file, string const & to_file) << "\t'rm' -f ${fromfile}\n" << "fi\n"; - return command.str().c_str(); + return STRCONV(command.str()); } diff --git a/src/graphics/GraphicsImageXPM.C b/src/graphics/GraphicsImageXPM.C index be5c4b3b81..274803ea49 100644 --- a/src/graphics/GraphicsImageXPM.C +++ b/src/graphics/GraphicsImageXPM.C @@ -3,8 +3,8 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Baruch Even - * \author Angus Leeming + * \author Baruch Even + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index b8533eba81..20f57bf299 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -258,7 +258,7 @@ struct IncrementedFileName { { ostringstream os; os << base_ << counter_++ << "." << to_format_; - string const file = os.str().c_str(); + string const file = STRCONV(os.str()); return make_pair(snippet, file); } @@ -281,7 +281,7 @@ InProgress::InProgress(string const & filename_base, PendingSnippets::const_iterator pend = pending.end(); BitmapFile::iterator sit = snippets.begin(); - std::transform(pit, pend, sit, + std::transform(pit, pend, sit, IncrementedFileName(to_format, filename_base)); } @@ -478,7 +478,7 @@ void PreviewLoader::Impl::startLoading() cs << pconverter_->command << " " << latexfile << " " << int(font_scaling_factor_) << " " << pconverter_->to; - string const command = "sh " + LibScriptSearch(cs.str().c_str()); + string const command = "sh " + LibScriptSearch(STRCONV(cs.str())); // Initiate the conversion from LaTeX to bitmap images files. Forkedcall::SignalTypePtr convert_ptr(new Forkedcall::SignalType); diff --git a/src/importer.C b/src/importer.C index f70b2295ac..03eb4002b9 100644 --- a/src/importer.C +++ b/src/importer.C @@ -40,7 +40,7 @@ bool Importer::Import(LyXView * lv, string const & filename, string const displaypath = MakeDisplayPath(filename); ostringstream s1; s1 << _("Importing") << ' ' << displaypath << "..."; - lv->message(s1.str().c_str()); + lv->message(STRCONV(s1.str())); string const lyxfile = ChangeExtension(filename, ".lyx"); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 14f583a99d..95dd6517fd 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,13 @@ 2002-11-04 Lars Gullik Bjønnes + * insettabular.C (copySelection): STRCONV + + * insetinclude.C (uniqueID): STRCONV + (latexString): ditto + + * insetgraphics.C: put VersionNumber inside anon namespace + (createLatexOptions): STRCONV + * insetcommandparams.C: include config.h 2002-10-31 Rob Lahaye diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index dd92daaba0..cbcd6c8d20 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -100,12 +100,13 @@ extern string system_tempdir; using std::ostream; using std::endl; + +namespace { + /////////////////////////////////////////////////////////////////////////// int const VersionNumber = 1; /////////////////////////////////////////////////////////////////////////// -namespace { - // This function is a utility function // ... that should be with ChangeExtension ... inline @@ -114,10 +115,6 @@ string const RemoveExtension(string const & filename) return ChangeExtension(filename, string()); } -} // namespace anon - - -namespace { string const uniqueID() { @@ -127,7 +124,30 @@ string const uniqueID() ost << "graph" << ++seed; // Needed if we use lyxstring. - return ost.str().c_str(); + return STRCONV(ost.str()); +} + + +string findTargetFormat(string const & suffix) +{ + // lyxrc.pdf_mode means: + // Are we creating a PDF or a PS file? + // (Should actually mean, are we using latex or pdflatex). + if (lyxrc.pdf_mode) { + lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode\n"; + if (contains(suffix, "ps") || suffix == "pdf") + return "pdf"; + else if (suffix == "jpg") // pdflatex can use jpeg + return suffix; + else + return "png"; // and also png + } + // If it's postscript, we always do eps. + lyxerr[Debug::GRAPHICS] << "findTargetFormat: PostScript mode\n"; + if (suffix != "ps") // any other than ps + return "eps"; // is changed to eps + else + return suffix; // let ps untouched } } // namespace anon @@ -468,7 +488,6 @@ string const InsetGraphics::createLatexOptions() const options << " draft,\n"; if (params().clip) options << " clip,\n"; - if (!lyx::float_equal(params().scale, 0.0, 0.05)) { if (!lyx::float_equal(params().scale, 100.0, 0.05)) options << " scale=" << params().scale / 100.0 @@ -479,7 +498,7 @@ string const InsetGraphics::createLatexOptions() const if (!params().height.zero()) options << " height=" << params().height.asLatexString() << ",\n"; if (params().keepAspectRatio) - options << " keepaspectratio,\n"; + options << " keepaspectratio,\n"; } // Make sure rotation angle is not very close to zero; @@ -501,37 +520,13 @@ string const InsetGraphics::createLatexOptions() const if (!params().special.empty()) options << params().special << ",\n"; - string opts = options.str().c_str(); - return opts.substr(0,opts.size()-2); // delete last ",\n" + string opts = STRCONV(options.str()); + // delete last ",\n" + return opts.substr(0, opts.size() - 2); } -namespace { -string findTargetFormat(string const & suffix) -{ - // lyxrc.pdf_mode means: - // Are we creating a PDF or a PS file? - // (Should actually mean, are we using latex or pdflatex). - if (lyxrc.pdf_mode) { - lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode\n"; - if (contains(suffix, "ps") || suffix == "pdf") - return "pdf"; - else if (suffix == "jpg") // pdflatex can use jpeg - return suffix; - else - return "png"; // and also png - } - // If it's postscript, we always do eps. - lyxerr[Debug::GRAPHICS] << "findTargetFormat: PostScript mode\n"; - if (suffix != "ps") // any other than ps - return "eps"; // is changed to eps - else - return suffix; // let ps untouched -} -} // Anon. namespace - - -string const InsetGraphics::prepareFile(Buffer const *buf) const +string const InsetGraphics::prepareFile(Buffer const * buf) const { // LaTeX can cope if the graphics file doesn't exist, so just return the // filename. diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 3854c95098..4aea2aee1b 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -86,7 +86,7 @@ string const uniqueID() ost << "file" << ++seed; // Needed if we use lyxstring. - return ost.str().c_str(); + return STRCONV(ost.str()); } } // namespace anon @@ -554,7 +554,7 @@ string const InsetInclude::PreviewImpl::latexString() const ostringstream os; parent().latex(view()->buffer(), os, false, false); - return os.str().c_str(); + return STRCONV(os.str()); } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index fb01fa3015..79a3fef505 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2529,7 +2529,7 @@ bool InsetTabular::copySelection(BufferView * bv) ostringstream sstr; paste_tabular->ascii(bv->buffer(), sstr, (int)parOwner()->params().depth(), true, '\t'); - bv->stuffClipboard(sstr.str().c_str()); + bv->stuffClipboard(STRCONV(sstr.str())); return true; } diff --git a/src/lyx_main.C b/src/lyx_main.C index 3c50f3e0ac..61efafa627 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -91,7 +91,7 @@ LyX::LyX(int & argc, char * argv[]) // if this should not be in this file, please also remove // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye. grfx::setDisplayTranslator(); - + if (want_gui) { lyx_gui::parse_init(argc, argv); } diff --git a/src/lyxfont.C b/src/lyxfont.C index 7a04c7177e..5a11937436 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -539,7 +539,7 @@ string const LyXFont::stateText(BufferParams * params) const if (number() != OFF) ost << _(" Number ") << _(GUIMiscNames[number()]); - string buf(ost.str().c_str()); + string buf(STRCONV(ost.str())); buf = rtrim(buf, ", "); return buf; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 85eaa63d5c..f4208f820c 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -160,7 +160,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, << keysym->getSymbolName() << endl; } - + // Do nothing if we have nothing (JMarc) if (!keysym->isOK()) { lyxerr[Debug::KEY] << "Empty kbd action (probably composing)" @@ -948,10 +948,10 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) ostringstream s1; s1 << _("Saving document") << ' ' << MakeDisplayPath(owner->buffer()->fileName() + "..."); - owner->message(s1.str().c_str()); + owner->message(STRCONV(s1.str())); MenuWrite(view(), owner->buffer()); s1 << _(" done."); - owner->message(s1.str().c_str()); + owner->message(STRCONV(s1.str())); } else WriteAs(view(), owner->buffer()); break; @@ -1106,7 +1106,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) ostringstream str; str << _("Opening help file") << ' ' << MakeDisplayPath(fname) << "..."; - owner->message(str.str().c_str()); + owner->message(STRCONV(str.str())); view()->buffer(bufferlist.loadLyXFile(fname, false)); owner->allowInput(); break; @@ -1675,19 +1675,17 @@ void LyXFunc::open(string const & fname) ostringstream str; str << _("Opening document") << ' ' << disp_fn << "..."; - owner->message(str.str().c_str()); + owner->message(STRCONV(str.str())); Buffer * openbuf = bufferlist.loadLyXFile(filename); + ostringstream str2; if (openbuf) { view()->buffer(openbuf); - ostringstream str; - str << _("Document") << ' ' << disp_fn << ' ' << _("opened."); - owner->message(str.str().c_str()); + str2 << _("Document") << ' ' << disp_fn << ' ' << _("opened."); } else { - ostringstream str; - str << _("Could not open document") << ' ' << disp_fn; - owner->message(str.str().c_str()); + str2 << _("Could not open document") << ' ' << disp_fn; } + owner->message(STRCONV(str2.str())); } diff --git a/src/lyxgluelength.C b/src/lyxgluelength.C index fd1cf48565..ae56a83268 100644 --- a/src/lyxgluelength.C +++ b/src/lyxgluelength.C @@ -45,45 +45,45 @@ string const LyXGlueLength::asString() const if (plus_.zero() && minus_.zero()) { buffer << unit_name[len_.unit()]; - return buffer.str().c_str(); + return STRCONV(buffer.str()); } - + // just len and plus if (minus_.zero()) { if (len_.unit() != plus_.unit()) buffer << unit_name[len_.unit()]; buffer << "+" << plus_.value(); buffer << unit_name[plus_.unit()]; - return buffer.str().c_str(); + return STRCONV(buffer.str()); } - + // just len and minus if (plus_.zero()) { if (len_.unit() != minus_.unit()) buffer << unit_name[len_.unit()]; buffer << "-" << minus_.value(); buffer << unit_name[minus_.unit()]; - return buffer.str().c_str(); + return STRCONV(buffer.str()); } // ok, len, plus AND minus - + // len+- if (minus_ == plus_) { if (len_.unit() != minus_.unit()) buffer << unit_name[len_.unit()]; buffer << "+-" << minus_.value(); buffer << unit_name[minus_.unit()]; - return buffer.str().c_str(); + return STRCONV(buffer.str()); } - + // this is so rare a case, why bother minimising units ? buffer << unit_name[len_.unit()]; buffer << "+" << plus_.value() << unit_name[plus_.unit()]; buffer << "-" << minus_.value() << unit_name[minus_.unit()]; - - return buffer.str().c_str(); + + return STRCONV(buffer.str()); } @@ -92,12 +92,12 @@ string const LyXGlueLength::asLatexString() const ostringstream buffer; buffer << len_.value() << unit_name[len_.unit()]; - + if (!plus_.zero()) buffer << " plus " << plus_.value() << unit_name[plus_.unit()]; if (!minus_.zero()) buffer << " minus " << minus_.value() << unit_name[minus_.unit()]; - return buffer.str().c_str(); + return STRCONV(buffer.str()); } diff --git a/src/lyxlength.C b/src/lyxlength.C index 40eb3b5d06..2e16c84ed3 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -53,7 +53,7 @@ string const LyXLength::asString() const { ostringstream buffer; buffer << val_ << unit_name[unit_]; // setw? - return buffer.str().c_str(); + return STRCONV(buffer.str()); } @@ -89,7 +89,7 @@ string const LyXLength::asLatexString() const buffer << val_ << unit_name[unit_]; // setw? break; } - return buffer.str().c_str(); + return STRCONV(buffer.str()); } @@ -134,7 +134,7 @@ int LyXLength::inPixels(int text_width, int em_width_base) const double const em_width = (em_width_base > 0) ? em_width_base : 10*(dpi/72.27)*zoom; - // A different estimate for em_width is + // A different estimate for em_width is // font_metrics::width('M', LyXFont(LyXFont::ALL_SANE)) // but this estimate might not be more accurate as the screen font // is different then the latex font. diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 1c7f9a861d..d3776065d5 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,5 +1,24 @@ 2002-11-04 Lars Gullik Bjønnes + * math_inset.C (asString): STRCONV + + * math_factory.C (initSymbols): do not std:: qualify getline, use + empty() to check for empty string, STRCONV + + * math_extern.C: STRCONV + + * math_diminset.C (drawT): STRCONV + + * math_cursor.C (info): STRCONV + + * math_autocorrect.C (initAutoCorrect): STRCONV + + * formulamacro.C (InsetFormulaMacro): STRCONV + + * formulabase.C (localDispatch): STRCONV + + * formula.C (latexString): STRCONV + * math_factory.C: add using std::endl (math_font_available): use it (initSymbols): use it diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 4b8a9eaa76..440648d582 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -330,5 +330,5 @@ string const InsetFormula::PreviewImpl::latexString() const ostringstream ls; WriteStream wi(ls, false, false); parent().par_->write(wi); - return ls.str().c_str(); + return STRCONV(ls.str()); } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 529719eb86..b8510d499b 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -310,7 +310,7 @@ Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd) if (cmd.button() == mouse_button::button3) { // try to dispatch to enclosed insets first - if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) { + if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) { // launch math panel for right mouse button bv->owner()->getDialogs().showMathPanel(); } @@ -382,12 +382,12 @@ Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd) return DISPATCHED; // only select with button 1 - if (cmd.button() != mouse_button::button1) + if (cmd.button() != mouse_button::button1) return DISPATCHED; if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2) return DISPATCHED; - + first_x = cmd.x; first_y = cmd.y; @@ -662,7 +662,7 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd) unsigned int n = 1; string v_align; string h_align; - istringstream is(argument); + istringstream is(STRCONV(argument)); is >> m >> n >> v_align >> h_align; m = max(1u, m); n = max(1u, n); @@ -736,7 +736,7 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd) mathcursor->niceInsert(argument); updateLocal(bv, true); break; - + case -1: case LFUN_SELFINSERT: if (!argument.empty()) { @@ -949,7 +949,7 @@ bool InsetFormulaBase::display() const string InsetFormulaBase::selectionAsString() const { - return mathcursor ? mathcursor->grabSelection() : string(); + return mathcursor ? mathcursor->grabSelection() : string(); } ///////////////////////////////////////////////////////////////////// @@ -1025,13 +1025,13 @@ void mathDispatch(FuncRequest const & cmd) } break; - case LFUN_GREEK: - case LFUN_INSERT_MATH: - case LFUN_INSERT_MATRIX: + case LFUN_GREEK: + case LFUN_INSERT_MATH: + case LFUN_INSERT_MATRIX: case LFUN_MATH_DELIM: { InsetFormula * f = new InsetFormula(bv); if (openNewInset(bv, f)) { - bv->theLockingInset()-> + bv->theLockingInset()-> localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); bv->theLockingInset()->localDispatch(cmd); } diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 7c759d3432..8bc0531c0b 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -61,7 +61,7 @@ InsetFormulaMacro::InsetFormulaMacro(string const & name, int nargs) InsetFormulaMacro::InsetFormulaMacro(string const & s) { - std::istringstream is(s); + std::istringstream is(STRCONV(s)); read(is); } diff --git a/src/mathed/math_autocorrect.C b/src/mathed/math_autocorrect.C index c8ba7ca628..e279cb978b 100644 --- a/src/mathed/math_autocorrect.C +++ b/src/mathed/math_autocorrect.C @@ -1,5 +1,5 @@ #ifdef __GNUG__ -#pragma implementation +#pragma implementation #endif #include @@ -146,7 +146,8 @@ void initAutoCorrect() //lyxerr[Debug::MATHED] << "ignoring line '" << line << "'" << endl; continue; } - istringstream il(line); + istringstream il(STRCONV(line)); + //lyxerr[Debug::MATHED] << "line '" << line << "'" << endl; Correction corr; if (corr.read(il)) { diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index fec411d7b3..b38fdab121 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -1290,7 +1290,7 @@ string MathCursor::info() const if (prevAtom()->asSymbolInset() || prevAtom()->asScriptInset()) prevAtom()->infoize(os); os << " "; - return os.str().c_str(); // .c_str() needed for lyxstring + return STRCONV(os.str()); } diff --git a/src/mathed/math_diminset.C b/src/mathed/math_diminset.C index b851b75db9..2e9e75ef71 100644 --- a/src/mathed/math_diminset.C +++ b/src/mathed/math_diminset.C @@ -1,6 +1,5 @@ - #ifdef __GNUG__ -#pragma implementation +#pragma implementation #endif #include "math_diminset.h" @@ -28,6 +27,6 @@ void MathDimInset::drawT(TextPainter &, int, int) const /* std::ostringstream os; os << MathAtom(this); - pain.draw(x, y, os.str().c_str()); + pain.draw(x, y, STRCONV(os.str())); */ } diff --git a/src/mathed/math_extern.C b/src/mathed/math_extern.C index ac84ace034..8c887038f8 100644 --- a/src/mathed/math_extern.C +++ b/src/mathed/math_extern.C @@ -1,6 +1,5 @@ - #ifdef __GNUG__ -#pragma implementation +#pragma implementation #endif // This file contains most of the magic that extracts "context @@ -306,7 +305,7 @@ void extractExps(MathArray & ar) if (!sup || sup->hasDown()) continue; - // create a proper exp-inset as replacement + // create a proper exp-inset as replacement ar[i] = MathAtom(new MathExFuncInset("exp", sup->cell(1))); ar.erase(i + 1); } @@ -490,7 +489,7 @@ bool testIntegral(MathAtom const & at) { return testIntSymbol(at) || - ( at->asScriptInset() + ( at->asScriptInset() && at->asScriptInset()->nuc().size() && testIntSymbol(at->asScriptInset()->nuc().back()) ); } @@ -569,7 +568,7 @@ bool testSum(MathAtom const & at) { return testSumSymbol(at) || - ( at->asScriptInset() + ( at->asScriptInset() && at->asScriptInset()->nuc().size() && testSumSymbol(at->asScriptInset()->nuc().back()) ); } @@ -750,7 +749,7 @@ void extractLims(MathArray & ar) MathArray::iterator it = ar.begin() + i; // is this a limit function? - if (!testSymbol(*it, "lim")) + if (!testSymbol(*it, "lim")) continue; // the next one must be a subscript (without superscript) @@ -767,7 +766,7 @@ void extractLims(MathArray & ar) // the -> splits the subscript int x and x0 MathArray x = MathArray(s.begin(), st); MathArray x0 = MathArray(st + 1, s.end()); - + // use something behind the script as core MathArray f; MathArray::iterator tt = extractArgument(f, it + 2, ar.end()); @@ -927,7 +926,7 @@ namespace { ostringstream os; MaximaStream ms(os); ms << ar; - string expr = os.str().c_str(); + string expr = STRCONV(os.str()); string const header = "SIMPSUM:true;"; string out; @@ -1050,7 +1049,7 @@ namespace { ostringstream os; MapleStream ms(os); ms << ar; - string expr = os.str().c_str(); + string expr = STRCONV(os.str()); lyxerr << "ar: '" << ar << "'\n"; lyxerr << "ms: '" << os.str() << "'\n"; @@ -1098,7 +1097,7 @@ namespace { ostringstream os; OctaveStream vs(os); vs << ar; - string expr = os.str().c_str(); + string expr = STRCONV(os.str()); string out; lyxerr << "pipe: ar: '" << ar << "'\n"; @@ -1182,7 +1181,7 @@ MathArray pipeThroughExtern(string const & lang, string const & extra, os << "[" << extra << ' '; ns << ar; os << "]"; - string data = os.str().c_str(); + string data = STRCONV(os.str()); // search external script string file = LibFileSearch("mathed", "extern_" + lang); diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index 68b70d19ce..cd56903489 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -57,6 +57,7 @@ bool has_math_fonts; using std::endl; + namespace { // file scope @@ -98,15 +99,15 @@ void initSymbols() std::ifstream fs(filename.c_str()); string line; bool skip = false; - while (std::getline(fs, line)) { + while (getline(fs, line)) { int charid = 0; int fallbackid = 0; - if (line.size() > 0 && line[0] == '#') + if (!line.empty() && line[0] == '#') continue; // special case of iffont/else/endif if (line.size() >= 7 && line.substr(0, 6) == "iffont") { - istringstream is(line); + istringstream is(STRCONV(line)); string tmp; is >> tmp; is >> tmp; @@ -122,13 +123,13 @@ void initSymbols() // special case of pre-defined macros if (line.size() > 8 && line.substr(0, 5) == "\\def\\") { - //lyxerr << "defining: '" << line << "'\n"; - istringstream is(line); + //lyxerr << "defining: '" << line << "'" << endl; + istringstream is(STRCONV(line)); MathMacroTable::create(MathAtom(new MathMacroTemplate(is))); continue; } - istringstream is(line); + istringstream is(STRCONV(line)); latexkeys tmp; is >> tmp.name >> tmp.inset; if (isFontName(tmp.inset)) @@ -145,7 +146,7 @@ void initSymbols() if (isFontName(tmp.inset)) { // tmp.inset _is_ the fontname here. // create fallbacks if necessary - if (tmp.extra=="func" || tmp.extra=="funclim" || tmp.extra=="special") { + if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra == "special") { lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << endl; tmp.draw = tmp.name; } else if (math_font_available(tmp.inset)) { @@ -165,20 +166,24 @@ void initSymbols() } } else { // it's a proper inset - lyxerr[Debug::MATHED] << "inset " << tmp.inset << " used for " - << tmp.name << endl; + lyxerr[Debug::MATHED] << "inset " << tmp.inset + << " used for " << tmp.name + << endl; } if (theWordList.find(tmp.name) != theWordList.end()) - lyxerr[Debug::MATHED] << "readSymbols: inset " << tmp.name - << " already exists." << endl; + lyxerr[Debug::MATHED] + << "readSymbols: inset " << tmp.name + << " already exists." << endl; else theWordList[tmp.name] = tmp; - lyxerr[Debug::MATHED] << "read symbol '" << tmp.name - << " inset: " << tmp.inset - << " draw: " << int(tmp.draw[0]) - << " extra: " << tmp.extra - << "'" << endl; + + lyxerr[Debug::MATHED] + << "read symbol '" << tmp.name + << " inset: " << tmp.inset + << " draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0]) + << " extra: " << tmp.extra + << "'" << endl; } string tmp = "cmm"; string tmp2 = "cmsy"; @@ -203,18 +208,20 @@ latexkeys const * in_word_set(string const & str) { WordList::iterator it = theWordList.find(str); //lyxerr << "looking up '" << str << "' found: " - // << (it != theWordList.end()) << "\n"; + // << (it != theWordList.end()) << endl; return (it != theWordList.end()) ? &(it->second) : 0; } MathAtom createMathInset(string const & s) { - lyxerr[Debug::MATHED] << "creating inset with name: '" << s << "'" << endl; + lyxerr[Debug::MATHED] << "creating inset with name: '" + << s << "'" << endl;; latexkeys const * l = in_word_set(s); if (l) { string const & inset = l->inset; - lyxerr[Debug::MATHED] << " found inset: '" << inset << "'" << endl; + lyxerr[Debug::MATHED] << " found inset: '" << + inset << "'" << endl; if (inset == "ref") return MathAtom(new RefInset(l->name)); if (inset == "underset") diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 00a036c865..b6f743e32a 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -393,7 +393,7 @@ void MathHullInset::footer_write(WriteStream & os) const else os << "\\]\n"; - else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign" + else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign" || type_ == "alignat" || type_ == "xalignat") os << "\\end{" << type_ << star(n) << "}\n"; @@ -433,7 +433,7 @@ void MathHullInset::delRow(row_type row) void MathHullInset::addCol(col_type col) { - if (colChangeOK()) + if (colChangeOK()) MathGridInset::addCol(col); else lyxerr << "Can't change number of columns in '" << type_ << "'\n"; @@ -442,7 +442,7 @@ void MathHullInset::addCol(col_type col) void MathHullInset::delCol(col_type col) { - if (colChangeOK()) + if (colChangeOK()) MathGridInset::delCol(col); else lyxerr << "Can't change number of columns in '" << type_ << "'\n"; @@ -592,7 +592,7 @@ void MathHullInset::mutate(string const & newtype) } else if (type_ == "multline") { - if (newtype == "gather" || newtype == "align" || + if (newtype == "gather" || newtype == "align" || newtype == "xalignat" || newtype == "xxalignat" || newtype == "flalign") setType(newtype); else if (newtype == "eqnarray") { @@ -826,7 +826,7 @@ MathInset::result_type MathHullInset::dispatch idx = r * ncols() + c; if (idx >= nargs()) idx = nargs() - 1; - if (pos > cell(idx).size()) + if (pos > cell(idx).size()) pos = cell(idx).size(); return DISPATCHED_POP; } diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 2a6445205d..48f644d71a 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -18,7 +18,7 @@ #include #ifdef __GNUG__ -#pragma implementation +#pragma implementation #endif #include "math_inset.h" @@ -264,7 +264,7 @@ int MathInset::docbook(std::ostream &, bool) const MathInset::result_type - MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &) + MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &) { return UNDISPATCHED; } @@ -288,7 +288,7 @@ string asString(MathArray const & ar) std::ostringstream os; WriteStream ws(os); ws << ar; - return os.str().c_str(); + return STRCONV(os.str()); } diff --git a/src/paragraph.C b/src/paragraph.C index 2e3f8a927d..bee7384f6b 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1743,7 +1743,7 @@ string const Paragraph::asString(Buffer const * buffer, bool label) getInset(i)->lyxCode() == Inset::MATH_CODE) { ostringstream ost; getInset(i)->ascii(buffer, ost); - s += subst(ost.str().c_str(),'\n',' '); + s += subst(STRCONV(ost.str()),'\n',' '); } } @@ -1775,7 +1775,7 @@ string const Paragraph::asString(Buffer const * buffer, } } - return ost.str().c_str(); + return STRCONV(ost.str()); } diff --git a/src/sgml.C b/src/sgml.C index 35b4b018dc..52ada720fc 100644 --- a/src/sgml.C +++ b/src/sgml.C @@ -8,23 +8,23 @@ */ #include - + #include "support/LOstream.h" - + #include "paragraph.h" #include "sgml.h" - + using std::pair; using std::make_pair; using std::ostream; using std::endl; - + namespace sgml { pair escapeChar(char c) { string str; - + switch (c) { case Paragraph::META_HFILL: break; @@ -83,7 +83,7 @@ pair escapeChar(char c) return make_pair(false, str); } - + int openTag(ostream & os, Paragraph::depth_type depth, bool mixcont, string const & latexname) { diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 25f04786df..7824345f98 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,5 +1,12 @@ 2002-11-04 Lars Gullik Bjønnes + * lstrings.h (tostr): STRCONV + + * lstrings.C (regexMatch): STRCONV + (getVectorFromString): STRCONV, manual copy into vector + + * filetools.C (GetFileContents): STRCONV + * os.C: include config.h * lstrings.C (getVectorFromString): rewrite to use diff --git a/src/support/filetools.C b/src/support/filetools.C index d8c4438d96..31112d8b69 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -782,7 +782,7 @@ string const GetFileContents(string const & fname) if (ifs && ofs) { ofs << ifs.rdbuf(); ifs.close(); - return ofs.str().c_str(); + return STRCONV(ofs.str()); } } lyxerr << "LyX was not able to read file '" << fname << "'" << endl; diff --git a/src/support/lstrings.C b/src/support/lstrings.C index b0ca602de3..89ef75f0a7 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -447,8 +447,8 @@ bool regexMatch(string const & a, string const & pattern) string regex(pattern); regex = subst(regex, ".", "\\."); regex = subst(regex, "*", ".*"); - boost::regex reg(regex); - return boost::regex_match(a, reg); + boost::regex reg(STRCONV(regex)); + return boost::regex_match(STRCONV(a), reg); } @@ -637,7 +637,20 @@ vector const getVectorFromString(string const & str, #else boost::char_separator sep(delim.c_str()); boost::tokenizer > tokens(str, sep); +#ifndef USE_INCLUDED_STRING return vector(tokens.begin(), tokens.end()); +#else + vector vec; + using boost::tokenizer; + using boost::char_separator; + + tokenizer >::iterator it = tokens.begin(); + tokenizer >::iterator end = tokens.end(); + for (; it != end; ++it) { + vec.push_back(STRCONV((*it))); + } + return vec; +#endif #endif } diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 4fbde835dc..1330616ab9 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -97,7 +97,7 @@ string const tostr(T const & t) { ostringstream ostr; ostr << t; - return ostr.str().c_str(); + return STRCONV(ostr.str()); // We need to use the .c_str since we sometimes are using // our own string class and that is not compatible with // basic_string. (of course we don't want this later) diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index fbe70e23dc..73f2f67ceb 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -665,7 +665,7 @@ lyxstring::const_reference lyxstring::operator[](size_type pos) const #if 0 // This is actually what the standard requires, lyx::Assert(pos <= rep->sz); // OURS! - static char helper = '\0'; + static char const helper = '\0'; return pos == rep->sz ? helper : rep->s[pos]; #else // but we use this one since it is stricter diff --git a/src/text2.C b/src/text2.C index 075fcc6a58..720abda360 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1257,9 +1257,8 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const .numberLabel(layout->latexname(), numbertype, langtype, head); - par->params().labelString(par->params().labelString() + s.str().c_str()); - // We really want to remove the c_str as soon as - // possible... + par->params().labelString(par->params().labelString() + + STRCONV(s.str())); // reset enum counters textclass.counters().reset("enum"); @@ -1292,7 +1291,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const s << textclass.counters() .numberLabel(enumcounter, "enumeration", langtype); - par->params().labelString(s.str().c_str()); + par->params().labelString(STRCONV(s.str())); } } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302 textclass.counters().step("bibitem"); @@ -1335,7 +1334,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const ostringstream o; //o << fl.name() << " " << buf->counters().value(fl.name()) << ":"; o << fl.name() << " #:"; - s = o.str(); + s = STRCONV(o.str()); } else { // par->SetLayout(0); // s = layout->labelstring; diff --git a/src/vc-backend.C b/src/vc-backend.C index a41176b3a6..e81ed01b2c 100644 --- a/src/vc-backend.C +++ b/src/vc-backend.C @@ -31,7 +31,13 @@ using std::ifstream; using std::getline; using boost::regex; using boost::regex_match; + +#ifndef USE_INCLUDED_STRING using boost::smatch; +#else +using boost::cmatch; +#endif + int VCS::doVCCommand(string const & cmd, string const & path) { @@ -252,13 +258,18 @@ void CVS::scanMaster() lyxerr[Debug::LYXVC] << "\t line: " << line << endl; if (contains(line, tmpf)) { // Ok extract the fields. +#ifndef USE_INCLUDED_STRING smatch sm; - regex_match(line, sm, reg); +#else + cmatch sm; +#endif + regex_match(STRCONV(line), sm, reg); //sm[0]; // whole matched string //sm[1]; // filename - version_ = sm.str(2); - string file_date = sm.str(3); + version_ = STRCONV(sm.str(2)); + string const file_date = STRCONV(sm.str(3)); + //sm[4]; // options //sm[5]; // tag or tagdate FileInfo fi(file_);