From 7068a697b235f1ae05bc1a5cf93e7eeefbe7a1df Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 30 Oct 2016 20:15:35 +0100 Subject: Fix PRBS url parsing --- src/input/Prbs.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/input/Prbs.cpp b/src/input/Prbs.cpp index b9e244b..8e5a9ae 100644 --- a/src/input/Prbs.cpp +++ b/src/input/Prbs.cpp @@ -46,17 +46,23 @@ const uint32_t PRBS_DEFAULT_POLY = (1 << 19) | (1 << 16) | 1; int Prbs::open(const string& name) { - if (name.empty()) { + if (name.substr(0, 7) != "prbs://") { + throw logic_error("Invalid PRBS name"); + } + + const string& url_polynomial = name.substr(7); + + if (url_polynomial.empty()) { m_prbs.setup(PRBS_DEFAULT_POLY); } else { - if (name[0] != ':') { + if (url_polynomial[0] != ':') { throw invalid_argument( "Invalid PRBS address format. " "Must be prbs://:polynomial."); } - const string poly_str = name.substr(1); + const string poly_str = url_polynomial.substr(1); long polynomial = hexparse(poly_str); -- cgit v1.2.3