From 3c9817f94592907c8c19a8b8f97af87dad3dceaf Mon Sep 17 00:00:00 2001 From: John Denker Date: Thu, 22 Nov 2012 16:01:04 -0800 Subject: move case-insensitive string stuff to utils.h --- tools/skrewt.c | 54 ------------------------------------------------------ 1 file changed, 54 deletions(-) (limited to 'tools/skrewt.c') diff --git a/tools/skrewt.c b/tools/skrewt.c index 70265da..540b1cf 100644 --- a/tools/skrewt.c +++ b/tools/skrewt.c @@ -41,60 +41,6 @@ void usage(const int sts){ #include "utils.h" #include "sepofra.h" -///////////////////////////////////////////////////////// -// Case insensitive comparison of strings - -class lessthan_foldcase{ -public: - bool operator() (const std::string& a, const std::string& b) const { - size_t a_len = a.length(); - size_t b_len = b.length(); - - size_t lim = a_len < b_len ? a_len : b_len; - - for (size_t i=0; i chb) return false; - } - // here if one is an extension of the other - if ( a_len < b_len ) return true; - return false; - } -}; - - -// Returns negative if a is less than b in alphabetical order -// returns 0 if they are the same, or positive if a is greater. -// Like perl cmp operator, but ignores case. -int cmp_casefold(const std::string& a, const std::string& b) { - string::const_iterator aa, bb; - aa = a.begin(); - bb = b.begin(); - while (aa != a.end() && bb != b.end()){ - char ca = tolower(*aa++); - char cb = tolower(*bb++); - if (ca != cb) return ca < cb ? -2 : 2; - } - if (aa != a.end()) return 1; // a is longer - if (bb != b.end()) return -1; // b is longer - return 0; -} - -string noCR(const string bar){ - string foo(bar); - int len = foo.length(); - if (len){ - if (foo[len-1] == '\r') { - foo.erase(len-1); - } - } - return foo; -} - void maybe_exeunt(const int sts, const int really){ if (!really) return; if (sts == ex_good) exit(sts); -- cgit v1.2.3