refactor: created new class "Tokenizer" and replaced all usages of function "strtok_r" with new class; also created new function "MatchFileExt" for the similar code used in two places

This commit is contained in:
Andrey Prygunkov
2014-05-29 21:38:27 +00:00
parent 48446367f4
commit 1d3d875f3d
12 changed files with 257 additions and 287 deletions

View File

@@ -114,20 +114,15 @@ void NZBScriptController::ExecuteScriptList(const char* szScriptList)
if (szScriptList && *szScriptList)
{
// split szScriptList into tokens
char* szScriptList2 = strdup(szScriptList);
char* saveptr;
char* szScriptName = strtok_r(szScriptList2, ",;", &saveptr);
while (szScriptName)
Tokenizer tok(szScriptList, ",;");
while (const char* szScriptName = tok.Next())
{
szScriptName = Util::Trim(szScriptName);
if (*szScriptName && Util::SameFilename(szScriptName, pScript->GetName()))
if (Util::SameFilename(szScriptName, pScript->GetName()))
{
ExecuteScript(pScript);
break;
}
szScriptName = strtok_r(NULL, ",;", &saveptr);
}
free(szScriptList2);
}
}
}