mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-07 19:35:50 +01:00
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:
parent
ee83ed4c13
commit
113d5e1d74
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ stamp-gc-h
|
||||
stamp-h
|
||||
strfunc-test
|
||||
string-test
|
||||
strtod-test
|
||||
thread-test
|
||||
threadpool-test
|
||||
timeloop-closure
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user