Kaydet (Commit) 53fb1c71 authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane Kaydeden (comit) Andras Timar

postgresql-sdbc: fixup string2intarray

this allows getGeneratedValues to work

Change-Id: Ia87e87afa8cdb01f1d39c84bc7d7143c101d8891
Reviewed-on: https://gerrit.libreoffice.org/16341Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst ca990e8a
...@@ -862,33 +862,46 @@ com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const OUString & str ...@@ -862,33 +862,46 @@ com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const OUString & str
if( str.getLength() > 1 ) if( str.getLength() > 1 )
{ {
sal_Int32 start = 0; sal_Int32 start = 0;
while ( iswspace( str.iterateCodePoints(&start) ) ) sal_uInt32 c;
while ( iswspace( (c=str.iterateCodePoints(&start)) ) )
if ( start == strlen) if ( start == strlen)
return ret; return ret;
if ( str.iterateCodePoints(&start) != L'{' ) if ( c != L'{' )
return ret; return ret;
while ( iswspace( str.iterateCodePoints(&start) ) ) while ( iswspace( c=str.iterateCodePoints(&start) ) )
if ( start == strlen) if ( start == strlen)
return ret; return ret;
if ( str.iterateCodePoints(&start, 0) == L'}' ) if ( c == L'}' )
return ret; return ret;
std::vector< sal_Int32 > vec; std::vector< sal_Int32 > vec;
do do
{ {
OUString digits; OUString digits;
sal_Int32 c; do
while ( isdigit( c = str.iterateCodePoints(&start) ) )
{ {
if(!iswspace(c))
break;
if ( start == strlen) if ( start == strlen)
return ret; return ret;
digits += OUString(c); } while ( (c=str.iterateCodePoints(&start)) );
} do
{
if (!iswdigit(c))
break;
if ( start == strlen)
return ret;
digits += OUString(&c, 1);
} while ( (c = str.iterateCodePoints(&start)) );
vec.push_back( digits.toInt32() ); vec.push_back( digits.toInt32() );
while ( iswspace( str.iterateCodePoints(&start) ) ) do
{
if(!iswspace(c))
break;
if ( start == strlen) if ( start == strlen)
return ret; return ret;
if ( str.iterateCodePoints(&start, 0) == L'}' ) } while ( (c=str.iterateCodePoints(&start)) );
if ( c == L'}' )
break; break;
if ( str.iterateCodePoints(&start) != L',' ) if ( str.iterateCodePoints(&start) != L',' )
return ret; return ret;
...@@ -896,6 +909,7 @@ com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const OUString & str ...@@ -896,6 +909,7 @@ com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const OUString & str
return ret; return ret;
} while( true ); } while( true );
// vec is guaranteed non-empty // vec is guaranteed non-empty
assert(vec.size() > 0);
ret = com::sun::star::uno::Sequence< sal_Int32 > ( &vec[0] , vec.size() ); ret = com::sun::star::uno::Sequence< sal_Int32 > ( &vec[0] , vec.size() );
} }
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment