diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/hash.cc | 1 | ||||
-rw-r--r-- | src/libutil/util.cc | 6 | ||||
-rw-r--r-- | src/libutil/util.hh | 4 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 70604a50a342..372826f31d2d 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -257,6 +257,7 @@ Hash hashString(HashType ht, const string & s) start(ht, ctx); update(ht, ctx, (const unsigned char *) s.c_str(), s.length()); finish(ht, ctx, hash.hash); + //printMsg(lvlError, format("hashString %1% --> %2%:\n%3%\n===========END======") % s.size() % printHash(hash) % s); return hash; } diff --git a/src/libutil/util.cc b/src/libutil/util.cc index c28f4e1bb7b8..e541887ee0d4 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1046,6 +1046,12 @@ bool string2Int(const string & s, long long & n) } +bool hasSuffix(const string & s, const string & suffix) +{ + return s.size() >= suffix.size() && string(s, s.size() - suffix.size()) == suffix; +} + + void ignoreException() { try { diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 6c67e450b557..1fd89f3a55bf 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -294,6 +294,10 @@ bool string2Int(const string & s, int & n); bool string2Int(const string & s, long long & n); +/* Return true iff `s' ends in `suffix'. */ +bool hasSuffix(const string & s, const string & suffix); + + /* Exception handling in destructors: print an error message, then ignore the exception. */ void ignoreException(); |