Bug: Consecutive newlines stripped from output

Post Reply
Michael
Posts: 9
Joined: Sun Jul 05, 2009 11:19 am

Bug: Consecutive newlines stripped from output

Post by Michael »

Hey all,

New here, so I hope this is actually a bug and not already been reported (I did a quick search for "newline" but found nothing relevant).

Anyway, essentially the problem is that when I receive two newlines in a two, the second newline is stripped. I haven't tested if it continues for three or more newlines in a row, but I'm assuming the same will happen.

I've located the code causing the problem, and put in my own temporary hack-fix, as C++ is largely unfamiliar for me to implement/suggest a proper fix.

For reference, the problem is in:
void TBuffer::translateToPlainText( std::string & s ) in TBuffer.cpp. Around about line 1000 in this file, there's an if block in the routine:

Code: Select all

        if( ch == '\n' )
        {

            int line = lineBuffer.size()-1;
            mpHost->mpConsole->runTriggers( line );
            newLines += 1+wrap( line );
            std::deque<TChar> newLine;
            buffer.push_back( newLine );
            lineBuffer << nothing;
            QString time = "-----";
            timeBuffer << time;
            firstChar = true;
            msPos++;
            continue;
        }
Which seems to be causing the problem. If others are suffering the problem, the temporary fix I've done is declare:

Declare "char prevCh" near the top of the routine, before the loop. Change the code around the problem if-block to look like:

Code: Select all

        prevCh = '\0';
        if (msPos > 0) {
           prevCh = s[msPos-1];
        }

        if( ch == '\n' && prevCh != '\n')
        {

            int line = lineBuffer.size()-1;
            mpHost->mpConsole->runTriggers( line );
            newLines += 1+wrap( line );
            std::deque<TChar> newLine;
            buffer.push_back( newLine );
            lineBuffer << nothing;
            QString time = "-----";
            timeBuffer << time;
            firstChar = true;
            msPos++;
            continue;
        }
Cheers.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Bug: Consecutive newlines stripped from output

Post by Vadi »

Hey, thanks for reporting this and working on a solution.

Though, there is a bug in the current windows release where it will strip blank newlines that was fixed in git. Maybe this affects yours?

(also, bug reports are located here for future reference: https://bugs.launchpad.net/mudlet)

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Bug: Consecutive newlines stripped from output

Post by Heiko »

Hi Micheal,

thanks for your help, but you've been working with old code. The newline strip issue has been fixed about a week ago. You can find the new code on our git repositiory on mudlet.sf.net. The Mac version has been updated already, but I haven't updated the windows version yet. I'm going to do this tonight hopefully.

PS: Your bug fix proposal would break multiline and multi condition triggers, as well as linetriggers, empty line gags etc..

Michael
Posts: 9
Joined: Sun Jul 05, 2009 11:19 am

Re: Bug: Consecutive newlines stripped from output

Post by Michael »

Vadi wrote:(also, bug reports are located here for future reference: https://bugs.launchpad.net/mudlet)
That's useful to know, cheers.
Heiko wrote:Hi Micheal,

thanks for your help, but you've been working with old code. The newline strip issue has been fixed about a week ago. You can find the new code on our git repositiory on mudlet.sf.net. The Mac version has been updated already, but I haven't updated the windows version yet. I'm going to do this tonight hopefully.
Whoops, I didn't even think to check for updates. Thanks!
Heiko wrote: PS: Your bug fix proposal would break multiline and multi condition triggers, as well as linetriggers, empty line gags etc..
Yikes. >_>

Post Reply