added amb1610 - StripQuotes()

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402063
This commit is contained in:
David Anderson
2008-04-16 05:27:09 +00:00
parent 07915461e9
commit d014010a99
2 changed files with 36 additions and 0 deletions
+22
View File
@@ -560,6 +560,27 @@ static cell_t SplitString(IPluginContext *pContext, const cell_t *params)
return -1;
}
static cell_t StripQuotes(IPluginContext *pContext, const cell_t *params)
{
char *text;
size_t length;
pContext->LocalToString(params[1], &text);
length = strlen(text);
if (text[0] == '"' && text[length-1] == '"')
{
/* Null-terminate */
text[--length] = '\0';
/* Move the remaining bytes (including null terminator) down by one */
memmove(&text[0], &text[1], length);
return 1;
}
return 0;
}
REGISTER_NATIVES(basicStrings)
{
{"BreakString", BreakString},
@@ -586,6 +607,7 @@ REGISTER_NATIVES(basicStrings)
{"StringToIntEx", StringToIntEx},
{"StringToFloat", sm_strtofloat},
{"StringToFloatEx", StringToFloatEx},
{"StripQuotes", StripQuotes},
{"TrimString", TrimString},
{"VFormat", sm_vformat},
{NULL, NULL},