From d60dda793ce24818becf6dfb140579899a5e121b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 23 May 2012 18:02:48 -0400 Subject: more bjam stuff, more cleanup --- utils/Jamfile | 4 +--- utils/null_traits.h | 8 ++++---- utils/stringlib.h | 14 +++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'utils') diff --git a/utils/Jamfile b/utils/Jamfile index 53a51277..4444b25f 100644 --- a/utils/Jamfile +++ b/utils/Jamfile @@ -24,11 +24,9 @@ lib utils : ..//z : .. . : : .. . ; -exe ts : ts.cc utils ; exe atools : atools.cc utils ..//boost_program_options ; -exe phmt : phmt.cc utils ; exe reconstruct_weights : reconstruct_weights.cc utils ..//boost_program_options ; alias programs : reconstruct_weights atools ; -all_tests : utils ; +all_tests [ glob *_test.cc phmt.cc ts.cc ] : utils : $(TOP)/utils/test_data ; diff --git a/utils/null_traits.h b/utils/null_traits.h index fac857d9..7b2d32d0 100644 --- a/utils/null_traits.h +++ b/utils/null_traits.h @@ -3,23 +3,23 @@ template struct null_traits { - static V null; //TODO: maybe take out default null and make ppl explicitly define? they may be surprised that they need to when they include a header lib that uses null_traits + static V xnull; //TODO: maybe take out default null and make ppl explicitly define? they may be surprised that they need to when they include a header lib that uses null_traits }; // global bool is_null(V const& v) // definitely override this, and possibly set_null and is_null. that's the point. template -V null_traits::null; +V null_traits::xnull; //TODO: are we getting single init of the static null object? template void set_null(V &v) { - v=null_traits::null; + v=null_traits::xnull; } template void is_null(V const& v) { - return v==null_traits::null; + return v==null_traits::xnull; } diff --git a/utils/stringlib.h b/utils/stringlib.h index f457e1e4..13d14dbf 100644 --- a/utils/stringlib.h +++ b/utils/stringlib.h @@ -97,9 +97,9 @@ inline std::string Trim(const std::string& str, const std::string& dropChars = " inline void Tokenize(const std::string& str, char delimiter, std::vector* res) { std::string s = str; - int last = 0; + unsigned last = 0; res->clear(); - for (int i=0; i < s.size(); ++i) + for (unsigned i=0; i < s.size(); ++i) if (s[i] == delimiter) { s[i]=0; if (last != i) { @@ -120,14 +120,14 @@ inline unsigned NTokens(const std::string& str, char delimiter) inline std::string LowercaseString(const std::string& in) { std::string res(in.size(),' '); - for (int i = 0; i < in.size(); ++i) + for (unsigned i = 0; i < in.size(); ++i) res[i] = tolower(in[i]); return res; } inline std::string UppercaseString(const std::string& in) { std::string res(in.size(),' '); - for (int i = 0; i < in.size(); ++i) + for (unsigned i = 0; i < in.size(); ++i) res[i] = toupper(in[i]); return res; } @@ -146,8 +146,8 @@ inline int CountSubstrings(const std::string& str, const std::string& sub) { inline int SplitOnWhitespace(const std::string& in, std::vector* out) { out->clear(); - int i = 0; - int start = 0; + unsigned i = 0; + unsigned start = 0; std::string cur; while(i < in.size()) { if (in[i] == ' ' || in[i] == '\t') { @@ -249,7 +249,7 @@ inline void SplitCommandAndParam(const std::string& in, std::string* cmd, std::s SplitOnWhitespace(in, &x); if (x.size() == 0) return; *cmd = x[0]; - for (int i = 1; i < x.size(); ++i) { + for (unsigned i = 1; i < x.size(); ++i) { if (i > 1) { *param += " "; } *param += x[i]; } -- cgit v1.2.3