Made filelist weight sorting deterministic with different qsort implementations. By Henrik Lindström.
This commit is contained in:
parent
3a43995fb5
commit
8d9fcf658a
@ -4633,8 +4633,8 @@ void ecma119_filesrc_array(Ecma119Node *dir,
|
|||||||
} else {
|
} else {
|
||||||
if (!child->info.file->taken) {
|
if (!child->info.file->taken) {
|
||||||
filelist[*size] = child->info.file;
|
filelist[*size] = child->info.file;
|
||||||
child->info.file->taken = 1;
|
|
||||||
(*size)++;
|
(*size)++;
|
||||||
|
child->info.file->taken = *size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4658,8 +4658,8 @@ void hidden_filesrc_array(Ecma119Image *t,
|
|||||||
} else {
|
} else {
|
||||||
if (!item->src->taken) {
|
if (!item->src->taken) {
|
||||||
filelist[*size] = item->src;
|
filelist[*size] = item->src;
|
||||||
item->src->taken = 1;
|
|
||||||
(*size)++;
|
(*size)++;
|
||||||
|
item->src->taken = *size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,8 +218,19 @@ static int cmp_by_weight(const void *f1, const void *f2)
|
|||||||
{
|
{
|
||||||
IsoFileSrc *f = *((IsoFileSrc**)f1);
|
IsoFileSrc *f = *((IsoFileSrc**)f1);
|
||||||
IsoFileSrc *g = *((IsoFileSrc**)f2);
|
IsoFileSrc *g = *((IsoFileSrc**)f2);
|
||||||
|
int cmp;
|
||||||
|
|
||||||
/* higher weighted first */
|
/* higher weighted first */
|
||||||
return g->sort_weight - f->sort_weight;
|
cmp = g->sort_weight - f->sort_weight;
|
||||||
|
if (cmp)
|
||||||
|
return cmp;
|
||||||
|
/* Make the result of qsort(3) stable by avoiding return value 0 as good
|
||||||
|
as possible. If not f == g, then their ->taken values are supposed
|
||||||
|
to differ.
|
||||||
|
*/
|
||||||
|
if(f->taken == g->taken)
|
||||||
|
return 0;
|
||||||
|
return f->taken < g->taken ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -32,12 +32,15 @@ struct Iso_File_Src
|
|||||||
*/
|
*/
|
||||||
unsigned int no_write :1;
|
unsigned int no_write :1;
|
||||||
|
|
||||||
/* Is 1 if the object was already put into the filelist array.
|
|
||||||
*/
|
|
||||||
unsigned int taken :1;
|
|
||||||
|
|
||||||
unsigned int checksum_index :31;
|
unsigned int checksum_index :31;
|
||||||
|
|
||||||
|
/* Is > 0 if the object was already put into the filelist array.
|
||||||
|
In this case, the value is the order in which it was inserted,
|
||||||
|
which can be used for stable sorting of the filelist array in
|
||||||
|
case of identical file weights.
|
||||||
|
*/
|
||||||
|
size_t taken;
|
||||||
|
|
||||||
/** File Sections of the file in the image */
|
/** File Sections of the file in the image */
|
||||||
/* Special sections[0].block values while they are relative
|
/* Special sections[0].block values while they are relative
|
||||||
before filesrc_writer_compute_data_blocks().
|
before filesrc_writer_compute_data_blocks().
|
||||||
|
Loading…
Reference in New Issue
Block a user