+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
+2002-07-26 Matthias Clasen <maclas@gmx.de>
+
+ * glib/gunicode.h:
+ * glib/gutf8.c (g_utf8_strreverse): New function to revert
+ a utf8 string.
+ * glib/gpattern.c (g_utf8_reverse): Gone, replaced by
+ g_utf8_strreverse. (#87725)
+
Thu Jul 25 20:57:20 2002 Owen Taylor <otaylor@redhat.com>
* glib/giochannel.c (g_io_channel_read_line): Fix
/* --- functions --- */
-/**
- * g_utf8_reverse:
- * @string: a UTF-8 string.
- *
- * Reverses a UTF-8 string. The @string must be valid UTF-8 encoded text.
- * (Use g_utf8_validate() on all text before trying to use UTF-8
- * utility functions with it.)
- *
- * Note that unlike g_strreverse(), this function returns
- * newly-allocated memory, which should be freed with g_free() when
- * no longer needed.
- *
- * Returns: a newly-allocated string which is the reverse of @string.
- */
-static gchar *
-g_utf8_reverse (guint len, const gchar *string)
-{
- gchar *result;
- const gchar *p;
- gchar *m, *r, skip;
-
- result = g_new (gchar, len + 1);
- r = result + len;
- p = string;
- while (*p)
- {
- skip = g_utf8_skip[*(guchar*)p];
- r -= skip;
- for (m = r; skip; skip--)
- *m++ = *p++;
- }
- result[len] = 0;
-
- return result;
-}
static inline gboolean
g_pattern_ph_match (const gchar *match_pattern,
{
gboolean result;
gchar *tmp;
- tmp = g_utf8_reverse (string_length, string);
+ tmp = g_utf8_strreverse (string, string_length);
result = g_pattern_ph_match (pspec->pattern, tmp);
g_free (tmp);
return result;
pspec->match_type = tj_pos > hj_pos ? G_MATCH_ALL_TAIL : G_MATCH_ALL;
if (pspec->match_type == G_MATCH_ALL_TAIL) {
gchar *tmp = pspec->pattern;
- pspec->pattern = g_utf8_reverse (pspec->pattern_length, pspec->pattern);
+ pspec->pattern = g_utf8_strreverse (pspec->pattern, pspec->pattern_length);
g_free (tmp);
}
return pspec;
gchar* g_utf8_strrchr (const gchar *p,
gssize len,
gunichar c);
+gchar* g_utf8_strreverse (const gchar *str,
+ gssize len);
gunichar2 *g_utf8_to_utf16 (const gchar *str,
glong len,
{
return UNICODE_VALID (ch);
}
+
+/**
+ * g_utf8_strreverse:
+ * @str: a UTF-8 encoded string
+ * @len: the maximum length of @str to use. If @len < 0, then
+ * the string is nul-terminated.
+ *
+ * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
+ * (Use g_utf8_validate() on all text before trying to use UTF-8
+ * utility functions with it.)
+ *
+ * Note that unlike g_strreverse(), this function returns
+ * newly-allocated memory, which should be freed with g_free() when
+ * no longer needed.
+ *
+ * Returns: a newly-allocated string which is the reverse of @str.
+ */
+gchar *
+g_utf8_strreverse (const gchar *str,
+ gssize len)
+{
+ gchar *result;
+ const gchar *p;
+ gchar *m, *r, skip;
+
+ if (len < 0)
+ len = strlen (str);
+
+ result = g_new (gchar, len + 1);
+ r = result + len;
+ p = str;
+ while (*p)
+ {
+ skip = g_utf8_skip[*(guchar*)p];
+ r -= skip;
+ for (m = r; skip; skip--)
+ *m++ = *p++;
+ }
+ result[len] = 0;
+
+ return result;
+}