diff options
author | Miguel de Icaza <miguel@gnome.org> | 2006-10-22 01:34:50 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2006-10-22 01:34:50 +0400 |
commit | f6b278ad7e9b89b4609e51fbf4bdfba62699037c (patch) | |
tree | e38aeb356b3cb8a1822faafdea31cca91d61b973 /eglib | |
parent | 03be2afdc4ecc5d681ae2d73845f74c11196fdf2 (diff) |
Another corner case, might be worth rewriting this routine
svn path=/trunk/mono/; revision=66860
Diffstat (limited to 'eglib')
-rw-r--r-- | eglib/src/gstr.c | 2 | ||||
-rw-r--r-- | eglib/test/string-util.c | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/eglib/src/gstr.c b/eglib/src/gstr.c index 5947afd68a2..976c3967d67 100644 --- a/eglib/src/gstr.c +++ b/eglib/src/gstr.c @@ -204,7 +204,7 @@ g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens) break; } - token = strtok_save; + token = *strtok_save ? strtok_save : NULL; } else { token = (gchar *)strtok_r(NULL, delimiter, &strtok_save); } diff --git a/eglib/test/string-util.c b/eglib/test/string-util.c index 4e55c60ad06..4f75015d6eb 100644 --- a/eglib/test/string-util.c +++ b/eglib/test/string-util.c @@ -74,7 +74,22 @@ test_split () if (v [0][0] != 0) return FAILED ("Got a non-empty first element"); g_strfreev (v); - + + v = g_strsplit ("appdomain1, Version=0.0.0.0, Culture=neutral", ",", 4); + if (strcmp (v [0], "appdomain1") != 0) + return FAILED ("Invalid value"); + + if (strcmp (v [1], " Version=0.0.0.0") != 0) + return FAILED ("Invalid value"); + + if (strcmp (v [2], " Culture=neutral") != 0) + return FAILED ("Invalid value"); + + if (v [3] != NULL) + return FAILED ("Expected only 3 elements"); + + g_strfreev (v); + return OK; } |