def _adjust_indices(start, end, length):
    """helper to fixup start/end slice values"""
    if end > length:
        end = length
    elif end < 0:
        end += length
        if end < 0:
            end = 0
    if start < 0:
        start += length
        if start < 0:
            start = 0
    return start, end
