• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 21888402193

11 Feb 2026 12:53AM UTC coverage: 90.068% (-1.6%) from 91.638%
21888402193

push

github

web-flow
Merge pull request #5302 from randombit/jack/header-patrol-4

Cleanup various header inclusions

102229 of 113502 relevant lines covered (90.07%)

11489469.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/lib/utils/read_cfg.cpp
1
/*
2
* Simple config/test file reader
3
* (C) 2013,2014,2015 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/internal/parsing.h>
9

10
#include <botan/exceptn.h>
11
#include <istream>
12

13
namespace Botan {
14

15
namespace {
16

17
std::string clean_ws(std::string_view s) {
1,875✔
18
   const char* ws = " \t\n";
1,875✔
19
   auto start = s.find_first_not_of(ws);
1,875✔
20
   auto end = s.find_last_not_of(ws);
1,875✔
21

22
   if(start == std::string::npos) {
1,875✔
23
      return "";
×
24
   }
25

26
   if(end == std::string::npos) {
1,875✔
27
      return std::string(s.substr(start, end));
×
28
   } else {
29
      return std::string(s.substr(start, start + end + 1));
3,750✔
30
   }
31
}
32

33
}  // namespace
34

35
std::map<std::string, std::string> read_cfg(std::istream& is) {
92✔
36
   std::map<std::string, std::string> kv;
92✔
37
   size_t line = 0;
92✔
38

39
   while(is.good()) {
812✔
40
      std::string s;
720✔
41

42
      std::getline(is, s);
720✔
43

44
      ++line;
720✔
45

46
      if(s.empty() || s[0] == '#') {
720✔
47
         continue;
95✔
48
      }
49

50
      s = clean_ws(s.substr(0, s.find('#')));
625✔
51

52
      if(s.empty()) {
625✔
53
         continue;
×
54
      }
55

56
      auto eq = s.find('=');
625✔
57

58
      if(eq == std::string::npos || eq == 0 || eq == s.size() - 1) {
625✔
59
         throw Decoding_Error("Bad read_cfg input '" + s + "' on line " + std::to_string(line));
×
60
      }
61

62
      const std::string key = clean_ws(s.substr(0, eq));
625✔
63
      const std::string val = clean_ws(s.substr(eq + 1, std::string::npos));
625✔
64

65
      kv[key] = val;
1,250✔
66
   }
720✔
67

68
   return kv;
92✔
69
}
×
70

71
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc