Fix bug in mangle_all.

This commit is contained in:
Vreixo Formoso Lopes 2007-10-08 16:07:10 +00:00
parent 240377b3d0
commit 42e0289725

View File

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