summaryrefslogtreecommitdiff
path: root/tools/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/utils.c')
-rw-r--r--tools/utils.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/utils.c b/tools/utils.c
index 6dbbff4..691070e 100644
--- a/tools/utils.c
+++ b/tools/utils.c
@@ -1,4 +1,4 @@
-#include <string>
+#include "utils.h"
#include <sstream>
#include <iomanip>
#include <stdlib.h> /* for abs() */
@@ -6,8 +6,8 @@
///// due to lack of interger abs()
///// and ambiguous (and inefficient) promotion
#include <ctype.h> /* for isalnum() */
-using namespace std;
+using namespace std;
// strip off the directory part of a path, leaving just
// the basic filename
@@ -28,7 +28,6 @@ int prefix(const string shorter, const string longer){
// print a time as (-)hh:mm:ss
//
string time_out(const int _ttt){
-using namespace std;
int ttt(abs(_ttt));
int sec(ttt % 60);
int min((ttt / 60) % 60);
@@ -76,7 +75,6 @@ string trim(const string foo, const string bar){
static const string Pure_Enough("+-_.,@%~");
string purify(const string arg){
- using namespace std;
string rslt(arg);
for (string::iterator ptr = rslt.begin();
ptr != rslt.end(); ptr++){
@@ -115,3 +113,14 @@ string noCR(const string bar){
}
return foo;
}
+
+// sorta like Perl's join(...)
+string join(const string sep, const list<string> stuff){
+ string rslt;
+ for (list<string>::const_iterator ptr = stuff.begin();
+ ptr != stuff.end(); ptr++){
+ if (rslt.length()) rslt += sep;
+ rslt += *ptr;
+ }
+ return rslt;
+}