added strncmp
renamed StrCompare to strcmp --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40686
This commit is contained in:
		
							parent
							
								
									3474ba74a5
								
							
						
					
					
						commit
						e42773b07d
					
				@ -74,6 +74,21 @@ static cell_t sm_strcmp(IPluginContext *pCtx, const cell_t *params)
 | 
				
			|||||||
	return (func(str1, str2));
 | 
						return (func(str1, str2));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cell_t sm_strncmp(IPluginContext *pCtx, const cell_t *params)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *str1, *str2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pCtx->LocalToString(params[1], &str1);
 | 
				
			||||||
 | 
						pCtx->LocalToString(params[2], &str2);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if  (params[4])
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return strncmp(str1, str2, (size_t)params[3]);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return strncasecmp(str1, str2, (size_t)params[3]);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cell_t sm_strcopy(IPluginContext *pCtx, const cell_t *params)
 | 
					static cell_t sm_strcopy(IPluginContext *pCtx, const cell_t *params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char *dest, *src;
 | 
						char *dest, *src;
 | 
				
			||||||
@ -316,6 +331,7 @@ REGISTER_NATIVES(basicStrings)
 | 
				
			|||||||
	{"StrBreak",			StrBreak},
 | 
						{"StrBreak",			StrBreak},
 | 
				
			||||||
	{"StrContains",			sm_contain},
 | 
						{"StrContains",			sm_contain},
 | 
				
			||||||
	{"StrCompare",			sm_strcmp},
 | 
						{"StrCompare",			sm_strcmp},
 | 
				
			||||||
 | 
						{"StrCompareN",			sm_strncmp},
 | 
				
			||||||
	{"StrCopy",				sm_strcopy},
 | 
						{"StrCopy",				sm_strcopy},
 | 
				
			||||||
	{"StringToInt",			sm_strconvint},
 | 
						{"StringToInt",			sm_strconvint},
 | 
				
			||||||
	{"IntToString",			sm_numtostr},
 | 
						{"IntToString",			sm_numtostr},
 | 
				
			||||||
 | 
				
			|||||||
@ -55,7 +55,29 @@ native StrContains(const String:str[], const String:substr[], bool:caseSensitive
 | 
				
			|||||||
 *						0 if str1 == str2
 | 
					 *						0 if str1 == str2
 | 
				
			||||||
 *						1 if str1 > str2
 | 
					 *						1 if str1 > str2
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
native StrCompare(const String:str1[], const String:str2[], bool:caseSensitive=true);
 | 
					native strcmp(const String:str1[], const String:str2[], bool:caseSensitive=true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Compares two strings parts lexographically.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param str1			First string (left).
 | 
				
			||||||
 | 
					 * @param str2			Second string (right).
 | 
				
			||||||
 | 
					 * @param num			Number of characters to compare.
 | 
				
			||||||
 | 
					 * @param caseSensitive	If true (default), comparison is case sensitive.
 | 
				
			||||||
 | 
					 *						If false, comparison is case insensitive.
 | 
				
			||||||
 | 
					 * @return				-1 if str1 < str2
 | 
				
			||||||
 | 
					 *						0 if str1 == str2
 | 
				
			||||||
 | 
					 *						1 if str1 > str2
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					native strncmp(const String:str1[], const String:str2[], num, bool:caseSensitive=true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Backwards compatible stock - StrCompare is now strcmp
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					stock StrCompare(const String:str1[], const String:str2[], bool:caseSensitive=true)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return strcmp(str1, str2, caseSensitive);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Returns whether two strings are equal.
 | 
					 * Returns whether two strings are equal.
 | 
				
			||||||
 | 
				
			|||||||
@ -34,6 +34,7 @@
 | 
				
			|||||||
#define stat _stat
 | 
					#define stat _stat
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#define strcasecmp strcmpi
 | 
					#define strcasecmp strcmpi
 | 
				
			||||||
 | 
					#define strncasecmp strnicmp
 | 
				
			||||||
#include <windows.h>
 | 
					#include <windows.h>
 | 
				
			||||||
#include <direct.h>
 | 
					#include <direct.h>
 | 
				
			||||||
#define PLATFORM_LIB_EXT		"dll"
 | 
					#define PLATFORM_LIB_EXT		"dll"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user