From 6e1940e93060ea8e1b83bea932447bdd693a598e Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Mon, 15 Feb 2021 19:55:55 +0100
Subject: [PATCH] protocol/RangeArg: add static method OpenEnded()

---
 src/protocol/ArgParser.cxx | 2 +-
 src/protocol/RangeArg.hxx  | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx
index 98cf74150..deaa8f08f 100644
--- a/src/protocol/ArgParser.cxx
+++ b/src/protocol/ArgParser.cxx
@@ -94,7 +94,7 @@ ParseCommandArgRange(const char *s)
 						  s);
 
 		if (test == test2)
-			value = std::numeric_limits<int>::max();
+			return RangeArg::OpenEnded(range.start);
 
 		if (value < 0)
 			throw FormatProtocolError(ACK_ERROR_ARG,
diff --git a/src/protocol/RangeArg.hxx b/src/protocol/RangeArg.hxx
index a55a2755c..ab00dc990 100644
--- a/src/protocol/RangeArg.hxx
+++ b/src/protocol/RangeArg.hxx
@@ -25,8 +25,15 @@
 struct RangeArg {
 	unsigned start, end;
 
+	/**
+	 * Construct an open-ended range starting at the given index.
+	 */
+	static constexpr RangeArg OpenEnded(unsigned start) noexcept {
+		return { start, std::numeric_limits<unsigned>::max() };
+	}
+
 	static constexpr RangeArg All() noexcept {
-		return { 0, std::numeric_limits<unsigned>::max() };
+		return OpenEnded(0);
 	}
 
 	constexpr bool operator==(RangeArg other) const noexcept {