www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - (check) ifind

reply "Carlos Santander B." <csantander619 gmail.com> writes:
Can somebody check this, please?

//------------------------------
import std.string;
import std.stdio;

void main()
{
     char [] str1="sus mejores cortesanos. Se embarcaron en el puerto de 
Dubai y";
     char [] str2="page-break-before";
     writefln(ifind(str1,str2));
}
//------------------------------

The output I'm getting (DMD 0.112, WinXP Pro SP2) is (roll drums....) 
45, when it should be -1. Why it's happening, I have no idea. find, 
rfind, irfind seem to work ok, but not ifind.

_______________________
Carlos Santander Bernal
Feb 03 2005
next sibling parent "Regan Heath" <regan netwin.co.nz> writes:
On Thu, 03 Feb 2005 18:56:43 -0500, Carlos Santander B.  
<csantander619 gmail.com> wrote:
 Can somebody check this, please?

 //------------------------------
 import std.string;
 import std.stdio;

 void main()
 {
      char [] str1="sus mejores cortesanos. Se embarcaron en el puerto de  
 Dubai y";
      char [] str2="page-break-before";
      writefln(ifind(str1,str2));
 }
 //------------------------------

 The output I'm getting (DMD 0.112, WinXP Pro SP2) is (roll drums....)  
 45, when it should be -1.

Confirmed (DMD v0.112, compiler v0.111, WinXP Pro SP2).
 Why it's happening, I have no idea. find, rfind, irfind seem to work ok,  
 but not ifind.

Regan
Feb 03 2005
prev sibling parent reply zwang <nehzgnaw gmail.com> writes:
It's a bug in std.string (line 571 - 597.)
My quick fix goes here:

585c585
<                   break;
---
                   return i;

               return -1;

< break; ---
                   return i;

               return -1;

Carlos Santander B. wrote:
 Can somebody check this, please?
 
 //------------------------------
 import std.string;
 import std.stdio;
 
 void main()
 {
     char [] str1="sus mejores cortesanos. Se embarcaron en el puerto de 
 Dubai y";
     char [] str2="page-break-before";
     writefln(ifind(str1,str2));
 }
 //------------------------------
 
 The output I'm getting (DMD 0.112, WinXP Pro SP2) is (roll drums....) 
 45, when it should be -1. Why it's happening, I have no idea. find, 
 rfind, irfind seem to work ok, but not ifind.
 
 _______________________
 Carlos Santander Bernal

Feb 03 2005
parent zwang <nehzgnaw gmail.com> writes:
A shorter test case:  assert(ifind("00","01")<0);

BTW, find, rfind, and irfind do not have this bug as far as i see.


zwang wrote:
 It's a bug in std.string (line 571 - 597.)
 My quick fix goes here:
 
 585c585
 <                   break;
 ---
  >                   return i;
 586a587
  >               return -1;
 595c596
 <                   break;
 ---
  >                   return i;
 596a598
  >               return -1;
 
 
 
 Carlos Santander B. wrote:
 
 Can somebody check this, please?

 //------------------------------
 import std.string;
 import std.stdio;

 void main()
 {
     char [] str1="sus mejores cortesanos. Se embarcaron en el puerto 
 de Dubai y";
     char [] str2="page-break-before";
     writefln(ifind(str1,str2));
 }
 //------------------------------

 The output I'm getting (DMD 0.112, WinXP Pro SP2) is (roll drums....) 
 45, when it should be -1. Why it's happening, I have no idea. find, 
 rfind, irfind seem to work ok, but not ifind.

 _______________________
 Carlos Santander Bernal


Feb 03 2005