On Friday 09 August 2002 10:39 am, Martin Vermeer wrote:
> On Thu, Aug 08, 2002 at 07:15:23PM +0100, John Levon wrote:
> > On Thu, Aug 08, 2002 at 01:26:32PM +0100, Angus Leeming wrote:
> > > Kornel Benko sent me this file because we thought that the crash was
> > > caused by the previewing. However, I can't load it at all with current,
> > > with or without previews enabled. Since it is chock full of equations
> > > and little else, I thought André might like a look ;-)
>
> ...
>
> > ==9208==
> > ==9208== Conditional jump or move depends on uninitialised value(s)
> > ==9208==    at 0x80C94FD: ??? (/usr/include/g++-3/std/bastring.cc:249)
> > ==9208==    by 0x80C907B: ??? (/usr/include/g++-3/std/bastring.h:352)
> > ==9208==    by 0x80C7A00: Counters::reset(basic_string<char,
> > string_char_traits<char>, __default_alloc_template<true, 0> > const &)
> > (counters.C:206) ==9208==    by 0x81387FB: LyXText::setCounter(Buffer
> > const *, Paragraph *) const (text2.C:1235) ==9208==
> > ==9208== Conditional jump or move depends on uninitialised value(s)
> > ==9208==    at 0x80C94FD: ??? (/usr/include/g++-3/std/bastring.cc:249)
> > ==9208==    by 0x80C907B: ??? (/usr/include/g++-3/std/bastring.h:352)
> > ==9208==    by 0x80C7AD0: Counters::copy(Counters &, Counters &,
> > basic_string<char, string_char_traits<char>,
> > __default_alloc_template<true, 0> > const &) (counters.C:216)
> > ==9208==    by 0x81386A2: LyXText::setCounter(Buffer const *, Paragraph
> > *) const (text2.C:1225)
> >
> > Andre ? Martin ?
>
> Seems correct to me. The first dozen lines or so in LyXText::setCounter
> are: if a par has no previous(), it resets its counter array, otherwise it
> copies the one of its predecessor. Should cover all cases.
>
> Inside Counters::reset and copy, I don't see it either. What should be
> undefined? match, if it is the empty string? To my eyes, it looks OK.
> Or is perhaps .find() not supposed to have an empty arg?

It doesn't, it has a string argument that just happens to be empty. That's 
fine and string::find will return string::npos (for which you already test).

That is assuming that you haven't populated your map with an empty string() 
as an index...

Incidentally, why not:

void Counters::reset(string const & match)
{
        CounterList::iterator it = counterList.begin();
        CounterList::iterator end = counterList.end();
        if (match.empty()) {
                for (; it != end; ++it) {
                        it->second.reset();
                }
        } else {
                for (; it != end; ++it) {
                        if (it->first.find(match) != string::npos)
                                it->second.reset();
                }
        }
}

And whether you choose to use two loops or one, that should be match.empty(), 
not match == "". 

If you choose to remain with a single loop then you should also move the 
match.empty() test to the front of the if statement as it's quicker than 
find... (I believe that they're executed in order).

Angus

Reply via email to