aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-10-01 03:41:33 +0000
committerRoger Dingledine <arma@torproject.org>2008-10-01 03:41:33 +0000
commitc7af43a62497fb3e10c8de9a5bb8cc8113efb99c (patch)
tree847f11b6f733a3aa4af359b8d77b56f359327bc2 /src/common
parent914086628776bf915f7359a6486427c74391134a (diff)
downloadtor-c7af43a62497fb3e10c8de9a5bb8cc8113efb99c.tar
tor-c7af43a62497fb3e10c8de9a5bb8cc8113efb99c.tar.gz
Now NodeFamily and MyFamily config options allow spaces in
identity fingerprints, so it's easier to paste them in. Suggested by Lucky Green. svn:r17021
Diffstat (limited to 'src/common')
-rw-r--r--src/common/container.c22
-rw-r--r--src/common/container.h1
2 files changed, 16 insertions, 7 deletions
diff --git a/src/common/container.c b/src/common/container.c
index 8021bd19c..060615d1c 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -324,12 +324,17 @@ smartlist_insert(smartlist_t *sl, int idx, void *val)
/**
* Split a string <b>str</b> along all occurrences of <b>sep</b>,
- * adding the split strings, in order, to <b>sl</b>. If
- * <b>flags</b>&amp;SPLIT_SKIP_SPACE is true, remove initial and
- * trailing space from each entry. If
- * <b>flags</b>&amp;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. If <b>sep</b> is NULL, split on any sequence of horizontal space.
+ * adding the split strings, in order, to <b>sl</b>.
+ *
+ * If <b>flags</b>&amp;SPLIT_SKIP_SPACE is true, remove initial and
+ * trailing space from each entry.
+ * If <b>flags</b>&amp;SPLIT_IGNORE_BLANK is true, remove any entries
+ * of length 0.
+ * If <b>flags</b>&amp;SPLIT_STRIP_SPACE is true, strip spaces from each
+ * split string.
+ *
+ * If max>0, divide the string into no more than <b>max</b> 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,
@@ -375,7 +380,10 @@ smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
--end;
}
if (end != cp || !(flags&SPLIT_IGNORE_BLANK)) {
- smartlist_add(sl, tor_strndup(cp, end-cp));
+ char *string = tor_strndup(cp, end-cp);
+ if (flags&SPLIT_STRIP_SPACE)
+ tor_strstrip(string, " ");
+ smartlist_add(sl, string);
++n;
}
if (!next)
diff --git a/src/common/container.h b/src/common/container.h
index 0a790ea4a..b4ca35828 100644
--- a/src/common/container.h
+++ b/src/common/container.h
@@ -121,6 +121,7 @@ void smartlist_pqueue_assert_ok(smartlist_t *sl,
#define SPLIT_SKIP_SPACE 0x01
#define SPLIT_IGNORE_BLANK 0x02
+#define SPLIT_STRIP_SPACE 0x04
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
int flags, int max);
char *smartlist_join_strings(smartlist_t *sl, const char *join, int terminate,