Split CONTENT on a line boundary into a prefix smaller than 64k and
        a suffix containing the remainder, omitting the splitting newline.
354748
def _splitBigChunk(self, content, logid):
        
        # if it's small enough, just return it
        if len(content) < self.MAX_CHUNK_SIZE:
            return content, None

        # find the last newline before the limit
        i = content.rfind(b'\n', 0, self.MAX_CHUNK_SIZE)
        if i != -1:
            return content[:i], content[i + 1:]

        log.msg('truncating long line for log %d' % logid)

        # first, truncate this down to something that decodes correctly
        truncline = content[:self.MAX_CHUNK_SIZE]
        while truncline:
            try:
                truncline.decode('utf-8')
                break
            except UnicodeDecodeError:
                truncline = truncline[:-1]

        # then find the beginning of the next line
        i = content.find(b'\n', self.MAX_CHUNK_SIZE)
        if i == -1:
            return truncline, None
        return truncline, content[i + 1:]
1360564
private void split(Suffix<T, S> suffix, ActivePoint<T, S> activePoint) {
        Node<T, S> breakNode = new Node<>(this, sequence, tree);
        Edge<T, S> newEdge = new Edge<>(suffix.getEndPosition() - 1, breakNode,
                sequence, tree);
        breakNode.insert(newEdge);
        Edge<T, S> oldEdge = new Edge<>(start + activePoint.getLength(),
                breakNode, sequence, tree);
        oldEdge.end = end;
        oldEdge.terminal = this.terminal;
        breakNode.insert(oldEdge);
        this.terminal = breakNode;
        end = start + activePoint.getLength();
        tree.setSuffixLink(breakNode);
        tree.incrementInsertCount();
    }
946541
def _strip_line_sep(self, s):
        """"""
        if s[-2:] == b'\r\n':
            return s[:-2]
        elif s[-1:] == b'\n':
            return s[:-1]
        else:
            return s
1334100
def trim(self, prefixes):
        ""
        _prefixes, prefixes = set(map(lambda k:self._prepare_key(k), prefixes)), list()
        for t in lookahead(sorted(_prefixes)):
            if t[1] is not None:
                if t[0] == commonprefix(t):
                    continue
            prefixes.append(t[0])
        length = 0
        for prefix in prefixes:
            length += self._trim(prefix)
        return length
1176173
def strip_end(text, suffix):
    """"""
    if not text.endswith(suffix):
        return text
    return text[:len(text)-len(suffix)]
917815
def _get_trailing_whitespace(marker, s):
    
    suffix = ''
    start = s.index(marker) + len(marker)
    i = start
    while i < len(s):
        if s[i] in ' \t':
            suffix += s[i]
        elif s[i] in '\r\n':
            suffix += s[i]
            if s[i] == '\r' and i + 1 < len(s) and s[i + 1] == '\n':
                suffix += s[i + 1]
            break
        else:
            break
        i += 1
    return suffix
1145404
def _SkipLengthDelimited(buffer, pos, end):
  """"""

  (size, pos) = _DecodeVarint(buffer, pos)
  pos += size
  if pos > end:
    raise _DecodeError('Truncated message.')
  return pos
1162155
function trim(text) {
  var MAX_INDENT = 9999;
  var empty = RegExp.prototype.test.bind(/^\s*$/);
  var lines = text.split('\n');
  var minIndent = MAX_INDENT;
  var indentRegExp;
  var ignoreLine = (lines[0][0] != ' '  && lines.length > 1);
  // ignore first line if it has no indentation and there is more than one line

  lines.forEach(function(line){
    if (ignoreLine) {
      ignoreLine = false;
      return;
    }

    var indent = line.match(/^\s*/)[0].length;
    if (indent > 0 || minIndent == MAX_INDENT) {
      minIndent = Math.min(minIndent, indent);
    }
  });

  indentRegExp = new RegExp('^\\s{0,' + minIndent + '}');

  for ( var i = 0; i < lines.length; i++) {
    lines[i] = lines[i].replace(indentRegExp, '');
  }

  // remove leading lines
  while (empty(lines[0])) {
    lines.shift();
  }

  // remove trailing
  while (empty(lines[lines.length - 1])) {
    lines.pop();
  }
  return lines.join('\n');
}
208480
def strip_suffix(string, suffix):
    """"""
    if string.endswith(suffix):
        return string[:-(len(suffix))]
    return string
658593
function replaceWithSurround(text, find, prefix, suffix) {
  const escapedString = escapeRegex(find);
  const re = new RegExp(escapedString, 'gi');
  return text.replace(re, matched => prefix + matched + suffix);
}
620646
def trim(self, text):
        
        lines = text.splitlines()
        firstline = lines[0] or lines[1]
        indent = len(firstline) - len(firstline.lstrip())
        return '\n'.join(x[indent:] for x in lines if x.strip())
962678
def split_line(self):
        
        # coordinate of the # symbol or end of the line (-1) if not found
        hash_or_end = self.line.find("#")
        temp = self.line[self.region_end:hash_or_end].strip(" |")
        self.coord_str = regex_paren.sub("", temp)

        # don't want any meta_str if there is no metadata found
        if hash_or_end >= 0:
            self.meta_str = self.line[hash_or_end:]
        else:
            self.meta_str = ""
381093
def subpacket_prefix_len(item):
    """"""
    n = len(item)
    if n >= 8384:
        prefix = b'\xFF' + struct.pack('>L', n)
    elif n >= 192:
        n = n - 192
        prefix = struct.pack('BB', (n // 256) + 192, n % 256)
    else:
        prefix = struct.pack('B', n)
    return prefix + item
346349
def split_markers_from_line(line):
    # type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]]
    """"""
    if not any(line.startswith(uri_prefix) for uri_prefix in SCHEME_LIST):
        marker_sep = ";"
    else:
        marker_sep = "; "
    markers = None
    if marker_sep in line:
        line, markers = line.split(marker_sep, 1)
        markers = markers.strip() if markers else None
    return line, markers
114171
def indentsize(line):
    """"""
    expline = string.expandtabs(line)
    return len(expline) - len(string.lstrip(expline))
22936
def followingPrefix(prefix):
        """"""
        prefixBytes = array('B', prefix)

        changeIndex = len(prefixBytes) - 1
        while (changeIndex >= 0 and prefixBytes[changeIndex] == 0xff ):
            changeIndex = changeIndex - 1;
        if(changeIndex < 0):
            return None
        newBytes = array('B', prefix[0:changeIndex + 1])
        newBytes[changeIndex] = newBytes[changeIndex] + 1
        return newBytes.tostring()
332355
def remove_prefix(text, prefix):
	
	null, prefix, rest = text.rpartition(prefix)
	return rest