added strncmp

renamed StrCompare to strcmp

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40686
This commit is contained in:
David Anderson
2007-04-11 16:24:50 +00:00
parent 3474ba74a5
commit e42773b07d
3 changed files with 40 additions and 1 deletions
+16
View File
@@ -74,6 +74,21 @@ static cell_t sm_strcmp(IPluginContext *pCtx, const cell_t *params)
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)
{
char *dest, *src;
@@ -316,6 +331,7 @@ REGISTER_NATIVES(basicStrings)
{"StrBreak", StrBreak},
{"StrContains", sm_contain},
{"StrCompare", sm_strcmp},
{"StrCompareN", sm_strncmp},
{"StrCopy", sm_strcopy},
{"StringToInt", sm_strconvint},
{"IntToString", sm_numtostr},