Fix bug in mangle_all.

This commit is contained in:
Vreixo Formoso Lopes 2007-10-08 16:07:10 +00:00
parent 08c53aa997
commit 485607ce7b

View File

@ -583,8 +583,10 @@ mangle_all(struct ecma119_tree_node *dir)
struct ecma119_dir_info d = dir->info.dir;
size_t n_change;
int changed;
size_t digits;
assert(dir->type == ECMA119_DIR);
digits = 1;
do {
changed = 0;
for (i=0; i < d.nchildren; i++) {
@ -598,7 +600,7 @@ mangle_all(struct ecma119_tree_node *dir)
/* mangle the names */
changed = 1;
n_change = j / 10 + 1;
n_change = j / 10 + digits;
for (k=0; k < j; k++) {
mangle_name(&(d.children[i+k]->iso_name),
n_change,
@ -612,6 +614,12 @@ mangle_all(struct ecma119_tree_node *dir)
/* skip ahead by the number of mangled names */
i += j - 1;
}
if (changed) {
/* we need to reorder */
qsort(dir->info.dir.children, dir->info.dir.nchildren,
sizeof(void*), cmp_node);
}
digits++;
} while (changed);
for (i=0; i < d.nchildren; i++) {