Program: 45344
Project: 45344
Buggy source:
/** 
 * Main method, but returns the return code as an int instead of calling System.exit(code). Needed for testing main method without shutting down tests.
 * @param argv command line parameters
 * @return return code
 */
protected int mainExec(String[] argv){
  String file;
  int argCount=argv.length;
  int argIndex=0;
  Properties properties=new Properties();
  while (argCount > 0) {
    if (argv[argIndex].startsWith("String_Node_Str")) {
      String argName=argv[argIndex].toLowerCase();
      while (argName.length() > 0 && argName.charAt(0) == '-') {
        argName=argName.substring(1);
      }
      if (argName.equals("String_Node_Str") || argName.equals("String_Node_Str") || argName.equals("String_Node_Str")) {
        this.report.helpText(new PrintWriter(System.out,true));
        return 0;
      }
 else       if (argName.equals("String_Node_Str")) {
        configuration.printConfigOptions(new PrintWriter(System.out,true),false);
        return 0;
      }
 else       if (argName.equals("String_Node_Str")) {
        configuration.adjust();
        configuration.printConfigOptions(errout,true);
        return 0;
      }
 else       if (argName.equals("String_Node_Str") || argName.equals("String_Node_Str")) {
        this.report.showVersion(errout);
        return 0;
      }
      String argValue=null;
      if (argCount > 2 && !argv[argIndex + 1].startsWith("String_Node_Str")) {
        argValue=argv[argIndex + 1];
        --argCount;
        ++argIndex;
      }
      String alias=CMDLINE_ALIAS.get(argName);
      if (alias != null) {
        argName=alias;
      }
      if (Configuration.isKnownOption(argName)) {
        properties.setProperty(argName,(argValue == null ? "String_Node_Str" : argName));
      }
 else       if (argName.equals("String_Node_Str")) {
        if (argValue != null) {
          configuration.parseFile(argValue);
        }
      }
 else       if (TidyUtils.isCharEncodingSupported(argName)) {
        properties.setProperty("String_Node_Str",argName);
      }
 else {
        for (int i=0; i < argName.length(); i++) {
switch (argName.charAt(i)) {
case 'i':
            configuration.setIndentContent(TriState.Auto);
          if (configuration.getSpaces() == 0) {
            configuration.reset(Option.IndentSpaces);
          }
        break;
case 'o':
      configuration.setHideEndTags(true);
    break;
case 'u':
  configuration.setUpperCaseTags(true);
break;
case 'c':
configuration.setMakeClean(true);
break;
case 'b':
configuration.setMakeBare(true);
break;
case 'n':
configuration.setNumEntities(true);
break;
case 'm':
configuration.setWriteback(true);
break;
case 'e':
configuration.setShowMarkup(false);
break;
case 'q':
configuration.setQuiet(true);
break;
default :
this.report.unknownOption(this.errout,argName.charAt(i));
break;
}
}
}
--argCount;
++argIndex;
continue;
}
configuration.addProps(properties);
configuration.adjust();
if (configuration.getErrfile() != null) {
String errorfile="String_Node_Str";
if (!configuration.getErrfile().equals(errorfile)) {
if (this.errout != this.stderr) {
this.errout.close();
}
try {
this.setErrout(new PrintWriter(new FileWriter(configuration.getErrfile()),true));
errorfile=configuration.getErrfile();
}
 catch (IOException e) {
errorfile="String_Node_Str";
this.setErrout(stderr);
}
}
}
if (argCount > 0) {
file=argv[argIndex];
}
 else {
file="String_Node_Str";
}
try {
parse(null,file,System.out);
}
 catch (FileNotFoundException fnfe) {
this.report.unknownFile(this.errout,file);
}
catch (IOException ioe) {
this.report.unknownFile(this.errout,file);
}
--argCount;
++argIndex;
if (argCount <= 0) {
break;
}
}
if (this.parseErrors + this.parseWarnings > 0 && !configuration.isQuiet()) {
this.report.generalInfo(this.errout);
}
if (this.errout != this.stderr) {
this.errout.close();
}
if (this.parseErrors > 0) {
return 2;
}
if (this.parseWarnings > 0) {
return 1;
}
return 0;
}

