1. bug match_from (att: Matt)
- Posted by Salix <salix at ?reemail?hu> Jul 25, 2007
- 544 views
What is the expected output?
constant tx="Euphoria" ? match_from("ho",tx,-1) ? match_from("ho",tx,-9)
Regards, Salix
2. Re: bug match_from (att: Matt)
- Posted by Salix <salix at ?reemail.hu> Jul 25, 2007
- 554 views
- Last edited Jul 26, 2007
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).
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
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
if i2<=0 then i2=1 end if
or
if i2<=0 then return -1 end if
Regards, Salix
3. Re: bug match_from (att: Matt)
- Posted by CChris <christian.cuvier at agriculture.?ouv?fr> Jul 26, 2007
- 549 views
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