nus-yam/ex-repair huggingface dataset:
Program: 163456
Project: 163456
Buggy source:
void addValuesToColumns(boolean expandWithNulls,T[] row,ParsingContext context){
  if (columnValues == null) {
    initialize(context);
  }
  if (columnValues.size() < row.length) {
    int columnsToAdd=row.length - columnValues.size();
    while (columnsToAdd-- > 0) {
      ArrayList<T> values;
      long records=context.currentRecord();
      if (records == 1L || !expandWithNulls) {
        values=new ArrayList<T>(initialRowSize);
      }
 else {
        values=new ArrayList<T>(initialRowSize < records ? (int)records : initialRowSize);
        while (--records > 0) {
          values.add(null);
        }
      }
      columnValues.add(values);
    }
  }
  for (int i=0; i < row.length; i++) {
    columnValues.get(i).add(row[i]);
  }
  if (row.length < columnValues.size()) {
    for (int i=row.length; i < columnValues.size(); i++) {
      columnValues.get(i).add(null);
    }
  }
}

Fixed version (ground truth):
/** 
 * Splits the row and add stores the value of each column in its corresponding list in   {@link #columnValues}
 * @param row the row whose column values will be split
 * @param context the current active parsing context.
 */
void addValuesToColumns(T[] row,ParsingContext context){
  if (columnValues == null) {
    initialize(context);
  }
  if (columnValues.size() < row.length) {
    int columnsToAdd=row.length - columnValues.size();
    while (columnsToAdd-- > 0) {
      long records=context.currentRecord() - addNullsFrom;
      ArrayList<T> values=new ArrayList<T>(expectedRowCount < records ? (int)records : expectedRowCount);
      while (--records > 0) {
        values.add(null);
      }
      columnValues.add(values);
    }
  }
  for (int i=0; i < row.length; i++) {
    columnValues.get(i).add(row[i]);
  }
  if (row.length < columnValues.size()) {
    for (int i=row.length; i < columnValues.size(); i++) {
      columnValues.get(i).add(null);
    }
  }
  rowCount++;
}
Program: 163457
Project: 163457
Buggy source:
Map<Integer,List<T>> getColumnValuesAsMapOfIndexes(){
  Map<Integer,List<T>> map=new HashMap<Integer,List<T>>();
  putColumnValuesInMapOfIndexes(map);
  return map;
}

Fixed version (ground truth):
/** 
 * Returns a map of column indexes and their respective list of values parsed from the input.
 * @return a map of column indexes and their respective list of values.
 */
Map<Integer,List<T>> getColumnValuesAsMapOfIndexes(){
  Map<Integer,List<T>> map=new HashMap<Integer,List<T>>();
  putColumnValuesInMapOfIndexes(map);
  return map;
}
Program: 163458
Project: 163458
Buggy source:
private void initialize(ParsingContext context){
  headers:   if (this.headers == null) {
    String[] allHeaders=context.headers();
    if (allHeaders == null) {
      headers=ArgumentUtils.EMPTY_STRING_ARRAY;
      break headers;
    }
    if (!context.columnsReordered()) {
      this.headers=allHeaders;
      break headers;
    }
    int[] selectedIndexes=context.extractedFieldIndexes();
    final int last=Math.min(allHeaders.length,selectedIndexes.length);
    this.headers=new String[selectedIndexes.length];
    for (int i=0; i < last; i++) {
      headers[i]=allHeaders[selectedIndexes[i]];
    }
  }
  columnValues=new ArrayList<List<T>>(headers.length > 0 ? headers.length : 10);
}

Fixed version (ground truth):
/** 
 * Initializes the list of column values, the headers of each column and which columns to read if fields have been selected using   {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @param context the current active parsing context, which will be used to obtain information about headers and selected fields.
 */
private void initialize(ParsingContext context){
  headers:   if (this.headers == null) {
    String[] allHeaders=context.headers();
    if (allHeaders == null) {
      headers=ArgumentUtils.EMPTY_STRING_ARRAY;
      break headers;
    }
    if (!context.columnsReordered()) {
      this.headers=allHeaders;
      break headers;
    }
    int[] selectedIndexes=context.extractedFieldIndexes();
    final int last=Math.min(allHeaders.length,selectedIndexes.length);
    this.headers=new String[selectedIndexes.length];
    for (int i=0; i < last; i++) {
      headers[i]=allHeaders[selectedIndexes[i]];
    }
  }
  columnValues=new ArrayList<List<T>>(headers.length > 0 ? headers.length : 10);
}
Program: 163459
Project: 163459
Buggy source:
void putColumnValuesInMapOfIndexes(Map<Integer,List<T>> map){
  if (columnValues == null) {
    return;
  }
  for (int i=0; i < columnValues.size(); i++) {
    map.put(i,columnValues.get(i));
  }
}

Fixed version (ground truth):
/** 
 * Fills a given map associating each column index to its list of values
 * @param map the map to hold the values of each column
 */
