 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dennis Guest
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Wed Mar 09, 2005 1:46 pm Post subject: Re: StringReplace |
|
|
The combination "Closed" status with the "Need More Info" resolution
means they will not look into it, not that they fixed the bug.
I'd guess this is probably because the report doesn't have a "steps to
reproduce".
|
|
| Back to top |
|
 |
Dennis Guest
|
Posted: Wed Mar 09, 2005 2:01 pm Post subject: Re: StringReplace |
|
|
Hi Avatar
| Quote: | The combination "Closed" status with the "Need More Info" resolution
means they will not look into it, not that they fixed the bug.
|
Oh I did not see that.
| Quote: | I'd guess this is probably because the report doesn't have a "steps to
reproduce".
|
Then we better help them ;-)
Who volunteers to give them a testcase?
Regards
Dennis
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Wed Mar 09, 2005 3:23 pm Post subject: Re: StringReplace |
|
|
| Quote: | The combination "Closed" status with the "Need More Info" resolution
means they will not look into it, not that they fixed the bug.
Oh I did not see that.
I'd guess this is probably because the report doesn't have a "steps
to reproduce".
Then we better help them ;-)
Who volunteers to give them a testcase?
|
I've made a description that would probably please the debuggers. It's
included below. I haven't submitted it to QC and i wouldn't know if
it's better to post it as a new bug report or add it to the closed one.
The former has the disadvantage that it becomes a duplication, while in
the latter way it might go unnoticed because the report is closed. My
description for the issue is included below:
It appears that the StringReplace function in the SysUtils unit is
unable to handle strings containing #0 characters correctly. Text after
the first #0 character found in the string is ignored - instances of
the search string past the first #0 are not replaced.
The problem seems to be caused by the fact that StringReplace relies on
the AnsiPos function, which in turn uses AnsiStrPos. Since AnsiStrPos
operated on PChars, not on AnsiStrings, the length field of the string
is ignored and the first #0 is considered a terminator instead.
To reproduce the bug run this program:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
function StringToCharcodes(S: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(S) do
Result := Result+'#'+IntToStr(Ord(S[I]));
end;
begin
WriteLn('Resulting string 1: '+
StringToCharcodes(StringReplace(#0#1, #1, #2, [])));
WriteLn('Resulting string 2: '+
StringToCharcodes(StringReplace(#1#0, #1, #2, [])));
ReadLn;
end.
It will (at least on Delphi 7) produce the following output:
Resulting string 1: #0#1
Resulting string 2: #2#0
This #1 is not replaced in the first string, even though it should have
been.
|
|
| Back to top |
|
 |
Dennis Guest
|
Posted: Wed Mar 09, 2005 3:42 pm Post subject: Re: StringReplace |
|
|
Hi Avatar
Very nice and thank you.
Perhaps some SysOp will insert your test into the report and reopen it.
Regards
Dennis
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Wed Mar 09, 2005 4:18 pm Post subject: Re: StringReplace |
|
|
| Quote: | Very nice and thank you.
Perhaps some SysOp will insert your test into the report and reopen
it.
|
I don't think those SysOps read the newsgroups searching for bug
reports, so i submitted it. I added it as a seperate report, including
references to the other report in both reports.
http://qc.borland.com/wc/qcmain.aspx?d=11265
|
|
| Back to top |
|
 |
Dennis Guest
|
Posted: Wed Mar 09, 2005 4:51 pm Post subject: Re: StringReplace |
|
|
Hi Avatar
Super duper.
Thanks for helping me.
Regards
Dennis
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|