summaryrefslogtreecommitdiff
path: root/libs/ardour/io.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-05-14 22:54:45 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-05-14 22:54:45 +0000
commit3ecc9b4f75b6201efdf5550421423861191d79ec (patch)
tree10b8a45997dec791eb7c118763e891e462902917 /libs/ardour/io.cc
parent371ca6da989f1bafa836598ddf66bc72da1795fb (diff)
colinf's fix for my inadvertent commit of his previous patch
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3348 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/io.cc')
-rw-r--r--libs/ardour/io.cc50
1 files changed, 29 insertions, 21 deletions
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 6c48848712..10b1e42328 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -1784,44 +1784,53 @@ IO::ports_became_legal ()
Connection *
IO::find_possible_connection(const string &desired_name, const string &default_name, const string &connection_type_name) {
+static const string digits = "0123456789";
Connection* c = _session.connection_by_name (desired_name);
if (!c) {
- int connection_number, i, n, p, mask;
+ int connection_number, mask;
string possible_name;
bool stereo = false;
+ size_t last_non_digit_pos;
error << string_compose(_("Unknown connection \"%1\" listed for %2 of %3"), desired_name, connection_type_name, _name)
<< endmsg;
// find numeric suffix of desired name
connection_number = 0;
- p = 1;
- i = desired_name.length();
- while (n = desired_name[--i], isdigit(n) && i) {
- connection_number += (n-'0') * p;
- p *= 10;
- }
- if (i && n == '+') {
- // see if it's a stereo connection e.g. "in 3+4"
+
+ last_non_digit_pos = desired_name.find_last_not_of(digits);
+ if (last_non_digit_pos != string::npos) {
+ stringstream s;
+ s << desired_name.substr(last_non_digit_pos);
+ s >> connection_number;
+
+ }
+
+ // see if it's a stereo connection e.g. "in 3+4"
+ if (last_non_digit_pos > 1 && desired_name[last_non_digit_pos] == '+') {
int left_connection_number = 0;
- p = 1;
- info << "assuming port " << desired_name << " is stereo" << endmsg;
- while (n = desired_name[--i], isdigit(n) && i) {
- left_connection_number += (n-'0') * p;
- p *= 10;
- }
- if (left_connection_number > 0 && left_connection_number + 1 == connection_number) {
- connection_number--;
- stereo = true;
+
+ size_t left_last_non_digit_pos;
+ left_last_non_digit_pos = desired_name.find_last_not_of(digits, last_non_digit_pos-1);
+ if (left_last_non_digit_pos != string::npos) {
+ stringstream s;
+ s << desired_name.substr(left_last_non_digit_pos, last_non_digit_pos-1);
+ s >> left_connection_number;
+
+ if (left_connection_number > 0 && left_connection_number + 1 == connection_number) {
+ connection_number--;
+ stereo = true;
+ }
}
}
// make 0-based
- connection_number--;
- // cerr << "desired_name = " << desired_name << ", connection_number = " << connection_number << endl;
+ if (connection_number)
+ connection_number--;
+ cerr << "desired_name = " << desired_name << ", connection_number = " << connection_number << endl;
// find highest set bit
mask = 1;
while ((mask <= connection_number) && (mask <<= 1)) {
@@ -1856,7 +1865,6 @@ IO::find_possible_connection(const string &desired_name, const string &default_n
return c;
-
}
int