From: Sebastian Wilhelmi Date: Thu, 26 Oct 2000 13:00:18 +0000 (+0000) Subject: When the string is ended by a delimiter, return an extra empty string just X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=6f83e76ea8e27d1ab12f43a756d1ec46ac9726ff;p=dana%2Fcg-glib.git When the string is ended by a delimiter, return an extra empty string just 2000-10-26 Sebastian Wilhelmi * gstrfuncs.c (g_strsplit): When the string is ended by a delimiter, return an extra empty string just like for a delimiter at the start of the string. This makes the function behave more consitent and also fixes Bug #15026. --- diff --git a/ChangeLog b/ChangeLog index b723ec84..494a930d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b723ec84..494a930d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2000-10-26 Sebastian Wilhelmi + + * gstrfuncs.c (g_strsplit): When the string is ended by a + delimiter, return an extra empty string just like for a delimiter + at the start of the string. This makes the function behave more + consitent and also fixes Bug #15026. + Tue Oct 24 22:09:14 2000 Tim Janik * glib-object.h: added newly added gobject/ headers. diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index 032343ad..2d1ae71f 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -1487,7 +1487,7 @@ g_strsplit (const gchar *string, { GSList *string_list = NULL, *slist; gchar **str_array, *s; - guint i, n = 1; + guint n = 1; g_return_val_if_fail (string != NULL, NULL); g_return_val_if_fail (delimiter != NULL, NULL); @@ -1516,19 +1516,13 @@ g_strsplit (const gchar *string, } while (--max_tokens && s); } - if (*string) - { - n++; - string_list = g_slist_prepend (string_list, g_strdup (string)); - } - - str_array = g_new (gchar*, n); + string_list = g_slist_prepend (string_list, g_strdup (string)); - i = n - 1; + str_array = g_new (gchar*, n + 1); - str_array[i--] = NULL; + str_array[n--] = NULL; for (slist = string_list; slist; slist = slist->next) - str_array[i--] = slist->data; + str_array[n--] = slist->data; g_slist_free (string_list); diff --git a/gstrfuncs.c b/gstrfuncs.c index 032343ad..2d1ae71f 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -1487,7 +1487,7 @@ g_strsplit (const gchar *string, { GSList *string_list = NULL, *slist; gchar **str_array, *s; - guint i, n = 1; + guint n = 1; g_return_val_if_fail (string != NULL, NULL); g_return_val_if_fail (delimiter != NULL, NULL); @@ -1516,19 +1516,13 @@ g_strsplit (const gchar *string, } while (--max_tokens && s); } - if (*string) - { - n++; - string_list = g_slist_prepend (string_list, g_strdup (string)); - } - - str_array = g_new (gchar*, n); + string_list = g_slist_prepend (string_list, g_strdup (string)); - i = n - 1; + str_array = g_new (gchar*, n + 1); - str_array[i--] = NULL; + str_array[n--] = NULL; for (slist = string_list; slist; slist = slist->next) - str_array[i--] = slist->data; + str_array[n--] = slist->data; g_slist_free (string_list);