summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-07-19 20:07:41 +0000
committerDarin Adler <darin@src.gnome.org>2001-07-19 20:07:41 +0000
commit3fa620d4dfeb3440526682b4970bc9147b6665c9 (patch)
treee59b66c6d63436537d4b1c589c6769f4e80d9196
parentf9a6307e063e1d573ff851f850470d82b385685d (diff)
Add missing const. (g_strsplit): Add g_return_val_if_fail for case of
* glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add missing const. (g_strsplit): Add g_return_val_if_fail for case of empty delimiter, which can result in an infinite loop otherwise. * glib/gstrfuncs.h: Add missing const. * tests/.cvsignore: Ignore a generated file. * tests/array-test.c: * tests/dirname-test.c: * tests/hash-test.c: * tests/list-test.c: * tests/node-test.c: * tests/relation-test.c: * tests/shell-test.c: * tests/slist-test.c: * tests/spawn-test.c: * tests/strfunc-test.c: * tests/string-test.c: * tests/testglib.c: * tests/tree-test.c: * tests/type-test.c: Add an #undef G_DISABLE_ASSERT so all tests will assert even if asserts are disabled inside glib itself.
-rw-r--r--ChangeLog26
-rw-r--r--ChangeLog.pre-2-026
-rw-r--r--ChangeLog.pre-2-1026
-rw-r--r--ChangeLog.pre-2-1226
-rw-r--r--ChangeLog.pre-2-226
-rw-r--r--ChangeLog.pre-2-426
-rw-r--r--ChangeLog.pre-2-626
-rw-r--r--ChangeLog.pre-2-826
-rw-r--r--docs/reference/ChangeLog6
-rw-r--r--docs/reference/glib/tmpl/string_utils.sgml10
-rw-r--r--glib/gstrfuncs.c13
-rw-r--r--glib/gstrfuncs.h4
-rw-r--r--tests/.cvsignore1
-rw-r--r--tests/array-test.c1
-rw-r--r--tests/dirname-test.c1
-rw-r--r--tests/hash-test.c1
-rw-r--r--tests/list-test.c1
-rw-r--r--tests/node-test.c1
-rw-r--r--tests/relation-test.c1
-rw-r--r--tests/shell-test.c1
-rw-r--r--tests/slist-test.c1
-rw-r--r--tests/spawn-test.c1
-rw-r--r--tests/strfunc-test.c1
-rw-r--r--tests/string-test.c1
-rw-r--r--tests/testglib.c1
-rw-r--r--tests/tree-test.c1
-rw-r--r--tests/type-test.c1
27 files changed, 246 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 6339de26a..d23dbbe52 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,29 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ * glib/gstrfuncs.c: (g_ascii_strdown), (g_ascii_strup): Add
+ missing const.
+ (g_strsplit): Add g_return_val_if_fail for case of empty
+ delimiter, which can result in an infinite loop otherwise.
+ * glib/gstrfuncs.h: Add missing const.
+ * tests/.cvsignore: Ignore a generated file.
+
+ * tests/array-test.c:
+ * tests/dirname-test.c:
+ * tests/hash-test.c:
+ * tests/list-test.c:
+ * tests/node-test.c:
+ * tests/relation-test.c:
+ * tests/shell-test.c:
+ * tests/slist-test.c:
+ * tests/spawn-test.c:
+ * tests/strfunc-test.c:
+ * tests/string-test.c:
+ * tests/testglib.c:
+ * tests/tree-test.c:
+ * tests/type-test.c:
+ Add an #undef G_DISABLE_ASSERT so all tests will assert even if
+ asserts are disabled inside glib itself.
+
Fri Jul 13 19:20:06 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstring.c (g_string_insert/append/prepend_unichar):
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 38fd6bc09..63f550393 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,9 @@
+2001-07-19 Darin Adler <darin@bentspoon.com>
+
+ reviewed by: <delete if not using a buddy>
+
+ * glib/tmpl/string_utils.sgml:
+
2001-06-03 Matthias Clasen <matthiasc@poet.de>
* glib/tmpl/caches.sgml, glib/tmpl/main.sgml,
diff --git a/docs/reference/glib/tmpl/string_utils.sgml b/docs/reference/glib/tmpl/string_utils.sgml
index 2a87e3100..43a87005b 100644
--- a/docs/reference/glib/tmpl/string_utils.sgml
+++ b/docs/reference/glib/tmpl/string_utils.sgml
@@ -359,17 +359,19 @@ nesting such as g_strup (g_strcanon (str)).
<!-- ##### FUNCTION g_strsplit ##### -->
<para>
Splits a string into a maximum of @max_tokens pieces, using the given
-@delimiter. If @max_tokens is reached, the final string in the returned
-string array contains the remainder of @string.
+@delimiter. If @max_tokens is reached, the last piece contains the
+remainder of @string. If @string is an empty string, then the resulting
+string array has no elements.
</para>
@string: a string to split.
@delimiter: a string which specifies the places at which to split the string.
The delimiter is not included in any of the resulting strings, unless
max_tokens is reached.
-@max_tokens: the maximum number of strings to split @string into. If this is
+@max_tokens: the maximum number of pieces to split @string into. If this is
less than 1, the string is split completely.
-@Returns: a newly-allocated array of strings. Use g_strfreev() to free it.
+@Returns: a newly-allocated NULL-terminated array of strings. Use g_strfreev()
+to free it.
<!-- ##### FUNCTION g_strfreev ##### -->
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index feb88c6fd..c79cc51bf 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -971,10 +971,12 @@ g_strlcat (gchar *dest,
*
* Return value: a newly allocated string, with all the upper case
* characters in @string converted to lower case, with
- * semantics that exactly match g_ascii_tolower.
+ * semantics that exactly match g_ascii_tolower. (Note
+ * that this is unlike the old g_strdown, which modified
+ * the string in place.)
**/
gchar*
-g_ascii_strdown (gchar *string)
+g_ascii_strdown (const gchar *string)
{
gchar *result, *s;
@@ -995,10 +997,12 @@ g_ascii_strdown (gchar *string)
*
* Return value: a newly allocated string, with all the lower case
* characters in @string converted to upper case, with
- * semantics that exactly match g_ascii_toupper.
+ * semantics that exactly match g_ascii_toupper. (Note
+ * that this is unlike the old g_strup, which modified
+ * the string in place.)
**/
gchar*
-g_ascii_strup (gchar *string)
+g_ascii_strup (const gchar *string)
{
gchar *result, *s;
@@ -1573,6 +1577,7 @@ g_strsplit (const gchar *string,
g_return_val_if_fail (string != NULL, NULL);
g_return_val_if_fail (delimiter != NULL, NULL);
+ g_return_val_if_fail (delimiter[0] != '\0', NULL);
if (max_tokens < 1)
max_tokens = G_MAXINT;
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h
index 36af2a8bb..434626639 100644
--- a/glib/gstrfuncs.h
+++ b/glib/gstrfuncs.h
@@ -82,8 +82,8 @@ gint g_ascii_strcasecmp (const gchar *s1,
gint g_ascii_strncasecmp (const gchar *s1,
const gchar *s2,
guint n);
-gchar* g_ascii_strdown (gchar *string);
-gchar* g_ascii_strup (gchar *string);
+gchar* g_ascii_strdown (const gchar *string);
+gchar* g_ascii_strup (const gchar *string);
#ifndef G_DISABLE_DEPRECATED
diff --git a/tests/.cvsignore b/tests/.cvsignore
index 59d653709..be029496e 100644
--- a/tests/.cvsignore
+++ b/tests/.cvsignore
@@ -17,6 +17,7 @@ cxx-test
date-test
dirname-test
hash-test
+iochannel-test
list-test
mainloop-test
markup-test
diff --git a/tests/array-test.c b/tests/array-test.c
index b3b64536e..4f187919b 100644
--- a/tests/array-test.c
+++ b/tests/array-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/dirname-test.c b/tests/dirname-test.c
index 3fb54b2f9..7e7d33e64 100644
--- a/tests/dirname-test.c
+++ b/tests/dirname-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/hash-test.c b/tests/hash-test.c
index f295d6aaf..e199b954d 100644
--- a/tests/hash-test.c
+++ b/tests/hash-test.c
@@ -25,6 +25,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#ifdef HAVE_CONFIG_H
diff --git a/tests/list-test.c b/tests/list-test.c
index d9735484e..08ae6eefc 100644
--- a/tests/list-test.c
+++ b/tests/list-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/node-test.c b/tests/node-test.c
index 9f47bcc9b..31b5db4db 100644
--- a/tests/node-test.c
+++ b/tests/node-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#ifdef HAVE_CONFIG_H
diff --git a/tests/relation-test.c b/tests/relation-test.c
index b82793f25..35f5a16e6 100644
--- a/tests/relation-test.c
+++ b/tests/relation-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/shell-test.c b/tests/shell-test.c
index c71b10d7f..8dc32c021 100644
--- a/tests/shell-test.c
+++ b/tests/shell-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <glib.h>
diff --git a/tests/slist-test.c b/tests/slist-test.c
index e50eac92d..614166880 100644
--- a/tests/slist-test.c
+++ b/tests/slist-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/spawn-test.c b/tests/spawn-test.c
index 87ad8eed5..a508fd395 100644
--- a/tests/spawn-test.c
+++ b/tests/spawn-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <glib.h>
diff --git a/tests/strfunc-test.c b/tests/strfunc-test.c
index 2a0c6f580..504195d82 100644
--- a/tests/strfunc-test.c
+++ b/tests/strfunc-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/string-test.c b/tests/string-test.c
index 5753d3388..7ae3149ee 100644
--- a/tests/string-test.c
+++ b/tests/string-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/testglib.c b/tests/testglib.c
index bc25d4122..c914e8aff 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -26,6 +26,7 @@
#include "config.h"
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#ifdef GLIB_COMPILATION
diff --git a/tests/tree-test.c b/tests/tree-test.c
index fde562664..1d8897715 100644
--- a/tests/tree-test.c
+++ b/tests/tree-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>
diff --git a/tests/type-test.c b/tests/type-test.c
index 6cea617b3..5fa500269 100644
--- a/tests/type-test.c
+++ b/tests/type-test.c
@@ -24,6 +24,7 @@
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <stdio.h>