@@ -292,6 +292,14 @@ trait MatchContextDrive {
292
292
let this = !self . at_end ( ) && word_checker ( self . peek_char ( ) ) ;
293
293
this != that
294
294
}
295
+ fn at_non_boundary < F : FnMut ( u32 ) -> bool > ( & self , mut word_checker : F ) -> bool {
296
+ if self . at_beginning ( ) && self . at_end ( ) {
297
+ return false ;
298
+ }
299
+ let that = !self . at_beginning ( ) && word_checker ( self . back_peek_char ( ) ) ;
300
+ let this = !self . at_end ( ) && word_checker ( self . peek_char ( ) ) ;
301
+ this == that
302
+ }
295
303
fn back_peek_char ( & self ) -> u32 {
296
304
self . state ( ) . string . back_peek ( self . ctx ( ) . string_offset )
297
305
}
@@ -738,14 +746,14 @@ fn at(drive: &StackDrive, atcode: SreAtCode) -> bool {
738
746
SreAtCode :: BEGINNING | SreAtCode :: BEGINNING_STRING => drive. at_beginning ( ) ,
739
747
SreAtCode :: BEGINNING_LINE => drive. at_beginning ( ) || is_linebreak ( drive. back_peek_char ( ) ) ,
740
748
SreAtCode :: BOUNDARY => drive. at_boundary ( is_word) ,
741
- SreAtCode :: NON_BOUNDARY => ! drive. at_boundary ( is_word) ,
749
+ SreAtCode :: NON_BOUNDARY => drive. at_non_boundary ( is_word) ,
742
750
SreAtCode :: END => ( drive. remaining_chars ( ) == 1 && drive. at_linebreak ( ) ) || drive. at_end ( ) ,
743
751
SreAtCode :: END_LINE => drive. at_linebreak ( ) || drive. at_end ( ) ,
744
752
SreAtCode :: END_STRING => drive. at_end ( ) ,
745
753
SreAtCode :: LOC_BOUNDARY => drive. at_boundary ( is_loc_word) ,
746
- SreAtCode :: LOC_NON_BOUNDARY => ! drive. at_boundary ( is_loc_word) ,
754
+ SreAtCode :: LOC_NON_BOUNDARY => drive. at_non_boundary ( is_loc_word) ,
747
755
SreAtCode :: UNI_BOUNDARY => drive. at_boundary ( is_uni_word) ,
748
- SreAtCode :: UNI_NON_BOUNDARY => ! drive. at_boundary ( is_uni_word) ,
756
+ SreAtCode :: UNI_NON_BOUNDARY => drive. at_non_boundary ( is_uni_word) ,
749
757
}
750
758
}
751
759
0 commit comments