tools/clang/scripts/apply_edits.py
def _FindStartOfPreviousLine(contents, index):
  """ Requires that `index` points to the start of a line.
      Returns an index to the start of the previous line.
  """
  assert (index > 0)
  assert (contents[index - 1] in _NEWLINE_CHARACTERS)

  # Go back over the newline characters associated with the *single* end of a
  # line just before `index`, despite of whether end of a line is designated by
  # "\r", "\n" or "\r\n".  Examples:
  # 1. "... \r\n <new index> \r\n <old index> ...
  # 2. "... \n <new index> \n <old index> ...
  index = index - 1
  if index > 0 and contents[index - 1] in _NEWLINE_CHARACTERS and \
      contents[index - 1] != contents[index]:
    index = index - 1

  # Go back until `index` points right after an end of a line (or at the
  # beginning of the `contents`).
  while index > 0 and contents[index - 1] not in _NEWLINE_CHARACTERS:
    index = index - 1

  return index
 Requires that `index` points to the start of a line.
      Returns an index to the start of the previous line.
  
Requires that `index` points to the start of a line.
Returns an index to the start of the previous line.
Requires that ` index ` points to the start of a line . Returns an index to the start of the previous line .
def _FindStartOfPreviousLine(contents, index):
  assert (index > 0)
  assert (contents[index - 1] in _NEWLINE_CHARACTERS)
  index = index - 1
  if index > 0 and contents[index - 1] in _NEWLINE_CHARACTERS and \
      contents[index - 1] != contents[index]:
    index = index - 1
  while index > 0 and contents[index - 1] not in _NEWLINE_CHARACTERS:
    index = index - 1
  return index
def _FindStartOfPreviousLine ( contents , index ) : assert ( index > 0 ) assert ( contents [ index - 1 ] in _NEWLINE_CHARACTERS ) index = index - 1 if index > 0 and contents [ index - 1 ] in _NEWLINE_CHARACTERS and contents [ index - 1 ] != contents [ index ] : index = index - 1 while index > 0 and contents [ index - 1 ] not in _NEWLINE_CHARACTERS : index = index - 1 return index
Requires that `index` points to the start of a line.
Requires that ` index ` points to the start of a line .
""" Requires that `index` points to the start of a line.
      Returns an index to the start of the previous line.
  """ # Go back over the newline characters associated with the *single* end of a # line just before `index`, despite of whether end of a line is designated by # "\r", "\n" or "\r\n".  Examples: # 1. "... \r\n <new index> \r\n <old index> ... # 2. "... \n <new index> \n <old index> ... # Go back until `index` points right after an end of a line (or at the # beginning of the `contents`).
contents
index