www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - std.string.replace in 0.133

reply Steve Adams <adamss ascinet.com> writes:
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
parent reply =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.cn> writes:
-----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: to: Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDOb4o3w+/yD4P9tIRAgvVAJ4kc9JyD/oOrlL7VHMV0BdnimJWtACgxjMf V1k9K7avq/oapznSPz+LQcs= =t75a -----END PGP SIGNATURE-----
Sep 27 2005
parent Derek Parnell <derek psych.ward> writes:
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: to:
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