Program: 135985
Project: 135985
Buggy source:
/** 
 * Added by LL on 30 Jan 2006.                                           * Generate TLA+ for the `either' statement.  This performs the same     sort of hackery as for the `if' statement, necessitated by the        design flaw commented on above.                                      
 */
private void GenEither(AST.Either ast,Changed c,String context,String prefix,int col) throws PcalTLAGenException {
  Changed allC=new Changed(c);
  Changed[] cOrs=new Changed[ast.ors.size()];
  int[] ucLocs=new int[ast.ors.size()];
  StringBuffer sb=new StringBuffer(prefix);
  int prefixIndent=sb.length();
  sb.append("String_Node_Str");
  int here=sb.length();
  for (int i=0; i < ast.ors.size(); i++) {
    if (i != 0) {
      sb=new StringBuffer(NSpaces(prefixIndent) + "String_Node_Str");
    }
    ;
    sb.append("String_Node_Str");
    Vector orClause=(Vector)ast.ors.elementAt(i);
    Changed cC=new Changed(c);
    for (int j=0; j < orClause.size(); j++) {
      GenStmt((AST)orClause.elementAt(j),cC,context,sb.toString(),here);
      sb=new StringBuffer(NSpaces(here) + "String_Node_Str");
    }
    ;
    cOrs[i]=cC;
    allC.Merge(cC);
    ucLocs[i]=tlacode.size();
    tlacode.addElement("String_Node_Str");
  }
  ;
  int i=ast.ors.size();
  while (i > 0) {
    i=i - 1;
    tlacode.removeElementAt(ucLocs[i]);
    int numUnchanged=cOrs[i].NumUnchanged(allC);
    String NotChanged=cOrs[i].Unchanged(allC);
    if (numUnchanged > 1) {
      tlacode.insertElementAt(NSpaces(here) + "String_Node_Str" + NotChanged+ "String_Node_Str",ucLocs[i]);
    }
 else     if (numUnchanged == 1) {
      tlacode.insertElementAt(NSpaces(here) + "String_Node_Str" + NotChanged,ucLocs[i]);
    }
  }
  ;
  c.Merge(allC);
}

Fixed version (ground truth):
/** 
 * Added by LL on 30 Jan 2006.                                           * Generate TLA+ for the `either' statement.  This performs the same     sort of hackery as for the `if' statement, necessitated by the        design flaw commented on above.                                      
 */
private void GenEither(AST.Either ast,Changed c,String context,String prefix,int col) throws PcalTLAGenException {
  Changed allC=new Changed(c);
  Changed[] cOrs=new Changed[ast.ors.size()];
  int[] ucLocs=new int[ast.ors.size()];
  StringBuffer sb=new StringBuffer(prefix);
  int prefixIndent=sb.length();
  sb.append("String_Node_Str");
  int here=sb.length();
  for (int i=0; i < ast.ors.size(); i++) {
    if (i != 0) {
      sb=new StringBuffer(NSpaces(prefixIndent) + "String_Node_Str");
    }
    ;
    sb.append("String_Node_Str");
    Vector orClause=(Vector)ast.ors.elementAt(i);
    Changed cC=new Changed(c);
    for (int j=0; j < orClause.size(); j++) {
      GenStmt((AST)orClause.elementAt(j),cC,context,sb.toString(),here + 3);
      sb=new StringBuffer(NSpaces(here) + "String_Node_Str");
    }
    ;
    cOrs[i]=cC;
    allC.Merge(cC);
    ucLocs[i]=tlacode.size();
    tlacode.addElement("String_Node_Str");
  }
  ;
  int i=ast.ors.size();
  while (i > 0) {
    i=i - 1;
    tlacode.removeElementAt(ucLocs[i]);
    int numUnchanged=cOrs[i].NumUnchanged(allC);
    String NotChanged=cOrs[i].Unchanged(allC);
    if (numUnchanged > 1) {
      tlacode.insertElementAt(NSpaces(here) + "String_Node_Str" + NotChanged+ "String_Node_Str",ucLocs[i]);
    }
 else     if (numUnchanged == 1) {
      tlacode.insertElementAt(NSpaces(here) + "String_Node_Str" + NotChanged,ucLocs[i]);
    }
  }
  ;
  c.Merge(allC);
}