diff --git a/ChangeLog b/ChangeLog index 4277986e59..1a16909cb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +1999-10-19 Lars Gullik Bjønnes + + * src/chset.C (encodeString): use a char temporary instead + + * src/table.C (TexEndOfCell): added tostr around + column_of_cell(fcell+i)+1 and around right_column_of_cell(fcell+i)+1 + (TexEndOfCell): ditto + (TexEndOfCell): ditto + (TexEndOfCell): ditto + (DocBookEndOfCell): ditto + (DocBookEndOfCell): ditto + (DocBookEndOfCell): ditto + (DocBookEndOfCell): ditto + + * src/paragraph.C (TeXEnvironment): added tostr around foot_count -1 + + * src/lyxfr1.C (SearchReplaceAllCB): added tostr around replace_count + + * src/lyx_cb.C (MenuRunLaTeX): added tostr around ret + (MenuBuildProg): added tostr around ret + (MenuRunChktex): added tostr around ret + (DocumentApplyCB): added tostr around ret + + * src/chset.C (encodeString): added tostr around t->ic + + * src/buffer.C (makeLaTeXFile): added tostr around secnumdepth + (makeLaTeXFile): added tostr around tocdepth + (makeLaTeXFile): added tostr around ftcound - 1 + + * src/insets/insetbib.C (setCounter): added tostr around counter. + + * src/support/lyxstring.h: added an operator+=(int) to catch more + mistakes. + + * src/support/lyxstring.C (lyxstring): We DON'T allow NULL pointers. + (lyxstring): We DON'T allow NULL pointers. + 1999-10-19 Jean-Marc Lasgouttes * src/mathed/math_macro.C (MathMacroArgument::Write, diff --git a/src/buffer.C b/src/buffer.C index 6ac2a892f0..978772dec7 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1832,13 +1832,13 @@ void Buffer::makeLaTeXFile(string const & filename, if (params.secnumdepth != tclass->secnumdepth) { LFile += "\\setcounter{secnumdepth}{"; - LFile += params.secnumdepth; + LFile += tostr(params.secnumdepth); LFile += "}\n"; texrow.newline(); } if (params.tocdepth != tclass->tocdepth) { LFile += "\\setcounter{tocdepth}{"; - LFile += params.tocdepth; + LFile += tostr(params.tocdepth); LFile += "}\n"; texrow.newline(); } @@ -1995,7 +1995,7 @@ void Buffer::makeLaTeXFile(string const & filename, if (ftcount >= 1) { if (ftcount > 1) { LFile += "\\addtocounter{footnote}{-"; - LFile += ftcount - 1; + LFile += tostr(ftcount - 1); LFile += '}'; } LFile += ftnote; diff --git a/src/chset.C b/src/chset.C index 0cd8c56382..ae0d8ed0ab 100644 --- a/src/chset.C +++ b/src/chset.C @@ -98,15 +98,14 @@ bool CharacterSet::loadFile(const string& fname) } -bool CharacterSet::encodeString(string& str) +bool CharacterSet::encodeString(string & str) { Cdef *t=map_; while(t) { if (t->str==str) { - str.erase(); - str += t->ic; - //str = tostr(t->ic); + // Can this fail? Why is ic an unsigned char? + str = char(t->ic); break; } t=t->next; diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index e66147d3a9..99a3b52097 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -231,7 +231,7 @@ void InsetBibKey::setCounter(int c) counter = c; if (contents.empty()) - contents += counter; + contents += tostr(counter); } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 132a446a89..90d652c2b7 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -465,7 +465,7 @@ int MenuRunLaTeX(Buffer *buffer) s = _("One error detected"); t = _("You should try to fix it."); } else { - s += ret; + s += tostr(ret); s += _(" errors detected."); t = _("You should try to fix them."); } @@ -497,7 +497,7 @@ int MenuBuildProg(Buffer *buffer) s = _("One error detected"); t = _("You should try to fix it."); } else { - s += ret; + s += tostr(ret); s += _(" errors detected."); t = _("You should try to fix them."); } @@ -526,7 +526,7 @@ int MenuRunChktex(Buffer *buffer) s = _("One warning found."); t = _("Use 'Edit->Go to Error' to find it."); } else { - s += ret; + s += tostr(ret); s += _(" warnings found."); t = _("Use 'Edit->Go to Error' to find them."); } @@ -2886,7 +2886,7 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long) if (ret==1) s= _("One paragraph couldn't be converted"); else { - s += ret; + s += tostr(ret); s += _(" paragraphs couldn't be converted"); } WriteAlert(_("Conversion Errors!"),s, diff --git a/src/lyxfr1.C b/src/lyxfr1.C index 80bfa18070..b2ede55857 100644 --- a/src/lyxfr1.C +++ b/src/lyxfr1.C @@ -32,6 +32,7 @@ #include "LyXView.h" #include "lyx_gui_misc.h" #include "minibuffer.h" +#include "support/lstrings.h" extern BufferView *current_view; // called too many times in this file... extern MiniBuffer *minibuffer; @@ -234,8 +235,7 @@ void LyXFindReplace1::SearchReplaceAllCB() if( replace_count == 1 ) { minibuffer->Set(_("1 string has been replaced.")); } else { - string str; - str += replace_count; + string str = tostr(replace_count); str += _(" strings have been replaced."); minibuffer->Set(str); } diff --git a/src/paragraph.C b/src/paragraph.C index 6c55890cd1..93865c6df2 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -3526,7 +3526,7 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow, if (foot_count >= 1) { if (foot_count > 1) { file += "\\addtocounter{footnote}{-"; - file += foot_count - 1; + file += tostr(foot_count - 1); file += '}'; } file += foot; diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index ae20c4d23c..ce3d08f744 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -342,7 +342,7 @@ lyxstring::lyxstring(value_type const * s, size_type n) { Assert(s); // we don't allow null pointers static Srep empty_rep(0, ""); - if (s && *s && n) { // s is not empty string and n > 0 + if (*s && n) { // s is not empty string and n > 0 rep = new Srep(min(strlen(s), n), s); } else { ++empty_rep.ref; @@ -353,10 +353,9 @@ lyxstring::lyxstring(value_type const * s, size_type n) lyxstring::lyxstring(value_type const * s) { - // yes we allow them just don't initalize them - // Assert(s); // we don't allow null pointers + Assert(s); // we don't allow null pointers static Srep empty_rep(0, ""); - if (s && *s) { // s is not empty string + if (*s) { // s is not empty string rep = new Srep(strlen(s), s); } else { ++empty_rep.ref; diff --git a/src/support/lyxstring.h b/src/support/lyxstring.h index 632eb97532..a2cba89b8f 100644 --- a/src/support/lyxstring.h +++ b/src/support/lyxstring.h @@ -510,6 +510,8 @@ private: lyxstring & operator+(int); /// lyxstring & operator=(int); + /// + lyxstring & operator+=(int); /// A string representation struct Srep { diff --git a/src/table.C b/src/table.C index f2aba98011..1153146445 100644 --- a/src/table.C +++ b/src/table.C @@ -15,6 +15,7 @@ #include "table.h" #include "vspace.h" #include "layout.h" +#include "support/lstrings.h" #ifdef __GNUG__ #pragma implementation @@ -1010,9 +1011,9 @@ int LyXTable::TexEndOfCell(string& file, int cell) for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i)){ file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; tmp = 1; } @@ -1083,9 +1084,9 @@ int LyXTable::TexEndOfCell(string& file, int cell) for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (TopLine(fcell+i)){ file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; tmp = 1; } @@ -1151,14 +1152,14 @@ int LyXTable::TexEndOfCell(string& file, int cell) for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i)){ file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; hline1 += "\\cline{"; - hline1 += column_of_cell(fcell+i)+1; + hline1 += tostr(column_of_cell(fcell+i)+1); hline1 += '-'; - hline1 += right_column_of_cell(fcell+i)+1; + hline1 += tostr(right_column_of_cell(fcell+i)+1); hline1 += "} "; tmp = 1; } @@ -1209,15 +1210,15 @@ int LyXTable::TexEndOfCell(string& file, int cell) if (TopLine(fcell+i)){ if (print_hline) { file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; } hline2 += "\\cline{"; - hline2 += column_of_cell(fcell+i)+1; + hline2 += tostr(column_of_cell(fcell+i)+1); hline2 += '-'; - hline2 += right_column_of_cell(fcell+i)+1; + hline2 += tostr(right_column_of_cell(fcell+i)+1); hline2 += "} "; tmp = 1; } @@ -1279,7 +1280,7 @@ int LyXTable::TexEndOfCell(string& file, int cell) } if (nvcell < numberofcells && IsMultiColumn(nvcell)) { file += "\\multicolumn{"; - file += cells_in_multicolumn(nvcell); + file += tostr(cells_in_multicolumn(nvcell)); file += "}{"; if (!cellinfo_of_cell(cell+1)->align_special.empty()) { file += cellinfo_of_cell(cell+1)->align_special; @@ -1535,7 +1536,7 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth) else file += "