Program: 101725
Project: 101725
Buggy source:
/** 
 * Convenience method to generate a Vector of SearchWords
 * @param sought The text to parse
 * @param commands The Hashtable of SearchWords to select from
 * @return A List of selected SearchWords
 */
public static List tokenize(String sought,Map commands) throws BookException {
  List output=new ArrayList();
  String commandChars=getSingleCharWords(commands);
  int currentType=charType(sought.charAt(0),commandChars);
  int startIndex=0;
  if (sought.length() > 0 && sought.charAt(0) == '[') {
    sought="String_Node_Str" + sought;
  }
  for (int i=1; i <= sought.length(); i++) {
    if (i != sought.length() && sought.charAt(i) == '[') {
      int end=sought.indexOf(']',i);
      if (end == -1) {
        throw new BookException(Msg.UNMATCHED_ESCAPE);
      }
      addWord(output,commands,"String_Node_Str");
      addWord(output,commands,sought.substring(i + 1,end));
      addWord(output,commands,"String_Node_Str");
      currentType=CHAR_SPACE;
      i=end + 1;
    }
    if (i < sought.length() - 4 && sought.indexOf("String_Node_Str",i) != -1) {
      int end=sought.indexOf("String_Node_Str",i + 2);
      if (end == -1) {
        addWord(output,commands,sought.substring(i + 1));
        i=sought.length();
      }
 else {
        addWord(output,commands,sought.substring(i + 1,end));
        i=end + 2;
      }
      currentType=CHAR_SPACE;
    }
    if (i == sought.length()) {
      if (currentType != CHAR_SPACE) {
        addWord(output,commands,sought.substring(startIndex));
      }
    }
 else {
      int new_type=charType(sought.charAt(i),commandChars);
      if (currentType != new_type || new_type == CHAR_COMMAND) {
        if (currentType != CHAR_SPACE) {
          addWord(output,commands,sought.substring(startIndex,i));
        }
        startIndex=i;
        currentType=charType(sought.charAt(i),commandChars);
      }
    }
  }
  return output;
}

Fixed version (ground truth):
/** 
 * Convenience method to generate a Vector of SearchWords
 * @param sought The text to parse
 * @param commands The Hashtable of SearchWords to select from
 * @return A List of selected SearchWords
 */
public static List tokenize(String sought,Map commands) throws BookException {
  List output=new ArrayList();
  String commandChars=getSingleCharWords(commands);
  char firstChar=sought.charAt(0);
  int currentType=charType(firstChar,commandChars);
  int startIndex=0;
  if (sought.length() > 0 && (firstChar == '[' || firstChar == ':')) {
    sought=' ' + sought;
  }
  for (int i=1; i <= sought.length(); i++) {
    if (i != sought.length() && sought.charAt(i) == '[') {
      int end=sought.indexOf(']',i);
      if (end == -1) {
        throw new BookException(Msg.UNMATCHED_ESCAPE);
      }
      addWord(output,commands,"String_Node_Str");
      addWord(output,commands,sought.substring(i + 1,end));
      addWord(output,commands,"String_Node_Str");
      currentType=CHAR_SPACE;
      i=end + 1;
    }
    if (i < sought.length() - 4 && sought.indexOf("String_Node_Str",i) == i) {
      int end=sought.indexOf("String_Node_Str",i + 2);
      if (end == -1) {
        addWord(output,commands,sought.substring(i + 2));
        i=sought.length();
      }
 else {
        addWord(output,commands,sought.substring(i + 1,end));
        i=end + 2;
      }
      currentType=CHAR_SPACE;
    }
    if (i == sought.length()) {
      if (currentType != CHAR_SPACE) {
        addWord(output,commands,sought.substring(startIndex));
      }
    }
 else {
      int new_type=charType(sought.charAt(i),commandChars);
      if (currentType != new_type || new_type == CHAR_COMMAND) {
        if (currentType != CHAR_SPACE) {
          addWord(output,commands,sought.substring(startIndex,i));
        }
        startIndex=i;
        currentType=charType(sought.charAt(i),commandChars);
      }
    }
  }
  return output;
}