[libgsf] GsfInputTextline: fix current file location management.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] GsfInputTextline: fix current file location management.
- Date: Sun, 22 Jan 2017 22:45:25 +0000 (UTC)
commit c7b4b53020d507dccf8ba73c5a2a3a23cc649562
Author: Morten Welinder <terra gnome org>
Date: Sun Jan 22 17:44:28 2017 -0500
GsfInputTextline: fix current file location management.
I.e., make _tell sane and _seek do the right thing.
ChangeLog | 8 ++++++++
NEWS | 3 +++
gsf/gsf-input-textline.c | 19 ++++++++++++++++---
3 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eb21278..e5d3cd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-01-22 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-input-textline.c (gsf_input_textline_read): Make current
+ file position follow the source's.
+ (gsf_input_textline_seek): Ditto.
+ (gsf_input_textline_utf8_gets): Ditto.
+ (gsf_input_textline_dup): Duplicate name too.
+
2016-12-02 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index 6cf1574..f45ddbd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
libgsf 1.14.42
+Morten:
+ * Fix GsfInputTextline's file location management.
+
--------------------------------------------------------------------------
libgsf 1.14.41
diff --git a/gsf/gsf-input-textline.c b/gsf/gsf-input-textline.c
index f9183ba..6c84a75 100644
--- a/gsf/gsf-input-textline.c
+++ b/gsf/gsf-input-textline.c
@@ -94,6 +94,7 @@ gsf_input_textline_dup (GsfInput *src_input, G_GNUC_UNUSED GError **err)
dst->source = g_object_ref (src->source);
gsf_input_set_size (GSF_INPUT (dst), gsf_input_size (src_input));
+ gsf_input_set_name (GSF_INPUT (dst), gsf_input_name (src_input));
return GSF_INPUT (dst);
}
@@ -102,16 +103,26 @@ static guint8 const *
gsf_input_textline_read (GsfInput *input, size_t num_bytes, guint8 *buffer)
{
GsfInputTextline *textline = GSF_INPUT_TEXTLINE (input);
+ const guint8 *res;
+
textline->remainder = NULL;
- return gsf_input_read (textline->source, num_bytes, buffer);
+ res = gsf_input_read (textline->source, num_bytes, buffer);
+ input->cur_offset = textline->source->cur_offset;
+
+ return res;
}
static gboolean
gsf_input_textline_seek (GsfInput *input, gsf_off_t offset, GSeekType whence)
{
GsfInputTextline *textline = GSF_INPUT_TEXTLINE (input);
+ gboolean res;
+
textline->remainder = NULL;
- return gsf_input_seek (textline->source, offset, whence);
+ res = gsf_input_seek (textline->source, offset, whence);
+ input->cur_offset = textline->source->cur_offset;
+
+ return res;
}
static void
@@ -234,12 +245,14 @@ gsf_input_textline_utf8_gets (GsfInputTextline *textline)
break;
} else
textline->remainder = NULL;
-
}
textline->remainder = ptr;
textline->remainder_size = end - ptr;
+ GSF_INPUT(textline)->cur_offset = textline->source->cur_offset -
+ (textline->remainder ? textline->remainder_size : 0);
+
textline->buf[count] = '\0';
return textline->buf;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]