Avoided unnecessary recursion with production of collision avoiding names

This commit is contained in:
Thomas Schmitt 2014-01-03 20:53:59 +01:00
parent fea649835c
commit 5e1aaca232
1 changed files with 5 additions and 1 deletions

View File

@ -745,6 +745,7 @@ void ascii_increment(char *name, int pos)
int c, len;
len = strlen(name);
again:;
if (pos < 0 || pos >= len)
pos = len - 1;
c = name[pos];
@ -763,7 +764,10 @@ void ascii_increment(char *name, int pos)
} else if (c == 'z') {
c = '0';
name[pos] = c;
ascii_increment(name, pos - 1);
pos--;
if (pos >= 0 ||
strchr(name, '.') != NULL) /* Do not get caged before last dot */
goto again;
return;
} else {
if (pos == len - 1 || name[pos + 1] == '.')