Seeking to seekmode_End in a memory stream should move relative to
the last written position in the buffer, not the end of the memory
buffer. This brings the behavior of memory streams into line with
what would happen in a file stream.
Fixes #30.
str->file_mode = fmode;
str->type = STREAM_TYPE_MEMORY;
str->mark = 0;
+ str->endmark = 0;
str->unicode = FALSE;
if(buf && buflen)
str->file_mode = fmode;
str->type = STREAM_TYPE_MEMORY;
str->mark = 0;
+ str->endmark = 0;
str->unicode = TRUE;
if(buf && buflen)
gchar *buffer;
glui32 *ubuffer;
glui32 mark;
+ glui32 endmark;
glui32 buflen;
gidispatch_rock_t buffer_rock;
/* Specific to file streams */
str->mark += copycount;
}
+ /* Move the EOF marker if we wrote past it */
+ if(str->mark > str->endmark)
+ str->endmark = str->mark;
+
str->write_count += len;
break;
str->mark += copycount;
}
+ /* Move the EOF marker if we wrote past it */
+ if(str->mark > str->endmark)
+ str->endmark = str->mark;
+
str->write_count += len;
break;
{
case seekmode_Start: str->mark = pos; break;
case seekmode_Current: str->mark += pos; break;
- case seekmode_End: str->mark = str->buflen + pos; break;
+ case seekmode_End: str->mark = str->endmark + pos; break;
default:
g_return_if_reached();
return;