Merge lp:~zorba-coders/zorba/bug-fixing into lp:zorba

Proposed by Matthias Brantner
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug-fixing
Merge into: lp:zorba
Diff against target: 84 lines (+31/-11)
3 files modified
src/api/serialization/serializer.cpp (+18/-11)
src/store/api/item.h (+8/-0)
src/store/naive/item.cpp (+5/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-fixing
Reviewer Review Type Date Requested Status
William Candillon Pending
Nicolae Brinza Pending
Review via email: mp+83991@code.launchpad.net

This proposal has been superseded by a proposal from 2011-11-30.

Commit message

fix for bug #898064 (error when text-serializing a non-seekable streamable string)

Description of the change

fix for bug #898064

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/api/serialization/serializer.cpp'
2--- src/api/serialization/serializer.cpp 2011-11-11 07:44:01 +0000
3+++ src/api/serialization/serializer.cpp 2011-11-30 18:36:25 +0000
4@@ -1682,14 +1682,18 @@
5 std::streambuf * pbuf;
6 std::streamsize read_bytes;
7 std::istream& is = item->getStream();
8-
9- // prepare the stream
10+ std::streampos pos;
11 std::ios::iostate const old_exceptions = is.exceptions();
12- is.exceptions( std::ios::badbit | std::ios::failbit );
13- std::streampos const pos = is.tellg();
14- if (pos)
15- is.seekg(0, std::ios::beg);
16- is.exceptions(is.exceptions() & ~std::ios::failbit);
17+
18+ if (item->isSeekable())
19+ {
20+ // prepare the stream
21+ is.exceptions( std::ios::badbit | std::ios::failbit );
22+ pos = is.tellg();
23+ if (pos)
24+ is.seekg(0, std::ios::beg);
25+ is.exceptions(is.exceptions() & ~std::ios::failbit);
26+ }
27
28 // read bytes and do string expansion
29 do
30@@ -1703,12 +1707,15 @@
31
32 // restore stream's state
33 is.clear(); // clear eofbit
34- if (pos)
35+ if (item->isSeekable())
36 {
37- is.exceptions(is.exceptions() | std::ios::failbit);
38- is.seekg(pos, std::ios::beg);
39+ if (pos != 0 && pos != -1)
40+ {
41+ is.exceptions(is.exceptions() | std::ios::failbit);
42+ is.seekg(pos, std::ios::beg);
43+ }
44+ is.exceptions(old_exceptions);
45 }
46- is.exceptions(old_exceptions);
47 }
48
49
50
51=== modified file 'src/store/api/item.h'
52--- src/store/api/item.h 2011-10-15 10:41:19 +0000
53+++ src/store/api/item.h 2011-11-30 18:36:25 +0000
54@@ -807,6 +807,14 @@
55 virtual bool isStreamable() const;
56
57 /**
58+ * Checks whether the item's content is streamable
59+ * and the underlying stream is seekable
60+ *
61+ * @return true only if it is.
62+ */
63+ virtual bool isSeekable() const;
64+
65+ /**
66 * Gets an istream for the item's content.
67 *
68 * @return the stream.
69
70=== modified file 'src/store/naive/item.cpp'
71--- src/store/naive/item.cpp 2011-10-15 10:41:19 +0000
72+++ src/store/naive/item.cpp 2011-11-30 18:36:25 +0000
73@@ -1291,6 +1291,11 @@
74 return false;
75 }
76
77+bool Item::isSeekable() const
78+{
79+ return false;
80+}
81+
82 std::istream& Item::getStream()
83 {
84 throw ZORBA_EXCEPTION(

Subscribers

People subscribed via source and target branches