From bae86a2d908122d0bb54afcce82d2cf232268a8a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 30 Jun 2014 18:25:11 +0200 Subject: Disallow empty names for Groups, automatically enumerate them --- libs/ardour/utils.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libs') 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; -- cgit v1.2.3