From 55688d6cc6d7085bc35a58a2cacb22cf19807564 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sat, 30 Jun 2001 16:54:33 +0000 Subject: [PATCH] Patch from Darin Adler (#54166) Sat Jun 30 12:49:26 2001 Owen Taylor Patch from Darin Adler (#54166) * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive g_ascii_to[lower/upper], g_ascii_str[down/up], g_ascii_is[upper/lower] and deprecate the locale-affected versions which break for UTF-8, etc. Make g_ascii_strup/strdown duplicating, not in-place for consistency with UTF-8 functions. * glib/gstring.[ch]: Add ascii-only, locale-insensitive g_string_ascii_[down/up], and deprecate the locale-affected versions which break for UTF-8, etc. * glib/gutils.c glib/gwin32.c test/testglib.c: Use the g_ascii_* functions where appropriate. --- ChangeLog | 18 +++ ChangeLog.pre-2-0 | 18 +++ ChangeLog.pre-2-10 | 18 +++ ChangeLog.pre-2-12 | 18 +++ ChangeLog.pre-2-2 | 18 +++ ChangeLog.pre-2-4 | 18 +++ ChangeLog.pre-2-6 | 18 +++ ChangeLog.pre-2-8 | 18 +++ docs/reference/glib/tmpl/strings.sgml | 2 +- glib/gstrfuncs.c | 261 ++++++++++++++++++++++++++++++++++ glib/gstrfuncs.h | 40 +++++- glib/gstring.c | 66 ++++++++- glib/gstring.h | 21 ++- glib/gutils.c | 16 +-- glib/gwin32.c | 4 +- tests/testglib.c | 30 ++-- 16 files changed, 546 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4fdcac..8695c22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d4fdcac..8695c22 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +Sat Jun 30 12:49:26 2001 Owen Taylor + + Patch from Darin Adler (#54166) + + * glib/gstrfuncs.[ch]: Add ascii-only, locale-insensitive + g_ascii_to[lower/upper], g_ascii_str[down/up], + g_ascii_is[upper/lower] and deprecate the locale-affected + versions which break for UTF-8, etc. Make + g_ascii_strup/strdown duplicating, + not in-place for consistency with UTF-8 functions. + + * glib/gstring.[ch]: Add ascii-only, locale-insensitive + g_string_ascii_[down/up], and deprecate the locale-affected + versions which break for UTF-8, etc. + + * glib/gutils.c glib/gwin32.c test/testglib.c: Use + the g_ascii_* functions where appropriate. + Fri Jun 29 13:36:39 2001 Owen Taylor * glib/gstring.[ch] (g_string_set_size): Add function to diff --git a/docs/reference/glib/tmpl/strings.sgml b/docs/reference/glib/tmpl/strings.sgml index 1c435d2..e12793a 100644 --- a/docs/reference/glib/tmpl/strings.sgml +++ b/docs/reference/glib/tmpl/strings.sgml @@ -32,7 +32,7 @@ string. @str: @len: -@alloc: +@allocated_len: diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index f570fc7..de6760e 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -963,6 +963,54 @@ g_strlcat (gchar *dest, } #endif /* ! HAVE_STRLCPY */ +/** + * g_ascii_strdown: + * @string: a string + * + * Converts all upper case ASCII letters to lower case ASCII letters. + * + * 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. + **/ +gchar* +g_ascii_strdown (gchar *string) +{ + gchar *result, *s; + + g_return_val_if_fail (string != NULL, NULL); + + result = g_strdup (string); + for (s = result; *s; s++) + *s = g_ascii_tolower (*s); + + return result; +} + +/** + * g_ascii_strup: + * @string: a string + * + * Converts all lower case ASCII letters to upper case ASCII letters. + * + * 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. + **/ +gchar* +g_ascii_strup (gchar *string) +{ + gchar *s; + + g_return_val_if_fail (string != NULL, NULL); + + result = g_strdup (string); + for (s = result; *s; s++) + *s = g_ascii_toupper (*s); + + return result; +} + gchar* g_strdown (gchar *string) { @@ -1028,6 +1076,219 @@ g_strreverse (gchar *string) return string; } +/** + * g_ascii_isalpha: + * @c: any character + * + * Determines whether a character is alphabetic (i.e. a letter). + * + * Unlike the standard C library isalpha function, this only + * recognizes standard ASCII letters 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 + * on EOF but no need to cast to guchar before passing a possibly + * non-ASCII character in. + * + * Return value: %TRUE if @c is an ASCII alphabetic character + **/ +gboolean +g_ascii_isalpha (gchar c) +{ + return g_ascii_is_lower (c) || g_ascii_is_upper (c); +} + +/** + * g_ascii_isalnum: + * @c: any character + * + * Determines whether a character is alphanumeric. + * + * Unlike the standard C library isalnum function, this only + * recognizes standard ASCII letters 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 + * on EOF but no need to cast to guchar before passing a possibly + * non-ASCII character in. + * + * Return value: %TRUE if @c is an ASCII alphanumeric character + **/ +gboolean +g_ascii_isalnum (gchar c) +{ + return g_ascii_is_alpha (c) || isdigit (c); +} + + +/** + * g_ascii_islower: + * @c: any character + * + * Determines whether a character is an ASCII lower case letter. + * + * Unlike the standard C library islower function, this only + * recognizes standard ASCII letters 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 + * on EOF but no need to worry about casting to guchar before passing + * a possibly non-ASCII character in. + * + * Return value: %TRUE if @c is an ASCII lower case letter + **/ +gboolean +g_ascii_islower (gchar c) +{ + return c >= 'a' && c <= 'z'; +} + +/** + * g_ascii_isupper: + * @c: any character + * + * Determines whether a character is an ASCII upper case letter. + * + * Unlike the standard C library isupper function, this only + * recognizes standard ASCII letters 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 + * on EOF but no need to worry about casting to guchar before passing + * a possibly non-ASCII character in. + * + * Return value: %TRUE if @c is an ASCII upper case letter + **/ +gboolean +g_ascii_isupper (gchar c) +{ + return c >= 'A' && c <= 'Z'; +} + +/** + * g_ascii_tolower: + * @c: any character + * + * Convert a character to ASCII lower case. + * + * Unlike the standard C library tolower function, this only + * recognizes standard ASCII letters and ignores the locale, returning + * all non-ASCII characters unchanged, even if they are lower case + * letters in a particular character set. Also unlike the standard + * library function, this takes and returns a char, not an int, so + * don't call it on EOF but no need to worry about casting to guchar + * before passing a possibly non-ASCII character in. + * + * Return value: the result of converting @c to lower case. + * If @c is not an ASCII upper case letter, + * @c is returned unchanged. + **/ +gchar +g_ascii_tolower (gchar c) +{ + return g_ascii_isupper (c) ? c - 'A' + 'a' : c; +} + +/** + * g_ascii_toupper: + * @c: any character + * + * Convert a character to ASCII upper case. + * + * Unlike the standard C library toupper function, this only + * recognizes standard ASCII letters and ignores the locale, returning + * all non-ASCII characters unchanged, even if they are upper case + * letters in a particular character set. Also unlike the standard + * library function, this takes and returns a char, not an int, so + * don't call it on EOF but no need to worry about casting to guchar + * before passing a possibly non-ASCII character in. + * + * Return value: the result of converting @c to upper case. + * If @c is not an ASCII lower case letter, + * @c is returned unchanged. + **/ +gchar +g_ascii_toupper (gchar c) +{ + return g_ascii_islower (c) ? c - 'a' + 'A' : c; +} + +/** + * g_ascii_strcasecmp: + * @s1: string to compare with @s2 + * @s2: string to compare with @s1 + * + * Compare two strings, ignoring the case of ASCII characters. + * + * Unlike the BSD strcasecmp function, this only recognizes standard + * ASCII letters and ignores the locale, treating all non-ASCII + * characters as if they are not letters. + * + * Return value: an integer less than, equal to, or greater than + * zero if @s1 is found, respectively, to be less than, + * to match, or to be greater than @s2. + **/ +gint +g_ascii_strcasecmp (const gchar *s1, + const gchar *s2) +{ + gint c1, c2; + + g_return_val_if_fail (s1 != NULL, 0); + g_return_val_if_fail (s2 != NULL, 0); + + while (*s1 && *s2) + { + c1 = (gint)(guchar) g_ascii_tolower (*s1); + c2 = (gint)(guchar) g_ascii_tolower (*s2); + if (c1 != c2) + return (c1 - c2); + s1++; s2++; + } + + return (((gint)(guchar) *s1) - ((gint)(guchar) *s2)); +} + +/** + * g_ascii_strncasecmp: + * @s1: string to compare with @s2 + * @s2: string to compare with @s1 + * @n: number of characters to compare + * + * Compare @s1 and @s2, ignoring the case of ASCII characters and any + * characters after the first @n in each string. + * + * Unlike the BSD strcasecmp function, this only recognizes standard + * ASCII letters and ignores the locale, treating all non-ASCII + * characters as if they are not letters. + * + * Return value: an integer less than, equal to, or greater than zero + * if the first @n bytes of @s1 is found, respectively, + * to be less than, to match, or to be greater than the + * first @n bytes of @s2. + **/ +gint +g_ascii_strncasecmp (const gchar *s1, + const gchar *s2, + guint n) +{ + gint c1, c2; + + g_return_val_if_fail (s1 != NULL, 0); + g_return_val_if_fail (s2 != NULL, 0); + + while (n && *s1 && *s2) + { + n -= 1; + c1 = (gint)(guchar) g_ascii_tolower (*s1); + c2 = (gint)(guchar) g_ascii_tolower (*s2); + if (c1 != c2) + return (c1 - c2); + s1++; s2++; + } + + if (n) + return (((gint) (guchar) *s1) - ((gint) (guchar) *s2)); + else + return 0; +} + gint g_strcasecmp (const gchar *s1, const gchar *s2) diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h index 628b3b1..36af2a8 100644 --- a/glib/gstrfuncs.h +++ b/glib/gstrfuncs.h @@ -32,6 +32,14 @@ G_BEGIN_DECLS +/* Functions like the ones in that are not affected by locale. */ +gboolean g_ascii_isalpha (gchar c) G_GNUC_CONST; +gboolean g_ascii_isalnum (gchar c) G_GNUC_CONST; +gboolean g_ascii_islower (gchar c) G_GNUC_CONST; +gboolean g_ascii_isupper (gchar c) G_GNUC_CONST; +gchar g_ascii_tolower (gchar c) G_GNUC_CONST; +gchar g_ascii_toupper (gchar c) G_GNUC_CONST; + /* String utility functions that modify a string argument or * return a constant string that must not be freed. */ @@ -46,13 +54,6 @@ gdouble g_strtod (const gchar *nptr, gchar **endptr); G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST; G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST; -gint g_strcasecmp (const gchar *s1, - const gchar *s2); -gint g_strncasecmp (const gchar *s1, - const gchar *s2, - gsize n); -gchar* g_strdown (gchar *string); -gchar* g_strup (gchar *string); gchar* g_strreverse (gchar *string); gsize g_strlcpy (gchar *dest, const gchar *src, @@ -76,6 +77,31 @@ gchar* g_strchomp (gchar *string); /* removes leading & trailing spaces */ #define g_strstrip( string ) g_strchomp (g_strchug (string)) +gint g_ascii_strcasecmp (const gchar *s1, + const gchar *s2); +gint g_ascii_strncasecmp (const gchar *s1, + const gchar *s2, + guint n); +gchar* g_ascii_strdown (gchar *string); +gchar* g_ascii_strup (gchar *string); + +#ifndef G_DISABLE_DEPRECATED + +/* The following four functions are deprecated and will be removed in + * the next major release. They use the locale-specific tolower and + * toupper, which is almost never the right thing. + */ + +gint g_strcasecmp (const gchar *s1, + const gchar *s2); +gint g_strncasecmp (const gchar *s1, + const gchar *s2, + guint n); +gchar* g_strdown (gchar *string); +gchar* g_strup (gchar *string); + +#endif /* G_DISABLE_DEPRECATED */ + /* String utility functions that return a newly allocated string which * ought to be freed with g_free from the caller at some point. */ diff --git a/glib/gstring.c b/glib/gstring.c index bc450e4..58909cb 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -565,6 +565,66 @@ g_string_erase (GString *fstring, return fstring; } +/** + * g_string_ascii_down: + * @string: a GString + * + * Converts all upper case ASCII letters to lower case ASCII letters. + * + * Return value: passed-in @string pointer, with all the upper case + * characters converted to lower case in place, with + * semantics that exactly match g_ascii_tolower. + **/ +GString* +g_string_ascii_down (GString *string) +{ + gchar *s; + gint n = string->len; + + g_return_val_if_fail (string != NULL, NULL); + + s = string->str; + + while (n) + { + *s = g_ascii_tolower (*s); + s++; + n--; + } + + return string; +} + +/** + * g_string_ascii_up: + * @string: a GString + * + * Converts all lower case ASCII letters to upper case ASCII letters. + * + * Return value: passed-in @string pointer, with all the lower case + * characters converted to upper case in place, with + * semantics that exactly match g_ascii_toupper. + **/ +GString* +g_string_ascii_up (GString *string) +{ + gchar *s; + gint n = string->len; + + g_return_val_if_fail (string != NULL, NULL); + + s = string->str; + + while (n) + { + *s = g_ascii_toupper (*s); + s++; + n--; + } + + return string; +} + GString* g_string_down (GString *fstring) { @@ -578,7 +638,8 @@ g_string_down (GString *fstring) while (n) { - *s = tolower (*s); + if (isupper (*s)) + *s = tolower (*s); s++; n--; } @@ -599,7 +660,8 @@ g_string_up (GString *fstring) while (n) { - *s = toupper (*s); + if (islower (*s)) + *s = toupper (*s); s++; n--; } diff --git a/glib/gstring.h b/glib/gstring.h index 4337f3c..fe42491 100644 --- a/glib/gstring.h +++ b/glib/gstring.h @@ -95,18 +95,33 @@ GString* g_string_insert_c (GString *string, GString* g_string_erase (GString *string, gsize pos, gsize len); -GString* g_string_down (GString *string); -GString* g_string_up (GString *string); +GString* g_string_ascii_down (GString *string); +GString* g_string_ascii_up (GString *string); void g_string_printf (GString *string, const gchar *format, ...) G_GNUC_PRINTF (2, 3); void g_string_printfa (GString *string, const gchar *format, ...) G_GNUC_PRINTF (2, 3); -/* compatibility */ + +#ifndef G_DISABLE_DEPRECATED + +#ifndef G_DISABLE_DEPRECATED + +/* The following two functions are deprecated and will be removed in + * the next major release. They use the locale-specific tolower and + * toupper, which is almost never the right thing. + */ + +GString* g_string_down (GString *string); +GString* g_string_up (GString *string); + +/* These aliases are included for compatibility. */ #define g_string_sprintf g_string_printf #define g_string_sprintfa g_string_printfa +#endif /* G_DISABLE_DEPRECATED */ + G_END_DECLS #endif /* __G_STRING_H__ */ diff --git a/glib/gutils.c b/glib/gutils.c index e4cc7a6..24d7ad9 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -48,7 +48,7 @@ #include #endif -/* implement Glib's inline functions +/* implement gutils's inline functions */ #define G_IMPLEMENT_INLINES 1 #define __G_UTILS_C__ @@ -430,7 +430,7 @@ g_parse_debug_string (const gchar *string, g_return_val_if_fail (string != NULL, 0); - if (!g_strcasecmp (string, "all")) + if (!g_ascii_strcasecmp (string, "all")) { for (i=0; i 0); - g_assert (g_strcasecmp ("b", "A") > 0); - g_assert (g_strcasecmp ("B", "a") > 0); - g_assert (g_strcasecmp ("B", "A") > 0); + g_print ("checking g_ascii_strcasecmp..."); + g_assert (g_ascii_strcasecmp ("FroboZZ", "frobozz") == 0); + g_assert (g_ascii_strcasecmp ("frobozz", "frobozz") == 0); + g_assert (g_ascii_strcasecmp ("frobozz", "FROBOZZ") == 0); + g_assert (g_ascii_strcasecmp ("FROBOZZ", "froboz") > 0); + g_assert (g_ascii_strcasecmp ("", "") == 0); + g_assert (g_ascii_strcasecmp ("!#%&/()", "!#%&/()") == 0); + g_assert (g_ascii_strcasecmp ("a", "b") < 0); + g_assert (g_ascii_strcasecmp ("a", "B") < 0); + g_assert (g_ascii_strcasecmp ("A", "b") < 0); + g_assert (g_ascii_strcasecmp ("A", "B") < 0); + g_assert (g_ascii_strcasecmp ("b", "a") > 0); + g_assert (g_ascii_strcasecmp ("b", "A") > 0); + g_assert (g_ascii_strcasecmp ("B", "a") > 0); + g_assert (g_ascii_strcasecmp ("B", "A") > 0); g_print ("ok\n"); -- 2.7.4