Program: 64222
Project: 64222
Buggy source:
/** 
 * this routine is actually checking all the include patterns in order to avoid scanning everything under base dir
 * @since ant1.6
 */
private void checkIncludePatterns(){
  Hashtable newroots=new Hashtable();
  for (int icounter=0; icounter < includes.length; icounter++) {
    String newpattern=SelectorUtils.rtrimWildcardTokens(includes[icounter]);
    boolean hasParent=false;
    Enumeration myenum=newroots.keys();
    Vector vdelete=new Vector();
    while (myenum.hasMoreElements()) {
      String existingpattern=(String)myenum.nextElement();
      if (existingpattern.length() >= newpattern.length()) {
        if (existingpattern.indexOf(newpattern) == 0) {
          vdelete.add(existingpattern);
        }
      }
      if (existingpattern.length() <= newpattern.length()) {
        if (newpattern.indexOf(existingpattern) == 0) {
          hasParent=true;
          break;
        }
      }
    }
    if (!hasParent) {
      newroots.put(newpattern,includes[icounter]);
      for (int icounter2=0; icounter2 < vdelete.size(); icounter2++) {
        newroots.remove(vdelete.elementAt(icounter2));
      }
    }
  }
  Enumeration enum2=newroots.keys();
  while (enum2.hasMoreElements()) {
    String currentelement=(String)enum2.nextElement();
    String originalpattern=(String)newroots.get(currentelement);
    File myfile=new File(basedir,currentelement);
    if (!myfile.exists() && !isCaseSensitive) {
      File f=findFileCaseInsensitive(basedir,currentelement);
      if (f.exists()) {
        currentelement=fileUtils.removeLeadingPath(basedir,f);
        myfile=f;
      }
    }
    if (myfile.exists()) {
      if (!followSymlinks && isSymlink(basedir,currentelement)) {
        continue;
      }
      if (myfile.isDirectory()) {
        if (isIncluded(currentelement) && currentelement.length() > 0) {
          accountForIncludedDir(currentelement,myfile,true);
        }
 else {
          if (currentelement.length() > 0) {
            if (currentelement.charAt(currentelement.length() - 1) != File.separatorChar) {
              currentelement=currentelement + File.separatorChar;
            }
          }
          scandir(myfile,currentelement,true);
        }
      }
 else {
        if (isCaseSensitive && originalpattern.equals(currentelement)) {
          accountForIncludedFile(currentelement,myfile);
        }
 else         if (!isCaseSensitive && originalpattern.equalsIgnoreCase(currentelement)) {
          accountForIncludedFile(currentelement,myfile);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * this routine is actually checking all the include patterns in order to avoid scanning everything under base dir
 * @since ant1.6
 */
private void checkIncludePatterns(){
  Hashtable newroots=new Hashtable();
  for (int icounter=0; icounter < includes.length; icounter++) {
    String newpattern=SelectorUtils.rtrimWildcardTokens(includes[icounter]);
    boolean hasParent=false;
    Enumeration myenum=newroots.keys();
    Vector vdelete=new Vector();
    while (myenum.hasMoreElements()) {
      String existingpattern=(String)myenum.nextElement();
      if (existingpattern.length() >= newpattern.length()) {
        if (existingpattern.indexOf(newpattern) == 0) {
          vdelete.add(existingpattern);
        }
      }
      if (existingpattern.length() <= newpattern.length()) {
        if (newpattern.indexOf(existingpattern) == 0) {
          hasParent=true;
          break;
        }
      }
    }
    if (!hasParent) {
      newroots.put(newpattern,includes[icounter]);
      for (int icounter2=0; icounter2 < vdelete.size(); icounter2++) {
        newroots.remove(vdelete.elementAt(icounter2));
      }
    }
  }
  Enumeration enum2=newroots.keys();
  while (enum2.hasMoreElements()) {
    String currentelement=(String)enum2.nextElement();
    String originalpattern=(String)newroots.get(currentelement);
    File myfile=new File(basedir,currentelement);
    if (Os.isFamily("String_Node_Str") && myfile.exists()) {
      try {
        myfile=myfile.getCanonicalFile();
      }
 catch (      Exception ex) {
        throw new BuildException(ex);
      }
      currentelement=fileUtils.removeLeadingPath(basedir,myfile);
    }
    if (!myfile.exists() && !isCaseSensitive) {
      File f=findFileCaseInsensitive(basedir,currentelement);
      if (f.exists()) {
        currentelement=fileUtils.removeLeadingPath(basedir,f);
        myfile=f;
      }
    }
    if (myfile.exists()) {
      if (!followSymlinks && isSymlink(basedir,currentelement)) {
        continue;
      }
      if (myfile.isDirectory()) {
        if (isIncluded(currentelement) && currentelement.length() > 0) {
          accountForIncludedDir(currentelement,myfile,true);
        }
 else {
          if (currentelement.length() > 0) {
            if (currentelement.charAt(currentelement.length() - 1) != File.separatorChar) {
              currentelement=currentelement + File.separatorChar;
            }
          }
          scandir(myfile,currentelement,true);
        }
      }
 else {
        if (isCaseSensitive && originalpattern.equals(currentelement)) {
          accountForIncludedFile(currentelement,myfile);
        }
 else         if (!isCaseSensitive && originalpattern.equalsIgnoreCase(currentelement)) {
          accountForIncludedFile(currentelement,myfile);
        }
      }
    }
  }
}