gst/typefind/gsttypefindfunctions.c: Remove part from previous commit that was bogus: g_utf8_validate() does in fact ...
Original commit message from CVS: * gst/typefind/gsttypefindfunctions.c: (utf8_type_find_have_valid_utf8_at_offset): Remove part from previous commit that was bogus: g_utf8_validate() does in fact not accept embedded zeroes, so we don't need to check for those (thanks to Mike for the hint).
This commit is contained in:
parent
ca6e20ae1a
commit
7aff0dfe96
@ -1,3 +1,12 @@
|
|||||||
|
2006-03-09 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* gst/typefind/gsttypefindfunctions.c:
|
||||||
|
(utf8_type_find_have_valid_utf8_at_offset):
|
||||||
|
Remove part from previous commit that was bogus:
|
||||||
|
g_utf8_validate() does in fact not accept embedded
|
||||||
|
zeroes, so we don't need to check for those (thanks
|
||||||
|
to Mike for the hint).
|
||||||
|
|
||||||
2006-03-08 Tim-Philipp Müller <tim at centricular dot net>
|
2006-03-08 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst/typefind/gsttypefindfunctions.c:
|
* gst/typefind/gsttypefindfunctions.c:
|
||||||
|
@ -46,20 +46,6 @@ static GstStaticCaps utf8_caps = GST_STATIC_CAPS ("text/plain");
|
|||||||
|
|
||||||
#define UTF8_CAPS gst_static_caps_get(&utf8_caps)
|
#define UTF8_CAPS gst_static_caps_get(&utf8_caps)
|
||||||
|
|
||||||
static guint
|
|
||||||
utf8_type_find_count_embedded_zeroes (const gchar * data, guint size)
|
|
||||||
{
|
|
||||||
guint num = 0;
|
|
||||||
|
|
||||||
while (size > 0) {
|
|
||||||
if (data[size - 1] == 0)
|
|
||||||
++num;
|
|
||||||
--size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset,
|
utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset,
|
||||||
GstTypeFindProbability * prob)
|
GstTypeFindProbability * prob)
|
||||||
@ -80,11 +66,8 @@ utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset,
|
|||||||
gchar *start = (gchar *) data;
|
gchar *start = (gchar *) data;
|
||||||
|
|
||||||
if (g_utf8_validate (start, size, (const gchar **) &end) || (end - start + 4 > size)) { /* allow last char to be cut off */
|
if (g_utf8_validate (start, size, (const gchar **) &end) || (end - start + 4 > size)) { /* allow last char to be cut off */
|
||||||
/* embedded zeroes are a sure sign that this isn't a plain text file */
|
*prob = probability;
|
||||||
if (utf8_type_find_count_embedded_zeroes (start, size) <= 2) {
|
return TRUE;
|
||||||
*prob = probability;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*prob = 0;
|
*prob = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user