Herbert Voss <[EMAIL PROTECTED]> writes:

| Lars Gullik Bjønnes wrote:
>
>> John Levon <[EMAIL PROTECTED]> writes:
>> | On Tue, Mar 05, 2002 at 01:35:22PM +0100, Lars Gullik Bjønnes
>> wrote:
>>
>>>>anyway... imagine what happens here if data does not contain a '=' or
>>>>if data is empty.
>>>>
>>>>biblio.C: 356
>>>>data = data.substr(data.find('='), data.length() - 1);
>
|  >>>
>
>> | I've never understood why the STL can't handle this, it causes so much
>> | more typing ...
>> In this case you should think about what you are doing...
>> do you want a substring _or_ do you want to get rid of part of the
>> string...
>
>
| where is the difference?

In intent?
code clearity?
effectiveness?

>> data.erase(data.find('='), string::npos));
>
>
| is better than substr because it causes no out of range exception.
| -> the only difference ...

false. it also creates no temporaries, and requires no reallocations.
I addition to that it clearly shows the intent with the code: to erase
every thing after '='. The substr does not do that.


| If we have a "real" bibtex entry there is always a "=". The problem
| was, that parseBibtex() was called without any need. The lyxlayout
| "Bibliography" is far different to bibtex entries.

What it there is a bug in the line you are trying to parse?

-- 
        Lgb

Reply via email to