From f8be4baf5a2318363b42f8883f66ed8a976dfc79 Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 29 Jul 2012 23:26:28 -0700 Subject: scan40 appears to be working, much cleaner than last week's version --- tools/utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools/utils.c') diff --git a/tools/utils.c b/tools/utils.c index aecbfda..c544f20 100644 --- a/tools/utils.c +++ b/tools/utils.c @@ -3,6 +3,7 @@ #include //#include /* for abs() */ #include +#include /* for isalnum() */ // strip off the directory part of a path, leaving just // the basic filename @@ -58,3 +59,18 @@ std::string ltrim(const std::string foo){ if (where == foo.npos) return foo; return foo.substr(where); } + +static const std::string Pure_Enough("+-_.,@%~"); + +std::string purify(const std::string arg){ + using namespace std; + string rslt(arg); + for (string::iterator ptr = rslt.begin(); + ptr != rslt.end(); ptr++){ + char ch = *ptr; + if (isalnum(ch)) continue; + if (Pure_Enough.find(ch) != string::npos) continue; + *ptr = '~'; + } + return rslt; +} -- cgit v1.2.3