Program: 135989
Project: 135989
Buggy source:
/** 
 * Processes the command line arguments This method changes values of public static variables of the   {@link PcalParams} SZ: This will cause problems, due to the fact that the PCalParams are static. Any initialization should overwrite the previous, which is currently NOT the case Should be re-factored to non-static access to the properties
 * @return status of processing. the status  {@link trans#STATUS_OK} indicates that no errors has been detected.the status  {@link trans#STATUS_EXIT_WITHOUT_ERROR} indicates that no errors has been found but translationshould not be started (e.G -help call) the status  {@link trans#STATUS_EXIT_WITH_ERRORS} indicates errors Change made on 9 December 2009 for pcal-file input.  This procedure is called a second time if there is pcal-file input with an options statement. It will be the second call iff  {@link PcalParams#optionsInFile} equals true.The second call should have a dummy extra argument in place of the  command-line's file-name argument.
 */
static int parseAndProcessArguments(String[] args){
  boolean inFile=PcalParams.optionsInFile;
  boolean notInFile=!inFile;
  boolean firstFairness=inFile;
  int nextArg=0;
  int maxArg=args.length - 1;
  if (maxArg < 0) {
    return CommandLineError("String_Node_Str");
  }
  if (notInFile && (args[maxArg].length() != 0) && (args[maxArg].charAt(0) == '-')) {
    if (OutputHelpMessage()) {
      return STATUS_EXIT_WITHOUT_ERROR;
    }
 else {
      return STATUS_EXIT_WITH_ERRORS;
    }
  }
  while (nextArg < maxArg) {
    String option=args[nextArg];
    if (notInFile && option.equals("String_Node_Str")) {
      if (OutputHelpMessage()) {
        return STATUS_EXIT_WITHOUT_ERROR;
      }
 else {
        return STATUS_EXIT_WITH_ERRORS;
      }
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.WriteASTFlag=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.SpecOption=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.MyspecOption=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.Spec2Option=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      ;
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.Myspec2Option=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      ;
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.Debug=true;
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      System.setProperty("String_Node_Str","String_Node_Str");
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      PcalParams.CheckTermination=true;
    }
 else     if (option.equals("String_Node_Str")) {
      PcalParams.Nocfg=true;
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      PcalParams.LabelFlag=true;
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.ReportLabelsFlag=true;
      PcalParams.LabelFlag=true;
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.LabelRoot=args[nextArg];
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      if (!PcalParams.ProcessVersion(args[nextArg])) {
        return CommandLineError("String_Node_Str");
      }
    }
 else     if (option.equals("String_Node_Str")) {
      nextArg=nextArg + 1;
      try {
        if (nextArg == maxArg) {
          throw new NumberFormatException();
        }
        PcalParams.SpecFile=args[nextArg];
        int a=new Integer("String_Node_Str").intValue();
        if (a < 60) {
          throw new NumberFormatException();
        }
        PcalTLAGen.wrapColumn=a;
        PcalTLAGen.ssWrapColumn=a - 33;
      }
 catch (      Exception e) {
        return CommandLineError("String_Node_Str");
      }
    }
 else {
      if (notInFile) {
        return CommandLineError("String_Node_Str" + option);
      }
 else {
        return CommandLineError("String_Node_Str" + option);
      }
    }
    ;
    nextArg=nextArg + 1;
  }
  if (nextArg > maxArg) {
    return CommandLineError("String_Node_Str");
  }
  if (inFile) {
    return STATUS_OK;
  }
  File file=new File(args[maxArg]);
  boolean hasExtension=false;
  if (file.getName().lastIndexOf("String_Node_Str") == -1) {
    PcalParams.TLAInputFile=file.getPath();
  }
 else {
    if (file.getName().toLowerCase().endsWith("String_Node_Str")) {
      hasExtension=true;
    }
 else {
      return CommandLineError("String_Node_Str" + "String_Node_Str");
    }
  }
  if (hasExtension) {
    PcalParams.TLAInputFile=file.getPath().substring(0,file.getPath().lastIndexOf("String_Node_Str"));
    if (!file.exists()) {
      return CommandLineError("String_Node_Str" + file.getPath() + "String_Node_Str");
    }
  }
 else {
    file=new File(PcalParams.TLAInputFile + "String_Node_Str");
    if (!file.exists()) {
      return CommandLineError("String_Node_Str" + PcalParams.TLAInputFile + "String_Node_Str"+ file.getPath()+ "String_Node_Str");
    }
  }
  if (PcalParams.FairnessOption.equals("String_Node_Str")) {
    PcalParams.FairnessOption="String_Node_Str";
  }
 else {
    if (PcalParams.CheckTermination && PcalParams.FairnessOption.equals("String_Node_Str")) {
      PcalParams.FairnessOption="String_Node_Str";
    }
  }
  return STATUS_OK;
}

