diff options
Diffstat (limited to 'deps/ada/ada.cpp')
-rw-r--r-- | deps/ada/ada.cpp | 89 |
1 files changed, 41 insertions, 48 deletions
diff --git a/deps/ada/ada.cpp b/deps/ada/ada.cpp index be7e778bac..1070ef6814 100644 --- a/deps/ada/ada.cpp +++ b/deps/ada/ada.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2023-04-17 12:20:41 -0400. Do not edit! */ +/* auto-generated on 2023-04-20 18:39:35 -0400. Do not edit! */ /* begin file src/ada.cpp */ #include "ada.h" /* begin file src/checkers.cpp */ @@ -10501,7 +10501,7 @@ ada_unused std::string get_state(ada::state s) { } } -ada_really_inline std::optional<std::string_view> prune_fragment( +ada_really_inline std::optional<std::string_view> prune_hash( std::string_view& input) noexcept { // compiles down to 20--30 instructions including a class to memchr (C // function). this function should be quite fast. @@ -10509,10 +10509,10 @@ ada_really_inline std::optional<std::string_view> prune_fragment( if (location_of_first == std::string_view::npos) { return std::nullopt; } - std::string_view fragment = input; - fragment.remove_prefix(location_of_first + 1); + std::string_view hash = input; + hash.remove_prefix(location_of_first + 1); input.remove_suffix(input.size() - location_of_first); - return fragment; + return hash; } ada_really_inline bool shorten_path(std::string& path, @@ -10523,9 +10523,9 @@ ada_really_inline bool shorten_path(std::string& path, // If url’s scheme is "file", path’s size is 1, and path[0] is a normalized // Windows drive letter, then return. if (type == ada::scheme::type::FILE && - first_delimiter == std::string_view::npos) { + first_delimiter == std::string_view::npos && !path.empty()) { if (checkers::is_normalized_windows_drive_letter( - std::string_view(path.data() + 1, first_delimiter - 1))) { + helpers::substring(path, 1))) { return false; } } @@ -10547,9 +10547,9 @@ ada_really_inline bool shorten_path(std::string_view& path, // If url’s scheme is "file", path’s size is 1, and path[0] is a normalized // Windows drive letter, then return. if (type == ada::scheme::type::FILE && - first_delimiter == std::string_view::npos) { + first_delimiter == std::string_view::npos && !path.empty()) { if (checkers::is_normalized_windows_drive_letter( - std::string_view(path.data() + 1, first_delimiter - 1))) { + helpers::substring(path, 1))) { return false; } } @@ -10998,8 +10998,8 @@ ada_really_inline void strip_trailing_spaces_from_opaque_path( url_type& url) noexcept { ada_log("helpers::strip_trailing_spaces_from_opaque_path"); if (!url.has_opaque_path) return; - if (url.base_fragment_has_value()) return; - if (url.base_search_has_value()) return; + if (url.has_hash()) return; + if (url.has_search()) return; auto path = std::string(url.get_pathname()); while (!path.empty() && path.back() == ' ') { @@ -11451,7 +11451,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) { // If url includes credentials or has a non-null port, and buffer is // "file", then return. - if ((includes_credentials() || port.has_value()) && + if ((has_credentials() || port.has_value()) && parsed_type == ada::scheme::type::FILE) { return true; } @@ -11496,7 +11496,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) { // If url includes credentials or has a non-null port, and buffer is // "file", then return. - if ((includes_credentials() || port.has_value()) && _buffer == "file") { + if ((has_credentials() || port.has_value()) && _buffer == "file") { return true; } @@ -11648,7 +11648,7 @@ std::string url::to_string() const { answer.append("\t\"protocol\":\""); helpers::encode_json(get_protocol(), back); answer.append("\",\n"); - if (includes_credentials()) { + if (has_credentials()) { answer.append("\t\"username\":\""); helpers::encode_json(username, back); answer.append("\",\n"); @@ -11671,16 +11671,16 @@ std::string url::to_string() const { answer.append("\",\n"); answer.append("\t\"opaque path\":"); answer.append((has_opaque_path ? "true" : "false")); - if (base_search_has_value()) { + if (has_search()) { answer.append(",\n"); answer.append("\t\"query\":\""); helpers::encode_json(query.value(), back); answer.append("\""); } - if (fragment.has_value()) { + if (hash.has_value()) { answer.append(",\n"); - answer.append("\t\"fragment\":\""); - helpers::encode_json(fragment.value(), back); + answer.append("\t\"hash\":\""); + helpers::encode_json(hash.value(), back); answer.append("\""); } answer.append("\n}"); @@ -11781,9 +11781,8 @@ namespace ada { [[nodiscard]] std::string url::get_hash() const noexcept { // If this’s URL’s fragment is either null or the empty string, then return // the empty string. Return U+0023 (#), followed by this’s URL’s fragment. - return (!fragment.has_value() || (fragment.value().empty())) - ? "" - : "#" + fragment.value(); + return (!hash.has_value() || (hash.value().empty())) ? "" + : "#" + hash.value(); } } // namespace ada @@ -11839,7 +11838,7 @@ bool url::set_host_or_hostname(const std::string_view input) { // empty string, and either url includes credentials or url’s port is // non-null, return. else if (host_view.empty() && - (is_special() || includes_credentials() || port.has_value())) { + (is_special() || has_credentials() || port.has_value())) { return false; } @@ -11939,7 +11938,7 @@ bool url::set_port(const std::string_view input) { void url::set_hash(const std::string_view input) { if (input.empty()) { - fragment = std::nullopt; + hash = std::nullopt; helpers::strip_trailing_spaces_from_opaque_path(*this); return; } @@ -11947,8 +11946,8 @@ void url::set_hash(const std::string_view input) { std::string new_value; new_value = input[0] == '#' ? input.substr(1) : input; helpers::remove_ascii_tab_or_newline(new_value); - fragment = unicode::percent_encode( - new_value, ada::character_sets::FRAGMENT_PERCENT_ENCODE); + hash = unicode::percent_encode(new_value, + ada::character_sets::FRAGMENT_PERCENT_ENCODE); return; } @@ -12014,7 +12013,7 @@ bool url::set_href(const std::string_view input) { port = out->port; path = out->path; query = out->query; - fragment = out->fragment; + hash = out->hash; type = out->type; non_special_scheme = out->non_special_scheme; has_opaque_path = out->has_opaque_path; @@ -12106,7 +12105,7 @@ result_type parse_url(std::string_view user_input, helpers::trim_c0_whitespace(url_data); // Optimization opportunity. Most websites do not have fragment. - std::optional<std::string_view> fragment = helpers::prune_fragment(url_data); + std::optional<std::string_view> fragment = helpers::prune_hash(url_data); // We add it last so that an implementation like ada::url_aggregator // can append it last to its internal buffer, thus improving performance. @@ -12463,7 +12462,7 @@ result_type parse_url(std::string_view user_input, // Otherwise, if c is not the EOF code point: else if (input_position != input_size) { // Set url’s query to null. - url.clear_base_search(); + url.clear_search(); if constexpr (result_type_is_ada_url) { // Shorten url’s path. helpers::shorten_path(url.path, url.type); @@ -12878,7 +12877,7 @@ result_type parse_url(std::string_view user_input, // Otherwise, if c is not the EOF code point: else if (input_position != input_size) { // Set url’s query to null. - url.clear_base_search(); + url.clear_search(); // If the code point substring from pointer to the end of input does // not start with a Windows drive letter, then shorten url’s path. @@ -12895,11 +12894,7 @@ result_type parse_url(std::string_view user_input, // Otherwise: else { // Set url’s path to an empty list. - if constexpr (result_type_is_ada_url) { - url.path.clear(); - } else { - url.clear_base_pathname(); - } + url.clear_pathname(); url.has_opaque_path = true; } @@ -13091,8 +13086,7 @@ template <bool has_state_override> // If url includes credentials or has a non-null port, and buffer is // "file", then return. - if ((includes_credentials() || - components.port != url_components::omitted) && + if ((has_credentials() || components.port != url_components::omitted) && parsed_type == ada::scheme::type::FILE) { return true; } @@ -13115,7 +13109,7 @@ template <bool has_state_override> // If url’s port is url’s scheme’s default port, then set url’s port to // null. if (components.port == urls_scheme_port) { - clear_base_port(); + clear_port(); } } } else { // slow path @@ -13135,8 +13129,7 @@ template <bool has_state_override> // If url includes credentials or has a non-null port, and buffer is // "file", then return. - if ((includes_credentials() || - components.port != url_components::omitted) && + if ((has_credentials() || components.port != url_components::omitted) && _buffer == "file") { return true; } @@ -13158,7 +13151,7 @@ template <bool has_state_override> // If url’s port is url’s scheme’s default port, then set url’s port to // null. if (components.port == urls_scheme_port) { - clear_base_port(); + clear_port(); } } } @@ -13339,7 +13332,7 @@ bool url_aggregator::set_port(const std::string_view input) { std::string trimmed(input); helpers::remove_ascii_tab_or_newline(trimmed); if (trimmed.empty()) { - clear_base_port(); + clear_port(); return true; } // Input should not start with control characters. @@ -13370,7 +13363,7 @@ bool url_aggregator::set_pathname(const std::string_view input) { if (has_opaque_path) { return false; } - clear_base_pathname(); + clear_pathname(); parse_path(input); if (checkers::begins_with(input, "//") && !has_authority() && !has_dash_dot()) { @@ -13427,7 +13420,7 @@ void url_aggregator::set_search(const std::string_view input) { ADA_ASSERT_TRUE(validate()); ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); if (input.empty()) { - clear_base_search(); + clear_search(); helpers::strip_trailing_spaces_from_opaque_path(*this); return; } @@ -13623,7 +13616,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { // empty string, and either url includes credentials or url’s port is // non-null, return. else if (host_view.empty() && - (is_special() || includes_credentials() || + (is_special() || has_credentials() || components.port != url_components::omitted)) { return false; } @@ -13631,7 +13624,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { // Let host be the result of host parsing host_view with url is not special. if (host_view.empty()) { if (has_hostname()) { - clear_base_hostname(); // easy! + clear_hostname(); // easy! } else if (has_dash_dot()) { add_authority_slashes_if_needed(); delete_dash_dot(); @@ -13657,7 +13650,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { if (new_host.empty()) { // Set url’s host to the empty string. - clear_base_hostname(); + clear_hostname(); } else { // Let host be the result of host parsing buffer with url is not special. if (!parse_host(new_host)) { @@ -13669,7 +13662,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { // If host is "localhost", then set host to the empty string. if (helpers::substring(buffer, components.host_start, components.host_end) == "localhost") { - clear_base_hostname(); + clear_hostname(); } } ADA_ASSERT_TRUE(validate()); @@ -13836,7 +13829,7 @@ std::string ada::url_aggregator::to_string() const { helpers::encode_json(get_protocol(), back); answer.append("\",\n"); - if (includes_credentials()) { + if (has_credentials()) { answer.append("\t\"username\":\""); helpers::encode_json(get_username(), back); answer.append("\",\n"); |