void putColumnValuesInMapOfIndexes(Map<Integer,List<T>> map){
  if (columnValues == null) {
    return;
  }
  for (int i=0; i < columnValues.size(); i++) {
    map.put(i,columnValues.get(i));
  }
}
Program: 163460
Project: 163460
Buggy source:
Map<String,List<T>> getColumnValuesAsMapOfNames(){
  Map<String,List<T>> map=new HashMap<String,List<T>>();
  putColumnValuesInMapOfNames(map);
  return map;
}

Fixed version (ground truth):
/** 
 * Returns a map of column names and their respective list of values parsed from the input.
 * @return a map of column names and their respective list of values.
 */
Map<String,List<T>> getColumnValuesAsMapOfNames(){
  Map<String,List<T>> map=new HashMap<String,List<T>>();
  putColumnValuesInMapOfNames(map);
  return map;
}
Program: 163461
Project: 163461
Buggy source:
String getHeader(int columnIndex){
  if (headers.length < columnIndex) {
    return headers[columnIndex];
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the header of a particular column
 * @param columnIndex the index of the column whose header is to be obtained
 * @return the name of the column at the given index, or null if there's no header defined for the given column index.
 */
String getHeader(int columnIndex){
  if (headers.length < columnIndex) {
    return headers[columnIndex];
  }
  return null;
}
Program: 163462
Project: 163462
Buggy source:
void putColumnValuesInMapOfNames(Map<String,List<T>> map){
  if (columnValues == null) {
    return;
  }
  for (int i=0; i < columnValues.size(); i++) {
    String header=getHeader(i);
    if (header == null) {
      throw new IllegalArgumentException("String_Node_Str" + i + "String_Node_Str"+ Arrays.toString(getHeaders()));
    }
    map.put(header,columnValues.get(i));
  }
}

Fixed version (ground truth):
/** 
 * Fills a given map associating each column name to its list o values
 * @param map the map to hold the values of each column
 * @throws IllegalArgumentException if a column does not have a name associated to it. In this case, use {@link #putColumnValuesInMapOfIndexes(Map)} instead.
 */
void putColumnValuesInMapOfNames(Map<String,List<T>> map){
  if (columnValues == null) {
    return;
  }
  for (int i=0; i < columnValues.size(); i++) {
    String header=getHeader(i);
    if (header == null) {
      throw new IllegalArgumentException("String_Node_Str" + i + "String_Node_Str"+ Arrays.toString(getHeaders()));
    }
    map.put(header,columnValues.get(i));
  }
}
Program: 163463
Project: 163463
Buggy source:
@Override public final void processStarted(ParsingContext context){
  super.processStarted(context);
  splitter.clearValuesAndHeaders();
}

Fixed version (ground truth):
@Override public final void processStarted(ParsingContext context){
  super.processStarted(context);
  splitter.reset();
}
Program: 163464
Project: 163464
Buggy source:
@Override public final void rowProcessed(Object[] row,ParsingContext context){
  splitter.addValuesToColumns(true,row,context);
}

Fixed version (ground truth):
@Override public final void rowProcessed(Object[] row,ParsingContext context){
  splitter.addValuesToColumns(row,context);
}
Program: 163465
Project: 163465
Buggy source:
@Override public void batchProcessed(int rowsInThisBatch){
  List<List<String>> columnValues=getColumnValuesAsList();
  Map<Integer,List<String>> columnsByIndex=getColumnValuesAsMapOfIndexes();
  String[][] expectedValues=getBatchesProcessed() == 0 ? expectedValueOnFirstBatch : expectedValueOnSecondBatch;
  assertEquals(columnValues.size(),expectedValues.length);
  for (int i=0; i < rowsInThisBatch; i++) {
    assertEquals(columnValues.get(i).size(),rowsInThisBatch);
    assertEquals(columnValues.get(i).toArray(),expectedValues[i]);
    assertEquals(columnsByIndex.get(i).toArray(),expectedValues[i]);
  }
  try {
    getColumnValuesAsMapOfNames();
    fail("String_Node_Str");
  }
 catch (  Exception e) {
  }
  assertEquals(getHeaders(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
}

Fixed version (ground truth):
@Override public void batchProcessed(int rowsInThisBatch){
  List<List<String>> columnValues=getColumnValuesAsList();
  Map<Integer,List<String>> columnsByIndex=getColumnValuesAsMapOfIndexes();
  String[][] expectedValues=getBatchesProcessed() == 0 ? expectedValueOnFirstBatch : expectedValueOnSecondBatch;
  assertEquals(columnValues.size(),expectedValues.length);
  for (int i=0; i < expectedValues.length; i++) {
    assertEquals(columnValues.get(i).size(),rowsInThisBatch);
    assertEquals(columnValues.get(i).toArray(),expectedValues[i]);
    assertEquals(columnsByIndex.get(i).toArray(),expectedValues[i]);
  }
  try {
    getColumnValuesAsMapOfNames();
    fail("String_Node_Str");
  }
 catch (  Exception e) {
  }
  assertEquals(getHeaders(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
}
Program: 163467
Project: 163467
Buggy source:
@Override public void batchProcessed(int rowsInThisBatch){
  List<List<Object>> columnValues=getColumnValuesAsList();
  Map<Integer,List<Object>> columnsByIndex=getColumnValuesAsMapOfIndexes();
  Object[][] expectedValues=getBatchesProcessed() == 0 ? expectedValueOnFirstBatch : expectedValueOnSecondBatch;
  assertEquals(columnValues.size(),expectedValues.length);
  for (int i=0; i < rowsInThisBatch; i++) {
    assertEquals(columnValues.get(i).size(),rowsInThisBatch);
    assertEquals(columnValues.get(i).toArray(),expectedValues[i]);
    assertEquals(columnsByIndex.get(i).toArray(),expectedValues[i]);
  }
  try {
    getColumnValuesAsMapOfNames();
    fail("String_Node_Str");
  }
 catch (  Exception e) {
  }
  assertEquals(getHeaders(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
}

Fixed version (ground truth):
@Override public void batchProcessed(int rowsInThisBatch){
  List<List<Object>> columnValues=getColumnValuesAsList();
  Map<Integer,List<Object>> columnsByIndex=getColumnValuesAsMapOfIndexes();
  Object[][] expectedValues=getBatchesProcessed() == 0 ? expectedValueOnFirstBatch : expectedValueOnSecondBatch;
  assertEquals(columnValues.size(),expectedValues.length);
  for (int i=0; i < expectedValues.length; i++) {
    assertEquals(columnValues.get(i).size(),rowsInThisBatch);
    assertEquals(columnValues.get(i).toArray(),expectedValues[i]);
    assertEquals(columnsByIndex.get(i).toArray(),expectedValues[i]);
  }
  try {
    getColumnValuesAsMapOfNames();
    fail("String_Node_Str");
  }
 catch (  Exception e) {
  }
  assertEquals(getHeaders(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
}
Program: 163469
Project: 163469
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected void processRow(Object[] row){
  for (int i=0; i < row.length; i++) {
    if (i != 0) {
      appendToRow(separator);
    }
    String nextElement=getStringValue(row[i]);
    boolean isElementQuoted=quoteElement(nextElement);
    if (isElementQuoted) {
      appender.append(quotechar);
    }
    int originalLength=appender.length();
    append(isElementQuoted,nextElement);
    if (appender.length() == originalLength && nullValue != null && !nullValue.isEmpty()) {
      if (isElementQuoted) {
        append(isElementQuoted,emptyValue);
      }
 else {
        append(isElementQuoted,nullValue);
      }
    }
    if (isElementQuoted) {
      appender.append(quotechar);
    }
    appendValueToRow();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected void processRow(Object[] row){
  for (int i=0; i < row.length; i++) {
    if (i != 0) {
      appendToRow(separator);
    }
    String nextElement=getStringValue(row[i]);
    boolean isElementQuoted=quoteElement(nextElement);
    if (isElementQuoted) {
      appender.append(quotechar);
    }
    int originalLength=appender.length();
    append(isElementQuoted,nextElement);
    if (appender.length() == originalLength && nullValue != null && !nullValue.isEmpty()) {
      if (isElementQuoted) {
        append(isElementQuoted,emptyValue);
      }
 else {
        append(isElementQuoted,nullValue);
      }
    }
    if (isElementQuoted) {
      appender.appendIgnoringWhitespace(quotechar);
    }
    appendValueToRow();
  }
}
Program: 163470
Project: 163470
Buggy source:
/** 
 * Parses the entirety of a given input and delegates each parsed row to an instance of   {@link RowProcessor}, defined by   {@link CommonParserSettings#getRowProcessor()}.
 * @param reader The input to be parsed.
 */
public final void parse(Reader reader){
  beginParsing(reader);
  try {
    while (!context.stopped && (ch=input.nextChar()) != '\0') {
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
      }
    }
  }
 catch (  Exception ex) {
    throw new TextParsingException(context,ex);
  }
 finally {
    stopParsing();
  }
}

Fixed version (ground truth):
/** 
 * Parses the entirety of a given input and delegates each parsed row to an instance of   {@link RowProcessor}, defined by   {@link CommonParserSettings#getRowProcessor()}.
 * @param reader The input to be parsed.
 */
public final void parse(Reader reader){
  beginParsing(reader);
  try {
    while (!context.stopped) {
      ch=input.nextChar();
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
      }
    }
  }
 catch (  EOFException ex) {
    if (output.column != 0) {
      if (output.appender.length() > 0) {
        output.valueParsed();
      }
 else {
        output.emptyParsed();
      }
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
      }
    }
 else     if (output.appender.length() > 0) {
      output.valueParsed();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
      }
    }
  }
catch (  Exception ex) {
    throw new TextParsingException(context,ex);
  }
 finally {
    stopParsing();
  }
}
Program: 163471
Project: 163471
Buggy source:
/** 
 * Parses the next record from the input. Note that   {@link AbstractParser#beginParsing(Reader)} must have been invoked once before calling this method.If the end of the input is reached, then this method will return null. Additionally, all resources will be closed automatically at the end of the input or if any error happens while parsing.
 * @return The record parsed from the input or null if there's no more characters to read.
 */
public final String[] parseNext(){
  try {
    while (!context.stopped && (ch=input.nextChar()) != '\0') {
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
        return row;
      }
    }
    stopParsing();
    return null;
  }
 catch (  Exception ex) {
    try {
      throw new TextParsingException(context,ex);
    }
  finally {
      stopParsing();
    }
  }
}

Fixed version (ground truth):
/** 
 * Parses the next record from the input. Note that   {@link AbstractParser#beginParsing(Reader)} must have been invoked once before calling this method.If the end of the input is reached, then this method will return null. Additionally, all resources will be closed automatically at the end of the input or if any error happens while parsing.
 * @return The record parsed from the input or null if there's no more characters to read.
 */
public final String[] parseNext(){
  try {
    while (!context.stopped) {
      ch=input.nextChar();
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
        return row;
      }
    }
    stopParsing();
    return null;
  }
 catch (  EOFException ex) {
    if (output.appender.length() > 0) {
      output.valueParsed();
    }
    String[] row=output.rowParsed();
    stopParsing();
    return row;
  }
catch (  Exception ex) {
    try {
      throw new TextParsingException(context,ex);
    }
  finally {
      stopParsing();
    }
  }
}
Program: 163472
Project: 163472
Buggy source:
/** 
 * Gets all values parsed in the   {@link ParserOutput#parsedValues} array
 * @return the sequence of parsed values in a record.
 */
String[] rowParsed(){
  if (column > 0) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
      if (settings.isHeaderExtractionEnabled()) {
        Arrays.fill(parsedValues,null);
        return null;
      }
    }
    currentRecord++;
    if (columnsReordered) {
      String[] reorderedValues=new String[selectedIndexes.length];
      for (int i=0; i < selectedIndexes.length; i++) {
        int index=selectedIndexes[i];
        if (index >= column) {
          reorderedValues[i]=nullValue;
        }
 else {
          reorderedValues[i]=parsedValues[index];
        }
      }
      return reorderedValues;
    }
 else {
      String[] out=new String[column];
      System.arraycopy(parsedValues,0,out,0,column);
      return out;
    }
  }
 else   if (!skipEmptyLines) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
    }
    currentRecord++;
    if (columnsReordered) {
      String[] out=new String[selectedIndexes.length];
      Arrays.fill(out,nullValue);
      return out;
    }
    return ArgumentUtils.EMPTY_STRING_ARRAY;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets all values parsed in the   {@link ParserOutput#parsedValues} array
 * @return the sequence of parsed values in a record.
 */
String[] rowParsed(){
  if (column > 0) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
      if (settings.isHeaderExtractionEnabled()) {
        Arrays.fill(parsedValues,null);
        column=0;
        return null;
      }
    }
    currentRecord++;
    if (columnsReordered) {
      String[] reorderedValues=new String[selectedIndexes.length];
      for (int i=0; i < selectedIndexes.length; i++) {
        int index=selectedIndexes[i];
        if (index >= column) {
          reorderedValues[i]=nullValue;
        }
 else {
          reorderedValues[i]=parsedValues[index];
        }
      }
      column=0;
      return reorderedValues;
    }
 else {
      String[] out=new String[column];
      System.arraycopy(parsedValues,0,out,0,column);
      column=0;
      return out;
    }
  }
 else   if (!skipEmptyLines) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
    }
    currentRecord++;
    if (columnsReordered) {
      String[] out=new String[selectedIndexes.length];
      Arrays.fill(out,nullValue);
      return out;
    }
    return ArgumentUtils.EMPTY_STRING_ARRAY;
  }
  return null;
}
Program: 163473
Project: 163473
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public final char nextChar(){
  if (length == -1) {
    return '\0';
  }
  char ch=buffer[i - 1];
  if (i >= length) {
    if (length != -1) {
      updateBuffer();
    }
 else {
      return '\0';
    }
  }
  i++;
  if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i - 1])) {
    lineCount++;
    if (lineSeparator2 != '\0') {
      ch=normalizedLineSeparator;
      if (i >= length) {
        if (length != -1) {
          updateBuffer();
        }
 else {
          return '\0';
        }
      }
      if (i < length) {
        i++;
      }
    }
  }
  return ch;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public final char nextChar(){
  if (length == -1) {
    throw new EOFException();
  }
  char ch=buffer[i - 1];
  if (i >= length) {
    if (length != -1) {
      updateBuffer();
    }
 else {
      throw new EOFException();
    }
  }
  i++;
  if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i - 1])) {
    lineCount++;
    if (lineSeparator2 != '\0') {
      ch=normalizedLineSeparator;
      if (i >= length) {
        if (length != -1) {
          updateBuffer();
        }
 else {
          throw new EOFException();
        }
      }
      if (i < length) {
        i++;
      }
    }
  }
  return ch;
}
Program: 163474
Project: 163474
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public final void skipLines(int lines){
  if (lines < 1) {
    return;
  }
  int expectedLineCount=this.lineCount + lines;
  char ch='\0';
  do {
    ch=nextChar();
  }
 while (lineCount < expectedLineCount && ch != '\0');
  if (ch == '\0' && lineCount < lines) {
    throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public final void skipLines(int lines){
  if (lines < 1) {
    return;
  }
  int expectedLineCount=this.lineCount + lines;
  char ch='\0';
  try {
    do {
      ch=nextChar();
    }
 while (lineCount < expectedLineCount && ch != '\0');
    if (lineCount < lines) {
      throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
    }
  }
 catch (  EOFException ex) {
    throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
  }
}
Program: 163475
Project: 163475
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected void parseRecord(){
  if (ch <= ' ' && ignoreLeadingWhitespace) {
    skipWhitespace();
  }
  while (ch != newLine && ch != '\0') {
    parseField();
    if (ch != newLine) {
      ch=input.nextChar();
      if (ch == newLine) {
        output.emptyParsed();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected void parseRecord(){
  if (ch <= ' ' && ignoreLeadingWhitespace) {
    skipWhitespace();
  }
  while (ch != newLine) {
    parseField();
    if (ch != newLine) {
      ch=input.nextChar();
      if (ch == newLine) {
        output.emptyParsed();
      }
    }
  }
}
Program: 163476
Project: 163476
Buggy source:
private void parseQuotedValue(){
  char prev='\0';
  ch=input.nextChar();
  while (!(prev == quote && (ch == delimiter || ch <= ' ')) && ch != '\0') {
    if (ch != quote) {
      output.appender.append(ch);
      prev=ch;
    }
 else     if (prev == quoteEscape) {
      output.appender.append(quote);
      prev='\0';
    }
 else {
      prev=ch;
    }
    ch=input.nextChar();
  }
  if (ch <= ' ') {
    skipWhitespace();
  }
}

Fixed version (ground truth):
private void parseQuotedValue(){
  char prev='\0';
  ch=input.nextChar();
  while (!(prev == quote && (ch == delimiter || ch <= ' '))) {
    if (ch != quote) {
      output.appender.append(ch);
      prev=ch;
    }
 else     if (prev == quoteEscape) {
      output.appender.append(quote);
      prev='\0';
    }
 else {
      prev=ch;
    }
    ch=input.nextChar();
  }
  if (ch <= ' ') {
    skipWhitespace();
  }
}
Program: 163477
Project: 163477
Buggy source:
private void parseValue(){
  if (ignoreTrailingWhitespace) {
    while (ch != delimiter && ch != newLine && ch != '\0') {
      output.appender.appendIgnoringWhitespace(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (ch != delimiter && ch != newLine && ch != '\0') {
      output.appender.append(ch);
      ch=input.nextChar();
    }
  }
}

Fixed version (ground truth):
private void parseValue(){
  if (ignoreTrailingWhitespace) {
    while (ch != delimiter && ch != newLine) {
      output.appender.appendIgnoringWhitespace(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (ch != delimiter && ch != newLine) {
      output.appender.append(ch);
      ch=input.nextChar();
    }
  }
}
Program: 163478
Project: 163478
Buggy source:
private void skipWhitespace(){
  while (ch <= ' ' && ch != delimiter && ch != newLine && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipWhitespace(){
  while (ch <= ' ' && ch != delimiter && ch != newLine) {
    ch=input.nextChar();
  }
}
Program: 163479
Project: 163479
Buggy source:
private void readValueUntilNewLine(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0 && ch != newLine && ch != '\0') {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0 && ch != newLine && ch != '\0') {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}

Fixed version (ground truth):
private void readValueUntilNewLine(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0 && ch != newLine) {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0 && ch != newLine) {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}
Program: 163480
Project: 163480
Buggy source:
private void readValue(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0 && ch != '\0') {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0 && ch != '\0') {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}

Fixed version (ground truth):
private void readValue(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0) {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0) {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}
Program: 163481
Project: 163481
Buggy source:
private void skipToNewLine(){
  while (ch != newLine && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipToNewLine(){
  while (ch != newLine) {
    ch=input.nextChar();
  }
}
Program: 163482
Project: 163482
Buggy source:
private void skipPadding(){
  while (ch == padding && length-- > 0 && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipPadding(){
  while (ch == padding && length-- > 0) {
    ch=input.nextChar();
  }
}
Program: 163483
Project: 163483
Buggy source:
private void skipWhitespace(){
  while (ch <= ' ' && length-- > 0 && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipWhitespace(){
  while (ch <= ' ' && length-- > 0) {
    ch=input.nextChar();
  }
}
Program: 163484
Project: 163484
Buggy source:
/** 
 * Initializes the sequence of selected fields, if any.
 * @param values a sequence of values that represent the headers of the input. This can be either a parsed record or the headers as defined in {@link CommonSettings#getHeaders()}
 */
private void initializeColumnsToExtract(String[] values){
  columnsToExtractInitialized=true;
  columnsReordered=false;
  selectedIndexes=null;
  FieldSelector selector=settings.getFieldSelector();
  if (selector != null) {
    selectedIndexes=selector.getFieldIndexes(values);
    if (selectedIndexes != null) {
      Arrays.fill(appenders,NoopCharAppender.getInstance());
      for (int i=0; i < selectedIndexes.length; i++) {
        appenders[selectedIndexes[i]]=appender;
      }
      columnsReordered=settings.isColumnReorderingEnabled();
    }
  }
}

Fixed version (ground truth):
/** 
 * Initializes the sequence of selected fields, if any.
 * @param values a sequence of values that represent the headers of the input. This can be either a parsed record or the headers as defined in {@link CommonSettings#getHeaders()}
 */
private void initializeColumnsToExtract(String[] values){
  columnsToExtractInitialized=true;
  columnsReordered=false;
  selectedIndexes=null;
  FieldSelector selector=settings.getFieldSelector();
  if (selector != null) {
    selectedIndexes=selector.getFieldIndexes(values);
    if (selectedIndexes != null) {
      Arrays.fill(appenders,NoopCharAppender.getInstance());
      for (int i=0; i < selectedIndexes.length; i++) {
        appenders[selectedIndexes[i]]=appender;
      }
      columnsReordered=settings.isColumnReorderingEnabled();
      if (!columnsReordered && values.length < appenders.length) {
        Arrays.fill(appenders,values.length,appenders.length,appender);
      }
    }
  }
}
Program: 163485
Project: 163485
Buggy source:
protected abstract RowListProcessor newRowListProcessor();

Fixed version (ground truth):
protected RowListProcessor newRowListProcessor(){
  return new RowListProcessor();
}
Program: 163486
Project: 163486
Buggy source:
/** 
 * Parses the entirety of a given input and delegates each parsed row to an instance of   {@link RowProcessor}, defined by   {@link CommonParserSettings#getRowProcessor()}.
 * @param reader The input to be parsed.
 */
public final void parse(Reader reader){
  beginParsing(reader);
  try {
    while (!context.stopped && (ch=input.nextChar()) != '\0') {
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
      }
    }
  }
 catch (  Exception ex) {
    throw new TextParsingException(context,ex);
  }
 finally {
    stopParsing();
  }
}

Fixed version (ground truth):
/** 
 * Parses the entirety of a given input and delegates each parsed row to an instance of   {@link RowProcessor}, defined by   {@link CommonParserSettings#getRowProcessor()}.
 * @param reader The input to be parsed.
 */
public final void parse(Reader reader){
  beginParsing(reader);
  try {
    while (!context.stopped) {
      ch=input.nextChar();
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
      }
    }
  }
 catch (  EOFException ex) {
    if (output.column != 0) {
      if (output.appender.length() > 0) {
        output.valueParsed();
      }
 else {
        output.emptyParsed();
      }
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
      }
    }
 else     if (output.appender.length() > 0) {
      output.valueParsed();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
      }
    }
  }
catch (  Exception ex) {
    throw new TextParsingException(context,ex);
  }
 finally {
    stopParsing();
  }
}
Program: 163487
Project: 163487
Buggy source:
/** 
 * Parses the next record from the input. Note that   {@link AbstractParser#beginParsing(Reader)} must have been invoked once before calling this method.If the end of the input is reached, then this method will return null. Additionally, all resources will be closed automatically at the end of the input or if any error happens while parsing.
 * @return The record parsed from the input or null if there's no more characters to read.
 */
public final String[] parseNext(){
  try {
    while (!context.stopped && (ch=input.nextChar()) != '\0') {
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
        return row;
      }
    }
    stopParsing();
    return null;
  }
 catch (  Exception ex) {
    try {
      throw new TextParsingException(context,ex);
    }
  finally {
      stopParsing();
    }
  }
}

Fixed version (ground truth):
/** 
 * Parses the next record from the input. Note that   {@link AbstractParser#beginParsing(Reader)} must have been invoked once before calling this method.If the end of the input is reached, then this method will return null. Additionally, all resources will be closed automatically at the end of the input or if any error happens while parsing.
 * @return The record parsed from the input or null if there's no more characters to read.
 */
public final String[] parseNext(){
  try {
    while (!context.stopped) {
      ch=input.nextChar();
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
        return row;
      }
    }
    stopParsing();
    return null;
  }
 catch (  EOFException ex) {
    if (output.appender.length() > 0) {
      output.valueParsed();
    }
    String[] row=output.rowParsed();
    stopParsing();
    return row;
  }
catch (  Exception ex) {
    try {
      throw new TextParsingException(context,ex);
    }
  finally {
      stopParsing();
    }
  }
}
Program: 163488
Project: 163488
Buggy source:
/** 
 * Gets all values parsed in the   {@link ParserOutput#parsedValues} array
 * @return the sequence of parsed values in a record.
 */
String[] rowParsed(){
  if (column > 0) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
      if (settings.isHeaderExtractionEnabled()) {
        Arrays.fill(parsedValues,null);
        return null;
      }
    }
    currentRecord++;
    if (columnsReordered) {
      String[] reorderedValues=new String[selectedIndexes.length];
      for (int i=0; i < selectedIndexes.length; i++) {
        int index=selectedIndexes[i];
        if (index >= column) {
          reorderedValues[i]=nullValue;
        }
 else {
          reorderedValues[i]=parsedValues[index];
        }
      }
      return reorderedValues;
    }
 else {
      String[] out=new String[column];
      System.arraycopy(parsedValues,0,out,0,column);
      return out;
    }
  }
 else   if (!skipEmptyLines) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
    }
    currentRecord++;
    if (columnsReordered) {
      String[] out=new String[selectedIndexes.length];
      Arrays.fill(out,nullValue);
      return out;
    }
    return ArgumentUtils.EMPTY_STRING_ARRAY;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets all values parsed in the   {@link ParserOutput#parsedValues} array
 * @return the sequence of parsed values in a record.
 */
String[] rowParsed(){
  if (column > 0) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
      if (settings.isHeaderExtractionEnabled()) {
        Arrays.fill(parsedValues,null);
        column=0;
        return null;
      }
    }
    currentRecord++;
    if (columnsReordered) {
      String[] reorderedValues=new String[selectedIndexes.length];
      for (int i=0; i < selectedIndexes.length; i++) {
        int index=selectedIndexes[i];
        if (index >= column) {
          reorderedValues[i]=nullValue;
        }
 else {
          reorderedValues[i]=parsedValues[index];
        }
      }
      column=0;
      return reorderedValues;
    }
 else {
      String[] out=new String[column];
      System.arraycopy(parsedValues,0,out,0,column);
      column=0;
      return out;
    }
  }
 else   if (!skipEmptyLines) {
    if (!columnsToExtractInitialized) {
      initializeHeaders();
    }
    currentRecord++;
    if (columnsReordered) {
      String[] out=new String[selectedIndexes.length];
      Arrays.fill(out,nullValue);
      return out;
    }
    return ArgumentUtils.EMPTY_STRING_ARRAY;
  }
  return null;
}
Program: 163489
Project: 163489
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public final char nextChar(){
  if (length == -1) {
    return '\0';
  }
  char ch=buffer[i - 1];
  if (i >= length) {
    if (length != -1) {
      updateBuffer();
    }
 else {
      return '\0';
    }
  }
  i++;
  if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i - 1])) {
    lineCount++;
    if (lineSeparator2 != '\0') {
      ch=normalizedLineSeparator;
      if (i >= length) {
        if (length != -1) {
          updateBuffer();
        }
 else {
          return '\0';
        }
      }
      if (i < length) {
        i++;
      }
    }
  }
  return ch;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public final char nextChar(){
  if (length == -1) {
    throw new EOFException();
  }
  char ch=buffer[i - 1];
  if (i >= length) {
    if (length != -1) {
      updateBuffer();
    }
 else {
      throw new EOFException();
    }
  }
  i++;
  if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i - 1])) {
    lineCount++;
    if (lineSeparator2 != '\0') {
      ch=normalizedLineSeparator;
      if (i >= length) {
        if (length != -1) {
          updateBuffer();
        }
 else {
          throw new EOFException();
        }
      }
      if (i < length) {
        i++;
      }
    }
  }
  return ch;
}
Program: 163490
Project: 163490
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public final void skipLines(int lines){
  if (lines < 1) {
    return;
  }
  int expectedLineCount=this.lineCount + lines;
  char ch='\0';
  do {
    ch=nextChar();
  }
 while (lineCount < expectedLineCount && ch != '\0');
  if (ch == '\0' && lineCount < lines) {
    throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public final void skipLines(int lines){
  if (lines < 1) {
    return;
  }
  int expectedLineCount=this.lineCount + lines;
  char ch='\0';
  try {
    do {
      ch=nextChar();
    }
 while (lineCount < expectedLineCount && ch != '\0');
    if (lineCount < lines) {
      throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
    }
  }
 catch (  EOFException ex) {
    throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
  }
}
Program: 163491
Project: 163491
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected void parseRecord(){
  if (ch <= ' ' && ignoreLeadingWhitespace) {
    skipWhitespace();
  }
  while (ch != newLine && ch != '\0') {
    parseField();
    if (ch != newLine) {
      ch=input.nextChar();
      if (ch == newLine) {
        output.emptyParsed();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected void parseRecord(){
  if (ch <= ' ' && ignoreLeadingWhitespace) {
    skipWhitespace();
  }
  while (ch != newLine) {
    parseField();
    if (ch != newLine) {
      ch=input.nextChar();
      if (ch == newLine) {
        output.emptyParsed();
      }
    }
  }
}
Program: 163492
Project: 163492
Buggy source:
private void parseQuotedValue(){
  char prev='\0';
  ch=input.nextChar();
  while (!(prev == quote && (ch == delimiter || ch <= ' ')) && ch != '\0') {
    if (ch != quote) {
      output.appender.append(ch);
      prev=ch;
    }
 else     if (prev == quoteEscape) {
      output.appender.append(quote);
      prev='\0';
    }
 else {
      prev=ch;
    }
    ch=input.nextChar();
  }
  if (ch <= ' ') {
    skipWhitespace();
  }
}

Fixed version (ground truth):
private void parseQuotedValue(){
  char prev='\0';
  ch=input.nextChar();
  while (!(prev == quote && (ch == delimiter || ch <= ' '))) {
    if (ch != quote) {
      output.appender.append(ch);
      prev=ch;
    }
 else     if (prev == quoteEscape) {
      output.appender.append(quote);
      prev='\0';
    }
 else {
      prev=ch;
    }
    ch=input.nextChar();
  }
  if (ch <= ' ') {
    skipWhitespace();
  }
}
Program: 163493
Project: 163493
Buggy source:
private void parseValue(){
  if (ignoreTrailingWhitespace) {
    while (ch != delimiter && ch != newLine && ch != '\0') {
      output.appender.appendIgnoringWhitespace(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (ch != delimiter && ch != newLine && ch != '\0') {
      output.appender.append(ch);
      ch=input.nextChar();
    }
  }
}

Fixed version (ground truth):
private void parseValue(){
  if (ignoreTrailingWhitespace) {
    while (ch != delimiter && ch != newLine) {
      output.appender.appendIgnoringWhitespace(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (ch != delimiter && ch != newLine) {
      output.appender.append(ch);
      ch=input.nextChar();
    }
  }
}
Program: 163494
Project: 163494
Buggy source:
private void skipWhitespace(){
  while (ch <= ' ' && ch != delimiter && ch != newLine && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipWhitespace(){
  while (ch <= ' ' && ch != delimiter && ch != newLine) {
    ch=input.nextChar();
  }
}
Program: 163495
Project: 163495
Buggy source:
private void readValueUntilNewLine(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0 && ch != newLine && ch != '\0') {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0 && ch != newLine && ch != '\0') {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}

Fixed version (ground truth):
private void readValueUntilNewLine(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0 && ch != newLine) {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0 && ch != newLine) {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}
Program: 163496
Project: 163496
Buggy source:
private void readValue(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0 && ch != '\0') {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0 && ch != '\0') {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}

Fixed version (ground truth):
private void readValue(){
  if (ignoreTrailingWhitespace) {
    while (length-- > 0) {
      output.appender.appendIgnoringWhitespaceAndPadding(ch);
      ch=input.nextChar();
    }
  }
 else {
    while (length-- > 0) {
      output.appender.appendIgnoringPadding(ch);
      ch=input.nextChar();
    }
  }
}
Program: 163497
Project: 163497
Buggy source:
private void skipToNewLine(){
  while (ch != newLine && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipToNewLine(){
  while (ch != newLine) {
    ch=input.nextChar();
  }
}
Program: 163498
Project: 163498
Buggy source:
private void skipPadding(){
  while (ch == padding && length-- > 0 && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipPadding(){
  while (ch == padding && length-- > 0) {
    ch=input.nextChar();
  }
}
Program: 163499
Project: 163499
Buggy source:
private void skipWhitespace(){
  while (ch <= ' ' && length-- > 0 && ch != '\0') {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipWhitespace(){
  while (ch <= ' ' && length-- > 0) {
    ch=input.nextChar();
  }
}
Program: 163500
Project: 163500
Buggy source:
/** 
 * Parses the entirety of a given input and delegates each parsed row to an instance of   {@link RowProcessor}, defined by   {@link CommonParserSettings#getRowProcessor()}.
 * @param reader The input to be parsed.
 */
public final void parse(Reader reader){
  beginParsing(reader);
  try {
    while (!context.stopped) {
      ch=input.nextChar();
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
      }
    }
  }
 catch (  EOFException ex) {
    if (output.column != 0) {
      if (output.appender.length() > 0) {
        output.valueParsed();
      }
 else {
        output.emptyParsed();
      }
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
      }
    }
 else     if (output.appender.length() > 0) {
      output.valueParsed();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
      }
    }
  }
catch (  Exception ex) {
    throw new TextParsingException(context,ex);
  }
 finally {
    stopParsing();
  }
}

Fixed version (ground truth):
/** 
 * Parses the entirety of a given input and delegates each parsed row to an instance of   {@link RowProcessor}, defined by   {@link CommonParserSettings#getRowProcessor()}.
 * @param reader The input to be parsed.
 */
public final void parse(Reader reader){
  beginParsing(reader);
  try {
    while (!context.stopped && (ch=input.nextChar()) != '\0') {
      if (ch == comment) {
        input.skipLines(1);
        continue;
      }
      output.clear();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        processor.rowProcessed(row,context);
        if (recordsToRead > 0 && context.currentRecord() >= recordsToRead) {
          context.stop();
        }
      }
    }
  }
 catch (  Exception ex) {
    throw new TextParsingException(context,ex);
  }
 finally {
    stopParsing();
  }
}