Skip to content

Commit dc6789a

Browse files
authored
Merge pull request #3423 from heplesser/fix_string_find
Correctly detect that substring was not found
2 parents b70d597 + 14d4ece commit dc6789a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

sli/slidata.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,19 +1440,18 @@ Search_sFunction::execute( SLIInterpreter* i ) const
14401440

14411441
assert( s1 and s2 );
14421442

1443-
size_t p = s1->find( *s2 );
1443+
const size_t p = s1->find( *s2 );
14441444

1445-
1446-
if ( p == ULONG_MAX ) // what we realy want is MAX of size_type
1447-
{ // as soon as C++ limits are supported
1448-
i->OStack.pop(); // (see Stroustrup 3rd ed. p. 586)
1445+
if ( p == s1->npos )
1446+
{
1447+
i->OStack.pop();
14491448
i->OStack.push( i->baselookup( i->false_name ) );
14501449
}
14511450
else
14521451
{
14531452
StringDatum* s3 = new StringDatum();
14541453

1455-
size_t n = p; // number of pre elements
1454+
const size_t n = p; // number of pre elements
14561455
s3->assign( *s1, ( size_t ) 0, n );
14571456
s1->erase( 0, n + s2->size() );
14581457

0 commit comments

Comments
 (0)