mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
Handle empty matches in regex.replace. Fixes #421.
This commit is contained in:
@@ -108,7 +108,13 @@ LIST * regex_replace( FRAME * frame, int flags )
|
||||
{
|
||||
string_append_range( buf, pos, re->startp[ 0 ] );
|
||||
string_append( buf, object_str( replacement ) );
|
||||
pos = re->endp[ 0 ];
|
||||
/* Handle empty matches */
|
||||
if ( *pos == '\0' )
|
||||
break;
|
||||
else if ( pos == re->endp[ 0 ] )
|
||||
++pos;
|
||||
else
|
||||
pos = re->endp[ 0 ];
|
||||
}
|
||||
string_append( buf, pos );
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ rule __test__ ( )
|
||||
assert.result " string string" : replace " string string" " " " " ;
|
||||
assert.result "string string" : replace "string string" " " " " ;
|
||||
assert.result "-" : replace "&" "&" "-" ;
|
||||
assert.result "x" : replace "" "" "x" ;
|
||||
|
||||
assert.result "-" "a-b" : replace-list "&" "a&b" : "&" : "-" ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user