Angus Leeming <[EMAIL PROTECTED]> writes:

| On Thursday 07 March 2002 1:34 pm, Angus Leeming wrote:
>> > a patch like this: (I have not even tried to compile it...)
>> 
>> SIGH.... would you like me to have a go? Ok.
>
| Actually, having read Jürgen's response, I'm not going to do this. I don't 
| want to replace one bug with another!

I actually thingk that the whole functions should be rewritten into
two parts... one part that just emmits "lines" to an ostream, and
another that takes this stream and breaks overlong lines.

Hmm...

What about this patch...

Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.314
diff -u -p -r1.314 buffer.C
--- src/buffer.C        2002/03/07 11:08:25     1.314
+++ src/buffer.C        2002/03/07 14:15:04
@@ -1793,7 +1793,7 @@ string const Buffer::asciiParagraph(Para
                                     bool noparbreak) const
 {
        ostringstream buffer;
-       ostringstream word;
+       //ostringstream word;
        Paragraph::depth_type depth = 0;
        int ltype = 0;
        Paragraph::depth_type ltype_depth = 0;
@@ -1918,6 +1918,9 @@ string const Buffer::asciiParagraph(Para
        }
        // this is to change the linebreak to do it by word a bit more intelligent
        // hopefully! (only in the case where we have a max linelenght!) (Jug)
+
+       string word;
+       
        for (pos_type i = 0; i < par->size(); ++i) {
                char c = par->getUChar(params, i);
                switch (c) {
@@ -1926,8 +1929,8 @@ string const Buffer::asciiParagraph(Para
                        Inset const * inset = par->getInset(i);
                        if (inset) {
                                if (linelen > 0) {
-                                       buffer << word.str();
-                                       word.str("");
+                                       buffer << word;
+                                       word.erase();
                                }
                                if (inset->ascii(this, buffer, linelen)) {
                                        // to be sure it breaks paragraph
@@ -1948,8 +1951,8 @@ string const Buffer::asciiParagraph(Para
                
                case Paragraph::META_NEWLINE:
                        if (linelen > 0) {
-                               buffer << word.str() << "\n";
-                               word.str("");
+                               buffer << word << "\n";
+                               word.erase();
                                for (Paragraph::depth_type j = 0; 
                                     j < depth; ++j)
                                        buffer << "  ";
@@ -1964,25 +1967,25 @@ string const Buffer::asciiParagraph(Para
                        break;
                        
                case Paragraph::META_HFILL:
-                       buffer << word.str() << "\t";
-                       currlinelen += word.str().length() + 1;
-                       word.str("");
+                       buffer << word << "\t";
+                       currlinelen += word.length() + 1;
+                       word.erase();
                        break;
 
                default:
                        if (c == ' ') {
-                               buffer << word.str() << ' ';
-                               currlinelen += word.str().length() + 1;
-                               word.str("");
+                               buffer << word << ' ';
+                               currlinelen += word.length() + 1;
+                               word.erase();
                        } else {
                                if (c != '\0') {
-                                       word << c;
+                                       word.push_back(c);
                                } else {
                                        lyxerr[Debug::INFO] <<
                                                "writeAsciiFile: NULL char in 
structure." << endl;
                                }
                                if ((linelen > 0) &&
-                                       (currlinelen+word.str().length()) > linelen)
+                                       (currlinelen + word.length()) > linelen)
                                {
                                        buffer << "\n";
                                        for (Paragraph::depth_type j = 0; j < depth; 
++j)
@@ -2001,7 +2004,7 @@ string const Buffer::asciiParagraph(Para
                        break;
                }
        }
-       buffer << word.str();
+       buffer << word;
        return buffer.str().c_str();
 }
 

| A
>

-- 
        Lgb

Reply via email to