| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | |||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // | ||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/boostorg/url | ||
| 8 | // | ||
| 9 | |||
| 10 | |||
| 11 | #include <boost/url/detail/config.hpp> | ||
| 12 | #include <boost/url/grammar/error.hpp> | ||
| 13 | #include <boost/url/grammar/literal_rule.hpp> | ||
| 14 | #include <boost/assert.hpp> | ||
| 15 | #include <cstring> | ||
| 16 | |||
| 17 | namespace boost { | ||
| 18 | namespace urls { | ||
| 19 | namespace grammar { | ||
| 20 | |||
| 21 | auto | ||
| 22 | 10 | literal_rule:: | |
| 23 | parse( | ||
| 24 | char const*& it, | ||
| 25 | char const* end) const noexcept -> | ||
| 26 | system::result<value_type> | ||
| 27 | { | ||
| 28 | // Can't have a literal | ||
| 29 | // with an empty string! | ||
| 30 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | BOOST_ASSERT(n_ > 0); |
| 31 | |||
| 32 | 10 | std::size_t n = end - it; | |
| 33 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
|
10 | if(n >= n_) |
| 34 | { | ||
| 35 | 4 | if(std::memcmp( | |
| 36 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | it, s_, n_) != 0) |
| 37 | { | ||
| 38 | // non-match | ||
| 39 | 1 | BOOST_URL_RETURN_EC( | |
| 40 | error::mismatch); | ||
| 41 | } | ||
| 42 | 3 | it += n_; | |
| 43 | 3 | return core::string_view( | |
| 44 | 3 | it - n_, it); | |
| 45 | } | ||
| 46 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
|
6 | if(n > 0) |
| 47 | { | ||
| 48 | // short input | ||
| 49 | 5 | if(std::memcmp( | |
| 50 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | it, s_, n) != 0) |
| 51 | { | ||
| 52 | // non-match | ||
| 53 | 2 | BOOST_URL_RETURN_EC( | |
| 54 | error::mismatch); | ||
| 55 | } | ||
| 56 | // prefix matches | ||
| 57 | 3 | BOOST_URL_RETURN_EC( | |
| 58 | error::need_more); | ||
| 59 | } | ||
| 60 | // end | ||
| 61 | 1 | BOOST_URL_RETURN_EC( | |
| 62 | error::need_more); | ||
| 63 | } | ||
| 64 | |||
| 65 | } // grammar | ||
| 66 | } // urls | ||
| 67 | } // boost | ||
| 68 | |||
| 69 |