Fix bug #3534. Now set EOF and file position to requested offset in a seek when the offset is past the current EOF. With this fix pinkerton's workaround in reg.c is no longer required si it has been removed. Reviewed pinkerton, approved chofmann.

This commit is contained in:
sdagley%netscape.com 1999-05-20 01:25:54 +00:00
Родитель c2db68fd3f
Коммит 0b20aacbf6
2 изменённых файлов: 4 добавлений и 29 удалений

Просмотреть файл

@ -721,22 +721,8 @@ static REGERR nr_ReadHdr(REGFILE *reg)
static REGERR nr_WriteHdr(REGFILE *reg)
{
#ifdef XP_MAC
#define HACK_WRITE_ENTIRE_RESERVE 1
#endif
REGERR err;
#if HACK_WRITE_ENTIRE_RESERVE
/*
* pinkerton
* Until NSPR can be fixed to seek out past the EOF on MacOS, we need to make
* sure that we write all 128 bytes to push out the EOF to the right location
*/
char hdrBuf[HDRRESERVE];
XP_MEMSET(hdrBuf, NULL, HDRRESERVE);
#else
char hdrBuf[sizeof(REGHDR)];
#endif
XP_ASSERT(reg);
@ -787,21 +773,6 @@ static REGERR nr_CreateRoot(REGFILE *reg)
root.valuebuf = 0;
root.parent = 0;
#ifdef XP_MAC
#define HACK_UNTIL_NSPR_DOES_SEEK_CORRECTLY 1
#endif
#if HACK_UNTIL_NSPR_DOES_SEEK_CORRECTLY
/*
* pinkerton
* The AppendName() and AppendDesc() code that follows assumes that it can just
* seek out past the end of the file and write a name and descriptor. However,
* mac doesn't allow that. NSPR needs to be "fixed" somehow, but in the meantime,
* we can just write out the header first, extending the EOF to 128 bytes where
* the name and desc can follow w/out silently failing.
*/
nr_WriteHdr(reg);
#endif
err = nr_AppendName(reg, ROOTKEY_STR, &root);
if (err != REGERR_OK)
return err;

Просмотреть файл

@ -437,10 +437,14 @@ PRInt32 _MD_LSeek(PRFileDesc *fd, PRInt32 offset, PRSeekWhence how)
}
/* set the new mark and extend the file if seeking beyond current EOF */
/* making sure to set the mark after any required extend */
if (err == noErr) {
err = SetFPos(refNum, fsFromStart, endPos);
if (err == eofErr) {
err = SetEOF(refNum, endPos);
if (err == noErr) {
err = SetFPos(refNum, fsFromStart, endPos);
}
}
}