library/src/utility/BP-StringUtilities.cc
// Checks if two strings are the same.  Strings must be reasonable/printable or this routine will return false.  This
// is a slightly safer version of strcmp.  Strings which are not null terminated can still result in access violations.
Checks if two strings are the same.  Strings must be reasonable/printable or this routine will return false.  This
is a slightly safer version of strcmp.  Strings which are not null terminated can still result in access violations.
Checks if two strings are the same . Strings must be reasonable / printable or this routine will return false . This is a slightly safer version of strcmp . Strings which are not null terminated can still result in access violations .
BP_BOOL BP_StringsMatchAsReasonableStrings(char *str1, char *str2)
{
	if(!str1)
		return BP_FALSE;
	if(!str2)
		return BP_FALSE;
	size_t str1_len = bpstrlen(str1);
	size_t str2_len = bpstrlen(str2);
	if(str1_len != str2_len)
		return BP_FALSE;
	if(!BP_StringIsReasonablePrintableString(str1, str1_len, BP_TRUE, BP_TRUE))
		return BP_FALSE;
	if(!BP_StringIsReasonablePrintableString(str2, str2_len, BP_TRUE, BP_TRUE))
		return BP_FALSE;
	if(memcmp(str1, str2, str1_len) != 0)
		return BP_FALSE;
	return BP_TRUE;
}
BP_BOOL BP_StringsMatchAsReasonableStrings ( char * str1 , char * str2 ) { if ( ! str1 ) return BP_FALSE ; if ( ! str2 ) return BP_FALSE ; size_t str1_len = bpstrlen ( str1 ) ; size_t str2_len = bpstrlen ( str2 ) ; if ( str1_len != str2_len ) return BP_FALSE ; if ( ! BP_StringIsReasonablePrintableString ( str1 , str1_len , BP_TRUE , BP_TRUE ) ) return BP_FALSE ; if ( ! BP_StringIsReasonablePrintableString ( str2 , str2_len , BP_TRUE , BP_TRUE ) ) return BP_FALSE ; if ( memcmp ( str1 , str2 , str1_len ) != 0 ) return BP_FALSE ; return BP_TRUE ; }
Checks if two strings are the same.
Checks if two strings are the same .
// ensure pointers are not // get basic length checks (can potentially fault on unterminated strings) // lengths must match // ensure both strings are reasonable/printable // ensure that both strings match // return indicating that the strings match