diff options
| author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-16 17:44:35 +0000 |
|---|---|---|
| committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-16 17:44:35 +0000 |
| commit | 72a4c7e6c7a4187bfee58bdbf3c235f2b0ae44c7 (patch) | |
| tree | 16401c11ca7f35fd2a54517e5820500077864d67 /src/misc.c | |
| parent | 0db67c7938e8f7c30ffc227d756bb5d51a53d861 (diff) | |
Added module blocks for autoloading non-core modules.
Modified buildStringList to take an std::string and use spacesepstream instead of strtok.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1745 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/misc.c')
| -rw-r--r-- | src/misc.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/misc.c b/src/misc.c index df0b628f6..77eee30cc 100644 --- a/src/misc.c +++ b/src/misc.c @@ -15,6 +15,7 @@ #include "services.h" #include "language.h" +#include "hashcomp.h" // If this gets added to services.h or someplace else later, remove it from here -- CyberBotX /* Cheaper than isspace() or isblank() */ #define issp(c) ((c) == 32) @@ -1165,23 +1166,18 @@ void ntoa(struct in_addr addr, char *ipaddr, int len) * Build a string list from a given source string. * This is usually used for parsing out values from the config file, but could * be used for other things. - * NOTE: this function uses strtok(), be aware it will break any buffer you think you have in there ;) **/ -char **buildStringList(char *src, int *number) +char **buildStringList(const std::string &src, int *number) { - char *s; int i = 0; char **list = NULL; + spacesepstream tokens(src); + std::string token; - if (src) { - s = strtok(src, " "); - do { - if (s) { - i++; - list = (char **)realloc(list, sizeof(char *) * i); - list[i - 1] = sstrdup(s); - } - } while ((s = strtok(NULL, " "))); + while (tokens.GetToken(token)) { + i++; + list = (char **)realloc(list, sizeof(char *) * i); + list[i - 1] = sstrdup(token.c_str()); } *number = i; /* always zero it, even if we have no setters */ return list; |
