<NAME>G_OS_BEOS</NAME>
#define G_OS_BEOS
</MACRO>
+
+# g_ascii_isxxx
+
+<FUNCTION>
+<NAME>g_ascii_isalnum</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isalpha</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_iscntrl</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isdigit</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isgraph</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_islower</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isprint</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_ispunct</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isspace</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isupper</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
+
+<FUNCTION>
+<NAME>g_ascii_isxdigit</NAME>
+<RETURNS>gboolean</RETURNS>
+gchar c
+</FUNCTION>
g_printf_string_upper_bound
<SUBSECTION>
+g_ascii_isalnum
+g_ascii_isalpha
+g_ascii_iscntrl
+g_ascii_isdigit
+g_ascii_isgraph
+g_ascii_islower
+g_ascii_isprint
+g_ascii_ispunct
+g_ascii_isspace
+g_ascii_isupper
+g_ascii_isxdigit
+
+<SUBSECTION>
+g_ascii_digit_value
+g_ascii_xdigit_value
+
+<SUBSECTION>
+g_ascii_strcasecmp
+g_ascii_strncasecmp
+
+<SUBSECTION>
+g_ascii_strup
+g_ascii_strdown
+
+<SUBSECTION>
+g_ascii_tolower
+g_ascii_toupper
+
+<SUBSECTION>
+g_string_ascii_up
+g_string_ascii_down
+
+<SUBSECTION>
g_strup
g_strdown
@Returns: the maximum space needed to store the formatted string.
+<!-- ##### FUNCTION g_ascii_isalnum ##### -->
+<para>
+Determines whether a character is alphanumeric.
+</para>
+<para>
+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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII alphanumeric character
+
+
+<!-- ##### FUNCTION g_ascii_isalpha ##### -->
+<para>
+Determines whether a character is alphabetic (i.e. a letter).
+</para>
+<para>
+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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII alphabetic character
+
+
+<!-- ##### FUNCTION g_ascii_iscntrl ##### -->
+<para>
+Determines whether a character is a control character.
+</para>
+<para>
+Unlike the standard C library iscntrl function, this only
+recognizes standard ASCII control characters 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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII control character.
+
+
+<!-- ##### FUNCTION g_ascii_isdigit ##### -->
+<para>
+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
+on EOF but no need to cast to guchar before passing a possibly
+non-ASCII character in.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII digit.
+
+
+<!-- ##### FUNCTION g_ascii_isgraph ##### -->
+<para>
+Determines whether a character is a printing character and not a space.
+</para>
+<para>
+Unlike the standard C library isgraph function, this only
+recognizes standard ASCII characters 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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII printing character other than space.
+
+
+<!-- ##### FUNCTION g_ascii_islower ##### -->
+<para>
+Determines whether a character is an ASCII lower case letter.
+</para>
+<para>
+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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII lower case letter
+
+
+<!-- ##### FUNCTION g_ascii_isprint ##### -->
+<para>
+Determines whether a character is a printing character.
+</para>
+<para>
+Unlike the standard C library isprint function, this only
+recognizes standard ASCII characters 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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII printing character.
+
+
+<!-- ##### FUNCTION g_ascii_ispunct ##### -->
+<para>
+Determines whether a character is a punctuation character.
+</para>
+<para>
+Unlike the standard C library ispunct 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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII punctuation character.
+
+
+<!-- ##### FUNCTION g_ascii_isspace ##### -->
+<para>
+Determines whether a character is a white-space character.
+</para>
+<para>
+Unlike the standard C library isspace function, this only
+recognizes standard ASCII white-space 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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII white-space character
+
+
+<!-- ##### FUNCTION g_ascii_isupper ##### -->
+<para>
+Determines whether a character is an ASCII upper case letter.
+</para>
+<para>
+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.
+</para>
+
+@c: any characted
+@Returns: %TRUE if @c is an ASCII upper case letter
+
+
+<!-- ##### FUNCTION g_ascii_isxdigit ##### -->
+<para>
+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
+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
+@Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
+
+
+<!-- ##### FUNCTION g_ascii_digit_value ##### -->
+<para>
+
+</para>
+
+@c:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_xdigit_value ##### -->
+<para>
+
+</para>
+
+@c:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_strcasecmp ##### -->
+<para>
+
+</para>
+
+@s1:
+@s2:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_strncasecmp ##### -->
+<para>
+
+</para>
+
+@s1:
+@s2:
+@n:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_strup ##### -->
+<para>
+
+</para>
+
+@string:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_strdown ##### -->
+<para>
+
+</para>
+
+@string:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_tolower ##### -->
+<para>
+
+</para>
+
+@c:
+@Returns:
+
+
+<!-- ##### FUNCTION g_ascii_toupper ##### -->
+<para>
+
+</para>
+
+@c:
+@Returns:
+
+
+<!-- ##### FUNCTION g_string_ascii_up ##### -->
+<para>
+
+</para>
+
+@string:
+@Returns:
+
+
+<!-- ##### FUNCTION g_string_ascii_down ##### -->
+<para>
+
+</para>
+
+@string:
+@Returns:
+
+
<!-- ##### FUNCTION g_strup ##### -->
<para>
Converts a string to upper case.
* inteferes with g_strsignal() on some OSes
*/
+const guint16 g_ascii_table[256] = {
+ 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
+ 0x004, 0x104, 0x104, 0x004, 0x104, 0x104, 0x004, 0x004,
+ 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
+ 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
+ 0x140, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
+ 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
+ 0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459,
+ 0x459, 0x459, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
+ 0x0d0, 0x653, 0x653, 0x653, 0x653, 0x653, 0x653, 0x253,
+ 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
+ 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
+ 0x253, 0x253, 0x253, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
+ 0x0d0, 0x473, 0x473, 0x473, 0x473, 0x473, 0x473, 0x073,
+ 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
+ 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
+ 0x073, 0x073, 0x073, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x004
+ /* the upper 128 are all zeroes */
+};
+
gchar*
g_strdup (const gchar *str)
{
}
/**
- * 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_islower (c) || g_ascii_isupper (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_isalpha (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
*
}
/**
+ * g_ascii_digit_value:
+ * @c: an ASCII character
+ *
+ * Determines the numeric value of a character as a decimal
+ * digit. Differs from g_unichar_digit_value because it takes
+ * a char, so there's no worry about sign extension if characters
+ * are signed.
+ *
+ * Return value: If @c is a decimal digit (according to
+ * `g_ascii_isdigit'), its numeric value. Otherwise, -1.
+ **/
+int
+g_ascii_digit_value (gchar c)
+{
+ if (g_ascii_isdigit (c))
+ return c - '0';
+ return -1;
+}
+
+/**
+ * g_ascii_xdigit_value:
+ * @c: an ASCII character
+ *
+ * Determines the numeric value of a character as a hexidecimal
+ * digit. Differs from g_unichar_xdigit_value because it takes
+ * a char, so there's no worry about sign extension if characters
+ * are signed.
+ *
+ * Return value: If @c is a hex digit (according to
+ * `g_ascii_isxdigit'), its numeric value. Otherwise, -1.
+ **/
+int
+g_ascii_xdigit_value (gchar c)
+{
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ return g_ascii_digit_value (c);
+}
+
+/**
* g_ascii_strcasecmp:
* @s1: string to compare with @s2
* @s2: string to compare with @s1
G_BEGIN_DECLS
/* Functions like the ones in <ctype.h> 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;
+typedef enum {
+ G_ASCII_ALNUM = 1 << 0,
+ G_ASCII_ALPHA = 1 << 1,
+ G_ASCII_CNTRL = 1 << 2,
+ G_ASCII_DIGIT = 1 << 3,
+ G_ASCII_GRAPH = 1 << 4,
+ G_ASCII_LOWER = 1 << 5,
+ G_ASCII_PRINT = 1 << 6,
+ G_ASCII_PUNCT = 1 << 7,
+ G_ASCII_SPACE = 1 << 8,
+ G_ASCII_UPPER = 1 << 9,
+ G_ASCII_XDIGIT = 1 << 10
+} GAsciiType;
+
+extern const guint16 g_ascii_table[256];
+
+#define g_ascii_isalnum(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0)
+
+#define g_ascii_isalpha(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0)
+
+#define g_ascii_iscntrl(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0)
+
+#define g_ascii_isdigit(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0)
+
+#define g_ascii_isgraph(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0)
+
+#define g_ascii_islower(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0)
+
+#define g_ascii_isprint(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0)
+
+#define g_ascii_ispunct(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0)
+
+#define g_ascii_isspace(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0)
+
+#define g_ascii_isupper(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0)
+
+#define g_ascii_isxdigit(c) \
+ ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0)
+
gchar g_ascii_tolower (gchar c) G_GNUC_CONST;
gchar g_ascii_toupper (gchar c) G_GNUC_CONST;
+gint g_ascii_digit_value (gchar c) G_GNUC_CONST;
+gint g_ascii_xdigit_value (gchar c) G_GNUC_CONST;
+
/* String utility functions that modify a string argument or
* return a constant string that must not be freed.
*/
* g_unichar_ispunct:
* @c: a Unicode character
*
- * Determines whether a character is punctuation.
+ * Determines whether a character is punctuation or a symbol.
* Given some UTF-8 text, obtain a character value with
* g_utf8_get_char().
*
- * Return value: %TRUE if @c is a punctuation character
+ * Return value: %TRUE if @c is a punctuation or symbol character
**/
gboolean
g_unichar_ispunct (gunichar c)
return (t == G_UNICODE_CONNECT_PUNCTUATION || t == G_UNICODE_DASH_PUNCTUATION
|| t == G_UNICODE_CLOSE_PUNCTUATION || t == G_UNICODE_FINAL_PUNCTUATION
|| t == G_UNICODE_INITIAL_PUNCTUATION || t == G_UNICODE_OTHER_PUNCTUATION
- || t == G_UNICODE_OPEN_PUNCTUATION);
+ || t == G_UNICODE_OPEN_PUNCTUATION || t == G_UNICODE_CURRENCY_SYMBOL
+ || t == G_UNICODE_MODIFIER_SYMBOL || t == G_UNICODE_MATH_SYMBOL
+ || t == G_UNICODE_OTHER_SYMBOL);
}
/**
case '\n':
case '\r':
case '\f':
- case '\v': /* vertical tab - as if anyone has ever used this... */
return TRUE;
break;
* @c: a unicode character
*
* Determines the numeric value of a character as a decimal
- * degital.
+ * digit.
*
* Return value: If @c is a decimal digit (according to
* `g_unichar_isdigit'), its numeric value. Otherwise, -1.
* @c: a unicode character
*
* Determines the numeric value of a character as a hexidecimal
- * degital.
+ * digit.
*
* Return value: If @c is a hex digit (according to
* `g_unichar_isxdigit'), its numeric value. Otherwise, -1.
{
gint i;
- printf ("\nCommand line was: '%s'\n", cmdline);
+ fprintf (stderr, "Command line was: '%s'\n", cmdline);
- printf ("Expected result (%d args):\n", result->argc);
+ fprintf (stderr, "Expected result (%d args):\n", result->argc);
i = 0;
while (result->argv[i])
{
- printf (" %3d '%s'\n", i, result->argv[i]);
-
+ fprintf (stderr, " %3d '%s'\n", i, result->argv[i]);
++i;
}
- printf ("Actual result (%d args):\n", argc);
+ fprintf (stderr, "Actual result (%d args):\n", argc);
i = 0;
while (argv[i])
{
- printf (" %3d '%s'\n", i, argv[i]);
-
+ fprintf (stderr, " %3d '%s'\n", i, argv[i]);
++i;
}
}
i = 0;
while (test_command_lines[i])
{
- printf ("g_shell_parse_argv() test %d - ", i);
do_argv_test (test_command_lines[i], &correct_results[i]);
- printf ("ok (%s)\n", test_command_lines[i]);
-
++i;
}
}
#include <string.h>
#include "glib.h"
#include <stdarg.h>
+#include <ctype.h>
static gboolean any_failed = FALSE;
static gboolean failed = FALSE;
#define TEST(m,cond) G_STMT_START { failed = !(cond); \
if (failed) \
{ if (!m) \
- g_print ("\n(%s:%d) failed for: %s\n", __FILE__, __LINE__, ( # cond )); \
+ g_print ("(%s:%d) failed for: %s\n", __FILE__, __LINE__, ( # cond )); \
else \
- g_print ("\n(%s:%d) failed for: %s: (%s)\n", __FILE__, __LINE__, ( # cond ), (gchar*)m); \
- any_failed = TRUE; \
+ g_print ("(%s:%d) failed for: %s: (%s)\n", __FILE__, __LINE__, ( # cond ), (gchar*)m); \
+ fflush (stdout); \
+ any_failed = TRUE; \
} \
-else \
- g_print ("."); fflush (stdout); \
} G_STMT_END
+#define TEST_FAILED(message) \
+ G_STMT_START { g_print ("Error: "); g_print message; g_print ("\n"); any_failed = TRUE; } G_STMT_END
+
#define GLIB_TEST_STRING "el dorado "
static gboolean
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);
+}
+
+
+
+static void
+test_is_function (const char *name,
+ gboolean (* ascii_function) (gchar),
+ int (* c_library_function) (int),
+ gboolean (* unicode_function) (gunichar))
+{
+ int c;
+
+ for (c = 0; c <= 0x7F; c++)
+ {
+ gboolean ascii_result = ascii_function ((gchar)c);
+ gboolean c_library_result = c_library_function (c) != 0;
+ gboolean unicode_result = unicode_function ((gunichar) c);
+ if (ascii_result != c_library_result && c != '\v')
+ TEST_FAILED (("g_ascii_%s returned %d and %s returned %d for 0x%X",
+ name, ascii_result, name, c_library_result, c));
+ if (ascii_result != unicode_result)
+ TEST_FAILED (("g_ascii_%s returned %d and g_unichar_%s returned %d for 0x%X",
+ name, ascii_result, name, unicode_result, c));
+ }
+ for (c = 0x80; c <= 0xFF; c++)
+ {
+ gboolean ascii_result = ascii_function ((gchar)c);
+ if (ascii_result)
+ TEST_FAILED (("g_ascii_%s returned TRUE for 0x%X",
+ name, c));
+ }
+}
+
+static void
+test_to_function (const char *name,
+ gchar (* ascii_function) (gchar),
+ int (* c_library_function) (int),
+ gunichar (* unicode_function) (gunichar))
+{
+ int c;
+
+ for (c = 0; c <= 0x7F; c++)
+ {
+ int ascii_result = (guchar) ascii_function ((gchar) c);
+ int c_library_result = c_library_function (c);
+ int unicode_result = unicode_function ((gunichar) c);
+ if (ascii_result != c_library_result)
+ TEST_FAILED (("g_ascii_%s returned 0x%X and %s returned 0x%X for 0x%X",
+ name, ascii_result, name, c_library_result, c));
+ if (ascii_result != unicode_result)
+ TEST_FAILED (("g_ascii_%s returned 0x%X and g_unichar_%s returned 0x%X for 0x%X",
+ name, ascii_result, name, unicode_result, c));
+ }
+ for (c = 0x80; c <= 0xFF; c++)
+ {
+ int ascii_result = (guchar) ascii_function ((gchar) c);
+ if (ascii_result != c)
+ TEST_FAILED (("g_ascii_%s returned 0x%X for 0x%X",
+ name, ascii_result, c));
+ }
+}
+
+static void
+test_digit_function (const char *name,
+ int (* ascii_function) (gchar),
+ int (* unicode_function) (gunichar))
+{
+ int c;
+
+ for (c = 0; c <= 0x7F; c++)
+ {
+ int ascii_result = ascii_function ((gchar) c);
+ int unicode_result = unicode_function ((gunichar) c);
+ if (ascii_result != unicode_result)
+ TEST_FAILED (("g_ascii_%s_value returned %d and g_unichar_%s_value returned %d for 0x%X",
+ name, ascii_result, name, unicode_result, c));
+ }
+ for (c = 0x80; c <= 0xFF; c++)
+ {
+ int ascii_result = ascii_function ((gchar) c);
+ if (ascii_result != -1)
+ TEST_FAILED (("g_ascii_%s_value returned %d for 0x%X",
+ name, ascii_result, c));
+ }
+}
+
int
main (int argc,
char *argv[])
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));
- g_print ("\n");
+ #define TEST_IS(name) test_is_function (#name, test_##name, 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);
+
+ #undef TEST_IS
+
+ #define TEST_TO(name) test_to_function (#name, g_ascii_##name, name, g_unichar_##name)
+
+ TEST_TO (tolower);
+ TEST_TO (toupper);
+
+ #undef TEST_TO
+
+ #define TEST_DIGIT(name) test_digit_function (#name, g_ascii_##name##_value, g_unichar_##name##_value)
+
+ TEST_DIGIT (digit);
+ TEST_DIGIT (xdigit);
+
+ #undef TEST_DIGIT
return any_failed;
}