Program: 135891
Project: 135891
Buggy source:
/** 
 * The argument spec is the current tokenized specification, generated by the Tokenize method.  If that spec has a C-Syntax PlusCal algorithm, this method turns "(", ")", "{", and "}" tokens that are PlusCal delimiters (rather than parts of an expression) into the corresponding tokens that produce the appropriate TeX output.   A PlusCal "(" can follow the following: "macro" + IDENT "procedure" + an IDENT  "process" | "if" | "while" | "with" A PlusCal "{" other than the initial one can follow the following: a PlusCal "{" a PlusCal ")" "else" | "either" | "or" | "define" "variable[s]" [<expression> [, | ;]]^+  ";"   PCAL_LABEL
 * @param spec
 */
public static void FixPlusCal(Token[][] spec){
  if ((!hasPcal) || (!isCSyntax)) {
    return;
  }
  Position pos=pcalStart;
  while ((pos != null) && ((pos.toToken(spec).type != Token.BUILTIN) || (!pos.toToken(spec).string.equals("String_Node_Str")))) {
    pos=nextTokenPos(pos,spec);
  }
  if (pos != null) {
    ProcessPcalBrace(pos,spec);
  }
}

Fixed version (ground truth):
/** 
 * The argument spec is the current tokenized specification, generated by the Tokenize method.  If that spec has a C-Syntax PlusCal algorithm, this method turns "(", ")", "{", and "}" tokens that are PlusCal delimiters (rather than parts of an expression) into the corresponding tokens that produce the appropriate TeX output.   A PlusCal "(" can follow the following: "macro" + IDENT "procedure" + an IDENT  "process" | "if" | "while" | "with" A PlusCal "{" other than the initial one can follow the following: a PlusCal "{" a PlusCal ")" "else" | "either" | "or" | "define" "variable[s]" [<expression> [, | ;]]^+  ";"   PCAL_LABEL This method also removes an extra gray bar that can appear after the algorithm when using the -shade and -noPcalShade options.
 * @param spec
 */
public static void FixPlusCal(Token[][] spec){
  if (!hasPcal) {
    return;
  }
  if (Parameters.CommentShading && Parameters.NoPlusCalShading && (pcalEnd.line < spec.length)&& (pcalEnd.item < spec[pcalEnd.line].length)) {
    Token tok=pcalEnd.toToken(spec);
    if (tok.type == Token.COMMENT) {
      CommentToken ctok=(CommentToken)tok;
      if (ctok.string.trim().equals("String_Node_Str")) {
        int rsubtype=ctok.rsubtype;
        Token[] newline=new Token[spec[pcalEnd.line].length - 1];
        int j=0;
        for (int i=0; i < spec[pcalEnd.line].length; i++) {
          if (i != pcalEnd.item) {
            newline[j]=spec[pcalEnd.line][i];
            j++;
          }
        }
        if (rsubtype == CommentToken.NORMAL) {
          spec[pcalEnd.line]=newline;
        }
 else {
          if (rsubtype == CommentToken.BEGIN_OVERRUN) {
            Token next=spec[pcalEnd.line + 1][0];
            int nextLine=pcalEnd.line + 1;
            while ((next != null) && (next.type == CommentToken.COMMENT) && (((CommentToken)next).rsubtype == CommentToken.OVERRUN)&& (next.string.trim().equals("String_Node_Str"))) {
              nextLine++;
              if (spec[nextLine + 1].length > 0) {
                next=spec[nextLine][0];
              }
 else {
                next=null;
              }
            }
            if ((next != null) && (next.type == CommentToken.COMMENT) && (next.string.trim().equals("String_Node_Str"))&& (((CommentToken)next).rsubtype == CommentToken.END_OVERRUN)) {
              spec[pcalEnd.line]=newline;
              for (int i=pcalEnd.line + 1; i < nextLine; i++) {
                spec[i]=new Token[0];
              }
              newline=new Token[spec[nextLine].length - 1];
              System.arraycopy(spec[nextLine],1,newline,0,spec[nextLine].length - 1);
              spec[nextLine]=newline;
            }
          }
        }
      }
    }
  }
  if (!isCSyntax) {
    return;
  }
  Position pos=pcalStart;
  while ((pos != null) && ((pos.toToken(spec).type != Token.BUILTIN) || (!pos.toToken(spec).string.equals("String_Node_Str")))) {
    pos=nextTokenPos(pos,spec);
  }
  if (pos != null) {
    ProcessPcalBrace(pos,spec);
  }
}