Program: 74841
Project: 74841
Buggy source:
/** 
 * Generate a makefile to that can be used to run the generated code. <p>For example, if the model is called MyModel, and this phase is called with: <pre> -p wjtp.makefileWriter targetPackage:foo.bar,outdir:c:/tmp,templateDirectory:bif </pre> Then we will create the directory c:/tmp/foo/bar/MyModel, read in $PTII/bif/makefile.in and generate c:/tmp/foo/bar/makefile.
 * @param phaseName The name of the phase, for example<code>wjtp.appletWriter</code>.
 * @param options The options Map.This transformer uses the following options: <dl> <dd>_generatorAttributeFileName <dd>The pathname to the  {@link GeneratorAttribute} that containsthe keys and values will we use to update the makefile template with. <dt>outDir <dd>The absolute path to the directory where the generated code will reside, for example: <code>c:/ptII/ptolemy/copernicus/applet/cg/Butterfly</code> <dt>overwrite <dd>Determines whether we overwrite a preexisting makefile. The default is to overwrite.  T <dt>targetPackage <dd>The package where the generated code will reside, for example: <code>ptolemy.copernicus.applet.cg.Butterfly</code> <dt>templateDirectory <dd>The directory where we should read the makefile.in file </dl>
 */
protected void internalTransform(String phaseName,Map options){
  System.out.println("String_Node_Str" + phaseName + "String_Node_Str"+ options+ "String_Node_Str");
  _generatorAttributeFileName=PhaseOptions.getString(options,"String_Node_Str");
  boolean overwrite=PhaseOptions.getBoolean(options,"String_Node_Str");
  if (_generatorAttributeFileName.length() == 0) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  }
  System.out.println("String_Node_Str" + _generatorAttributeFileName);
  GeneratorAttribute generatorAttribute=null;
  try {
    MoMLParser parser=new MoMLParser();
    CompositeActor toplevel;
    List oldFilters=parser.getMoMLFilters();
    parser.setMoMLFilters(null);
    try {
      parser.addMoMLFilters(BackwardCompatibility.allFilters());
      toplevel=(CompositeActor)parser.parse(null,new File(_generatorAttributeFileName).toURL());
    }
  finally {
      parser.setMoMLFilters(oldFilters);
    }
    generatorAttribute=(GeneratorAttribute)toplevel.getAttribute(Copernicus.GENERATOR_NAME,GeneratorAttribute.class);
    if (generatorAttribute == null) {
      System.out.println("String_Node_Str" + _generatorAttributeFileName + "String_Node_Str"+ "String_Node_Str"+ Copernicus.GENERATOR_NAME+ "String_Node_Str"+ toplevel.exportMoML());
      generatorAttribute=new GeneratorAttribute(toplevel,Copernicus.GENERATOR_NAME);
    }
  }
 catch (  Exception ex) {
    throw new InternalErrorException(_model,ex,"String_Node_Str" + "String_Node_Str");
  }
  _outputDirectory=PhaseOptions.getString(options,"String_Node_Str");
  if (!_outputDirectory.endsWith("String_Node_Str")) {
    _outputDirectory=_outputDirectory + "String_Node_Str";
  }
  File outDirFile=new File(_outputDirectory);
  if (!outDirFile.isDirectory()) {
    outDirFile.mkdirs();
  }
  _targetPackage=PhaseOptions.getString(options,"String_Node_Str");
  _templateDirectory=PhaseOptions.getString(options,"String_Node_Str");
  if (!_templateDirectory.endsWith("String_Node_Str")) {
    _templateDirectory=_templateDirectory + "String_Node_Str";
  }
  Map substituteMap;
  try {
    substituteMap=Copernicus.newMap(generatorAttribute);
    substituteMap.put("String_Node_Str",_outputDirectory);
    substituteMap.put("String_Node_Str",_targetPackage);
    substituteMap.put("String_Node_Str",_templateDirectory);
    substituteMap.putAll(_addedSubstitutions);
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(_model,ex,"String_Node_Str" + generatorAttribute);
  }
  if (overwrite || !(new File(_outputDirectory + "String_Node_Str")).isFile()) {
    try {
      System.out.println("String_Node_Str" + _templateDirectory + "String_Node_Str"+ _outputDirectory+ "String_Node_Str");
      CodeGeneratorUtilities.substitute(_templateDirectory + "String_Node_Str",substituteMap,_outputDirectory + "String_Node_Str");
    }
 catch (    Exception ex) {
      System.err.println("String_Node_Str" + ex);
      ex.printStackTrace();
      throw new InternalErrorException(_model,ex,"String_Node_Str");
    }
  }
 else {
    System.out.println("String_Node_Str" + _outputDirectory + "String_Node_Str");
  }
  BufferedReader inputFile=null;
  String obfuscateTemplate=_templateDirectory + "String_Node_Str";
  try {
    inputFile=CodeGeneratorUtilities.openAsFileOrURL(obfuscateTemplate);
  }
 catch (  IOException ex) {
    System.out.println("String_Node_Str" + "String_Node_Str" + ex);
  }
  if (inputFile != null) {
    try {
      CodeGeneratorUtilities.substitute(inputFile,substituteMap,_outputDirectory + "String_Node_Str");
    }
 catch (    Exception ex) {
      System.err.println("String_Node_Str" + ex);
      ex.printStackTrace();
      throw new InternalErrorException(_model,ex,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Generate a makefile to that can be used to run the generated code. <p>For example, if the model is called MyModel, and this phase is called with: <pre> -p wjtp.makefileWriter targetPackage:foo.bar,outdir:c:/tmp,templateDirectory:bif </pre> Then we will create the directory c:/tmp/foo/bar/MyModel, read in $PTII/bif/makefile.in and generate c:/tmp/foo/bar/makefile.
 * @param phaseName The name of the phase, for example<code>wjtp.appletWriter</code>.
 * @param options The options Map.This transformer uses the following options: <dl> <dd>_generatorAttributeFileName <dd>The pathname to the  {@link GeneratorAttribute} that containsthe keys and values will we use to update the makefile template with. <dt>outDir <dd>The absolute path to the directory where the generated code will reside, for example: <code>c:/ptII/ptolemy/copernicus/applet/cg/Butterfly</code> <dt>overwrite <dd>Determines whether we overwrite a preexisting makefile. The default is to overwrite.  T <dt>targetPackage <dd>The package where the generated code will reside, for example: <code>ptolemy.copernicus.applet.cg.Butterfly</code> <dt>templateDirectory <dd>The directory where we should read the makefile.in file </dl>
 */
protected void internalTransform(String phaseName,Map options){
  System.out.println("String_Node_Str" + phaseName + "String_Node_Str"+ options+ "String_Node_Str");
  _generatorAttributeFileName=PhaseOptions.getString(options,"String_Node_Str");
  boolean overwrite=PhaseOptions.getBoolean(options,"String_Node_Str");
  if (_generatorAttributeFileName.length() == 0) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  }
  System.out.println("String_Node_Str" + _generatorAttributeFileName);
  GeneratorAttribute generatorAttribute=null;
  try {
    MoMLParser parser=new MoMLParser();
    CompositeActor toplevel;
    List oldFilters=parser.getMoMLFilters();
    MoMLParser.setMoMLFilters(null);
    try {
      parser.addMoMLFilters(BackwardCompatibility.allFilters());
      toplevel=(CompositeActor)parser.parse(null,new File(_generatorAttributeFileName).toURL());
    }
  finally {
      MoMLParser.setMoMLFilters(oldFilters);
    }
    generatorAttribute=(GeneratorAttribute)toplevel.getAttribute(Copernicus.GENERATOR_NAME,GeneratorAttribute.class);
    if (generatorAttribute == null) {
      System.out.println("String_Node_Str" + _generatorAttributeFileName + "String_Node_Str"+ "String_Node_Str"+ Copernicus.GENERATOR_NAME+ "String_Node_Str"+ toplevel.exportMoML());
      generatorAttribute=new GeneratorAttribute(toplevel,Copernicus.GENERATOR_NAME);
    }
  }
 catch (  Exception ex) {
    throw new InternalErrorException(_model,ex,"String_Node_Str" + "String_Node_Str");
  }
  _outputDirectory=PhaseOptions.getString(options,"String_Node_Str");
  if (!_outputDirectory.endsWith("String_Node_Str")) {
    _outputDirectory=_outputDirectory + "String_Node_Str";
  }
  File outDirFile=new File(_outputDirectory);
  if (!outDirFile.isDirectory()) {
    outDirFile.mkdirs();
  }
  _targetPackage=PhaseOptions.getString(options,"String_Node_Str");
  _templateDirectory=PhaseOptions.getString(options,"String_Node_Str");
  if (!_templateDirectory.endsWith("String_Node_Str")) {
    _templateDirectory=_templateDirectory + "String_Node_Str";
  }
  Map substituteMap;
  try {
    substituteMap=CodeGeneratorUtilities.newMap(generatorAttribute);
    substituteMap.put("String_Node_Str",_outputDirectory);
    substituteMap.put("String_Node_Str",_targetPackage);
    substituteMap.put("String_Node_Str",_templateDirectory);
    substituteMap.putAll(_addedSubstitutions);
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(_model,ex,"String_Node_Str" + generatorAttribute);
  }
  if (overwrite || !(new File(_outputDirectory + "String_Node_Str")).isFile()) {
    try {
      System.out.println("String_Node_Str" + _templateDirectory + "String_Node_Str"+ _outputDirectory+ "String_Node_Str");
      CodeGeneratorUtilities.substitute(_templateDirectory + "String_Node_Str",substituteMap,_outputDirectory + "String_Node_Str");
    }
 catch (    Exception ex) {
      System.err.println("String_Node_Str" + ex);
      ex.printStackTrace();
      throw new InternalErrorException(_model,ex,"String_Node_Str");
    }
  }
 else {
    System.out.println("String_Node_Str" + _outputDirectory + "String_Node_Str");
  }
  BufferedReader inputFile=null;
  String obfuscateTemplate=_templateDirectory + "String_Node_Str";
  try {
    inputFile=CodeGeneratorUtilities.openAsFileOrURL(obfuscateTemplate);
  }
 catch (  IOException ex) {
    System.out.println("String_Node_Str" + "String_Node_Str" + ex);
  }
  if (inputFile != null) {
    try {
      CodeGeneratorUtilities.substitute(inputFile,substituteMap,_outputDirectory + "String_Node_Str");
    }
 catch (    Exception ex) {
      System.err.println("String_Node_Str" + ex);
      ex.printStackTrace();
      throw new InternalErrorException(_model,ex,"String_Node_Str");
    }
  }
}