mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Patch from Darin Adler (#54166)
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com> 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.
This commit is contained in:
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -1,3 +1,21 @@
|
||||
Sat Jun 30 12:49:26 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
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 <otaylor@redhat.com>
|
||||
|
||||
* glib/gstring.[ch] (g_string_set_size): Add function to
|
||||
|
@@ -32,7 +32,7 @@ string.
|
||||
|
||||
@str:
|
||||
@len:
|
||||
@alloc:
|
||||
@allocated_len:
|
||||
|
||||
<!-- ##### FUNCTION g_string_new ##### -->
|
||||
<para>
|
||||
|
261
glib/gstrfuncs.c
261
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)
|
||||
|
@@ -32,6 +32,14 @@
|
||||
|
||||
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;
|
||||
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.
|
||||
*/
|
||||
|
@@ -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--;
|
||||
}
|
||||
|
@@ -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__ */
|
||||
|
@@ -48,7 +48,7 @@
|
||||
#include <sys/param.h>
|
||||
#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<nkeys; i++)
|
||||
result |= keys[i].value;
|
||||
@@ -451,7 +451,7 @@ g_parse_debug_string (const gchar *string,
|
||||
}
|
||||
|
||||
for (i=0; i<nkeys; i++)
|
||||
if (g_strncasecmp(keys[i].key, p, q - p) == 0 &&
|
||||
if (g_ascii_strncasecmp(keys[i].key, p, q - p) == 0 &&
|
||||
keys[i].key[q - p] == '\0')
|
||||
result |= keys[i].value;
|
||||
|
||||
@@ -474,7 +474,7 @@ g_basename (const gchar *file_name)
|
||||
return base + 1;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (isalpha (file_name[0]) && file_name[1] == ':')
|
||||
if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
|
||||
return (gchar*) file_name + 2;
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
@@ -505,7 +505,7 @@ g_path_get_basename (const gchar *file_name)
|
||||
return g_strdup (G_DIR_SEPARATOR_S);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (last_nonslash == 1 && isalpha (file_name[0]) && file_name[1] == ':')
|
||||
if (last_nonslash == 1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
|
||||
/* string only containing slashes and a drive */
|
||||
return g_strdup (G_DIR_SEPARATOR_S);
|
||||
#endif /* G_OS_WIN32 */
|
||||
@@ -516,7 +516,7 @@ g_path_get_basename (const gchar *file_name)
|
||||
base--;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (base == -1 && isalpha (file_name[0]) && file_name[1] == ':')
|
||||
if (base == -1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
|
||||
base = 1;
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
@@ -537,7 +537,7 @@ g_path_is_absolute (const gchar *file_name)
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Recognize drive letter on native Windows */
|
||||
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
|
||||
if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
|
||||
return TRUE;
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
@@ -584,7 +584,7 @@ g_path_skip_root (const gchar *file_name)
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Skip X:\ */
|
||||
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
|
||||
if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
|
||||
return (gchar *)file_name + 3;
|
||||
#endif
|
||||
|
||||
|
@@ -904,8 +904,8 @@ get_package_directory_from_module (gchar *module_name)
|
||||
if (module_name)
|
||||
{
|
||||
p = strrchr (fn, G_DIR_SEPARATOR);
|
||||
if (p && (g_strcasecmp (p + 1, "bin") == 0 ||
|
||||
g_strcasecmp (p + 1, "lib") == 0))
|
||||
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0 ||
|
||||
g_ascii_strcasecmp (p + 1, "lib") == 0))
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
@@ -929,21 +929,21 @@ main (int argc,
|
||||
|
||||
g_print ("ok\n");
|
||||
|
||||
g_print ("checking g_strcasecmp...");
|
||||
g_assert (g_strcasecmp ("FroboZZ", "frobozz") == 0);
|
||||
g_assert (g_strcasecmp ("frobozz", "frobozz") == 0);
|
||||
g_assert (g_strcasecmp ("frobozz", "FROBOZZ") == 0);
|
||||
g_assert (g_strcasecmp ("FROBOZZ", "froboz") != 0);
|
||||
g_assert (g_strcasecmp ("", "") == 0);
|
||||
g_assert (g_strcasecmp ("!#%&/()", "!#%&/()") == 0);
|
||||
g_assert (g_strcasecmp ("a", "b") < 0);
|
||||
g_assert (g_strcasecmp ("a", "B") < 0);
|
||||
g_assert (g_strcasecmp ("A", "b") < 0);
|
||||
g_assert (g_strcasecmp ("A", "B") < 0);
|
||||
g_assert (g_strcasecmp ("b", "a") > 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");
|
||||
|
||||
|
Reference in New Issue
Block a user