Program: 76248
Project: 76248
Buggy source:
/** 
 * Parse pxgraph style command-line arguments, using the specified base URL for any relative URL references.
 * @param args A set of command-line arguments.
 * @param base A base URL for relative URL references, or null ifthere is none.
 * @return The number of arguments read.
 * @exception CmdLineArgException If there is a problem parsingthe command line arguments.
 * @exception FileNotFoundException If a file is specified that is notfound.
 * @exception IOException If an error occurs reading an input file.
 */
public int parseArgs(String args[],URL base) throws CmdLineArgException, FileNotFoundException, IOException {
  int i=0, j, argumentsRead=0;
  boolean sawbararg=false;
  boolean sawnlarg=false;
  String savedmarks="String_Node_Str";
  binary=false;
  int width=400, height=400;
  String arg;
  String unsupportedOptions[]={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  while (args != null && i < args.length && (args[i].startsWith("String_Node_Str") || args[i].startsWith("String_Node_Str"))) {
    arg=args[i++];
    if (arg.startsWith("String_Node_Str")) {
      boolean badarg=false;
      for (j=0; j < unsupportedOptions.length; j++) {
        if (arg.equals(unsupportedOptions[j])) {
          System.err.println("String_Node_Str" + arg + "String_Node_Str");
          i++;
          badarg=true;
        }
      }
      if (badarg)       continue;
      if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setBackground(Plot.getColorByName(args[i++]));
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        double[] spec=_parseDoubles(args[i++]);
        if (spec.length == 1) {
          _plot.setBars(spec[0],0);
        }
 else {
          _plot.setBars(spec[0],spec[1]);
        }
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setLabelFont(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        double[] spec=_parseDoubles(args[i++]);
        if (spec.length == 1) {
          throw new CmdLineArgException("String_Node_Str" + arg + "String_Node_Str");
        }
 else {
          _plot.setXRange(spec[0],spec[1]);
        }
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        double[] spec=_parseDoubles(args[i++]);
        if (spec.length == 1) {
          throw new CmdLineArgException("String_Node_Str" + arg + "String_Node_Str");
        }
 else {
          _plot.setYRange(spec[0],spec[1]);
        }
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        String title=args[i++];
        _plot.setTitle(title);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setTitleFont(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setXLabel(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setYLabel(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        sawbararg=true;
        if (sawnlarg) {
          _plot.setImpulses(true);
        }
 else {
          _plot.setBars(true);
          _plot.setMarksStyle("String_Node_Str");
        }
        _plot.setConnected(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        binary=true;
        _endian=_NATIVE_ENDIAN;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        binary=true;
        _endian=_BIG_ENDIAN;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        binary=true;
        _endian=_LITTLE_ENDIAN;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _debug=10;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _debug=(int)Integer.valueOf(args[i++]).intValue();
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setForeground(_plot.getColorByName(args[i++]));
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setImpulses(true);
        _plot.setConnected(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setXLog(true);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setYLog(true);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        sawnlarg=true;
        if (sawbararg) {
          _plot.setMarksStyle(savedmarks);
          _plot.setBars(false);
          _plot.setImpulses(true);
        }
        _plot.setConnected(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        i++;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setBackground(_plot.getColorByName("String_Node_Str"));
        _plot.setForeground(_plot.getColorByName("String_Node_Str"));
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setGrid(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str") || arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.length() > 1 && arg.charAt(0) == '-') {
        try {
          Integer datasetnumberint=new Integer(arg.substring(1));
          int datasetnumber=datasetnumberint.intValue();
          if (datasetnumber >= 0) {
            _plot.addLegend(datasetnumber,args[i++]);
            continue;
          }
        }
 catch (        NumberFormatException e) {
        }
      }
    }
 else {
      if (arg.startsWith("String_Node_Str")) {
        width=(int)Integer.valueOf(arg.substring(1,arg.indexOf('x'))).intValue();
        int plusIndex=arg.indexOf('+');
        int minusIndex=arg.indexOf('-');
        if (plusIndex != -1 || minusIndex != -1) {
          if (plusIndex != -1 && minusIndex != -1) {
            int index=minusIndex;
            if (plusIndex < minusIndex) {
              index=plusIndex;
            }
            height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,index)).intValue();
          }
 else {
            if (plusIndex != -1) {
              height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,plusIndex)).intValue();
            }
 else {
              height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,minusIndex)).intValue();
            }
          }
        }
 else {
          if (arg.length() > arg.indexOf('x')) {
            height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,arg.length())).intValue();
          }
        }
        continue;
      }
    }
    throw new CmdLineArgException("String_Node_Str" + arg + "String_Node_Str");
  }
  argumentsRead=i++;
  _plot.setSize(width,height);
  for (i=argumentsRead; i < args.length; i++) {
    InputStream instream;
    try {
      URL inurl=new URL(base,args[i]);
      instream=inurl.openStream();
    }
 catch (    MalformedURLException ex) {
      instream=new FileInputStream(args[i]);
    }
    read(instream);
  }
  return argumentsRead;
}

Fixed version (ground truth):
/** 
 * Parse pxgraph style command-line arguments, using the specified base URL for any relative URL references.
 * @param args A set of command-line arguments.
 * @param base A base URL for relative URL references, or null ifthere is none.
 * @return The number of arguments read.
 * @exception CmdLineArgException If there is a problem parsingthe command line arguments.
 * @exception FileNotFoundException If a file is specified that is notfound.
 * @exception IOException If an error occurs reading an input file.
 */
public int parseArgs(String args[],URL base) throws CmdLineArgException, FileNotFoundException, IOException {
  int i=0, j, argumentsRead=0;
  boolean sawbararg=false;
  boolean sawnlarg=false;
  String savedmarks="String_Node_Str";
  _binary=false;
  int width=400, height=400;
  String arg;
  String unsupportedOptions[]={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  while (args != null && i < args.length && (args[i].startsWith("String_Node_Str") || args[i].startsWith("String_Node_Str"))) {
    arg=args[i++];
    if (arg.startsWith("String_Node_Str")) {
      boolean badarg=false;
      for (j=0; j < unsupportedOptions.length; j++) {
        if (arg.equals(unsupportedOptions[j])) {
          System.err.println("String_Node_Str" + arg + "String_Node_Str");
          i++;
          badarg=true;
        }
      }
      if (badarg)       continue;
      if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setBackground(Plot.getColorByName(args[i++]));
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        double[] spec=_parseDoubles(args[i++]);
        if (spec.length == 1) {
          _plot.setBars(spec[0],0);
        }
 else {
          _plot.setBars(spec[0],spec[1]);
        }
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setLabelFont(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        double[] spec=_parseDoubles(args[i++]);
        if (spec.length == 1) {
          throw new CmdLineArgException("String_Node_Str" + arg + "String_Node_Str");
        }
 else {
          _plot.setXRange(spec[0],spec[1]);
        }
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        double[] spec=_parseDoubles(args[i++]);
        if (spec.length == 1) {
          throw new CmdLineArgException("String_Node_Str" + arg + "String_Node_Str");
        }
 else {
          _plot.setYRange(spec[0],spec[1]);
        }
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        String title=args[i++];
        _plot.setTitle(title);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setTitleFont(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setXLabel(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setYLabel(args[i++]);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        sawbararg=true;
        if (sawnlarg) {
          _plot.setImpulses(true);
        }
 else {
          _plot.setBars(true);
          _plot.setMarksStyle("String_Node_Str");
        }
        _plot.setConnected(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _binary=true;
        _endian=_NATIVE_ENDIAN;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _binary=true;
        _endian=_BIG_ENDIAN;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _binary=true;
        _endian=_LITTLE_ENDIAN;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _debug=10;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _debug=(int)Integer.valueOf(args[i++]).intValue();
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setForeground(_plot.getColorByName(args[i++]));
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setImpulses(true);
        _plot.setConnected(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setXLog(true);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setYLog(true);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        sawnlarg=true;
        if (sawbararg) {
          _plot.setMarksStyle(savedmarks);
          _plot.setBars(false);
          _plot.setImpulses(true);
        }
        _plot.setConnected(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        i++;
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setMarksStyle("String_Node_Str");
        savedmarks="String_Node_Str";
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setBackground(_plot.getColorByName("String_Node_Str"));
        _plot.setForeground(_plot.getColorByName("String_Node_Str"));
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.equals("String_Node_Str")) {
        _plot.setGrid(false);
        continue;
      }
 else       if (arg.equals("String_Node_Str") || arg.equals("String_Node_Str")) {
        continue;
      }
 else       if (arg.length() > 1 && arg.charAt(0) == '-') {
        try {
          Integer datasetnumberint=new Integer(arg.substring(1));
          int datasetnumber=datasetnumberint.intValue();
          if (datasetnumber >= 0) {
            _plot.addLegend(datasetnumber,args[i++]);
            continue;
          }
        }
 catch (        NumberFormatException e) {
        }
      }
    }
 else {
      if (arg.startsWith("String_Node_Str")) {
        width=(int)Integer.valueOf(arg.substring(1,arg.indexOf('x'))).intValue();
        int plusIndex=arg.indexOf('+');
        int minusIndex=arg.indexOf('-');
        if (plusIndex != -1 || minusIndex != -1) {
          if (plusIndex != -1 && minusIndex != -1) {
            int index=minusIndex;
            if (plusIndex < minusIndex) {
              index=plusIndex;
            }
            height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,index)).intValue();
          }
 else {
            if (plusIndex != -1) {
              height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,plusIndex)).intValue();
            }
 else {
              height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,minusIndex)).intValue();
            }
          }
        }
 else {
          if (arg.length() > arg.indexOf('x')) {
            height=Integer.valueOf(arg.substring(arg.indexOf('x') + 1,arg.length())).intValue();
          }
        }
        continue;
      }
    }
    throw new CmdLineArgException("String_Node_Str" + arg + "String_Node_Str");
  }
  argumentsRead=i++;
  _plot.setSize(width,height);
  for (i=argumentsRead; i < args.length; i++) {
    InputStream instream;
    try {
      URL inurl=new URL(base,args[i]);
      instream=inurl.openStream();
    }
 catch (    MalformedURLException ex) {
      instream=new FileInputStream(args[i]);
    }
    read(instream);
  }
  return argumentsRead;
}