Fixed version (ground truth):
/** 
 * Main method, but returns the return code as an int instead of calling System.exit(code). Needed for testing main method without shutting down tests.
 * @param argv command line parameters
 * @return return code
 */
protected int mainExec(String[] argv){
  String file;
  int argCount=argv.length;
  int argIndex=0;
  Properties properties=new Properties();
  while (argCount > 0) {
    if (argv[argIndex].startsWith("String_Node_Str")) {
      String argName=argv[argIndex].toLowerCase();
      while (argName.length() > 0 && argName.charAt(0) == '-') {
        argName=argName.substring(1);
      }
      if (argName.equals("String_Node_Str") || argName.equals("String_Node_Str") || argName.equals("String_Node_Str")) {
        this.report.helpText(new PrintWriter(System.out,true));
        return 0;
      }
 else       if (argName.equals("String_Node_Str")) {
        configuration.printConfigOptions(new PrintWriter(System.out,true),false);
        return 0;
      }
 else       if (argName.equals("String_Node_Str")) {
        configuration.adjust();
        configuration.printConfigOptions(errout,true);
        return 0;
      }
 else       if (argName.equals("String_Node_Str") || argName.equals("String_Node_Str")) {
        this.report.showVersion(errout);
        return 0;
      }
      String argValue=null;
      if (argCount > 2 && !argv[argIndex + 1].startsWith("String_Node_Str")) {
        argValue=argv[argIndex + 1];
        --argCount;
        ++argIndex;
      }
      String alias=CMDLINE_ALIAS.get(argName);
      if (alias != null) {
        argName=alias;
      }
      if (Configuration.isKnownOption(argName)) {
        properties.setProperty(argName,(argValue == null ? "String_Node_Str" : argValue));
      }
 else       if (argName.equals("String_Node_Str")) {
        if (argValue != null) {
          configuration.parseFile(argValue);
        }
      }
 else       if (TidyUtils.isCharEncodingSupported(argName)) {
        properties.setProperty("String_Node_Str",argName);
      }
 else {
        for (int i=0; i < argName.length(); i++) {
switch (argName.charAt(i)) {
case 'i':
            configuration.setIndentContent(TriState.Auto);
          if (configuration.getSpaces() == 0) {
            configuration.reset(Option.IndentSpaces);
          }
        break;
case 'o':
      configuration.setHideEndTags(true);
    break;
case 'u':
  configuration.setUpperCaseTags(true);
break;
case 'c':
configuration.setMakeClean(true);
break;
case 'b':
configuration.setMakeBare(true);
break;
case 'n':
configuration.setNumEntities(true);
break;
case 'm':
configuration.setWriteback(true);
break;
case 'e':
configuration.setShowMarkup(false);
break;
case 'q':
configuration.setQuiet(true);
break;
default :
this.report.unknownOption(this.errout,argName.charAt(i));
break;
}
}
}
--argCount;
++argIndex;
continue;
}
configuration.addProps(properties);
configuration.adjust();
if (configuration.getErrfile() != null) {
String errorfile="String_Node_Str";
if (!configuration.getErrfile().equals(errorfile)) {
if (this.errout != this.stderr) {
this.errout.close();
}
try {
this.setErrout(new PrintWriter(new FileWriter(configuration.getErrfile()),true));
errorfile=configuration.getErrfile();
}
 catch (IOException e) {
errorfile="String_Node_Str";
this.setErrout(stderr);
}
}
}
if (argCount > 0) {
file=argv[argIndex];
}
 else {
file="String_Node_Str";
}
try {
parse(null,file,System.out);
}
 catch (FileNotFoundException fnfe) {
this.report.unknownFile(this.errout,file);
}
catch (IOException ioe) {
this.report.unknownFile(this.errout,file);
}
--argCount;
++argIndex;
if (argCount <= 0) {
break;
}
}
if (this.parseErrors + this.parseWarnings > 0 && !configuration.isQuiet()) {
this.report.generalInfo(this.errout);
}
if (this.errout != this.stderr) {
this.errout.close();
}
if (this.parseErrors > 0) {
return 2;
}
if (this.parseWarnings > 0) {
return 1;
}
return 0;
}