[or-cvs] Make split(..., NULL) split on horizontal space; fix bug wi...

Nick Mathewson nickm at seul.org
Thu Dec 16 21:10:55 UTC 2004


Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv342/src/or

Modified Files:
	config.c hibernate.c test.c 
Log Message:
Make split(..., NULL) split on horizontal space; fix bug with tabs in config file.

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.285
retrieving revision 1.286
diff -u -d -r1.285 -r1.286
--- config.c	13 Dec 2004 18:32:29 -0000	1.285
+++ config.c	16 Dec 2004 21:10:51 -0000	1.286
@@ -1831,7 +1831,7 @@
   elts = smartlist_create();
   for (opt = options->Logs; opt; opt = opt->next) {
     int levelMin=LOG_DEBUG, levelMax=LOG_ERR;
-    smartlist_split_string(elts, opt->value, " ",
+    smartlist_split_string(elts, opt->value, NULL,
                            SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 3);
     if (smartlist_len(elts) == 0) {
       log_fn(LOG_WARN, "Bad syntax on Log option 'Log %s'", opt->value);
@@ -2045,7 +2045,7 @@
 
   r = tor_malloc_zero(sizeof(exit_redirect_t));
   elements = smartlist_create();
-  smartlist_split_string(elements, line->value, " ",
+  smartlist_split_string(elements, line->value, NULL,
                          SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
   if (smartlist_len(elements) != 2) {
     log_fn(LOG_WARN, "Wrong number of elements in RedirectExit line");
@@ -2098,7 +2098,7 @@
   char digest[DIGEST_LEN];
 
   items = smartlist_create();
-  smartlist_split_string(items, line, " ",
+  smartlist_split_string(items, line, NULL,
                          SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 2);
   if (smartlist_len(items) < 2) {
     log_fn(LOG_WARN, "Too few arguments to DirServer line.");

Index: hibernate.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/hibernate.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- hibernate.c	13 Dec 2004 00:44:38 -0000	1.40
+++ hibernate.c	16 Dec 2004 21:10:51 -0000	1.41
@@ -125,7 +125,8 @@
   }
 
   items = smartlist_create();
-  smartlist_split_string(items, v, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK,0);
+  smartlist_split_string(items, v, NULL,
+                         SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK,0);
   if (smartlist_len(items)<2) {
     log_fn(LOG_WARN, "Too few arguments to AccountingStart");
     goto err;

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- test.c	7 Dec 2004 05:33:55 -0000	1.159
+++ test.c	16 Dec 2004 21:10:51 -0000	1.160
@@ -642,6 +642,22 @@
   SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
   smartlist_clear(sl);
 
+  smartlist_split_string(sl, " ab\tc \td ef  ", NULL,
+                         SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+  test_eq(4, smartlist_len(sl));
+  test_streq("ab", smartlist_get(sl,0));
+  test_streq("c", smartlist_get(sl,1));
+  test_streq("d", smartlist_get(sl,2));
+  test_streq("ef", smartlist_get(sl,3));
+  smartlist_split_string(sl, "ghi\tj", NULL,
+                         SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+  test_eq(6, smartlist_len(sl));
+  test_streq("ghi", smartlist_get(sl,4));
+  test_streq("j", smartlist_get(sl,5));
+
+  SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+  smartlist_clear(sl);
+
   smartlist_split_string(sl, " z <> zhasd <>  <> bnud<>   ", "<>", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
   test_eq(3, smartlist_len(sl));
   test_streq("z", smartlist_get(sl, 0));



More information about the tor-commits mailing list