upstream nonfunctional ZXE patch offset sorting algorithm in stale working directory

This commit is contained in:
GutPuncher 2023-10-25 22:13:19 -04:00
parent 8c3f160283
commit 4c84a83f32
No known key found for this signature in database
GPG key ID: 38CE0A7B6841D1C7

View file

@ -33,6 +33,11 @@ public Bool ZXERep(U8 *filename)
CZXE *zxe; CZXE *zxe;
CHashExport *saved_hash_ptr = NULL; CHashExport *saved_hash_ptr = NULL;
Bool unlock_doc = DocLock(Fs->put_doc); Bool unlock_doc = DocLock(Fs->put_doc);
CQueueD3I32 *patch_offsets_queue = CAlloc(sizeof(CQueueD3I32));
CQueueD3I32 *patch; // x == i
I32 t;
QueueInit(patch_offsets_queue);
fbuf = ExtDefault(filename, "ZXE"); fbuf = ExtDefault(filename, "ZXE");
@ -72,6 +77,9 @@ public Bool ZXERep(U8 *filename)
sptr = ptr; sptr = ptr;
ptr += StrLen(sptr) + 1; ptr += StrLen(sptr) + 1;
progress1 += StrLen(sptr) + 1; progress1 += StrLen(sptr) + 1;
patch = CAlloc(sizeof(CQueueD3I32));
patch->p.x = i;
QueueInsert(patch, patch_offsets_queue);
"$$LTCYAN$$%16Z:$$GREEN$$%s$$FG$$:%X ", etype, "ST_ZXE_FILE_TYPES", sptr, i; "$$LTCYAN$$%16Z:$$GREEN$$%s$$FG$$:%X ", etype, "ST_ZXE_FILE_TYPES", sptr, i;
switch (etype) switch (etype)
{ {
@ -135,6 +143,30 @@ public Bool ZXERep(U8 *filename)
} }
'\n'; '\n';
} }
progress2_max = QueueSize(patch_offsets_queue);
progress3_max = QueueSize(patch_offsets_queue);
progress3 = 0;
br_patchloop:
progress2 = 0;
patch = patch_offsets_queue->next;
while (patch != patch_offsets_queue)
{
"%X ?--> %X", patch->p.x, patch->next->p.x;
if (patch->next != patch_offsets_queue && patch->p.x > patch->next->p.x)
{
t = patch->p.x;
patch->p.x = patch->next->p.x;
patch->next->p.x = t;
if (progress3 < progress2)
progress3++;
goto br_patchloop;
}
patch = patch->next;
progress2++;
}
"\n";
res = TRUE; res = TRUE;
Free(absname); Free(absname);
br_done2: br_done2:
@ -146,6 +178,8 @@ br_done1:
DocUnlock(Fs->put_doc); DocUnlock(Fs->put_doc);
progress1_max = 0; progress1_max = 0;
progress2_max = 0;
progress3_max = 0;
return res; return res;
} }