digitalmars.D.bugs - std.string.replace in 0.133
- Steve Adams <adamss ascinet.com> Sep 27 2005
- =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.cn> Sep 27 2005
- Derek Parnell <derek psych.ward> Sep 27 2005
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 );
}
Sep 27 2005
-----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; Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDOb4o3w+/yD4P9tIRAgvVAJ4kc9JyD/oOrlL7VHMV0BdnimJWtACgxjMf V1k9K7avq/oapznSPz+LQcs= =t75a -----END PGP SIGNATURE-----
Sep 27 2005
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
Sep 27 2005








Derek Parnell <derek psych.ward>