disabled_queries_parser.cc 895 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "third_party/sqlite/fuzz/disabled_queries_parser.h"
  5. namespace sql_fuzzer {
  6. std::set<std::string> ParseDisabledQueries(std::string query_list) {
  7. // Trimming
  8. query_list.erase(query_list.find_last_not_of(" \t\n\r\f\v") + 1);
  9. query_list.erase(0, query_list.find_first_not_of(" \t\n\r\f\v"));
  10. std::set<std::string> ret;
  11. std::string curr_query;
  12. for (size_t i = 0; i < query_list.length(); i++) {
  13. if (query_list[i] == ',') {
  14. ret.insert(curr_query);
  15. curr_query.clear();
  16. continue;
  17. }
  18. curr_query += query_list[i];
  19. }
  20. if (curr_query.length() != 0) {
  21. // Add last query, which doesn't have a trailing comma
  22. ret.insert(curr_query);
  23. }
  24. return ret;
  25. }
  26. } // namespace sql_fuzzer