Program: 50397
Project: 50397
Buggy source:
private void parseCurrentLine(){
  Arrays.fill(columnStarts,0);
  Arrays.fill(columnEnds,0);
  Arrays.fill(fieldStarts,0);
  Arrays.fill(fieldEnds,0);
  columnStarts[0]=0;
  int columnIndex=0;
  int fieldIndex=0;
  lineLength=line.length();
  int lineFieldIndexToColumnIndex[]=new int[numberOfFields];
  Arrays.fill(lineFieldIndexToColumnIndex,-1);
  previousColumnFieldIndices.clear();
  for (int i=0; i < lineLength; i++) {
    final char c=line.charAt(i);
    if (c == columnSeparatorCharacter) {
      columnEnds[columnIndex]=i;
      if (columnIndex + 1 < numberOfColumns) {
        columnStarts[columnIndex + 1]=i + 1;
      }
    }
    if (c == columnSeparatorCharacter || c == fieldSeparatorCharacter || (columnIndex >= formatColumnIndex && c == formatFieldSeparatorCharacter)) {
      if (TSV) {
        fieldEnds[columnIndex]=columnEnds[columnIndex];
        fieldStarts[columnIndex]=columnStarts[columnIndex];
        fieldIndex=columnIndex;
        lineFieldIndexToColumnIndex[fieldIndex]=columnIndex;
      }
 else {
        fieldEnds[fieldIndex]=i;
        if (fieldIndex + 1 < numberOfFields) {
          fieldStarts[fieldIndex + 1]=i + 1;
        }
        previousColumnFieldIndices.add(fieldIndex);
        fieldIndex++;
      }
    }
    if (c == columnSeparatorCharacter) {
      push(columnIndex,lineFieldIndexToColumnIndex,previousColumnFieldIndices);
      columnIndex++;
    }
  }
  int numberOfFieldsOnLine=fieldIndex;
  int numberOfColumnsOnLine=columnIndex;
  columnStarts[0]=0;
  columnEnds[numberOfColumnsOnLine]=line.length();
  fieldStarts[0]=0;
  fieldEnds[numberOfFieldsOnLine]=line.length();
  previousColumnFieldIndices.add(fieldIndex);
  push(columnIndex,lineFieldIndexToColumnIndex,previousColumnFieldIndices);
  Arrays.fill(fieldPermutation,-1);
  for (  ColumnInfo c : columns) {
    c.formatIndex=0;
  }
  for (int lineFieldIndex=0; lineFieldIndex <= numberOfFieldsOnLine; lineFieldIndex++) {
    int start=fieldStarts[lineFieldIndex];
    int end=fieldEnds[lineFieldIndex];
    final int cIndex=lineFieldIndexToColumnIndex[lineFieldIndex];
    ColumnInfo column=columnList.get(cIndex);
    int colMinGlobalFieldIndex=Integer.MAX_VALUE;
    int colMaxGlobalFieldIndex=Integer.MIN_VALUE;
    final ColumnFields fields=column.fields;
    fields.rebuildList();
    for (int fi=0; fi < fields.size(); ++fi) {
      ColumnField f=fields.get(fi);
      colMinGlobalFieldIndex=Math.min(colMinGlobalFieldIndex,f.globalFieldIndex);
      colMaxGlobalFieldIndex=Math.max(colMaxGlobalFieldIndex,f.globalFieldIndex);
    }
    final int formatColumnIndex=TSV ? -1 : formatColumn.columnIndex;
    final int startFormatColumn=TSV ? 0 : columnStarts[formatColumnIndex];
    final int endFormatColumn=TSV ? 0 : columnEnds[formatColumnIndex];
    final String[] formatTokens=split(line,formatFieldSeparatorCharacter,startFormatColumn,endFormatColumn);
    for (int fi=0; fi < fields.size(); ++fi) {
      final ColumnField f=fields.get(fi);
      if (fieldPermutation[f.globalFieldIndex] != -1) {
        continue;
      }
      if (colMaxGlobalFieldIndex == colMinGlobalFieldIndex) {
        fieldPermutation[f.globalFieldIndex]=lineFieldIndex;
        break;
      }
 else {
        int j=start;
        final String id=f.id;
        int matchLength=0;
        for (int i=0; i < id.length(); i++) {
          if (j >= end) {
            break;
          }
          final char linechar=line.charAt(j);
          if (id.charAt(i) != linechar) {
            matchLength=-1;
            break;
          }
          matchLength++;
          j++;
        }
        if (matchLength == id.length() && line.charAt(j) == '=' || (j == end && f.type == ColumnType.Flag)) {
          fieldPermutation[f.globalFieldIndex]=lineFieldIndex;
          if (f.type != ColumnType.Flag) {
            fieldStarts[lineFieldIndex]+=f.id.length() + 1;
          }
          break;
        }
 else {
          if (column.useFormat && column.formatIndex < formatTokens.length) {
            if (f.id.equals(formatTokens[column.formatIndex])) {
              fieldPermutation[f.globalFieldIndex]=lineFieldIndex;
              column.formatIndex++;
              break;
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void parseCurrentLine(){
  Arrays.fill(columnStarts,0);
  Arrays.fill(columnEnds,0);
  Arrays.fill(fieldStarts,0);
  Arrays.fill(fieldEnds,0);
  columnStarts[0]=0;
  int columnIndex=0;
  int fieldIndex=0;
  lineLength=line.length();
  int lineFieldIndexToColumnIndex[]=new int[numberOfFields];
  Arrays.fill(lineFieldIndexToColumnIndex,-1);
  previousColumnFieldIndices.clear();
  for (int i=0; i < lineLength; i++) {
    final char c=line.charAt(i);
    if (c == columnSeparatorCharacter) {
      columnEnds[columnIndex]=i;
      if (columnIndex + 1 < numberOfColumns) {
        columnStarts[columnIndex + 1]=i + 1;
      }
    }
    if (c == columnSeparatorCharacter || c == fieldSeparatorCharacter || (columnIndex >= formatColumnIndex && c == formatFieldSeparatorCharacter)) {
      if (TSV) {
        fieldEnds[columnIndex]=columnEnds[columnIndex];
        fieldStarts[columnIndex]=columnStarts[columnIndex];
        fieldIndex=columnIndex;
        lineFieldIndexToColumnIndex[fieldIndex]=columnIndex;
      }
 else {
        fieldEnds[fieldIndex]=i;
        if (fieldIndex + 1 < numberOfFields) {
          fieldStarts[fieldIndex + 1]=i + 1;
        }
        previousColumnFieldIndices.add(fieldIndex);
        fieldIndex++;
      }
    }
    if (c == columnSeparatorCharacter) {
      if (TSV) {
        lineFieldIndexToColumnIndex[fieldIndex]=columnIndex;
      }
      push(columnIndex,lineFieldIndexToColumnIndex,previousColumnFieldIndices);
      columnIndex++;
    }
  }
  int numberOfFieldsOnLine=fieldIndex;
  int numberOfColumnsOnLine=columnIndex;
  columnStarts[0]=0;
  columnEnds[numberOfColumnsOnLine - (TSV ? 1 : 0)]=line.length();
  fieldStarts[0]=0;
  fieldEnds[numberOfFieldsOnLine - (TSV ? 1 : 0)]=line.length();
  previousColumnFieldIndices.add(fieldIndex);
  push(columnIndex,lineFieldIndexToColumnIndex,previousColumnFieldIndices);
  Arrays.fill(fieldPermutation,-1);
  for (  ColumnInfo c : columns) {
    c.formatIndex=0;
  }
  for (int lineFieldIndex=0; lineFieldIndex <= numberOfFieldsOnLine; lineFieldIndex++) {
    int start=fieldStarts[lineFieldIndex];
    int end=fieldEnds[lineFieldIndex];
    final int cIndex=lineFieldIndexToColumnIndex[lineFieldIndex];
    if (cIndex >= columnList.size()) {
      break;
    }
    ColumnInfo column=columnList.get(cIndex);
    int colMinGlobalFieldIndex=Integer.MAX_VALUE;
    int colMaxGlobalFieldIndex=Integer.MIN_VALUE;
    final ColumnFields fields=column.fields;
    fields.rebuildList();
    for (int fi=0; fi < fields.size(); ++fi) {
      ColumnField f=fields.get(fi);
      colMinGlobalFieldIndex=Math.min(colMinGlobalFieldIndex,f.globalFieldIndex);
      colMaxGlobalFieldIndex=Math.max(colMaxGlobalFieldIndex,f.globalFieldIndex);
    }
    final int formatColumnIndex=TSV ? -1 : formatColumn.columnIndex;
    final int startFormatColumn=TSV ? 0 : columnStarts[formatColumnIndex];
    final int endFormatColumn=TSV ? 0 : columnEnds[formatColumnIndex];
    final String[] formatTokens=split(line,formatFieldSeparatorCharacter,startFormatColumn,endFormatColumn);
    for (int fi=0; fi < fields.size(); ++fi) {
      final ColumnField f=fields.get(fi);
      if (fieldPermutation[f.globalFieldIndex] != -1) {
        continue;
      }
      if (colMaxGlobalFieldIndex == colMinGlobalFieldIndex) {
        fieldPermutation[f.globalFieldIndex]=lineFieldIndex;
        break;
      }
 else {
        int j=start;
        final String id=f.id;
        int matchLength=0;
        for (int i=0; i < id.length(); i++) {
          if (j >= end) {
            break;
          }
          final char linechar=line.charAt(j);
          if (id.charAt(i) != linechar) {
            matchLength=-1;
            break;
          }
          matchLength++;
          j++;
        }
        if (matchLength == id.length() && line.charAt(j) == '=' || (j == end && f.type == ColumnType.Flag)) {
          fieldPermutation[f.globalFieldIndex]=lineFieldIndex;
          if (f.type != ColumnType.Flag) {
            fieldStarts[lineFieldIndex]+=f.id.length() + 1;
          }
          break;
        }
 else {
          if (column.useFormat && column.formatIndex < formatTokens.length) {
            if (f.id.equals(formatTokens[column.formatIndex])) {
              fieldPermutation[f.globalFieldIndex]=lineFieldIndex;
              column.formatIndex++;
              break;
            }
          }
        }
      }
    }
  }
}