missing include for rand() in self-tests
[ardour.git] / libs / pbd / strsplit.cc
index 1fb61121501d63419ae6f27f2db6162920727ab9..85f0c5c310552d9d7ef30e0e81403c31dd5dcd48 100644 (file)
@@ -1,11 +1,30 @@
-#include <pbd/strsplit.h>
+/*
+    Copyright (C) 2000-2007 Paul Davis
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "pbd/strsplit.h"
 
 using namespace std;
 using namespace Glib;
 
 void
 split (string str, vector<string>& result, char splitchar)
-{      
+{
        string::size_type pos;
        string remaining;
        string::size_type len = str.length();
@@ -30,8 +49,10 @@ split (string str, vector<string>& result, char splitchar)
 
        remaining = str;
 
-       while ((pos = remaining.find_first_of (':')) != string::npos) {
-               result.push_back (remaining.substr (0, pos));
+       while ((pos = remaining.find_first_of (splitchar)) != string::npos) {
+               if (pos != 0) {
+                       result.push_back (remaining.substr (0, pos));
+               }
                remaining = remaining.substr (pos+1);
        }
 
@@ -43,7 +64,7 @@ split (string str, vector<string>& result, char splitchar)
 
 void
 split (ustring str, vector<ustring>& result, char splitchar)
-{      
+{
        ustring::size_type pos;
        ustring remaining;
        ustring::size_type len = str.length();
@@ -68,7 +89,7 @@ split (ustring str, vector<ustring>& result, char splitchar)
 
        remaining = str;
 
-       while ((pos = remaining.find_first_of (':')) != ustring::npos) {
+       while ((pos = remaining.find_first_of (splitchar)) != ustring::npos) {
                result.push_back (remaining.substr (0, pos));
                remaining = remaining.substr (pos+1);
        }