[patch] simple strfuncs test fix
- From: Darin Adler <darin bentspoon com>
- To: gtk-devel-list gnome org
- Subject: [patch] simple strfuncs test fix
- Date: Mon, 10 Sep 2001 12:39:57 -0700
This patch contains a few small strfuncs-related fixes. May I commit?
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/glib/ChangeLog,v
retrieving revision 1.826
diff -p -u -r1.826 ChangeLog
--- ChangeLog 2001/09/10 18:03:28 1.826
+++ ChangeLog 2001/09/10 19:26:31
@@ -1,3 +1,12 @@
+2001-09-10 Darin Adler <darin bentspoon com>
+
+ * tests/strfunc-test.c: (main): Change so that it works
+ on platforms where isalpha is a macro only, without the
+ corresponding function that the C standard requires.
+ Also eliminate the multiple lists of ctype functions.
+
+ * tests/.cvsignore: Ignore the new test.
+
Mon Sep 10 17:13:36 2001 Tim Janik <timj gtk org>
* glib/gmessages.h: got rid of g_set_error_handler(),
Index: docs/reference/ChangeLog
===================================================================
RCS file: /cvs/gnome/glib/docs/reference/ChangeLog,v
retrieving revision 1.78
diff -p -u -r1.78 ChangeLog
--- docs/reference/ChangeLog 2001/09/10 18:03:29 1.78
+++ docs/reference/ChangeLog 2001/09/10 19:26:31
@@ -1,3 +1,10 @@
+2001-09-10 Darin Adler <darin bentspoon com>
+
+ * glib/tmpl/string_utils.sgml: Fix a typo and change
+ documentation for g_ascii_isdigit and g_ascii_isxdigit
+ to reflect the fact that the standard isdigit and
+ isxdigit are already locale-independent.
+
Wed Sep 5 05:24:07 2001 Tim Janik <timj gtk org>
* gobject/tmpl/gboxed.sgml: documented some functions.
Index: docs/reference/glib/tmpl/string_utils.sgml
===================================================================
RCS file: /cvs/gnome/glib/docs/reference/glib/tmpl/string_utils.sgml,v
retrieving revision 1.13
diff -p -u -r1.13 string_utils.sgml
--- docs/reference/glib/tmpl/string_utils.sgml 2001/09/10 15:50:02 1.13
+++ docs/reference/glib/tmpl/string_utils.sgml 2001/09/10 19:26:32
@@ -238,7 +238,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII alphanumeric character
@@ -255,7 +255,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII alphabetic character
@@ -272,7 +272,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII control character.
@@ -281,15 +281,13 @@ non-ASCII character in.
Determines whether a character is digit (0-9).
</para>
<para>
-Unlike the standard C library isdigit function, this only
-recognizes standard ASCII digits and ignores the locale, returning
-%FALSE for all non-ASCII characters. Also unlike the standard
-library function, this takes a char, not an int, so don't call it
+Unlike the standard C library isdigit function,
+this takes a char, not an int, so don't call it
on EOF but no need to cast to guchar before passing a possibly
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII digit.
@@ -306,7 +304,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII printing character other than space.
@@ -323,7 +321,7 @@ on EOF but no need to worry about castin
a possibly non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII lower case letter
@@ -340,7 +338,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII printing character.
@@ -357,7 +355,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII punctuation character.
@@ -374,7 +372,7 @@ on EOF but no need to cast to guchar bef
non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII white-space character
@@ -391,7 +389,7 @@ on EOF but no need to worry about castin
a possibly non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII upper case letter
@@ -400,15 +398,13 @@ a possibly non-ASCII character in.
Determines whether a character is a hexadecimal-digit character.
</para>
<para>
-Unlike the standard C library isxdigit function, this only
-recognizes standard ASCII hexadecimal digits and ignores the
-locale, returning %FALSE for all non-ASCII characters. Also unlike
-the standard library function, this takes a char, not an int, so
+Unlike the standard C library isxdigit function,
+this takes a char, not an int, so
don't call it on EOF but no need to cast to guchar before passing a
possibly non-ASCII character in.
</para>
- c: any characted
+ c: any character
@Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
Index: tests/.cvsignore
===================================================================
RCS file: /cvs/gnome/glib/tests/.cvsignore,v
retrieving revision 1.29
diff -p -u -r1.29 .cvsignore
--- tests/.cvsignore 2001/08/27 18:01:08 1.29
+++ tests/.cvsignore 2001/09/10 19:26:32
@@ -37,6 +37,7 @@ strfunc-test
string-test
thread-test
threadpool-test
+timeloop-closure
tree-test
type-test
unicode-encoding
Index: tests/strfunc-test.c
===================================================================
RCS file: /cvs/gnome/glib/tests/strfunc-test.c,v
retrieving revision 1.13
diff -p -u -r1.13 strfunc-test.c
--- tests/strfunc-test.c 2001/09/10 13:30:41 1.13
+++ tests/strfunc-test.c 2001/09/10 19:26:33
@@ -91,73 +91,35 @@ str_check (gchar *str,
return ok;
}
-static gboolean
-test_isalnum (gchar c)
-{
- return g_ascii_isalnum (c);
-}
-
-static gboolean
-test_isalpha (gchar c)
-{
- return g_ascii_isalpha (c);
-}
-
-static gboolean
-test_iscntrl (gchar c)
-{
- return g_ascii_iscntrl (c);
-}
-
-static gboolean
-test_isdigit (gchar c)
-{
- return g_ascii_isdigit (c);
-}
-
-static gboolean
-test_isgraph (gchar c)
-{
- return g_ascii_isgraph (c);
-}
-
-static gboolean
-test_islower (gchar c)
-{
- return g_ascii_islower (c);
-}
-
-static gboolean
-test_isprint (gchar c)
-{
- return g_ascii_isprint (c);
-}
-
-static gboolean
-test_ispunct (gchar c)
-{
- return g_ascii_ispunct (c);
-}
-
-static gboolean
-test_isspace (gchar c)
-{
- return g_ascii_isspace (c);
-}
-
-static gboolean
-test_isupper (gchar c)
-{
- return g_ascii_isupper (c);
-}
-
-static gboolean
-test_isxdigit (gchar c)
-{
- return g_ascii_isxdigit (c);
-}
-
+#define FOR_ALL_CTYPE(macro) \
+ macro(isalnum) \
+ macro(isalpha) \
+ macro(iscntrl) \
+ macro(isdigit) \
+ macro(isgraph) \
+ macro(islower) \
+ macro(isprint) \
+ macro(ispunct) \
+ macro(isspace) \
+ macro(isupper) \
+ macro(isxdigit)
+
+#define DEFINE_CALL_CTYPE(function) \
+ static int \
+ call_##function (int c) \
+ { \
+ return function (c); \
+ }
+
+#define DEFINE_CALL_G_ASCII_CTYPE(function) \
+ static gboolean \
+ call_g_ascii_##function (gchar c) \
+ { \
+ return g_ascii_##function (c); \
+ }
+FOR_ALL_CTYPE (DEFINE_CALL_CTYPE)
+FOR_ALL_CTYPE (DEFINE_CALL_G_ASCII_CTYPE)
static void
test_is_function (const char *name,
@@ -335,19 +297,9 @@ main (int argc,
TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",", 2), "", ",x,,y,,z,,", NULL));
TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",,", 2), "", "x,,y,,z,,", NULL));
- #define TEST_IS(name) test_is_function (#name, test_##name, name, g_unichar_##name)
+ #define TEST_IS(name) test_is_function (#name, call_g_ascii_##name, call_##name, g_unichar_##name);
- TEST_IS (isalnum);
- TEST_IS (isalpha);
- TEST_IS (iscntrl);
- TEST_IS (isdigit);
- TEST_IS (isgraph);
- TEST_IS (islower);
- TEST_IS (isprint);
- TEST_IS (ispunct);
- TEST_IS (isspace);
- TEST_IS (isupper);
- TEST_IS (isxdigit);
+ FOR_ALL_CTYPE(TEST_IS)
#undef TEST_IS
===================================================================
-- Darin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]