Program: 74731
Project: 74731
Buggy source:
/** 
 * Process the specified code, replacing macros with their values.
 * @param code The code to process.
 * @return The processed code.
 * @exception IllegalActionException If illegal macro names are found.
 */
public String processCode(String code) throws IllegalActionException {
  StringBuffer result=new StringBuffer();
  int currentPos=code.indexOf("String_Node_Str");
  if (currentPos < 0) {
    return code;
  }
  result.append(code.substring(0,currentPos));
  while (currentPos < code.length()) {
    int openParenIndex=code.indexOf("String_Node_Str",currentPos + 1);
    int closeParenIndex=_findCloseParen(code,openParenIndex);
    if (closeParenIndex < 0) {
      result.append(code.substring(currentPos));
      return result.toString();
    }
    int nextPos=code.indexOf("String_Node_Str",closeParenIndex + 1);
    if (nextPos < 0) {
      nextPos=code.length();
    }
    String subcode=code.substring(currentPos,nextPos);
    if ((currentPos > 0) && (code.charAt(currentPos - 1) == '\\')) {
      result.append(subcode);
      currentPos=nextPos;
      continue;
    }
    String macro=code.substring(currentPos + 1,openParenIndex);
    macro=macro.trim();
    if (!CodeGenerator._macros.contains(macro)) {
      result.append(subcode);
    }
 else {
      String name=code.substring(openParenIndex + 1,closeParenIndex);
      name=name.trim();
      if (macro.equals("String_Node_Str")) {
        result.append(getReference(name));
      }
 else       if (macro.equals("String_Node_Str")) {
        TypedIOPort port=getPort(name);
        if (port == null) {
          throw new IllegalActionException(name + "String_Node_Str");
        }
        result.append(cType(port.getType()));
      }
 else       if (macro.equals("String_Node_Str") || macro.equals("String_Node_Str")) {
        TypedIOPort port=getPort(name);
        if (port == null) {
          throw new IllegalActionException(name + "String_Node_Str");
        }
        if (macro.equals("String_Node_Str")) {
          result.append("String_Node_Str");
        }
        result.append(codeGenType(port.getType()));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getParameterValue(name,_component));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getSize(name));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(generateName(_component));
        result.append("String_Node_Str" + name);
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(_component.getClassName().replace('.','_'));
        result.append("String_Node_Str" + name);
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getNewInvocation(name));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getFunctionInvocation(name,false));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getFunctionInvocation(name,true));
      }
 else {
        throw new IllegalActionException("String_Node_Str");
      }
      result.append(code.substring(closeParenIndex + 1,nextPos));
    }
    currentPos=nextPos;
  }
  return result.toString();
}

Fixed version (ground truth):
/** 
 * Process the specified code, replacing macros with their values.
 * @param code The code to process.
 * @return The processed code.
 * @exception IllegalActionException If illegal macro names are found.
 */
public String processCode(String code) throws IllegalActionException {
  StringBuffer result=new StringBuffer();
  int currentPos=code.indexOf("String_Node_Str");
  if (currentPos < 0) {
    return code;
  }
  result.append(code.substring(0,currentPos));
  while (currentPos < code.length()) {
    int openParenIndex=code.indexOf("String_Node_Str",currentPos + 1);
    int closeParenIndex=_findCloseParen(code,openParenIndex);
    if (closeParenIndex < 0) {
      result.append(code.substring(currentPos));
      return result.toString();
    }
    int nextPos=code.indexOf("String_Node_Str",closeParenIndex + 1);
    if (nextPos < 0) {
      nextPos=code.length();
    }
    String subcode=code.substring(currentPos,nextPos);
    if ((currentPos > 0) && (code.charAt(currentPos - 1) == '\\')) {
      result.append(subcode);
      currentPos=nextPos;
      continue;
    }
    String macro=code.substring(currentPos + 1,openParenIndex);
    macro=macro.trim();
    if (!CodeGenerator._macros.contains(macro)) {
      result.append(subcode.substring(0,1));
      result.append(processCode(subcode.substring(1)));
    }
 else {
      String name=code.substring(openParenIndex + 1,closeParenIndex);
      name=name.trim();
      if (macro.equals("String_Node_Str")) {
        result.append(getReference(name));
      }
 else       if (macro.equals("String_Node_Str")) {
        TypedIOPort port=getPort(name);
        if (port == null) {
          throw new IllegalActionException(name + "String_Node_Str");
        }
        result.append(cType(port.getType()));
      }
 else       if (macro.equals("String_Node_Str") || macro.equals("String_Node_Str")) {
        TypedIOPort port=getPort(name);
        if (port == null) {
          throw new IllegalActionException(name + "String_Node_Str");
        }
        if (macro.equals("String_Node_Str")) {
          result.append("String_Node_Str");
        }
        result.append(codeGenType(port.getType()));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getParameterValue(name,_component));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getSize(name));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(generateName(_component));
        result.append("String_Node_Str" + name);
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(_component.getClassName().replace('.','_'));
        result.append("String_Node_Str" + name);
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getNewInvocation(name));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getFunctionInvocation(name,false));
      }
 else       if (macro.equals("String_Node_Str")) {
        result.append(getFunctionInvocation(name,true));
      }
 else {
        throw new IllegalActionException("String_Node_Str");
      }
      result.append(code.substring(closeParenIndex + 1,nextPos));
    }
    currentPos=nextPos;
  }
  return result.toString();
}