mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:02:44 +00:00 
			
		
		
		
	LibRegex: Partially implement string compare for Utf32View
This commit is contained in:
		
							parent
							
								
									da1fda73a7
								
							
						
					
					
						commit
						052004f92d
					
				
					 1 changed files with 16 additions and 2 deletions
				
			
		|  | @ -529,6 +529,11 @@ ALWAYS_INLINE void OpCode_Compare::compare_char(const MatchInput& input, MatchSt | |||
| 
 | ||||
| ALWAYS_INLINE bool OpCode_Compare::compare_string(const MatchInput& input, MatchState& state, const char* str, size_t length, bool& had_zero_length_match) | ||||
| { | ||||
|     if (length == 0) { | ||||
|         had_zero_length_match = true; | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     if (input.view.is_u8_view()) { | ||||
|         auto str_view1 = StringView(str, length); | ||||
|         auto str_view2 = StringView(&input.view.u8view()[state.string_position], length); | ||||
|  | @ -541,8 +546,17 @@ ALWAYS_INLINE bool OpCode_Compare::compare_string(const MatchInput& input, Match | |||
| 
 | ||||
|         if (string_equals) { | ||||
|             state.string_position += length; | ||||
|             if (length == 0) | ||||
|                 had_zero_length_match = true; | ||||
|             return true; | ||||
|         } | ||||
|     } else { | ||||
|         bool equals; | ||||
|         if (input.regex_options & AllFlags::Insensitive) | ||||
|             TODO(); | ||||
|         else | ||||
|             equals = __builtin_memcmp(str, &input.view.u32view().code_points()[state.string_position], length) == 0; | ||||
| 
 | ||||
|         if (equals) { | ||||
|             state.string_position += length; | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ali Mohammad Pur
						Ali Mohammad Pur