Program: 194466
Project: 194466
Buggy source:
/** 
 * Return the start position of the line, given the left and right bounds of the margins.
 * @param line the line index
 * @param left the left bounds (0, or leading margin if ltr para)
 * @param right the right bounds (width, minus leading margin if rtl para)
 * @return the start position of the line (to right of line if rtl para)
 */
private int getLineStartPos(int line,int left,int right){
  Alignment align=getParagraphAlignment(line);
  int dir=getParagraphDirection(line);
  if (align == Alignment.ALIGN_LEFT) {
    align=(dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE;
  }
 else   if (align == Alignment.ALIGN_RIGHT) {
    align=(dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_OPPOSITE : Alignment.ALIGN_NORMAL;
  }
  int x;
  if (align == Alignment.ALIGN_NORMAL) {
    if (dir == DIR_LEFT_TO_RIGHT) {
      x=left;
    }
 else {
      x=right;
    }
  }
 else {
    TabStops tabStops=null;
    if (mSpannedText && getLineContainsTab(line)) {
      Spanned spanned=(Spanned)mText;
      int start=getLineStart(line);
      int spanEnd=spanned.nextSpanTransition(start,spanned.length(),TabStopSpan.class);
      TabStopSpan[] tabSpans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
      if (tabSpans.length > 0) {
        tabStops=new TabStops(TAB_INCREMENT,tabSpans);
      }
    }
    int max=(int)getLineExtent(line,tabStops,false);
    if (align == Alignment.ALIGN_OPPOSITE) {
      if (dir == DIR_LEFT_TO_RIGHT) {
        x=right - max;
      }
 else {
        x=left - max;
      }
    }
 else {
      max=max & ~1;
      x=(left + right - max) >> 1;
    }
  }
  return x;
}

Fixed version (ground truth):
/** 
 * Return the start position of the line, given the left and right bounds of the margins.
 * @param line the line index
 * @param left the left bounds (0, or leading margin if ltr para)
 * @param right the right bounds (width, minus leading margin if rtl para)
 * @return the start position of the line (to right of line if rtl para)
 */
private int getLineStartPos(int line,int left,int right){
  Alignment align=getParagraphAlignment(line);
  int dir=getParagraphDirection(line);
  if (align == Alignment.ALIGN_LEFT) {
    align=(dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE;
  }
 else   if (align == Alignment.ALIGN_RIGHT) {
    align=(dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_OPPOSITE : Alignment.ALIGN_NORMAL;
  }
  int x;
  if (align == Alignment.ALIGN_NORMAL) {
    if (dir == DIR_LEFT_TO_RIGHT) {
      x=left + getIndentAdjust(line,Alignment.ALIGN_LEFT);
    }
 else {
      x=right + getIndentAdjust(line,Alignment.ALIGN_RIGHT);
    }
  }
 else {
    TabStops tabStops=null;
    if (mSpannedText && getLineContainsTab(line)) {
      Spanned spanned=(Spanned)mText;
      int start=getLineStart(line);
      int spanEnd=spanned.nextSpanTransition(start,spanned.length(),TabStopSpan.class);
      TabStopSpan[] tabSpans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
      if (tabSpans.length > 0) {
        tabStops=new TabStops(TAB_INCREMENT,tabSpans);
      }
    }
    int max=(int)getLineExtent(line,tabStops,false);
    if (align == Alignment.ALIGN_OPPOSITE) {
      if (dir == DIR_LEFT_TO_RIGHT) {
        x=right - max + getIndentAdjust(line,Alignment.ALIGN_RIGHT);
      }
 else {
        x=left - max + getIndentAdjust(line,Alignment.ALIGN_LEFT);
      }
    }
 else {
      max=max & ~1;
      x=(left + right - max) >> 1 + getIndentAdjust(line,Alignment.ALIGN_CENTER);
    }
  }
  return x;
}