cut: Don't skip final character when using byte or character ranges

This commit is contained in:
Tim Ledbetter 2024-05-13 07:06:43 +01:00
parent 157da60710
commit 9d2e3b2f14

View file

@ -130,7 +130,7 @@ static bool expand_list(ByteString& list, Vector<Range>& ranges)
static void process_line_bytes(StringView line, Vector<Range> const& ranges)
{
for (auto& i : ranges) {
if (i.m_from >= line.length())
if (i.m_from > line.length())
continue;
auto to = min(i.m_to, line.length());
@ -143,7 +143,7 @@ static void process_line_bytes(StringView line, Vector<Range> const& ranges)
static void process_line_characters(StringView line, Vector<Range> const& ranges)
{
for (auto const& range : ranges) {
if (range.m_from >= line.length())
if (range.m_from > line.length())
continue;
auto s = String::from_utf8(line).release_value_but_fixme_should_propagate_errors();