Program: 74677
Project: 74677
Buggy source:
/** 
 * Generate initialization code. This method first checks if "System.out" is the file parameter. If so, it reads from LineWriter.c for the <code>openForStdout</code> block, which is code for opening standard output stream.  Then, the method checks the actor's confirmOverwrite and appends parameters, reads the <code>confirmOverwrite</code>, <code>openForAppend</code>, and <code>openForWrite</code> blocks accordingly.  Then it replaces macros with their values and returns the resulting code string.
 * @return The processed code string.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generateInitializeCode() throws IllegalActionException {
  super.generateInitializeCode();
  ptolemy.actor.lib.io.LineWriter actor=(ptolemy.actor.lib.io.LineWriter)getComponent();
  _codeStream.clear();
  if (actor.fileName.getExpression().equals("String_Node_Str")) {
    _codeStream.appendCodeBlock("String_Node_Str");
  }
 else {
    String fileNameString=FileReader.getFileName(actor.fileName);
    fileNameString=FileReader.getFileName(actor.fileName);
    ArrayList args=new ArrayList();
    args.add(fileNameString);
    if (actor.confirmOverwrite.getExpression().equals("String_Node_Str")) {
      _codeStream.appendCodeBlock("String_Node_Str",args);
    }
    if (actor.append.getExpression().equals("String_Node_Str")) {
      _codeStream.appendCodeBlock("String_Node_Str",args);
    }
 else {
      _codeStream.appendCodeBlock("String_Node_Str",args);
    }
  }
  return processCode(_codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate initialization code. This method first checks if "System.out" is the file parameter. If so, it reads from LineWriter.c for the <code>openForStdout</code> block, which is code for opening standard output stream.  Then, the method checks the actor's confirmOverwrite and appends parameters, reads the <code>confirmOverwrite</code>, <code>openForAppend</code>, and <code>openForWrite</code> blocks accordingly.  Then it replaces macros with their values and returns the resulting code string.
 * @return The processed code string.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generateInitializeCode() throws IllegalActionException {
  super.generateInitializeCode();
  ptolemy.actor.lib.io.LineWriter actor=(ptolemy.actor.lib.io.LineWriter)getComponent();
  _codeStream.clear();
  if (actor.fileName.getExpression().equals("String_Node_Str")) {
    _codeStream.appendCodeBlock("String_Node_Str");
  }
 else {
    String fileNameString=FileReader.getFileName(actor.fileName);
    ArrayList args=new ArrayList();
    args.add(fileNameString);
    if (actor.confirmOverwrite.getExpression().equals("String_Node_Str")) {
      _codeStream.appendCodeBlock("String_Node_Str",args);
    }
    if (actor.append.getExpression().equals("String_Node_Str")) {
      _codeStream.appendCodeBlock("String_Node_Str",args);
    }
 else {
      _codeStream.appendCodeBlock("String_Node_Str",args);
    }
  }
  return processCode(_codeStream.toString());
}