Fixed version (ground truth):
/** 
 * Processes the command line arguments This method changes values of public static variables of the   {@link PcalParams} SZ: This will cause problems, due to the fact that the PCalParams are static. Any initialization should overwrite the previous, which is currently NOT the case Should be re-factored to non-static access to the properties
 * @return status of processing. the status  {@link trans#STATUS_OK} indicates that no errors has been detected.the status  {@link trans#STATUS_EXIT_WITHOUT_ERROR} indicates that no errors has been found but translationshould not be started (e.G -help call) the status  {@link trans#STATUS_EXIT_WITH_ERRORS} indicates errors Change made on 9 December 2009 for pcal-file input.  This procedure is called a second time if there is pcal-file input with an options statement. It will be the second call iff  {@link PcalParams#optionsInFile} equals true.The second call should have a dummy extra argument in place of the  command-line's file-name argument.
 */
static int parseAndProcessArguments(String[] args){
  boolean inFile=PcalParams.optionsInFile;
  boolean notInFile=!inFile;
  boolean firstFairness=inFile;
  boolean explicitNof=false;
  int nextArg=0;
  int maxArg=args.length - 1;
  if (maxArg < 0) {
    return CommandLineError("String_Node_Str");
  }
  if (notInFile && (args[maxArg].length() != 0) && (args[maxArg].charAt(0) == '-')) {
    if (OutputHelpMessage()) {
      return STATUS_EXIT_WITHOUT_ERROR;
    }
 else {
      return STATUS_EXIT_WITH_ERRORS;
    }
  }
  while (nextArg < maxArg) {
    String option=args[nextArg];
    if (notInFile && option.equals("String_Node_Str")) {
      if (OutputHelpMessage()) {
        return STATUS_EXIT_WITHOUT_ERROR;
      }
 else {
        return STATUS_EXIT_WITH_ERRORS;
      }
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.WriteASTFlag=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.SpecOption=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.MyspecOption=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.Spec2Option=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      ;
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.Myspec2Option=true;
      if (CheckForConflictingSpecOptions()) {
        return STATUS_EXIT_WITH_ERRORS;
      }
      ;
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.SpecFile=args[nextArg];
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.Debug=true;
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      System.setProperty("String_Node_Str","String_Node_Str");
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      PcalParams.CheckTermination=true;
    }
 else     if (option.equals("String_Node_Str")) {
      PcalParams.Nocfg=true;
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      if (firstFairness) {
        PcalParams.FairnessOption="String_Node_Str";
        firstFairness=false;
      }
      if (!PcalParams.FairnessOption.equals("String_Node_Str")) {
        return CommandLineError("String_Node_Str" + "String_Node_Str");
      }
      PcalParams.FairnessOption="String_Node_Str";
      explicitNof=true;
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      PcalParams.LabelFlag=true;
    }
 else     if (notInFile && option.equals("String_Node_Str")) {
      PcalParams.ReportLabelsFlag=true;
      PcalParams.LabelFlag=true;
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      PcalParams.LabelRoot=args[nextArg];
    }
 else     if (option.equals("String_Node_Str") || (inFile && option.equals("String_Node_Str"))) {
      nextArg=nextArg + 1;
      if (nextArg == maxArg) {
        return CommandLineError("String_Node_Str");
      }
      if (!PcalParams.ProcessVersion(args[nextArg])) {
        return CommandLineError("String_Node_Str");
      }
    }
 else     if (option.equals("String_Node_Str")) {
      nextArg=nextArg + 1;
      try {
        if (nextArg == maxArg) {
          throw new NumberFormatException();
        }
        PcalParams.SpecFile=args[nextArg];
        int a=new Integer("String_Node_Str").intValue();
        if (a < 60) {
          throw new NumberFormatException();
        }
        PcalTLAGen.wrapColumn=a;
        PcalTLAGen.ssWrapColumn=a - 33;
      }
 catch (      Exception e) {
        return CommandLineError("String_Node_Str");
      }
    }
 else {
      if (notInFile) {
        return CommandLineError("String_Node_Str" + option);
      }
 else {
        return CommandLineError("String_Node_Str" + option);
      }
    }
    ;
    nextArg=nextArg + 1;
  }
  if (nextArg > maxArg) {
    return CommandLineError("String_Node_Str");
  }
  if (PcalParams.FairnessOption.equals("String_Node_Str")) {
    PcalParams.FairnessOption="String_Node_Str";
  }
  if (PcalParams.CheckTermination && PcalParams.FairnessOption.equals("String_Node_Str") && !explicitNof) {
    PcalParams.FairnessOption="String_Node_Str";
  }
  if (inFile) {
    return STATUS_OK;
  }
  File file=new File(args[maxArg]);
  boolean hasExtension=false;
  if (file.getName().lastIndexOf("String_Node_Str") == -1) {
    PcalParams.TLAInputFile=file.getPath();
  }
 else {
    if (file.getName().toLowerCase().endsWith("String_Node_Str")) {
      hasExtension=true;
    }
 else {
      return CommandLineError("String_Node_Str" + "String_Node_Str");
    }
  }
  if (hasExtension) {
    PcalParams.TLAInputFile=file.getPath().substring(0,file.getPath().lastIndexOf("String_Node_Str"));
    if (!file.exists()) {
      return CommandLineError("String_Node_Str" + file.getPath() + "String_Node_Str");
    }
  }
 else {
    file=new File(PcalParams.TLAInputFile + "String_Node_Str");
    if (!file.exists()) {
      return CommandLineError("String_Node_Str" + PcalParams.TLAInputFile + "String_Node_Str"+ file.getPath()+ "String_Node_Str");
    }
  }
  return STATUS_OK;
}