From 8adfb38bd602a69bebed77899ac759a0268f97bd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 23 Feb 2007 17:27:06 +0000 Subject: [PATCH] fix for #1041, I/O names with colons in them git-svn-id: svn://localhost/ardour2/trunk@1502 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/about.cc | 2 ++ libs/ardour/io.cc | 7 +++++++ libs/pbd/SConscript | 1 + libs/pbd/pbd/replace_all.h | 8 ++++++++ libs/pbd/strreplace.cc | 19 +++++++++++++++++++ 5 files changed, 37 insertions(+) create mode 100644 libs/pbd/pbd/replace_all.h create mode 100644 libs/pbd/strreplace.cc diff --git a/gtk2_ardour/about.cc b/gtk2_ardour/about.cc index 40bf23d262..dfd08b816f 100644 --- a/gtk2_ardour/about.cc +++ b/gtk2_ardour/about.cc @@ -144,6 +144,8 @@ static const char* authors[] = { N_("Stefan Kersten"), N_("Christopher George"), N_("Robert Jordens"), + N_("Dave Robillard"), + N_("Hans Fugal"), N_("Brian Ahr"), N_("Nimal Ratnayake"), N_("Mike Taht"), diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 692515f710..f899b71d1e 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -2100,6 +2101,12 @@ IO::set_name (string name, void* src) return 0; } + /* replace all colons in the name. i wish we didn't have to do this */ + + if (replace_all (name, ":", "-")) { + warning << _("you cannot use colons to name objects with I/O connections") << endmsg; + } + for (vector::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { string current_name = (*i)->short_name(); current_name.replace (current_name.find (_name), _name.length(), name); diff --git a/libs/pbd/SConscript b/libs/pbd/SConscript index afb24a4311..12664a1fca 100644 --- a/libs/pbd/SConscript +++ b/libs/pbd/SConscript @@ -36,6 +36,7 @@ pthread_utils.cc receiver.cc stacktrace.cc stateful.cc +strreplace.cc strsplit.cc textreceiver.cc transmitter.cc diff --git a/libs/pbd/pbd/replace_all.h b/libs/pbd/pbd/replace_all.h new file mode 100644 index 0000000000..4434637283 --- /dev/null +++ b/libs/pbd/pbd/replace_all.h @@ -0,0 +1,8 @@ +#ifndef __pbd_replace_all_h__ +#define __pbd_replace_all_h__ + +#include + +int replace_all (std::string& str, const std::string& target, const std::string& replacement); + +#endif // __pbd_replace_all_h__ diff --git a/libs/pbd/strreplace.cc b/libs/pbd/strreplace.cc new file mode 100644 index 0000000000..dd90baf324 --- /dev/null +++ b/libs/pbd/strreplace.cc @@ -0,0 +1,19 @@ +#include + +int +replace_all (std::string& str, + std::string const& target, + std::string const& replacement) +{ + std::string::size_type start = str.find (target, 0); + int cnt = 0; + + while (start != std::string::npos) { + str.replace (start, target.size(), replacement); + start = str.find (target, start+replacement.size()); + ++cnt; + } + + return cnt; +} +