Re: bug match_from (att: Matt)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Salix wrote:
> 
> Now that I have some more time I decided to write about the strange behaviour
> of match_from(s1,s2,i2) and find_from(x,s,i2).
> 
> }}}
<eucode>
> constant tx="Euphoria"
> ? find_from('h',tx,-8)		-- I get 4 
> ? find_from('h',tx,-9)		-- I get 0 
> ? match_from("ho",tx,-8)	-- I get 4 
> ? match_from("ho",tx,-9)	-- I get error 
> -- Note: length(tx)=8
> </eucode>
{{{

> 
> I know it is highly unexpected that somebody enters a negative number as i2
> but it happens.
> (E.g. in a loop with an always changing i2 value.)
> 
> I don't speak C but something like this could be implemented
> 
> }}}
<eucode>
> if i2<=0 then i2=1 end if
> </eucode>
{{{

> 
> or 
> 
> }}}
<eucode>
> if i2<=0 then return -1 end if
> </eucode>
{{{

> 
> Regards,
> 
> Salix

Nooooooo!!!
It is extremely useful to request a find or match from a location defined using
the end of string as reference - like for seek(). So
find_from('h',tx,-8)=find_from('h',tx,8+1-8)=4: correct
find_from('h',tx,-9)=find_from('h',tx,8+1-9)=0: perhaps an error would be better
here, or 0 always when the starting point is not greater than zero. At the very
least, find_from() and match_from() should behave the same in that case, ie both
error out or both return 0.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu