Thread overview | |||||
---|---|---|---|---|---|
|
September 27, 2005 std.string.replace in 0.133 | ||||
---|---|---|---|---|
| ||||
This works in prior releases. When compiled and run with dmd -w, this causes an access violation. import std.string; int main() { // change " YYY" to " YYY" and it runs char[] s = replace( std.string.toupper( "xxx" ), " YYY", "" ); return( 0 ); } |
September 27, 2005 Re: std.string.replace in 0.133 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Adams Attachments: | Steve Adams schrieb:
> This works in prior releases. When compiled and run with dmd -w, this causes an access violation.
>
>
> import std.string;
> int main()
> {
> // change " YYY" to " YYY" and it runs
> char[] s = replace( std.string.toupper( "xxx" ), " YYY", "" );
> return( 0 );
> }
FIX: std/string.d -> ifind (line 596)
from:
# size_t imax = s.length - sublength + 1;
to:
# size_t imax;
# if(s.length + 1 > sublength)
# imax = (s.length + 1) - sublength;
Thomas
|
September 27, 2005 Re: std.string.replace in 0.133 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | On Tue, 27 Sep 2005 23:48:24 +0200, Thomas Kühne wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Steve Adams schrieb: > >> This works in prior releases. When compiled and run with dmd -w, this causes an access violation. >> >> import std.string; >> int main() >> { >> // change " YYY" to " YYY" and it runs >> char[] s = replace( std.string.toupper( "xxx" ), " YYY", "" ); >> return( 0 ); >> } > > FIX: std/string.d -> ifind (line 596) > > from: > # size_t imax = s.length - sublength + 1; > > to: > # size_t imax; > # if(s.length + 1 > sublength) > # imax = (s.length + 1) - sublength; > Could that 'fix' also be if (sublength > s.length) return -1; on basis that if the substring is longer than the string, then the string cannot contain the substring. -- Derek (skype: derek.j.parnell) Melbourne, Australia 28/09/2005 8:44:34 AM |
Copyright © 1999-2021 by the D Language Foundation