diff options
author | Jeffrey <jeffryan@tamu.edu> | 2022-03-30 13:29:32 -0500 |
---|---|---|
committer | Jeffrey <jeffryan@tamu.edu> | 2022-03-30 13:29:32 -0500 |
commit | 1ce9e9cda411a1399bd9d16e21b46c821205b31a (patch) | |
tree | 7e21eb10207b37e8951e6a071d8a80236f711d2e /contrib/epee | |
parent | Merge pull request #8216 (diff) | |
download | monero-1ce9e9cda411a1399bd9d16e21b46c821205b31a.tar.xz |
Remove dead code from parserse_base_utils and fix unit tests
* Remove `match_string()`, `match_number()`, and `match_word()`
* Remove `match_word_with_extrasymb()` and `match_word_til_equal_mark()`
* Adapt unit test for `match_number()` to `match_number2()`
* Adapt unit test for `match_string()` to `match_string2()`
Note: the unit tests were testing for the old version of the functions, and
the interfaces for these functions changed slightly, so I had to also edit
the tests.
As of writing, this PR has no merge conflicts with #8211
Additional changes during review:
* Explicitly set up is_[float/signed]_val to be changed before each call
* Structify the tests and fix uninitialized variables
Diffstat (limited to 'contrib/epee')
-rw-r--r-- | contrib/epee/include/storages/parserse_base_utils.h | 40 | ||||
-rw-r--r-- | contrib/epee/src/parserse_base_utils.cpp | 38 |
2 files changed, 1 insertions, 77 deletions
diff --git a/contrib/epee/include/storages/parserse_base_utils.h b/contrib/epee/include/storages/parserse_base_utils.h index e59cbcf5f..898813ff9 100644 --- a/contrib/epee/include/storages/parserse_base_utils.h +++ b/contrib/epee/include/storages/parserse_base_utils.h @@ -107,48 +107,10 @@ namespace misc_utils */ void match_string2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val); - inline bool match_string(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val) - { - try - { - match_string2(star_end_string, buf_end, val); - return true; - } - catch(...) - { - return false; - } - } void match_number2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val, bool& is_float_val, bool& is_signed_val); - inline bool match_number(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val) - { - try - { - bool is_v_float = false;bool is_signed_val = false; - match_number2(star_end_string, buf_end, val, is_v_float, is_signed_val); - return !is_v_float; - } - catch(...) - { - return false; - } - } + void match_word2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val); - inline bool match_word(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val) - { - try - { - match_word2(star_end_string, buf_end, val); - return true; - } - catch(...) - { - return false; - } - } - bool match_word_with_extrasymb(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val); - bool match_word_til_equal_mark(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string::const_iterator& word_end); } } } diff --git a/contrib/epee/src/parserse_base_utils.cpp b/contrib/epee/src/parserse_base_utils.cpp index e96c2dede..e154a75f8 100644 --- a/contrib/epee/src/parserse_base_utils.cpp +++ b/contrib/epee/src/parserse_base_utils.cpp @@ -239,44 +239,6 @@ namespace misc_utils } ASSERT_MES_AND_THROW("failed to match word number in json entry: " << std::string(star_end_string, buf_end)); } - bool match_word_with_extrasymb(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val) - { - val.clear(); - - for(std::string::const_iterator it = star_end_string;it != buf_end;++it) - { - if(!isalnum(*it) && *it != '-' && *it != '_') - { - val.assign(star_end_string, it); - if(val.size()) - { - star_end_string = --it; - return true; - }else - return false; - } - } - return false; - } - bool match_word_til_equal_mark(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string::const_iterator& word_end) - { - word_end = star_end_string; - - for(std::string::const_iterator it = star_end_string;it != buf_end;++it) - { - if(isspace(*it)) - { - - continue; - }else if( *it == '=' ) - { - star_end_string = it; - word_end = it; - return true; - } - } - return false; - } } } } |