www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D - [bug] Using a single-character string in std.string.rfind

Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I found a problem in std.string.rfind when a single-character string is 
used, an "Error: ArrayBoundsError string(413)" is produced.  I know if I 
used a character literal the problem goes away, but I still think this 
is a hole that should be plugged.

I came up with a two-line fix for rfind(char[], char[]) in string.d that 
might be a good way to fix it:

	if (sub.length == 1)
		return rfind(s, sub[0]);


I'm sure there's another way to fix it, but this is the first one I found.

The file rfind_char.d shows the Phobos problem, and when it's compiled 
with "-version=fix", my fix is shown.

-- 
Justin
http://jcc_7.tripod.com/d/
Dec 21 2003