diff options
author | Robin Gareus <robin@gareus.org> | 2014-06-30 18:25:11 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-06-30 18:33:05 +0200 |
commit | bae86a2d908122d0bb54afcce82d2cf232268a8a (patch) | |
tree | dd02552b2e063fb877684d15d1ab4092ed45140b /libs/ardour/utils.cc | |
parent | 26ba90815b7e0e5ce4823e6fe86edc795bb3e7b1 (diff) |
Disallow empty names for Groups, automatically enumerate them
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r-- | libs/ardour/utils.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 6fdab19497..54943562cb 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -200,18 +200,19 @@ string ARDOUR::bump_name_number (const std::string& name) { size_t pos = name.length(); + size_t num = 0; bool have_number = false; while (pos > 0 && isdigit(name.at(--pos))) { have_number = true; + num = pos; } string newname; if (have_number) { - ++pos; - int32_t num = strtol (name.c_str() + pos, (char **)NULL, 10); + int32_t seq = strtol (name.c_str() + num, (char **)NULL, 10); char buf[32]; - snprintf (buf, sizeof(buf), "%d", num + 1); - newname = name.substr (0, pos); + snprintf (buf, sizeof(buf), "%d", seq + 1); + newname = name.substr (0, num); newname += buf; } else { newname = name; |