Bug of fseek and wrong setting of position.
This commit is contained in:
parent
41fd51eeea
commit
78899705d5
|
@ -77,7 +77,7 @@ int rd_fdopen(FILE* fd)
|
||||||
|
|
||||||
for (i = 0; i < NPARTS; i++) outseek[i] = 0;
|
for (i = 0; i < NPARTS; i++) outseek[i] = 0;
|
||||||
offcnt = 0;
|
offcnt = 0;
|
||||||
rd_base = fseek(fd, 0L, SEEK_CUR);
|
rd_base = ftell(fd);
|
||||||
if (rd_base < 0) {
|
if (rd_base < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,8 @@ __wr_flush(struct fil *ptr)
|
||||||
#ifdef OUTSEEK
|
#ifdef OUTSEEK
|
||||||
/* seek to correct position even if we aren't going to write now */
|
/* seek to correct position even if we aren't going to write now */
|
||||||
if (currpos != ptr->currpos) {
|
if (currpos != ptr->currpos) {
|
||||||
currpos = fseek(ptr->fd, ptr->currpos, SEEK_SET);
|
fseek(ptr->fd, ptr->currpos, SEEK_SET);
|
||||||
|
currpos = ptr->currpos;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ptr->pnow > ptr->pbegin) {
|
if (ptr->pnow > ptr->pbegin) {
|
||||||
|
@ -129,7 +130,8 @@ static void BEGINSEEK(int p, long o)
|
||||||
ptr->fd = outfile;
|
ptr->fd = outfile;
|
||||||
ptr->currpos = o;
|
ptr->currpos = o;
|
||||||
#else
|
#else
|
||||||
ptr->currpos = fseek(ptr->fd, o, SEEK_SET);
|
fseek(ptr->fd, o, SEEK_SET);
|
||||||
|
ptr->currpos = o;
|
||||||
#endif
|
#endif
|
||||||
if (p >= PARTRELO) o = 0; /* no attempt to align writes
|
if (p >= PARTRELO) o = 0; /* no attempt to align writes
|
||||||
for the time being */
|
for the time being */
|
||||||
|
@ -259,8 +261,11 @@ wr_outsect(int s)
|
||||||
|
|
||||||
if (s != sectionnr && s >= (SECTCNT-1) && sectionnr >= (SECTCNT-1)) {
|
if (s != sectionnr && s >= (SECTCNT-1) && sectionnr >= (SECTCNT-1)) {
|
||||||
#ifdef OUTSEEK
|
#ifdef OUTSEEK
|
||||||
if (currpos != ptr->currpos)
|
if (currpos != ptr->currpos)
|
||||||
currpos = fseek(ptr->fd, ptr->currpos, SEEK_SET);
|
{
|
||||||
|
fseek(ptr->fd, ptr->currpos, SEEK_SET);
|
||||||
|
currpos -> ptr->currpos;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
wr_bytes(ptr->fd, ptr->pbegin, (long)(ptr->pnow - ptr->pbegin));
|
wr_bytes(ptr->fd, ptr->pbegin, (long)(ptr->pnow - ptr->pbegin));
|
||||||
ptr->currpos += ptr->pnow - ptr->pbegin;
|
ptr->currpos += ptr->pnow - ptr->pbegin;
|
||||||
|
@ -269,7 +274,8 @@ wr_outsect(int s)
|
||||||
#endif
|
#endif
|
||||||
offset[sectionnr] = ptr->currpos;
|
offset[sectionnr] = ptr->currpos;
|
||||||
if (offset[s] != ptr->currpos) {
|
if (offset[s] != ptr->currpos) {
|
||||||
ptr->currpos = fseek(ptr->fd, offset[s], SEEK_SET);
|
fseek(ptr->fd, offset[s], SEEK_SET);
|
||||||
|
ptr->currpos = offset[s];
|
||||||
#ifdef OUTSEEK
|
#ifdef OUTSEEK
|
||||||
currpos = ptr->currpos;
|
currpos = ptr->currpos;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue