diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/apps/apps.h | 3 | ||||
-rw-r--r-- | src/apps/asn1.cpp | 8 | ||||
-rw-r--r-- | src/common.h | 16 | ||||
-rw-r--r-- | src/main.cpp | 32 | ||||
-rw-r--r-- | src/tests/kat_bigint.cpp | 26 | ||||
-rw-r--r-- | src/tests/tests.h | 2 |
6 files changed, 34 insertions, 53 deletions
diff --git a/src/apps/apps.h b/src/apps/apps.h index 956a891fd..e9367c669 100644 --- a/src/apps/apps.h +++ b/src/apps/apps.h @@ -1,9 +1,10 @@ -#include "../common.h" #include <botan/auto_rng.h> #include <botan/hex.h> #include <iostream> +#include "../getopt.h" + using namespace Botan; int apps_main(const std::string& cmd, int argc, char* argv[]); diff --git a/src/apps/asn1.cpp b/src/apps/asn1.cpp index 79d52d485..eeda6f809 100644 --- a/src/apps/asn1.cpp +++ b/src/apps/asn1.cpp @@ -37,10 +37,10 @@ std::string url_encode(const std::vector<byte>& in) for(size_t i = 0; i != in.size(); ++i) { const int c = in[i]; - if(isprint((int)c)) - out << (char)c; + if(isprint(c)) + out << static_cast<char>(c); else - out << "%" << std::hex << (int)c << std::dec; + out << "%" << std::hex << static_cast<char>(c) << std::dec; } return out.str(); } @@ -181,7 +181,7 @@ void decode(BER_Decoder& decoder, size_t level) std::string str; for(size_t i = 0; i != rep.size(); ++i) - str += (char)rep[i]; + str += static_cast<char>(rep[i]); emit(type_name(type_tag), level, length, str); } diff --git a/src/common.h b/src/common.h deleted file mode 100644 index 8d4652a3c..000000000 --- a/src/common.h +++ /dev/null @@ -1,16 +0,0 @@ -// common code for the validation and benchmark code - -#ifndef BOTAN_CHECK_COMMON_H__ -#define BOTAN_CHECK_COMMON_H__ - -#include <string> -#include "getopt.h" - -void strip_comments(std::string& line); -void strip_newlines(std::string& line); -void strip(std::string& line); - -inline std::string strip(const std::string& line) - { std::string s = line; strip(s); return s; } - -#endif diff --git a/src/main.cpp b/src/main.cpp index f2182fe3f..3c8db5ad7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,44 +26,16 @@ using namespace Botan; -#include "common.h" #include "tests/tests.h" #include "apps/apps.h" -// from common.h -void strip_comments(std::string& line) - { - if(line.find('#') != std::string::npos) - line = line.erase(line.find('#'), std::string::npos); - } - -void strip_newlines(std::string& line) - { - while(line.find('\n') != std::string::npos) - line = line.erase(line.find('\n'), 1); - } - -/* Strip comments, whitespace, etc */ -void strip(std::string& line) - { - strip_comments(line); - -#if 0 - while(line.find(' ') != std::string::npos) - line = line.erase(line.find(' '), 1); -#endif - - while(line.find('\t') != std::string::npos) - line = line.erase(line.find('\t'), 1); - } - namespace { int help(int , char* argv[]) { std::cout << "Usage: " << argv[0] << " subcommand\n"; - std::cout << "Common commands: help version test speed\n"; - std::cout << "Other commands: cpuid bcrypt x509 factor tls_client asn1 base64 hash self_sig\n"; + std::cout << "Common commands: test help version\n"; + std::cout << "Other commands: speed cpuid bcrypt x509 factor tls_client asn1 base64 hash self_sig\n"; return 1; } diff --git a/src/tests/kat_bigint.cpp b/src/tests/kat_bigint.cpp index c19b6cc23..fe63f8b85 100644 --- a/src/tests/kat_bigint.cpp +++ b/src/tests/kat_bigint.cpp @@ -22,6 +22,32 @@ using namespace Botan; namespace { +void strip_comments(std::string& line) + { + if(line.find('#') != std::string::npos) + line = line.erase(line.find('#'), std::string::npos); + } + +void strip_newlines(std::string& line) + { + while(line.find('\n') != std::string::npos) + line = line.erase(line.find('\n'), 1); + } + +/* Strip comments, whitespace, etc */ +void strip(std::string& line) + { + strip_comments(line); + +#if 0 + while(line.find(' ') != std::string::npos) + line = line.erase(line.find(' '), 1); +#endif + + while(line.find('\t') != std::string::npos) + line = line.erase(line.find('\t'), 1); + } + std::vector<std::string> parse(const std::string& line) { const char DELIMITER = ':'; diff --git a/src/tests/tests.h b/src/tests/tests.h index 1dec5ff28..494ce72a5 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -8,8 +8,6 @@ #include <string> #include <vector> -#include "../common.h" - size_t run_tests_bb(std::istream& src, const std::string& name_key, const std::string& output_key, |