Fix max_tokens == 1 case to match documentation. Add tests.

* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
	match documentation.
	* tests/strfunc-test.c: (main): Add tests.

	* tests/.cvsignore: Recently-added test.
This commit is contained in:
Darin Adler 2001-11-13 00:02:30 +00:00
parent ee83ed4c13
commit 113d5e1d74
11 changed files with 79 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1,3 +1,11 @@
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
match documentation.
* tests/strfunc-test.c: (main): Add tests.
* tests/.cvsignore: Recently-added test.
Mon Nov 12 03:01:28 2001 Tim Janik <timj@gtk.org>
* glib/gscanner.c (g_scanner_eof): G_TOKEN_ERROR is also an end

View File

@ -1888,8 +1888,6 @@ g_strsplit (const gchar *string,
if (max_tokens < 1)
max_tokens = G_MAXINT;
else
--max_tokens;
remainder = string;
s = strstr (remainder, delimiter);
@ -1897,7 +1895,7 @@ g_strsplit (const gchar *string,
{
gsize delimiter_len = strlen (delimiter);
do
while (--max_tokens && s)
{
gsize len;
gchar *new_string;
@ -1911,7 +1909,6 @@ g_strsplit (const gchar *string,
remainder = s + delimiter_len;
s = strstr (remainder, delimiter);
}
while (--max_tokens && s);
}
if (*string)
{

View File

@ -35,6 +35,7 @@ stamp-gc-h
stamp-h
strfunc-test
string-test
strtod-test
thread-test
threadpool-test
timeloop-closure

View File

@ -284,6 +284,19 @@ main (int argc,
TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",", 0), "", "", "x", "", "y", "", "z", "", "", NULL));
TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",,", 0), "", "x", "y", "z", "", NULL));
TEST (NULL, strv_check (g_strsplit ("", ",", 1), NULL));
TEST (NULL, strv_check (g_strsplit ("x", ",", 1), "x", NULL));
TEST (NULL, strv_check (g_strsplit ("x,y", ",", 1), "x,y", NULL));
TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 1), "x,y,", NULL));
TEST (NULL, strv_check (g_strsplit (",x,y", ",", 1), ",x,y", NULL));
TEST (NULL, strv_check (g_strsplit (",x,y,", ",", 1), ",x,y,", NULL));
TEST (NULL, strv_check (g_strsplit ("x,y,z", ",", 1), "x,y,z", NULL));
TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 1), "x,y,z,", NULL));
TEST (NULL, strv_check (g_strsplit (",x,y,z", ",", 1), ",x,y,z", NULL));
TEST (NULL, strv_check (g_strsplit (",x,y,z,", ",", 1), ",x,y,z,", NULL));
TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",", 1), ",,x,,y,,z,,", NULL));
TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",,", 1), ",,x,,y,,z,,", NULL));
TEST (NULL, strv_check (g_strsplit ("", ",", 2), NULL));
TEST (NULL, strv_check (g_strsplit ("x", ",", 2), "x", NULL));
TEST (NULL, strv_check (g_strsplit ("x,y", ",", 2), "x", "y", NULL));