From cece3cd62c794515dc26ced655eb0b164a1ed79b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 29 Jul 2016 11:21:41 +0200 Subject: Make /EHsc and /MD default for VC compiler --- build2/utility.cxx | 123 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 113 insertions(+), 10 deletions(-) (limited to 'build2/utility.cxx') diff --git a/build2/utility.cxx b/build2/utility.cxx index 87a2749..46741a3 100644 --- a/build2/utility.cxx +++ b/build2/utility.cxx @@ -4,6 +4,7 @@ #include +#include // strlen(), str[n]cmp() #include // strtol() #include // cerr @@ -161,35 +162,137 @@ namespace build2 } bool - find_option (const char* option, const lookup& l, bool ic) + find_option (const char* o, const lookup& l, bool ic) { - return l && find_option (option, cast (l), ic); + return l && find_option (o, cast (l), ic); } bool - find_option (const char* option, const strings& strs, bool) + find_option (const char* o, const strings& strs, bool) { //@@ CASE ignore case for (const string& s: strs) - { - if (s == option) + if (s == o) return true; - } return false; } bool - find_option (const char* option, const cstrings& cstrs, bool) + find_option (const char* o, const cstrings& cstrs, bool) { //@@ CASE ignore case for (const char* s: cstrs) - { - if (s != nullptr && strcmp (s, option) == 0) + if (s != nullptr && strcmp (s, o) == 0) return true; - } + + return false; + } + + bool + find_options (initializer_list os, const lookup& l, bool ic) + { + return l && find_options (os, cast (l), ic); + } + + bool + find_options (initializer_list os, const strings& strs, bool) + { + //@@ CASE ignore case + + for (const string& s: strs) + for (const char* o: os) + if (s == o) + return true; + + return false; + } + + bool + find_options (initializer_list os, const cstrings& cstrs, bool) + { + //@@ CASE ignore case + + for (const char* s: cstrs) + if (s != nullptr) + for (const char* o: os) + if (strcmp (s, o) == 0) + return true; + + return false; + } + + bool + find_option_prefix (const char* p, const lookup& l, bool ic) + { + return l && find_option_prefix (p, cast (l), ic); + } + + bool + find_option_prefix (const char* p, const strings& strs, bool) + { + //@@ CASE ignore case + + size_t n (strlen (p)); + + for (const string& s: strs) + if (s.compare (0, n, p) == 0) + return true; + + return false; + } + + bool + find_option_prefix (const char* p, const cstrings& cstrs, bool) + { + //@@ CASE ignore case + + size_t n (strlen (p)); + + for (const char* s: cstrs) + if (s != nullptr && strncmp (s, p, n) == 0) + return true; + + return false; + } + + bool + find_option_prefixes (initializer_list ps, + const lookup& l, + bool ic) + { + return l && find_option_prefixes (ps, cast (l), ic); + } + + bool + find_option_prefixes (initializer_list ps, + const strings& strs, + bool) + { + //@@ CASE ignore case + + for (const string& s: strs) + for (const char* p: ps) + if (s.compare (0, strlen (p), p) == 0) + return true; + + return false; + } + + bool + find_option_prefixes (initializer_list ps, + const cstrings& cstrs, + bool) + { + //@@ CASE ignore case + + for (const char* s: cstrs) + if (s != nullptr) + for (const char* p: ps) + if (strncmp (s, p, strlen (p)) == 0) + return true; return false; } -- cgit v1.1