← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-957580 into lp:zorba

 

Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug-957580 into lp:zorba.

Requested reviews:
  Paul J. Lucas (paul-lucas)
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #957580 in Zorba: "stream read failure in StringToCodepointsIteartor"
  https://bugs.launchpad.net/zorba/+bug/957580

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-957580/+merge/98227

Fixed EOF handling.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-957580/+merge/98227
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/spec/strings/strings.xml'
--- src/runtime/spec/strings/strings.xml	2012-01-18 13:57:48 +0000
+++ src/runtime/spec/strings/strings.xml	2012-03-19 16:32:45 +0000
@@ -59,6 +59,7 @@
     <zorba:member type="checked_vector&lt;xs_unsignedInt&gt;" name="theResult"
       brief="the resulting vector"/>
     <zorba:member type="std::istream*" name="theStream" />
+    <zorba:member type="store::Item_t" name="theStreamItem" />
   </zorba:state>
 
 </zorba:iterator>

=== modified file 'src/runtime/strings/pregenerated/strings.h'
--- src/runtime/strings/pregenerated/strings.h	2012-01-18 13:57:48 +0000
+++ src/runtime/strings/pregenerated/strings.h	2012-03-19 16:32:45 +0000
@@ -83,6 +83,7 @@
   xs_unsignedInt theIterator; //the current iterator
   checked_vector<xs_unsignedInt> theResult; //the resulting vector
   std::istream* theStream; //
+  store::Item_t theStreamItem; //
 
   StringToCodepointsIteratorState();
 

=== modified file 'src/runtime/strings/strings_impl.cpp'
--- src/runtime/strings/strings_impl.cpp	2012-02-29 11:10:30 +0000
+++ src/runtime/strings/strings_impl.cpp	2012-03-19 16:32:45 +0000
@@ -126,13 +126,14 @@
     }
     else
     {
+      state->theStreamItem = item;
       state->theStream = &item->getStream();
     }
   }
 
   if ( state->theStream )
   {
-    while ( !state->theStream->eof() )
+    while ( true )
     {
       utf8::encoded_char_type ec;
       memset( ec, 0, sizeof( ec ) );
@@ -141,6 +142,8 @@
 
       if ( utf8::read( *state->theStream, ec ) == utf8::npos )
       {
+        if ( state->theStream->eof() )
+          break;
         if ( state->theStream->good() ) {
           //
           // If read() failed but the stream state is good, it means that an
@@ -212,6 +215,7 @@
   PlanIteratorState::reset(planState);
   theIterator = 0;
   theResult.clear();
+  theStreamItem = 0;
 }
 
 


Follow ups