mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
rewrite, based on bug #52328 from Anders
2001-03-20 Havoc Pennington <hp@redhat.com> * gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from Anders
This commit is contained in:
parent
fad8693b76
commit
767800fcb3
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-20 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
|
||||||
|
Anders
|
||||||
|
|
||||||
2001-03-19 Havoc Pennington <hp@redhat.com>
|
2001-03-19 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gutf8.c (g_unichar_validate): added this function
|
* gutf8.c (g_unichar_validate): added this function
|
||||||
|
39
glib/gutf8.c
39
glib/gutf8.c
@ -206,20 +206,35 @@ g_utf8_strlen (const gchar *p, gint max)
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
const gchar *start = p;
|
const gchar *start = p;
|
||||||
/* special case for the empty string */
|
|
||||||
if (!*p)
|
if (max < 0)
|
||||||
return 0;
|
|
||||||
/* Note that the test here and the test in the loop differ subtly.
|
|
||||||
In the loop we want to see if we've passed the maximum limit --
|
|
||||||
for instance if the buffer ends mid-character. Here at the top
|
|
||||||
of the loop we want to see if we've just reached the last byte. */
|
|
||||||
while (max < 0 || p - start < max)
|
|
||||||
{
|
{
|
||||||
p = g_utf8_next_char (p);
|
while (*p)
|
||||||
++len;
|
{
|
||||||
if (! *p || (max > 0 && p - start > max))
|
p = g_utf8_next_char (p);
|
||||||
break;
|
++len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (max == 0 || !*p)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p = g_utf8_next_char (p);
|
||||||
|
|
||||||
|
while (p - start < max && *p)
|
||||||
|
{
|
||||||
|
++len;
|
||||||
|
p = g_utf8_next_char (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* only do the last len increment if we got a complete
|
||||||
|
* char (don't count partial chars)
|
||||||
|
*/
|
||||||
|
if (p - start == max)
|
||||||
|
++len;
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
gutf8.c
39
gutf8.c
@ -206,20 +206,35 @@ g_utf8_strlen (const gchar *p, gint max)
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
const gchar *start = p;
|
const gchar *start = p;
|
||||||
/* special case for the empty string */
|
|
||||||
if (!*p)
|
if (max < 0)
|
||||||
return 0;
|
|
||||||
/* Note that the test here and the test in the loop differ subtly.
|
|
||||||
In the loop we want to see if we've passed the maximum limit --
|
|
||||||
for instance if the buffer ends mid-character. Here at the top
|
|
||||||
of the loop we want to see if we've just reached the last byte. */
|
|
||||||
while (max < 0 || p - start < max)
|
|
||||||
{
|
{
|
||||||
p = g_utf8_next_char (p);
|
while (*p)
|
||||||
++len;
|
{
|
||||||
if (! *p || (max > 0 && p - start > max))
|
p = g_utf8_next_char (p);
|
||||||
break;
|
++len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (max == 0 || !*p)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p = g_utf8_next_char (p);
|
||||||
|
|
||||||
|
while (p - start < max && *p)
|
||||||
|
{
|
||||||
|
++len;
|
||||||
|
p = g_utf8_next_char (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* only do the last len increment if we got a complete
|
||||||
|
* char (don't count partial chars)
|
||||||
|
*/
|
||||||
|
if (p - start == max)
|
||||||
|
++len;
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user