← Back to team overview

kicad-developers team mailing list archive

Re: bug in numeric_evaluator?

 

Ah, right, I misread it.  In the while condition isdigit() and isDecSep() will both return false for \0 and thereby exit the loop.  It’s just a typo introduced when the new isDecSep() was implemented.

That’s pretty funny that it works.

Thanks for the clarification, Michael.

Cheers,
Jeff.



> On 13 Mar 2018, at 11:44, Michael Geselbracht <mgeselbracht3@xxxxxxxxx> wrote:
> 
> It is a bug/typo that just happens to work. There is no need to check for \0. There used to be a comparison like "ch == clDecSep". Ugly but it should be safe for now.
> 
> if( isDecSep( ch ) && sepCount )
>    break;
> 
> should do the trick.
> 
>  - Michael
> 
> 
> On Tue, Mar 13, 2018 at 11:10 AM, Jeff Young <jeff@xxxxxxxxx <mailto:jeff@xxxxxxxxx>> wrote:
> Yuck.  It’s clever code all right.  The “correct” version would be:
> 
> if( !ch || ( isDecSep( ch ) && sepCount ) )
>    break;
> 
> but it’s a whole 3 characters longer. ;)
> 
> I’ll fix this in my 6.0 tree (which already has libeval re-formatted to Kicad standards), but I suggest we leave it sleeping for 5.0.
> 
> Cheers,
> Jeff.
> 
> 
>> On 13 Mar 2018, at 02:20, Jon Evans <jon@xxxxxxxxxxxxx <mailto:jon@xxxxxxxxxxxxx>> wrote:
>> 
>> +Michael
>> 
>> This looks like "clever" code so I can't tell if this is a bug or not without running through a bunch of test cases which I'm not going to do right now.
>> Do you see any issues with the operation of the code, Mark, or just the warning?
>> 
>> -Jon
>> 
>> On Mon, Mar 12, 2018 at 9:28 PM, Mark Roszko <mark.roszko@xxxxxxxxx <mailto:mark.roszko@xxxxxxxxx>> wrote:
>> Not sure where to even begin looking at libeval since it looks scary but MSVC complains:
>> 
>> D:\kicad-source-mirror\common\libeval\numeric_evaluator.cpp(216): warning C4805: '==': unsafe mix of type 'char' and type 'bool' in operation
>> 
>> which is:
>> 
>>       auto ch = clToken.input[clToken.pos];
>>       do {
>>          if (ch == isDecSep(ch) && sepCount) break;
>> 
>> 
>> ch is a char
>> 
>> isDecSep returns bool
>> 
>> char == bool?
>> 
>> 
>> 
>> -- 
>> Mark
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>> 
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
> 
> 


References