Skip to content

Commit

Permalink
Merge pull request #3423 from heplesser/fix_string_find
Browse files Browse the repository at this point in the history
Correctly detect that substring was not found
  • Loading branch information
heplesser authored Mar 4, 2025
2 parents b70d597 + 14d4ece commit dc6789a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions sli/slidata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1440,19 +1440,18 @@ Search_sFunction::execute( SLIInterpreter* i ) const

assert( s1 and s2 );

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


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

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

Expand Down

0 comments on commit dc6789a

Please sign in to comment.