Add missing const. (g_strsplit): Add g_return_val_if_fail for case of
authorDarin Adler <darin@src.gnome.org>
Thu, 19 Jul 2001 20:07:41 +0000 (20:07 +0000)
committerDarin Adler <darin@src.gnome.org>
Thu, 19 Jul 2001 20:07:41 +0000 (20:07 +0000)
* 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.

27 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/glib/tmpl/string_utils.sgml
glib/gstrfuncs.c
glib/gstrfuncs.h
tests/.cvsignore
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

index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
--- 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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 6339de26a24dcb011d567b90fa645e2601c461a1..d23dbbe52ffab76fd2a8fe6c0371c1fcc2672bad 100644 (file)
@@ -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):
index 38fd6bc0906bb0e5af4c450fa3328441df203575..63f550393180f43b53e5c5422264debf53a30cf2 100644 (file)
@@ -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, 
index 2a87e310003a347c47bcf5f434e7f3a14c7211f8..43a87005b40582ccffde6dcee37f53e61475c85e 100644 (file)
@@ -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 ##### -->
index feb88c6fd842dbd7ddbcf3a4f23f11e4d467d6e4..c79cc51bf2e1c16bb67e0acf152bd36330f5e5a1 100644 (file)
@@ -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;
index 36af2a8bbd8340fc314f0453184211df23eb65b3..43462663942adefa40a820ccdd57318e20b07f49 100644 (file)
@@ -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
 
index 59d6537092496cda9343b0aa4356bad1da4aec04..be029496e868a9a50c669f9e34c4447dac8d0d82 100644 (file)
@@ -17,6 +17,7 @@ cxx-test
 date-test
 dirname-test
 hash-test
+iochannel-test
 list-test
 mainloop-test
 markup-test
index b3b64536e854e914f8291643a18f940e1354b1c6..4f187919b19f7d250ca31db9465b2792847850b4 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index 3fb54b2f98b0cbfb98afb9b1b1c8c41b83886731..7e7d33e642e350d9cf20a93e59480e9f8f14523c 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index f295d6aaff5c92c165630644c781e8199cdebbe1..e199b954d871862681afbaf977a6e61a99c8cbf9 100644 (file)
@@ -25,6 +25,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #ifdef HAVE_CONFIG_H
index d9735484ed19cd3a8bca01c0ac36b5fa025e642d..08ae6eefced23cfaa3d701f913178cd6cc3b4ae6 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index 9f47bcc9baf337464aaa1f97ffcb05a6b323cccb..31b5db4dbacadc96e40ac260ac61851bbd005819 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #ifdef HAVE_CONFIG_H
index b82793f251f36c21fb34d8283bd2e8211e55287e..35f5a16e6f373e1ece65d5d0daa146a26c1fb8cb 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index c71b10d7ffacb60b87697ccd19d81909b958fb0d..8dc32c021a3d940648fc2ca9fa4d1b705b7c5b6e 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <glib.h>
index e50eac92d1259f9366b693d55a58b7aa7ce5cfe2..61416688013dd0ef68da567d4258c67a82262394 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index 87ad8eed530ce6c3ce92146a1def5f89093fdd4c..a508fd39533ca14739c50988e013a20e554d9d15 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <glib.h>
index 2a0c6f580d2f924a179c70b7f88549c327423694..504195d82fdfb9a2ce44695791f43ed2936ccf4c 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index 5753d33883ac890ea8768b22a2a97866499a2eff..7ae3149eeb7d100124fd60456ecb2e4591c8e7a7 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index bc25d41225b43050ec7dcac89d55e51ebd42472b..c914e8aff5c708d6b7f8d56dfe49a885ad7a5986 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "config.h"
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #ifdef GLIB_COMPILATION
index fde562664c647c9e90ce58b33961aa8b5dbe52eb..1d88977152ce976b7641c7bc156cf771f45b8187 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
index 6cea617b33aa947d9f3507069f59356ef0082d64..5fa50026910bb4cb57710db8960b143243258604 100644 (file)
@@ -24,6 +24,7 @@
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef G_DISABLE_ASSERT
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>