diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-12-16 21:10:51 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-12-16 21:10:51 +0000 |
commit | bbc10c2ea12b836497d3ef41fc434b50108b70f1 (patch) | |
tree | 53b685569045209495dfba7b1f81f7b69c831402 /src/common | |
parent | a3922d0bdcc06a22131d26a4258590338b8cea12 (diff) | |
download | tor-bbc10c2ea12b836497d3ef41fc434b50108b70f1.tar.gz tor-bbc10c2ea12b836497d3ef41fc434b50108b70f1.zip |
Make split(..., NULL) split on horizontal space; fix bug with tabs in config file.
svn:r3155
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/container.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/common/container.c b/src/common/container.c index 0055fcb476..5ce205f466 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -247,7 +247,7 @@ void smartlist_insert(smartlist_t *sl, int idx, void *val) * trailing space from each entry. If * <b>flags</b>&SPLIT_IGNORE_BLANK is true, remove any entries of * length 0. If max>0, divide the string into no more than <b>max</b> - * pieces. + * pieces. If <b>sep</b> is NULL, split on any sequence of horizontal space. */ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max) @@ -257,7 +257,6 @@ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, tor_assert(sl); tor_assert(str); - tor_assert(sep); cp = str; while (1) { @@ -267,15 +266,23 @@ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, if (max>0 && n == max-1) { end = strchr(cp,'\0'); - } else { + } else if (sep) { end = strstr(cp,sep); if (!end) end = strchr(cp,'\0'); + } else { + for (end = cp; *end && *end != '\t' && *end != ' '; ++end) + ; } + if (!*end) { next = NULL; - } else { + } else if (sep) { next = end+strlen(sep); + } else { + next = end+1; + while (*next == '\t' || *next == ' ') + ++next; } if (flags&SPLIT_SKIP_SPACE) { |