[or-cvs] r17021: {tor} Now NodeFamily and MyFamily config options allow spaces in i (in tor/trunk: . src/common src/or)

arma at seul.org arma at seul.org
Wed Oct 1 03:41:34 UTC 2008


Author: arma
Date: 2008-09-30 23:41:33 -0400 (Tue, 30 Sep 2008)
New Revision: 17021

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/common/container.c
   tor/trunk/src/common/container.h
   tor/trunk/src/or/config.c
   tor/trunk/src/or/router.c
   tor/trunk/src/or/routerlist.c
Log:
Now NodeFamily and MyFamily config options allow spaces in
identity fingerprints, so it's easier to paste them in.
Suggested by Lucky Green.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-10-01 01:55:07 UTC (rev 17020)
+++ tor/trunk/ChangeLog	2008-10-01 03:41:33 UTC (rev 17021)
@@ -1,3 +1,10 @@
+Changes in version 0.2.1.7-alpha - 2008-10-xx
+  o Minor features:
+    - Now NodeFamily and MyFamily config options allow spaces in
+      identity fingerprints, so it's easier to paste them in.
+      Suggested by Lucky Green.
+
+
 Changes in version 0.2.1.6-alpha - 2008-09-30
   o Major features:
     - Implement proposal 121: make it possible to build hidden services

Modified: tor/trunk/src/common/container.c
===================================================================
--- tor/trunk/src/common/container.c	2008-10-01 01:55:07 UTC (rev 17020)
+++ tor/trunk/src/common/container.c	2008-10-01 03:41:33 UTC (rev 17021)
@@ -324,12 +324,17 @@
 
 /**
  * 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 @@
         --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)

Modified: tor/trunk/src/common/container.h
===================================================================
--- tor/trunk/src/common/container.h	2008-10-01 01:55:07 UTC (rev 17020)
+++ tor/trunk/src/common/container.h	2008-10-01 03:41:33 UTC (rev 17021)
@@ -121,6 +121,7 @@
 
 #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,

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-10-01 01:55:07 UTC (rev 17020)
+++ tor/trunk/src/or/config.c	2008-10-01 03:41:33 UTC (rev 17021)
@@ -3740,7 +3740,7 @@
 #endif
 }
 
-/** Verify whether lst is a string containing valid-looking space-separated
+/** Verify whether lst is a string containing valid-looking comma-separated
  * nicknames, or NULL. Return 0 on success. Warn and return -1 on failure.
  */
 static int
@@ -3752,7 +3752,10 @@
   if (!lst)
     return 0;
   sl = smartlist_create();
-  smartlist_split_string(sl, lst, ",", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+
+  smartlist_split_string(sl, lst, ",",
+    SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK|SPLIT_STRIP_SPACE, 0);
+
   SMARTLIST_FOREACH(sl, const char *, s,
     {
       if (!is_legal_nickname_or_hexdigest(s)) {

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2008-10-01 01:55:07 UTC (rev 17020)
+++ tor/trunk/src/or/router.c	2008-10-01 03:41:33 UTC (rev 17021)
@@ -1313,7 +1313,7 @@
     family = smartlist_create();
     ri->declared_family = smartlist_create();
     smartlist_split_string(family, options->MyFamily, ",",
-                           SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+      SPLIT_SKIP_SPACE|SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
     SMARTLIST_FOREACH(family, char *, name,
      {
        routerinfo_t *member;

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2008-10-01 01:55:07 UTC (rev 17020)
+++ tor/trunk/src/or/routerlist.c	2008-10-01 03:41:33 UTC (rev 17021)
@@ -1324,7 +1324,7 @@
 
   nickname_list = smartlist_create();
   smartlist_split_string(nickname_list, list, ",",
-                         SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+    SPLIT_SKIP_SPACE|SPLIT_STRIP_SPACE|SPLIT_IGNORE_BLANK, 0);
   SMARTLIST_FOREACH(nickname_list, const char *, cp,
                     if (router_nickname_matches(router, cp)) {v=1;break;});
   SMARTLIST_FOREACH(nickname_list, char *, cp, tor_free(cp));



More information about the tor-commits mailing list