Returns the index in the buffer of the end of line found.
Returns -1 if no end of line was found in the buffer.
496254
private static int findEndOfLine(final ByteBuf buffer) {
        final int n = buffer.writerIndex();
        for (int i = buffer.readerIndex(); i < n; i++) {
            final byte b = buffer.getByte(i);
            if (b == '\r' && i < n - 1 && buffer.getByte(i + 1) == '\n') {
                return i;  // \r\n
            }
        }
        return -1;  // Not found.
    }
1291551
private int getConstraintIndex(int colIndex) {

        for (int i = 0; i < imColIndex.length; i++) {
            for (int j = 0; j < imColIndex[i].length; j++) {
                if (colIndex == imColIndex[i][j]) {
                    return i;
                }    // end of if (col == imColIndex[i][j])
            }        // end of for (int j=0; j<imColIndex[i].length; j++)
        }            // end of for (int i=0; i<imColIndex.length; i++)

        return -1;
    }
190251
def get_rightmost_index(byte_index=0, file_starts=[0]):

    '''
    
    '''
    i = 1
    while i <= len(file_starts):
        start = file_starts[-i]
        if start <= byte_index:
            return len(file_starts) - i
        else:
            i += 1
    else:
        raise Exception('byte_index lower than all file_starts')
170153
private long findAfter(long offset) {
    if (size == 0) {
      return -1;
    }

    int low  = 0;
    int high = size-1;

    while (low <= high) {
      int mid = low + ((high - low) / 2);

      long i = buffer.readLong(mid * ENTRY_SIZE);
      if (i < offset) {
        low = mid + 1;
      } else if (i > offset) {
        high = mid - 1;
      } else {
        return mid;
      }
    }

    return (low < high) ? low + 1 : high + 1;
  }
55137
int nextIndexOf(char c) {
        // doesn't handle scanning for surrogates
        bufferUp();
        for (int i = bufPos; i < bufLength; i++) {
            if (c == charBuf[i])
                return i - bufPos;
        }
        return -1;
    }
1245155
public int getLine(int pos) {
	for (int i = 0; i < lines.length; i++) {
	    if (pos <= lines[i].intValue()) return i + 1;
	}
	return lines.length;
    }
1353992
def getline(self):
        """"""
        if self.index >= len(self.lines):
            line = ''
        else:
            line = self.lines[self.index]
            self.index += 1
        return line
250253
public int findIn(Source source) {
        if (source.hasNext()) {
            // maybe we are on the beginning of line already?
            if (onBol(source)) {
                return source.getOffset();
            }

            // If no find next line break
            int index = findLineBreak(source);

            if (index < 0) {
                return -1;
            }

            // Skip line break 1 or 2 characters
            index = skipLineBreak(source, index);

            // If index is not on the end of text return it otherwise it's not a beginning of line.
            if (index < source.length()) {
                return index;
            } else {
                return -1;
            }
        } else {
            return -1;
        }
    }
1042029
def get_real_end_line(token):
    
    end_line = token.end_mark.line + 1

    if not isinstance(token, yaml.ScalarToken):
        return end_line

    pos = token.end_mark.pointer - 1
    while (pos >= token.start_mark.pointer - 1 and
           token.end_mark.buffer[pos] in string.whitespace):
        if token.end_mark.buffer[pos] == '\n':
            end_line -= 1
        pos -= 1
    return end_line
1304962
def character_offset_end(self):
        
        if self._character_offset_end is None:
            offsets = self._element.xpath('CharacterOffsetEnd/text()')
            if len(offsets) > 0:
                self._character_offset_end = int(offsets[0])
        return self._character_offset_end
109608
def _get_line(self):
        """"""
        line = self._f.readline()
        if len(line) == 0:
            raise StopIteration
        return line
1220147
public static int findFirstOf(String string, String chars, int start, int end) {
        for (int i = start; i < end; i++) {
            char c = string.charAt(i);
            if (chars.indexOf(c) != -1) {
                return i;
            }
        }
        return end;
    }
27046
def get_line_number (s, index):
    """
    i = 0
    if index < 0:
        return 0
    line = 1
    while i < index:
        if s[i] == '\n':
            line += 1
        i += 1
    return line
403269
def next_match char
      start = @current_index
      start.upto(@list.length-1) do |ix|
        if @list[ix][0,1].casecmp(char) == 0
          return @list[ix] unless @list[ix] == @buffer
        end
        @current_index += 1
      end
      ## could not find, start from zero
      @current_index = 0
      start = [@list.length()-1, start].min
      0.upto(start) do |ix|
        if @list[ix][0,1].casecmp(char) == 0
          return @list[ix] unless @list[ix] == @buffer
        end
        @current_index += 1
      end
      @current_index = [@list.length()-1, @current_index].min
      return nil
    end
302434
def _find_last_line_index(contents):
    """"""
    lineno = 0
    headerblock = re.compile(r"^{0}.*$".format(_ALL_COMMENT))

    if not len(contents):
        raise RuntimeError("""File does not not have any contents""")

    while headerblock.match(contents[lineno]):
        if lineno + 1 == len(contents):
            raise RuntimeError("""No end of headerblock in file""")
        lineno = lineno + 1

    if lineno < 2:
        raise RuntimeError("""Headerblock must have at least two lines""")

    return lineno - 1
1184852
public int indexOf(byte b) {
        if (_buf.hasArray()) {
            byte[] array = _buf.array();
            int arrayOffset = _buf.arrayOffset();
            int startAt = arrayOffset + position();
            int endAt = arrayOffset + limit();

            for (int i = startAt; i < endAt; i++) {
                if (array[i] == b) {
                    return i - arrayOffset;
                }
            }
            return -1;
        } else {
            int startAt = _buf.position();
            int endAt = _buf.limit();

            for (int i = startAt; i < endAt; i++) {
                if (_buf.get(i) == b) {
                    return i;
                }
            }
            return -1;
        }
    }
40327
private static int getLine0(int[] newlines, int index) {
        int j = Arrays.binarySearch(newlines, index);
        return j >= 0 ? j : -(j + 1);
    }