summaryrefslogtreecommitdiff
path: root/tools/utils.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-29 23:26:28 -0700
committerJohn Denker <jsd@av8n.com>2012-07-29 23:26:28 -0700
commitf8be4baf5a2318363b42f8883f66ed8a976dfc79 (patch)
tree9f747a0423647b016376fe353ceea197a5848cbf /tools/utils.c
parent2f6fd23b841c1f4e3c18d1cbfd228784aa8c3298 (diff)
scan40 appears to be working, much cleaner than last week's version
Diffstat (limited to 'tools/utils.c')
-rw-r--r--tools/utils.c16
1 files changed, 16 insertions, 0 deletions
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 <iomanip>
//#include <stdlib.h> /* for abs() */
#include <cmath>
+#include <ctype.h> /* 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;
+}