]> git.lyx.org Git - lyx.git/commitdiff
more tostr fixes and stricter lyxstring again + lyxstring & operator+=(int)
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 19 Oct 1999 16:48:35 +0000 (16:48 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 19 Oct 1999 16:48:35 +0000 (16:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@213 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/buffer.C
src/chset.C
src/insets/insetbib.C
src/lyx_cb.C
src/lyxfr1.C
src/paragraph.C
src/support/lyxstring.C
src/support/lyxstring.h
src/table.C

index 4277986e5912383c11471bb7184418b13512054a..1a16909cb4ab2e461f11a98d848566b264f5d75c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+1999-10-19  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * 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  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/mathed/math_macro.C (MathMacroArgument::Write,
index 6ac2a892f03fa0fc4f2bf3517f1304b4977a0242..978772dec76b13dedec5c01360399cff555275d4 100644 (file)
@@ -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;
index 0cd8c56382c856ae7f00e76eb3985e174335f91d..ae0d8ed0ab03719cb024ce7832b9fa722d57b87c 100644 (file)
@@ -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;
index e66147d3a94ef8c56c20a9ee5743253c7fc9cdd3..99a3b52097a392050c427befd76b55c4891fb2a2 100644 (file)
@@ -231,7 +231,7 @@ void InsetBibKey::setCounter(int c)
        counter = c; 
     
        if (contents.empty())
-               contents += counter;
+               contents += tostr(counter);
 }
 
 
index 132a446a89785a600957ca3b076df41bce0b0b60..90d652c2b7087f9ced943ff3006c5254b988c6e5 100644 (file)
@@ -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,
index 80bfa1807013dc19955014fe83f4710e89cd4199..b2ede55857274632256f6a93610fb99e970fcb84 100644 (file)
@@ -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);
                }
index 6c55890cd17e56c6a4e215e94141dfe0def53bd2..93865c6df2e7a1c279e87830381e03323574a0af 100644 (file)
@@ -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;
index ae20c4d23c61bb6d0118cdc9a22c1ef878748131..ce3d08f74419bdbc5345bcca2992d2ed3e221f63 100644 (file)
@@ -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;
index 632eb975321a7815dfa34e584c2a60c99e6703a8..a2cba89b8f92ad997c17ade7f389a74c07c10c3d 100644 (file)
@@ -510,6 +510,8 @@ private:
        lyxstring & operator+(int);
        ///
        lyxstring & operator=(int);
+       ///
+       lyxstring & operator+=(int);
        
        /// A string representation
        struct Srep {
index f2aba980110dada284e7a006b130c8ae4857625a..11531464456f375c0b1e95da64cec45bc4e5270d 100644 (file)
@@ -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 += "<TGROUP ";
             file += "COLS='";
-            file += columns;
+            file += tostr(columns);
             file += "' COLSEP='1' ROWSEP='1'>";
            addNewlineAndDepth(file,++depth);
             ret++;
@@ -1543,9 +1544,9 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
                 file += "<COLSPEC ALIGN='";
                file += getDocBookAlign(i, true);
                file += "' COLNAME='col";
-                file += i+1;
+                file += tostr(i+1);
                 file += "' COLNUM='";
-                file += i+1;
+                file += tostr(i+1);
                file += "' COLSEP='";
                if (i == (columns-1)) {
                     file += '1';
@@ -1606,7 +1607,7 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
            file += "'";
            if (IsMultiColumn(0)) {
                file += " NAMEST='col1' NAMEEND='col";
-               file += cells_in_multicolumn(0);
+               file += tostr(cells_in_multicolumn(0));
                file += "'";
            }
             file += ">";
@@ -1638,10 +1639,10 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
                 file += "' VALIGN='middle'";
                if (IsMultiColumn(cell+1)) {
                    file += " NAMEST='col";
-                   file += column_of_cell(cell+1) + 1;
+                   file += tostr(column_of_cell(cell+1) + 1);
                    file += "' NAMEEND='col";
-                   file += column_of_cell(cell+1) +
-                       cells_in_multicolumn(cell+1);
+                   file += tostr(column_of_cell(cell+1) +
+                       cells_in_multicolumn(cell+1));
                    file += "'";
                }
                file += ">";
@@ -1807,10 +1808,10 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
                 file += "' VALIGN='middle'";
                if (IsMultiColumn(cell+1)) {
                    file += " NAMEST='col";
-                   file += column_of_cell(cell+1) + 1;
+                   file += tostr(column_of_cell(cell+1) + 1);
                    file += "' NAMEEND='col";
-                   file += column_of_cell(cell+1) +
-                       cells_in_multicolumn(cell+1);
+                   file += tostr(column_of_cell(cell+1) +
+                       cells_in_multicolumn(cell+1));
                    file += "'";
                }
                file += ">";