From 15a0218c0fbd310587456f1342f051a663a69d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 14 Jun 2001 17:58:49 +0000 Subject: [PATCH] fix some buggy constructs with stringstream git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2127 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 60 +++++++++++++++++++++--------------------- src/BufferView_pimpl.C | 33 ++++++++++++++--------- src/ChangeLog | 16 +++++++++++ src/Chktex.C | 6 ++++- src/LaTeX.C | 21 ++++++++++++--- src/bufferview_funcs.C | 31 +++++++++++++--------- src/importer.C | 5 ++-- src/lyx_main.C | 2 +- src/lyxfunc.C | 57 +++++++++++++++++++++++---------------- 9 files changed, 147 insertions(+), 84 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 55116f1083..53c323e68c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,8 +10,8 @@ src/CutAndPaste.C src/debug.C src/exporter.C src/ext_l10n.h -src/figureForm.C src/figure_form.C +src/figureForm.C src/FontLoader.C src/frontends/controllers/ButtonController.h src/frontends/controllers/character.C @@ -89,67 +89,67 @@ src/frontends/qt2/paragraphdlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/xforms/combox.C src/frontends/xforms/FileDialog.C -src/frontends/xforms/FormBibitem.C src/frontends/xforms/form_bibitem.C -src/frontends/xforms/FormBibtex.C +src/frontends/xforms/FormBibitem.C src/frontends/xforms/form_bibtex.C +src/frontends/xforms/FormBibtex.C src/frontends/xforms/form_browser.C -src/frontends/xforms/FormCharacter.C src/frontends/xforms/form_character.C -src/frontends/xforms/FormCitation.C +src/frontends/xforms/FormCharacter.C src/frontends/xforms/form_citation.C -src/frontends/xforms/FormCopyright.C +src/frontends/xforms/FormCitation.C src/frontends/xforms/form_copyright.C -src/frontends/xforms/FormCredits.C +src/frontends/xforms/FormCopyright.C src/frontends/xforms/form_credits.C -src/frontends/xforms/FormDocument.C +src/frontends/xforms/FormCredits.C src/frontends/xforms/form_document.C -src/frontends/xforms/FormError.C +src/frontends/xforms/FormDocument.C src/frontends/xforms/form_error.C -src/frontends/xforms/FormExternal.C +src/frontends/xforms/FormError.C src/frontends/xforms/form_external.C -src/frontends/xforms/FormFiledialog.C +src/frontends/xforms/FormExternal.C src/frontends/xforms/form_filedialog.C -src/frontends/xforms/FormGraphics.C +src/frontends/xforms/FormFiledialog.C src/frontends/xforms/form_graphics.C -src/frontends/xforms/FormInclude.C +src/frontends/xforms/FormGraphics.C src/frontends/xforms/form_include.C -src/frontends/xforms/FormIndex.C +src/frontends/xforms/FormInclude.C src/frontends/xforms/form_index.C +src/frontends/xforms/FormIndex.C src/frontends/xforms/FormLog.C src/frontends/xforms/FormMathsBitmap.C -src/frontends/xforms/FormMathsDeco.C src/frontends/xforms/form_maths_deco.C -src/frontends/xforms/FormMathsDelim.C +src/frontends/xforms/FormMathsDeco.C src/frontends/xforms/form_maths_delim.C -src/frontends/xforms/FormMathsMatrix.C +src/frontends/xforms/FormMathsDelim.C src/frontends/xforms/form_maths_matrix.C -src/frontends/xforms/FormMathsPanel.C +src/frontends/xforms/FormMathsMatrix.C src/frontends/xforms/form_maths_panel.C -src/frontends/xforms/FormMathsSpace.C +src/frontends/xforms/FormMathsPanel.C src/frontends/xforms/form_maths_space.C -src/frontends/xforms/FormMinipage.C +src/frontends/xforms/FormMathsSpace.C src/frontends/xforms/form_minipage.C -src/frontends/xforms/FormParagraph.C +src/frontends/xforms/FormMinipage.C src/frontends/xforms/form_paragraph.C -src/frontends/xforms/FormPreamble.C +src/frontends/xforms/FormParagraph.C src/frontends/xforms/form_preamble.C -src/frontends/xforms/FormPreferences.C +src/frontends/xforms/FormPreamble.C src/frontends/xforms/form_preferences.C -src/frontends/xforms/FormPrint.C +src/frontends/xforms/FormPreferences.C src/frontends/xforms/form_print.C -src/frontends/xforms/FormRef.C +src/frontends/xforms/FormPrint.C src/frontends/xforms/form_ref.C -src/frontends/xforms/FormSearch.C +src/frontends/xforms/FormRef.C src/frontends/xforms/form_search.C -src/frontends/xforms/FormTabular.C +src/frontends/xforms/FormSearch.C src/frontends/xforms/form_tabular.C -src/frontends/xforms/FormTabularCreate.C +src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular_create.C -src/frontends/xforms/FormToc.C +src/frontends/xforms/FormTabularCreate.C src/frontends/xforms/form_toc.C -src/frontends/xforms/FormUrl.C +src/frontends/xforms/FormToc.C src/frontends/xforms/form_url.C +src/frontends/xforms/FormUrl.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index d3278201ed..52d01f62ce 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1122,8 +1122,9 @@ void BufferView::Pimpl::savePosition(unsigned int i) bv_->text->cursor.par()->id(), bv_->text->cursor.pos()); if (i > 0) { - string const str = _("Saved bookmark") + ' ' + tostr(i); - owner_->message(str); + ostringstream str; + str << _("Saved bookmark") << ' ' << i; + owner_->message(str.str().c_str()); } } @@ -1153,8 +1154,9 @@ void BufferView::Pimpl::restorePosition(unsigned int i) update(bv_->text, BufferView::SELECT|BufferView::FITCUR); if (i > 0) { - string const str = _("Moved to bookmark") + ' ' + tostr(i); - owner_->message(str); + ostringstream str; + str << _("Moved to bookmark") << ' ' << i; + owner_->message(str.str().c_str()); } } @@ -1390,19 +1392,24 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen) if (!IsLyXFilename(filename)) filename += ".lyx"; + string const disp_fn(MakeDisplayPath(filename)); + // Inserts document - string const s1 = _("Inserting document") + ' ' - + MakeDisplayPath(filename) + " ..."; - owner_->message(s1); + ostringstream s1; + s1 << _("Inserting document") << ' ' + << disp_fn << " ..."; + owner_->message(s1.str().c_str()); bool const res = bv_->insertLyXFile(filename); if (res) { - string const str = _("Document") + ' ' - + MakeDisplayPath(filename) + ' ' + _("inserted."); - owner_->message(str); + ostringstream str; + str << _("Document") << ' ' << disp_fn + << ' ' << _("inserted."); + owner_->message(str.str().c_str()); } else { - string const str = _("Could not insert document") + ' ' - + MakeDisplayPath(filename); - owner_->message(str); + ostringstream str; + str << _("Could not insert document") << ' ' + << disp_fn; + owner_->message(str.str().c_str()); } } diff --git a/src/ChangeLog b/src/ChangeLog index 03d6860ec9..809edaf0f6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2001-06-14 Lars Gullik Bjønnes + + * lyxfunc.C (Dispatch): use stringstream + (MenuNew): use stringstream + (Open): use stringstream + + * importer.C (Import): use stringstream + + * bufferview_funcs.C (CurrentState): use stringstream + + * LaTeX.C (run): use stringstream + + * BufferView_pimpl.C (savePosition): use stringstream + (restorePosition): use stringstream + (MenuInsertLyXFile): use stringstream + 2001-06-14 Angus Leeming * BufferView.C: diff --git a/src/Chktex.C b/src/Chktex.C index dd7b410b02..e0b3991379 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -68,7 +68,11 @@ int Chktex::scanLogFile(TeXErrors & terr) ifstream ifs(tmp.c_str()); while (getline(ifs, token)) { - string srcfile, line, pos, warno, warning; + string srcfile; + string line; + string pos; + string warno; + string warning; token = split(token, srcfile, ':'); token = split(token, line, ':'); token = split(token, pos, ':'); diff --git a/src/LaTeX.C b/src/LaTeX.C index 15c13cb833..a8106ccf2f 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -174,7 +174,12 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) ++count; lyxerr[Debug::LATEX] << "Run #" << count << endl; - if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run number") + ' ' + tostr(count)); + if (lfun) { + ostringstream str; + str << _("LaTeX run number") << ' ' << count; + lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); + } + //WriteStatus(lfun, string(_("LaTeX run number ")) + tostr(count)); this->operator()(); @@ -251,7 +256,12 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) << "Dep. file has changed or rerun requested" << endl; lyxerr[Debug::LATEX] << "Run #" << count << endl; - if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run number") + ' ' + tostr(count)); + if (lfun) { + ostringstream str; + str << _("LaTeX run number") << ' ' << count; + lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); + } + // WriteStatus(minib, // string(_("LaTeX run number ")) + tostr(count)); this->operator()(); @@ -302,7 +312,12 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) rerun = false; ++count; lyxerr[Debug::LATEX] << "Run #" << count << endl; - if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run numger") + ' ' + tostr(count)); + if (lfun) { + ostringstream str; + str << _("LaTeX run number") << ' ' << count; + lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); + } + // WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count)); this->operator()(); scanres = scanLogFile(terr); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 28c3c62e35..065e488036 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -191,7 +191,8 @@ void FontSize(BufferView * bv, string const & size) // Returns the current font and depth as a message. string const CurrentState(BufferView * bv) { - string state; + ostringstream state; + if (bv->available()) { // I think we should only show changes from the default // font. (Asger) @@ -203,31 +204,37 @@ string const CurrentState(BufferView * bv) .TextClass(buffer->params.textclass) .defaultfont(); font.reduce(defaultfont); - state = _("Font: ") + font.stateText(&buffer->params); + + state << _("Font:") << ' ' + << font.stateText(&buffer->params); + // The paragraph depth int depth = text->GetDepth(); - if (depth > 0) - state += string(_(", Depth: ")) + tostr(depth); + if (depth > 0) + state << _(", Depth: ") << depth; + // The paragraph spacing, but only if different from // buffer spacing. if (!text->cursor.par()->params.spacing().isDefault()) { Spacing::Space cur_space = text->cursor.par()->params.spacing().getSpace(); - state += _(", Spacing: "); + state << _(", Spacing: "); + switch (cur_space) { case Spacing::Single: - state += _("Single"); + state << _("Single"); + break; case Spacing::Onehalf: - state += _("Onehalf"); + state << _("Onehalf"); break; case Spacing::Double: - state += _("Double"); + state << _("Double"); break; case Spacing::Other: - state += _("Other ("); - state += tostr(text->cursor.par()->params.spacing().getValue()); - state += ")"; + state << _("Other (") + << text->cursor.par()->params.spacing().getValue() + << ")"; break; case Spacing::Default: // should never happen, do nothing @@ -235,7 +242,7 @@ string const CurrentState(BufferView * bv) } } } - return state; + return state.str().c_str(); } diff --git a/src/importer.C b/src/importer.C index a486d7b8c8..58f1c87b28 100644 --- a/src/importer.C +++ b/src/importer.C @@ -37,8 +37,9 @@ bool Importer::Import(LyXView * lv, string const & filename, string const & format) { string const displaypath = MakeDisplayPath(filename); - string const s1 = _("Importing") + ' ' + displaypath + "..."; - lv->message(s1); + ostringstream s1; + s1 << _("Importing") << ' ' << displaypath << "..."; + lv->message(s1.str().c_str()); string const lyxfile = ChangeExtension(filename, ".lyx"); diff --git a/src/lyx_main.C b/src/lyx_main.C index 2a8c845665..6249bec5e7 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -587,7 +587,7 @@ bool LyX::ReadRcFile(string const & name) << " in " << lyxrc_path << endl; if (lyxrc.read(lyxrc_path) < 0) { WriteAlert(_("LyX Warning!"), - _("Error while reading ")+lyxrc_path+".", + _("Error while reading ") + lyxrc_path + ".", _("Using built-in defaults.")); return false; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 6f6a4156a8..94a1710e48 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -869,11 +869,10 @@ string const LyXFunc::Dispatch(int ac, case LFUN_MENUWRITE: if (!owner->buffer()->isUnnamed()) { - string const s1 = _("Saving document") + ' ' - + MakeDisplayPath(owner->buffer()->fileName() - + "..."); - - owner->message(s1); + ostringstream s1; + s1 << _("Saving document") << ' ' + << MakeDisplayPath(owner->buffer()->fileName() + "..."); + owner->message(s1.str().c_str()); MenuWrite(owner->view(), owner->buffer()); } else WriteAs(owner->view(), owner->buffer()); @@ -1043,10 +1042,10 @@ string const LyXFunc::Dispatch(int ac, AllowInput(owner->view()); break; } - string const str = _("Opening help file") + ' ' - + MakeDisplayPath(fname) + "..."; - - owner->message(str); + ostringstream str; + str << _("Opening help file") << ' ' + << MakeDisplayPath(fname) << "..."; + owner->message(str.str().c_str()); owner->view()->buffer(bufferlist.loadLyXFile(fname,false)); AllowInput(owner->view()); break; @@ -1568,14 +1567,22 @@ void LyXFunc::MenuNew(bool fromTemplate) MakeDisplayPath(s, 50), _("Do you want to open the document?"))) { // loads document - owner->message(_("Opening document") + ' ' - + MakeDisplayPath(s) + "..."); - XFlush(fl_get_display()); + string const disp_fn(MakeDisplayPath(s)); + + ostringstream str; + str << _("Opening document") << ' ' + << disp_fn << "..."; + + owner->message(str.str().c_str()); + //XFlush(fl_get_display()); owner->view()->buffer( bufferlist.loadLyXFile(s)); - owner->message(_("Document") + ' ' - + MakeDisplayPath(s) + ' ' - + _("opened.")); + ostringstream str2; + str2 << _("Document") << ' ' + << disp_fn << ' ' << _("opened."); + + owner->message(str2.str().c_str()); + return; } } @@ -1667,17 +1674,23 @@ void LyXFunc::Open(string const & fname) filename += ".lyx"; // loads document - owner->message(_("Opening document") + ' ' - + MakeDisplayPath(filename) + "..."); + string const disp_fn(MakeDisplayPath(filename)); + + ostringstream str; + str << _("Opening document") << ' ' << disp_fn << "..."; + + owner->message(str.str().c_str()); + Buffer * openbuf = bufferlist.loadLyXFile(filename); if (openbuf) { owner->view()->buffer(openbuf); - owner->message(_("Document") + ' ' - + MakeDisplayPath(filename) - + ' ' + _("opened.")); + ostringstream str; + str << _("Document") << ' ' << disp_fn << ' ' << _("opened."); + owner->message(str.str().c_str()); } else { - owner->message(_("Could not open document") + ' ' - + MakeDisplayPath(filename)); + ostringstream str; + str << _("Could not open docuent") << ' ' << disp_fn; + owner->message(str.str().c_str()); } }