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

2013-04-24 Thread Paul J. Lucas
Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug-1169908 into 
lp:zorba.

Commit message:
char_length() and utf8::read() now throw an exception upon an invalid UTF-8.

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #1169908 in Zorba: Zorba hangs with invalid utf-8 input
  https://bugs.launchpad.net/zorba/+bug/1169908

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

char_length() and utf8::read() now throw an exception upon an invalid UTF-8.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/strings/strings_impl.cpp'
--- src/runtime/strings/strings_impl.cpp	2013-04-12 04:34:41 +
+++ src/runtime/strings/strings_impl.cpp	2013-04-24 15:47:29 +
@@ -16,6 +16,7 @@
 #include stdafx.h
 
 #include iostream
+#include sstream
 
 #include common/common.h
 
@@ -39,11 +40,13 @@
 
 #include zorbautils/string_util.h
 
+#include util/ascii_util.h
+#include util/oseparator.h
 #include util/regex.h
-#include util/utf8_util.h
-#include util/utf8_string.h
 #include util/string_util.h
 #include util/uri_util.h
+#include util/utf8_string.h
+#include util/utf8_util.h
 #include util/xml_util.h
 
 
@@ -137,49 +140,32 @@
 {
   utf8::encoded_char_type ec;
   memset( ec, 0, sizeof( ec ) );
-  utf8::storage_type *p;
-  p = ec;
 
-  if ( utf8::read( *state-theStream, ec ) == utf8::npos )
-  {
-if ( state-theStream-eof() )
+  try {
+if ( !utf8::read( *state-theStream, ec ) ) {
+  if ( !state-theStream-eof()  !state-theStream-good() )
+throw XQUERY_EXCEPTION(
+  zerr::ZOSE0003_STREAM_READ_FAILURE, ERROR_LOC( loc )
+);
   break;
-if ( state-theStream-good() ) {
-  //
-  // If read() failed but the stream state is good, it means that an
-  // invalid byte was encountered.
-  //
-  char buf[ 6 /* bytes at most */ * 5 /* chars per byte */ ], *b = buf;
-  bool first = true;
-  for ( ; *p; ++p ) {
-if ( first )
-  first = false;
-else
-  *b++ = ',';
-::strcpy( b, 0x );  b += 2;
-::sprintf( b, %0hhX, *p );  b += 2;
-  }
-  throw XQUERY_EXCEPTION(
-zerr::ZXQD0006_INVALID_UTF8_BYTE_SEQUENCE,
-ERROR_PARAMS( buf ),
-ERROR_LOC( loc )
-  );
-} else {
-  throw XQUERY_EXCEPTION(
-zerr::ZOSE0003_STREAM_READ_FAILURE, ERROR_LOC( loc )
-  );
 }
   }
-  state-theResult.clear();
-  state-theResult.push_back( utf8::next_char( p ) );
-
+  catch ( utf8::invalid_byte const ) {
+ostringstream oss;
+oseparator comma( ',' );
+for ( utf8::storage_type const *c = ec; *c; ++c )
+  oss  comma  ascii::printable_char( *c );
+throw XQUERY_EXCEPTION(
+  zerr::ZXQD0006_INVALID_UTF8_BYTE_SEQUENCE,
+  ERROR_PARAMS( oss.str() ),
+  ERROR_LOC( loc )
+);
+  }
   GENV_ITEMFACTORY-createInteger(
-result,
-Integer(state-theResult[0])
+result, xs_integer( utf8::decode( ec ) )
   );
-
-  STACK_PUSH(true, state );
-  state-theIterator = state-theIterator + 1;
+  STACK_PUSH( true, state );
+  ++(state-theIterator);
 }
   }
   else if (!inputStr.empty())
@@ -190,7 +176,7 @@
 {
   GENV_ITEMFACTORY-createInteger(
 result,
-Integer(state-theResult[state-theIterator])
+xs_integer(state-theResult[state-theIterator])
   );
 
   STACK_PUSH(true, state );
@@ -263,7 +249,7 @@
 
   res = (res  0 ? -1 : (res  0 ? 1 : 0));
 
-  GENV_ITEMFACTORY-createInteger(result, Integer(res));
+  GENV_ITEMFACTORY-createInteger(result, xs_integer(res));
 
   STACK_PUSH(true, state);
 }
@@ -758,13 +744,11 @@
   if (consumeNext(item, theChildren [0].getp(), planState))
   {
 item-getStringValue2(strval);
-
-STACK_PUSH(GENV_ITEMFACTORY-createInteger(result, Integer(utf8::length(strval))),
-   state);
+STACK_PUSH(GENV_ITEMFACTORY-createInteger(result, xs_integer(utf8::length(strval))), state);
   }
   else
   {
-STACK_PUSH(GENV_ITEMFACTORY-createInteger(result, Integer::zero()),
+STACK_PUSH(GENV_ITEMFACTORY-createInteger(result, xs_integer::zero()),
state);
   }
   STACK_END(state);
@@ -2350,6 +2334,7 @@
 store::Item_t result,
 PlanState planState) const
 {
+  bool read;
   store::Item_t item;
   size_t lNewPos = 0;
   zstring lToken;
@@ -2381,11 +2366,24 @@
 while ( !state-theIStream-eof() )
 {
   utf8::encoded_char_type ec;
-  memset( ec, '\0' , sizeof(ec) );
-  utf8::storage_type *p;
-  p = ec;
-
-  if ( utf8::read( *state-theIStream, ec ) != utf8::npos )
+  memset( ec, 0 , sizeof(ec) 

Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/bug-1169908 into lp:zorba

2013-04-24 Thread Paul J. Lucas
Review: Approve


-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Paul J. Lucas
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Needs review = Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/bug-1169908-2013-04-24T15-53-40.871Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/bug-1169908 into lp:zorba

2013-04-24 Thread Zorba Build Bot
The attempt to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba failed. 
Below is the output from the failed tests.


CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 
(message):
  Validation queue job bug-1169908-2013-04-24T15-53-40.871Z is finished.  The
  final status was:

  

  433 tests did not succeed - changes not commited.


Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Approved = Needs review

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Paul J. Lucas
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Needs review = Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/bug-1169908 into lp:zorba

2013-04-24 Thread Zorba Build Bot
There are additional revisions which have not been approved in review. Please 
seek review and approval of these new revisions.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Paul J. Lucas
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Needs review = Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/bug-1169908-2013-04-24T21-32-43.53Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/bug-1169908 into lp:zorba

2013-04-24 Thread Zorba Build Bot
The attempt to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba failed. 
Below is the output from the failed tests.


CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 
(message):
  Validation queue job bug-1169908-2013-04-24T21-32-43.53Z is finished.  The
  final status was:

  

  4 tests did not succeed - changes not commited.


Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Approved = Needs review

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Paul J. Lucas
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Needs review = Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/bug-1169908-2013-04-25T02-10-50.587Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
Validation queue job bug-1169908-2013-04-25T02-10-50.587Z is finished. The 
final status was:

All tests succeeded!
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/bug-1169908 into lp:zorba

2013-04-24 Thread Zorba Build Bot
Voting does not meet specified criteria. Required: Approve  1, Disapprove  1, 
Needs Fixing  1, Pending  1, Needs Information  1, Resubmit  1. Got: 1 
Approve.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Approved = Needs review

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/bug-1169908 into lp:zorba

2013-04-24 Thread Matthias Brantner
Review: Approve


-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/bug-1169908-2013-04-25T02-57-44.597Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread Zorba Build Bot
Validation queue job bug-1169908-2013-04-25T02-57-44.597Z is finished. The 
final status was:

All tests succeeded!
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2013-04-24 Thread noreply
The proposal to merge lp:~zorba-coders/zorba/bug-1169908 into lp:zorba has been 
updated.

Status: Approved = Merged

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1169908/+merge/160692
Your team Zorba Coders is subscribed to branch lp:zorba.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp