v4.60 problem with "StrStr" (solved in mP 4.80 bèta)

Beta Testing discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

v4.60 problem with "StrStr" (solved in mP 4.80 bèta)

#1 Post by Dany » 12 Jan 2011 20:27

Hi,
according the help the function "StrStr" should return $FFFF when the search string is not found. In reality the following code makes the function return the value 11 in stead if $FFFF:

Code: Select all

  
var Wrd: word;
    Str: string[10];
...
  Str := '1234567890';
  Wrd := StrStr(Str, '012345'); // Wrd gets the value 11.
while this code gives the correct result:

Code: Select all

var Wrd: word;
    Str: string[10];
...
  Str := '123456789';
  Wrd := StrStr(Str, '012345'); // Wrd gets the value $FFFF
In the first case the source string if "filled" completely (all chars used), in the second case it is not.

Thanks in advance!
Last edited by Dany on 12 Apr 2011 19:31, edited 3 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: v4.60 problem with "StrStr" (String lib)

#2 Post by filip » 13 Jan 2011 12:00

Hi,

I have tried to reproduce this issue in the mikroPascal PRO for PIC 4.60 but had no success.
Which version of the compiler are you using ?

Regards,
Filip.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: v4.60 problem with "StrStr" (String lib)

#3 Post by Dany » 14 Jan 2011 08:17

filip wrote:Hi,

I have tried to reproduce this issue in the mikroPascal PRO for PIC 4.60 but had no success.
Which version of the compiler are you using ?

Regards,
Filip.
v4.60.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: v4.60 problem with "StrStr" (String lib)

#4 Post by Dany » 14 Jan 2011 08:34

Hi Filip,

At this moment I can not reproduce it either, I do not know why. If the problem pops up again I will try to find out more.
Sorry for the inconvenience!

I did see the problem in the simulator, did not try it in real life.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: v4.60 problem with "StrStr" (String lib) -not reproducib

#5 Post by Dany » 15 Jan 2011 10:53

Hi, I was able to reproduce the problem. Apparently the StrStr function also searches the address space following the string searched in.

The following code shows the phenomenon:

Code: Select all

var Str: string[10]; absolute $50;
    Str2: string[50]; absolute $5B; // placed right after Str1 in memory
...
  Str2 := '01234567890';
  Str := '1234567890';
  Wrd := StrStr(Str, '012345'); // function returns 11 in stead of $FFFF 
Apparently StrStr does not stop the search at the boundaries of Str1. The result returned depends on the value of Str2 also.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: v4.60 problem with "StrStr" (String lib)

#6 Post by janni » 15 Jan 2011 17:21

Indeed, the StrStr function has a flow :( . In an inner loop it doesn't check if the first string ended.

Slightly simplified example should be easier on the developers:

Code: Select all

var Wrd: word;
    Str1: string[4]; absolute $20;
    Str2: string[4]; absolute $25; // placed right after Str1 in memory

begin
  Str1:='1234';
  Str2:='412';
  Wrd:=StrStr(Str1,Str2);   // function returns 5 instead of $FFFF
...
Apparently the strings library needs a thorough check - it's a third routine with a flow (others being StrCmp - see here, and rTrim - if trimmed string is empty or consists of spaces, then preceeding it memory cell will be erased if it contains 32).

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: v4.60 problem with "StrStr" (String lib)

#7 Post by filip » 18 Jan 2011 10:39

Hi,

I have reported these issues to our developers and they will solve it as soon as possible.

I apologize for the inconvenience.

Regards,
Filip.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: v4.60 problem with "StrStr" (String lib)

#8 Post by Dany » 12 Apr 2011 19:30

Issue solved in mP 4.80 bèta, including the "rtrim" issue.

Thanks mE guys! Good work. :D :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC Beta Testing”