Disallow empty names for Groups, automatically enumerate them

This commit is contained in:
Robin Gareus 2014-06-30 18:25:11 +02:00 committed by Paul Davis
parent 0cef3d60cf
commit d0a4e1a35a
3 changed files with 20 additions and 9 deletions

View file

@ -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;