X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstrio.c;h=41146f24fd6613bb159cc7d653093bcbaf5f5835;hb=1461483626f28b52f8f9f3cc350f9cb330579285;hp=039e189a5d8676b6c34506ebeb63a02add52ab9e;hpb=38218bc5a9a2c0ac25840a9ca52e8e6d7d0123ac;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/strio.c b/libchimara/strio.c index 039e189..41146f2 100644 --- a/libchimara/strio.c +++ b/libchimara/strio.c @@ -310,6 +310,10 @@ write_buffer_to_stream(strid_t str, gchar *buf, glui32 len) 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; @@ -402,6 +406,10 @@ write_buffer_to_stream_uni(strid_t str, glui32 *buf, glui32 len) 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; @@ -628,7 +636,7 @@ is_unicode_newline(glsi32 ch, strid_t str, gboolean utf8) glsi32 ch2 = utf8? read_utf8_char_from_file(str) : read_ucs4be_char_from_file(str); if(ch2 != 0x0A) { - if(fseek(str->file_pointer, utf8? -1 : -4, SEEK_CUR) == -1); + if(fseek(str->file_pointer, utf8? -1 : -4, SEEK_CUR) == -1) WARNING_S("Seek failed on stream", g_strerror(errno) ); str->lastop = 0; /* can read or write after a seek */ } @@ -1343,7 +1351,7 @@ glk_stream_set_position(strid_t str, glsi32 pos, glui32 seekmode) { 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;